jiangping
2024-05-17 44a0ef1620cad87479390900eb6ded041c7b8d7b
Merge remote-tracking branch 'origin/1.0.1' into 1.0.1
已修改39个文件
1835 ■■■■ 文件已修改
server/company/src/main/java/com/doumee/api/business/ApplyChangeController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/InsuranceApplyController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/SolutionsController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/system/SystemDictController.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/ApplyChangeController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/UnionChangeController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/system/SystemDictController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/task/ScheduleTool.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/pom.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelImporter.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 364 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/DateUtil.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/dto/CountCyclePriceDTO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionChangeDTO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/dto/UnionChangeBXDDTO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/ApplyChagneDetail.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/Member.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/Solutions.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/vo/CountCyclePriceVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/InsuranceApplyService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/SolutionsService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java 517 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java 438 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/shop/src/main/java/com/doumee/api/business/ApplyChangeController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/shop/src/main/java/com/doumee/api/business/UnionApplyController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/shop/src/main/java/com/doumee/api/system/SystemDictController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/ApplyChangeController.java
@@ -8,6 +8,7 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.model.ApplyChange;
import com.doumee.dao.business.vo.CountCyclePriceVO;
@@ -21,6 +22,7 @@
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -129,6 +131,7 @@
    @ApiOperation("加减保业务补充金额")
    @PostMapping("/getChangeCountCyclePriceVO")
    public ApiResponse<CountCyclePriceVO> getChangeCountCyclePriceVO (@RequestBody ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO) {
        applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(new Date(),1));
        return ApiResponse.success("操作成功",applyChangeService.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO));
    }
server/company/src/main/java/com/doumee/api/business/InsuranceApplyController.java
@@ -162,8 +162,8 @@
    @ApiOperation("测试实际金额")
    @GetMapping("/testFee")
    public ApiResponse testFee(Integer id) {
        insuranceApplyService.updateApplyCurrentFee(id);
    public ApiResponse testFee(Integer id,Integer unionId) {
        insuranceApplyService.updateApplyCurrentFee(id, unionId);
        return ApiResponse.success(null);
    }
server/company/src/main/java/com/doumee/api/business/SolutionsController.java
@@ -7,7 +7,9 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.Solutions;
import com.doumee.dao.system.vo.BigDecimalVO;
import com.doumee.service.business.SolutionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -16,7 +18,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -122,4 +126,25 @@
        return ApiResponse.success(solutionsService.findById(id));
    }
    @ApiOperation("testSolutionAddMoney")
    @GetMapping("/testSolutionAddMoney")
    public ApiResponse<BigDecimal> testSolutionAddMoney (Integer id, BigDecimal fee, String start, String end, String newDate, String newEndDate) {
        return ApiResponse.success(solutionsService.testSolutionAddMoney(id,fee, DateUtil.StringToDate(start),DateUtil.StringToDate(end)
                ,DateUtil.StringToDate(newDate),DateUtil.StringToDate(newEndDate)));
    }
    @ApiOperation("testSolutionReduceMoney")
    @GetMapping("/testSolutionReduceMoney")
    public ApiResponse<BigDecimal> testSolutionReduceMoney (Integer id, BigDecimal fee, String start, String end, String reduceStartTime,String reduceEndTime) {
        return ApiResponse.success(solutionsService.testSolutionReduceMoney(id,fee, DateUtil.StringToDate(start),DateUtil.StringToDate(end) ,DateUtil.StringToDate(reduceStartTime),DateUtil.StringToDate(reduceEndTime)));
    }
    @ApiOperation("testSolutionProduceMoney")
    @GetMapping("/testSolutionProduceMoney")
    public ApiResponse<BigDecimal> testSolutionProduceMoney (Integer id, BigDecimal fee, String start, String end,String produceStart) {
        return ApiResponse.success(solutionsService.testSolutionProduceMoney(id,fee, DateUtil.StringToDate(start),DateUtil.StringToDate(end),DateUtil.StringToDate(produceStart)));
    }
}
server/company/src/main/java/com/doumee/api/system/SystemDictController.java
@@ -2,13 +2,16 @@
import com.doumee.api.BaseController;
import com.doumee.biz.system.SystemDictBiz;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.OperaType;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.dao.system.dto.QuerySystemDictDTO;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictListVO;
import com.doumee.service.system.SystemDictService;
import io.swagger.annotations.Api;
@@ -20,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
 * @author Eva.Caesar Liu
@@ -79,4 +83,29 @@
    public ApiResponse<PageData<SystemDictListVO>> findPage (@RequestBody PageWrap<QuerySystemDictDTO> pageWrap) {
        return ApiResponse.success(systemDictService.findPage(pageWrap));
    }
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @ApiOperation("查询字典值")
    @PostMapping("/getAgreement")
    public ApiResponse<List<String>> getAgreement() {
        List<String> list = new ArrayList<>();
        SystemDictData use = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.USE);
        if(Objects.nonNull(use)){
            list.add(use.getCode());
        }else{
            list.add("");
        }
        SystemDictData privacy = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.PRIVACY);
        if(Objects.nonNull(privacy)){
            list.add(privacy.getCode());
        }else{
            list.add("");
        }
        return ApiResponse.success(list);
    }
}
server/company/src/main/resources/application.yml
@@ -12,7 +12,7 @@
#  application:git
#    name: doumeemes
  profiles:
    active: dev
    active: pro
  # JSON返回配置
  jackson:
server/platform/src/main/java/com/doumee/api/business/ApplyChangeController.java
@@ -9,6 +9,7 @@
import com.doumee.dao.business.model.ApplyChange;
import com.doumee.dao.business.model.InsuranceApply;
import com.doumee.service.business.ApplyChangeService;
import com.doumee.service.business.InsuranceApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;    
@@ -30,6 +31,9 @@
    @Autowired
    private ApplyChangeService applyChangeService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
@@ -57,7 +61,9 @@
    @PostMapping("/uploadPidan")
    @RequiresPermissions("business:applychange:uploadPidan")
    public ApiResponse uploadPidan(@RequestBody ApplyChange applyChange) {
        return ApiResponse.success(applyChangeService.uploadPidan(applyChange));
        Integer applyId = applyChangeService.uploadPidan(applyChange);
        insuranceApplyService.updateApplyCurrentFee(applyId,null);
        return ApiResponse.success(null);
    }
    @PreventRepeat
    @ApiOperation("平台修改批单")
server/platform/src/main/java/com/doumee/api/business/UnionChangeController.java
@@ -11,6 +11,7 @@
import com.doumee.dao.business.dto.SmsCheckDTO;
import com.doumee.dao.business.dto.UnionChangeBXDDTO;
import com.doumee.dao.business.model.UnionChange;
import com.doumee.service.business.InsuranceApplyService;
import com.doumee.service.business.UnionChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -33,6 +34,8 @@
    @Autowired
    private UnionChangeService unionChangeService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
@@ -122,6 +125,7 @@
    @RequiresPermissions("business:unionchange:uploadBXD")
    public ApiResponse uploadBXD(@RequestBody UnionChangeBXDDTO unionChangeBXDDTO) {
        unionChangeService.uploadBXD(unionChangeBXDDTO);
        insuranceApplyService.updateApplyCurrentFee(null,unionChangeBXDDTO.getApplyId());
        return ApiResponse.success(null);
    }
server/platform/src/main/java/com/doumee/api/system/SystemDictController.java
@@ -2,13 +2,16 @@
import com.doumee.api.BaseController;
import com.doumee.biz.system.SystemDictBiz;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.OperaType;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.dao.system.dto.QuerySystemDictDTO;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictListVO;
import com.doumee.service.system.SystemDictService;
import io.swagger.annotations.Api;
@@ -20,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
 * @author Eva.Caesar Liu
@@ -35,6 +39,9 @@
    @Autowired
    private SystemDictBiz systemDictBiz;
    @PreventRepeat
    @ApiOperation("新建")
@@ -79,4 +86,29 @@
    public ApiResponse<PageData<SystemDictListVO>> findPage (@RequestBody PageWrap<QuerySystemDictDTO> pageWrap) {
        return ApiResponse.success(systemDictService.findPage(pageWrap));
    }
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @ApiOperation("查询字典值")
    @PostMapping("/getAgreement")
    public ApiResponse<List<String>> getAgreement() {
        List<String> list = new ArrayList<>();
        SystemDictData use = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.USE);
        if(Objects.nonNull(use)){
            list.add(use.getCode());
        }else{
            list.add("");
        }
        SystemDictData privacy = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.PRIVACY);
        if(Objects.nonNull(privacy)){
            list.add(privacy.getCode());
        }else{
            list.add("");
        }
        return ApiResponse.success(list);
    }
}
server/platform/src/main/java/com/doumee/task/ScheduleTool.java
@@ -76,7 +76,7 @@
    @Scheduled(cron = "0 5 00 * * ?")
    public void updateApplyCurrentFee(){
        log.info("==============定时更新保单实际金额=======start======");
        insuranceApplyService.updateApplyCurrentFee(null);
        insuranceApplyService.updateApplyCurrentFee(null,null);
        log.info("==============定时更新保单实际金额======end=======");
        log.info("==============定时更新合并单实际金额=======start======");
server/platform/src/main/resources/application.yml
@@ -11,7 +11,7 @@
#  application:
#  name: doumeemes
  profiles:
    active: dev
    active: pro
  # JSON返回配置
  jackson:
server/pom.xml
@@ -37,6 +37,8 @@
    <oshi.version>5.7.0</oshi.version>
    <jna.version>5.7.0</jna.version>
    <poi.version>5.0.0</poi.version>
    <!-- hutool 工具相关-->
    <hutool.version>5.5.8</hutool.version>
    <!-- 微信小程序 -->
    <weixin-java-miniapp.version>4.1.0</weixin-java-miniapp.version>
  </properties>
@@ -88,7 +90,12 @@
      <artifactId>mysql-connector-java</artifactId>
      <scope>runtime</scope>
    </dependency>
    <!--hutool工具-->
    <dependency>
      <groupId>cn.hutool</groupId>
      <artifactId>hutool-all</artifactId>
      <version>${hutool.version}</version>
    </dependency>
    <!-- swagger -->
    <dependency>
      <groupId>com.github.xiaoymin</groupId>
@@ -235,6 +242,7 @@
      <artifactId>jxl</artifactId>
      <version>2.6.12</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
server/service/pom.xml
@@ -21,6 +21,7 @@
            <artifactId>dianziqian</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
        <!--jacob依赖-->
    </dependencies>
    <properties>
server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java
@@ -97,6 +97,7 @@
        map.put("/public/signNotify", "anon");
        map.put("/public/testPdf", "anon");
        map.put("/business/areas/*", "anon");
        map.put("/system/dict/getAgreement", "anon");
        // - 放行swagger
        map.put("/doc.html", "anon");
        map.put("/webjars/**", "anon");
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -811,7 +811,7 @@
            header2.createCell(5).setCellValue("");
            header2.createCell(6).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime()));
            header2.createCell(7).setCellValue("");
            header2.createCell(8).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getValidTime()));
            header2.createCell(8).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getApplyStartTime()));
            header2.createCell(9).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getDelValidTime()));
            header2.createCell(10).setCellValue(data.getAddNum());
            header2.createCell(11).setCellValue(data.getDelNum());
@@ -1255,7 +1255,7 @@
            sheet.addMergedRegion(new CellRangeAddress(rowIndex ,rowIndex,0,5));
            Row header7= sheet.createRow(rowIndex+1);
            header7.setHeight((short) 3000);
            header7.createCell(0).setCellValue("投保企业签章 :                            \n \n \n" +"日期:     年     月     日    ");
            header7.createCell(0).setCellValue("被保险人签章 :                            \n \n \n" +"日期:     年     月     日    ");
            for (int i =0; i < 6; i++) {
                if(i>0){
                    header7.createCell(i).setCellValue("");
@@ -1650,9 +1650,10 @@
                configFirstCell(sxssfWorkbook,header3.getCell(i));
            }
            sheet.addMergedRegion(new CellRangeAddress(3  ,3,1,8));
            Integer row = 4;
            Integer row = 3;
            List<ApplyChagneDetail> addChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList());
            if(CollectionUtils.isNotEmpty(addChangeDetailList)){
                row = row + 1;
                Row header4 = sheet.createRow(row);
                header4.createCell(0).setCellValue("加保人员");
                for (int i = 0; i < 8; i++) {
@@ -1722,7 +1723,6 @@
                row = row + 1 ;
                for (int rowIndex = 0; rowIndex < reduceChangeDetailList.size(); rowIndex++) {
                    row = row + rowIndex;
                    Row header6 = sheet.createRow(row);
                    ApplyChagneDetail applyChagneDetail = reduceChangeDetailList.get(rowIndex);
                    header6.createCell(0).setCellValue(rowIndex + 1);
@@ -1738,6 +1738,7 @@
                        configDataCell(sxssfWorkbook,header6.getCell(i));
                    }
                    sheet.addMergedRegion(new CellRangeAddress(row  ,row,5,6));
                    row = row +  1;
                }
            }
@@ -1776,7 +1777,7 @@
            byte [] bookByteAry = out.toByteArray();
            InputStream     in = new ByteArrayInputStream(bookByteAry);
            String tempExcel = saveIsToFile(in);
            String tempPdf =System.getProperty("java.io.tmpdir")+File.separator+UUID.randomUUID().toString()+".pdf";
            String tempPdf =   System.getProperty("java.io.tmpdir")+File.separator+UUID.randomUUID().toString()+".pdf"; //"d:/1.docx";
//            ExcelToPdfToolNew.excelToPdf(in,tempPdf);//转PDF
            ExcelToPdfToolNew.excelToPdf(tempExcel,tempPdf);//转PDF
            File f = new File(tempPdf);
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelImporter.java
@@ -143,7 +143,7 @@
     * @return
     */
    public int getDataRowNum(){
        return headerNum+1;
        return headerNum;
    }
    /**
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java
@@ -34,8 +34,8 @@
                // 获取页面设置
                Dispatch pageSetup = Dispatch.get(currentSheet, "PageSetup") .toDispatch();
                Dispatch.put(pageSetup, "Orientation", new Variant(2));
                Dispatch.put(pageSetup, "FitToPagesTall", new Variant(0));
                Dispatch.put(pageSetup, "FitToPagesWide", new Variant(1));
                Dispatch.put(pageSetup, "FitToPagesTall", new Variant(false));
                Dispatch.put(pageSetup, "FitToPagesWide", new Variant(false));
                // 获取页面设置
//                Dispatch.put(pageSetup, "PaperSize", pageSize);
                // 内容缩放
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,7 +1,9 @@
package com.doumee.core.utils;
import cn.hutool.core.util.IdcardUtil;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.dao.business.dto.CountCyclePriceDTO;
import com.doumee.dao.business.model.Solutions;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import io.swagger.models.auth.In;
@@ -13,6 +15,7 @@
import javax.servlet.ServletOutputStream;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL;
import java.net.URLDecoder;
import java.time.LocalDate;
@@ -49,6 +52,11 @@
    public static final String WX_MIN_SECRET = "WX_MIN_SECRET";
    public static final String SYSTEM ="SYSTEM";
    public static final String PROTOCOL ="PROTOCOL";
    public static final String PRIVACY ="PRIVACY";
    public static final String USE ="USE";
    public static final String GOODS_IMG_DIR ="GOODS_IMG_DIR";
    public static final String CREDIT_CODE_REGEX = "[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}";
@@ -175,31 +183,77 @@
    }
    public static CountCyclePriceVO getCountCyclePriceVO(CountCyclePriceDTO countCyclePriceDTO){
        if(Objects.isNull(countCyclePriceDTO)
                || Objects.isNull(countCyclePriceDTO.getSolutions())
                || Objects.isNull(countCyclePriceDTO.getStartDate())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        return Constants.countPriceVO(countCyclePriceDTO.getStartDate(),countCyclePriceDTO.getSolutions());
    }
    public static CountCyclePriceVO countPriceVO(Date startDate, Solutions solutions){
        CountCyclePriceVO countCyclePriceVO = new CountCyclePriceVO();
        if(solutions.getInsureCycleUnit().equals(Constants.ZERO)){
        //天
        if(solutions.getTimeUnit().equals(TimeUnit.DAY.getValue())){
            countCyclePriceVO.setEndDate(
                    DateUtil.getMontageDate(
                        DateUtil.afterDateByType(startDate,0,solutions.getInsureCycle()-1)
                    ,2)
                            DateUtil.afterDateByType(startDate,0,0)
                            ,2)
            );
        }else if(solutions.getInsureCycleUnit().equals(Constants.TWO)){
        }else if(solutions.getTimeUnit().equals(TimeUnit.MONTH.getValue())){
            //获取当月天数
            Integer monthDays = DateUtil.monthDays(startDate);
            //获取天数后的日期
            Date afterDate = DateUtil.afterDateByType(startDate,0,monthDays);
            //赋值 每日结束时分秒
            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
        }else if(solutions.getInsureCycleUnit().equals(Constants.THREE)){
        }else if(solutions.getTimeUnit().equals(TimeUnit.QUARTER.getValue())){
            //获取X年后日期 多了一天
            Date afterDate = DateUtil.afterDateByType(startDate,2,solutions.getInsureCycle());
            Date afterDate = DateUtil.afterDateByType(startDate,1,3);
            //赋值 每日结束时分秒 然后减少一天
            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
        }else if(solutions.getTimeUnit().equals(TimeUnit.HALF_YEAR.getValue())){
            //获取X年后日期 多了一天
            Date afterDate = DateUtil.afterDateByType(startDate,1,6);
            //赋值 每日结束时分秒 然后减少一天
            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
        }else if(solutions.getTimeUnit().equals(TimeUnit.YEAR.getValue())){
            //获取X年后日期 多了一天
            Date afterDate = DateUtil.afterDateByType(startDate,2,1);
            //赋值 每日结束时分秒 然后减少一天
            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
        }
        countCyclePriceVO.setCyclePrice(Constants.countDetailFee(solutions,countCyclePriceVO.getEndDate(),startDate));
        countCyclePriceVO.setCyclePrice(solutions.getPrice());
        return countCyclePriceVO;
    }
//    public static CountCyclePriceVO countPriceVO(Date startDate, Solutions solutions){
//        CountCyclePriceVO countCyclePriceVO = new CountCyclePriceVO();
//        if(solutions.getInsureCycleUnit().equals(Constants.ZERO)){
//            countCyclePriceVO.setEndDate(
//                    DateUtil.getMontageDate(
//                        DateUtil.afterDateByType(startDate,0,solutions.getInsureCycle()-1)
//                    ,2)
//            );
//        }else if(solutions.getInsureCycleUnit().equals(Constants.TWO)){
//            //获取当月天数
//            Integer monthDays = DateUtil.monthDays(startDate);
//            //获取天数后的日期
//            Date afterDate = DateUtil.afterDateByType(startDate,0,monthDays);
//            //赋值 每日结束时分秒
//            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
//        }else if(solutions.getInsureCycleUnit().equals(Constants.THREE)){
//            //获取X年后日期 多了一天
//            Date afterDate = DateUtil.afterDateByType(startDate,2,solutions.getInsureCycle());
//            //赋值 每日结束时分秒 然后减少一天
//            countCyclePriceVO.setEndDate(DateUtil.getMontageDate(afterDate,3));
//        }
//        countCyclePriceVO.setCyclePrice(Constants.countDetailFee(solutions,countCyclePriceVO.getEndDate(),startDate));
//        return countCyclePriceVO;
//    }
    public static Integer getSexByIdCard(String idCard){
        if(StringUtils.isBlank(idCard)){
@@ -579,7 +633,10 @@
    public static void main(String[] args) {
        System.out.println("{\"companyName\":\"应宝科技\",\"endtime\":\"2024-03-01 17:19:00\",\"erpId\":\"4D40185D5BC74A13821BE46EAF8B4179\",\"erpWithVisitDTOList\":[],\"faceImg\":\"20240304/1709518170325_742.jpg\",\"idcardNo\":\"342501199609300535\",\"idcardType\":0,\"name\":\"黄晋\",\"phone\":\"17756328697\",\"reason\":\"探险\",\"receptMemberId\":\"E7E514BD7DE3F27CE0530B630A0AEAE0\",\"starttime\":\"2024-03-01 13:18:00\"}");
        System.out.println(IdcardUtil.isValidCard("340621199310134818"));
        System.out.println(IdcardUtil.isValidCard("341621199310134818"));
//        System.out.println("{\"companyName\":\"应宝科技\",\"endtime\":\"2024-03-01 17:19:00\",\"erpId\":\"4D40185D5BC74A13821BE46EAF8B4179\",\"erpWithVisitDTOList\":[],\"faceImg\":\"20240304/1709518170325_742.jpg\",\"idcardNo\":\"342501199609300535\",\"idcardType\":0,\"name\":\"黄晋\",\"phone\":\"17756328697\",\"reason\":\"探险\",\"receptMemberId\":\"E7E514BD7DE3F27CE0530B630A0AEAE0\",\"starttime\":\"2024-03-01 13:18:00\"}");
    }
    /**
     * 用户类型 0系统用户 1企业用户 2服务机构管理员 3服务机构子账号 4综合服务单位管理员 5综合服务单位子账号 6专家 7县区用户 8市局用户
@@ -1000,6 +1057,128 @@
            this.collectStatus = collectStatus;
        }
    }
    /**
     * 方案 周期单位
     *  coefficient  以半月为最小颗粒
     */
    public enum TimeUnit {
        DAY(0,"日",0),
        MONTH(2,"月",2),
        QUARTER(3,"季度",6),
        HALF_YEAR(4,"半年",12),
        YEAR(5,"年",24);
        private  Integer value;
        private  String des;
        private  Integer coefficient;
        TimeUnit(Integer value, String des, Integer coefficient) {
            this.value = value;
            this.des = des;
            this.coefficient = coefficient;
        }
        public Integer getValue() {
            return value;
        }
        public void setValue(Integer value) {
            this.value = value;
        }
        public String getDes() {
            return des;
        }
        public void setDes(String des) {
            this.des = des;
        }
        public Integer getCoefficient() {
            return coefficient;
        }
        public void setCoefficient(Integer coefficient) {
            this.coefficient = coefficient;
        }
        public static TimeUnit getTimeUnit(Integer value) {
            for (TimeUnit c : TimeUnit.values()) {
                if (Constants.equalsInteger(c.getValue() , value)) {
                    return c;
                }
            }
            return null;
        }
    }
    /**
     * 方案 周期单位 INSURE_CYCLE_UNIT
     *  coefficient  以半月为最小颗粒
     */
    public enum InsureCycleUnit {
        DAY(0,"日",new BigDecimal(1),0),
        HALF_MONTH(1,"半月",new BigDecimal(15.5),1),
        MONTH(2,"月",new BigDecimal(31),2),
        QUARTER(3,"季度",new BigDecimal(92),6),
        HALF_YEAR(4,"半年", new BigDecimal(184),12),
        YEAR(5,"年", new BigDecimal(365),24);
        private  Integer value;
        private  String des;
        private  BigDecimal days;
        private  Integer coefficient;
        public static InsureCycleUnit getInsureCycleUnit(Integer value) {
            for (InsureCycleUnit c : InsureCycleUnit.values()) {
                if (Constants.equalsInteger(c.getValue() , value)) {
                    return c;
                }
            }
            return null;
        }
        InsureCycleUnit(Integer value, String des,BigDecimal days, Integer coefficient) {
            this.value = value;
            this.des = des;
            this.days = days;
            this.coefficient = coefficient;
        }
        public Integer getValue() {
            return value;
        }
        public void setValue(Integer value) {
            this.value = value;
        }
        public String getDes() {
            return des;
        }
        public void setDes(String des) {
            this.des = des;
        }
        public BigDecimal getDays() {
            return days;
        }
        public void setDays(BigDecimal days) {
            this.days = days;
        }
        public Integer getCoefficient() {
            return coefficient;
        }
        public void setCoefficient(Integer coefficient) {
            this.coefficient = coefficient;
        }
    }
@@ -1874,4 +2053,173 @@
            }
        }
    }
    /**
     * 减保 总费用
     * @param solutions
     * @param fee
     * @param startTime
     * @param endTime
     * @param reduceStartTime
     * @param reduceEndTime
     * @return
     */
    public static BigDecimal reduceFee(Solutions solutions,BigDecimal fee,Date startTime ,Date endTime,Date reduceStartTime,Date reduceEndTime){
        Integer days = DateUtil.daysBetweenDates(reduceEndTime, reduceStartTime) + 1;
        Integer countDays = DateUtil.daysBetweenDates(endTime, startTime) + 1;
        Constants.TimeUnit timeUnit = Constants.TimeUnit.getTimeUnit(solutions.getTimeUnit());
        Constants.InsureCycleUnit insureCycleUnit = Constants.InsureCycleUnit.getInsureCycleUnit(solutions.getInsureCycleUnit());
        if(solutions.getTimeUnit().equals(solutions.getInsureCycleUnit())){
            return fee;
        }else{
            if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.DAY.getValue())){
                //天为批改单位
                return fee.multiply(new BigDecimal(days)).divide(new BigDecimal(countDays),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())) {
                //半月为批改单位
                BigDecimal cycle = new BigDecimal(days).divide(insureCycleUnit.getDays(),0,RoundingMode.CEILING);
                //根据投保周期 定义的 每个周期 = X个 半月周期 进行计算
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数
                return fee.multiply(cycle).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())) {
                //月份为批改单位
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(reduceEndTime,reduceStartTime));
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 2
                return fee.multiply(cycle).multiply(new BigDecimal(2)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.QUARTER.getValue())) {
                //季度为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(reduceEndTime,reduceStartTime));
                //转换为 总季度
                cycle = cycle.divide(new BigDecimal(3),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(6)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_YEAR.getValue())) {
                //半年为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(reduceEndTime,reduceStartTime));
                //转换为 半年
                cycle = cycle.divide(new BigDecimal(6),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(12)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else {
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
            }
        }
    }
    /**
     * 加保业务 根据方案计算总费用
     * @param solutions
     * @param startTime
     * @param endTime
     * @param newStartTime
     * @return
     */
    public static BigDecimal addFee(Solutions solutions,BigDecimal fee,Date startTime ,Date endTime,Date newStartTime,Date newEndTime){
        Integer days = DateUtil.daysBetweenDates(newEndTime, newStartTime) + 1;
        Integer countDays = DateUtil.daysBetweenDates(endTime, startTime) + 1;
        Constants.TimeUnit timeUnit = Constants.TimeUnit.getTimeUnit(solutions.getTimeUnit());
        Constants.InsureCycleUnit insureCycleUnit = Constants.InsureCycleUnit.getInsureCycleUnit(solutions.getInsureCycleUnit());
        if(solutions.getTimeUnit().equals(solutions.getInsureCycleUnit())){
            return fee;
        }else{
            if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.DAY.getValue())){
                //天为批改单位
                return fee.multiply(new BigDecimal(days)).divide(new BigDecimal(countDays),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())) {
                //半月为批改单位
                BigDecimal cycle = new BigDecimal(days).divide(insureCycleUnit.getDays(),0,RoundingMode.CEILING);
                //根据投保周期 定义的 每个周期 = X个 半月周期 进行计算
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数
                return fee.multiply(cycle).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())) {
                //月份为批改单位
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(newEndTime,newStartTime));
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 2
                return fee.multiply(cycle).multiply(new BigDecimal(2)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.QUARTER.getValue())) {
                //季度为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(newEndTime,newStartTime));
                //转换为 总季度
                cycle = cycle.divide(new BigDecimal(3),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(6)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_YEAR.getValue())) {
                //半年为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(newEndTime,newStartTime));
                //转换为 半年
                cycle = cycle.divide(new BigDecimal(6),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(12)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else {
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
            }
        }
    }
    /**
     * 计算已产生费用
     * @param solutions
     * @param fee
     * @param startTime
     * @param endTime
     * @return
     */
    public static BigDecimal produceFee(Solutions solutions,BigDecimal fee,Date startTime ,Date endTime,Date produceStartTime){
        //超出天数
        Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), produceStartTime) + 1;
        Integer countDays = DateUtil.daysBetweenDates(endTime, startTime) + 1;
        Constants.TimeUnit timeUnit = Constants.TimeUnit.getTimeUnit(solutions.getTimeUnit());
        Constants.InsureCycleUnit insureCycleUnit = Constants.InsureCycleUnit.getInsureCycleUnit(solutions.getInsureCycleUnit());
        if(solutions.getTimeUnit().equals(solutions.getInsureCycleUnit())){
            return fee;
        }else{
            if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.DAY.getValue())){
                //天为批改单位
                return fee.multiply(new BigDecimal(days)).divide(new BigDecimal(countDays),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())) {
                //半月为批改单位
                BigDecimal cycle = new BigDecimal(days).divide(insureCycleUnit.getDays(),0,RoundingMode.CEILING);
                //根据投保周期 定义的 每个周期 = X个 半月周期 进行计算
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数
                return fee.multiply(cycle).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())) {
                //月份为批改单位
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 2
                return fee.multiply(cycle).multiply(new BigDecimal(2)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.QUARTER.getValue())) {
                //季度为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
                //转换为 总季度
                cycle = cycle.divide(new BigDecimal(3),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(6)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_YEAR.getValue())) {
                //半年为批改单位
                //查询产生费用总月份
                BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
                //转换为 半年
                cycle = cycle.divide(new BigDecimal(6),0,RoundingMode.CEILING);
                // 总金额 * 产生费用的周期 / 投保周期定义的 半月周期数 * 6
                return fee.multiply(cycle).multiply(new BigDecimal(12)).divide(new BigDecimal(timeUnit.getCoefficient()),2, RoundingMode.HALF_UP);
            }else {
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
            }
        }
    }
}
server/service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -1,6 +1,8 @@
package com.doumee.core.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
@@ -8,6 +10,7 @@
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
@@ -3186,8 +3189,17 @@
//        );
        LocalDate startDate= LocalDate.of(2021,2,28);
        LocalDate endDate =LocalDate.of(2022,4,5);
//        System.out.println(
//                new BigDecimal(16).divide(new BigDecimal(15.5),0, RoundingMode.CEILING)
//        );
        LocalDate startDate = DateUtil.StringToDate("2021-02-28 23:59:59").toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();
        LocalDate endDate = DateUtil.StringToDate("2022-04-05 23:59:59").toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();
//        LocalDate startDate= LocalDate.of(2021,2,28);
//        LocalDate endDate =LocalDate.of(2022,4,5);
        Period period = Period.between(startDate,endDate);
        int months = period.getYears()* 12 + period.getMonths();
        System.out.println("Months between the two dates: " + months);
@@ -3214,9 +3226,28 @@
//
//        );
    }
    /**
     * 获取相差的月数
     * @param sDate
     * @param eDate
     * @return
     */
    public static Integer getDifferenceMonths(Date sDate ,Date eDate) {
        LocalDate startDate = sDate.toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();
        LocalDate endDate = eDate.toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();
//        LocalDate startDate= LocalDate.of(2021,2,28);
//        LocalDate endDate =LocalDate.of(2022,4,5);
        Period period = Period.between(endDate,startDate);
        int months = period.getYears()* 12 + period.getMonths();
        return months + 1;
    }
}
server/service/src/main/java/com/doumee/dao/business/dto/CountCyclePriceDTO.java
@@ -1,5 +1,6 @@
package com.doumee.dao.business.dto;
import com.doumee.dao.business.model.Solutions;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -21,5 +22,8 @@
    @ApiModelProperty(value = "生效起期")
    private Date startDate;
    @ApiModelProperty(value = "方案", example = "1")
    private Solutions solutions;
}
server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionChangeDTO.java
@@ -22,9 +22,9 @@
    @ApiModelProperty(value = "加减保/换厂单据主键 多个以,分割")
    private List<Integer> applyIds;
//    @ApiModelProperty(value = "批单日期")
//    @JsonFormat(pattern = "yyyy-MM-dd")
//    private Date applyDate;
    @ApiModelProperty(value = "批单日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date applyDate;
    @ApiModelProperty(value = "业务类型:0=加减保;1=换厂")
    private Integer businessType;
server/service/src/main/java/com/doumee/dao/business/dto/UnionChangeBXDDTO.java
@@ -20,12 +20,16 @@
    @ApiModelProperty(value = "合并单主键")
    private Integer id;
    @ApiModelProperty(value = "投保申请单合并单主键")
    private Integer applyId;
    @ApiModelProperty(value = "保单号")
    private String code;
    @ApiModelProperty(value = "批单日期")
    @ApiModelProperty(value = "批单日期(加保批单日期)")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date applyDate;
    @ApiModelProperty(value = "减保批单日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date delValidTime;
server/service/src/main/java/com/doumee/dao/business/model/ApplyChagneDetail.java
@@ -142,6 +142,11 @@
    @TableField(exist = false)
    private BigDecimal solutionPrice;
    @ApiModelProperty(value = "服务费")
    @TableField(exist = false)
    private BigDecimal serverCost;
    @ApiModelProperty(value = "保险时间单位0天 1半月 2月 3年", example = "1")
    @TableField(exist = false)
    private Integer solutionTimeUnit;
server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java
@@ -147,6 +147,14 @@
    @ExcelColumn(name="人员名单签署合同号")
    private String signMemberListNo;
    @ApiModelProperty(value = "周期结束日期 (2022-02-02 23:59:59)")
    @ExcelColumn(name="周期结束日期 (2022-02-02 23:59:59)")
//    @DateTimeFormat(pattern = "yyyy-MM-dd")
//    @JsonFormat(pattern="yyyy-MM-dd")
    private Date finalEndTime;
    @ApiModelProperty(value = "企业名称")
    @TableField(exist = false)
    private String companyName;
server/service/src/main/java/com/doumee/dao/business/model/Member.java
@@ -9,6 +9,8 @@
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
@@ -111,4 +113,25 @@
    @TableField(exist = false)
    private Integer sn;
    @ApiModelProperty(value = "保险方案主键")
    @TableField(exist = false)
    private Integer solutionId;
    @ApiModelProperty(value = "费用")
    @TableField(exist = false)
    private BigDecimal fee;
    @ApiModelProperty(value = "保单明细行实际开始日期")
    @TableField(exist = false)
    private Date detailStartTime;
    @ApiModelProperty(value = "保单明细行实际结束日期")
    @TableField(exist = false)
    private Date detailEndTime;
    @ApiModelProperty(value = "保单明细行服务费")
    @TableField(exist = false)
    private BigDecimal detailServerCost;
}
server/service/src/main/java/com/doumee/dao/business/model/Solutions.java
@@ -89,11 +89,11 @@
    @ExcelColumn(name="最高年龄")
    private Integer maxAge;
    @ApiModelProperty(value = "保险费用(人/天)", example = "1")
    @ApiModelProperty(value = "保险费用(人) -- 保险费用(人/天)", example = "1")
    @ExcelColumn(name="保险费用(人/天)")
    private BigDecimal price;
    @ApiModelProperty(value = "保险时间单位0天 1半月 2月 3年", example = "1")
    @ApiModelProperty(value = " 周期单位 0天 2月 3季度  4半年 5年 -- 保险时间单位0天 1半月 2月 3年", example = "1")
    @ExcelColumn(name="保险时间单位0天 1半月 2月 3年")
    private Integer timeUnit;
@@ -101,7 +101,7 @@
    @ExcelColumn(name="投保周期")
    private Integer insureCycle;
    @ApiModelProperty(value = "最小投保周期时间单位0天 1半月 2月 3年", example = "1")
    @ApiModelProperty(value = "批改计费单位 0天 1半月 2月 3季度  4半年 5年 -- 最小投保周期时间单位0天 1半月 2月 3年", example = "1")
    @ExcelColumn(name="最小投保周期时间单位0天 1半月 2月 3年")
    private Integer insureCycleUnit;
server/service/src/main/java/com/doumee/dao/business/vo/CountCyclePriceVO.java
@@ -12,10 +12,14 @@
@Data
public class CountCyclePriceVO {
    @ApiModelProperty(value = "总金额", example = "1")
    @ApiModelProperty(value = "加保使用金额", example = "1")
    private BigDecimal cyclePrice;
    @ApiModelProperty(value = "生效止期")
    private Date endDate;
    @ApiModelProperty(value = "加保使用金额", example = "1")
    private BigDecimal reducePrice;
}
server/service/src/main/java/com/doumee/service/business/InsuranceApplyService.java
@@ -117,13 +117,13 @@
    Integer check(InsuranceApply insuranceApply);
     InsuranceApply  findDetailForExport(InsuranceApply model);
    InsuranceApply  findDetailForExport(InsuranceApply model);
    List<InsuranceApply> findListByDTO(InsuranceApplyQueryDTO model);
    Integer editBaoxiandan(InsuranceApply param);
    void updateApplyCurrentFee(Integer id);
    void updateApplyCurrentFee(Integer id,Integer unionId);
    String getSignLink(Integer id);
server/service/src/main/java/com/doumee/service/business/SolutionsService.java
@@ -3,6 +3,9 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.Solutions;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@@ -100,4 +103,12 @@
     * @return long
     */
    long count(Solutions solutions);
    BigDecimal testSolutionAddMoney(Integer id, BigDecimal fee, Date start,Date end,Date newDate,Date newEndDate);
    BigDecimal testSolutionReduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date reduceStartTime,Date reduceEndTime);
    BigDecimal testSolutionProduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date produceStart);
}
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1,6 +1,8 @@
package com.doumee.service.business.impl;
import cn.hutool.core.util.IdcardUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.api.R;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.constants.ResponseStatus;
@@ -193,6 +195,26 @@
        }
        ApplyChange model = applyChangeMapper.selectById(param.getId());
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(model.getApplyId());
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单信息");
        }
        if(model.getType().equals(Constants.ZERO)){
            if(param.getDelValidTime() == null){
                throw  new BusinessException(ResponseStatus.BAD_REQUEST);
            }
            if(!(param.getApplyStartTime().getTime()>insuranceApply.getStartTime().getTime()&&param.getApplyStartTime().getTime()<=insuranceApply.getEndTime().getTime())){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"批增日期必须处于保单申请日期内");
            }
            if(!(param.getDelValidTime().getTime()>insuranceApply.getStartTime().getTime()&&param.getDelValidTime().getTime()<=insuranceApply.getEndTime().getTime())){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"批减日期必须处于保单申请日期内");
            }
        }else{
            if(param.getApplyStartTime().getTime()<model.getApplyStartTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"批单日期必须大于申请日期");
            }
        }
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
@@ -204,10 +226,6 @@
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(model.getApplyId());
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保单信息");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        ApplyChange update = new ApplyChange();
@@ -268,7 +286,7 @@
        applyLogMapper.insert(log);
        return  1;
        return  model.getApplyId();
    }
    @Override
@@ -388,86 +406,117 @@
            if(oldModel == null  ){
                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,用户【"+detail.getMemberName()+"】原保单信息有误,批单日期未在保单日期内!");
            }
            Date endDate = oldModel.getEndTime();
            MemberInsurance memberInsurance = new MemberInsurance(detail,update,update.getEditor(),null,insuranceApply.getSolutionId());
            memberInsurance.setSolutionId(detail.getSolutionId());
            memberInsurance.setWorktypeName(detail.getWorkTypeName());
            memberInsurance.setDuName(detail.getDuName());
            memberInsurance.setApplyChangeId(detail.getApplyChangeId());
            memberInsurance.setSolutionName(detail.getSolutionsName());
            memberInsurance.setPdCode(update.getValidCode());
            memberInsurance.setBdCode(insuranceApply.getCode());
            memberInsurance.setRelationType(Constants.ONE);
            memberInsurance.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(),1));
            memberInsurance.setRelationId(oldModel.getId());
            memberInsuranceJoinMapper.insert(memberInsurance);
            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                    .set(ApplyDetail::getEditor,update.getEditor())
                    .set(ApplyDetail::getEditDate,update.getEditDate())
                    .set(ApplyDetail::getDuId,detail.getDuId())
                    .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                    .eq(ApplyDetail::getId,oldModel.getId())
            );
            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                    .eq(MemberInsurance::getApplyId,update.getApplyId())
                    .le(MemberInsurance::getStartTime,applyStartTime)
                    .ge(MemberInsurance::getEndTime,applyStartTime)
                    .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())!=0,
                            MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 3))
                    .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())==0,
                            MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 2))
                            .ne(MemberInsurance::getId,memberInsurance.getId())
//                    .eq(MemberInsurance::getRelationId,oldModel.getId())
            );
            //如果实际批单日期 和 原记录日期相等 则直接修改记录派遣单位与工种信息
            if(applyStartTime.compareTo(oldModel.getStartTime())!=Constants.ZERO){
                //当前日期大于批单日期 需要回滚数据实际数据
                Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(update.getApplyStartTime(),2))>0;
                //换厂后历史记录的费用 fee
                Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(update.getApplyStartTime(),3),DateUtil.getMontageDate(oldModel.getStartTime(),1))+1;
                BigDecimal oldFee = this.getApplyPrice(update.getApplyId(),days);
                BigDecimal fee = oldModel.getFee();
                BigDecimal oldCurrentFee = oldModel.getCurrentFee();
                applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                        .set(ApplyDetail::getEditor,update.getEditor())
                        .set(ApplyDetail::getEditDate,update.getEditDate())
                        .set(ApplyDetail::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(),3))
                        .set(ApplyDetail::getFee,oldFee)
                        .set(flag,ApplyDetail::getCurrentFee,oldFee)
                        .eq(ApplyDetail::getId,oldModel.getId())
                );
                //修改 员工投保明细记录 历史数据
                memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                        .set(MemberInsurance::getEndTime,update.getApplyStartTime())
                        .set(MemberInsurance::getFee,oldFee)
                        .eq(MemberInsurance::getRelationId,oldModel.getId())
                );
                ApplyDetail applyDetail = new ApplyDetail();
                applyDetail.setApplyId(oldModel.getApplyId());
                applyDetail.setCreateDate(new Date());
                applyDetail.setCreator(update.getEditor());
                applyDetail.setMemberId(oldModel.getMemberId());
                applyDetail.setIdcardNo(detail.getIdcardNo());
                applyDetail.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
                applyDetail.setMemberName(detail.getMemberName());
                applyDetail.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(),1));
                applyDetail.setEndTime(endDate);
                applyDetail.setDuId(detail.getDuId());
                applyDetail.setWorktypeId(detail.getWorktypeId());
                applyDetail.setIdcardNo(oldModel.getIdcardNo());
                applyDetail.setFee(fee.subtract(oldFee));
                applyDetail.setIsdeleted(Constants.ZERO);
                if(flag){
                    applyDetail.setCurrentFee(oldCurrentFee.multiply(oldFee));
                }else{
                    applyDetail.setCurrentFee(BigDecimal.ZERO);
                }
                applyDetail.setSex(oldModel.getSex());
                applyDetail.setMemberName(oldModel.getMemberName());
                applyDetail.setFromId(detail.getId());
                applyDetailJoinMapper.insert(applyDetail);
                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
                memberInsurance.setSolutionId(detail.getSolutionId());
                memberInsurance.setWorktypeName(detail.getWorkTypeName());
                memberInsurance.setDuName(detail.getDuName());
                memberInsurance.setApplyChangeId(detail.getApplyChangeId());
                memberInsurance.setSolutionName(detail.getSolutionsName());
                memberInsurance.setPdCode(update.getValidCode());
                memberInsurance.setBdCode(insuranceApply.getCode());
                memberInsurance.setRelationType(Constants.ONE);
                memberInsuranceJoinMapper.insert(memberInsurance);
            }else{
                applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                        .set(ApplyDetail::getEditor,update.getEditor())
                        .set(ApplyDetail::getEditDate,update.getEditDate())
                        .set(ApplyDetail::getDuId,detail.getDuId())
                        .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                        .eq(ApplyDetail::getId,oldModel.getId())
                );
                //员工投保明细记录 历史数据
                memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                        .set(MemberInsurance::getDuId,detail.getDuId())
                        .set(MemberInsurance::getDuName,detail.getDuName())
                        .set(MemberInsurance::getWorktypeId,detail.getWorktypeId())
                        .set(MemberInsurance::getWorktypeName,detail.getWorkTypeName())
                        .eq(MemberInsurance::getRelationId,oldModel.getId())
                );
            }
//            if(applyStartTime.compareTo(oldModel.getStartTime())!=Constants.ZERO){
//                //当前日期大于批单日期 需要回滚数据实际数据
//                Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(update.getApplyStartTime(),2))>0;
//                //换厂后历史记录的费用 fee
//                Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(update.getApplyStartTime(),3),DateUtil.getMontageDate(oldModel.getStartTime(),1))+1;
//                BigDecimal oldFee = this.getApplyPrice(update.getApplyId(),days);
//                BigDecimal fee = oldModel.getFee();
//                BigDecimal oldCurrentFee = oldModel.getCurrentFee();
//
//                applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
//                        .set(ApplyDetail::getEditor,update.getEditor())
//                        .set(ApplyDetail::getEditDate,update.getEditDate())
//                        .set(ApplyDetail::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(),3))
//                        .set(ApplyDetail::getFee,oldFee)
//                        .set(flag,ApplyDetail::getCurrentFee,oldFee)
//                        .eq(ApplyDetail::getId,oldModel.getId())
//                );
//
//                //修改 员工投保明细记录 历史数据
//                memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
//                        .set(MemberInsurance::getEndTime,update.getApplyStartTime())
//                        .set(MemberInsurance::getFee,oldFee)
//                        .eq(MemberInsurance::getRelationId,oldModel.getId())
//                );
//
//                ApplyDetail applyDetail = new ApplyDetail();
//                applyDetail.setApplyId(oldModel.getApplyId());
//                applyDetail.setCreateDate(new Date());
//                applyDetail.setCreator(update.getEditor());
//                applyDetail.setMemberId(oldModel.getMemberId());
//                applyDetail.setIdcardNo(detail.getIdcardNo());
//                applyDetail.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
//                applyDetail.setMemberName(detail.getMemberName());
//                applyDetail.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(),1));
//                applyDetail.setEndTime(endDate);
//                applyDetail.setDuId(detail.getDuId());
//                applyDetail.setWorktypeId(detail.getWorktypeId());
//                applyDetail.setIdcardNo(oldModel.getIdcardNo());
//                applyDetail.setFee(fee.subtract(oldFee));
//                applyDetail.setIsdeleted(Constants.ZERO);
//                if(flag){
//                    applyDetail.setCurrentFee(oldCurrentFee.multiply(oldFee));
//                }else{
//                    applyDetail.setCurrentFee(BigDecimal.ZERO);
//                }
//                applyDetail.setSex(oldModel.getSex());
//                applyDetail.setMemberName(oldModel.getMemberName());
//                applyDetail.setFromId(detail.getId());
//                applyDetailJoinMapper.insert(applyDetail);
//
//                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
//                memberInsurance.setSolutionId(detail.getSolutionId());
//                memberInsurance.setWorktypeName(detail.getWorkTypeName());
//                memberInsurance.setDuName(detail.getDuName());
//                memberInsurance.setApplyChangeId(detail.getApplyChangeId());
//                memberInsurance.setSolutionName(detail.getSolutionsName());
//                memberInsurance.setPdCode(update.getValidCode());
//                memberInsurance.setBdCode(insuranceApply.getCode());
//                memberInsurance.setRelationType(Constants.ONE);
//                memberInsuranceJoinMapper.insert(memberInsurance);
//            }else{
//                applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
//                        .set(ApplyDetail::getEditor,update.getEditor())
//                        .set(ApplyDetail::getEditDate,update.getEditDate())
//                        .set(ApplyDetail::getDuId,detail.getDuId())
//                        .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
//                        .eq(ApplyDetail::getId,oldModel.getId())
//                );
//                //员工投保明细记录 历史数据
//                memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
//                        .set(MemberInsurance::getDuId,detail.getDuId())
//                        .set(MemberInsurance::getDuName,detail.getDuName())
//                        .set(MemberInsurance::getWorktypeId,detail.getWorktypeId())
//                        .set(MemberInsurance::getWorktypeName,detail.getWorkTypeName())
//                        .eq(MemberInsurance::getRelationId,oldModel.getId())
//                );
//            }
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
@@ -476,8 +525,8 @@
            member.setApplyId(update.getApplyId());
            member.setDuId(detail.getDuId());
            member.setWorktypeId(detail.getWorktypeId());
            member.setStartTime(detail.getStartTime());
            member.setEndTime(detail.getEndTime());
//            member.setStartTime(detail.getStartTime());
//            member.setEndTime(detail.getEndTime());
            memberMapper.updateById(member);
            applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
@@ -513,39 +562,27 @@
        if (detailList == null || detailList.size() == 0) {
            return;
        }
        List<ApplyDetail> addList = new ArrayList<>();
        List<Integer> reduceMembers = new ArrayList<>();
        BigDecimal totalFee = new BigDecimal(0);
        BigDecimal currentFee = new BigDecimal(0);
        //投保记录 加保数据加入新数据  减保数据 修改老数据
        List<MemberInsurance> memberInsuranceList = new ArrayList<>();
        //加保业务 使用的加保金额
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_add = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO_add.setApplyId(update.getApplyId());
        applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
        //加保 添加的金额
        CountCyclePriceVO countCyclePriceVO_add = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_add);
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
        }
        if(solutions.getDataType().equals(Constants.ONE)){
            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
            if(Objects.isNull(solutions)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到方案最新版本信息");
            }
        }
//        if(solutions.getDataType().equals(Constants.ONE)){
//            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
//            if(Objects.isNull(solutions)){
//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到方案最新版本信息");
//            }
//        }
        for (ApplyChagneDetail detail : detailList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
                //查询加保人员是否存在 冲突的 保单明细数据
                if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
                        .lambda()
@@ -556,8 +593,6 @@
                )>Constants.ZERO){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据");
                }
                //加保
                ApplyDetail add = new ApplyDetail();
                add.setApplyId(update.getApplyId());
@@ -573,17 +608,17 @@
                add.setIdcardNo(detail.getIdcardNo());
                add.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
                add.setMemberName(detail.getMemberName());
                add.setRemark(detail.getRemark());
                add.setDuId(detail.getDuId());
                add.setStartTime(update.getApplyStartTime());
                add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
                add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
                add.setFee(countCyclePriceVO_add.getCyclePrice());
                add.setFee(Constants.addFee(solutions,solutions.getPrice(),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),update.getApplyStartTime(),insuranceApply.getEndTime()));
                if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){
                    Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), detail.getStartTime()) + 1;
                    //如果已已产生费用,计算已已产生费用
                    add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
                    //2024年5月8日17:37:23 修改 计算产生费用
                    add.setCurrentFee(
                            Constants.produceFee(solutions,add.getFee(),add.getStartTime(),add.getEndTime(),add.getStartTime())
                    );
                }else{
                    add.setCurrentFee(BigDecimal.ZERO);
                }
@@ -603,6 +638,10 @@
                        .eq(ApplyChagneDetail::getId,detail.getId())
                );
//                if(1==1){
//                    throw new BusinessException(ResponseStatus.SERVER_ERROR);
//                }
            } else {
                    //减保操作
                    //查询员工是在主单下 是否存在生效中的数据
@@ -614,50 +653,61 @@
                    if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) {
                        throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】原保单信息有误,当前申请不支持减保处理!");
                    }
                    //减保业务 使用的减保金额
                    ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
                    applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
                    applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 2));
                    //减保 需要减少的金额 即 退保需要退回的费用
                    CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
                    BigDecimal updateFee = countCyclePriceVO_reduce.getCyclePrice().multiply(new BigDecimal(-1));
                    //当审批时间 大于 申请的时间时 计算实际减少金额 因为已扣金额会大于 应扣金额
                    BigDecimal updateCurrentFee = BigDecimal.ZERO;
                    if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),update.getApplyStartTime()) > 0) {
                        applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(new Date(), 2));
                        //获取 大于审批日期导致 多减的金额
                        CountCyclePriceVO timeoutCountCyclePriceVOReduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
                        updateCurrentFee = timeoutCountCyclePriceVOReduce.getCyclePrice().subtract(countCyclePriceVO_reduce.getCyclePrice());
                    if(!(oldModel.getStartTime().getTime()<update.getDelValidTime().getTime()&& oldModel.getEndTime().getTime()>=update.getDelValidTime().getTime())){
                        throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】减保日期未在保单记录日期中!");
                    }
                    Date delValidTime = oldModel.getStartTime().compareTo(update.getDelValidTime())!=0?
                            DateUtil.getMontageDate(update.getDelValidTime(), 3):
                            DateUtil.getMontageDate(update.getDelValidTime(), 2);
                    BigDecimal sumFee = Objects.isNull(insuranceApply.getServerCost())?
                            solutions.getPrice():
                            solutions.getPrice().add(insuranceApply.getServerCost());
                    // 减保后 总费用
                    BigDecimal updateFee =  Constants.reduceFee(
                            solutions,
                            sumFee
                            ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),delValidTime
                    ) ;
                    //当审批时间 大于 申请的时间时 计算实际减少金额 因为已扣金额会大于 应扣金额
                    BigDecimal updateCurrentFee = BigDecimal.ZERO;
                    if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),oldModel.getStartTime()) > 0) {
                        //// 2024年5月8日17:37:23 修改 计算产生费用
                        updateCurrentFee = Constants.produceFee(solutions,sumFee,insuranceApply.getStartTime(),insuranceApply.getEndTime(),
                                oldModel.getStartTime()
                        );
                    }
                    applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                            .setSql(" fee = ifnull(fee,0)+" + updateFee)
                            .setSql(" fee = " + updateFee)
                            .setSql(" current_fee = " + updateCurrentFee)
                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())!=0,ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 3))
                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())==0,ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 2))
                            .set(ApplyDetail::getEndTime, delValidTime)
                            .set(ApplyDetail::getEditor, update.getEditor())
                            .set(ApplyDetail::getEditDate, update.getEditDate())
                            .eq(ApplyDetail::getId, oldModel.getId())
                    );
                    totalFee = totalFee.add(updateFee);
                    totalFee = totalFee.add(updateFee).subtract(oldModel.getFee());
                    currentFee = currentFee.add(updateCurrentFee);
                    //修改 员工投保明细记录 历史数据
                    memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                            .setSql(" fee = ifnull(fee,0)+" + updateFee)
                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())!=0,MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 3))
                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())==0,MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 2))
                            .set(MemberInsurance::getStartTime, update.getApplyStartTime())
                            .setSql(" fee = " + updateFee)
                            .set(MemberInsurance::getEndTime, delValidTime)
                            .eq(MemberInsurance::getRelationId, oldModel.getId())
                    );
                    //修改业务明细行数据实际批单日期
                    applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                            .set(ApplyChagneDetail::getFee,updateFee)
                            .set(ApplyChagneDetail::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 3))
                            .set(ApplyChagneDetail::getFee,updateFee.subtract(oldModel.getFee()))
                            .set( ApplyChagneDetail::getEndTime, delValidTime)
                            .eq(ApplyChagneDetail::getId,detail.getId())
                    );
//                if(1==1){
//                    throw new BusinessException(ResponseStatus.SERVER_ERROR);
//                }
            }
@@ -668,10 +718,11 @@
            member.setEndTime(detail.getEndTime());
            memberMapper.updateById(member);
            if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
                memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
            }
        }
        if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
            memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
        }
        if (totalFee.compareTo(new BigDecimal(0)) != 0) {
            //如果保单金额发生编码,更新总保单金额
            insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
@@ -778,6 +829,11 @@
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer create(ApplyChange applyChange) {
        if(applyChange.getType().equals(Constants.ZERO)){
            //2024年5月9日14:59:24  修改 默认入当前天
            applyChange.setValidTime(DateUtil.getMontageDate(new Date(),1));
        }
        if (Objects.isNull(applyChange)
                || Objects.isNull(applyChange.getApplyId())
                || Objects.isNull(applyChange.getValidTime())
@@ -809,14 +865,12 @@
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
        }
        if(solutions.getDataType().equals(Constants.ONE)){
            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
            if(Objects.isNull(solutions)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到方案最新版本信息");
            }
        }
//        if(solutions.getDataType().equals(Constants.ONE)){
//            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
//            if(Objects.isNull(solutions)){
//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到方案最新版本信息");
//            }
//        }
        CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
                .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
                .eq(CompanySolution::getSolutionBaseId,solutions.getBaseId())
@@ -840,27 +894,31 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "存在进行中的加减保/换厂申请");
        };
        applyChange.setCreateDate(new Date());
        applyChange.setCreator(loginUserInfo.getId());
        applyChange.setEditor(loginUserInfo.getId());
        applyChange.setEditDate(new Date());
        applyChange.setIsdeleted(Constants.ZERO);
        //根据申请日期 处理加减保的 实际生效日期
        if(Objects.nonNull(solutions.getAddValidDays())){
            applyChange.setApplyStartTime(
                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
            );
        if(applyChange.getType().equals(Constants.ZERO)){
            if(Objects.nonNull(solutions.getAddValidDays())){
                applyChange.setApplyStartTime(
                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
                );
            }else{
                applyChange.setApplyStartTime(applyChange.getValidTime());
            }
            if(Objects.nonNull(solutions.getDelValidDays())){
                applyChange.setDelValidTime(
                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
                );
            }else{
                applyChange.setDelValidTime(applyChange.getValidTime());
            }
        }else{
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
        if(Objects.nonNull(solutions.getDelValidDays())){
            applyChange.setDelValidTime(
                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
            );
        }else{
            applyChange.setDelValidTime(applyChange.getValidTime());
        }
        applyChange.setStatus(Constants.ZERO);
        applyChangeMapper.insert(applyChange);
@@ -874,7 +932,10 @@
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_COMPANY_COMMIT;
        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),"",applyChange.getId(),applyLogType.getKey(), null, null);
        applyLogMapper.insert(log);
//        if(1==1){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "存在进行中的加减保/换厂申请");
//        }
        return applyChange.getId();
    }
@@ -1028,12 +1089,16 @@
            }
            //加保明细数据 计算金额  根据批单时间 计算
            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),1));
            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
//            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),1));
//            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
//            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
            BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost());
            BigDecimal detailFee = Constants.addFee(solutions,
                    sumPrice
                    ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),
                    applyChange.getApplyStartTime(),insuranceApply.getEndTime());
            this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee);
            fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
        }
@@ -1051,21 +1116,14 @@
            if(Objects.isNull(solutions.getCanReduce()) || solutions.getCanReduce().equals(Constants.ZERO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案无法进行减保");
            }
//            if(companySolution.getCanReduce().equals(Constants.ZERO)){
//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该企业分配保险方案无法进行减保");
//            }
            //减保明细数据 计算金额  根据批单时间 前一天 计算
            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),3));
            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee,applyChangeCyclePriceDTO.getValidTime());
            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo, BigDecimal.ZERO,
                    DateUtil.getMontageDate(applyChange.getDelValidTime(),3));
            fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        }
        if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
            if(delDetailSize > addDetailSize){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案仅支持替换");
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案仅支持替换(减保人数不得大于加保人数)");
            }
        }
@@ -1124,8 +1182,8 @@
                    .lambda()
                    .eq(ApplyDetail::getApplyId,applyChange.getApplyId())
                    .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo())
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),3))
            )<=Constants.ZERO){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,减保人员【" + applyChagneDetail.getMemberName() + "】未查询到符合批单日期的数据");
            }
@@ -1148,8 +1206,8 @@
            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
                    .eq(ApplyDetail::getApplyId, applyChange.getApplyId())
                    .eq(ApplyDetail::getMemberId, applyChagneDetail.getMemberId())
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getDelValidTime(),3))
                    .orderByDesc(ApplyDetail::getCreateDate));
            if (applyDetailList.size() > Constants.ONE) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单信息异常,存在多条数据");
@@ -1158,8 +1216,6 @@
            if (applyChange.getValidTime().compareTo(applyDetail.getEndTime()) > 0) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单保障日期至:【" + applyDetail.getEndTime() + "】无法通过本次申请");
            }
            applyChagneDetail.setPrice(applyDetail.getPrice());
            applyChagneDetail.setCreateDate(new Date());
            applyChagneDetail.setCreator(loginUserInfo.getId());
@@ -1174,13 +1230,20 @@
            member.setDuId(applyChagneDetail.getDuId());
            member.setWorktypeId(applyChagneDetail.getWorktypeId());
            member.setStartTime(applyChagneDetail.getStartTime());
            member.setEndTime(applyChagneDetail.getEndTime());
            member.setEndTime(applyDetail.getEndTime());
            memberMapper.updateById(member);
            //查询减保日期
            Integer delDays = DateUtil.daysBetweenDates(applyDetail.getEndTime(),endTime);
            applyChagneDetail.setFee( new BigDecimal(delDays).multiply(applyDetail.getPrice()).multiply(new BigDecimal(-1)));
//            Integer delDays = DateUtil.daysBetweenDates(applyDetail.getEndTime(),endTime);
//            ;
            applyChagneDetail.setFee(
                    Constants.reduceFee(solutions,
                                    Objects.isNull(insuranceApply.getServerCost())?
                                    solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost()),
                                    insuranceApply.getStartTime(),
                                    insuranceApply.getFinalEndTime(),
                                    applyDetail.getStartTime(),endTime)
                            .subtract(applyDetail.getFee()
            ));
            applyChagneDetailJoinMapper.insert(applyChagneDetail);
        }
    }
@@ -1248,6 +1311,9 @@
                    member.setName(applyChagneDetail.getMemberName());
                    member.setCompanyId(insuranceApply.getCompanyId());
                    member.setSex(Constants.getSexByIdCard(applyChagneDetail.getIdcardNo()));
                    if(!IdcardUtil.isValidCard(applyDetail.getIdcardNo())){
                        throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"加保员工信息身份证信息错误["+member.getName()+"]");
                    }
                    member.setIdcardNo(applyChagneDetail.getIdcardNo());
                    member.setApplyId(insuranceApply.getId());
                    member.setDuId(applyChagneDetail.getDuId());
@@ -1569,7 +1635,7 @@
            }else if(pageWrap.getModel().getSolutionType()!=null && pageWrap.getModel().getSolutionType() ==1){
                queryWrapper.eq(Solutions::getShopId,loginUserInfo.getCompanyId());
            }else{
                queryWrapper.apply("((t1.type=0 and exists(select cs.id from company_solution cs where cs.isdeleted=0 AND cs.SOLUTION_ID = t1.SOLUTION_ID  and cs.shop_id="+loginUserInfo.getCompanyId()+")) or (" +
                queryWrapper.apply("((t2.type=0 and exists(select cs.id from company_solution cs where cs.isdeleted=0 AND cs.SOLUTION_ID = t1.SOLUTION_ID  and cs.shop_id="+loginUserInfo.getCompanyId()+")) or (" +
                        "t2.type=1 and t2.shop_id="+loginUserInfo.getCompanyId()+"))") ;
            }
        }else{
@@ -2082,18 +2148,19 @@
                && DateUtil.compareDate( applyChangeCyclePriceDTO.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
        //总天数
        Integer sumDays = DateUtil.daysBetweenDates(insuranceApply.getEndTime(),insuranceApply.getStartTime()) + 1;
        //加减保 到结束的天数
        Integer optDays = DateUtil.daysBetweenDates(insuranceApply.getEndTime(),applyChangeCyclePriceDTO.getValidTime()) + 1;
        CountCyclePriceVO countCyclePriceVO = Constants.countPriceVO(insuranceApply.getStartTime(),solutions);
        //总金额
        BigDecimal sumPrice = countCyclePriceVO.getCyclePrice();
        BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost());
        CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO();
        //加减保金额
//        returnCountCyclePriceVO.setCyclePrice(sumPrice.multiply(new BigDecimal(optDays)).divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP));
        returnCountCyclePriceVO.setCyclePrice(applyDetail.getPrice().multiply(new BigDecimal(optDays)).setScale(2, RoundingMode.HALF_UP));
        returnCountCyclePriceVO.setCyclePrice(Constants.addFee(solutions,
                sumPrice
                ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),
                DateUtil.afterDateByType(applyChangeCyclePriceDTO.getValidTime(),0,solutions.getAddValidDays()),insuranceApply.getEndTime()));
        BigDecimal reducePrice =  solutions.getPrice().subtract(Constants.reduceFee(solutions,
                        sumPrice
                        ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime()
                ,insuranceApply.getStartTime(),
                DateUtil.getMontageDate(
                        DateUtil.afterDateByType(applyChangeCyclePriceDTO.getValidTime(),0,solutions.getDelValidDays()),3)));
        returnCountCyclePriceVO.setReducePrice(reducePrice);
        return returnCountCyclePriceVO;
    }
@@ -2300,4 +2367,62 @@
    }
//    BigDecimal cycle1 = new BigDecimal(days).divide(insureCycleUnit.getDays(),0,RoundingMode.CEILING);
//
//                if(solutions.getTimeUnit().equals(Constants.TimeUnit.MONTH.getValue())){
//                    if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(days).divide(Constants.InsureCycleUnit.HALF_MONTH.getDays(),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(2),2, RoundingMode.HALF_UP);
//                    }else{
//                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
//                    }
//                }else if(solutions.getTimeUnit().equals(Constants.TimeUnit.QUARTER.getValue())){
//                    if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(days).divide(Constants.InsureCycleUnit.HALF_MONTH.getDays(),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(6),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        return fee.multiply(cycle).divide(new BigDecimal(3),2, RoundingMode.HALF_UP);
//                    }else{
//                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
//                    }
//                }else if(solutions.getTimeUnit().equals(Constants.TimeUnit.HALF_YEAR.getValue())){
//                    if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(days).divide(Constants.InsureCycleUnit.HALF_MONTH.getDays(),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(12),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        return fee.multiply(cycle).divide(new BigDecimal(6),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.QUARTER.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        cycle = cycle.divide(new BigDecimal(3),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(2),2, RoundingMode.HALF_UP);
//                    }else{
//                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
//                    }
//                }else if(solutions.getTimeUnit().equals(Constants.TimeUnit.YEAR.getValue())){
//                    if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(days).divide(Constants.InsureCycleUnit.HALF_MONTH.getDays(),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(24),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.MONTH.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        return fee.multiply(cycle).divide(new BigDecimal(12),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.QUARTER.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        cycle = cycle.divide(new BigDecimal(3),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(4),2, RoundingMode.HALF_UP);
//                    }else if(solutions.getInsureCycleUnit().equals(Constants.InsureCycleUnit.HALF_YEAR.getValue())){
//                        BigDecimal cycle = new BigDecimal(DateUtil.getDifferenceMonths(new Date(),startTime));
//                        cycle = cycle.divide(new BigDecimal(6),0,RoundingMode.CEILING);
//                        return fee.multiply(cycle).divide(new BigDecimal(2),2, RoundingMode.HALF_UP);
//                    }else{
//                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
//                    }
//                }else{
//                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"方案配置错误");
//                }
}
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
@@ -404,6 +404,7 @@
        }
        if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda()
                .ne(DispatchUnit::getId,saveDispatchUnitDTO.getId())
                .ne(DispatchUnit::getBaseId,saveDispatchUnitDTO.getId())
                .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
                .eq(DispatchUnit::getName,saveDispatchUnitDTO.getName())
                .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
@@ -418,6 +419,11 @@
        dispatchUnit.setEditor(loginUserInfo.getId());
        dispatchUnitMapper.updateById(dispatchUnit);
        dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda().set(DispatchUnit::getDataType,Constants.ONE).eq(DispatchUnit::getBaseId,dispatchUnit.getId())
                .eq(DispatchUnit::getDataType,Constants.TWO)
        );
        //存储操作记录
        this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.EDIT_UNIT,null);
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
import cn.hutool.core.util.IdcardUtil;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.excel.ExcelExporter;
@@ -98,6 +99,8 @@
    private DuSolutionJoinMapper duSolutionJoinMapper;
    @Autowired
    private DuWorktypeMapper duWorktypeMapper;
    @Autowired
    private DuWorkTypeJoinMapper duWorkTypeJoinMapper;
    @Autowired
    private NoticesMapper noticesMapper;
@@ -235,11 +238,17 @@
        update.setCode(insuranceApply.getCode());
        update.setEndTime(actEndTime);
        update.setStartTime(insuranceApply.getStartTime());
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutionsId(model.getSolutionId());
        countCyclePriceDTO.setStartDate(insuranceApply.getStartTime());
        update.setFinalEndTime(this.getCountCyclePriceVO(countCyclePriceDTO).getEndDate());
        insuranceApplyMapper.updateById(update);
        //修改明细行的开始结束日期
        applyDetailMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda().set(ApplyDetail::getStartTime,insuranceApply.getStartTime())
                .set(ApplyDetail::getEndTime,actEndTime).eq(ApplyDetail::getApplyId,model.getId()));
        applyDetailMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda()
                .set(ApplyDetail::getStartTime,insuranceApply.getStartTime())
                .set(ApplyDetail::getEndTime,actEndTime)
                .eq(ApplyDetail::getApplyId,model.getId()));
        multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda()
                .eq(Multifile::getIsdeleted,Constants.ZERO)
@@ -313,6 +322,7 @@
            memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
        }
        this.updateApplyCurrentFee(insuranceApply.getId(),null);
        return  1;
    }
@@ -1596,18 +1606,18 @@
        insuranceApply.setCheckUserId(loginUserInfo.getId());
        insuranceApply.setStatus(insuranceApplyStatus.getKey());
        insuranceApply.setUnionApplyTbdStatus(Constants.ZERO);
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutionsId(insuranceApply.getSolutionId());
        countCyclePriceDTO.setStartDate(insuranceApply.getStartTime());
        CountCyclePriceVO  countCyclePriceVO = this.getCountCyclePriceVO(countCyclePriceDTO);
        insuranceApply.setApplyEndTime(countCyclePriceVO.getEndDate());
        insuranceApply.setEndTime(countCyclePriceVO.getEndDate());
        insuranceApply.setFinalEndTime(countCyclePriceVO.getEndDate());
        insuranceApplyMapper.insert(insuranceApply);
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO);
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO,true);
        InsuranceApply updBean = new InsuranceApply();
        updBean.setId(insuranceApply.getId());
        updBean.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
@@ -1643,7 +1653,6 @@
                noticesMapper.insert(shopNotices);
            }
        }
        return insuranceApply.getId();
    }
@@ -1709,7 +1718,7 @@
        }
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO);
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO,false);
        insuranceApply.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        insuranceApplyMapper.updateById(insuranceApply);
        //存储日志数据
@@ -1735,7 +1744,8 @@
    public void dealApplyDetailData(InsuranceApply insuranceApply,Solutions solutions,List<ApplyDetail> applyDetailList,LoginUserInfo loginUserInfo,CountCyclePriceVO  countCyclePriceVO){
    public void dealApplyDetailData(InsuranceApply insuranceApply,Solutions solutions,List<ApplyDetail> applyDetailList,
                                    LoginUserInfo loginUserInfo,CountCyclePriceVO  countCyclePriceVO,Boolean checkNewData){
        //查询保险方案下的所有派遣单位
        List<DuSolution>  duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,new MPJLambdaWrapper<DuSolution>()
                .selectAll(DuSolution.class)
@@ -1744,16 +1754,22 @@
                .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
                .eq(DispatchUnit::getUnitStatus,Constants.ONE)
                .eq(DuSolution::getIsdeleted,Constants.ZERO)
                .eq(checkNewData,DispatchUnit::getDataType,Constants.TWO)
                .eq(DuSolution::getStatus,Constants.ONE)
                .eq(DuSolution::getSolutionId,insuranceApply.getSolutionId()));
                .eq(DuSolution::getSolutionId,insuranceApply.getSolutionId())
                .apply(" t1.BASE_ID in ( select du.id from dispatch_unit du where du.STATUS = 0 and du.ISDELETED = 0 ) ")
        );
        if(!CollectionUtils.isNotEmpty(duSolutionList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到派遣单位");
        }
        //查询所有派遣单位下的工种
        List<Integer> duSolutionIdList = duSolutionList.stream().map(i->i.getId()).collect(Collectors.toList());
        List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
        List<DuWorktype> duWorktypeList = duWorkTypeJoinMapper.selectJoinList(DuWorktype.class,new MPJLambdaWrapper<DuWorktype>()
                .selectAll(DuWorktype.class)
                .innerJoin(Worktype.class,Worktype::getId,DuWorktype::getWorkTypeId)
                .eq(DuWorktype::getIsdeleted,Constants.ZERO)
                .eq(DuWorktype::getStatus,Constants.ONE)
                .eq(checkNewData,Worktype::getDataType,Constants.TWO)
                .in(DuWorktype::getDuSolutionId,duSolutionIdList));
        if(!CollectionUtils.isNotEmpty(duWorktypeList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到工种信息");
@@ -1794,12 +1810,16 @@
                        member.setName(applyDetail.getMemberName());
                        member.setCompanyId(insuranceApply.getCompanyId());
                        member.setSex(Constants.getSexByIdCard(applyDetail.getIdcardNo()));
                        if(!IdcardUtil.isValidCard(applyDetail.getIdcardNo())){
                            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保员工信息身份证信息错误["+member.getName()+"]");
                        }
                        member.setIdcardNo(applyDetail.getIdcardNo());
                        member.setApplyId(insuranceApply.getId());
                        member.setStartTime(applyDetail.getStartTime());
                        member.setEndTime(applyDetail.getEndTime());
                        member.setDuId(applyDetail.getDuId());
                        member.setWorktypeId(applyDetail.getWorktypeId());
                        memberMapper.insert(member);
                    }else{
                        member.setApplyId(insuranceApply.getId());
@@ -2516,38 +2536,38 @@
     */
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public void updateApplyCurrentFee(Integer id){
    public void updateApplyCurrentFee(Integer id,Integer unionId){
        List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>()
                .selectAll(InsuranceApply.class)
                .eq(InsuranceApply::getIsdeleted,Constants.ZERO)
                .in(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey(),Constants.InsuranceApplyStatus.WTB_DONE.getKey())
                .eq(!Objects.isNull(id),InsuranceApply::getId,id)
                .eq(!Objects.isNull(unionId),InsuranceApply::getUnionApplyId,unionId)
                .le(InsuranceApply::getStartTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 00:00:00")
                .ge(InsuranceApply::getEndTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 23:59:59")
        );
        if(CollectionUtils.isNotEmpty(insuranceApplyList)){
            for (InsuranceApply insuranceApply:insuranceApplyList) {
//                Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
//                if(Objects.isNull(solutions)){
//                    continue;
//                }
                Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
                if(Objects.isNull(solutions)){
                    continue;
                }
                BigDecimal sumAmount = BigDecimal.ZERO;
                List<ApplyDetail> applyDetailList = applyDetailMapper
                        .selectList(new QueryWrapper<ApplyDetail>().lambda()
                                .eq(ApplyDetail::getApplyId,insuranceApply.getId()));
                if(CollectionUtils.isNotEmpty(applyDetailList)){
                    for (ApplyDetail applyDetail: applyDetailList) {
                        //2024-1-30 10:04:24 修改 根据实际天数进行计算 当前费用  总金额/总天数*实际天数
//                        Integer maxDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
                        BigDecimal fee = applyDetail.getFee();
                        BigDecimal fee =  Objects.isNull(insuranceApply.getServerCost())?
                                solutions.getPrice():
                                solutions.getPrice().add(insuranceApply.getServerCost());
                        //在开始结束日期之间
                        if(applyDetail.getStartTime().compareTo(new Date()) <= 0 && applyDetail.getEndTime().compareTo(new Date()) >= 0 ){
                            Integer days =  DateUtil.calculateBetween(applyDetail.getStartTime(),new Date(),0);
                            applyDetail.setCurrentFee(new BigDecimal(days).multiply(applyDetail.getPrice()));
                            //applyDetail.setCurrentFee(fee.divide(BigDecimal.valueOf(maxDays),2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(days)));
                            applyDetail.setCurrentFee(Constants.produceFee(solutions,fee,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),applyDetail.getStartTime()));
                            applyDetailMapper.updateById(applyDetail);
                        }else if(applyDetail.getStartTime().compareTo(new Date()) <= 0&&applyDetail.getEndTime().compareTo(new Date()) <= 0){
                            applyDetail.setCurrentFee(fee);
                        }else  if(applyDetail.getStartTime().compareTo(new Date()) <= 0&&applyDetail.getEndTime().compareTo(new Date()) <= 0){
                            //在结束日期之后
                            applyDetail.setCurrentFee(applyDetail.getFee());
                            applyDetailMapper.updateById(applyDetail);
                        }
                        sumAmount = sumAmount.add(applyDetail.getCurrentFee());
@@ -2557,6 +2577,9 @@
                insuranceApplyMapper.updateById(insuranceApply);
            }
        }
//        if(1==1){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
//        }
    }
server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
import cn.hutool.core.util.IdcardUtil;
import com.doumee.core.annotation.excel.ExcelImporter;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
@@ -10,6 +11,7 @@
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.MemberMapper;
import com.doumee.dao.business.SolutionsMapper;
import com.doumee.dao.business.WorktypeMapper;
import com.doumee.dao.business.dto.MemberImport;
import com.doumee.dao.business.dto.MemberQueryDTO;
@@ -31,6 +33,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -53,6 +56,9 @@
    @Autowired
    private WorktypeMapper worktypeMapper;
    @Autowired
    private SolutionsMapper solutionsMapper;
    @Override
    public Integer create(Member member) {
@@ -297,10 +303,19 @@
                                " and ad.member_id = t.id ") ;
        if(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())){
            lambdaWrapper = new MPJLambdaWrapper<Member>()
                    .selectAll(Member.class)
                    .select(Member::getId,Member::getName,Member::getIdcardNo)
                    .selectAs(Worktype::getId,Member::getWorktypeId)
                    .selectAs(DispatchUnit::getId,Member::getDuId)
                    .selectAs(DispatchUnit::getName,Member::getDuName)
                    .selectAs(Worktype::getName,Member::getWorkTypeName)
                    .selectAs(Company::getName,Member::getCompanyName)
                    .selectAs(InsuranceApply::getStartTime,Member::getStartTime)
                    .selectAs(InsuranceApply::getFinalEndTime,Member::getEndTime)
                    .selectAs(InsuranceApply::getSolutionId,Member::getSolutionId)
                    .selectAs(ApplyDetail::getStartTime,Member::getDetailStartTime)
                    .selectAs(ApplyDetail::getEndTime,Member::getDetailEndTime)
                    .selectAs(ApplyDetail::getFee,Member::getFee)
                    .selectAs(InsuranceApply::getServerCost,Member::getDetailServerCost)
                    .leftJoin(ApplyDetail.class,ApplyDetail::getMemberId,Member::getId)
                    .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                    .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId)
@@ -316,6 +331,26 @@
                                    " and ad.member_id = t.id ");
        }
        List<Member> memberList = memberJoinMapper.selectJoinList(Member.class,lambdaWrapper);
        if(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())&&Objects.isNull(memberQueryDTO.getValidTime())){
            if(CollectionUtils.isNotEmpty(memberList)){
                Solutions solutions = solutionsMapper.selectById(memberList.get(Constants.ZERO).getSolutionId());
                Date  reduceEndTime = DateUtil.getMontageDate(
                        DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3);
                memberList = memberList.stream().filter(member->member.getDetailStartTime().getTime()<=reduceEndTime.getTime()
                        &&member.getDetailEndTime().getTime()>=reduceEndTime.getTime()).collect(Collectors.toList());
                for (Member member:memberList) {
                    //减保业务 使用 选择人员 根据日期实时查询
                    member.setFee(
                    Constants.reduceFee(solutions,
                            Objects.isNull(member.getDetailServerCost())?
                            solutions.getPrice():solutions.getPrice().add(member.getDetailServerCost()),member.getStartTime(),member.getEndTime(),member.getDetailStartTime(),
                            reduceEndTime).subtract(member.getFee()));
                }
            }
        }
        return memberList;
    }
@@ -338,7 +373,7 @@
        ExcelImporter ie = null;
        List<MemberImport> dataList =null;
        try {
            ie = new ExcelImporter(file,0,0);
            ie = new ExcelImporter(file,1,0);
            dataList = ie.getDataList(MemberImport.class,null);
        }  catch (Exception e) {
            e.printStackTrace();
@@ -381,6 +416,9 @@
            if(StringUtils.isBlank(model.getIdCard())||model.getIdCard().length()!=18){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据身份证信息异常!");
            }
            if(!IdcardUtil.isValidCard(model.getIdCard())){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据身份证信息异常!");
            }
            if(StringUtils.isBlank(model.getName())){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据姓名信息异常!");
            }
server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
@@ -488,13 +488,14 @@
        if (pageWrap.getModel().getBaseId() != null) {
            queryWrapper.eq(Solutions::getBaseId, pageWrap.getModel().getBaseId());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        queryWrapper.orderByDesc(Solutions::getCreateDate);
//        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
//            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
//                queryWrapper.orderByDesc(sortData.getProperty());
//            } else {
//                queryWrapper.orderByAsc(sortData.getProperty());
//            }
//        }
        PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper));
        return pageData;
@@ -546,7 +547,7 @@
                .eq(Company::getStatus,Constants.ZERO)
                .eq(Insurance::getIsdeleted,Constants.ZERO)
                .eq(Insurance::getStatus,Constants.ZERO)
                .orderByAsc(Solutions::getSortnum)
                .orderByDesc(Solutions::getCreateDate)
        );
        return solutionsList;
    }
@@ -585,5 +586,18 @@
    }
    @Override
    public BigDecimal testSolutionAddMoney(Integer id, BigDecimal fee, Date start,Date end,Date newDate,Date newEndTime){
        return Constants.addFee(solutionsMapper.selectById(id),fee,start,end,newDate,newEndTime);
    }
    @Override
    public BigDecimal testSolutionReduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date reduceStartTime,Date reduceEndTime){
        return Constants.reduceFee(solutionsMapper.selectById(id),fee,start,end,reduceStartTime,reduceEndTime);
    }
    @Override
    public BigDecimal testSolutionProduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date produceStart){
        return Constants.produceFee(solutionsMapper.selectById(id),fee,start,end,produceStart);
    }
}
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -156,7 +156,7 @@
                .selectAs(Solutions::getOrtherInfo,UnionApply::getOrtherInfo)
                .selectAs(Solutions::getSpecialAgreement,UnionApply::getSpecialAgreement)
                .selectAs(Solutions::getSpecialInfo,UnionApply::getSpecialInfo);
        queryWrapper.select("(select count(b.id) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum ");
        queryWrapper.select("(select count(distinct(b.MEMBER_ID)) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum ");
        if(pageWrap.getModel().getQueryFlag() == 1){
            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
@@ -246,7 +246,8 @@
        }
        if (pageWrap.getModel().getSignApplyNo() != null) {
            queryWrapper.eq(UnionApply::getSignApplyNo, pageWrap.getModel().getSignApplyNo());
        }if(pageWrap.getSorts().size() == 0){
        }
        if(pageWrap.getSorts().size() == 0){
            queryWrapper.orderByDesc(UnionApply::getCreateDate );
        }else {
            for(PageWrap.SortData sortData: pageWrap.getSorts()) {
@@ -416,6 +417,14 @@
        if(solutions == null){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,方案信息有误,请刷新页面重试");
        }
        //根据方案查询对应的结束日期
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutions(solutions);
        countCyclePriceDTO.setStartDate(saveUnionApplyDTO.getStartDate());
        Date endTime =  Constants.getCountCyclePriceVO(countCyclePriceDTO).getEndDate();
        if(saveUnionApplyDTO.getEndDate().getTime()>endTime.getTime()) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,结束日期超出方案可允许日期周期,请更改后重试!");
        }
        List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,
                new MPJLambdaWrapper<InsuranceApply>()
                        .selectAll(InsuranceApply.class)
@@ -458,8 +467,9 @@
        }
        BigDecimal fee = BigDecimal.ZERO;
        for (ApplyDetail applyDetail:applyDetailList) {
            Integer oldDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
            fee =fee.add(new BigDecimal(maxDays).multiply( applyDetail.getFee()).divide(new BigDecimal(oldDays),2,RoundingMode.HALF_UP));
            fee =fee.add(
                    Constants.reduceFee(solutions,solutions.getPrice(),applyDetail.getStartTime(),applyDetail.getEndTime(),saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate())
            );
        }
        unionApply.setFee(fee);
@@ -752,6 +762,18 @@
        if(!unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该合并单状态已流转,当前不支持该操作~");
        }
        Solutions solutions = solutionsMapper.selectById(unionApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
        }
        //根据方案查询对应的结束日期
        CountCyclePriceDTO countCyclePriceDTO = new CountCyclePriceDTO();
        countCyclePriceDTO.setSolutions(solutions);
        countCyclePriceDTO.setStartDate(unionApplyBXDDTO.getStartTime());
        Date endTime =  Constants.getCountCyclePriceVO(countCyclePriceDTO).getEndDate();
        if(unionApplyBXDDTO.getEndTime().getTime()>endTime.getTime()) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,结束日期超出方案可允许日期周期,请更改后重试!");
        }
        //加价参数
        List<UnionApplyBXDDetailDTO> unionApplyBXDDetailDTOList = unionApplyBXDDTO.getUnionApplyBXDDDetailDTOList();
@@ -794,16 +816,12 @@
                continue;
            }
            BigDecimal price = Constants.formatBigdecimal(applyDetails.get(Constants.ZERO).getPrice());
            Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter(
                    m->m.getApplyId().equals(insuranceApply.getId())).findFirst();
            BigDecimal serverCost = BigDecimal.ZERO;
            if(unionApplyBXDDDetailTO.isPresent()){
                UnionApplyBXDDetailDTO unionApplyBXDDetailDTO = unionApplyBXDDDetailTO.get();
                serverCost = unionApplyBXDDetailDTO.getServerMoney();
                BigDecimal dayServerMoney = unionApplyBXDDetailDTO.getServerMoney().divide(new BigDecimal(maxDays),6, RoundingMode.HALF_UP);
                price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(dayServerMoney));
                //上传保单信息
                if(StringUtils.isNotBlank(unionApplyBXDDetailDTO.getFileUrl())){
                    Multifile multifile = new Multifile();
@@ -824,9 +842,12 @@
            //实际已产生费用(单人)
            BigDecimal currentFee = BigDecimal.ZERO;
            if(useDays==-1){
                currentFee =  new BigDecimal(maxDays).multiply(price);
                currentFee = solutions.getPrice().add(serverCost);
            }else if(useDays>0){
                currentFee =  new BigDecimal(useDays).multiply(price);
                currentFee = Constants.produceFee(solutions,solutions.getPrice().add(serverCost)
                        ,unionApplyBXDDTO.getStartTime(),unionApplyBXDDTO.getEndTime(),
                        unionApplyBXDDTO.getStartTime()
                );
            }
            //生成投保记录
            if(CollectionUtils.isNotEmpty(applyDetailList)){
@@ -834,7 +855,7 @@
                for (ApplyDetail applyDetail:applyDetailList.stream()
                        .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList())) {
                    applyDetail.setPrice(price);
                    applyDetail.setFee(price.multiply(new BigDecimal(maxDays)));
                    applyDetail.setFee(price.multiply(new BigDecimal(maxDays)).add(serverCost));
                    applyDetail.setStartTime(unionApplyBXDDTO.getStartTime());
                    applyDetail.setEndTime(unionApplyBXDDTO.getEndTime());
                    MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
@@ -854,12 +875,18 @@
                }
                memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
            }
            BigDecimal detailFee = Constants.reduceFee(solutions,solutions.getPrice().add(serverCost),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),
                    unionApplyBXDDTO.getStartTime(),unionApplyBXDDTO.getEndTime());
            BigDecimal applyFee =  detailFee.multiply(new BigDecimal(applyDetails.size()));
            Date finalEndTime =  endTime;
            //更新投保申请单
            insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
                    .set(InsuranceApply::getUnionApplyTbdStatus,Constants.THREE)
                    .set(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey())
                    .set(InsuranceApply::getFee,price.multiply(new BigDecimal(applyDetails.size())).multiply(new BigDecimal(maxDays)))
                    .set(InsuranceApply::getFee,applyFee)
                    .set(InsuranceApply::getCurrentFee,currentFee.multiply(new BigDecimal(applyDetails.size())))
                    .set(InsuranceApply::getStartTime,unionApplyBXDDTO.getStartTime())
                    .set(InsuranceApply::getEndTime,unionApplyBXDDTO.getEndTime())
@@ -867,11 +894,12 @@
                    .set(InsuranceApply::getEditor,user.getId())
                    .set(InsuranceApply::getServerCost,serverCost)
                    .set(InsuranceApply::getCode,unionApplyBXDDTO.getCode())
                    .set(InsuranceApply::getFinalEndTime,finalEndTime)
                    .eq(InsuranceApply::getId,insuranceApply.getId()));
            //更新投保单明细金额
            applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda()
                    .set(ApplyDetail::getPrice,price)
                    .set(ApplyDetail::getFee, price.multiply(new BigDecimal(maxDays)))
                    .set(ApplyDetail::getFee, detailFee)
                    .set(ApplyDetail::getCurrentFee,currentFee)
                    .set(ApplyDetail::getEditDate,new Date())
                    .set(ApplyDetail::getEditor,user.getId())
@@ -879,7 +907,7 @@
                    .set(ApplyDetail::getEndTime,unionApplyBXDDTO.getEndTime())
                    .in(ApplyDetail::getId,applyDetails.stream().map(m->m.getId()).collect(Collectors.toList()))
            );
            sumFee = sumFee.add(price.multiply(new BigDecimal(applyDetails.size())).multiply(new BigDecimal(maxDays)));
            sumFee = sumFee.add(applyFee);
            sumCurrFee = sumCurrFee.add(currentFee.multiply(new BigDecimal(applyDetails.size())));
        }
@@ -931,7 +959,7 @@
        List<UnionApply> unionApplyList = unionApplyJoinMapper.selectJoinList(UnionApply.class,new MPJLambdaWrapper<UnionApply>()
                .selectAll(UnionApply.class)
                .eq(UnionApply::getIsdeleted,Constants.ZERO)
                .eq(UnionApply::getStatus,Constants.UnionApplyStatus.FINISH)
                .eq(UnionApply::getStatus,Constants.UnionApplyStatus.FINISH.getKey())
                .eq(!Objects.isNull(id),UnionApply::getId,id)
                .le(UnionApply::getStartTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 00:00:00")
                .ge(UnionApply::getEndTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 23:59:59")
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -167,7 +167,6 @@
                        .eq(UnionChange::getId,id)
                        .last(" limit 1 ")
        );
        if(!Objects.isNull(unionChange)){
            //查询加减保明细数据
            List<ApplyChagneDetail> applyChangeList = applyChagneDetailJoinMapper
@@ -176,18 +175,18 @@
                            .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO)
                            .ne(ApplyChagneDetail::getType,Constants.TWO)
                            .eq(ApplyChagneDetail::getUnionChangeId,unionChange.getId()));
            BigDecimal fee = BigDecimal.ZERO;
            for (ApplyChagneDetail applyChagneDetail:applyChangeList) {
                Integer maxDays = DateUtil.calculateBetween(unionChange.getApplyStartTime(),applyChagneDetail.getEndTime(),0);
                if(applyChagneDetail.getType().equals(Constants.ONE)){
                    maxDays = DateUtil.daysBetweenDates(applyChagneDetail.getEndTime(),DateUtil.getMontageDate(unionChange.getApplyStartTime(),3));
                }
                if(applyChagneDetail.getType().equals(Constants.ZERO)){
                    fee = fee.add(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice()));
                }else{
                    fee = fee.subtract(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())).add(applyChagneDetail.getFee());
                }
            }
            BigDecimal fee = applyChangeList.stream().map(m->m.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add);
//            for (ApplyChagneDetail applyChagneDetail:applyChangeList) {
//                Integer maxDays = DateUtil.calculateBetween(unionChange.getApplyStartTime(),applyChagneDetail.getEndTime(),0);
//                if(applyChagneDetail.getType().equals(Constants.ONE)){
//                    maxDays = DateUtil.daysBetweenDates(applyChagneDetail.getEndTime(),DateUtil.getMontageDate(unionChange.getApplyStartTime(),3));
//                }
//                if(applyChagneDetail.getType().equals(Constants.ZERO)){
//                    fee = fee.add(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice()));
//                }else{
//                    fee = fee.subtract(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())).add(applyChagneDetail.getFee());
//                }
//            }
            unionChange.setFee(fee.setScale(2, RoundingMode.HALF_UP));
            //查询操作记录
            List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
@@ -324,13 +323,18 @@
        if (pageWrap.getModel().getSignApplyNo() != null) {
            queryWrapper.eq(UnionChange::getSignApplyNo, pageWrap.getModel().getSignApplyNo());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
        if(pageWrap.getSorts().size() == 0){
            queryWrapper.orderByDesc(UnionChange::getCreateDate );
        }else {
            for(PageWrap.SortData sortData: pageWrap.getSorts()) {
                if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                    queryWrapper.orderByDesc(sortData.getProperty());
                } else {
                    queryWrapper.orderByAsc(sortData.getProperty());
                }
            }
        }
        PageData<UnionChange> pageData = PageData.from(unionChangeJoinMapper.selectJoinPage(page,UnionChange.class, queryWrapper));
        return pageData;
    }
@@ -350,10 +354,13 @@
        if(!user.getType().equals(Constants.TWO)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非商户用户,无法进行该操作");
        }
        if(saveUnionChangeDTO.getBusinessType().equals(Constants.ZERO)){
            //2024年5月9日14:59:24  修改 默认入当前天
            saveUnionChangeDTO.setApplyDate(DateUtil.getMontageDate(new Date(),1));
        }
        if(Objects.isNull(saveUnionChangeDTO)
                || Objects.isNull(saveUnionChangeDTO.getApplyIds())
                || Objects.isNull(saveUnionChangeDTO.getAddValidDate())
                || Objects.isNull(saveUnionChangeDTO.getDelValidDate())
                || Objects.isNull(saveUnionChangeDTO.getApplyDate())
                || Objects.isNull(saveUnionChangeDTO.getUnionApplyId())
                || Objects.isNull(saveUnionChangeDTO.getBusinessType())
        ){
@@ -364,16 +371,44 @@
        if(Objects.isNull(unionApply)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到合并保单数据");
        }
        //判断批单日期 合并单的批单生效期在为 保单起期的次日 到保单止期
        //获取开始日期次日
        if(saveUnionChangeDTO.getAddValidDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
        || saveUnionChangeDTO.getAddValidDate().getTime()> unionApply.getEndTime().getTime()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
        Solutions solutions = solutionsMapper.selectById(unionApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
        }
        if(saveUnionChangeDTO.getDelValidDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
                || saveUnionChangeDTO.getDelValidDate().getTime()> unionApply.getEndTime().getTime()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
        if(saveUnionChangeDTO.getBusinessType().equals(Constants.ZERO)){
            //根据申请日期 处理加减保的 实际生效日期
            if(Objects.nonNull(solutions.getAddValidDays())){
                saveUnionChangeDTO.setAddValidDate(
                        DateUtil.afterDateByType(saveUnionChangeDTO.getApplyDate(),0,solutions.getAddValidDays())
                );
            }else{
                saveUnionChangeDTO.setAddValidDate(saveUnionChangeDTO.getApplyDate());
            }
            if(Objects.nonNull(solutions.getDelValidDays())){
                saveUnionChangeDTO.setDelValidDate(
                        DateUtil.afterDateByType(saveUnionChangeDTO.getApplyDate(),0,solutions.getDelValidDays())
                );
            }else{
                saveUnionChangeDTO.setDelValidDate(saveUnionChangeDTO.getApplyDate());
            }
            //判断批单日期 合并单的批单生效期在为 保单起期的次日 到保单止期
            //获取开始日期次日
            if(saveUnionChangeDTO.getAddValidDate().getTime()<unionApply.getStartTime().getTime()
                    || saveUnionChangeDTO.getAddValidDate().getTime()> unionApply.getEndTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
            }
            if(saveUnionChangeDTO.getDelValidDate().getTime()<unionApply.getStartTime().getTime()
                    || saveUnionChangeDTO.getDelValidDate().getTime()> unionApply.getEndTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
            }
        }else{
            if(saveUnionChangeDTO.getApplyDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
                    || saveUnionChangeDTO.getApplyDate().getTime()> unionApply.getEndTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的换厂生效期错误");
            }
            saveUnionChangeDTO.setAddValidDate(saveUnionChangeDTO.getApplyDate());
        }
        List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,
                new MPJLambdaWrapper<ApplyChange>()
@@ -637,6 +672,7 @@
                unionChangeBXDDTO.getDelValidTime() == null ){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        unionChangeBXDDTO.setApplyId(unionChange.getUnionApplyId());
        unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
        unionChange.setShopId(Constants.formatIntegerNum(unionChange.getShopId()));
        if(!unionChange.getShopId().equals(user.getCompanyId())){
@@ -655,17 +691,26 @@
        if(Objects.isNull(unionApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到合并保单信息");
        }
        //判断批单日期 合并单的批单生效期在为 保单起期的次日 到保单止期
        //获取开始日期次日
        if(unionChangeBXDDTO.getApplyDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
                || unionChangeBXDDTO.getApplyDate().getTime()> unionApply.getEndTime().getTime()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
        Solutions solutions = solutionsMapper.selectById(unionApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
        }
        if(unionChangeBXDDTO.getDelValidTime().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
                || unionChangeBXDDTO.getDelValidTime().getTime()> unionApply.getEndTime().getTime()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单减保生效期错误");
        if(unionChange.getType().equals(Constants.ZERO)){
            //判断批单日期 合并单的批单生效期在为 保单起期的次日 到保单止期
            //获取开始日期次日
            if(unionChangeBXDDTO.getApplyDate().getTime()<unionApply.getStartTime().getTime()
                    || unionChangeBXDDTO.getApplyDate().getTime()> unionApply.getEndTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单加保生效期错误");
            }
            if(unionChangeBXDDTO.getDelValidTime().getTime()<unionApply.getStartTime().getTime()
                    || unionChangeBXDDTO.getDelValidTime().getTime()> unionApply.getEndTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合并单的批单减保生效期错误");
            }
        }else{
            if(unionChangeBXDDTO.getApplyDate().getTime()<unionChange.getApplyStartTime().getTime()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"批单日期必须大于申请日期");
            }
        }
        List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,
                new MPJLambdaWrapper<ApplyChange>()
@@ -741,6 +786,7 @@
                                .selectAs(Member::getName, ApplyChagneDetail::getMemberName)
                                .selectAs(Solutions::getName,ApplyChagneDetail::getSolutionsName)
                                .selectAs(InsuranceApply::getCode,ApplyChagneDetail::getApplyCode)
                                .selectAs(InsuranceApply::getServerCost,ApplyChagneDetail::getServerCost)
                                .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
                                .leftJoin(Member.class, Member::getId, ApplyChagneDetail::getMemberId)
                                .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
@@ -748,7 +794,7 @@
                                .leftJoin(Worktype.class, Worktype::getId, ApplyChagneDetail::getWorktypeId)
                                .leftJoin(DispatchUnit.class, DispatchUnit::getId, ApplyChagneDetail::getDuId)
                                .eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
                this.dealApplyChangeDetail(applyChange,allList);
                this.dealApplyChangeDetail(applyChange,allList,solutions);
                applyChangeJoinMapper.updateById(applyChange);
                //存储批单完成信息
@@ -789,37 +835,34 @@
    public void dealApplyChangeDetail(ApplyChange applyChange,List<ApplyChagneDetail> applyChagneDetailList){
    public void dealApplyChangeDetail(ApplyChange applyChange,List<ApplyChagneDetail> applyChagneDetailList,Solutions solutions){
        BigDecimalVO bigDecimalVO = new BigDecimalVO();
        bigDecimalVO.setTotalFee(BigDecimal.ZERO);
        bigDecimalVO.setCurrentFee(BigDecimal.ZERO);
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
        for (ApplyChagneDetail detail:applyChagneDetailList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
               this.addChangeDetailData(applyChange,detail,bigDecimalVO);
               this.addChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO);
            }else if(Constants.equalsInteger(detail.getType(),Constants.ONE)){
                this.reduceChangeDetailData(applyChange,detail,bigDecimalVO);
                this.reduceChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO);
            }else{
                this.otherChangeDetailData(applyChange,detail);
                this.otherChangeDetailData(applyChange,detail,insuranceApply);
            }
        }
        if (bigDecimalVO.getTotalFee().compareTo(new BigDecimal(0)) != 0) {
            //如果保单金额发生编码,更新总保单金额
            insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
                    .setSql(" fee = ifnull(fee,0)+" + bigDecimalVO.getTotalFee())
                    .setSql(" current_fee = ifnull(current_fee,0)+" + bigDecimalVO.getCurrentFee())
                    .set(InsuranceApply::getEditor, applyChange.getEditor())
                    .set(InsuranceApply::getEditDate, applyChange.getEditDate())
                    .eq(InsuranceApply::getId, applyChange.getApplyId())
            );
            applyChange.setFee(bigDecimalVO.getTotalFee());
        }
        //如果保单金额发生编码,更新总保单金额
        insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
                .setSql(bigDecimalVO.getTotalFee().compareTo(new BigDecimal(0)) != 0," fee = ifnull(fee,0)+" + bigDecimalVO.getTotalFee())
                .setSql(bigDecimalVO.getCurrentFee().compareTo(new BigDecimal(0)) != 0," current_fee = ifnull(current_fee,0)+" + bigDecimalVO.getCurrentFee())
                .set(InsuranceApply::getEditor, applyChange.getEditor())
                .set(InsuranceApply::getEditDate, applyChange.getEditDate())
                .eq(InsuranceApply::getId, applyChange.getApplyId())
        );
        applyChange.setFee(bigDecimalVO.getTotalFee());
    }
@@ -828,7 +871,7 @@
     * @param applyChange
     * @param detail
     */
    public void addChangeDetailData(ApplyChange applyChange, ApplyChagneDetail detail
    public void addChangeDetailData(ApplyChange applyChange, ApplyChagneDetail detail,InsuranceApply insuranceApply,Solutions solutions
            , BigDecimalVO bigDecimalVO){
        //查询加保人员是否存在 冲突的 保单明细数据
        if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
@@ -840,26 +883,24 @@
        )>Constants.ZERO){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据");
        }
        //总天数
        Integer countDays = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(detail.getEndTime(), 2),0);
        //加保
        ApplyDetail add = new ApplyDetail();
        if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))>=0){
            Integer days =  DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0);
        BigDecimal fee = Objects.isNull(insuranceApply.getServerCost())?
                solutions.getPrice():
                solutions.getPrice().add(insuranceApply.getServerCost());
            //如果已已产生费用,计算已已产生费用
            add.setCurrentFee(new BigDecimal(days).multiply(detail.getPrice()));
        add.setFee(Constants.addFee
                (solutions,fee,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),applyChange.getApplyStartTime(),insuranceApply.getEndTime()));
        if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1))>=0){
            add.setCurrentFee(
                    Constants.produceFee(solutions,fee,insuranceApply.getStartTime(),insuranceApply.getEndTime(),DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1))
            );
        }else{
            add.setCurrentFee(BigDecimal.ZERO);
        }
        add.setPrice(detail.getPrice());
        add.setApplyId(applyChange.getApplyId());
        add.setValidCode(applyChange.getValidCode());
        add.setFee(detail.getFee());
        add.setIsdeleted(Constants.ZERO);
        add.setCreator(applyChange.getEditor());
        add.setCreateDate(applyChange.getEditDate());
@@ -873,7 +914,8 @@
        add.setDuId(detail.getDuId());
        add.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1));
        add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
        add.setFee(new BigDecimal(countDays).multiply(detail.getPrice()));
        add.setRemark(detail.getRemark());
        add.setUnionApplyId(insuranceApply.getUnionApplyId());
        applyDetailJoinMapper.insert(add);
        detail.setFee(add.getFee());
@@ -901,6 +943,9 @@
                .eq(Member::getId, memberInsurance.getMemberId())
        );
//        if(1==1){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
//        }
    }
    /**
@@ -908,59 +953,62 @@
     * @param applyChange
     * @param detail
     */
    public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimalVO bigDecimalVO){
    public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,InsuranceApply insuranceApply,Solutions solutions
            ,BigDecimalVO bigDecimalVO){
        //查询员工是在主单下 是否存在生效中的数据
        ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
                .eq(ApplyDetail::getApplyId, applyChange.getApplyId())
                .eq(ApplyDetail::getMemberId, detail.getMemberId())
                .orderByDesc(ApplyDetail::getCreateDate)
                .last("limit 1"));
        if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > applyChange.getApplyStartTime().getTime()) {
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】原保单信息有误,当前申请不支持减保处理!");
        if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > applyChange.getDelValidTime().getTime()) {
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】当前批减日期不支持减保操作!");
        }
        //计算已生效天数
        //当审批时间 小于 当前时间 计算实际减少金额 因为已扣金额会大于 应扣金额
        if(oldModel.getStartTime().getTime()>applyChange.getDelValidTime().getTime()||oldModel.getEndTime().getTime()<applyChange.getDelValidTime().getTime()){
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,批减日期未在用户【" + detail.getMemberName() + "】的保单日期内!");
        }
        BigDecimal fee = Objects.isNull(insuranceApply.getServerCost())?
                solutions.getPrice():
                solutions.getPrice().add(insuranceApply.getServerCost());
        Date reduceDate = oldModel.getStartTime().compareTo(applyChange.getDelValidTime())!=0?
                DateUtil.getMontageDate(applyChange.getDelValidTime(), 3):
                DateUtil.getMontageDate(applyChange.getDelValidTime(), 2);
        //减保记录操作后的总费用
        BigDecimal reduceFee = Constants.reduceFee(
                solutions,fee,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),reduceDate) ;
        BigDecimal pullFee = BigDecimal.ZERO;
        //减保减少的金额
        BigDecimal reduceFee = BigDecimal.ZERO;
        Date reduceDate = DateUtil.getMontageDate(applyChange.getApplyStartTime(),3);
        if (reduceDate.getTime() <  DateUtil.getMontageDate(new Date(), 2).getTime()) {
            //计算多扣金额
            Integer days = DateUtil.calculateBetween(reduceDate,DateUtil.getMontageDate(new Date(), 2),0);
            pullFee = new BigDecimal(days).multiply(detail.getPrice()).multiply(new BigDecimal(-1));
        if (DateUtil.getMontageDate(new Date(), 2).getTime()>oldModel.getStartTime().getTime()) {
            //// 2024年5月8日17:37:23 修改 计算产生费用
            pullFee =  Constants.produceFee(solutions,fee,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime());
            if(pullFee.compareTo(reduceFee)>0){
                pullFee = reduceFee;
            }
        }
        //计算投保明细应减少的天数
        Integer reduceDays = DateUtil.daysBetweenDates(oldModel.getEndTime(),reduceDate);
        if(reduceDays>0){
            reduceFee = new BigDecimal(reduceDays).multiply(detail.getPrice()).multiply(new BigDecimal(-1));
        }
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee).subtract(oldModel.getFee()));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee).subtract(oldModel.getCurrentFee()));
        applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                .setSql(" fee = ifnull(fee,0)+" + reduceFee)
                .setSql(" current_fee = ifnull(current_fee,0)+" + pullFee)
                .set(oldModel.getStartTime().compareTo(reduceDate)!=0,ApplyDetail::getEndTime, reduceDate)
                .set(oldModel.getStartTime().compareTo(reduceDate)==0,ApplyDetail::getEndTime, DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))
                .setSql(" fee =  " + reduceFee)
                .setSql(" current_fee =  " + pullFee)
                .set(ApplyDetail::getEndTime, reduceDate)
                .set(ApplyDetail::getEditor, applyChange.getEditor())
                .set(ApplyDetail::getEditDate, applyChange.getEditDate())
                .eq(ApplyDetail::getId, oldModel.getId())
        );
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee));
        //修改 员工投保明细记录 历史数据
        memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                .setSql(" fee = ifnull(fee,0)+" + reduceFee)
                .set(oldModel.getStartTime().compareTo(reduceDate)!=0,MemberInsurance::getEndTime,reduceDate)
                .set(oldModel.getStartTime().compareTo(reduceDate)==0,MemberInsurance::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))
                .setSql(" fee = " + reduceFee)
                .set(MemberInsurance::getEndTime,reduceDate)
                .eq(MemberInsurance::getRelationId, oldModel.getId())
        );
        memberMapper.update(null,new UpdateWrapper<Member>()
                .lambda()
                .set(Member::getStartTime,oldModel.getStartTime())
                .set(oldModel.getStartTime().compareTo(reduceDate)!=0,Member::getEndTime,reduceDate)
                .set(oldModel.getStartTime().compareTo(reduceDate)==0,Member::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))
                .set(Member::getEndTime,reduceDate)
                .set(Member::getDuId,oldModel.getDuId())
                .set(Member::getWorktypeId,oldModel.getWorktypeId())
                .eq(Member::getId, oldModel.getMemberId())
@@ -969,13 +1017,13 @@
        //修改业务明细行数据实际批单日期
        applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
//                .setSql(" fee = ifnull(fee,0)+" + reduceFee)
                .set(ApplyChagneDetail::getFee,reduceFee)
                .set(ApplyChagneDetail::getFee,reduceFee.subtract(oldModel.getFee()))
                .set(ApplyChagneDetail::getEndTime,reduceDate)
                .eq(ApplyChagneDetail::getId,detail.getId())
        );
    }
    public void otherChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail){
    public void otherChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,InsuranceApply insuranceApply){
        //实际批单生效日期
        Date applyStartTime = DateUtil.getMontageDate(applyChange.getApplyStartTime(),1);
        //查询减保人员是否存在 冲突的 保单明细数据
@@ -1000,86 +1048,128 @@
        if(oldModel == null  ){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,用户【"+detail.getMemberName()+"】原保单信息有误,批单日期未在保单日期内!");
        }
        //如果实际批单日期 和 原记录日期相等 则直接修改记录派遣单位与工种信息
        if(applyStartTime.compareTo(oldModel.getStartTime())!=Constants.ZERO){
            //当前日期大于批单日期 需要回滚数据实际数据
            Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(applyStartTime,2))>0;
            //换厂后历史记录的费用 fee
            Integer days = DateUtil.calculateBetween(DateUtil.getMontageDate(applyStartTime,3),DateUtil.getMontageDate(oldModel.getStartTime(),1),0);
            BigDecimal oldFee = new BigDecimal(days).multiply(detail.getPrice());
            BigDecimal fee = oldModel.getFee();
            BigDecimal oldCurrentFee = oldModel.getCurrentFee();
            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                    .set(ApplyDetail::getEditor,applyChange.getEditor())
                    .set(ApplyDetail::getEditDate,applyChange.getEditDate())
                    .set(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyStartTime,3))
                    .set(ApplyDetail::getFee,oldFee)
                    .set(flag,ApplyDetail::getCurrentFee,oldFee)
                    .eq(ApplyDetail::getId,oldModel.getId())
            );
        MemberInsurance memberInsurance = new MemberInsurance(detail,applyChange,applyChange.getEditor(),null,insuranceApply.getSolutionId());
        memberInsurance.setSolutionId(detail.getSolutionId());
        memberInsurance.setWorktypeName(detail.getWorkTypeName());
        memberInsurance.setDuName(detail.getDuName());
        memberInsurance.setApplyChangeId(detail.getApplyChangeId());
        memberInsurance.setSolutionName(detail.getSolutionsName());
        memberInsurance.setPdCode(applyChange.getValidCode());
        memberInsurance.setBdCode(insuranceApply.getCode());
        memberInsurance.setRelationType(Constants.ONE);
        memberInsurance.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1));
        memberInsurance.setEndTime(oldModel.getEndTime());
            //修改 员工投保明细记录 历史数据
            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                    .set(MemberInsurance::getEndTime,DateUtil.getMontageDate(applyStartTime,3))
                    .set(MemberInsurance::getFee,oldFee)
                    .eq(MemberInsurance::getRelationId,oldModel.getId())
            );
        applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                .set(ApplyDetail::getEditor,applyChange.getEditor())
                .set(ApplyDetail::getEditDate,applyChange.getEditDate())
                .set(ApplyDetail::getDuId,detail.getDuId())
                .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                .eq(ApplyDetail::getId,oldModel.getId())
        );
            ApplyDetail add = new ApplyDetail();
            add.setApplyId(oldModel.getApplyId());
            add.setCreateDate(new Date());
            add.setCreator(applyChange.getEditor());
            add.setMemberId(oldModel.getMemberId());
            add.setIdcardNo(detail.getIdcardNo());
            add.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
            add.setMemberName(detail.getMemberName());
            add.setStartTime(DateUtil.getMontageDate(applyStartTime,1));
            add.setEndTime(oldModel.getEndTime());
            add.setDuId(detail.getDuId());
            add.setWorktypeId(detail.getWorktypeId());
            add.setIdcardNo(oldModel.getIdcardNo());
            add.setFee(fee.subtract(oldFee));
            add.setIsdeleted(Constants.ZERO);
            if(flag){
                add.setCurrentFee(oldCurrentFee.multiply(oldFee));
            }else{
                add.setCurrentFee(BigDecimal.ZERO);
            }
            add.setSex(oldModel.getSex());
            add.setMemberName(oldModel.getMemberName());
            add.setFromId(detail.getId());
            applyDetailJoinMapper.insert(add);
//        memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
//                .set(MemberInsurance::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
//                .eq(MemberInsurance::getRelationId,oldModel.getId())
//        );
            MemberInsurance memberInsurance = new MemberInsurance(add,applyChange.getId());
            memberInsurance.setSolutionId(detail.getSolutionId());
            memberInsurance.setWorktypeName(detail.getWorkTypeName());
            memberInsurance.setDuName(detail.getDuName());
            memberInsurance.setApplyChangeId(detail.getApplyChangeId());
            memberInsurance.setSolutionName(detail.getSolutionsName());
            memberInsurance.setPdCode(applyChange.getValidCode());
            memberInsurance.setBdCode(applyChange.getApplyCode());
            memberInsurance.setRelationType(Constants.ONE);
            memberInsuranceJoinMapper.insert(memberInsurance);
        memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                        .eq(MemberInsurance::getApplyId,applyChange.getApplyId())
                        .eq(MemberInsurance::getMemberId,detail.getMemberId())
                        .le(MemberInsurance::getStartTime,applyStartTime)
                        .ge(MemberInsurance::getEndTime,applyStartTime)
                        .set(insuranceApply.getStartTime().compareTo(applyChange.getApplyStartTime())!=0,
                                MemberInsurance::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 3))
                        .set(insuranceApply.getStartTime().compareTo(applyChange.getApplyStartTime())==0,
                                MemberInsurance::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))
//                        .ne(MemberInsurance::getId,memberInsurance.getId())
//                    .eq(MemberInsurance::getRelationId,oldModel.getId())
        );
        }else{
            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                    .set(ApplyDetail::getEditor,applyChange.getEditor())
                    .set(ApplyDetail::getEditDate,applyChange.getEditDate())
                    .set(ApplyDetail::getDuId,detail.getDuId())
                    .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                    .eq(ApplyDetail::getId,oldModel.getId())
            );
            //员工投保明细记录 历史数据
            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                    .set(MemberInsurance::getDuId,detail.getDuId())
                    .set(MemberInsurance::getDuName,detail.getDuName())
                    .set(MemberInsurance::getWorktypeId,detail.getWorktypeId())
                    .set(MemberInsurance::getWorktypeName,detail.getWorkTypeName())
                    .eq(MemberInsurance::getRelationId,oldModel.getId())
            );
        memberInsuranceJoinMapper.insert(memberInsurance);
        }
//        //如果实际批单日期 和 原记录日期相等 则直接修改记录派遣单位与工种信息
//        if(applyStartTime.compareTo(oldModel.getStartTime())!=Constants.ZERO){
//            //当前日期大于批单日期 需要回滚数据实际数据
//            Boolean flag = DateUtil.getMontageDate(new Date(),2).compareTo(DateUtil.getMontageDate(applyStartTime,2))>0;
//            //换厂后历史记录的费用 fee
//            Integer days = DateUtil.calculateBetween(DateUtil.getMontageDate(applyStartTime,3),DateUtil.getMontageDate(oldModel.getStartTime(),1),0);
//            BigDecimal oldFee = new BigDecimal(days).multiply(detail.getPrice());
//            BigDecimal fee = oldModel.getFee();
//            BigDecimal oldCurrentFee = oldModel.getCurrentFee();
//
//            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
//                    .set(ApplyDetail::getEditor,applyChange.getEditor())
//                    .set(ApplyDetail::getEditDate,applyChange.getEditDate())
//                    .set(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyStartTime,3))
//                    .set(ApplyDetail::getFee,oldFee)
//                    .set(flag,ApplyDetail::getCurrentFee,oldFee)
//                    .eq(ApplyDetail::getId,oldModel.getId())
//            );
//
//            //修改 员工投保明细记录 历史数据
//            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
//                    .set(MemberInsurance::getEndTime,DateUtil.getMontageDate(applyStartTime,3))
//                    .set(MemberInsurance::getFee,oldFee)
//                    .eq(MemberInsurance::getRelationId,oldModel.getId())
//            );
//
//            ApplyDetail add = new ApplyDetail();
//            add.setApplyId(oldModel.getApplyId());
//            add.setCreateDate(new Date());
//            add.setCreator(applyChange.getEditor());
//            add.setMemberId(oldModel.getMemberId());
//            add.setIdcardNo(detail.getIdcardNo());
//            add.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
//            add.setMemberName(detail.getMemberName());
//            add.setStartTime(DateUtil.getMontageDate(applyStartTime,1));
//            add.setEndTime(oldModel.getEndTime());
//            add.setDuId(detail.getDuId());
//            add.setWorktypeId(detail.getWorktypeId());
//            add.setIdcardNo(oldModel.getIdcardNo());
//            add.setFee(fee.subtract(oldFee));
//            add.setIsdeleted(Constants.ZERO);
//            if(flag){
//                add.setCurrentFee(oldCurrentFee.multiply(oldFee));
//            }else{
//                add.setCurrentFee(BigDecimal.ZERO);
//            }
//            add.setSex(oldModel.getSex());
//            add.setMemberName(oldModel.getMemberName());
//            add.setFromId(detail.getId());
//            applyDetailJoinMapper.insert(add);
//
//            MemberInsurance memberInsurance = new MemberInsurance(add,applyChange.getId());
//            memberInsurance.setSolutionId(detail.getSolutionId());
//            memberInsurance.setWorktypeName(detail.getWorkTypeName());
//            memberInsurance.setDuName(detail.getDuName());
//            memberInsurance.setApplyChangeId(detail.getApplyChangeId());
//            memberInsurance.setSolutionName(detail.getSolutionsName());
//            memberInsurance.setPdCode(applyChange.getValidCode());
//            memberInsurance.setBdCode(applyChange.getApplyCode());
//            memberInsurance.setRelationType(Constants.ONE);
//            memberInsuranceJoinMapper.insert(memberInsurance);
//
//        }else{
//            applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
//                    .set(ApplyDetail::getEditor,applyChange.getEditor())
//                    .set(ApplyDetail::getEditDate,applyChange.getEditDate())
//                    .set(ApplyDetail::getDuId,detail.getDuId())
//                    .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
//                    .eq(ApplyDetail::getId,oldModel.getId())
//            );
//            //员工投保明细记录 历史数据
//            memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
//                    .set(MemberInsurance::getDuId,detail.getDuId())
//                    .set(MemberInsurance::getDuName,detail.getDuName())
//                    .set(MemberInsurance::getWorktypeId,detail.getWorktypeId())
//                    .set(MemberInsurance::getWorktypeName,detail.getWorkTypeName())
//                    .eq(MemberInsurance::getRelationId,oldModel.getId())
//            );
//
//        }
        Member member = memberMapper.selectById(detail.getMemberId());
        if(Objects.isNull(member)){
server/shop/src/main/java/com/doumee/api/business/ApplyChangeController.java
@@ -10,6 +10,7 @@
import com.doumee.dao.business.model.ApplyChange;
import com.doumee.dao.business.model.InsuranceApply;
import com.doumee.service.business.ApplyChangeService;
import com.doumee.service.business.InsuranceApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -31,6 +32,8 @@
    @Autowired
    private ApplyChangeService applyChangeService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
@@ -58,7 +61,9 @@
    @PostMapping("/uploadPidan")
    @RequiresPermissions("business:applychange:uploadPidan")
    public ApiResponse uploadPidan(@RequestBody ApplyChange applyChange) {
        return ApiResponse.success(applyChangeService.uploadPidan(applyChange));
        Integer applyId = applyChangeService.uploadPidan(applyChange);
        insuranceApplyService.updateApplyCurrentFee(applyId,null);
        return ApiResponse.success(null);
    }
    @PreventRepeat
    @ApiOperation("平台修改批单")
server/shop/src/main/java/com/doumee/api/business/UnionApplyController.java
@@ -9,6 +9,7 @@
import com.doumee.dao.business.dto.*;
import com.doumee.dao.business.model.InsuranceApply;
import com.doumee.dao.business.model.UnionApply;
import com.doumee.service.business.InsuranceApplyService;
import com.doumee.service.business.UnionApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -31,6 +32,8 @@
    @Autowired
    private UnionApplyService unionApplyService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
@@ -135,8 +138,17 @@
    @RequiresPermissions("business:unionapply:uploadBXD")
    public ApiResponse uploadBXD(@RequestBody UnionApplyBXDDTO unionApplyBXDDTO) {
        unionApplyService.uploadBXD(unionApplyBXDDTO);
        insuranceApplyService.updateApplyCurrentFee(null,unionApplyBXDDTO.getId());
        unionApplyService.updateUnionApplyCurrentFee(unionApplyBXDDTO.getId());
        return ApiResponse.success(null);
    }
    @ApiOperation("测试合并单实际金额")
    @GetMapping("/testFee")
    public ApiResponse testFee(Integer id) {
        unionApplyService.updateUnionApplyCurrentFee(id);
        return ApiResponse.success(null);
    }
}
server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java
@@ -12,6 +12,7 @@
import com.doumee.dao.business.dto.UnionChangeBXDDTO;
import com.doumee.dao.business.model.UnionApply;
import com.doumee.dao.business.model.UnionChange;
import com.doumee.service.business.InsuranceApplyService;
import com.doumee.service.business.UnionChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -34,6 +35,8 @@
    @Autowired
    private UnionChangeService unionChangeService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
@@ -123,6 +126,7 @@
    @RequiresPermissions("business:unionchange:uploadBXD")
    public ApiResponse uploadBXD(@RequestBody UnionChangeBXDDTO unionChangeBXDDTO) {
        unionChangeService.uploadBXD(unionChangeBXDDTO);
        insuranceApplyService.updateApplyCurrentFee(null,unionChangeBXDDTO.getApplyId());
        return ApiResponse.success(null);
    }
server/shop/src/main/java/com/doumee/api/system/SystemDictController.java
@@ -2,13 +2,16 @@
import com.doumee.api.BaseController;
import com.doumee.biz.system.SystemDictBiz;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.OperaType;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.dao.system.dto.QuerySystemDictDTO;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictListVO;
import com.doumee.service.system.SystemDictService;
import io.swagger.annotations.Api;
@@ -20,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
 * @author Eva.Caesar Liu
@@ -79,4 +83,30 @@
    public ApiResponse<PageData<SystemDictListVO>> findPage (@RequestBody PageWrap<QuerySystemDictDTO> pageWrap) {
        return ApiResponse.success(systemDictService.findPage(pageWrap));
    }
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @ApiOperation("查询字典值")
    @PostMapping("/getAgreement")
    public ApiResponse<List<String>> getAgreement() {
        List<String> list = new ArrayList<>();
        SystemDictData use = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.USE);
        if(Objects.nonNull(use)){
            list.add(use.getCode());
        }else{
            list.add("");
        }
        SystemDictData privacy = systemDictDataBiz.queryByCode(Constants.PROTOCOL,Constants.PRIVACY);
        if(Objects.nonNull(privacy)){
            list.add(privacy.getCode());
        }else{
            list.add("");
        }
        return ApiResponse.success(list);
    }
}