Bläddra i källkod

供应链 订单添加到货金额

home 2 år sedan
förälder
incheckning
c2a5490e2a

+ 5 - 0
hx-common/library-supply/src/main/java/com/fjhx/entity/Order.java

@@ -40,6 +40,11 @@ public class Order extends BaseEntity {
     private BigDecimal price;
 
     /**
+     * 到货金额
+     */
+    private BigDecimal arrivalPrice;
+
+    /**
      * 状态 1待审批 2不通过 3审批通过 4完成
      */
     private Integer status;

+ 10 - 4
hx-common/library-supply/src/main/java/com/fjhx/service/impl/ApplyPurchaseServiceImpl.java

@@ -8,8 +8,10 @@ import com.fjhx.constants.ErrorMsgConstant;
 import com.fjhx.constants.LibrarySupplyLockConstant;
 import com.fjhx.constants.StatusConstant;
 import com.fjhx.entity.ApplyPurchase;
+import com.fjhx.entity.Order;
 import com.fjhx.entity.OrderFlow;
 import com.fjhx.enums.ApplyPurchaseStatusEnum;
+import com.fjhx.enums.OrderStatusEnum;
 import com.fjhx.mapper.ApplyPurchaseMapper;
 import com.fjhx.service.ApplyPurchaseService;
 import com.fjhx.service.OrderFlowService;
@@ -188,15 +190,19 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
             applyPurchase.setStatus(ApplyPurchaseStatusEnum.PART_ARRIVAL.getValue());
         }
 
-        boolean b = updateById(applyPurchase);
+        Assert.eqTrue(updateById(applyPurchase), ErrorMsgConstant.SYSTEM_BUSY_ERROR);
 
-        Assert.eqTrue(b, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
+        // 赋值订单到货金额
+        Long orderId = applyPurchase.getOrderId();
+        Order order = orderService.getById(orderId);
+        order.setArrivalPrice(order.getArrivalPrice().add(arrivalQuantity.multiply(applyPurchase.getUnitPrice())));
 
         // 如果完成订单,修改订单状态为已完成
-        if (totalArrivalQuantity.compareTo(quantity) >= 0 && autoComplete) {
-            orderService.orderComplete(applyPurchase.getOrderId());
+        if (autoComplete && totalArrivalQuantity.compareTo(quantity) >= 0 && orderIsComplete(orderId)) {
+            order.setStatus(OrderStatusEnum.COMPLETED.getValue());
         }
 
+        Assert.eqTrue(orderService.updateById(order), ErrorMsgConstant.SYSTEM_BUSY_ERROR);
     }
 
     @Override