‘linchangsheng’ hai 7 meses
pai
achega
1d1d0bb67c

+ 1 - 1
src/main/java/com/zfire/mall/manager/controller/k3/K3ReceiptController.java

@@ -167,7 +167,7 @@ public class K3ReceiptController {
     @PostMapping("/examine")
     @PostMapping("/examine")
     public ResponseHelper examine(
     public ResponseHelper examine(
             @ApiParam(required = false, value = "单据编号") @RequestParam(required = false) String billNo,
             @ApiParam(required = false, value = "单据编号") @RequestParam(required = false) String billNo,
-            @ApiParam(required = false, value = " 状态 A=保存 B=审核中 C=已审核") @RequestParam(required = false) String status
+            @ApiParam(required = false, value = " 状态  OK通过  WAIT待审 FAIL 不通过") @RequestParam(required = false) String status
     ) throws Exception {
     ) throws Exception {
         k3ReceiptLogic.examine(billNo,status);
         k3ReceiptLogic.examine(billNo,status);
         return ResponseHelper.success();
         return ResponseHelper.success();

+ 63 - 4
src/main/java/com/zfire/mall/manager/logic/k3/K3ReceiptLogic.java

@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zfire.mall.manager.bean.CommonCountBean;
 import com.zfire.mall.manager.bean.CommonCountBean;
 import com.zfire.mall.manager.bean.ExcelData;
 import com.zfire.mall.manager.bean.ExcelData;
@@ -17,6 +16,7 @@ import com.zfire.mall.manager.commonmapper.K3Mapper;
 import com.zfire.mall.manager.commonmapper.listV2.CommonCMapper;
 import com.zfire.mall.manager.commonmapper.listV2.CommonCMapper;
 import com.zfire.mall.manager.constant.Constant;
 import com.zfire.mall.manager.constant.Constant;
 import com.zfire.mall.manager.constant.KingDeeCons;
 import com.zfire.mall.manager.constant.KingDeeCons;
+import com.zfire.mall.manager.enums.ExamineStatusEnum;
 import com.zfire.mall.manager.exception.RemoteServiceException;
 import com.zfire.mall.manager.exception.RemoteServiceException;
 import com.zfire.mall.manager.helper.ResponseHelper;
 import com.zfire.mall.manager.helper.ResponseHelper;
 import com.zfire.mall.manager.logic.common.CommonLogic;
 import com.zfire.mall.manager.logic.common.CommonLogic;
@@ -32,6 +32,7 @@ import com.zfire.mall.manager.plus.service.KingDeeWalletService;
 import com.zfire.mall.manager.zfire.bean.ZfireParamBean;
 import com.zfire.mall.manager.zfire.bean.ZfireParamBean;
 import com.zfire.mall.manager.zfire.util.FieldUtils;
 import com.zfire.mall.manager.zfire.util.FieldUtils;
 import lombok.extern.log4j.Log4j;
 import lombok.extern.log4j.Log4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -476,11 +477,19 @@ public class K3ReceiptLogic {
         kingDeeWallet.updateById();
         kingDeeWallet.updateById();
     }
     }
 
 
-    public void examine(String billNo, String cancelStatus) {
+
+    @Transactional(rollbackFor = Exception.class)
+    public void examine(String billNo, String cancelStatus) throws InterruptedException {
 
 
         KingDeeReceipt kingDeeReceipt = kingDeeReceiptService.getById(billNo);
         KingDeeReceipt kingDeeReceipt = kingDeeReceiptService.getById(billNo);
         kingDeeReceipt.setStatus(cancelStatus);
         kingDeeReceipt.setStatus(cancelStatus);
         kingDeeReceipt.updateById();
         kingDeeReceipt.updateById();
+
+        if (kingDeeReceipt.getStatus().equals(ExamineStatusEnum.OK.getKey())) {
+            List<KingDeeReceipt> kingDeeReceipts = new ArrayList<>();
+            kingDeeReceipts.add(kingDeeReceipt);
+            this.initAmount(kingDeeReceipts);
+        }
     }
     }
 
 
 
 
@@ -525,12 +534,62 @@ public class K3ReceiptLogic {
             }
             }
             if(oldBill != null && oldBill.getStatus().equals("C")){
             if(oldBill != null && oldBill.getStatus().equals("C")){
                 BigDecimal subAmount = BigDecimal.valueOf(0).subtract(oldBill.getAmount());
                 BigDecimal subAmount = BigDecimal.valueOf(0).subtract(oldBill.getAmount());
-              //  customerWalletAmountBeans.add(this.doAmount(oldBill,subAmount,oldBill.getRemark()));
+                customerWalletAmountBeans.add(this.doAmount(oldBill,subAmount,oldBill.getRemark()));
             }
             }
 
 
-           // customerWalletAmountBeans.add(this.doAmount(kingDeeReceipt,amount,kingDeeReceipt.getRemark()));
+            customerWalletAmountBeans.add(this.doAmount(kingDeeReceipt,amount,kingDeeReceipt.getRemark()));
         }
         }
         walletLogic.doWalletAmount(customerWalletAmountBeans);
         walletLogic.doWalletAmount(customerWalletAmountBeans);
     }
     }
 
 
+
+
+    private CustomerWalletAmountBean doAmount(KingDeeReceipt kingDeeReceipt,BigDecimal amountParam,String remark) throws InterruptedException {
+        String customerId = kingDeeReceipt.getCustomerId();
+        String walletId = kingDeeReceipt.getWalletId();
+        String billType = kingDeeReceipt.getBillType();//1=收款单  2=退款单   3=付款单
+        String billNo = kingDeeReceipt.getBillNo();
+
+        //退款单 和 付款单 要反着来
+        if("3".equals(billType) || "2".equals(billType)){
+            amountParam = BigDecimal.valueOf(0).subtract(amountParam);
+        }
+
+        double amount = amountParam.stripTrailingZeros().doubleValue();
+        if(amount == 0){
+            return null;
+        }
+        if(StringUtils.isEmpty(customerId) || StringUtils.isEmpty(walletId)){
+            return null;
+        }
+        CustomerWallet customerWallet = walletLogic.queryCustomerWallet(customerId, walletId);
+        if(customerWallet == null){
+            return null;
+        }
+        if(amount > 0) {
+            String billName = "";
+            if(billType.equals("1")){
+                billName = Constant.BILL_TYPE_SKD;
+            }else if(billType.equals("2")){
+                billName = Constant.BILL_TYPE_TKD;
+            }else{
+                billName = Constant.BILL_TYPE_FKD;
+            }
+            return new CustomerWalletAmountBean(customerWallet.getCustomerWalletId(), amountParam, remark, billName, new Date(), billNo, 1, "add");
+        } else{
+            String billName = "";
+            if(billType.equals("1")){
+                billName = Constant.BILL_TYPE_SKD;
+            }else if(billType.equals("2")){
+                billName = Constant.BILL_TYPE_TKD;
+            }else{
+                billName = Constant.BILL_TYPE_FKD;
+            }
+            BigDecimal a = BigDecimal.valueOf(0).subtract(amountParam);
+            return new CustomerWalletAmountBean(customerWallet.getCustomerWalletId(), a, remark, billName, new Date(),billNo , 1,"sub");
+        }
+    }
+
+
+
 }
 }