Explorar o código

二级市场订单修改

linbl %!s(int64=2) %!d(string=hai) anos
pai
achega
143299367c

+ 69 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/MethodOrdersService.java

@@ -0,0 +1,69 @@
+package com.pj.tb_orders;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.tb_demand_quotation.TbDemandQuotation;
+import com.pj.tb_demand_quotation.TbDemandQuotationService;
+import com.pj.tb_goods_demand.TbGoodsDemand;
+import com.pj.tb_goods_demand.TbGoodsDemandService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 二级市场订单-抽取方法公共类
+ * @Author lbl
+ * @Date 2023 08 09
+ **/
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class MethodOrdersService {
+    @Autowired
+    private TbGoodsDemandService goodsDemandService;
+    @Autowired
+    private TbDemandQuotationService demandQuotationService;
+
+    // 公共方法:TbOrders数据封装成TbOrdersDto
+    List<TbOrdersDto> getTbOrdersDto(List<TbOrders> orderList) {
+
+        List<TbOrdersDto> ordersDtoList = new ArrayList<>();
+
+        orderList.forEach(order -> {
+            TbOrdersDto ordersDto = new TbOrdersDto();
+            BeanUtils.copyProperties(order,ordersDto);
+
+
+            // 需求表主键Id
+            Long goodsDemandId = ordersDto.getFkGoodsDemandId();
+            // 获取订单关联的需求表信息
+            TbGoodsDemand goodsDemand = goodsDemandService.getById(goodsDemandId);
+            ordersDto.setGoodsImg(goodsDemand.getGoodsImg());
+            ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
+            ordersDto.setRemark(goodsDemand.getRemark());
+            ordersDto.setGoodsUnit(goodsDemand.getGoodsUnit());
+            ordersDto.setGoodsNo(goodsDemand.getGoodsNo());
+            ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
+            ordersDto.setAcquirerName(goodsDemand.getCreateName());
+            ordersDto.setGoodsDemandTime(goodsDemand.getCreateTime());
+
+
+            // 根据需求表主键Id,获取报价表信息
+            LambdaQueryWrapper<TbDemandQuotation> wrapper = new LambdaQueryWrapper();
+            wrapper.eq(TbDemandQuotation::getDemandId, goodsDemandId);
+            wrapper.eq(TbDemandQuotation::getQuotationResult, 1);
+            TbDemandQuotation demandQuotation = demandQuotationService.getOne(wrapper);
+            // 商品报价
+            ordersDto.setQuotation(demandQuotation.getQuotation());
+            // 商品报价人
+            ordersDto.setQuotationPerson(demandQuotation.getCreateName());
+
+
+            ordersDtoList.add(ordersDto);
+        });
+
+        return ordersDtoList;
+    }
+}

+ 13 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.List;
 
 
@@ -24,6 +25,8 @@ public class TbOrdersApiController {
 	/** 底层 Service 对象 */
 	@Autowired
 	TbOrdersService tbOrdersService;
+	@Autowired
+	private MethodOrdersService methodOrdersService;
 
 	/** 增 */
 	@RequestMapping("add")
@@ -97,7 +100,17 @@ public class TbOrdersApiController {
 		return AjaxJson.getSuccessData(orders);
 	}
 
+	/** 查 根据订单Id查订单详情 */
+	@RequestMapping("getDetailById")
+	public AjaxJson getDetailById(Long id) {
+		TbOrders t = tbOrdersService.getById(id);
 
+		List<TbOrders> OrderList = new ArrayList<>();
+		OrderList.add(t);
+		List<TbOrdersDto> tbOrdersDto = methodOrdersService.getTbOrdersDto(OrderList);
+		if(tbOrdersDto.size() > 0) return AjaxJson.getSuccessData(tbOrdersDto.get((0)));
+		return AjaxJson.getError();
+	}
 
 
 }

+ 40 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersDto.java

@@ -216,6 +216,22 @@ public class TbOrdersDto {
 	 */
 	private String AcquirerName;
 
+	/**
+	 * 报价(CNY)
+	 */
+	private Double quotation;
+
+	/**
+	 * 报价人(组长)
+	 */
+	private String quotationPerson;
+
+	/**
+	 * 发布时间
+	 */
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date goodsDemandTime;
+
 	public Long getId() {
 		return id;
 	}
@@ -527,4 +543,28 @@ public class TbOrdersDto {
 	public void setIsDelivery(Integer isDelivery) {
 		this.isDelivery = isDelivery;
 	}
+
+	public Double getQuotation() {
+		return quotation;
+	}
+
+	public void setQuotation(Double quotation) {
+		this.quotation = quotation;
+	}
+
+	public String getQuotationPerson() {
+		return quotationPerson;
+	}
+
+	public void setQuotationPerson(String quotationPerson) {
+		this.quotationPerson = quotationPerson;
+	}
+
+	public Date getGoodsDemandTime() {
+		return goodsDemandTime;
+	}
+
+	public void setGoodsDemandTime(Date goodsDemandTime) {
+		this.goodsDemandTime = goodsDemandTime;
+	}
 }

+ 4 - 43
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -48,6 +48,8 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 	private TbGoodsDemandService goodsDemandService;
 	@Autowired
 	private TbDemandQuotationService demandQuotationService;
+	@Autowired
+	private MethodOrdersService methodOrdersService;
 
 	/** 增 */
 	void add(TbOrders t){
@@ -91,26 +93,7 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 		so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
 		List<TbOrders> orderList = tbOrdersMapper.getList(so);
 
-		List<TbOrdersDto> ordersDtoList = new ArrayList<>();
-		BeanUtils.copyProperties(orderList,ordersDtoList);
-
-		ordersDtoList.forEach(ordersDto -> {
-			// 需求表主键Id
-			Long goodsDemandId = ordersDto.getFkGoodsDemandId();
-			// 获取订单关联的需求表信息
-			TbGoodsDemand goodsDemand = goodsDemandService.getById(goodsDemandId);
-
-			ordersDto.setGoodsImg(goodsDemand.getGoodsImg());
-			ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
-			ordersDto.setRemark(goodsDemand.getRemark());
-			ordersDto.setGoodsUnit(goodsDemand.getGoodsUnit());
-			ordersDto.setGoodsNo(goodsDemand.getGoodsNo());
-			ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
-			ordersDto.setAcquirerName(goodsDemand.getCreateName());
-
-		});
-
-		return ordersDtoList;
+		return methodOrdersService.getTbOrdersDto(orderList);
 	}
 
 	/**
@@ -124,29 +107,7 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 		so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
 		List<TbOrders> orderList = tbOrdersMapper.getList(so);
 
-		List<TbOrdersDto> ordersDtoList = new ArrayList<>();
-
-		orderList.forEach(order -> {
-			// 需求表主键Id
-			Long goodsDemandId = order.getFkGoodsDemandId();
-			// 获取订单关联的需求表信息
-			TbGoodsDemand goodsDemand = goodsDemandService.getById(goodsDemandId);
-
-			TbOrdersDto ordersDto = new TbOrdersDto();
-			BeanUtils.copyProperties(order,ordersDto);
-
-			ordersDto.setGoodsImg(goodsDemand.getGoodsImg());
-			ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
-			ordersDto.setRemark(goodsDemand.getRemark());
-			ordersDto.setGoodsUnit(goodsDemand.getGoodsUnit());
-			ordersDto.setGoodsNo(goodsDemand.getGoodsNo());
-			ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
-			ordersDto.setAcquirerName(goodsDemand.getCreateName());
-
-			ordersDtoList.add(ordersDto);
-		});
-
-		return ordersDtoList;
+		return methodOrdersService.getTbOrdersDto(orderList);
 	}
 
 	/**