Parcourir la source

利润结算表BUG
报价单、合同增加客户非空校验

caozj il y a 1 an
Parent
commit
c7793cc8f8

+ 3 - 3
hx-purchase/src/main/resources/mapper/pay/PayDetailMapper.xml

@@ -41,9 +41,9 @@
 
     <select id="getPayDetailList" resultType="com.fjhx.purchase.entity.pay.po.Pay">
         SELECT
-            t1.money,
-            t2.rate,
-            t2.currency
+            IFNULL( t1.money, 0 ) AS money,
+            IFNULL( t2.rate, 1 ) AS rate,
+            IFNULL( t2.currency, "CNY" ) AS currency
         FROM
         pay_detail t1
         LEFT JOIN pay t2 ON t1.pay_id = t2.id

+ 4 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -1,5 +1,6 @@
 package com.fjhx.sale.flow;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@@ -78,6 +79,9 @@ public class ContractFlow extends FlowDelegate {
         if (StringUtils.isEmpty(contract.getCurrency())) {
             throw new ServiceException("币种不能为空");
         }
+        if(ObjectUtil.isEmpty(contract.getBuyCorporationId())){
+            throw new ServiceException("客户不能为空");
+        }
 
         //赋值合同号
         contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));

+ 4 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/SaleQuotationFlow.java

@@ -1,5 +1,6 @@
 package com.fjhx.sale.flow;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
@@ -112,6 +113,9 @@ public class SaleQuotationFlow extends FlowDelegate {
      * @param opType 操作类型 0直接发起 1重新发起
      */
     private SaleQuotationDto commStart(SaleQuotationDto saleQuotation, Integer opType) {
+        if(ObjectUtil.isEmpty(saleQuotation.getBuyCorporationId())){
+            throw new ServiceException("客户不能为空");
+        }
         //赋值城市省份信息
         CustomizeAreaUtil.setAreaId(saleQuotation);
         saleQuotation.setBuyCityId(saleQuotation.getCityId());

+ 3 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -534,6 +534,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      * 开始公共代码抽取
      */
     public ContractDto commStart(ContractDto contract) {
+        if(ObjectUtil.isEmpty(contract.getBuyCorporationId())){
+            throw new ServiceException("客户不能为空");
+        }
         // 赋值城市省份信息
         CustomizeAreaUtil.setAreaId(contract);
         contract.setUserName(SecurityUtils.getUsername());

+ 3 - 0
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -175,6 +175,9 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
     @DSTransactional
     @Override
     public long add(SaleQuotationDto saleQuotation) {
+        if(ObjectUtil.isEmpty(saleQuotation.getBuyCorporationId())){
+            throw new ServiceException("客户不能为空");
+        }
         //赋值城市省份信息
         CustomizeAreaUtil.setAreaId(saleQuotation);
         saleQuotation.setBuyCityId(saleQuotation.getCityId());

+ 4 - 4
hx-sale/src/main/java/com/fjhx/sale/service/statement/impl/SaleStatementServiceImpl.java

@@ -338,8 +338,8 @@ public class SaleStatementServiceImpl implements SaleStatementService {
                         BigDecimal payAmount = payList.stream().map(pay -> {
                             //获取汇率
                             BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
-                            // 获取认领金额
-                            BigDecimal money = pay.getAmount();
+                            // 获取金额
+                            BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
                             // 返回兑人民币后金额
                             return rate.multiply(money);
                         }).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -374,7 +374,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
                     BigDecimal contractArrival = cList.stream().map(claimContract -> {
                         //获取汇率
                         BigDecimal rate = waterMap.getOrDefault(claimContract.getBusinessId(), BigDecimal.ONE);
-                        // 获取认领金额
+                        // 获取金额
                         BigDecimal money = claimContract.getMoney();
                         // 返回兑人民币后金额
                         return rate.multiply(money);
@@ -422,7 +422,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
                             //获取汇率
                             BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
                             // 获取认领金额
-                            BigDecimal money = pay.getAmount();
+                            BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
                             // 返回兑人民币后金额
                             return rate.multiply(money);
                         }).reduce(BigDecimal.ZERO, BigDecimal::add);