From 3fbdd17668bc5b22b49d094195995214d9478c17 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 03 二月 2023 17:02:47 +0800
Subject: [PATCH] modify purchase

---
 service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java b/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
index 9a0e17a..c7acc5f 100644
--- a/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
+++ b/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
@@ -5,15 +5,17 @@
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
 import com.java110.dto.allocationStorehouseApply.AllocationStorehouseApplyDto;
 import com.java110.dto.resourceStore.ResourceStoreDto;
+import com.java110.dto.user.UserDto;
 import com.java110.dto.userStorehouse.UserStorehouseDto;
 import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
 import com.java110.intf.store.*;
+import com.java110.intf.user.IUserV1InnerServiceSMO;
 import com.java110.po.allocationStorehouse.AllocationStorehousePo;
 import com.java110.po.allocationStorehouseApply.AllocationStorehouseApplyPo;
 import com.java110.po.purchase.ResourceStorePo;
@@ -36,7 +38,7 @@
  *
  */
 @Java110Cmd(serviceCode = "resourceStore.saveAllocationStorehouse")
-public class SaveAllocationStorehouseCmd extends AbstractServiceCmdListener {
+public class SaveAllocationStorehouseCmd extends Cmd {
 
     @Autowired
     private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl;
@@ -58,6 +60,9 @@
 
     @Autowired
     private IUserStorehouseV1InnerServiceSMO userStorehouseV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
 
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
@@ -135,6 +140,16 @@
         int flag = 0;
         //鑾峰彇璋冩嫧杩旇繕鐘舵�佹爣璇�
         String applyType = reqJson.getString("apply_type");
+
+        // 鏌ヨ鐢ㄦ埛鍚嶇О
+        UserDto userDto = new UserDto();
+        userDto.setUserId(reqJson.getString("userId"));
+        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+
+        Assert.listOnlyOne(userDtos, "鐢ㄦ埛涓嶅瓨鍦�");
+        reqJson.put("userName", userDtos.get(0).getName());
+
+
         //灏佽璋冩嫧瀵硅薄
         AllocationStorehouseApplyPo allocationStorehouseApplyPo = covertAllocationStorehouseApply(reqJson);
         JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
@@ -152,6 +167,7 @@
         if (AllocationStorehouseApplyDto.STORE_TYPE_ALLOCATION.equals(applyType)) {
             AllocationStorehouseApplyDto allocationStorehouseDto = BeanConvertUtil.covertBean(allocationStorehouseApplyPo, AllocationStorehouseApplyDto.class);
             allocationStorehouseDto.setCurrentUserId(reqJson.getString("userId"));
+            allocationStorehouseDto.setNextUserId(reqJson.getString("staffId"));
             allocationStorehouseUserInnerServiceSMOImpl.startProcess(allocationStorehouseDto);
         }
 
@@ -159,7 +175,6 @@
     }
 
     private void doDealResourceStore(JSONObject reqJson, String applyType, AllocationStorehouseApplyPo allocationStorehouseApplyPo, JSONArray resourceStores, JSONObject resObj) {
-        int flag;
         //淇濆瓨璋冩嫧鐢宠鐨勭墿鍝佽皟鎷ㄨ褰�
         saveAllocationStorehouse(reqJson, applyType, allocationStorehouseApplyPo, resObj);
         if (AllocationStorehouseApplyDto.STORE_TYPE_ALLOCATION.equals(applyType)) { //璋冩嫧鍑忓幓搴撳瓨
@@ -345,7 +360,7 @@
             resourceStorePo.setShId(resObj.getString("shId"));
             BigDecimal stockA = new BigDecimal(resObj.getString("stock"));//鐜版湁搴撳瓨
             BigDecimal stockB = new BigDecimal(resObj.getString("curStock"));//璋冩嫧鏁伴噺
-            if (stockA.compareTo(stockB) == -1) {
+            if (stockA.compareTo(stockB) < 0) {
                 throw new IllegalArgumentException("搴撳瓨涓嶈冻锛�");
             }
             resourceStorePo.setStock((stockA.subtract(stockB)).toString());

--
Gitblit v1.8.0