Browse Source

云帆bug修复

24282 2 năm trước cách đây
mục cha
commit
44b96ef281

+ 2 - 1
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/interestrate/mapper/InterestRateMapper.xml

@@ -3,11 +3,12 @@
 <mapper namespace="com.fjhx.interestrate.mapper.InterestRateMapper">
 
     <!-- 字段对应实体的MAP -->
-    <resultMap id="InterestRateMap" type="com.fjhx.InterestRate.entity.InterestRate">
+    <resultMap id="InterestRateMap" autoMapping="true" type="com.fjhx.InterestRate.entity.InterestRate">
         <result property="id" column="id"/>
         <result property="tenantId" column="tenant_id"/>
         <result property="euroToRmb" column="euro_to_rmb"/>
         <result property="euroToRmb" column="euro_to_rmb"/>
+        <result property="sterlingToRmb" column="sterling_to_rmb"/>
         <result property="taxRate" column="tax_rate"/>
         <result property="quota" column="quota"/>
         <result property="createTime" column="create_time"/>

+ 26 - 14
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/paymentgoods/service/impl/PaymentGoodsFlowServiceImpl.java

@@ -34,6 +34,7 @@ import com.fjhx.paymentgoods.service.IPaymentGoodsService;
 import com.fjhx.purchase.entity.PurchaseContract;
 import com.fjhx.purchase.service.IPurchaseContractService;
 import com.fjhx.subscribe.enums.SubscribeStatusEnum;
+import com.fjhx.utils.Assert;
 import com.fjhx.utils.ExampleAbstract;
 import com.fjhx.utils.ExampleResult;
 import com.fjhx.utils.FlowConstructor;
@@ -45,7 +46,6 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.id.IdUtils;
-import org.springblade.system.attachment.entity.Attachment;
 import org.springblade.system.constant.RoleConstant;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
@@ -55,10 +55,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -158,7 +156,7 @@ public class PaymentGoodsFlowServiceImpl implements IPaymentGoodsFlowService {
                     @Transactional(rollbackFor = {Exception.class})
                     @Override
                     public boolean deleteLogic(String flowLinkNo) {
-                        //旧数据做伪删除
+                        // 旧数据做伪删除
                         return iPaymentGoodsService.deleteLogic(flowLinkNo);
                     }
                 }
@@ -173,22 +171,36 @@ public class PaymentGoodsFlowServiceImpl implements IPaymentGoodsFlowService {
     @Transactional(rollbackFor = {Exception.class})
     @Override
     public void start(PaymentGoods entity) {
-        //提交时候检查 付款金额+已付款金额是否大于合同金额 大于不让提交
+        // 提交时候检查 付款金额+已付款金额是否大于合同金额 大于不让提交
         List<PaymentGoodsDetails> details = entity.getDetails();
-        for (PaymentGoodsDetails paymentGoodsDetails : details) {
-            PurchaseContract purchaseContract = iPurchaseContractService.lambdaQuery().eq(PurchaseContract::getId, paymentGoodsDetails.getPurchaseContractId()).one();
-            BigDecimal money = paymentGoodsDetails.getMoney();//付款金额
-            BigDecimal purchasePrice = purchaseContract.getPurchasePrice();//合同金额
 
-            QueryWrapper wrapper = new QueryWrapper();
+        for (PaymentGoodsDetails paymentGoodsDetailsItem : details) {
+
+            // 付款金额
+            BigDecimal money = paymentGoodsDetailsItem.getMoney();
+            Assert.notEmpty(money, "付款金额不能为空");
+
+            // 合同id
+            String purchaseContractId = paymentGoodsDetailsItem.getPurchaseContractId();
+            Assert.notEmpty(purchaseContractId, "合同id不能为空");
+
+            // 获取合同金额
+            PurchaseContract purchaseContract = iPurchaseContractService.getById(purchaseContractId);
+            Assert.notEmpty(purchaseContract, "没有找到对应合同");
+            BigDecimal purchasePrice = purchaseContract.getPurchasePrice();
+
+            // 查询已付金额
+            QueryWrapper<PaymentGoodsDetails> wrapper = new QueryWrapper<>();
             wrapper.select("sum(money) as money");
-            wrapper.eq("purchase_contract_id", paymentGoodsDetails.getPurchaseContractId());
-            PaymentGoodsDetails paymentGoodsDetails0 = paymentGoodsDetailsService.getOne(wrapper);
-            BigDecimal payMoney = paymentGoodsDetails0.getMoney();//已付款金额
+            wrapper.lambda().eq(PaymentGoodsDetails::getPurchaseContractId, purchaseContractId);
+            PaymentGoodsDetails paymentGoodsDetails = paymentGoodsDetailsService.getOne(wrapper);
+            BigDecimal payMoney = paymentGoodsDetails == null ? BigDecimal.ZERO : paymentGoodsDetails.getMoney();
 
+            // 判断合同金额不能大于总付款金额
             if (payMoney.add(money).compareTo(purchasePrice) > 0) {
-                throw new ServiceException("总付款金额大于合同金额");
+                throw new ServiceException("总付款金额不能大于合同金额");
             }
+
         }
 
         //初始化业务数据ID

+ 4 - 8
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/paymentgoods/service/impl/PaymentGoodsServiceImpl.java

@@ -247,16 +247,12 @@ public class PaymentGoodsServiceImpl extends BasicsServiceImpl<PaymentGoodsMappe
                     List<PaymentGoodsDetails> details = paymentGoodsDetailsMap.get(contract.getCode());
                     BigDecimal payMoney = details.stream().map(PaymentGoodsDetails::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
                     contract.setPayMoney(payMoney);
+                } else {
+                    contract.setPayMoney(BigDecimal.ZERO);
                 }
             }
-            //过滤掉已支付金额>=合同金额的关联合同
-            Iterator<PurchaseContract> iterator = list.iterator();
-            while (iterator.hasNext()){
-                PurchaseContract purchaseContract = iterator.next();
-                if(purchaseContract.getPurchasePrice().compareTo(purchaseContract.getPayMoney())>=0){
-                    iterator.remove();
-                }
-            }
+            // 过滤掉已支付金额>=合同金额的关联合同
+            list.removeIf(purchaseContract -> purchaseContract.getPurchasePrice().compareTo(purchaseContract.getPayMoney()) <= 0);
         }
         return list;
     }

+ 1 - 2
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/purchase/controller/PurchaseDocumentaryController.java

@@ -18,7 +18,6 @@ import com.fjhx.trackpacking.service.ITrackPackingInstructionsService;
 import lombok.extern.slf4j.Slf4j;
 import org.springblade.common.constant.ApiConstant;
 import org.springblade.common.utils.ListPageMap;
-import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.system.attachment.entity.Attachment;
@@ -172,7 +171,7 @@ public class PurchaseDocumentaryController {
             try {
                 outputStream.write("预览pdf失败".getBytes(StandardCharsets.UTF_8));
             } catch (IOException ex) {
-                log.error("预览pdf失败"+ex.getMessage(),ex);
+                log.error("预览pdf失败:{}", ex.getMessage(), ex);
             }
         } finally {
             IoUtil.close(outputStream);

+ 13 - 5
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/purchase/service/impl/PurchaseContractServiceImpl.java

@@ -374,21 +374,29 @@ public class PurchaseContractServiceImpl extends BasicsServiceImpl<PurchaseContr
 
         // 收费项目
         if (CollectionUtils.isNotEmpty(purchaseContract.getProjects())) {
+
+            List<ChargeProject> chargeProjectList = new ArrayList<>();
             for (PurchaseContractProject project : purchaseContract.getProjects()) {
                 // 此处ID设为null,是防止复制采购合同时把复制对象的ID携带过来
                 project.setId(IdWorker.getIdStr());
                 project.setPurchaseContractId(purchaseContract.getId());
-                //判断是否是用户手动添加的 收费项目
-                if(project.getProjectId().equals("")){
-                    //添加用户收费项目
+                // 判断是否是用户手动添加的 收费项目
+                if (ObjectUtil.isEmpty(project.getProjectId())) {
+                    String chargeProjectId = IdWorker.getIdStr();
+
+                    // 添加用户收费项目
                     ChargeProject chargeProject = new ChargeProject();
+                    chargeProject.setId(chargeProjectId);
                     chargeProject.setRemarks(project.getRemark());
                     chargeProject.setProject(project.getProjectName());
                     chargeProject.setPrice(project.getProjectPrice());
-                    chargeProjectService.insert(chargeProject);
-                    project.setProjectId(chargeProject.getId());
+                    chargeProjectList.add(chargeProject);
+
+                    project.setProjectId(chargeProjectId);
                 }
             }
+
+            chargeProjectService.saveBatch(chargeProjectList);
             iPurchaseContractProjectService.saveBatch(purchaseContract.getProjects());
         }
         // 出货明细