瀏覽代碼

修改业务编号获取逻辑

nzf 3 年之前
父節點
當前提交
a05da1031c
共有 1 個文件被更改,包括 21 次插入16 次删除
  1. 21 16
      ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

+ 21 - 16
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -789,6 +789,8 @@ public class TFeeServiceImpl implements ITFeeService {
             }
         }
         TFee tFee = JSONArray.parseObject(tfee, TFee.class);
+        // 声明业务编号 list
+        List<String> fSrcBillnos = new ArrayList<>();
         String billstatus = "";
         if (isApprove) {
             billstatus = "4";
@@ -813,28 +815,31 @@ public class TFeeServiceImpl implements ITFeeService {
             tFeeMapper.updateTFee(tFee);
         }
         // 删除从表
-        tFeeDoMapper.deleteByFPid(tFee.getfId());
+        //tFeeDoMapper.deleteByFPid(tFee.getfId());
         messageMap.put("tFee", tFee);
-        // 声明业务编号 list
-        List<String> fSrcBillnos = new ArrayList<>();
+        fSrcBillnos.add(tFee.getfSrcBillno());
         //  财务从表
         if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
             JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
             List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
             for (TFeeDo tFeeDo : tFeeDoList) {
-                Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
-                if (!(Boolean) map.get("flag")) {
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    return AjaxResult.error(map.get("message").toString());
-                }
-                tFeeDo.setfPid(tFee.getfId());
-                tFeeDo.setCreateBy(loginUser.getUser().getUserName());
-                tFeeDo.setCreateTime(new Date());
-                tFeeDo.setfStatus(billstatus);
-                tFeeDoMapper.insertTFeeDo(tFeeDo);
-                if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) { // 判断是否有来源单据编号(业务编号)
-                    // 装载业务编号传递
-                    fSrcBillnos.add(tFeeDo.getfSrcBillno());
+                if (StringUtils.isNull(tFeeDo.getfId())) {
+                    Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
+                    if (!(Boolean) map.get("flag")) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error(map.get("message").toString());
+                    }
+                    tFeeDo.setfPid(tFee.getfId());
+                    tFeeDo.setCreateBy(loginUser.getUser().getUserName());
+                    tFeeDo.setCreateTime(new Date());
+                    tFeeDo.setfStatus(billstatus);
+                    tFeeDo.setfSrcBillno(tFee.getfSrcBillno());
+                    tFeeDoMapper.insertTFeeDo(tFeeDo);
+                } else {
+                    // 走了修改
+                    tFeeDo.setUpdateBy(loginUser.getUser().getUserName());
+                    tFeeDo.setUpdateTime(new Date());
+                    tFeeDoMapper.updateTFeeDo(tFeeDo);
                 }
             }
         }