From a13573d5ef8d16f4bc2535a3c89c2891e6f5b56c Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 30 五月 2023 15:33:30 +0800
Subject: [PATCH] optimize

---
 service-store/src/main/java/com/java110/store/cmd/resourceStore/AuditAllocationStoreOrderCmd.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/service-store/src/main/java/com/java110/store/cmd/resourceStore/AuditAllocationStoreOrderCmd.java b/service-store/src/main/java/com/java110/store/cmd/resourceStore/AuditAllocationStoreOrderCmd.java
index 85e52d9..41f1544 100644
--- a/service-store/src/main/java/com/java110/store/cmd/resourceStore/AuditAllocationStoreOrderCmd.java
+++ b/service-store/src/main/java/com/java110/store/cmd/resourceStore/AuditAllocationStoreOrderCmd.java
@@ -8,12 +8,14 @@
 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.allocationStorehouse.AllocationStorehouseApplyDto;
 import com.java110.dto.resourceStore.ResourceStoreDto;
+import com.java110.dto.resourceStoreTimes.ResourceStoreTimesDto;
 import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
 import com.java110.intf.store.*;
 import com.java110.po.allocationStorehouseApply.AllocationStorehouseApplyPo;
 import com.java110.po.purchase.ResourceStorePo;
+import com.java110.po.resourceStoreTimes.ResourceStoreTimesPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -48,6 +50,9 @@
     @Autowired
     private IAllocationStorehouseApplyV1InnerServiceSMO allocationStorehouseApplyV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.hasKeyAndValue(reqJson, "applyId", "璁㈠崟鍙蜂笉鑳戒负绌�");
@@ -56,6 +61,14 @@
         Assert.hasKeyAndValue(reqJson, "remark", "蹇呭~锛岃濉啓鎵规敞");
     }
 
+    /**
+     * 璋冩嫧鐢宠-鐗╁搧璋冩嫧瀹℃牳
+     * @param event              浜嬩欢瀵硅薄
+     * @param context 鏁版嵁涓婃枃瀵硅薄
+     * @param reqJson            璇锋眰鎶ユ枃
+     * @throws CmdException
+     * @throws ParseException
+     */
     @Override
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
@@ -185,7 +198,7 @@
                     resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
                     Assert.listOnlyOne(resourceStoreDtos, "鍘熶粨搴撹褰曚笉瀛樺湪");
                     resourceStorePo = BeanConvertUtil.covertBean(allocationStorehouseDto, resourceStorePo);
-                    resourceStorePo.setResId(resourceStoreDtos.get(0).getResId());
+                    resourceStorePo.setResId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_resId));
                     resourceStorePo.setStock(allocationStorehouseDto.getStock());
                     //鑾峰彇鏈�灏忚閲忓崟浣嶆暟閲�
                     if (StringUtil.isEmpty(resourceStoreDtos.get(0).getMiniUnitStock())) {
@@ -210,11 +223,27 @@
                     resourceStorePo.setRssId(resourceStoreDtos.get(0).getRssId());
                     resourceStorePo.setMiniUnitCode(resourceStoreDtos.get(0).getMiniUnitCode());
                     resourceStorePo.setMiniUnitStock(resourceStoreDtos.get(0).getMiniUnitStock());
-                    flag = resourceStoreV1InnerServiceSMOImpl.updateResourceStore(resourceStorePo);
+                    flag = resourceStoreV1InnerServiceSMOImpl.saveResourceStore(resourceStorePo);
                     if (flag < 1) {
-                        throw new CmdException("淇敼澶辫触");
+                        throw new CmdException("娣诲姞澶辫触");
                     }
                 }
+                // 淇濆瓨鑷� 鐗╁搧 times琛�
+                //鏌ヨ璋冩嫧鎵规浠锋牸
+                ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+                resourceStoreTimesDto.setTimesId(allocationStorehouseDto.getTimesId());
+                List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+
+                ResourceStoreTimesPo resourceStoreTimesPo = new ResourceStoreTimesPo();
+                resourceStoreTimesPo.setApplyOrderId(tmpAllocationStorehouseDto.getApplyId());
+                resourceStoreTimesPo.setPrice(resourceStoreTimesDtos.get(0).getPrice());
+                resourceStoreTimesPo.setStock(allocationStorehouseDto.getStock());
+                resourceStoreTimesPo.setResCode(allocationStorehouseDto.getResCode());
+                resourceStoreTimesPo.setStoreId(allocationStorehouseDto.getStoreId());
+                resourceStoreTimesPo.setTimesId(GenerateCodeFactory.getGeneratorId("10"));
+                resourceStoreTimesPo.setShId(allocationStorehouseDto.getShIdz());
+                resourceStoreTimesV1InnerServiceSMOImpl.saveOrUpdateResourceStoreTimes(resourceStoreTimesPo);
+
             }
         } else if (allocationStorehouseApplyDtos.get(0).getState().equals("1203")) {
             allocationStorehouseApplyPo.setState(AllocationStorehouseDto.STATE_FAIL);
@@ -245,7 +274,8 @@
         int flag = allocationStorehouseApplyV1InnerServiceSMOImpl.updateAllocationStorehouseApply(allocationStorehouseApplyPo);
         if (flag < 1) {
             throw new CmdException("淇敼澶辫触");
-        }        //璋冩嫧璇︽儏鏁版嵁
+        }
+        //璋冩嫧璇︽儏鏁版嵁
         AllocationStorehouseDto tmpAllocationStorehouseDto = new AllocationStorehouseDto();
         tmpAllocationStorehouseDto.setApplyId(paramInJson.getString("applyId"));
         tmpAllocationStorehouseDto.setStoreId(paramInJson.getString("storeId"));
@@ -280,6 +310,23 @@
             BigDecimal newMiniStock = miniStock.add(nowMiniStock);
             resourceStorePo.setMiniStock(String.valueOf(newMiniStock));
             flag = resourceStoreV1InnerServiceSMOImpl.updateResourceStore(resourceStorePo);
+
+            // 淇濆瓨鑷� 鐗╁搧 times琛�
+            //鏌ヨ璋冩嫧鎵规浠锋牸
+            ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+            resourceStoreTimesDto.setTimesId(allocationStorehouseDto.getTimesId());
+            List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+
+            ResourceStoreTimesPo resourceStoreTimesPo = new ResourceStoreTimesPo();
+            resourceStoreTimesPo.setApplyOrderId(tmpAllocationStorehouseDto.getApplyId());
+            resourceStoreTimesPo.setPrice(resourceStoreTimesDtos.get(0).getPrice());
+            resourceStoreTimesPo.setStock(allocationStorehouseDto.getStock());
+            resourceStoreTimesPo.setResCode(allocationStorehouseDto.getResCode());
+            resourceStoreTimesPo.setStoreId(allocationStorehouseDto.getStoreId());
+            resourceStoreTimesPo.setTimesId(GenerateCodeFactory.getGeneratorId("10"));
+            resourceStoreTimesPo.setShId(allocationStorehouseDto.getShIda());
+            resourceStoreTimesV1InnerServiceSMOImpl.saveOrUpdateResourceStoreTimes(resourceStoreTimesPo);
+
             if (flag < 1) {
                 throw new CmdException("淇敼澶辫触");
             }

--
Gitblit v1.8.0