Bladeren bron

修复质保金导入重复师傅计算错误问题

FengChaoYu 2 weken geleden
bovenliggende
commit
5229f60867

+ 7 - 7
mall-server-api/src/main/java/com/gree/mall/manager/logic/worker/WorkerWarrantyLogic.java

@@ -2,18 +2,15 @@ package com.gree.mall.manager.logic.worker;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
-import com.gree.mall.manager.bean.notice.NoticeWebsitVO;
 import com.gree.mall.manager.bean.worker.WorkerWarrantyDetail;
 import com.gree.mall.manager.bean.worker.WorkerWarrantyVO;
 import com.gree.mall.manager.commonmapper.NoticeRecordBeanMapper;
-import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.*;
@@ -26,7 +23,6 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
@@ -36,8 +32,6 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -217,13 +211,19 @@ public class WorkerWarrantyLogic {
                 for (WorkerWarrantyPay workerWarrantyPay : workerWarrantyPays1) {
                     workerWarranty.setPayableAmount(workerWarrantyPay.getPayAmount().add((workerWarranty.getPayableAmount() == null?BigDecimal.ZERO:workerWarranty.getPayableAmount())));
                 }
+
+                // 对重复出现的师傅累加已缴纳金额
+                if (CollectionUtils.isNotEmpty(workerWarrantyListUp))
+                    workerWarrantyListUp.get(0).setPayableAmount(workerWarranty.getPayableAmount());
             }
 
             if (CollectionUtils.isNotEmpty(workerWarrantyListUp) && workerWarranty.getRefundAmount() != null)
                 workerWarranty.setRefundAmount(workerWarrantyListUp.get(0).getRefundAmount().add(workerWarranty.getRefundAmount()));
 
             workerWarranty.setWaitAmount(workerWarranty.getShouldAmount().subtract(workerWarranty.getPayableAmount() == null?BigDecimal.ZERO:workerWarranty.getPayableAmount()));
-
+            if (workerWarranty.getWaitAmount().compareTo(BigDecimal.ZERO) < 0) {
+                workerWarranty.setWaitAmount(BigDecimal.ZERO);
+            }
   /*          if (workerWarranty.getWaitAmount().doubleValue() < 0)
                 throw new RemoteServiceException("第"+rowIndex+"行"+"缴纳金额超过应缴纳金额");
 */