Forráskód Böngészése

Merge remote-tracking branch 'origin/test' into test

Qchen 2 éve
szülő
commit
25fca1e2bf
66 módosított fájl, 3527 hozzáadás és 940 törlés
  1. 0 16
      sql/Online.sql
  2. 4 2
      src/main/java/com/ydtech/constants/enums/dict/agreement/ValidStatus.java
  3. 34 0
      src/main/java/com/ydtech/modules/admin/constants/QuMarks.java
  4. 13 0
      src/main/java/com/ydtech/modules/admin/controller/SysDeptController.java
  5. 15 2
      src/main/java/com/ydtech/modules/admin/controller/SysUserController.java
  6. 9 1
      src/main/java/com/ydtech/modules/admin/dao/SysDeptMapper.java
  7. 10 1
      src/main/java/com/ydtech/modules/admin/dao/SysUserLinkAreaMapper.java
  8. 14 0
      src/main/java/com/ydtech/modules/admin/dao/SysUserMapper.java
  9. 36 1
      src/main/java/com/ydtech/modules/admin/model/QuUserNum.java
  10. 3 2
      src/main/java/com/ydtech/modules/admin/model/dto/QuUserNumDto.java
  11. 14 1
      src/main/java/com/ydtech/modules/admin/service/SysDeptService.java
  12. 14 0
      src/main/java/com/ydtech/modules/admin/service/SysUserService.java
  13. 41 0
      src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java
  14. 6 3
      src/main/java/com/ydtech/modules/admin/service/impl/SysUserLinkAreaServiceImpl.java
  15. 286 15
      src/main/java/com/ydtech/modules/admin/service/impl/SysUserServiceImpl.java
  16. 36 0
      src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeService.java
  17. 10 7
      src/main/java/com/ydtech/modules/fee/service/impl/CostsCalServiceImpl.java
  18. 152 163
      src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceImpl.java
  19. 1 1
      src/main/java/com/ydtech/modules/fnc/controller/CarSettleController.java
  20. 92 6
      src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java
  21. 11 1
      src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java
  22. 205 3
      src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java
  23. 16 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java
  24. 10 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryLogEntity.java
  25. 28 0
      src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java
  26. 1 1
      src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java
  27. 461 143
      src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java
  28. 43 2
      src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java
  29. 5 0
      src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java
  30. 3 0
      src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java
  31. 49 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/BxOtherExcel.java
  32. 131 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/BxSettlementFeesExcel.java
  33. 173 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/SettlementFeesExcel.java
  34. 18 1
      src/main/java/com/ydtech/modules/inv/model/dto/InsPlyIncomeExcelDto.java
  35. 0 8
      src/main/java/com/ydtech/modules/order/aop/aspect/AuditVerificationAspect.java
  36. 25 19
      src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java
  37. 1 1
      src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java
  38. 9 0
      src/main/java/com/ydtech/modules/order/entity/InsOrders.java
  39. 0 235
      src/main/java/com/ydtech/modules/order/entity/bo/UnderwritingRulesBo.java
  40. 3 1
      src/main/java/com/ydtech/modules/order/entity/vo/FeeOrderNewVo.java
  41. 13 0
      src/main/java/com/ydtech/modules/order/entity/vo/InsOrdersEditingVo.java
  42. 66 12
      src/main/java/com/ydtech/modules/order/entity/vo/OrderQueryVo.java
  43. 56 0
      src/main/java/com/ydtech/modules/order/entity/vo/OrderVo.java
  44. 1 1
      src/main/java/com/ydtech/modules/order/service/InsAreaCompanyService.java
  45. 10 0
      src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java
  46. 5 3
      src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java
  47. 91 22
      src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java
  48. 12 12
      src/main/java/com/ydtech/modules/order/service/impl/YongchengOrderApiServiceImpl.java
  49. 1 1
      src/main/java/com/ydtech/modules/order/service/impl/ZijinOrderApiServiceImpl.java
  50. 1 0
      src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementMapper.java
  51. 1 1
      src/main/java/com/ydtech/modules/protocol/entity/vo/PtlAgreementPageVo.java
  52. 2 0
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java
  53. 34 19
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java
  54. 4 0
      src/main/java/com/ydtech/modules/protocols/service/InsFeeOrderNewService.java
  55. 8 0
      src/main/java/com/ydtech/modules/protocols/service/impl/InsFeeOrderNewServiceImpl.java
  56. 126 79
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java
  57. 33 0
      src/main/resources/mapper/modules/admin/SysDeptMapper.xml
  58. 23 18
      src/main/resources/mapper/modules/admin/SysUserLinkAreaMapper.xml
  59. 7 7
      src/main/resources/mapper/modules/admin/SysUserLinkPtlAgreementMapper.xml
  60. 229 3
      src/main/resources/mapper/modules/admin/SysUserMapper.xml
  61. 579 36
      src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml
  62. 5 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml
  63. 3 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryLogMapper.xml
  64. 126 69
      src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml
  65. 98 21
      src/main/resources/mapper/modules/order/InsOrdersMapper.xml
  66. 11 0
      src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

+ 0 - 16
sql/Online.sql

@@ -1,16 +0,0 @@
---  add by hxl   2024-04-27 添加 后线人员关联区域表
-DROP TABLE IF EXISTS `sys_user_link_area`;
-CREATE TABLE `sys_user_link_area`  (
-                                       `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                       `user_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户id',
-                                       `area_code` int(11) NULL DEFAULT NULL COMMENT '区域编码',
-                                       `create_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人ID',
-                                       `create_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
-                                       `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
-                                       `update_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人ID',
-                                       `update_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人名称',
-                                       `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
-                                       PRIMARY KEY (`id`) USING BTREE,
-                                       INDEX `user_id_index`(`user_id`) USING BTREE COMMENT '用户id索引',
-                                       INDEX `area_code_index`(`area_code`) USING BTREE COMMENT '部门code索引'
-) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '后线人员关联区域表' ROW_FORMAT = Dynamic;

+ 4 - 2
src/main/java/com/ydtech/constants/enums/dict/agreement/ValidStatus.java

@@ -15,8 +15,10 @@ import lombok.Getter;
 public enum ValidStatus {
 
 
-    VS_1("1", "有效", 1, 0),
-    VS_2("0", "无效", 2, 0);
+    VS_2("0", "无效", 1, 0),
+    VS_1("1", "有效", 2, 0),
+    VS_3("2", "待审核", 3, 0);
+
 
     // 编号
     private final String code;

+ 34 - 0
src/main/java/com/ydtech/modules/admin/constants/QuMarks.java

@@ -0,0 +1,34 @@
+package com.ydtech.modules.admin.constants;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @version
+ * @description: 金钱属性
+ * @author: tz
+ * @date: 2024-4-11 17:36:15
+ **/
+@Getter
+@AllArgsConstructor
+public enum QuMarks {
+
+    COMPANY_MARK(1, "保险公司"),
+    USER_MARK(2,"用户");
+
+    private final Integer code;
+
+    private final String desc;
+
+    public static QuMarks getQuMarks(Integer code) {
+        for (QuMarks quMarks : QuMarks.values()) {
+            if (quMarks.getCode().equals(code)) {
+                return quMarks;
+            }
+        }
+        return null;
+    }
+
+
+}

+ 13 - 0
src/main/java/com/ydtech/modules/admin/controller/SysDeptController.java

@@ -138,4 +138,17 @@ public class SysDeptController extends BaseController {
         queryWrapper.eq(SysDept::getDelFlag, 0);
         return HttpResult.ok(sysDeptService.findTree("9",null));
     }
+    @ApiOperation(value = "省市区门店列表查询 省级parentId=99 市县传值上级id,level传值省市县门店1,2,3,4")
+    @GetMapping(value = "/queryListByParentId/{level}/{parentId}")
+    public HttpResult<List<SysDept>> queryListByParentId(@PathVariable("level")  String level, @PathVariable("parentId") String parentId) {
+        if(parentId==null || "".equals(parentId)) {
+            return HttpResult.error("parentId父级id不能为空");
+        }
+        if(level==null || "".equals(level)) {
+            return HttpResult.error("level类型不能为空");
+        }
+        List<SysDept> sysDeptList = sysDeptService.queryListByParentId(level,parentId);
+        return HttpResult.ok(sysDeptList);
+    }
+
 }

+ 15 - 2
src/main/java/com/ydtech/modules/admin/controller/SysUserController.java

@@ -713,18 +713,31 @@ public class SysUserController extends BaseController {
         return HttpResult.ok(list);
     }
 
-    @ApiOperation(value = "区域数据管理")
+    @ApiOperation(value = "渠道区域业绩管理")
     @PostMapping(value = "/quUserNum")
     public HttpResult quUserNum(@RequestBody QuUserNumDto quUserNumDto) {
         return HttpResult.ok("", sysUserService.quUserNum(quUserNumDto));
     }
 
-    @ApiOperation(value = "区域数据管理详情")
+    @ApiOperation(value = "渠道区域业绩地区管理详情")
     @PostMapping(value = "/quUserNumDetail")
     public HttpResult quUserNumDetail(@RequestBody QuUserNumDto quUserNumDto) {
         return HttpResult.ok("", sysUserService.getQuUserByCompany(quUserNumDto));
     }
 
+    @ApiOperation(value = "个代区域业绩管理")
+    @PostMapping(value = "quAgentAreaAdmin")
+    public HttpResult quAgentAreaAdmin(@RequestBody QuUserNumDto quUserNumDto) {
+        return HttpResult.ok("", sysUserService.quAgentAreaAdmin(quUserNumDto));
+    }
+
+    @ApiOperation(value = "个代区域业绩地区管理详情")
+    @PostMapping(value = "/quAgentAreaAdminDetail")
+    public HttpResult quAgentAreaAdminDetail(@RequestBody QuUserNumDto quUserNumDto) {
+        return HttpResult.ok("", sysUserService.quAgentAreaAdminDetail(quUserNumDto));
+    }
+
+
     /**
      *  @version
      *  @author: hxl

+ 9 - 1
src/main/java/com/ydtech/modules/admin/dao/SysDeptMapper.java

@@ -4,11 +4,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ydtech.modules.admin.model.SysDept;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface SysDeptMapper extends BaseMapper<SysDept> {
 
 
     String getMaxId(@Param(value = "deptId") String deptId);
-
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/28 10:01
+     *  @Description: 通过县级code查询门店列表
+     */
+    List<SysDept> queryListByParentId(@Param(value = "level") String level,@Param(value = "parentId") String parentId);
 }
 
 

+ 10 - 1
src/main/java/com/ydtech/modules/admin/dao/SysUserLinkAreaMapper.java

@@ -48,5 +48,14 @@ public interface SysUserLinkAreaMapper extends BaseMapper<SysUserLinkArea> {
      *  @Date: 2024/4/26 18:28
      *  @Description: 通过用户id查询绑定的代理人集合
      */
-    List<String> findAreaIdsByAgentUserId(@Param("userId") String userId);
+    List<String> findAreaIdsByAgentUserId(@Param("userId") String userId,@Param("areaCodes") List<String> areaCodes);
+
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/29 9:53
+     *  @Description:查询当前登录人绑定的区域数据
+     */
+    List<String> findAreaCodeByUserId(@Param("userId") String userId);
 }

+ 14 - 0
src/main/java/com/ydtech/modules/admin/dao/SysUserMapper.java

@@ -169,7 +169,18 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 
     List<QuUserNum> getUserNum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
 
+    List<QuUserNum> getMainOrderDetails(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+
     List<QuUserNum> getUserByCompany(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getComMainWaitAuditSum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getComMainWaitPaySum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getComMainAcceptInsuranceSum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+
+    List<QuUserNum> getUserDetail(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getUserMainWaitAuditSum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getUserMainWaitPaySum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+    List<QuUserNum> getUserMainAcceptInsuranceSum(@Param("quUserNumDto") QuUserNumDto quUserNumDto);
+
     /**
      *  @version
      *  @author: hxl
@@ -264,6 +275,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      *  @Description:  查询所有的代理人
      */
     List<SysUserBaseVO> getAgentUserList();
+
+
+    List<SysUserBaseVO> getAgentUserIdsByAreaIds();
 }
 
 

+ 36 - 1
src/main/java/com/ydtech/modules/admin/model/QuUserNum.java

@@ -16,13 +16,31 @@ public class QuUserNum {
     @ApiModelProperty(value = "订单状态")
     private String orderStatus;
 
+    @ApiModelProperty(value = "主订单待核保总数")
+    private String mainWaitAuditSum;
+
+    @ApiModelProperty(value = "主订单已核保总数")
+    private String mainWaitPaySum;
+
+    @ApiModelProperty(value = "主订单已承包总数")
+    private String mainAcceptInsuranceSum;
+
+    @ApiModelProperty(value = "子订单待核保总数")
+    private String subWaitAuditSum;
+
+    @ApiModelProperty(value = "子订单已核保总数")
+    private String subWaitPaySum;
+
+    @ApiModelProperty(value = "子订单已承包总数")
+    private String subAcceptInsuranceSum;
+
     @ApiModelProperty(value = "保险公司编号")
     private String companyId;
 
     @ApiModelProperty(value = "保险公司名称")
     private String insCompany;
 
-    @ApiModelProperty(value = "该订单状态下次数")
+    @ApiModelProperty(value = "订单总数")
     private String count;
 
     @ApiModelProperty(value = "报价次数")
@@ -52,4 +70,21 @@ public class QuUserNum {
     @ApiModelProperty(value = "省市区名称")
     private String areaName;
 
+
+    public QuUserNum() {
+        this.mainWaitAuditSum = "0";
+        this.mainWaitPaySum = "0";
+        this.mainAcceptInsuranceSum = "0";
+        this.subWaitAuditSum = "0";
+        this.subWaitPaySum = "0";
+        this.subAcceptInsuranceSum = "0";
+        this.count = "0";
+        this.quoteNum = "0";
+        this.submitNum = "0";
+        this.hasInsuredNum = "0";
+        this.totalSumpremium = "0";
+        this.jqPremiumSum = "0";
+        this.syPremiumSum = "0";
+        this.taxaMountSum = "0";
+    }
 }

+ 3 - 2
src/main/java/com/ydtech/modules/admin/model/dto/QuUserNumDto.java

@@ -38,10 +38,11 @@ public class QuUserNumDto {
     @ApiModelProperty(value = "下属ID")
     private List<String> userIds;
 
-    @TableField(exist = false)
+    @ApiModelProperty(value = "查询标示")
+    private Integer quMarks;
+
     private int pageNum;
 
-    @TableField(exist = false)
     private int pageSize;
 
 }

+ 14 - 1
src/main/java/com/ydtech/modules/admin/service/SysDeptService.java

@@ -1,11 +1,11 @@
 package com.ydtech.modules.admin.service;
 
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.admin.model.SysArea;
 import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.vo.SysDeptVo;
 import com.ydtech.modules.admin.model.vo.TreeSysDeptVO;
@@ -76,7 +76,20 @@ public interface SysDeptService extends IService<SysDept> {
      * @return
      */
     public List<SysDept> findTeamList(String deptId);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/28 10:22
+     *  @Description:  查询省、市、县、门店列表信息
+     */
+    List<SysDept> queryListByParentId(String level, String parentId);
 
+    /**
+     * 查询归属地区信息
+     * @param deptId
+     * @return
+     */
+    String queryBelongArea(String deptId);
 }
 
 

+ 14 - 0
src/main/java/com/ydtech/modules/admin/service/SysUserService.java

@@ -147,6 +147,20 @@ public interface SysUserService extends IService<SysUser> {
      *  @Description: 获取客服人员列表数据
      */
     List<SysUserBaseVO> getCustomerUsers();
+
+    IPage<QuUserNum> quAgentAreaAdmin(QuUserNumDto quUserNumDto);
+
+    IPage<QuUserNum> quAgentAreaAdminDetail(QuUserNumDto quUserNumDto);
+
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/29 16:03
+     *  @Description: 查询当前登陆人管理的渠道信息 ,即领导人为当前人的数据
+     */
+    List<String> getUserIdsByLeaderId(String userId);
+
 }
 
 

+ 41 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java

@@ -9,14 +9,18 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.exception.SystemException;
+import com.ydtech.modules.admin.dao.SysAreaMapper;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
+import com.ydtech.modules.admin.model.SysArea;
 import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.vo.SysDeptVo;
 import com.ydtech.modules.admin.model.vo.TreeSysDeptVO;
+import com.ydtech.modules.admin.service.SysAreaService;
 import com.ydtech.modules.admin.service.SysDeptService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
@@ -32,6 +36,14 @@ import java.util.stream.Collectors;
 public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         implements SysDeptService {
 
+    @Autowired
+    private SysDeptMapper sysDeptMapper;
+
+    @Autowired
+    private SysAreaService sysAreaService;
+
+    @Autowired
+    private SysAreaMapper sysAreaMapper;
 
     @Override
     public List<SysDept> findTree(String deptId,String managementSource) {
@@ -366,6 +378,35 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         List<SysDept> sysDeptList = list(lqw);
         return sysDeptList;
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/28 10:24
+     *  @Description: 查询省、市、县 、门店的列表
+     */
+    @Override
+    public List<SysDept> queryListByParentId(String level, String parentId) {
+        return sysDeptMapper.queryListByParentId(level,parentId);
+    }
+
+    @Override
+    public String queryBelongArea(String deptId){
+        //长度大于8的话 进行切割
+        StringBuilder result = new StringBuilder();
+        if(deptId.length() >= 8)
+        {
+            String area = deptId.substring(2,8);
+            SysArea sysArea = sysAreaMapper.selectOne(new LambdaQueryWrapper<SysArea>().eq(SysArea::getAreaCode, area));
+            if(sysArea == null){
+                return "";
+            }
+            List<SysArea> sysAreas = sysAreaService.queryAllParent(sysArea);
+            result.append(sysAreas.get(2).getAreaCname());
+            result.append(sysAreas.get(1).getAreaCname());
+            result.append(sysAreas.get(0).getAreaCname());
+        }
+        return result.toString();
+    }
 
 }
 

+ 6 - 3
src/main/java/com/ydtech/modules/admin/service/impl/SysUserLinkAreaServiceImpl.java

@@ -161,11 +161,14 @@ public class SysUserLinkAreaServiceImpl extends ServiceImpl<SysUserLinkAreaMappe
      *  @version
      *  @author: hxl
      *  @Date: 2024/4/27 9:45
-     *  @Description:  获取当前用户绑定区域的代理人ids 或者  代理人机构信息
-     *  1 为用户ids   2 为机构ids
+     *  @Description:  获取当前用户绑定区域的代理人ids
      */
     @Override
     public List<String> findUserIdsByLoginUserId(String  userId) {
-       return  sysUserLinkAreaMapper.findAreaIdsByAgentUserId(userId);
+        List<String> areaCodes = sysUserLinkAreaMapper.findAreaCodeByUserId(userId);
+        if(areaCodes!=null && areaCodes.size()>0){
+            return  sysUserLinkAreaMapper.findAreaIdsByAgentUserId(userId,areaCodes);
+        }
+        return  null;
     }
 }

+ 286 - 15
src/main/java/com/ydtech/modules/admin/service/impl/SysUserServiceImpl.java

@@ -11,6 +11,7 @@ import com.ydtech.constants.SysConstants;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.exception.SystemException;
+import com.ydtech.modules.admin.constants.QuMarks;
 import com.ydtech.modules.admin.constants.RoleConstants;
 import com.ydtech.modules.admin.dao.SysUserMapper;
 import com.ydtech.modules.admin.model.*;
@@ -813,7 +814,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             // 根据查询条件获取用户数量统计信息
             quUserNumDto.setUserIds(strIds);
             List<QuUserNum> userNums = sysUserMapper.getUserNum(quUserNumDto);
-
+            List<QuUserNum> orderDetails = sysUserMapper.getMainOrderDetails(quUserNumDto);
             // 根据区域名称匹配用户数量统计信息,并构造最终返回的结果列表
             for (QuUserNum quUserNum : userNums) {
                 for (SysArea sysArea : areaList) {
@@ -822,27 +823,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                         String substring = sysArea.getAreaCode().substring(0, quUserNumDto.getGrouping());
                         if (quUserNum.getAreaCode().equals(substring)) {
                             quUserNum.setAreaName(sysArea.getAreaCname());
-                            quUserNums.add(quUserNum);
                         }
                     }
                 }
+                for (QuUserNum orderDetail : orderDetails) {
+                    if (quUserNum.getAreaCode().equals(orderDetail.getAreaCode())) {
+                        quUserNum.setMainAcceptInsuranceSum(orderDetail.getMainAcceptInsuranceSum());
+                        quUserNum.setMainWaitAuditSum(orderDetail.getMainWaitAuditSum());
+                        quUserNum.setMainWaitPaySum(orderDetail.getMainWaitPaySum());
+                    }
+                }
+                quUserNums.add(quUserNum);
             }
         }
 
-
         // 为每个区域生成未匹配到的统计信息
         for (SysArea sysArea : areaList) {
             if (exists(quUserNums, sysArea)) {
                 QuUserNum userNum = new QuUserNum();
                 // 设置未匹配到的区域的默认统计信
                 userNum.setAreaName(sysArea.getAreaCname());
-                userNum.setQuoteNum("0");
-                userNum.setSubmitNum("0");
-                userNum.setHasInsuredNum("0");
-                userNum.setTotalSumpremium("0");
-                userNum.setJqPremiumSum("0");
-                userNum.setSyPremiumSum("0");
-                userNum.setTaxaMountSum("0");
                 quUserNums.add(userNum);
             }
         }
@@ -895,8 +895,65 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         // 设置查询条件中的用户ID列表
         quUserNumDto.setUserIds(strIds);
 
-        // 根据公司和用户ID列表查询用户数量统计信息
-        List<QuUserNum> deptByCompany = sysUserMapper.getUserByCompany(quUserNumDto);
+        List<QuUserNum> deptByCompany = new ArrayList<>();
+
+        if (quUserNumDto.getQuMarks().equals(QuMarks.COMPANY_MARK.getCode())) {
+            // 根据公司和用户ID列表查询用户数量统计信息
+            deptByCompany = sysUserMapper.getUserByCompany(quUserNumDto);
+            // 获取公司主订单待核保订单数量
+            List<QuUserNum> mainWaitAuditSums = sysUserMapper.getComMainWaitAuditSum(quUserNumDto);
+            // 获取公司主订单已核保待缴费订单数量
+            List<QuUserNum> mainWaitPaySums = sysUserMapper.getComMainWaitPaySum(quUserNumDto);
+            // 获取公司主订单已承包订单数量
+            List<QuUserNum> mainAcceptInsuranceSums = sysUserMapper.getComMainAcceptInsuranceSum(quUserNumDto);
+
+            for (QuUserNum quUserNum : deptByCompany) {
+                for (QuUserNum mainWaitAuditSum : mainWaitAuditSums) {
+                    if (quUserNum.getCompanyId().equals(mainWaitAuditSum.getCompanyId())) {
+                        quUserNum.setMainWaitAuditSum(mainWaitAuditSum.getMainWaitAuditSum());
+                    }
+                }
+                for (QuUserNum mainWaitPaySum : mainWaitPaySums) {
+                    if (quUserNum.getCompanyId().equals(mainWaitPaySum.getCompanyId())) {
+                        quUserNum.setMainWaitPaySum(mainWaitPaySum.getMainWaitPaySum());
+                    }
+                }
+                for (QuUserNum mainAcceptInsuranceSum : mainAcceptInsuranceSums) {
+                    if (quUserNum.getCompanyId().equals(mainAcceptInsuranceSum.getCompanyId())) {
+                        quUserNum.setMainAcceptInsuranceSum(mainAcceptInsuranceSum.getMainAcceptInsuranceSum());
+                    }
+                }
+            }
+
+        } else if (quUserNumDto.getQuMarks().equals(QuMarks.USER_MARK.getCode())) {
+            // 根据公司和用户ID列表查询用户数量统计信息
+            deptByCompany = sysUserMapper.getUserDetail(quUserNumDto);
+
+            // 获取用户主订单待核保订单数量
+            List<QuUserNum> mainWaitAuditSums = sysUserMapper.getUserMainWaitAuditSum(quUserNumDto);
+            // 获取用户主订单已核保待缴费订单数量
+            List<QuUserNum> mainWaitPaySums = sysUserMapper.getUserMainWaitPaySum(quUserNumDto);
+            // 获取用户主订单已承包订单数量
+            List<QuUserNum> mainAcceptInsuranceSums = sysUserMapper.getUserMainAcceptInsuranceSum(quUserNumDto);
+
+            for (QuUserNum quUserNum : deptByCompany) {
+                for (QuUserNum mainWaitAuditSum : mainWaitAuditSums) {
+                    if (quUserNum.getUserId().equals(mainWaitAuditSum.getUserId()) && quUserNum.getCompanyId().equals(mainWaitAuditSum.getCompanyId())) {
+                        quUserNum.setMainWaitAuditSum(mainWaitAuditSum.getMainWaitAuditSum());
+                    }
+                }
+                for (QuUserNum mainWaitPaySum : mainWaitPaySums) {
+                    if (quUserNum.getUserId().equals(mainWaitPaySum.getUserId()) && quUserNum.getCompanyId().equals(mainWaitPaySum.getCompanyId())) {
+                        quUserNum.setMainWaitPaySum(mainWaitPaySum.getMainWaitPaySum());
+                    }
+                }
+                for (QuUserNum mainAcceptInsuranceSum : mainAcceptInsuranceSums) {
+                    if (quUserNum.getUserId().equals(mainAcceptInsuranceSum.getUserId()) && quUserNum.getCompanyId().equals(mainAcceptInsuranceSum.getCompanyId())) {
+                        quUserNum.setMainAcceptInsuranceSum(mainAcceptInsuranceSum.getMainAcceptInsuranceSum());
+                    }
+                }
+            }
+        }
 
         List<QuUserNum> paginate = paginate(deptByCompany, quUserNumDto.getPageNum(), quUserNumDto.getPageSize());
 
@@ -990,9 +1047,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      */
     @Override
     public List<SysUserBaseVO> getAllUsersByHospitality(SysUserVOExt sysUserVOExt) {
-        if(StringUtils.isNotEmpty(sysUserVOExt.getUserId()) || StringUtils.isNotEmpty(sysUserVOExt.getIdentity()) ||
-                StringUtils.isNotEmpty(sysUserVOExt.getMobile()) || StringUtils.isNotEmpty(sysUserVOExt.getName())){
-            return  super.baseMapper.getAllUsersByHospitality(sysUserVOExt);
+        if (StringUtils.isNotEmpty(sysUserVOExt.getUserId()) || StringUtils.isNotEmpty(sysUserVOExt.getIdentity()) ||
+                StringUtils.isNotEmpty(sysUserVOExt.getMobile()) || StringUtils.isNotEmpty(sysUserVOExt.getName())) {
+            return super.baseMapper.getAllUsersByHospitality(sysUserVOExt);
         }
         return new ArrayList<SysUserBaseVO>();
     }
@@ -1008,6 +1065,220 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return super.baseMapper.getCustomerUsers(new SysUserVOExt());
     }
 
+    @Override
+    public IPage<QuUserNum> quAgentAreaAdmin(QuUserNumDto quUserNumDto) {
+
+        //获取所有代理人用户
+        List<SysUserBaseVO> agentUsers = baseMapper.getAgentUserIdsByAreaIds();
+
+        List<String> strIds = agentUsers.stream().map(SysUserBaseVO::getUserId).collect(Collectors.toList());
+
+        // 根据区域编码和级别查询符合条件的区域
+        LambdaQueryWrapper<SysArea> wrapper = new LambdaQueryWrapper<>();
+        if (strIds.size() != 0) {
+            if (quUserNumDto.getAreaCode() != null && !"".equals(quUserNumDto.getAreaCode())) {
+                String area = quUserNumDto.getAreaCode();
+                switch (quUserNumDto.getLevel()) {
+                    case "1": { // 省级查询逻辑
+                        quUserNumDto.setGrouping(4);
+                        String prefix = area.substring(0, 2);
+                        strIds.removeIf(id -> !id.contains("99" + prefix));
+                        quUserNumDto.setLevel("2");
+                        wrapper.eq(SysArea::getLevel, "2");
+                        wrapper.likeRight(SysArea::getAreaCode, prefix);
+                        break;
+                    }
+                    case "2": {  // 市级查询逻辑
+                        quUserNumDto.setGrouping(6);
+                        String prefix = area.substring(0, 4);
+                        strIds.removeIf(id -> !id.contains("99" + prefix));
+                        quUserNumDto.setLevel("3");
+                        wrapper.eq(SysArea::getLevel, "3");
+                        wrapper.likeRight(SysArea::getAreaCode, prefix);
+                        break;
+                    }
+                    case "3": {  // 区县级查询逻辑
+                        quUserNumDto.setGrouping(6);
+                        String prefix = area.substring(0, 6);
+                        strIds.removeIf(id -> !id.contains("99" + prefix));
+                        quUserNumDto.setLevel("3");
+                        wrapper.eq(SysArea::getLevel, "3");
+                        wrapper.likeRight(SysArea::getAreaCode, prefix);
+                        break;
+                    }
+                }
+            } else { // 默认查询省级区域
+                quUserNumDto.setGrouping(2);
+                quUserNumDto.setLevel("1");
+                wrapper.eq(SysArea::getLevel, "1");
+            }
+        }
+
+        //遍历匹配区域名称
+        List<SysArea> areaList = sysAreaService.list(wrapper);
+
+        List<QuUserNum> quUserNums = new ArrayList<>();
+        // 如果没有查询到用户ID,则直接返回空的分页对象
+        if (strIds.size() != 0) {
+            // 根据查询条件获取用户数量统计信息
+            quUserNumDto.setUserIds(strIds);
+            List<QuUserNum> userNums = sysUserMapper.getUserNum(quUserNumDto);
+
+            List<QuUserNum> orderDetails = sysUserMapper.getMainOrderDetails(quUserNumDto);
+            // 根据区域名称匹配用户数量统计信息,并构造最终返回的结果列表
+            for (QuUserNum quUserNum : userNums) {
+                for (SysArea sysArea : areaList) {
+                    if (!Objects.isNull(sysArea.getAreaCode())) {
+                        // 匹配区域名称
+                        String substring = sysArea.getAreaCode().substring(0, quUserNumDto.getGrouping());
+                        if (quUserNum.getAreaCode().equals(substring)) {
+                            quUserNum.setAreaName(sysArea.getAreaCname());
+                        }
+                    }
+                }
+                for (QuUserNum orderDetail : orderDetails) {
+                    if (quUserNum.getAreaCode().equals(orderDetail.getAreaCode())) {
+                        quUserNum.setMainAcceptInsuranceSum(orderDetail.getMainAcceptInsuranceSum());
+                        quUserNum.setMainWaitAuditSum(orderDetail.getMainWaitAuditSum());
+                        quUserNum.setMainWaitPaySum(orderDetail.getMainWaitPaySum());
+                    }
+                }
+                quUserNums.add(quUserNum);
+            }
+        }
+        // 为每个区域生成未匹配到的统计信息
+        for (SysArea sysArea : areaList) {
+            if (exists(quUserNums, sysArea)) {
+                QuUserNum userNum = new QuUserNum();
+                // 设置未匹配到的区域的默认统计信
+                userNum.setAreaName(sysArea.getAreaCname());
+                quUserNums.add(userNum);
+            }
+        }
+        List<QuUserNum> paginate = paginate(quUserNums, quUserNumDto.getPageNum(), quUserNumDto.getPageSize());
+
+        // 构造返回的分页对象
+        IPage<QuUserNum> recordsPage = new Page<>(quUserNumDto.getPageNum(), quUserNumDto.getPageSize());
+        recordsPage.setRecords(paginate);
+        recordsPage.setTotal(quUserNums.size());
+        return recordsPage;
+
+    }
+
+    @Override
+    public IPage<QuUserNum> quAgentAreaAdminDetail(QuUserNumDto quUserNumDto) {
+
+        //获取所有代理人用户
+        List<SysUserBaseVO> agentUsers = baseMapper.getAgentUserIdsByAreaIds();
+
+        List<String> strIds = agentUsers.stream().map(SysUserBaseVO::getUserId).collect(Collectors.toList());
+
+
+        // 如果未指定区域码,返回空分页对
+        if (Objects.isNull(quUserNumDto.getAreaCode())) {
+            return new Page<>();
+        }
+
+        // 根据区域码筛选有效的下属ID
+        strIds.removeIf(id -> !id.contains("99" + quUserNumDto.getAreaCode()));
+
+        // 如果筛选后没有有效的下属ID,返回空分页对象
+        if (strIds.size() == 0) {
+            return new Page<>();
+        }
+
+        // 设置查询条件中的用户ID列表
+        quUserNumDto.setUserIds(strIds);
+
+        List<QuUserNum> deptByCompany = new ArrayList<>();
+
+        if (quUserNumDto.getQuMarks().equals(QuMarks.COMPANY_MARK.getCode())) {
+            // 根据公司和用户ID列表查询用户数量统计信息
+            deptByCompany = sysUserMapper.getUserByCompany(quUserNumDto);
+            // 获取公司主订单待核保订单数量
+            List<QuUserNum> mainWaitAuditSums = sysUserMapper.getComMainWaitAuditSum(quUserNumDto);
+            // 获取公司主订单已核保待缴费订单数量
+            List<QuUserNum> mainWaitPaySums = sysUserMapper.getComMainWaitPaySum(quUserNumDto);
+            // 获取公司主订单已承包订单数量
+            List<QuUserNum> mainAcceptInsuranceSums = sysUserMapper.getComMainAcceptInsuranceSum(quUserNumDto);
+
+            for (QuUserNum quUserNum : deptByCompany) {
+                for (QuUserNum mainWaitAuditSum : mainWaitAuditSums) {
+                    if (quUserNum.getCompanyId().equals(mainWaitAuditSum.getCompanyId())) {
+                        quUserNum.setMainWaitAuditSum(mainWaitAuditSum.getMainWaitAuditSum());
+                    }
+                }
+                for (QuUserNum mainWaitPaySum : mainWaitPaySums) {
+                    if (quUserNum.getCompanyId().equals(mainWaitPaySum.getCompanyId())) {
+                        quUserNum.setMainWaitPaySum(mainWaitPaySum.getMainWaitPaySum());
+                    }
+                }
+                for (QuUserNum mainAcceptInsuranceSum : mainAcceptInsuranceSums) {
+                    if (quUserNum.getCompanyId().equals(mainAcceptInsuranceSum.getCompanyId())) {
+                        quUserNum.setMainAcceptInsuranceSum(mainAcceptInsuranceSum.getMainAcceptInsuranceSum());
+                    }
+                }
+            }
+
+        } else if (quUserNumDto.getQuMarks().equals(QuMarks.USER_MARK.getCode())) {
+            // 根据公司和用户ID列表查询用户数量统计信息
+            deptByCompany = sysUserMapper.getUserDetail(quUserNumDto);
+
+            // 获取用户主订单待核保订单数量
+            List<QuUserNum> mainWaitAuditSums = sysUserMapper.getUserMainWaitAuditSum(quUserNumDto);
+            // 获取用户主订单已核保待缴费订单数量
+            List<QuUserNum> mainWaitPaySums = sysUserMapper.getUserMainWaitPaySum(quUserNumDto);
+            // 获取用户主订单已承包订单数量
+            List<QuUserNum> mainAcceptInsuranceSums = sysUserMapper.getUserMainAcceptInsuranceSum(quUserNumDto);
+
+            for (QuUserNum quUserNum : deptByCompany) {
+                for (QuUserNum mainWaitAuditSum : mainWaitAuditSums) {
+                    if (quUserNum.getUserId().equals(mainWaitAuditSum.getUserId()) && quUserNum.getCompanyId().equals(mainWaitAuditSum.getCompanyId())) {
+                        quUserNum.setMainWaitAuditSum(mainWaitAuditSum.getMainWaitAuditSum());
+                    }
+                }
+                for (QuUserNum mainWaitPaySum : mainWaitPaySums) {
+                    if (quUserNum.getUserId().equals(mainWaitPaySum.getUserId()) && quUserNum.getCompanyId().equals(mainWaitPaySum.getCompanyId())) {
+                        quUserNum.setMainWaitPaySum(mainWaitPaySum.getMainWaitPaySum());
+                    }
+                }
+                for (QuUserNum mainAcceptInsuranceSum : mainAcceptInsuranceSums) {
+                    if (quUserNum.getUserId().equals(mainAcceptInsuranceSum.getUserId()) && quUserNum.getCompanyId().equals(mainAcceptInsuranceSum.getCompanyId())) {
+                        quUserNum.setMainAcceptInsuranceSum(mainAcceptInsuranceSum.getMainAcceptInsuranceSum());
+                    }
+                }
+            }
+        }
+
+        List<QuUserNum> paginate = paginate(deptByCompany, quUserNumDto.getPageNum(), quUserNumDto.getPageSize());
+
+        // 创建并设置分页信息
+        IPage<QuUserNum> page = new Page<>(quUserNumDto.getPageNum(), quUserNumDto.getPageSize());
+        page.setRecords(paginate);
+        page.setTotal(deptByCompany.size());
+        return page;
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/4/29 16:01
+     *  @Description: 查询当前登陆人管理的渠道人 即领导人为当前登陆人的用户需要递归查询
+     */
+    public List<String> getUserIdsByLeaderId(String userId){
+        // 获取系统中的所有用户
+        LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysUser::getStatus, 1);
+        List<SysUser> allUsers = this.getBaseMapper().selectList(queryWrapper);
+        // 查询指定用户ID管理的用户,即第一级下属
+        queryWrapper.eq(SysUser::getId, userId);
+        List<SysUser> leadUsers = this.getBaseMapper().selectList(queryWrapper);
+        // 用于存储所有下属的ID
+        List<String> strIds = new ArrayList<>();
+        // 递归获取第一级下属及其所有下属的ID
+        findChildren(leadUsers, allUsers, strIds);
+        return strIds;
+    }
 }
 
 

+ 36 - 0
src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeService.java

@@ -3,9 +3,11 @@ package com.ydtech.modules.fee.service;
 
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
+import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeResultVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeVo;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -39,4 +41,38 @@ public interface FeeRuleSchemeService {
      * @param syCostsProportionStr
      */
     void compareAndUpdateFeeOrderInfo(String insOrderNo ,String jqCostsProportionStr,String syCostsProportionStr,String dealUser);
+
+    /**
+     * 计算入口费用
+     * @param premium    保费
+     * @param superviseCostsProportion  手续费比例
+     * @param otherCostsProportion      跟单比例
+     */
+    FeeOrderNewVo.EntranceFee calcEntranceFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal otherCostsProportion, BigDecimal taxRate);
+
+    /**
+     * 计算机构管理费用
+     * @param premium   保费
+     * @param level1Proportion  一级比例
+     * @param level2Proportion  二级比例
+     * @param level3Proportion  三级比例
+     * @param level4Proportion  四级比例
+     * @param level5Proportion  五级比例
+     * @return
+     */
+    public FeeOrderNewVo.DeptManagerFee calcDeptManagerFee(BigDecimal premium, BigDecimal level1Proportion,BigDecimal level2Proportion,
+                                                           BigDecimal level3Proportion,BigDecimal level4Proportion,BigDecimal level5Proportion);
+
+    /**
+     * 计算出口费用
+     * @param premium   保费
+     * @param superviseCostsProportion  出口手续费
+     * @param entranceTotalProportion   入口总比例
+     * @param deptTotalProportion       机构管理费总比例
+     * @param retailTotalProportion     分销总比例
+     * @param taxRate                   税率
+     * @return
+     */
+    public FeeOrderNewVo.ExportFee calcExportFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal entranceTotalProportion,
+                                                 BigDecimal deptTotalProportion,BigDecimal retailTotalProportion,BigDecimal taxRate);
 }

+ 10 - 7
src/main/java/com/ydtech/modules/fee/service/impl/CostsCalServiceImpl.java

@@ -162,12 +162,12 @@ public class CostsCalServiceImpl implements CostsCalcService {
         ExportFee exportFee = new ExportFee();
         //计算出口费用
         //出口比例
-        BigDecimal jqExportRadio = entranceFee.getTotalProportion().subtract(deptManagerFee.getDeptManagerRadio()).subtract(retailStoreFee.getRetailStoreRadio());
+        BigDecimal exportRadio = entranceFee.getTotalProportion().subtract(deptManagerFee.getDeptManagerRadio()).subtract(retailStoreFee.getRetailStoreRadio());
         //出口费用
         exportFee.setSuperviseCosts(exportProceduresRadio);
         exportFee.setSuperviseCostsPremiums(entranceFee.getPremium().multiply(exportProceduresRadio.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
         //跟单比例
-        exportFee.setOtherCostsProportion(entranceFee.getTotalProportion().subtract(exportProceduresRadio));
+        exportFee.setOtherCostsProportion(exportRadio.subtract(exportProceduresRadio));
         //跟单费用
         exportFee.setOtherCostsPremiums(entranceFee.getPremium().multiply(exportFee.getOtherCostsProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
         //总比例
@@ -190,20 +190,23 @@ public class CostsCalServiceImpl implements CostsCalcService {
         //计算出口费用
 
         //分销管理比例总和
-        BigDecimal retailStoreProportion = insFeeOrderNew.getFirstDetailProportion().add(insFeeOrderNew.getSecondDetailProportion()).add(insFeeOrderNew.getThirdDetailProportion());
+        BigDecimal retailStoreProportion = insFeeOrderNew.getFirstDetailProportion().add(insFeeOrderNew.getSecondDetailProportion()).
+                add(insFeeOrderNew.getThirdDetailProportion());
 
 
-        //交强入口比例总和
-        BigDecimal jqEntranceProportion = insFeeOrderNew.getJqSuperviseCostsProportion().add(insFeeOrderNew.getJqOtherCostsProportion());
         //交强机构管理费
         BigDecimal jqDeptProportion = insFeeOrderNew.getJqDeptProportionLevel1().add(insFeeOrderNew.getJqDeptProportionLevel2()).add(insFeeOrderNew.getJqDeptProportionLevel3()).add(insFeeOrderNew.getJqDeptProportionLevel4()).add(insFeeOrderNew.getJqDeptProportionLevel5());
+
+        //交强入口比例总和
+        BigDecimal jqEntranceProportion = insFeeOrderNew.getJqSuperviseCostsProportion().add(insFeeOrderNew.getJqOtherCostsProportion()).divide(taxRadio,2, RoundingMode.HALF_DOWN);
+
         //交强出口总比例
         BigDecimal jqExportProportion = jqEntranceProportion.subtract(jqDeptProportion).subtract(retailStoreProportion);
         //交强出口金额
         subOrderExportFeeVo.setJqExportCosts(insFeeOrderNew.getJqPremium().multiply(taxRadio).multiply(jqExportProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
 
         //商业入口比例总和
-        BigDecimal syEntranceProportion = insFeeOrderNew.getSySuperviseCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion());
+        BigDecimal syEntranceProportion = insFeeOrderNew.getSySuperviseCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()).divide(taxRadio,2, RoundingMode.HALF_DOWN);
         //商业部门管理比例总和
         BigDecimal syDeptProportion = insFeeOrderNew.getSyDeptProportionLevel1().add(insFeeOrderNew.getSyDeptProportionLevel2()).add(insFeeOrderNew.getSyDeptProportionLevel3()).add(insFeeOrderNew.getSyDeptProportionLevel4()).add(insFeeOrderNew.getSyDeptProportionLevel5());
         //商业出口比例总和
@@ -212,7 +215,7 @@ public class CostsCalServiceImpl implements CostsCalcService {
         subOrderExportFeeVo.setSyExportCosts(insFeeOrderNew.getSyPremium().multiply(taxRadio).multiply(syExportProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
 
         //非车入口比例总和
-        BigDecimal noEntranceProportion = insFeeOrderNew.getNoSuperviseCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion());
+        BigDecimal noEntranceProportion = insFeeOrderNew.getNoSuperviseCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()).divide(taxRadio,2, RoundingMode.HALF_DOWN);
         //非车部门比例总和
         BigDecimal noDeptProportion = insFeeOrderNew.getNoDeptProportionLevel1().add(insFeeOrderNew.getNoDeptProportionLevel2()).add(insFeeOrderNew.getNoDeptProportionLevel3()).add(insFeeOrderNew.getNoDeptProportionLevel4()).add(insFeeOrderNew.getNoDeptProportionLevel5());
         //非车出口比例总和

+ 152 - 163
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceImpl.java

@@ -2616,52 +2616,16 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         List<FeeOrderNewVo.ExportFee> exportFeeList = new ArrayList<>();
         List<FeeOrderNewVo.DeptManagerFee> deptManagerFeeList = new ArrayList<>();
 
-        FeeOrderNewVo.EntranceFee jqEntranceFee = new FeeOrderNewVo.EntranceFee();
-        FeeOrderNewVo.ExportFee jqExportFee = new  FeeOrderNewVo.ExportFee();
-        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = new FeeOrderNewVo.DeptManagerFee();
+        FeeOrderNewVo.EntranceFee jqEntranceFee,syEntranceFee,noEntranceFee;
+        FeeOrderNewVo.ExportFee jqExportFee,syExportFee,noExportFee;
+        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee,syDeptManagerFee,noDeptManagerFee;
 
-        FeeOrderNewVo.EntranceFee syEntranceFee = new FeeOrderNewVo.EntranceFee();
-        FeeOrderNewVo.ExportFee syExportFee = new  FeeOrderNewVo.ExportFee();
-        FeeOrderNewVo.DeptManagerFee syDeptManagerFee = new FeeOrderNewVo.DeptManagerFee();
-
-        FeeOrderNewVo.EntranceFee nonEntranceFee = new FeeOrderNewVo.EntranceFee();
-        FeeOrderNewVo.ExportFee nonExportFee = new  FeeOrderNewVo.ExportFee();
-        FeeOrderNewVo.DeptManagerFee nonDeptManagerFee = new FeeOrderNewVo.DeptManagerFee();
-
-        //入口费用
-        jqEntranceFee.setInsuranceType("交强险");  // 险种
-        jqEntranceFee.setPremium(insFeeOrderNew.getJqPremium());  //保费
-        jqEntranceFee.setTotalAmount(insFeeOrderNew.getJqCostsPremiums());   //总费用
-        jqEntranceFee.setTotalProportion(insFeeOrderNew.getJqCostsProportion()); //总比例
-        jqEntranceFee.setSySuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());   //手续费
-        jqEntranceFee.setOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());   // 跟单比例
-        jqEntranceFee.setOtherCostsPremiums(insFeeOrderNew.getJqOtherCostsPremiums());      // 跟单费
-        jqEntranceFee.setSuperviseCosts(insFeeOrderNew.getJqSuperviseCostsProportion());  // 手续费比例
-        jqEntranceFee.setExportSuperviseCosts(insFeeOrderNew.getJqCostsExportProportion());  // 出口费比例
-        entranceFeeList.add(jqEntranceFee);
-
-
-        // 机构管理费
-        jqDeptManagerFee.setInsuranceType("交强险");
-        jqDeptManagerFee.setDeptProportionLevelOne(insFeeOrderNew.getJqDeptProportionLevel1());
-        jqDeptManagerFee.setDeptPremiumsLevelOne(insFeeOrderNew.getJqDeptPremiumsLevel1());
-        jqDeptManagerFee.setDeptProportionLevelTwo(insFeeOrderNew.getJqDeptProportionLevel2());
-        jqDeptManagerFee.setDeptPremiumsLevelTwo(insFeeOrderNew.getJqDeptPremiumsLevel2());
-        jqDeptManagerFee.setDeptProportionLevelThree(insFeeOrderNew.getJqDeptProportionLevel3());
-        jqDeptManagerFee.setDeptPremiumsLevelThree(insFeeOrderNew.getJqDeptPremiumsLevel3());
-        jqDeptManagerFee.setDeptProportionLevelFoure(insFeeOrderNew.getJqDeptProportionLevel4());
-        jqDeptManagerFee.setDeptPremiumsLevelFoure(insFeeOrderNew.getJqDeptPremiumsLevel4());
-        jqDeptManagerFee.setDeptProportionLevelFive(insFeeOrderNew.getJqDeptProportionLevel5());
-        jqDeptManagerFee.setDeptPremiumsLevelFive(insFeeOrderNew.getJqDeptPremiumsLevel5());
-        deptManagerFeeList.add(jqDeptManagerFee);
-
-        //出口费用
-        jqExportFee.setInsuranceType("交强险");  // 险种
-        BigDecimal sumJqDeptProportion = insFeeOrderNew.getJqDeptProportionLevel1()
-                .add(insFeeOrderNew.getJqDeptProportionLevel2())
-                .add(insFeeOrderNew.getJqDeptProportionLevel3())
-                .add(insFeeOrderNew.getJqDeptProportionLevel4())
-                .add(insFeeOrderNew.getJqDeptProportionLevel5());
+        //查询协议是否包含税
+        PtlAgreement ptlAgreement = ptlAgreementService.getById(insFeeOrderNew.getAgreementId());
+        BigDecimal taxRadio = new BigDecimal("1.00");
+        if(ptlAgreement.getWithTax().equals("是")){
+            taxRadio = new BigDecimal("1.06");
+        }
 
         //分销总比例
         BigDecimal sumRetail = new BigDecimal(0);
@@ -2675,143 +2639,79 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
             sumRetail = sumRetail.add(insFeeOrderNew.getThirdDetailProportion());
         }
 
-        //交强总出口费比例
-        BigDecimal jqExportTotalProportion = jqEntranceFee.getTotalProportion().subtract(sumJqDeptProportion).subtract(sumRetail);
+        //交强入口费用
+        jqEntranceFee = calcEntranceFee(insFeeOrderNew.getJqPremium(),insFeeOrderNew.getJqSuperviseCostsProportion(),insFeeOrderNew.getJqOtherCostsProportion(),taxRadio);
+        jqEntranceFee.setInsuranceType("交强险");  // 险种
+        jqEntranceFee.setExportSuperviseCosts(insFeeOrderNew.getJqCostsExportProportion());  // 出口费比例
+        entranceFeeList.add(jqEntranceFee);
 
-        //交强出口手续费比例
-        BigDecimal jqExportSuperviseCosts =
-                jqExportTotalProportion.compareTo(jqEntranceFee.getExportSuperviseCosts()) > 0 ? jqEntranceFee.getExportSuperviseCosts() : jqExportTotalProportion;
+        //交强机构管理费比例
+        jqDeptManagerFee = calcDeptManagerFee(insFeeOrderNew.getJqPremium(),insFeeOrderNew.getJqDeptProportionLevel1(),
+                insFeeOrderNew.getJqDeptProportionLevel2(),insFeeOrderNew.getJqDeptProportionLevel3(),
+                insFeeOrderNew.getJqDeptProportionLevel4(),insFeeOrderNew.getJqDeptProportionLevel5());
+        jqDeptManagerFee.setInsuranceType("交强险");
+        deptManagerFeeList.add(jqDeptManagerFee);
 
-        //交强出口其他费比例
-        BigDecimal jqOtherCostsProportion =
-                jqExportTotalProportion.compareTo(jqEntranceFee.getExportSuperviseCosts()) > 0 ? jqExportTotalProportion.subtract(jqExportSuperviseCosts) : new BigDecimal(0);
+        //交强机构管理费总比例
+        BigDecimal jqDeptManagerRadio = jqDeptManagerFee.getDeptProportionLevelOne().add(jqDeptManagerFee.getDeptProportionLevelTwo())
+                .add(jqDeptManagerFee.getDeptProportionLevelThree()).add(jqDeptManagerFee.getDeptProportionLevelFoure())
+                .add(jqDeptManagerFee.getDeptProportionLevelFive());
 
-        jqExportFee.setSuperviseCosts(jqExportSuperviseCosts);
-        jqExportFee.setSuperviseCostsPremiums(insFeeOrderNew.getJqPremium().multiply(jqExportSuperviseCosts.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        jqExportFee.setOtherCostsProportion(jqOtherCostsProportion);
-        jqExportFee.setOtherCostsPremiums(insFeeOrderNew.getJqPremium().multiply(jqOtherCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        jqExportFee.setTotalProportion(jqExportSuperviseCosts.add(jqOtherCostsProportion));
-        jqExportFee.setTotalAmount(insFeeOrderNew.getJqPremium().multiply(jqExportFee.getTotalProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        //交强出口费用
+        jqExportFee = calcExportFee(insFeeOrderNew.getJqPremium(),insFeeOrderNew.getJqCostsExportProportion(),jqEntranceFee.getTotalProportion(),
+                jqDeptManagerRadio,sumRetail,taxRadio);
+        jqExportFee.setInsuranceType("交强险");
         exportFeeList.add(jqExportFee);
 
-
-
-
         //商业入口
+        syEntranceFee = calcEntranceFee(insFeeOrderNew.getSyPremium(),insFeeOrderNew.getSySuperviseCostsProportion(),insFeeOrderNew.getSyOtherCostsProportion(),taxRadio);
         syEntranceFee.setInsuranceType("商业险");  // 险种
-        syEntranceFee.setPremium(insFeeOrderNew.getSyPremium());  //保费
-        syEntranceFee.setTotalProportion(insFeeOrderNew.getSyCostsProportion()); //总保费
-        syEntranceFee.setTotalAmount(insFeeOrderNew.getSyCostsPremiums());   //总费用
-        syEntranceFee.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());   //手续费
-        syEntranceFee.setOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());   // 跟单比例
-        syEntranceFee.setOtherCostsPremiums(insFeeOrderNew.getSyOtherCostsPremiums());      // 跟单费
-        syEntranceFee.setSuperviseCosts(insFeeOrderNew.getSySuperviseCostsProportion());  // 手续费比例
         syEntranceFee.setExportSuperviseCosts(insFeeOrderNew.getSyCostsExportProportion());  // 出口费比例
         entranceFeeList.add(syEntranceFee);
 
         // 商业管理费
+        syDeptManagerFee = calcDeptManagerFee(insFeeOrderNew.getSyPremium(),insFeeOrderNew.getSyDeptProportionLevel1(),
+                insFeeOrderNew.getSyDeptProportionLevel2(),insFeeOrderNew.getSyDeptProportionLevel3(),
+                insFeeOrderNew.getSyDeptProportionLevel4(),insFeeOrderNew.getSyDeptProportionLevel5());
         syDeptManagerFee.setInsuranceType("商业险");
-        syDeptManagerFee.setDeptProportionLevelOne(insFeeOrderNew.getSyDeptProportionLevel1());
-        syDeptManagerFee.setDeptPremiumsLevelOne(insFeeOrderNew.getSyDeptPremiumsLevel1());
-        syDeptManagerFee.setDeptProportionLevelTwo(insFeeOrderNew.getSyDeptProportionLevel2());
-        syDeptManagerFee.setDeptPremiumsLevelTwo(insFeeOrderNew.getSyDeptPremiumsLevel2());
-        syDeptManagerFee.setDeptProportionLevelThree(insFeeOrderNew.getSyDeptProportionLevel3());
-        syDeptManagerFee.setDeptPremiumsLevelThree(insFeeOrderNew.getSyDeptPremiumsLevel3());
-        syDeptManagerFee.setDeptProportionLevelFoure(insFeeOrderNew.getSyDeptProportionLevel4());
-        syDeptManagerFee.setDeptPremiumsLevelFoure(insFeeOrderNew.getSyDeptPremiumsLevel4());
-        syDeptManagerFee.setDeptProportionLevelFive(insFeeOrderNew.getSyDeptProportionLevel5());
-        syDeptManagerFee.setDeptPremiumsLevelFive(insFeeOrderNew.getSyDeptPremiumsLevel5());
         deptManagerFeeList.add(syDeptManagerFee);
 
-        //商业出口
-        syExportFee.setInsuranceType("商业险");  // 险种
-        BigDecimal sumSyDeptProportion = insFeeOrderNew.getSyDeptProportionLevel1()
-                .add(insFeeOrderNew.getSyDeptProportionLevel2())
-                .add(insFeeOrderNew.getSyDeptProportionLevel3())
-                .add(insFeeOrderNew.getSyDeptProportionLevel4())
-                .add(insFeeOrderNew.getSyDeptProportionLevel5());
-
-        //商业总出口费比例
-        BigDecimal syExportTotalProportion = new BigDecimal(0);
-        if(syEntranceFee.getTotalProportion().compareTo(new BigDecimal(0)) > 0) {
-            syExportTotalProportion = syEntranceFee.getTotalProportion().subtract(sumSyDeptProportion).subtract(sumRetail);
-        }
-        //商业出口手续费比例
-        BigDecimal syExportSuperviseCosts =
-                syExportTotalProportion.compareTo(syEntranceFee.getExportSuperviseCosts()) > 0 ? syEntranceFee.getExportSuperviseCosts() : syExportTotalProportion;
-
-        //商业出口其他费比例
-        BigDecimal syOtherCostsProportion =
-                syExportTotalProportion.compareTo(syEntranceFee.getExportSuperviseCosts()) > 0 ? syExportTotalProportion.subtract(syExportSuperviseCosts) : new BigDecimal(0);
-
-        syExportFee.setSuperviseCosts(syExportSuperviseCosts);
-        syExportFee.setSuperviseCostsPremiums(insFeeOrderNew.getSyPremium().multiply(syExportSuperviseCosts.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        syExportFee.setOtherCostsProportion(syOtherCostsProportion);
-        syExportFee.setOtherCostsPremiums(insFeeOrderNew.getSyPremium().multiply(syOtherCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        //如果入口的总比例等于0  则出口的总比例也等于0
-        syExportFee.setTotalProportion(syExportSuperviseCosts.add(syExportFee.getOtherCostsProportion()));
-        syExportFee.setTotalAmount(syExportSuperviseCosts.add(syExportFee.getOtherCostsPremiums()));
-        exportFeeList.add(syExportFee);
 
+        //商业机构管理费总比例
+        BigDecimal syDeptManagerRadio = syDeptManagerFee.getDeptProportionLevelOne().add(syDeptManagerFee.getDeptProportionLevelTwo())
+                .add(syDeptManagerFee.getDeptProportionLevelThree()).add(syDeptManagerFee.getDeptProportionLevelFoure())
+                .add(syDeptManagerFee.getDeptProportionLevelFive());
 
+        //商业出口费用
+        syExportFee = calcExportFee(insFeeOrderNew.getSyPremium(),insFeeOrderNew.getSyCostsExportProportion(),syEntranceFee.getTotalProportion(),
+                syDeptManagerRadio,sumRetail,taxRadio);
+        syExportFee.setInsuranceType("商业险");
+        exportFeeList.add(syExportFee);
 
 
         //非车入口
-        nonEntranceFee.setInsuranceType("非车险");  // 险种
-        nonEntranceFee.setPremium(insFeeOrderNew.getNoPremium());  //保费
-        nonEntranceFee.setTotalProportion(insFeeOrderNew.getNoCostsProportion()); //总保费
-        nonEntranceFee.setTotalAmount(insFeeOrderNew.getNoCostsPremiums());   //总费用
-        nonEntranceFee.setSySuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums());   //手续费
-        nonEntranceFee.setOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());   // 跟单比例
-        nonEntranceFee.setOtherCostsPremiums(insFeeOrderNew.getNoOtherCostsPremiums());      // 跟单费
-        nonEntranceFee.setSuperviseCosts(insFeeOrderNew.getNoSuperviseCostsProportion());  // 手续费比例
-        nonEntranceFee.setExportSuperviseCosts(insFeeOrderNew.getNoCostsExportProportion());  // 出口费比例
-        entranceFeeList.add(nonEntranceFee);
-
-        // 五级管理费
-        nonDeptManagerFee.setInsuranceType("非车险");
-        nonDeptManagerFee.setDeptProportionLevelOne(insFeeOrderNew.getNoDeptProportionLevel1());
-        nonDeptManagerFee.setDeptPremiumsLevelOne(insFeeOrderNew.getNoDeptPremiumsLevel1());
-        nonDeptManagerFee.setDeptProportionLevelTwo(insFeeOrderNew.getNoDeptProportionLevel2());
-        nonDeptManagerFee.setDeptPremiumsLevelTwo(insFeeOrderNew.getNoDeptPremiumsLevel2());
-        nonDeptManagerFee.setDeptProportionLevelThree(insFeeOrderNew.getNoDeptProportionLevel3());
-        nonDeptManagerFee.setDeptPremiumsLevelThree(insFeeOrderNew.getNoDeptPremiumsLevel3());
-        nonDeptManagerFee.setDeptProportionLevelFoure(insFeeOrderNew.getNoDeptProportionLevel4());
-        nonDeptManagerFee.setDeptPremiumsLevelFoure(insFeeOrderNew.getNoDeptPremiumsLevel4());
-        nonDeptManagerFee.setDeptProportionLevelFive(insFeeOrderNew.getNoDeptProportionLevel5());
-        nonDeptManagerFee.setDeptPremiumsLevelFive(insFeeOrderNew.getNoDeptPremiumsLevel5());
-        deptManagerFeeList.add(nonDeptManagerFee);
-
-
-        //出口费用
-        nonExportFee.setInsuranceType("非车险");  // 险种
-        BigDecimal sumNonDeptProportion = insFeeOrderNew.getNoDeptProportionLevel1()
-                .add(insFeeOrderNew.getNoDeptProportionLevel2())
-                .add(insFeeOrderNew.getNoDeptProportionLevel3())
-                .add(insFeeOrderNew.getNoDeptProportionLevel4())
-                .add(insFeeOrderNew.getNoDeptProportionLevel5());
-
-        //非车总出口费比例
-        BigDecimal nonExportTotalProportion = new BigDecimal(0);
-        if(nonEntranceFee.getTotalProportion().compareTo(new BigDecimal(0)) > 0) {
-            nonExportTotalProportion = nonEntranceFee.getTotalProportion().subtract(sumSyDeptProportion).subtract(sumRetail);
-        }
-
-        //非车出口手续费比例
-        BigDecimal nonExportSuperviseCosts =
-                nonExportTotalProportion.compareTo(nonEntranceFee.getExportSuperviseCosts()) > 0 ? nonEntranceFee.getExportSuperviseCosts() : nonExportTotalProportion;
-
-        //非车出口其他费比例
-        BigDecimal nonOtherCostsProportion =
-                nonExportTotalProportion.compareTo(nonEntranceFee.getExportSuperviseCosts()) > 0 ? nonExportTotalProportion.subtract(nonExportSuperviseCosts) : new BigDecimal(0);
-
-        nonExportFee.setSuperviseCosts(nonExportSuperviseCosts);
-        nonExportFee.setSuperviseCostsPremiums(insFeeOrderNew.getNoPremium().multiply(nonExportSuperviseCosts.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        nonExportFee.setOtherCostsProportion(nonOtherCostsProportion);
-        nonExportFee.setOtherCostsPremiums(insFeeOrderNew.getNoPremium().multiply(nonOtherCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
-        nonExportFee.setTotalProportion(nonExportSuperviseCosts.add(nonOtherCostsProportion));
-        nonExportFee.setTotalAmount(nonExportFee.getSuperviseCostsPremiums().add(nonExportFee.getOtherCostsPremiums()));
-        exportFeeList.add(nonExportFee);
+        noEntranceFee = calcEntranceFee(insFeeOrderNew.getNoPremium(),insFeeOrderNew.getNoSuperviseCostsProportion(),insFeeOrderNew.getNoOtherCostsProportion(),taxRadio);
+        noEntranceFee.setInsuranceType("非车险");  // 险种
+        noEntranceFee.setExportSuperviseCosts(insFeeOrderNew.getNoCostsExportProportion());  // 出口费比例
+        entranceFeeList.add(noEntranceFee);
+
+        //非车五级管理费
+        noDeptManagerFee = calcDeptManagerFee(insFeeOrderNew.getNoPremium(),insFeeOrderNew.getNoDeptProportionLevel1(),
+                insFeeOrderNew.getNoDeptProportionLevel2(),insFeeOrderNew.getNoDeptProportionLevel3(),
+                insFeeOrderNew.getNoDeptProportionLevel4(),insFeeOrderNew.getNoDeptProportionLevel5());
+        noDeptManagerFee.setInsuranceType("非车险");
+        deptManagerFeeList.add(noDeptManagerFee);
+
+        //非车机构管理费总比例
+        BigDecimal noDeptManagerRadio = noDeptManagerFee.getDeptProportionLevelOne().add(noDeptManagerFee.getDeptProportionLevelTwo())
+                .add(noDeptManagerFee.getDeptProportionLevelThree()).add(noDeptManagerFee.getDeptProportionLevelFoure())
+                .add(noDeptManagerFee.getDeptProportionLevelFive());
+
+        //非车出口费用
+        noExportFee = calcExportFee(insFeeOrderNew.getNoPremium(),insFeeOrderNew.getNoCostsExportProportion(),noEntranceFee.getTotalProportion(),
+                noDeptManagerRadio,sumRetail,taxRadio);
+        noExportFee.setInsuranceType("非车险");
+        exportFeeList.add(noExportFee);
 
         feeOrderNewVo.setEntranceFee(entranceFeeList);
         feeOrderNewVo.setExportFee(exportFeeList);
@@ -2819,6 +2719,95 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         return feeOrderNewVo;
     }
 
+    /**
+     * 计算入口费用
+     * @param premium    保费
+     * @param superviseCostsProportion  手续费比例
+     * @param otherCostsProportion      跟单比例
+     */
+    public FeeOrderNewVo.EntranceFee calcEntranceFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal otherCostsProportion, BigDecimal taxRate){
+        FeeOrderNewVo.EntranceFee entranceFee = new FeeOrderNewVo.EntranceFee();
+        entranceFee.setPremium(premium);
+        premium = premium.divide(taxRate,2,RoundingMode.DOWN);
+        //手续费
+        entranceFee.setSuperviseCostsPremiums(premium.multiply(superviseCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        entranceFee.setSuperviseCosts(superviseCostsProportion);
+        //跟单费
+        entranceFee.setOtherCostsPremiums(premium.multiply(otherCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        entranceFee.setOtherCostsProportion(otherCostsProportion);
+        //总费用比例
+        BigDecimal totalCostsProportion = superviseCostsProportion.add(otherCostsProportion);
+        entranceFee.setTotalAmount(premium.multiply(totalCostsProportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        entranceFee.setTotalProportion(totalCostsProportion);
+        return entranceFee;
+    }
+
+    /**
+     * 计算机构管理费用
+     * @param premium   保费
+     * @param level1Proportion  一级比例
+     * @param level2Proportion  二级比例
+     * @param level3Proportion  三级比例
+     * @param level4Proportion  四级比例
+     * @param level5Proportion  五级比例
+     * @return
+     */
+    public FeeOrderNewVo.DeptManagerFee calcDeptManagerFee(BigDecimal premium, BigDecimal level1Proportion,BigDecimal level2Proportion,
+                                                           BigDecimal level3Proportion,BigDecimal level4Proportion,BigDecimal level5Proportion){
+        FeeOrderNewVo.DeptManagerFee deptManagerFee = new FeeOrderNewVo.DeptManagerFee();
+        //一级管理费
+        deptManagerFee.setDeptPremiumsLevelOne(premium.multiply(level1Proportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        deptManagerFee.setDeptProportionLevelOne(level1Proportion);
+        //二级管理费
+        deptManagerFee.setDeptPremiumsLevelTwo(premium.multiply(level2Proportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        deptManagerFee.setDeptProportionLevelTwo(level2Proportion);
+        //三级管理费
+        deptManagerFee.setDeptPremiumsLevelThree(premium.multiply(level3Proportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        deptManagerFee.setDeptProportionLevelThree(level3Proportion);
+        //四级管理费
+        deptManagerFee.setDeptPremiumsLevelFoure(premium.multiply(level4Proportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        deptManagerFee.setDeptProportionLevelFoure(level4Proportion);
+        //五级管理费
+        deptManagerFee.setDeptPremiumsLevelFive(premium.multiply(level5Proportion.divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        deptManagerFee.setDeptProportionLevelFive(level5Proportion);
+        return deptManagerFee;
+    }
+
+    /**
+     * 计算出口费用
+     * @param premium   保费
+     * @param superviseCostsProportion  出口手续费
+     * @param entranceTotalProportion   入口总比例
+     * @param deptTotalProportion       机构管理费总比例
+     * @param retailTotalProportion     分销总比例
+     * @param taxRate                   税率
+     * @return
+     */
+    public FeeOrderNewVo.ExportFee calcExportFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal entranceTotalProportion,
+                                                 BigDecimal deptTotalProportion,BigDecimal retailTotalProportion,BigDecimal taxRate){
+        FeeOrderNewVo.ExportFee exportFee = new FeeOrderNewVo.ExportFee();
+        exportFee.setPremium(premium);
+        //去税后的入口比例
+        BigDecimal noTaxEntranceTotalProportion = entranceTotalProportion.divide(taxRate,2,RoundingMode.DOWN);
+        //出口的总比例
+        BigDecimal exportTotalProportion = noTaxEntranceTotalProportion.subtract(deptTotalProportion).subtract(retailTotalProportion);
+        //如果手续费 大于 总比例 则出口手续费等于总比例
+        if(superviseCostsProportion.compareTo(exportTotalProportion) >= 0 ){
+            superviseCostsProportion = exportTotalProportion;
+            exportFee.setSuperviseCosts(superviseCostsProportion);
+            exportFee.setOtherCostsProportion(new BigDecimal(0));
+            exportFee.setTotalProportion(superviseCostsProportion);
+        }else{
+            exportFee.setTotalProportion(exportTotalProportion);
+            exportFee.setOtherCostsProportion(exportTotalProportion.subtract(superviseCostsProportion));
+            exportFee.setSuperviseCosts(superviseCostsProportion);
+        }
+        exportFee.setSuperviseCostsPremiums(premium.multiply(exportFee.getSuperviseCosts().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        exportFee.setOtherCostsPremiums(premium.multiply(exportFee.getOtherCostsProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        exportFee.setTotalAmount(premium.multiply(exportFee.getTotalProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN));
+        return exportFee;
+    }
+
     public List<DistributionLevelVo> converDistrbutionData(InsFeeOrderNew insFeeOrderNew) {
         ArrayList<DistributionLevelVo> resultList = new ArrayList<>();
         DistributionLevelVo  levelOne  =  new DistributionLevelVo();

+ 1 - 1
src/main/java/com/ydtech/modules/fnc/controller/CarSettleController.java

@@ -47,7 +47,7 @@ public class CarSettleController extends BaseController {
      */
     @PostMapping("/queryPageOrder")
     @ApiOperation(value = "[1]分页查询订单接口")
-    public HttpResult<BasePageResult<InsOrders>> queryPageOrder(@RequestBody @Valid OrderQueryVo orderQueryVo) {
+    public HttpResult<BasePageResult<InsOrders>> queryPageOrder(@RequestBody OrderQueryVo orderQueryVo) {
         orderQueryVo.setOrderStatus("3");//3已承保
         BasePageResult<InsOrders> quoteResult = this.insOrdersService.queryPageOrder(orderQueryVo);
         return HttpResult.ok("success", quoteResult);

+ 92 - 6
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.controller;
 
+import com.ydtech.aop.exception.DescribeException;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 import com.ydtech.modules.base.controller.BaseController;
@@ -17,9 +18,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.io.IOException;
 import java.time.LocalDate;
 import java.time.Period;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -74,6 +79,18 @@ public class InsPlyIncomeController extends BaseController {
 
         return result;
     }
+    @PostMapping("/totalAmount")
+    @ApiModelProperty(value = "平台手续费合计金额")
+    public HttpResult<InsPlyIncome>totalAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        InsPlyIncome  result = insPlyIncomeService.totalAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
+    @PostMapping("/totalPinAmount")
+    @ApiModelProperty(value = "平台结算未结算接口")
+    public HttpResult<List<InsPlyIncome>>totalPinAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        List<InsPlyIncome>  result = insPlyIncomeService.totalPinAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
     @PutMapping("/balance")
     @ApiModelProperty(value = "结算手续费")
     public HttpResult<Object> balance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
@@ -88,14 +105,23 @@ public class InsPlyIncomeController extends BaseController {
         return result;
     }
 
-        @PutMapping("/batchBalance")
-    @ApiModelProperty(value = "批量跟单费")
+    @PutMapping("/batchInvoic")
+    @ApiModelProperty(value = "批量开票跟单费")
+    public HttpResult<Object> batchInvoic(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+
+        return   insPlyIncomeService.batchInvoic(insPlyIncomeVo);
+    }
+    @PutMapping("/batchBalance")
+    @ApiModelProperty(value = "批量结算跟单费")
     public HttpResult<Object> batchBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
 
         return   insPlyIncomeService.batchBalance(insPlyIncomeVo);
     }
-
-
+    @PutMapping("/batchPinBalance")
+    @ApiModelProperty(value = "平台批量结算")
+    public HttpResult<Object> batchPinBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchPinBalance(insPlyIncomeVo);
+    }
 
     @PostMapping("/NonSettlementQuery")
     @ApiOperation(value = "非跟单查询")
@@ -110,7 +136,7 @@ public class InsPlyIncomeController extends BaseController {
         return  insPlyIncomeService.nonSettldetail(insPlyIncomeVo);
     }
     @PostMapping("/importData")
-    @ApiOperation(value = "渠道数据导入(excel)")
+    @ApiOperation(value = "手续费导入(excel)")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
     })
@@ -121,6 +147,8 @@ public class InsPlyIncomeController extends BaseController {
         return HttpResult.ok("导入成功");
     }
 
+
+
     @PutMapping("/update")
     @ApiModelProperty(value = "修改")
     public HttpResult<Object> updateByEntity(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
@@ -146,5 +174,63 @@ public class InsPlyIncomeController extends BaseController {
         return  HttpResult.ok(item) ;
     }
 
+    @PostMapping("/totalBxAmount")
+    @ApiModelProperty(value = "保险未开票金额")
+    public HttpResult<List<InsPlyIncome>>totalBxAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        List<InsPlyIncome>  result = insPlyIncomeService.totalBxAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
+
+
+    @PutMapping("/batchInvoicing")
+    @ApiModelProperty(value = "保险手续费批量开票")
+    public HttpResult<Object> batchInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchInvoicing(insPlyIncomeVo);
+    }
+
+    @PostMapping("/queryInvoicing")
+    @ApiModelProperty(value = "查询开票金额")
+    public HttpResult<InsPlyIncome> queryInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.queryInvoicing(insPlyIncomeVo);
+    }
+    @PostMapping("/querySettInvoicing")
+    @ApiModelProperty(value = "查询已开票已结算")
+    public HttpResult<InsPlyIncome> querySettInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.querySettInvoicing(insPlyIncomeVo);
+    }
+
+    @PutMapping("/batchBxBalance")
+    @ApiModelProperty(value = "保险批量结算")
+    public HttpResult<Object> batchBxBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchBxBalance(insPlyIncomeVo);
+    }
+
+
+    @PostMapping("/allOtherAmount")
+    @ApiModelProperty(value = "保险跟单总表")
+    public HttpResult<List<InsPlyIncome>> allOtherAmount(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.allOtherAmount(insPlyIncomeVo);
+    }
+
+
+    @ApiModelProperty("保险手续费导出")
+    @PostMapping("bxHandlingExcel")
+    public HttpResult bxHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ) throws IOException {
+            return  insPlyIncomeService.bxHandlingexcel(insPlyIncomeVo, request, response);
+
+    }
+
+    @ApiModelProperty("平台手续费导出")
+    @PostMapping("pinHandlingExcel")
+    public HttpResult pinHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+
+            return insPlyIncomeService.pinHandlingexcel(insPlyIncomeVo, request, response);
+    }
+    @ApiModelProperty("保险跟单导出")
+    @PostMapping("bxOtherExcel")
+    public HttpResult bxOtherExcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+            return insPlyIncomeService.bxOtherExcel(insPlyIncomeVo, request, response);
+        }
+    }
+
 
-}

+ 11 - 1
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -85,6 +85,16 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
 
     List<InsPlyIncome> NonSettlementQuery(HashMap<String, Object> params);
 
-    InsPlyIncome findByLicenseno(@Param("licenseno") String licenseno);
+    InsPlyIncome totalAmount(HashMap<String, Object> params);
 
+    List<InsPlyIncome> totalPinAmount(HashMap<String, Object> params);
+
+    List<InsPlyIncome> totalBxAmount(HashMap<String, Object> params);
+
+    InsPlyIncome queryInvoicing(HashMap<String, Object> params);
+
+    List<InsPlyIncome> allOtherAmount(HashMap<String, Object> params);
+
+
+    InsPlyIncome findByLicenseno(@Param ("licenseno")String licenseno, @Param ("policyno") String policyno, @Param ("syPolicyno") String syPolicyno,@Param ("noPolicyno")   String noPolicyno);
 }

+ 205 - 3
src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 /**
@@ -23,6 +25,7 @@ import lombok.Setter;
 @Setter
 @TableName("ins_ply_income")
 @ApiModel(value = "InsPlyIncome对象", description = "保司结算手续费")
+@NoArgsConstructor
 public class InsPlyIncome implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -76,7 +79,7 @@ public class InsPlyIncome implements Serializable {
     private String companyId;
 
     @ApiModelProperty("保险公司名称")
-    @TableField(exist = false)
+    @TableField("company_name")
     private String companyName;
 
     @ApiModelProperty("协议号")
@@ -127,6 +130,30 @@ public class InsPlyIncome implements Serializable {
     @TableField("create_time")
     private LocalDateTime createTime;
 
+    @ApiModelProperty("开票时间")
+    @TableField("invoic_time")
+    private LocalDate invoicTime;
+
+    @ApiModelProperty("结算日期")
+    @TableField("settlement_time")
+    private LocalDateTime settlementTime;
+
+    @ApiModelProperty("修改日期")
+    @TableField("update_time")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty("结算人")
+    @TableField("settlement_user_id")
+    private String settlementUserId;
+
+    @ApiModelProperty("修改人")
+    @TableField("update_user_id")
+    private String updateUserId;
+
+    @ApiModelProperty("被保人")
+    @TableField("user_id")
+    private String userId;
+
     @ApiModelProperty("凭证号")
     @TableField("voucher_number")
     private String voucherNumber;
@@ -139,12 +166,12 @@ public class InsPlyIncome implements Serializable {
     @TableField("contract_file_id")
     private String contractFileId;
 
-    @ApiModelProperty("手续费结算状态  1 为已结算")
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
     @TableField("handling_fees_status")
     private String handlingFeesStatus;
 
 
-    @ApiModelProperty("跟单费结算状态  1 为已结算")
+    @ApiModelProperty("跟单费结算状态  1 为已结算  2 已经结算")
     @TableField("documentary_fees_status")
     private String documentaryFeesStatus;
 
@@ -157,6 +184,117 @@ public class InsPlyIncome implements Serializable {
     @TableField("is_not_documentary")
     private String isNotDocumentary;
 
+    @ApiModelProperty("开票金额")
+    @TableField("invoic_amount")
+    private BigDecimal invoicAmount;
+
+    @ApiModelProperty("开票号")
+    @TableField("invoic_id")
+    private String invoicId;
+
+
+    @ApiModelProperty("含税保费")
+    @TableField("tax_premium")
+    private BigDecimal taxPremium;
+
+    @ApiModelProperty("交强手续费")
+    @TableField("jq_supervise_costs_premiums")
+    private BigDecimal jqSuperviseCostsPremiums;
+
+    @ApiModelProperty("交强手续费比例")
+    @TableField("jq_supervise_costs_proportion")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @ApiModelProperty("商业手续费")
+    @TableField("sy_supervise_costs_premiums")
+    private BigDecimal sySuperviseCostsPremiums;
+
+    @ApiModelProperty("商业手续费比例")
+    @TableField("sy_supervise_costs_proportion")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @ApiModelProperty("非车手续费")
+    @TableField("no_supervise_costs_premiums")
+    private BigDecimal noSuperviseCostsPremiums;
+
+    @ApiModelProperty("非车手续费比例")
+    @TableField("no_supervise_costs_proportion")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @ApiModelProperty("交强险含税保费")
+    @TableField("jq_premium")
+    private BigDecimal jqPremium;
+
+    @ApiModelProperty("商业险含保费")
+    @TableField("sy_premium")
+    private BigDecimal syPremium;
+
+    @ApiModelProperty("非车险含保费")
+    @TableField("no_premium")
+    private BigDecimal noPremium;
+
+    @ApiModelProperty("交强险不含税保费")
+    @TableField("jq_no_tax_premium")
+    private BigDecimal jqNoTaxPremium;
+
+
+    @ApiModelProperty("商业险不含税保费")
+    @TableField("sy_no_tax_premium")
+    private BigDecimal syNoTaxPremium;
+
+    @ApiModelProperty("非车险不含税保费")
+    @TableField("no_no_tax_premium")
+    private BigDecimal noNoTaxPremium;
+
+    @ApiModelProperty("交强应收比例")
+    @TableField("jq_receivable_proportion")
+    private BigDecimal jqReceivableProportion;
+
+    @ApiModelProperty("商业应收比例")
+    @TableField("sy_receivable_proportion")
+    private BigDecimal syReceivableProportion;
+
+
+    @ApiModelProperty("非车应收比例")
+    @TableField("no_receivable_proportion")
+    private BigDecimal noReceivableProportion;
+
+    @ApiModelProperty("应收金额")
+    @TableField("receivable_amount")
+    private BigDecimal receivableAmount;
+
+    @ApiModelProperty("交强跟单比例")
+    @TableField("jq_other_costs_proportion")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业跟单比例")
+    @TableField("sy_other_costs_proportion")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("非车跟单比例")
+    @TableField("no_other_costs_proportion")
+    private BigDecimal noOtherCostsProportion;
+
+    @ApiModelProperty("交强跟单金额")
+    @TableField("jq_other_costs_premium")
+    private BigDecimal jqOtherCostsPremium;
+
+    @ApiModelProperty("商业跟单金额")
+    @TableField("sy_other_costs_premium")
+    private BigDecimal syOtherCostsPremium;
+
+    @ApiModelProperty("非车跟单金额")
+    @TableField("no_other_costs_premium")
+    private BigDecimal noOtherCostsPremium;
+
+    @ApiModelProperty("合作公司id")
+    @TableField("partner_companies_id")
+    private String partnerCompaniesId;
+
+    @ApiModelProperty("合作公司名称")
+    @TableField("partner_companies_name")
+    private String partnerCompaniesName;
+
 
     @ApiModelProperty("总单数")
     @TableField(exist = false)
@@ -176,6 +314,9 @@ public class InsPlyIncome implements Serializable {
     @ApiModelProperty("ids")
     @TableField(exist = false)
     private String ids;
+    @ApiModelProperty("ids")
+    @TableField(exist = false)
+    private String unSettledIds;
 
     @ApiModelProperty("时间范围")
     @TableField(exist = false)
@@ -198,14 +339,75 @@ public class InsPlyIncome implements Serializable {
     @TableField(exist = false)
     private BigDecimal sdfStartTime;
 
+    @ApiModelProperty("预收金额")
+    @TableField(exist = false)
+    private BigDecimal totalFeevalue;
+
 
     @ApiModelProperty("结束时间")
     @TableField(exist = false)
     private BigDecimal sdfEndTime;
+
     @ApiModelProperty("月数")
     @TableField(exist = false)
     private String monthSigdate;
 
 
+    @ApiModelProperty("未结算手续费")
+    @TableField(exist = false)
+    private BigDecimal readyCommissionFeevalue;
+    @ApiModelProperty("未结算跟单费")
+    @TableField(exist = false)
+    private BigDecimal readyOtherFeevalue;
+    @ApiModelProperty("未结算总额")
+    @TableField(exist = false)
+    private BigDecimal readyTotalFeevalue;
+    @ApiModelProperty("已开票金额")
+    @TableField(exist = false)
+    private BigDecimal invoicCommissionFeevalue;
 
+    @ApiModelProperty("未开票金额")
+    @TableField(exist = false)
+    private BigDecimal noInvoicCommissionFeevalue;
+    @ApiModelProperty("开票ids")
+    @TableField(exist = false)
+    private String incomeIds;
+
+
+    public InsPlyIncome(String orderno, String policyno, String syPolicyno, String noPolicyno, String settleno, String deptId, String deptName, String riskcode, LocalDateTime payDate, LocalDateTime signDate, String companyId, String companyName, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal noTaxPremium, BigDecimal commissionFeerate, BigDecimal otherFeerate, BigDecimal commissionFeevalue, BigDecimal otherFeevalue, BigDecimal allFeeValue, BigDecimal finalFeeValue, BigDecimal doingFeeValue, LocalDateTime createTime, String voucherNumber, String contractId, String contractFileId, String handlingFeesStatus, String documentaryFeesStatus, String isNotCar, String isNotDocumentary) {
+        this.orderno = orderno;
+        this.policyno = policyno;
+        this.syPolicyno = syPolicyno;
+        this.noPolicyno = noPolicyno;
+        this.settleno = settleno;
+        this.deptId = deptId;
+        this.deptName = deptName;
+        this.riskcode = riskcode;
+        this.payDate = payDate;
+        this.signDate = signDate;
+        this.companyId = companyId;
+        this.companyName = companyName;
+        this.agreementId = agreementId;
+        this.licenseno = licenseno;
+        this.taxamount = taxamount;
+        this.noTaxPremium = noTaxPremium;
+        this.commissionFeerate = commissionFeerate;
+        this.otherFeerate = otherFeerate;
+        this.commissionFeevalue = commissionFeevalue;
+        this.otherFeevalue = otherFeevalue;
+        this.allFeeValue = allFeeValue;
+        this.finalFeeValue = finalFeeValue;
+        this.doingFeeValue = doingFeeValue;
+        this.createTime = createTime;
+        this.voucherNumber = voucherNumber;
+        this.contractId = contractId;
+        this.contractFileId = contractFileId;
+        this.handlingFeesStatus = handlingFeesStatus;
+        this.documentaryFeesStatus = documentaryFeesStatus;
+        this.isNotCar = isNotCar;
+        this.isNotDocumentary = isNotDocumentary;
+    }
+
+    public InsPlyIncome(String id, String jqpolicyno, String sypolicyno, Object o, Object o1, String deptId, Object o2, String productid, LocalDateTime payDate, LocalDateTime signingTime, String companyId, Object o3, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal allNoTaxPremium, BigDecimal handlingProportion, Object o4, BigDecimal handlingAmount, BigDecimal handlingAmount1, Object o5, Object o6, LocalDateTime now, Object o7, Object o8, Object o9, String number, String number1, String number2, String number3) {
+    }
 }

+ 16 - 0
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java

@@ -65,6 +65,22 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     @TableField("company_id")
     private String companyId;
 
+    @ApiModelProperty("结算年度")
+    @TableField("year")
+    private String year;
+
+    @ApiModelProperty("结算月份")
+    @TableField("month")
+    private String month;
+
+    @ApiModelProperty("结算日期")
+    @TableField("day")
+    private String day;
+
+    @ApiModelProperty("结算ids")
+    @TableField("ids")
+    private String ids;
+
 
 
 

+ 10 - 0
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryLogEntity.java

@@ -47,4 +47,14 @@ public class SettlementDocumentaryLogEntity implements Serializable {
     @TableField("handing_amount")
     private BigDecimal handingAmount;
 
+    @ApiModelProperty("结算ids")
+    @TableField("ids")
+    private String ids;
+
+    @ApiModelProperty("结算保险公司")
+    @TableField("company_id")
+    private String companyId;
+    @ApiModelProperty("其他费用金额")
+    private BigDecimal otherFeevalue;
+
 }

+ 28 - 0
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -10,6 +10,9 @@ import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -51,4 +54,29 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
 
     HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo);
 
+    InsPlyIncome totalAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo);
+
+    List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
+
+    HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
+
+    HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
 }

+ 1 - 1
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -136,7 +136,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         //bigdecimal为null时设置为0
 //        handleBigdecimal(insFeeOrder);
         //生成保司费用(应收费用)
-        gene_orderIncome( order, insFeeOrderNew,insAreaCompany);
+//        gene_orderIncome( order, insFeeOrderNew,insAreaCompany);
         //生成机构费用
         gene_deptfee( order, insFeeOrderNew,insAreaCompany);
         //生成分销费用

+ 461 - 143
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ydtech.modules.fnc.service.impl;
 
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,6 +13,7 @@ import com.github.pagehelper.PageInfo;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
@@ -21,9 +24,15 @@ import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
+import com.ydtech.modules.ins.model.vo.res.BxOtherExcel;
+import com.ydtech.modules.ins.model.vo.res.BxSettlementFeesExcel;
+import com.ydtech.modules.ins.model.vo.res.InsCmainNocarDetailResVo;
+import com.ydtech.modules.ins.model.vo.res.SettlementFeesExcel;
 import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
 import com.ydtech.modules.inv.model.dto.InsPlyIncomeExcelDto;
 import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
+import com.ydtech.modules.inv.model.excel.InvDisburseExcel;
+import com.ydtech.modules.inv.utils.EasyExcelUtils;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
@@ -35,10 +44,15 @@ import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.utils.SnowFlakeUtil;
 import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import com.ydtech.utils.excel.ExcelStyleUtil;
+import com.ydtech.utils.excel.ExcelUtils2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.Now;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,8 +60,15 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 import redis.clients.jedis.params.Params;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BandedSampleModel;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -60,6 +81,8 @@ import java.util.stream.Collectors;
  * @author gws
  * @since 2024-01-05
  */
+
+@Slf4j
 @Service
 public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, InsPlyIncome> implements InsPlyIncomeService {
 
@@ -78,6 +101,13 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     private SettlementDocumentaryLogService settlementDocumentaryLogService;
     @Autowired
     private PtlAgreementService  ptlAgreementService;
+    @Autowired
+    private EsmInsCompanyService EsmInsCompanyService;
+
+    @Value("${upload.file.path}")
+    private String uploadPath;
+    @Value("${upload.file.url}")
+    private String uploadUrl;
 
 
     public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo){
@@ -109,14 +139,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (StringUtils.isNotEmpty(agreeType)) {
 //            判断协议类型 平台  保险
             if ("1".equals(agreeType)) {
-                // 平台逻辑处理   判断是否是 和手续费 非车
-                if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //平台车险
-//                    生成手续费  跟单费和手续费是一条单据
-                    this.savePinTai(order,insFeeOrderNew,insAreaCompany);
-                }
-                if(insFeeOrderNew.getNoSuperviseCostsPremiums() != null || insFeeOrderNew.getNoOtherCostsPremiums() != null){ // 平台非车
-                    this.saveNoPinTai(order,insFeeOrderNew,insAreaCompany);
-                }
+                this.savePinTai(order,insFeeOrderNew,insAreaCompany);  //手续费不分非车不非车 跟单也不分
             }else {  // 保险  逻辑: 手续费生成一条  跟单费生成一条   非车手续费一条  非车跟单费一条
                 if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //手续费
                     this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
@@ -154,9 +177,13 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setCreateTime(LocalDateTime.now());
         insPlyIncome.setDocumentaryFeesStatus("0");
         insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setNoNoTaxPremium(insPlyIncome.getNoNoTaxPremium());
+        insPlyIncome.setNoPremium(insPlyIncome.getNoPremium());
         insPlyIncome.setIsNotCar("1");
         insPlyIncome.setIsNotDocumentary("1");
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+        baseMapper.insert(insPlyIncome);
     }
 
     private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
@@ -182,88 +209,59 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setIsNotCar("1");
         insPlyIncome.setIsNotDocumentary("0");
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium()); //非车保费
+        insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());  //非车不含税保费
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+
         baseMapper.insert(insPlyIncome);
     }
 
     private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 商业保单号
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno());  // 商业保单号
-        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
-        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
-        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
-        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("1");
-        insPlyIncome.setAllFeeValue(otherAmount);
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),null);
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),null);
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);  //交强不含税保费
+        BigDecimal allPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);// 总保费
+
+
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),
+                allNoTaxPremium,null,otherProportion,null,otherAmount,otherAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","1");
+
+        insPlyIncome.setTaxPremium(allPremium);
+        insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
+        insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
+        insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
+        insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
+        insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());   //交强跟单费比例
+        insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());   //商业跟单费比例
+        insPlyIncome.setSyOtherCostsPremium(insFeeOrderNew.getSyOtherCostsPremiums());
+        insPlyIncome.setJqOtherCostsPremium(insFeeOrderNew.getJqOtherCostsPremiums());
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+
         baseMapper.insert(insPlyIncome);
     }
 
     private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
 //        保险手续费
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());   // 交强保单号
-        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
-        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
-        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
-        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
-
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(handlingAmount);
-        baseMapper.insert(insPlyIncome);
-    }
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),null);
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),null);
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);//不含税保费
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount()
+        ,allNoTaxPremium,handlingProportion,null,handlingAmount,null,handlingAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","0");
+        BigDecimal allTaxPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);
+        insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
+        insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
+        insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
+        insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
+        insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion());
+        insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
+        insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
+        insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
+        insPlyIncome.setTaxPremium(allTaxPremium);
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
 
-    private void saveNoPinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
-        if(StringUtils.isNotEmpty(noPolicyno)){
-            insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
-        }
-        insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
-        insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion()); // 非车手续费比例
-        insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums());  //非车跟单费
-        insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("1");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
         baseMapper.insert(insPlyIncome);
     }
 
@@ -296,37 +294,62 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
-        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
-        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
-        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
-        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
-        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
-        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
-        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
-        //保单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 交强保单号
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(otherAmount.add(handlingAmount));
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),insFeeOrderNew.getNoSuperviseCostsPremiums());  //手续费
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),insFeeOrderNew.getNoSuperviseCostsProportion());//手续费比例
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),insFeeOrderNew.getNoOtherCostsPremiums());//跟单费
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),insFeeOrderNew.getNoOtherCostsProportion()); //跟单费比例
+//      不含税保费
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), insFeeOrderNew.getNoNoTaxPremium());
+        BigDecimal allAmount = this.calculateTotal(otherAmount, handlingAmount, null);
+        BigDecimal jqReceivableProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getNoSuperviseCostsProportion(), null);// 交强应收 比例
+        BigDecimal syReceivableProportion = this.calculateTotal(insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getSyOtherCostsProportion(), null);//商业应收比例
+        BigDecimal noReceivableProportion = this.calculateTotal(insFeeOrderNew.getNoSuperviseCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion(), null);
+
+        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),
+                noPolicyno,null,insFeeOrderNew.getDeptId(), null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),
+                null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),allNoTaxPremium,handlingProportion,
+                otherProportion,handlingAmount,otherAmount,allAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","0");
+        insPlyIncome.setJqReceivableProportion(jqReceivableProportion);
+        insPlyIncome.setSyReceivableProportion(syReceivableProportion);
+        insPlyIncome.setNoReceivableProportion(noReceivableProportion);
+//        应收金额 =  商业手续费+商业跟单  + 交强手续费  +交强跟单费 + 非车手续费 + 非车跟单费   = allAmount
+        insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums()); // 交强手续费
+        insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums()); // 商业手续费
+        insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums()); // 非车手续费
+        insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion()); //交强手续费 比例
+        insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion()); // 商业手续费 比例
+        insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费 比例
+        insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());  //交强跟单费比例
+        insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());  //商业跟单费比例
+        insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());  //非车跟单费比例
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
         baseMapper.insert(insPlyIncome);
     }
 
-    private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2) {
+    private void saveByCompanyId(InsFeeOrderNew insFeeOrderNew,String companyId, InsPlyIncome insPlyIncome) {
+        PtlAgreement  ptlAgreementQueryVo  = this.ptlAgreementService.getByAgreementIdNew(insFeeOrderNew.getAgreementId());
+        if(ObjectUtils.isNotEmpty(ptlAgreementQueryVo)){
+            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getPartnerCompaniesId())){
+//                合作公司id
+                String partnerCompaniesId = ptlAgreementQueryVo.getPartnerCompaniesId();
+                insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
+                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
+                String name = esmInsCompany.getName();   //合作名称
+                insPlyIncome.setPartnerCompaniesName(name);
+                insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
+            }
+            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getAssociationCompaniesId())){
+                String associationCompaniesId = ptlAgreementQueryVo.getAssociationCompaniesId();
+                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(associationCompaniesId);
+                String name = esmInsCompany.getName();   //保险公司名称
+                insPlyIncome.setCompanyName(name);
+            }
+        }
+    }
+
+    private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2, BigDecimal value3) {
         BigDecimal total = BigDecimal.ZERO;
 
         if (value1 != null) {
@@ -336,6 +359,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (value2 != null) {
             total = total.add(value2);
         }
+        if (value3 != null) {
+            total = total.add(value3);
+        }
 
         return total;
     }
@@ -364,29 +390,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
             params.put("pageNum",insPlyIncomeVo.getPageNum());
             params.put("pageSize",insPlyIncomeVo.getPageSize());
-            if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
-                params.put("startDate",insPlyIncomeVo.getStartDate().toString());
-
-            }
-            if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
-                params.put("endDate",insPlyIncomeVo.getEndDate().toString());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
-                params.put("orderno",insPlyIncomeVo.getOrderno());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
-                params.put("policyno",insPlyIncomeVo.getPolicyno());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
-                params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
-            }
+            params =this.saveParams(insPlyIncomeVo,params);
 
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
-                params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
-                params.put("agreementType",insPlyIncomeVo.getAgreementType());
-            }
 
             List<InsPlyIncome> list= this.baseMapper.queryNew(params);
             pageHelper=new PageInfo(list);
@@ -397,6 +402,119 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             return HttpResult.error("查询异常");
         }
     }
+    @Override
+    public InsPlyIncome totalAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome totalledAmount =baseMapper.totalAmount(params);  //总金额
+        params.put("handlingFeesStatus","0");
+        InsPlyIncome noTotalAmount =baseMapper.totalAmount(params);
+        if(ObjectUtils.isNotEmpty(totalledAmount) && ObjectUtils.isNotEmpty(noTotalAmount)){
+            totalledAmount.setReadyTotalFeevalue(noTotalAmount.getTotalFeevalue());
+            totalledAmount.setReadyCommissionFeevalue(noTotalAmount.getReadyCommissionFeevalue());
+            totalledAmount.setReadyOtherFeevalue(noTotalAmount.getOtherFeevalue());
+            return totalledAmount;
+        }
+        return totalledAmount;
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo) {
+
+            HashMap<String, Object> params = new HashMap<>();
+            List<InsPlyIncome> list= this.baseMapper.queryNew(params);
+            for (InsPlyIncome item : list) {
+                item.setHandlingFeesStatus("1");
+                item.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(item);
+            }
+            SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
+            settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
+            settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
+            settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());  //跟单费金额
+            settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue());  //手续费金额
+            settlementDocumentaryLogEntity.setCreateTime(new Date());
+            settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
+            return HttpResult.ok();
+    }
+
+    @Override
+    public List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome>   result=baseMapper.totalPinAmount(params);
+        return result;
+    }
+
+
+    private HashMap<String, Object> saveParams(InsPlyIncomeVo insPlyIncomeVo, HashMap<String, Object> params) {
+        if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
+            params.put("startDate",insPlyIncomeVo.getStartDate().toString());
+        }
+        if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
+            params.put("endDate",insPlyIncomeVo.getEndDate().toString());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
+            params.put("orderno",insPlyIncomeVo.getOrderno());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
+            params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
+            params.put("agreementType",insPlyIncomeVo.getAgreementType());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())){
+            params.put("licenseno", insPlyIncomeVo.getLicenseno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())){
+            params.put("userId",insPlyIncomeVo.getUserId());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
+            params.put("companyId",insPlyIncomeVo.getCompanyId());
+        }
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getRiskcode())){
+            params.put("riskcode",insPlyIncomeVo.getRiskcode());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
+            params.put("policyno",insPlyIncomeVo.getPolicyno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getSyPolicyno())){
+            params.put("syPolicyno",insPlyIncomeVo.getSyPolicyno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getNoPolicyno())){
+            params.put("noPolicyno",insPlyIncomeVo.getNoPolicyno().split(","));
+        }
+        if(insPlyIncomeVo.getSigndate()!=null){
+            params.put("signdate",insPlyIncomeVo.getSigndate());
+        }
+        if(insPlyIncomeVo.getCreateTime()!=null){
+            params.put("createTime",insPlyIncomeVo.getCreateTime());
+        }
+        if(insPlyIncomeVo.getSettlementTime()!=null){
+            params.put("settlementTime",insPlyIncomeVo.getSettlementTime());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getHandlingFeesStatus())){
+            params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesId())){
+            params.put("partnerCompaniesId",insPlyIncomeVo.getHandlingFeesStatus());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            params.put("year",insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
+            params.put("month",insPlyIncomeVo.getMonth());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
+            params.put("day",insPlyIncomeVo.getDay());
+        }
+        return params;
+    }
 
     @Override
     public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
@@ -415,8 +533,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
                 params.put("year",insPlyIncomeVo.getYear());
             }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
-                params.put("year",insPlyIncomeVo.getYear());
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
+                params.put("month",insPlyIncomeVo.getMonth());
             }
             if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
                 params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
@@ -434,7 +552,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
         try {
-            String ids = insPlyIncomeVo.getIds();
+            String ids = insPlyIncomeVo.getIncomeIds();
             ArrayList<InsPlyIncome> resultList = new ArrayList<>();
             if (ObjectUtils.isNotEmpty(ids)) {
                 String[] split = ids.split(",");
@@ -457,12 +575,14 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(file, InsPlyIncomeExcelDto.class, 0, 1, 1);
             for (InsPlyIncomeExcelDto excelItem : dtoList) {
                 String licenseno = excelItem.getLicenseno();//车牌号
+                String policyno = excelItem.getPolicyno(); //交强保单号
+                String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
+                String noPolicyno = excelItem.getNoPolicyno(); //非车保单号
+
                 if(ObjectUtils.isNotEmpty(licenseno)){
-                    InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(licenseno);
+                    InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(licenseno,policyno,syPolicyno,noPolicyno);
                     if(ObjectUtils.isNotEmpty(insPlyIncome)){
-                        insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
-                        insPlyIncome.setContractId(insPlyIncomeVo.getContractId());
-                        insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
+                        insPlyIncome.setHandlingFeesStatus("1"); //已结算
                         baseMapper.updateById(insPlyIncome);
                     }
                 }
@@ -475,6 +595,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     @Transactional
     public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
+//        根据协议   如果是含增值税结算   用保费 *   如果是  不含税保费
         InsPlyIncome insPlyIncome = new InsPlyIncome();
         BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
         baseMapper.updateById(insPlyIncome);
@@ -485,6 +606,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     private void saveLog(InsPlyIncomeVo insPlyIncomeVo) {
+
         //         添加记录
         SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
         settlementDocumentaryLogEntity.setCrudStatus(insPlyIncomeVo.getCrudStatus());
@@ -629,7 +751,112 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Transactional
     public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
 //  通过ids 查出跟单非结算单
-        String ids = insPlyIncomeVo.getIds();
+        String ids = insPlyIncomeVo.getIncomeIds();
+        if(StringUtils.isNotEmpty(ids)){
+            String[] split = ids.split(",");
+            for (int i =0; i <split.length ; i++) {
+                String id = split[i];
+                InsPlyIncome insPlyIncome = baseMapper.selectById(id);
+                insPlyIncome.setDocumentaryFeesStatus("1"); //1  为跟单费已经结算
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(insPlyIncome);
+            }
+        }
+        SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        }
+
+        settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
+        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
+        settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getOtherFeevalue().subtract(insPlyIncomeVo.getInvoicCommissionFeevalue())); //未开票金额
+        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());//已开票金额
+        settlementDocumentaryFeesVo.setSettlementStatus("2");
+        settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
+        return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
+    }
+
+
+    @Override
+    public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params=this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome>  resultList  =  baseMapper.totalBxAmount(params);
+        return resultList;
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+//      开票时生成  记录 用来合计已经开票数据
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        List<InsPlyIncome> list= this.baseMapper.queryNew(params);
+        for (InsPlyIncome item :  list){
+            item.setHandlingFeesStatus("2");  //已开票
+            item.setInvoicTime(LocalDate.now());
+            item.setInvoicAmount(item.getCommissionFeevalue());
+            baseMapper.updateById(item);
+        }
+        return HttpResult.ok();
+    }
+
+    @Override
+    public HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome result=  baseMapper.queryInvoicing(params);  //总金额
+        params.put("handlingFeesStatus","0");
+        InsPlyIncome noResult=  baseMapper.queryInvoicing(params);  //未结算金额
+        result.setReadyCommissionFeevalue(noResult.getCommissionFeevalue());
+        return HttpResult.ok(result);
+    }
+
+    @Override
+    public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIds())){
+            String[] split = insPlyIncomeVo.getIds().split(",");
+            for(String  id : split){
+                insPlyIncome.setId(id);
+                insPlyIncome.setHandlingFeesStatus("2");
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(insPlyIncome);
+            }
+
+        }
+        SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
+
+        settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getReadyCommissionFeevalue());
+        settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
+        settlementDocumentaryLogEntity.setCreateTime(new Date());
+        settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
+        settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
+        return HttpResult.ok();
+    }
+
+    @Override
+    public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome insPlyIncome = baseMapper.queryInvoicing(params);  //已经开票
+        return HttpResult.ok(insPlyIncome);
+    }
+
+    @Override
+    public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params=this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> result= baseMapper.allOtherAmount(params);
+        return HttpResult.ok(result);
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
+        //  通过ids 查出跟单非结算单
+        String ids = insPlyIncomeVo.getIncomeIds();
         if(StringUtils.isNotEmpty(ids)){
             String[] split = ids.split(",");
             for (int i =0; i <split.length ; i++) {
@@ -638,16 +865,107 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 insPlyIncome.setContractId(insPlyIncomeVo.getContractId()); // 合同id
                 insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
                 insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
-                insPlyIncome.setDocumentaryFeesStatus("1"); //1  为跟单费已经结算
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
                 baseMapper.updateById(insPlyIncome);
             }
         }
         SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
-        settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        }
         settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
-        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());
-        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getTotAmount());
+        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
+        settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
+        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
+        settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
+        settlementDocumentaryFeesVo.setSettlementStatus("1");
         return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
-//
     }
+
+    @Override
+    public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("保险手续费导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<SettlementFeesExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            SettlementFeesExcel bxSettlementFeesExcel = new SettlementFeesExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险手续费导出", SettlementFeesExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+
+    }
+
+    @Override
+    public HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxSettlementFeesExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", BxSettlementFeesExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
+    @Override
+    public HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        params.put("agreementType","2");
+        params.put("isOther","1");
+        params.put("isNotCar","0");
+        List<InsPlyIncome> insPlyIncomes = baseMapper.allOtherAmount(params);
+
+        ExportParams exportParams = new ExportParams("跟单费导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxOtherExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxOtherExcel bxSettlementFeesExcel = new BxOtherExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "跟单费导出", BxOtherExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
+
 }

+ 43 - 2
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -48,6 +48,19 @@ public class InsPlyIncomeVo implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private LocalDate endDate;
 
+
+    @ApiModelProperty(value = "签单日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate signdate;
+
+    @ApiModelProperty(value = "创建日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate createTime;
+
+    @ApiModelProperty(value = "结算日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate settlementTime;
+
     @ApiModelProperty("交强保单号")
     private String policyno;
 
@@ -98,11 +111,11 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("合同附件id")
     private String contractFileId;
 
-    @ApiModelProperty("手续费结算状态  1 为已结算")
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
     private String handlingFeesStatus;
 
 
-    @ApiModelProperty("跟单费结算状态  1 为已结算")
+    @ApiModelProperty("跟单费结算状态  1 为已结算  2 已经结算")
     private String documentaryFeesStatus;
 
 
@@ -136,10 +149,38 @@ public class InsPlyIncomeVo implements Serializable {
     @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
     private  String year;
 
+    @ApiModelProperty("月度")
+    @JsonFormat(pattern = "MM", timezone = "GMT+8")
+    private  String month;
+    @ApiModelProperty("天")
+    @JsonFormat(pattern = "dd", timezone = "GMT+8")
+    private  String day;
+
     @ApiModelProperty("其他费用比例")
     private BigDecimal otherFeerate;
 
     @ApiModelProperty("操作标识")
     private String crudStatus;
 
+    @ApiModelProperty("含税保费")
+    private BigDecimal taxPremium;
+
+    @ApiModelProperty("用户id")
+    private String userId;
+
+    @ApiModelProperty("用户id")
+    private String partnerCompaniesId;
+    @ApiModelProperty("未结算手续费")
+    private BigDecimal readyCommissionFeevalue;
+    @ApiModelProperty("未开票金额")
+    private BigDecimal noInvoicCommissionFeevalue;
+    @ApiModelProperty("开票金额")
+    private BigDecimal invoicCommissionFeevalue;
+    @ApiModelProperty("未结算金额")
+    private BigDecimal unSettledAmount;
+    @ApiModelProperty("未结算ids")
+    private String unSettledIds;
+
+    @ApiModelProperty("开票ids")
+    private String incomeIds;
 }

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java

@@ -64,4 +64,9 @@ public class SettlementDocumentaryFeesVo implements Serializable {
     @ApiModelProperty("签单日期")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private LocalDate signingTime;
+    @ApiModelProperty("是否是开票 结算")
+    private String settlementStatus;
+
+    @ApiModelProperty("结算ids")
+    private String ids;
 }

+ 3 - 0
src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java

@@ -150,6 +150,9 @@ public class QuoteRespVo {
     @ApiModelProperty("非车出口费用")
     private BigDecimal noExportFee;
 
+    @ApiModelProperty("总计出口费用")
+    private BigDecimal sumExportFee;
+
 
     public List<AccidentResponseVo> getAccidentInfo() {
         return accident == null ? Collections.emptyList() : accident;

+ 49 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxOtherExcel.java

@@ -0,0 +1,49 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class BxOtherExcel implements Serializable {
+    private static final long serialVersionUID = 699797306438199251L;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+
+    @ApiModelProperty("合作公司名称")
+    @ExcelProperty( "合作公司名称")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("跟单费总额")
+    @ExcelProperty( "跟单费总额")
+    private BigDecimal otherFeevalue;
+
+    @ApiModelProperty("未开票跟单")
+    @ExcelProperty( "未开票跟单")
+    private BigDecimal noInvoicCommissionFeevalue;
+
+    @ApiModelProperty("已开票跟单")
+    @ExcelProperty( "已开票跟单")
+    private BigDecimal invoicCommissionFeevalue;
+
+    @ApiModelProperty("已开票已结算跟单费")
+    @ExcelProperty( "已开票已结算跟单费")
+    private BigDecimal settleMentAmount;
+
+    @ApiModelProperty("已开票未结算跟单费")
+    @ExcelProperty( "已开票未结算跟单费")
+    private BigDecimal unsettledAmount;
+}

+ 131 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxSettlementFeesExcel.java

@@ -0,0 +1,131 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class BxSettlementFeesExcel implements Serializable {
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+    @ApiModelProperty("签单日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ExcelProperty( "签单日期")
+    private LocalDate signDate;
+
+
+    @ApiModelProperty("车牌号")
+    @ExcelProperty( "车牌号")
+    private String licenseno;
+
+    @ApiModelProperty("被保险人")
+    @ExcelProperty( "被保险人")
+    private String userName;
+
+
+    @ApiModelProperty("险种")
+    @ExcelProperty( "险种")
+    private String riskcode;
+
+    @ApiModelProperty("保司机构")
+    @ExcelProperty( "保司机构")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("协议号")
+    @ExcelProperty( "协议号")
+    private String agreementId;
+
+    @ApiModelProperty("交强保单号")
+    @ExcelProperty( "交强保单号")
+    private String policyno;
+
+
+    @ApiModelProperty("商业保单号")
+    @ExcelProperty( "商业保单号")
+    private String syPolicyno;
+
+    @ApiModelProperty("交强险保费")
+    @ExcelProperty( "交强险保费")
+    private BigDecimal jqPremium;
+    @ApiModelProperty("车船税")
+    @ExcelProperty( "车船税")
+    private BigDecimal taxamount;
+
+    @ApiModelProperty("商业险保费")
+    @ExcelProperty( "商业险保费")
+    private BigDecimal syPremium;
+
+
+    @ApiModelProperty("手续费比例")
+    @ExcelProperty( "手续费比例")
+    private BigDecimal commissionFeerate;
+
+
+    @ApiModelProperty("交强手续费比例")
+    @ExcelProperty( "交强手续费比例")
+    private BigDecimal jqSuperviseCostsProportion;
+
+
+
+    @ApiModelProperty("商业手续费比例")
+    @ExcelProperty( "商业手续费比例")
+    private BigDecimal sySuperviseCostsProportion;
+
+
+    @ApiModelProperty("手续费金额")
+    @ExcelProperty( "手续费金额")
+    private BigDecimal commissionFeevalue;
+
+
+
+    @ApiModelProperty("应收金额")
+    @ExcelProperty( "应收金额")
+    private BigDecimal receivableAmount;
+
+
+    @ExcelProperty( "创建日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建日期")
+    private LocalDate createTime;
+
+
+    @ExcelProperty( "结算日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "结算日期")
+    private LocalDate settlementTime;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String settlementUserName;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String updateUserName;
+
+
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
+    @ExcelProperty( "手续费结算状态")
+    private String handlingFeesStatus;
+
+}

+ 173 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/SettlementFeesExcel.java

@@ -0,0 +1,173 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class SettlementFeesExcel implements Serializable {
+    private static final long serialVersionUID = 699797306438199251L;
+
+
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+
+    @ApiModelProperty("签单日期")
+    @ExcelProperty( "签单日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private LocalDateTime signDate;
+
+
+    @ApiModelProperty("车牌号")
+    @ExcelProperty( "车牌号")
+    private String licenseno;
+
+    @ApiModelProperty("被保险人")
+    @ExcelProperty( "被保险人")
+    private String userName;
+
+
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("险种")
+    @ExcelProperty( "险种")
+    private String riskcode;
+
+
+    @ApiModelProperty("保司机构")
+    @ExcelProperty( "保司机构")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("协议号")
+    @ExcelProperty( "协议号")
+    private String agreementId;
+
+    @ApiModelProperty("交强保单号")
+    @ExcelProperty( "交强保单号")
+    private String policyno;
+
+
+    @ApiModelProperty("商业保单号")
+    @ExcelProperty( "商业保单号")
+    private String syPolicyno;
+
+    @ApiModelProperty("非车保单号")
+    @ExcelProperty( "非车保单号")
+    private String noPolicyno;
+
+    @ApiModelProperty("交强险保费")
+    @ExcelProperty( "交强险保费")
+    private BigDecimal jqPremium;
+
+
+    @ApiModelProperty("车船税")
+    @ExcelProperty( "车船税")
+    private BigDecimal taxamount;
+
+
+    @ApiModelProperty("商业险保费")
+    @ExcelProperty( "商业险保费")
+    private BigDecimal syPremium;
+
+    @ApiModelProperty("非车保费")
+    @ExcelProperty( "非车保费")
+    private BigDecimal noPremium;
+
+    @ApiModelProperty("交强应收比例")
+    @ExcelProperty( "交强应收比例")
+    private BigDecimal jqReceivableProportion;
+
+    @ApiModelProperty("交强手续费比例")
+    @ExcelProperty( "交强手续费比例")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @ApiModelProperty("交强非跟单比例")
+    @ExcelProperty( "交强非跟单比例")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业应收比例")
+    @ExcelProperty( "交强非跟单比例")
+    private BigDecimal syReceivableProportion;
+
+    @ApiModelProperty("商业手续费比例")
+    @ExcelProperty( "商业手续费比例")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @ApiModelProperty("商业非跟单比例")
+    @ExcelProperty( "商业非跟单比例")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("非车应收比例")
+    @ExcelProperty( "非车应收比例")
+    private BigDecimal noReceivableProportion;
+
+
+    @ApiModelProperty("非车手续费比例")
+    @ExcelProperty( "非车手续费比例")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @ApiModelProperty("非车跟单比例")
+    @ExcelProperty( "非车跟单比例")
+    private BigDecimal noOtherCostsProportion;
+
+
+    @ApiModelProperty("手续费金额")
+    @ExcelProperty( "手续费金额")
+    private BigDecimal commissionFeevalue;
+
+
+    @ApiModelProperty("非跟单金额")
+    @ExcelProperty( "非跟单金额")
+    private BigDecimal otherFeevalue;
+
+
+    @ApiModelProperty("应收金额")
+    @ExcelProperty( "应收金额")
+    private BigDecimal receivableAmount;
+
+    @ExcelProperty( "创建日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建日期")
+    private LocalDate createTime;
+
+
+    @ExcelProperty( "结算日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "结算日期")
+    private LocalDate settlementTime;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String settlementUserName;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String updateUserName;
+
+
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
+    @ExcelProperty( "手续费结算状态")
+    private String handlingFeesStatus;
+
+
+}

+ 18 - 1
src/main/java/com/ydtech/modules/inv/model/dto/InsPlyIncomeExcelDto.java

@@ -7,8 +7,25 @@ import lombok.Data;
 @Data
 public class InsPlyIncomeExcelDto {
     /**
-     * 等级
+     * 车牌号
      */
     @Excel(name = "车牌号")
     private String licenseno;
+    /**
+     * 交强保单号
+     */
+    @Excel(name = "交强保单号")
+    private String policyno;
+
+    /**
+     * 商业保单号
+     */
+    @Excel(name = "商业保单号")
+    private String syPolicyno;
+
+    /**
+     * 非车保单号
+     */
+    @Excel(name = "非车保单号")
+    private String noPolicyno;
 }

+ 0 - 8
src/main/java/com/ydtech/modules/order/aop/aspect/AuditVerificationAspect.java

@@ -27,14 +27,6 @@ import org.springframework.stereotype.Component;
 @RequiredArgsConstructor
 public class AuditVerificationAspect {
 
-    private final PtlAgreementDeptService ptlAgreementDeptService;
-
-    private final SysUserRoleService sysUserRoleService;
-
-    private final InsOrdersComponents insOrdersComponents;
-
-    private final TaxSourceServiceImpl taxSourceService;
-
     private final FeeRuleSchemeNewService feeRuleSchemeNewService;
 
     private final InsAreaCompanyService insAreaCompanyService;

+ 25 - 19
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -74,26 +74,32 @@ public class QuoteVerificationAspect {
     @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
     public void doAfter(HttpResult<QuoteRespVo> result){
         //计算费用因子
-        InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(result.getData().getCompanyId());
-        InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = insAreaCompanyAccidentalDrivingService.getByCompanyId(insAreaCompany.getId());
-        insAreaCompany.setAccidentalDriving(insAreaCompanyAccidentalDriving);
-        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
-
-        //再进行费用因子判断
-        try {
-            feeRuleSchemeNewService.verificationCostFactor(insAreaCompany, insOrders);
-            InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
-            if(insFeeOrderNew == null){
-                throw new RuntimeException("费用因子匹配失败");
+        if(result.getCode() == 200) {
+            InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(result.getData().getCompanyId());
+            InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = insAreaCompanyAccidentalDrivingService.getByCompanyId(insAreaCompany.getId());
+            insAreaCompany.setAccidentalDriving(insAreaCompanyAccidentalDriving);
+            InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+
+            //再进行费用因子判断
+            try {
+                feeRuleSchemeNewService.verificationCostFactor(insAreaCompany, insOrders);
+                InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
+                if (insFeeOrderNew == null) {
+                    throw new RuntimeException("费用因子匹配失败");
+                }
+                //出口
+                SubOrderExportFeeVo subOrderExportFeeVo = costsCalcService.getExportFee(insFeeOrderNew);
+
+                result.getData().setJqExportFee(subOrderExportFeeVo.getJqExportCosts());
+                result.getData().setSyExportFee(subOrderExportFeeVo.getSyExportCosts());
+                result.getData().setNoExportFee(subOrderExportFeeVo.getNoExportCosts());
+                result.getData().setSumExportFee(subOrderExportFeeVo.getJqExportCosts()
+                        .add(subOrderExportFeeVo.getSyExportCosts())
+                        .add(subOrderExportFeeVo.getNoExportCosts()));
+
+            } catch (Exception ignored) {
+                System.out.printf("费用因子匹配失败:" + ignored.getMessage());
             }
-            //出口
-            SubOrderExportFeeVo subOrderExportFeeVo = costsCalcService.getExportFee(insFeeOrderNew);
-
-            result.getData().setJqExportFee(subOrderExportFeeVo.getJqExportCosts());
-            result.getData().setSyExportFee(subOrderExportFeeVo.getSyExportCosts());
-            result.getData().setNoExportFee(subOrderExportFeeVo.getNoExportCosts());
-        } catch (Exception ignored) {
-            System.out.printf("费用因子匹配失败:" + ignored.getMessage());
         }
     }
 

+ 1 - 1
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java

@@ -50,7 +50,7 @@ public interface InsAreaCompanyMapper extends BaseMapper<InsAreaCompany> {
     /**
      * 获取待审核的订单
      */
-    Page<InsOrders> getPendingAuditOrders(Page page, @Param("params") OrderQueryVo orderQueryVo);
+    Page<InsOrders> getAuditOrders(Page page, @Param("params") OrderQueryVo orderQueryVo);
 
     Page<InsOrders> getAlreadyAuditOrders(Page page, @Param("params") OrderQueryVo orderQueryVo);
 

+ 9 - 0
src/main/java/com/ydtech/modules/order/entity/InsOrders.java

@@ -229,7 +229,16 @@ public class InsOrders implements Serializable {
     @TableField(exist = false)
     private String auditStatus;  //订单费用审核状态
 
+    @TableField(exist = false)
+    private String auditUser;   //订单费用审核人
+
+    @TableField(exist = false)
+    private String auditTime;   //订单费用审核时间
 
+    @TableField(exist = false)
+    private String agreementCode;   //协议code
+    @TableField(exist = false)
+    private String agreementName;   //协议名称
     public InsOrders(SysUser user, SysDept dept, BaseQuoteInfoVo quoteInfoVo) {
         // 2. 组装订单
         this.setQuoteno(String.valueOf(quoteInfoVo.getQuoteno()));

+ 0 - 235
src/main/java/com/ydtech/modules/order/entity/bo/UnderwritingRulesBo.java

@@ -1,235 +0,0 @@
-package com.ydtech.modules.order.entity.bo;
-
-
-import cn.hutool.core.util.IdcardUtil;
-import com.alibaba.fastjson.annotation.JSONField;
-import com.ydtech.constants.enums.InsurKind;
-import com.ydtech.modules.ins.model.vo.CarInfoVo;
-import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
-import com.ydtech.modules.ins.model.vo.KindInfoVo;
-import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.io.Serializable;
-import java.util.List;
-
-@NoArgsConstructor
-@Data
-public class UnderwritingRulesBo implements Serializable {
-
-    private static final long serialVersionUID = -9105463448498221619L;
-    /**
-     * 车牌号
-     */
-    @JSONField(name = "LicenseNo")
-    private String licenseNo;
-    /**
-     * 新车购置价
-     */
-    @JSONField(name = "CarPrice")
-    private Integer carPrice;
-    /**
-     * 车龄
-     */
-    @JSONField(name = "CarAge")
-    private Integer carAge;
-    /**
-     * 投保人女年龄
-     */
-    @JSONField(name = "ApplicantWage")
-    private Integer applicantWage;
-    /**
-     * 投保人男年龄
-     */
-    @JSONField(name = "ApplicantMage")
-    private Integer applicantMage;
-    /**
-     * 投保人类型
-     */
-    @JSONField(name = "ApplicantType")
-    private String applicantType;
-    /**
-     * 投保人证件号前六位
-     */
-    @JSONField(name = "ApplicantId")
-    private String applicantId;
-    /**
-     * 投保人性别
-     */
-    @JSONField(name = "ApplicantSex")
-    private String applicantSex;
-    /**
-     * 被保人性别
-     */
-    @JSONField(name = "InsureSex")
-    private String insureSex;
-    /**
-     * 被保人证件号前六位
-     */
-    @JSONField(name = "InsureId")
-    private String insureId;
-    /**
-     * 被保人男年龄
-     */
-    @JSONField(name = "InsureMage")
-    private Integer insureMage;
-    /**
-     * 保人女年龄
-     */
-    @JSONField(name = "InsureWage")
-    private Integer insureWage;
-    /**
-     * 被保人类型
-     */
-    @JSONField(name = "InsureType")
-    private String insureType;
-    /**
-     * 车主性别
-     */
-    @JSONField(name = "OwnerSex")
-    private String ownerSex;
-    /**
-     * 车主类型
-     */
-    @JSONField(name = "OwnerType")
-    private String ownerType;
-    /**
-     * 车主证件号前六位
-     */
-    @JSONField(name = "OwnerId")
-    private String ownerId;
-    /**
-     * 车主女年龄
-     */
-    @JSONField(name = "OwnerWage")
-    private Integer ownerWage;
-    /**
-     * 车主男年龄
-     */
-    @JSONField(name = "OwnerMage")
-    private Integer ownerMage;
-    /**
-     * 医保外乘客
-     */
-    @JSONField(name = "MedicalPassenger")
-    private Integer medicalPassenger;
-    /**
-     * 医保外司机
-     */
-    @JSONField(name = "MedicalDriver")
-    private Integer medicalDriver;
-    /**
-     * 司机
-     */
-    @JSONField(name = "Driver")
-    private Integer driver;
-    /**
-     * 三者险
-     */
-    @JSONField(name = "ThInsurance")
-    private Integer thInsurance;
-    /**
-     * 乘客
-     */
-    @JSONField(name = "Passenger")
-    private Integer passenger;
-    /**
-     * 医保外三者
-     */
-    @JSONField(name = "MedicalTh")
-    private Integer medicalTh;
-
-    public UnderwritingRulesBo(BaseQuoteInfoVo baseQuoteInfoVo) {
-        // 车辆因子
-        CarInfoVo carInfo = baseQuoteInfoVo.getCarInfo();
-        this.setTheVehicleFactor(carInfo);
-        // 投保人
-        CustomerInfoVo policyHolderInfo = baseQuoteInfoVo.getPolicyHolderInfo();
-        this.setPolicyHolderInfo(policyHolderInfo);
-        // 被保人
-        CustomerInfoVo insuredPersonInfo = baseQuoteInfoVo.getInsuredPersonInfo();
-        this.setInsuredPersonInfo(insuredPersonInfo);
-        // 车主
-        CustomerInfoVo ownerInfo = baseQuoteInfoVo.getOwnerInfo();
-        this.setOwnerInfo(ownerInfo);
-        // 车险
-        List<KindInfoVo> kindList = baseQuoteInfoVo.getKindList();
-        this.setInsurance(kindList);
-    }
-
-    private void setTheVehicleFactor(CarInfoVo carInfo) {
-        if(carInfo.isNoLicenseFlag()){
-            this.licenseNo = carInfo.getLicenseNo().substring(0, 2);
-        }
-        this.carPrice = Integer.valueOf(carInfo.getPurchasePrice());
-//        this.carAge = carAge;
-    }
-
-    private void setPolicyHolderInfo(CustomerInfoVo policyHolderInfo) {
-        String identifyNumber = policyHolderInfo.getIdentifyNumber();
-        int ageByIdCard = IdcardUtil.getAgeByIdCard(identifyNumber);
-        int genderByIdCard = IdcardUtil.getGenderByIdCard(identifyNumber);
-        this.applicantId = identifyNumber.substring(0, 6);
-        if (genderByIdCard == 0) {
-            this.applicantSex = "女";
-            this.applicantWage = ageByIdCard;
-        } else {
-            this.applicantSex = "男";
-            this.applicantMage = ageByIdCard;
-        }
-//        this.applicantType = applicantType;
-    }
-
-    private void setInsuredPersonInfo(CustomerInfoVo insuredPersonInfo) {
-        String identifyNumber = insuredPersonInfo.getIdentifyNumber();
-        int ageByIdCard = IdcardUtil.getAgeByIdCard(identifyNumber);
-        int genderByIdCard = IdcardUtil.getGenderByIdCard(identifyNumber);
-        this.insureId = identifyNumber.substring(0, 6);
-        if (genderByIdCard == 0) {
-            this.insureSex = "女";
-            this.insureWage = ageByIdCard;
-        } else {
-            this.insureSex = "男";
-            this.insureMage = ageByIdCard;
-        }
-//        this.insureType = insureType;
-    }
-
-    private void setOwnerInfo(CustomerInfoVo ownerInfo) {
-        String identifyNumber = ownerInfo.getIdentifyNumber();
-        int ageByIdCard = IdcardUtil.getAgeByIdCard(identifyNumber);
-        int genderByIdCard = IdcardUtil.getGenderByIdCard(identifyNumber);
-        this.ownerId = identifyNumber.substring(0, 6);
-
-        if (genderByIdCard == 0) {
-            this.ownerSex = "女";
-            this.ownerWage = ageByIdCard;
-        } else {
-            this.ownerSex = "男";
-            this.ownerMage = ageByIdCard;
-        }
-//        this.ownerType = ownerType;
-    }
-
-    private void setInsurance(List<KindInfoVo> kindList) {
-
-        for (KindInfoVo kindInfoVo : kindList) {
-            if (kindInfoVo.getKindCode().equals(InsurKind.SY_FJ_YBW2.getCode())) {
-                this.medicalPassenger = (int) kindInfoVo.getAmount();
-            } else if (kindInfoVo.getKindCode().equals(InsurKind.SY_FJ_YBW3.getCode())) {
-                this.medicalDriver = (int) kindInfoVo.getAmount();
-            } else if (kindInfoVo.getKindCode().equals(InsurKind.D3.getCode())) {
-                this.driver = (int) kindInfoVo.getAmount();
-            } else if (kindInfoVo.getKindCode().equals(InsurKind.B.getCode())) {
-                this.thInsurance = (int) kindInfoVo.getAmount();
-            } else if (kindInfoVo.getKindCode().equals(InsurKind.D4.getCode())) {
-                this.passenger = (int) kindInfoVo.getAmount();
-            } else if (kindInfoVo.getKindCode().equals(InsurKind.SY_FJ_YBW1.getCode())) {
-                this.medicalTh = (int) kindInfoVo.getAmount();
-            }
-        }
-
-    }
-
-}

+ 3 - 1
src/main/java/com/ydtech/modules/order/entity/vo/FeeOrderNewVo.java

@@ -47,7 +47,7 @@ public class FeeOrderNewVo implements Serializable {
         @ApiModelProperty("手续费比例")
         private BigDecimal superviseCosts;
         @ApiModelProperty("手续费")
-        private BigDecimal sySuperviseCostsPremiums;
+        private BigDecimal SuperviseCostsPremiums;
         @ApiModelProperty("跟单比例")
         private BigDecimal otherCostsProportion;
         @ApiModelProperty("跟单费")
@@ -65,6 +65,8 @@ public class FeeOrderNewVo implements Serializable {
     public static class ExportFee {
         @ApiModelProperty("险种")
         private String insuranceType;
+        @ApiModelProperty("保费")
+        private BigDecimal premium;
         @ApiModelProperty("总比例")
         private BigDecimal totalProportion;
         @ApiModelProperty("总费用")

+ 13 - 0
src/main/java/com/ydtech/modules/order/entity/vo/InsOrdersEditingVo.java

@@ -14,6 +14,7 @@ import lombok.EqualsAndHashCode;
 import org.apache.commons.lang3.ObjectUtils;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -140,6 +141,18 @@ public class InsOrdersEditingVo extends InsOrders implements Serializable {
         @TableField(value = "紫金能源车(鼎然-车辆风险评分)")
         private String ubiPredictedInfoScore;
 
+        @ApiModelProperty("交强出口费用")
+        private BigDecimal jqExportFee;
+
+        @ApiModelProperty("商业出口费用")
+        private BigDecimal syExportFee;
+
+        @ApiModelProperty("非车出口费用")
+        private BigDecimal noExportFee;
+
+        @ApiModelProperty("总共出口费用")
+        private BigDecimal sumExportFee;
+
         public InsAreaCompanyEditingDto(InsAreaCompanyQueryDto insAreaCompany) {
             this.orderno = insAreaCompany.getOrderno();
             this.orderstatus = insAreaCompany.getOrderstatus();

+ 66 - 12
src/main/java/com/ydtech/modules/order/entity/vo/OrderQueryVo.java

@@ -20,17 +20,11 @@ public class OrderQueryVo {
     @NotEmpty(message = "用户ID不能为空")
     private String userId;
 
+
     @ApiModelProperty(value = "订单号")
     private String orderNo;
 
-    @ApiModelProperty(value = "车牌号")
-    private String licenseNo;
 
-    @ApiModelProperty(value = "车架号(Vin码)")
-    private String frameNo;
-
-    @ApiModelProperty(value = "投保人姓名")
-    private String insuredName;
 
     @ApiModelProperty(value = "订单状态")
     private String orderStatus;
@@ -39,12 +33,10 @@ public class OrderQueryVo {
     @NotEmpty(message = "部门不能为空")
     private String deptId;
 
-    @ApiModelProperty("保险公司编号")
-    private String companyId;
-
     @ApiModelProperty("费用审核状态0未审核 1审核通过")
     private String auditStatus;
 
+
     @ApiModelProperty(value = "开始时间")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private LocalDate startDate;
@@ -66,12 +58,74 @@ public class OrderQueryVo {
     private String endDateStr;
 
 
-    @ApiModelProperty(value = "业务员工号")
+    @ApiModelProperty(value = "省机构id")
+    private String provinceId;
+
+    @ApiModelProperty(value = "市机构id")
+    private String cityId;
+
+    @ApiModelProperty(value = "县机构id")
+    private String countyId;
+
+    @ApiModelProperty(value = "门店机构id")
+    private String houseId;
+
+    @ApiModelProperty(value = "任务池号")
+    private String taskNo;
+
+    @ApiModelProperty("保险公司编号")
+    private String companyId;
+
+    @ApiModelProperty("协议Id")
+    private String agreeId;
+
+
+//    @ApiModelProperty(value = "协议Id")
+//    private String agreementId;
+
+
+
+    @ApiModelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @ApiModelProperty(value = "车架号(Vin码)")
+    private String frameNo;
+
+    @ApiModelProperty(value = "发动机号")
+    private String engineNo;
+
+    @ApiModelProperty(value = "险种代码")
+    private String riskCode;
+
+    @ApiModelProperty(value = "代理人工号")
     private String operatorId;
 
-    @ApiModelProperty(value = "业务员姓名")
+    @ApiModelProperty(value = "代理人姓名")
     private String operatorName;
 
+    @ApiModelProperty(value = "受理人工号")
+    private String auditId;
+
+    @ApiModelProperty(value = "投保险种")
+    private String productId;
+
+
+
+    @ApiModelProperty(value = "投保人姓名")
+    private String insuredName;
+
+    @ApiModelProperty(value = "报价开始时间")
+    private String quoteStartDateStr;
+
+    @ApiModelProperty(value = "报价结束时间")
+    private String quoteEndDateStr;
+
+    @ApiModelProperty(value = "起保开始时间")
+    private String attachStartDateStr;
+    @ApiModelProperty(value = "起保结束时间")
+    private String attachEndDateStr;
+
+
     public LocalDate getEndDatePlusOneDay() {
         if(ObjectUtils.isEmpty(endDate)){
             return endDate;

+ 56 - 0
src/main/java/com/ydtech/modules/order/entity/vo/OrderVo.java

@@ -61,6 +61,12 @@ public class OrderVo implements Serializable {
     @TableField(value = "deptid")
     private String deptid;
 
+    /**
+     * 代理团队归属信息
+     */
+    private String deptAreaInfo;
+
+
     /**
      * 代理团队名称
      */
@@ -366,4 +372,54 @@ public class OrderVo implements Serializable {
     @TableField(value = "ubi_predicted_info_score")
     private String ubiPredictedInfoScore;
 
+
+    /**
+     * 推荐人工号
+     */
+    private String referrerNo;
+
+    /**
+     * 推荐人姓名
+     */
+    private String referrerName;
+
+    /**
+     * 推荐人机构编号
+     */
+    private String referrerDeptId;
+
+    /**
+     * 推荐人机构名称
+     */
+    private String referrerDeptName;
+
+    /**
+     * 推荐人机构归属信息
+     */
+    private String referrerDeptAreaInfo;
+
+    /**
+     * 推荐人手机号
+     */
+    private String referrerMobile;
+
+    /**
+     * 推荐人性别
+     */
+    private String referrerSex;
+
+    /**
+     * 费用综合
+     */
+    private String sumFee;
+
+    /**
+     * 出单人电话
+     */
+    public String mobile;
+
+    /**
+     * 出单人性别
+     */
+    public String sex;
 }

+ 1 - 1
src/main/java/com/ydtech/modules/order/service/InsAreaCompanyService.java

@@ -87,7 +87,7 @@ public interface InsAreaCompanyService extends IService<InsAreaCompany> {
      * 查询待审核的订单
      * @return
      */
-    Page<InsOrders> getPendingAuditOrders(Page page, OrderQueryVo orderQueryVo);
+    Page<InsOrders> getAuditOrders(Page page, OrderQueryVo orderQueryVo);
 
     /**
      * 查询已审核得订单

+ 10 - 0
src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java

@@ -639,6 +639,16 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         // 保存订单信息
         InsAreaCompany insAreaCompany = new InsAreaCompany(quoteRespVo, ptlAgreementAttribution);
 
+        List<InsAreaCompanyAccidentalDriving> insAreaCompanyAccidentalDrivings = new ArrayList<>();
+        accidentalDrivingVo.forEach(accidentalDriving -> {
+            InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = new InsAreaCompanyAccidentalDriving();
+            insAreaCompanyAccidentalDriving.setQuantity(insAreaCompanyAccidentalDriving.getQuantity());
+            insAreaCompanyAccidentalDriving.setRideRiskCode(insAreaCompanyAccidentalDriving.getRideRiskCode());
+            insAreaCompanyAccidentalDriving.setRideRiskName(insAreaCompanyAccidentalDriving.getRideRiskName());
+            insAreaCompanyAccidentalDrivings.add(insAreaCompanyAccidentalDriving);
+        });
+        insAreaCompanyService.insertCompanyAndOrders(insAreaCompany,insAreaCompanyAccidentalDrivings);
+
         // 渤海业务id
         String busUniqueId = response.getData().getBusUniqueId();
         insAreaCompany.setId(orderId);

+ 5 - 3
src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java

@@ -140,14 +140,16 @@ public class InsAreaCompanyServiceImpl extends ServiceImpl<InsAreaCompanyMapper,
     }
 
     @Override
-    public Page<InsOrders> getPendingAuditOrders(Page page, OrderQueryVo orderQueryVo) {
+    public Page<InsOrders> getAuditOrders(Page page, OrderQueryVo orderQueryVo) {
         if(orderQueryVo.getStartDate() != null && orderQueryVo.getEndDate() != null){
             orderQueryVo.setStartDateStr(orderQueryVo.getStartDate().toString());
             orderQueryVo.setEndDateStr(orderQueryVo.getEndDate().toString());
         }
-        Page<InsOrders> pendingAuditOrders = baseMapper.getPendingAuditOrders(page, orderQueryVo);
+        Page<InsOrders> pendingAuditOrders = baseMapper.getAuditOrders(page, orderQueryVo);
         pendingAuditOrders.getRecords().forEach(item->{
-            item.setAuditStatus("0");
+            if(item.getAuditStatus() == null){
+                item.setAuditStatus("0");
+            }
         });
         return pendingAuditOrders;
     }

+ 91 - 22
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -23,14 +23,15 @@ import com.ydtech.modules.admin.constants.RoleConstants;
 import com.ydtech.modules.admin.dao.SysUserLinkAreaMapper;
 import com.ydtech.modules.admin.dao.SysUserLinkPtlAgreementMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
-import com.ydtech.modules.admin.model.SysDept;
-import com.ydtech.modules.admin.model.SysUser;
-import com.ydtech.modules.admin.model.SysUserRole;
+import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.SysUserLinkPtlAgreementDto;
 import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.admin.service.SysUserInfoService;
 import com.ydtech.modules.admin.service.SysUserRoleService;
 import com.ydtech.modules.admin.service.SysUserService;
+import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.esm.service.EsmUserReferrerService;
+import com.ydtech.modules.fee.service.CostsCalcService;
 import com.ydtech.modules.fee.service.impl.FeeRuleSchemeServiceImpl;
 import com.ydtech.modules.fnc.entity.InsFeeAudit;
 import com.ydtech.modules.fnc.service.InsFeeAuditService;
@@ -50,7 +51,6 @@ import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.InsOrdersTrack;
-import com.ydtech.modules.order.entity.bo.UnderwritingRulesBo;
 import com.ydtech.modules.order.entity.crawler.response.CrawlerVerifyPaymentResponse;
 import com.ydtech.modules.order.entity.dto.DrivingInsuranceDto;
 import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
@@ -80,11 +80,13 @@ import org.springframework.util.ObjectUtils;
 
 import javax.validation.constraints.NotBlank;
 import java.io.File;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import static com.ydtech.modules.order.constants.OrderCacheConstant.*;
+import static com.ydtech.modules.order.constants.OrderCacheConstant.QUOTE_INFO_KEY;
+import static com.ydtech.modules.order.constants.OrderCacheConstant.QUOTE_INFO_KEY_TIME;
 
 /**
  * @author wenkaisen
@@ -118,6 +120,10 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
 
     private final InsFileMapper insFileMapper;
 
+    @Autowired
+    private SysUserInfoService sysUserInfoService;
+
+
     @Autowired
     private InsFeeOrderNewService insFeeOrderNewService;
 
@@ -136,6 +142,9 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
     @Autowired
     private SysUserLinkAreaMapper sysUserLinkAreaMapper;
 
+    @Autowired
+    private CostsCalcService costsCalcService;
+
 
     public InsOrdersServiceImpl(OrderComponents orderComponents, SysUserService sysUserService,
                                 SysUserRoleService sysUserRoleService,
@@ -308,12 +317,6 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         String s = JSON.toJSONString(quoteInfoVo);
         redisTemplate.opsForValue().set(QUOTE_INFO_KEY + insOrders.getOrderno(), s, QUOTE_INFO_KEY_TIME, TimeUnit.DAYS);
 
-        // 5 生成承包规则参数
-        UnderwritingRulesBo underwritingRulesBo = new UnderwritingRulesBo(quoteInfoVo);
-        String rules = JSON.toJSONString(underwritingRulesBo);
-        redisTemplate.opsForValue().set(QUOTE_RULES_KEY + insOrders.getOrderno(), rules, QUOTE_RULES_KEY_TIME,
-                TimeUnit.HOURS);
-
         return insOrders;
     }
 
@@ -378,17 +381,13 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         //查询未审核
         if(orderQueryVo.getAuditStatus() == null)
             orderQueryVo.setAuditStatus("0"); //默认查询未审核
-        if (orderQueryVo.getAuditStatus().equals("0")) {
-            resultOrders = insAreaCompanyService.getPendingAuditOrders(page, orderQueryVo);
-        } else{
-            //已审核
-            resultOrders = insAreaCompanyService.getAlreadyAuditOrders(page, orderQueryVo);
-        }
+        resultOrders = insAreaCompanyService.getAuditOrders(page, orderQueryVo);
+
         //查找机构来源字典 遍历
         Map<String, DictionaryManagement> m = DictEnumConfig.getDmMap();
         DictionaryManagement organizationSource = m.get("organizationSource");
         resultOrders.getRecords().forEach(item->{
-            DictionaryData dictionaryData = organizationSource.getDdList().stream().filter(x -> x.getDictValue().equals(item.getManagementSource())).findFirst().get();
+            DictionaryData dictionaryData = organizationSource.getDdList().stream().filter(x -> x.getDictValue().equals(item.getManagementSource())).findFirst().orElse(null);
             if(dictionaryData != null){
                 item.setManagementSource(dictionaryData.getDictTag());
             }
@@ -620,6 +619,43 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
     @Override
     public HttpResult<OrderVo> getByCompanyId(@NotBlank(message = "子订单不能为空") String companyId, String userId) {
         OrderVo orderAndAreaCompany = baseMapper.getOrderAndAreaCompany(companyId);
+        //团队归属信息
+        String areaInfo = sysDeptService.queryBelongArea(orderAndAreaCompany.getDeptid());
+        SysUser sysUser = sysUserService.getById(orderAndAreaCompany.getUserid());
+        SysUserInfo sysUserInfo = sysUserInfoService.getById(orderAndAreaCompany.getUserid());
+        if("M".equals(sysUserInfo.getSex())){
+            orderAndAreaCompany.setSex("男");
+        }else{
+            orderAndAreaCompany.setSex("女");
+        }
+        orderAndAreaCompany.setMobile(sysUser.getMobile());
+        orderAndAreaCompany.setDeptAreaInfo(areaInfo);
+        //推荐人信息查询
+        EsmUserReferrer esmUserReferrer = esmUserReferrerService.getById(orderAndAreaCompany.getUserid());
+        if(esmUserReferrer != null){
+            SysUser referrerUser = sysUserService.findByUserId(esmUserReferrer.getReferrerId());
+            SysUserInfo referrerSysUserInfo = sysUserInfoService.getById(esmUserReferrer.getReferrerId());
+            if("M".equals(referrerSysUserInfo.getSex())){
+                orderAndAreaCompany.setReferrerSex("男");
+            }else{
+                orderAndAreaCompany.setReferrerSex("女");
+            }
+            orderAndAreaCompany.setReferrerMobile(referrerUser.getMobile());
+            orderAndAreaCompany.setReferrerNo(referrerUser.getId());
+            orderAndAreaCompany.setReferrerName(referrerUser.getName());
+            orderAndAreaCompany.setReferrerDeptId(referrerUser.getDeptId());
+            SysDept sysDept = sysDeptService.getById(referrerUser.getDeptId());
+            orderAndAreaCompany.setReferrerDeptName(sysDept.getName());
+            orderAndAreaCompany.setReferrerDeptAreaInfo(sysDeptService.queryBelongArea(referrerUser.getDeptId()));
+        }
+
+        //计算今年应缴税
+        JSONArray taxArrears = orderAndAreaCompany.getTaxArrears();
+        if(taxArrears != null && !taxArrears.isEmpty()) {
+            JSONObject taxArrear = taxArrears.getJSONObject(0);
+            taxArrear.put("dayYearTax", orderAndAreaCompany.getTaxamount().subtract(taxArrear.getBigDecimal("taxDefault")
+                    .subtract(taxArrear.getBigDecimal("lateFee"))));
+        }
 
         YaExtendInfoDto yaExtendInfoDto = new YaExtendInfoDto();
         // 永安财险
@@ -687,6 +723,13 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             FeeOrderNewVo feeOrderNewVo = feeRuleSchemeService.newConvertOrderFeeVoData(insFeeOrderNew, ptlAgreementProductCostsNew);
             feeOrderNewVo.setFeeId(insFeeOrderNew.getId());
             orderAndAreaCompany.setFeeOrderNewVo(feeOrderNewVo);
+            //计算总和
+
+            BigDecimal sum = feeOrderNewVo.getExportFee()
+                    .stream()
+                    .map(FeeOrderNewVo.ExportFee::getTotalAmount)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            orderAndAreaCompany.setSumFee(sum.toString());
             List<DistributionLevelVo> distributionLevelVoList = feeRuleSchemeService.converDistrbutionData(insFeeOrderNew);
             orderAndAreaCompany.setDistributionLevelVoList(distributionLevelVoList);
         }
@@ -702,6 +745,8 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         if (null == orderAndAreaCompany.getKindinfo()) orderAndAreaCompany.setKindinfo(JSON.parseArray("[]"));
         if (null == orderAndAreaCompany.getFeeStatus()) orderAndAreaCompany.setFeeStatus("0");
 
+        //获取出单员地区信息
+
         return HttpResult.ok("success", orderAndAreaCompany);
     }
 
@@ -718,6 +763,28 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         List<InsOrdersEditingVo.InsAreaCompanyEditingDto> insAreaCompanyEditingDtos =
                 insAreaCompanyQueryDtos.stream().map(InsOrdersEditingVo.InsAreaCompanyEditingDto::new).collect(Collectors.toList());
 
+        List<String> companyIds = insAreaCompanyEditingDtos.stream().map(x -> x.getCompanyId()).collect(Collectors.toList());
+
+        List<InsFeeOrderNew> insFeeOrderNews = new ArrayList<>();
+        if(!companyIds.isEmpty()) {
+            insFeeOrderNews = insFeeOrderNewService.getInsFeeOrderNewListByCompanyId(companyIds);
+        }
+
+        //计算费用
+        insFeeOrderNews.forEach(insFeeOrderNew -> {
+            SubOrderExportFeeVo subOrderExportFeeVo = costsCalcService.getExportFee(insFeeOrderNew);
+            insAreaCompanyEditingDtos.stream().filter(x -> x.getCompanyId().equals(insFeeOrderNew.getInsOrderNo())).findFirst().ifPresent(result -> {
+                result.setJqExportFee(subOrderExportFeeVo.getJqExportCosts());
+                result.setSyExportFee(subOrderExportFeeVo.getSyExportCosts());
+                result.setNoExportFee(subOrderExportFeeVo.getNoExportCosts());
+                result.setSumExportFee(subOrderExportFeeVo.getJqExportCosts()
+                        .add(subOrderExportFeeVo.getSyExportCosts())
+                        .add(subOrderExportFeeVo.getNoExportCosts()));
+            });
+
+        });
+
+
         insOrdersEditingVo.setInsAreaCompanyEditingDtos(insAreaCompanyEditingDtos);
         return insOrdersEditingVo;
     }
@@ -818,8 +885,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             //渠道
             //查询用户表中的信息为领带id为用户id的数据
             //List<SysUserBaseVO> allUsersByLeaderId = sysUserMapper.getAllUsersByLeaderId(orderQueryVo.getUserId());
-            agentUserIds = sysUserMapper.getUserIdsByLeaderId(orderQueryVo.getUserId());
-
+            agentUserIds = sysUserService.getUserIdsByLeaderId(orderQueryVo.getUserId());
             //查询下级
            // if (allUsersByLeaderId != null && allUsersByLeaderId.size() > 0) {
            //     for (SysUserBaseVO sysUserBaseVO : allUsersByLeaderId) {
@@ -827,12 +893,15 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
            //     }
            // }
             //查询团队长的机构ids
-            deptIds= sysUserMapper.getDeptIdsByUserIds(orderQueryVo.getUserId());
+            //deptIds= sysUserMapper.getDeptIdsByUserIds(orderQueryVo.getUserId());
         } else if (type == 2) {
             //查询所有的代理人
             //agentUserIds = sysUserMapper.getAgentUserIds();
             //查询绑定的区域的代理人信息
-            agentUserIds =sysUserLinkAreaMapper.findAreaIdsByAgentUserId(orderQueryVo.getUserId());
+            List<String> areaCodes = sysUserLinkAreaMapper.findAreaCodeByUserId(orderQueryVo.getUserId());
+            if(areaCodes!=null && areaCodes.size()>0){
+                agentUserIds =sysUserLinkAreaMapper.findAreaIdsByAgentUserId(orderQueryVo.getUserId(),areaCodes);
+            }
         } else if (type == 3) {
             //查询用户关联的协议
             List<SysUserLinkPtlAgreementDto> ptlAgreementListByUserIds =

+ 12 - 12
src/main/java/com/ydtech/modules/order/service/impl/YongchengOrderApiServiceImpl.java

@@ -420,11 +420,11 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
             String newStartDate = "";
             String newEndDate = "";
             //判断是否是及时起保
-            if(start.getHour() > 0 || start.getMinute() > 0 || start.getSecond() > 0){
+            if (start.getHour() > 0 || start.getMinute() > 0 || start.getSecond() > 0) {
                 newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
                 end = end.plusDays(1L);
                 newEndDate = DateTimeUtil.getStartTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
-            }else{
+            } else {
                 newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
                 newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
             }
@@ -505,7 +505,9 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
             //截取0 到 机动车交通事故强制险
             String ciMsg = tfiWarnData.getWarnMessage();
             requestInfoList.add(ciMsg);
-            if (ciMsg.contains("终保日期: 以上为所有结果信息")) return true;
+            if (ciMsg.contains("终保日期: 以上为所有结果信息")) {
+                throw new SystemException("商业险平台返回:" + ciMsg);
+            }
 
             //终保日期
             String coverageEndDate = ciMsg.substring(ciMsg.indexOf("终保日期") + 5, ciMsg.indexOf("终保日期") + 5 + 12);
@@ -516,11 +518,11 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
             String newStartDate = "";
             String newEndDate = "";
             //判断是否是及时起保
-            if(start.getHour() > 0 || start.getMinute() > 0 || start.getSecond() > 0){
+            if (start.getHour() > 0 || start.getMinute() > 0 || start.getSecond() > 0) {
                 newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
                 end = end.plusDays(1L);
                 newEndDate = DateTimeUtil.getStartTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
-            }else{
+            } else {
                 newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
                 newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
             }
@@ -758,7 +760,6 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
      */
 
 
-
     @Override
     public HttpResult callbackAnOrder(String quoteOrderNo) {
 
@@ -1363,14 +1364,13 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
 
     }
 
-     /**
-     * @Description  更新订单状态和支付时间
-     * @Author  xingming
-     * @Date   2024/3/28 16:55
+    /**
+     * @Description 更新订单状态和支付时间
+     * @Author xingming
+     * @Date 2024/3/28 16:55
      * @Param
      * @Return
      * @Exception
-     *
      */
     @Override
     public void callbackAnOrderNew(String insAreaCompanyId) {
@@ -1398,7 +1398,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
                     iac = buildCallBack(iac, param);
                 }
                 //设置支付时间
-                if(iac.getPayDate()==null){
+                if (iac.getPayDate() == null) {
                     iac.setPayDate(LocalDateTime.now());
                 }
                 log.info("变更前订单状态:" + order.getOrderstatus());

+ 1 - 1
src/main/java/com/ydtech/modules/order/service/impl/ZijinOrderApiServiceImpl.java

@@ -593,7 +593,7 @@ public class ZijinOrderApiServiceImpl implements ZijinOrderApiService {
             insAreaCompanyAccidentalDriving.setRideRiskName(insAreaCompanyAccidentalDriving.getRideRiskName());
             insAreaCompanyAccidentalDrivings.add(insAreaCompanyAccidentalDriving);
         });
-        insAreaCompany.setIsDjq(calculatePremiumResponse.getBasePart().getIsDjq());
+        insAreaCompany.setIsDjq(calculatePremiumResponse.getBasePart().getIsDjq().equals("")?"0":calculatePremiumResponse.getBasePart().getIsDjq());
         insAreaCompanyService.insertCompanyAndOrders(insAreaCompany,insAreaCompanyAccidentalDrivings);
         quoteRespVo.setCompanyId(orderNo);
         //添加调用费用匹配功能

+ 1 - 0
src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementMapper.java

@@ -20,6 +20,7 @@ public interface PtlAgreementMapper extends BaseMapper<PtlAgreement> {
 
     PtlAgreementInsCompanyDto getAgreementCompanyByCompanyId(@Param("localDate") LocalDate localDate, @Param("deptId") String deptId,@Param("companyId") String companyId);
 
+    PtlAgreement getByAgreementIdNew(String agreementId);
 }
 
 

+ 1 - 1
src/main/java/com/ydtech/modules/protocol/entity/vo/PtlAgreementPageVo.java

@@ -50,7 +50,7 @@ public class PtlAgreementPageVo extends PageRequest {
     @ApiModelProperty("合作公司id")
     private String partnerCompaniesId;
 
-    @ApiModelProperty("是否有效")
+    @ApiModelProperty("是否有效 0 无效 1 有效 2 待审核")
     private String validStatus;
 
     @ApiModelProperty("审核状态 0 申请审核 1 审核通过 2 审核不通过")

+ 2 - 0
src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java

@@ -215,4 +215,6 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreement> getCurrentAgreementList(String agreementId);
 
+    PtlAgreement getByAgreementIdNew(String agreementId);
+
 }

+ 34 - 19
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -38,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -349,10 +350,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         LambdaQueryWrapper<PtlAgreement> wrapper = new LambdaQueryWrapper<>();
         // 获取供应商本级id 及其 下级id
         List<String> lowerId = esmInsCompanyService.getByLowerId(ptlAgreementPageVo.getPartnerCompaniesId());
-        // 审核状态
-        wrapper.eq(!ObjectUtils.isEmpty(ptlAgreementPageVo.getAuditStatus()), PtlAgreement::getAuditStatus, ptlAgreementPageVo.getAuditStatus())
-                //是否有效
-                .eq(!ObjectUtils.isEmpty(ptlAgreementPageVo.getValidStatus()), PtlAgreement::getValidStatus, ptlAgreementPageVo.getValidStatus())
+        //是否有效
+        wrapper.eq(!ObjectUtils.isEmpty(ptlAgreementPageVo.getValidStatus()), PtlAgreement::getValidStatus, ptlAgreementPageVo.getValidStatus())
                 // 供应商类型
                 .eq(!ObjectUtils.isEmpty(ptlAgreementPageVo.getCompaniesType()), PtlAgreement::getCompaniesType, ptlAgreementPageVo.getCompaniesType())
                 // 协议类型
@@ -363,14 +362,23 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
                 .eq(!ObjectUtils.isEmpty(ptlAgreementPageVo.getModifiedBy()), PtlAgreement::getModifiedBy, ptlAgreementPageVo.getModifiedBy())
                 // 合作公司
                 .in(!StringUtils.isEmpty(ptlAgreementPageVo.getPartnerCompaniesId()) && !lowerId.isEmpty(), PtlAgreement::getPartnerCompaniesId, lowerId)
-                // 录入时间
-                .between(!ObjectUtils.isEmpty(ptlAgreementPageVo.getStartDate()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getEndDate()), PtlAgreement::getCreateTime, ptlAgreementPageVo.getStartDate(), ptlAgreementPageVo.getEndDate())
-                // 修改时间
-                .between(!ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateStarTime()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateEndTime()), PtlAgreement::getUpdateTime, ptlAgreementPageVo.getUpdateStarTime(), ptlAgreementPageVo.getUpdateEndTime())
                 // 协议起期
                 .le(!ObjectUtils.isEmpty(ptlAgreementPageVo.getAgreementStartDate()), PtlAgreement::getStartDate, ptlAgreementPageVo.getAgreementStartDate())
                 // 协议止期
                 .ge(!ObjectUtils.isEmpty(ptlAgreementPageVo.getAgreementEndDate()), PtlAgreement::getEndDate, ptlAgreementPageVo.getAgreementEndDate());
+        // 录入时间
+        if (!ObjectUtils.isEmpty(ptlAgreementPageVo.getStartDate()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getEndDate())) {
+            LocalDateTime startDateTime = ptlAgreementPageVo.getStartDate().atTime(LocalTime.MIN);
+            LocalDateTime endDateTime = ptlAgreementPageVo.getEndDate().atTime(LocalTime.MAX);
+            wrapper.between(!ObjectUtils.isEmpty(ptlAgreementPageVo.getStartDate()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getEndDate()), PtlAgreement::getCreateTime, startDateTime, endDateTime);
+
+        }
+        // 修改时间
+        if (!ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateStarTime()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateEndTime())) {
+            LocalDateTime startDateTime = ptlAgreementPageVo.getUpdateStarTime().atTime(LocalTime.MIN);
+            LocalDateTime endDateTime = ptlAgreementPageVo.getUpdateEndTime().atTime(LocalTime.MAX);
+            wrapper.between(!ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateStarTime()) && !ObjectUtils.isEmpty(ptlAgreementPageVo.getUpdateEndTime()), PtlAgreement::getUpdateTime, startDateTime,endDateTime);
+        }
         // 省市县
         if (ptlAgreementPageVo.getAreaCode() != null && !"".equals(ptlAgreementPageVo.getAreaCode()) && ptlAgreementPageVo.getLevel() != null) {
             String area = ptlAgreementPageVo.getAreaCode();
@@ -387,7 +395,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
                     prefix = area.substring(0, 4);
                     break;
                 }
-                case "3": {  // 区县级查询逻辑
+                case "3": { // 区县级查询逻辑
                     sign = 6;
                     prefix = area.substring(0, 6);
                     break;
@@ -395,9 +403,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
             }
             wrapper.apply("SUBSTRING(partner_companies_id, 6, " + sign + ") =" + prefix);
         }
-
-        Page<PtlAgreement> records = page(page,wrapper);
-        return records;
+        Page<PtlAgreement> agreementPage = page(page, wrapper);
+        return agreementPage;
     }
 
     @Override
@@ -573,13 +580,15 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         EsmInsCompany esmInsCompany;
 
         // 获取保险公司
-        if (AgreementType.AT2.getCode().equals(agreementSaveDto.getAgreementType())) {
-            String message = String.format("协议为 %s 保险公司必须传入", AgreementType.AT2.getDesc());
-            AssertionUtils.isStringEmpty(agreementSaveDto.getAssociationCompaniesId(), message);
-            esmInsCompany = esmInsCompanyService.isExists(agreementSaveDto.getAssociationCompaniesId());
-        } else {
-            esmInsCompany = esmInsCompanyService.getBySubsidiary(agreementSaveDto.getPartnerCompaniesId());
-        }
+//        if (AgreementType.AT2.getCode().equals(agreementSaveDto.getAgreementType())) {
+//            String message = String.format("协议为 %s 保险公司必须传入", AgreementType.AT2.getDesc());
+//            AssertionUtils.isStringEmpty(agreementSaveDto.getAssociationCompaniesId(), message);
+//            esmInsCompany = esmInsCompanyService.isExists(agreementSaveDto.getAssociationCompaniesId());
+//        } else {
+//            esmInsCompany = esmInsCompanyService.getBySubsidiary(agreementSaveDto.getPartnerCompaniesId());
+//        }
+
+        esmInsCompany = esmInsCompanyService.getBySubsidiary(agreementSaveDto.getPartnerCompaniesId());
 
         // 验证用户名密码 python api 对接需要验证用户名
         if (!ObjectUtils.isEmpty(attribution.getApiType()) && PtlApiType.PTL_API_2.getCode() == attribution.getApiType()) {
@@ -701,4 +710,10 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         return ptlAgreements;
     }
 
+    @Override
+    public PtlAgreement getByAgreementIdNew(String agreementId) {
+        PtlAgreement   ptlAgreement= baseMapper.getByAgreementIdNew(agreementId);
+        return ptlAgreement;
+    }
+
 }

+ 4 - 0
src/main/java/com/ydtech/modules/protocols/service/InsFeeOrderNewService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
 
+import java.util.List;
+
 /**
 *@author: tz
 *@description: 费用计算表 service
@@ -13,5 +15,7 @@ public interface InsFeeOrderNewService extends IService<InsFeeOrderNew> {
 
     InsFeeOrderNew getInsFeeOrderNewByCompanyId(String companyId);
 
+    List<InsFeeOrderNew> getInsFeeOrderNewListByCompanyId(List<String> companyIds);
+
     InsFeeOrderNew getInsFeeOrderEntity(String id);
 }

+ 8 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/InsFeeOrderNewServiceImpl.java

@@ -11,6 +11,8 @@ import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.modules.protocols.service.PtlAgreementProductCostsAttrLinkService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @description 费用结算表 service实现类
  * @createDate 2024-2-22 15:44:29
@@ -26,6 +28,12 @@ public class InsFeeOrderNewServiceImpl extends ServiceImpl<InsFeeOrderNewMapper,
                 .eq(InsFeeOrderNew::getInsOrderNo, companyId));
     }
 
+    @Override
+    public List<InsFeeOrderNew> getInsFeeOrderNewListByCompanyId(List<String> companyIds) {
+        return baseMapper.selectList(new LambdaQueryWrapper<InsFeeOrderNew>()
+                .in(InsFeeOrderNew::getInsOrderNo, companyIds));
+    }
+
     @Override
     public InsFeeOrderNew getInsFeeOrderEntity(String id) {
         return baseMapper.getInsFeeOrderEntity(id);

+ 126 - 79
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -12,6 +12,7 @@ import com.ydtech.modules.fee.dto.vo.EntranceFee;
 import com.ydtech.modules.fee.dto.vo.ExportFee;
 import com.ydtech.modules.fee.dto.vo.RetailStoreFee;
 import com.ydtech.modules.fee.service.CostsCalcService;
+import com.ydtech.modules.fee.service.FeeRuleSchemeService;
 import com.ydtech.modules.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.vo.FeeOrderNewRecordVo;
@@ -865,11 +866,15 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Autowired
     InsAreaCompanyService insAreaCompanyService;
 
+    @Autowired
+    FeeRuleSchemeService feeRuleSchemeService;
+
     @Transactional
     @Override
     public FeeOrderNewVo costsAdjust(FeeOrderNewRecordVo feeOrderNewRecordVo) {
         String feeId = feeOrderNewRecordVo.getFeeId();
         InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getById(feeId);
+
         //查询协议是否包含税
         PtlAgreement ptlAgreement = ptlAgreementService.getById(insFeeOrderNew.getAgreementId());
         BigDecimal taxRadio = new BigDecimal("1.00");
@@ -877,24 +882,48 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
             taxRadio = new BigDecimal("1.06");
         }
 
+        //分销费用
+        InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insFeeOrderNew.getInsOrderNo());
+        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+        SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
+        RetailStoreFee retailStoreFee = costsCalcService.getRetailStoreFee(sysUser.getId(),
+                insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium()));
+
         InsFeeOrderNewRecord record = new InsFeeOrderNewRecord();
         FeeOrderNewVo feeOrderNewVoOld = feeOrderNewRecordVo.getFeeOrderNewVoOld();
         FeeOrderNewVo feeOrderNewVo = feeOrderNewRecordVo.getFeeOrderNewVoNew();
 
+        if(feeOrderNewVo.getEntranceFee().get(0).getSuperviseCosts().add(feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion()).compareTo(feeOrderNewVo.getEntranceFee().get(0).getTotalProportion()) != 0)
+        {
+            throw new SystemException("交强入口费用不匹配,调整费用失败!");
+        }
+        if(feeOrderNewVo.getEntranceFee().get(1).getSuperviseCosts().add(feeOrderNewVo.getEntranceFee().get(1).getOtherCostsProportion()).compareTo(feeOrderNewVo.getEntranceFee().get(1).getTotalProportion()) != 0)
+        {
+            throw new SystemException("商业入口费用不匹配,调整费用失败!");
+        }
+        if(feeOrderNewVo.getEntranceFee().get(2).getSuperviseCosts().add(feeOrderNewVo.getEntranceFee().get(2).getOtherCostsProportion()).compareTo(feeOrderNewVo.getEntranceFee().get(2).getTotalProportion()) != 0)
+        {
+            throw new SystemException("非车入口费用不匹配,调整费用失败!");
+        }
+        //调整后的费用计算
+
         //交强入口费用
-        EntranceFee jqEntranceFee = costsCalcService.getEntranceFee("交强险", feeOrderNewVo.getEntranceFee().get(0).getPremium().divide(taxRadio,10, RoundingMode.UP),
-                feeOrderNewVo.getEntranceFee().get(0).getSuperviseCosts(), feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion());
+        FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
+                feeOrderNewVo.getEntranceFee().get(0).getSuperviseCosts(),
+                feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion(), taxRadio);
 
         //商业入口费用
-        EntranceFee syEntranceFee = costsCalcService.getEntranceFee("商业险", feeOrderNewVo.getEntranceFee().get(1).getPremium().divide(taxRadio,10, RoundingMode.UP),
-                feeOrderNewVo.getEntranceFee().get(1).getSuperviseCosts(), feeOrderNewVo.getEntranceFee().get(1).getOtherCostsProportion());
+        FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
+                feeOrderNewVo.getEntranceFee().get(1).getSuperviseCosts(),
+                feeOrderNewVo.getEntranceFee().get(1).getOtherCostsProportion(), taxRadio);
 
         //非车入口费用
-        EntranceFee noEntranceFee = costsCalcService.getEntranceFee("非车险", feeOrderNewVo.getEntranceFee().get(2).getPremium().divide(taxRadio,10, RoundingMode.UP),
-                feeOrderNewVo.getEntranceFee().get(2).getSuperviseCosts(), feeOrderNewVo.getEntranceFee().get(2).getOtherCostsProportion());
+        FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
+                feeOrderNewVo.getEntranceFee().get(2).getSuperviseCosts(),
+                feeOrderNewVo.getEntranceFee().get(2).getOtherCostsProportion(), taxRadio);
 
         //交强部门管理费用
-        DeptManagerFee jqDeptManagerFee = costsCalcService.getDeptManagerFee("交强险", insFeeOrderNew.getJqPremium().divide(taxRadio,10, RoundingMode.UP),
+        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
                 feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelOne(),
                 feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelTwo(),
                 feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelThree(),
@@ -902,32 +931,48 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFive());
 
         //商业部门管理费用
-        DeptManagerFee syDeptManagerFee = costsCalcService.getDeptManagerFee("商业险", insFeeOrderNew.getSyPremium().divide(taxRadio,10, RoundingMode.UP),
-                insFeeOrderNew.getSyDeptProportionLevel1(), insFeeOrderNew.getSyDeptProportionLevel2(), insFeeOrderNew.getSyDeptProportionLevel3(),
-                insFeeOrderNew.getSyDeptProportionLevel4(), insFeeOrderNew.getSyDeptProportionLevel5());
+        FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelOne(),
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelTwo(),
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelThree(),
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFoure(),
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFive());
 
         //非车部门管理费用
-        DeptManagerFee noDeptManagerFee = costsCalcService.getDeptManagerFee("非车险", insFeeOrderNew.getNoPremium().divide(taxRadio,10, RoundingMode.UP),
-                insFeeOrderNew.getNoDeptProportionLevel1(), insFeeOrderNew.getNoDeptProportionLevel2(), insFeeOrderNew.getNoDeptProportionLevel3(),
-                insFeeOrderNew.getNoDeptProportionLevel4(), insFeeOrderNew.getNoDeptProportionLevel5());
+        FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelOne(),
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelTwo(),
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelThree(),
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFoure(),
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFive());
 
 
-        //分销费用
-        InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insFeeOrderNew.getInsOrderNo());
-        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
-        SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
-        RetailStoreFee retailStoreFee = costsCalcService.getRetailStoreFee(sysUser.getId(),
-                insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium()));
 
-        //出口
-        ExportFee jqExportFee = costsCalcService.getExportFee("交强险",jqEntranceFee,jqDeptManagerFee,retailStoreFee,
-                feeOrderNewRecordVo.getFeeOrderNewVoNew().getExportFee().get(0).getSuperviseCosts());
+        BigDecimal jqDeptManagerTotalProportion = jqDeptManagerFee.getDeptProportionLevelOne().add(jqDeptManagerFee.getDeptProportionLevelTwo())
+                .add(jqDeptManagerFee.getDeptProportionLevelThree()).add(jqDeptManagerFee.getDeptProportionLevelFoure())
+                .add(jqDeptManagerFee.getDeptProportionLevelFive());
+
+        //交强出口费用
+        FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(),insFeeOrderNew.getJqCostsExportProportion(),
+                jqEntranceFee.getTotalProportion(),jqDeptManagerTotalProportion,retailStoreFee.getRetailStoreRadio(),taxRadio);
+
+        BigDecimal syDeptManagerTotalProportion = syDeptManagerFee.getDeptProportionLevelOne().add(syDeptManagerFee.getDeptProportionLevelTwo())
+                .add(syDeptManagerFee.getDeptProportionLevelThree()).add(syDeptManagerFee.getDeptProportionLevelFoure())
+                .add(syDeptManagerFee.getDeptProportionLevelFive());
+
+        //商业出口费用
+        FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(),insFeeOrderNew.getSyCostsExportProportion(),
+                syEntranceFee.getTotalProportion(),syDeptManagerTotalProportion,retailStoreFee.getRetailStoreRadio(),taxRadio);
 
-        ExportFee syExportFee = costsCalcService.getExportFee("商业险",syEntranceFee,syDeptManagerFee,retailStoreFee,
-                feeOrderNewRecordVo.getFeeOrderNewVoNew().getExportFee().get(1).getSuperviseCosts());
 
-        ExportFee noExportFee = costsCalcService.getExportFee("非车险",noEntranceFee,noDeptManagerFee,retailStoreFee,
-                feeOrderNewRecordVo.getFeeOrderNewVoNew().getExportFee().get(0).getSuperviseCosts());
+        BigDecimal noDeptManagerTotalProportion = noDeptManagerFee.getDeptProportionLevelOne().add(noDeptManagerFee.getDeptProportionLevelTwo())
+                .add(noDeptManagerFee.getDeptProportionLevelThree()).add(noDeptManagerFee.getDeptProportionLevelFoure())
+                .add(noDeptManagerFee.getDeptProportionLevelFive());
+
+        //商业出口费用
+        FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(),insFeeOrderNew.getNoCostsExportProportion(),
+                noEntranceFee.getTotalProportion(),noDeptManagerTotalProportion,retailStoreFee.getRetailStoreRadio(),taxRadio);
+
 
         //转换输出的格式
         FeeOrderNewVo resultFeeOrderNewVo = new FeeOrderNewVo();
@@ -1068,6 +1113,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNewRecordService.save(record);
 
 
+        //ins_fee_order_new 保存新的费用
         insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
         insFeeOrderNew.setJqCostsPremiums(jqEntranceFee.getTotalAmount());
         feeOrderNewVo.getEntranceFee().get(0).setPremium(insFeeOrderNew.getJqPremium());
@@ -1082,14 +1128,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         feeOrderNewVo.getEntranceFee().get(1).setTotalAmount(noEntranceFee.getTotalAmount());
 
         insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
-        insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSySuperviseCostsPremiums());
-        feeOrderNewVo.getEntranceFee().get(0).setSySuperviseCostsPremiums(jqEntranceFee.getSySuperviseCostsPremiums());
+        insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
+        feeOrderNewVo.getEntranceFee().get(0).setSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
         insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
-        insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSySuperviseCostsPremiums());
-        feeOrderNewVo.getEntranceFee().get(1).setSySuperviseCostsPremiums(syEntranceFee.getSySuperviseCostsPremiums());
+        insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
+        feeOrderNewVo.getEntranceFee().get(1).setSuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
         insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
-        insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSySuperviseCostsPremiums());
-        feeOrderNewVo.getEntranceFee().get(2).setSySuperviseCostsPremiums(noEntranceFee.getSySuperviseCostsPremiums());
+        insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
+        feeOrderNewVo.getEntranceFee().get(2).setSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
 
         insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
         insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
@@ -1101,53 +1147,53 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
         feeOrderNewVo.getEntranceFee().get(2).setOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
 
-        insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptManagerRadioLevel1());
-        insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptManagerRadioLevel2());
-        insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptManagerRadioLevel3());
-        insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptManagerRadioLevel4());
-        insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptManagerRadioLevel5());
-        insFeeOrderNew.setJqDeptPremiumsLevel1(jqDeptManagerFee.getDeptManagerFeeLevel1());
-        insFeeOrderNew.setJqDeptPremiumsLevel2(jqDeptManagerFee.getDeptManagerFeeLevel2());
-        insFeeOrderNew.setJqDeptPremiumsLevel3(jqDeptManagerFee.getDeptManagerFeeLevel3());
-        insFeeOrderNew.setJqDeptPremiumsLevel4(jqDeptManagerFee.getDeptManagerFeeLevel4());
-        insFeeOrderNew.setJqDeptPremiumsLevel5(jqDeptManagerFee.getDeptManagerFeeLevel5());
-        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelOne(jqDeptManagerFee.getDeptManagerFeeLevel1());
-        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelTwo(jqDeptManagerFee.getDeptManagerFeeLevel2());
-        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelThree(jqDeptManagerFee.getDeptManagerFeeLevel3());
-        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelFoure(jqDeptManagerFee.getDeptManagerFeeLevel4());
-        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelFive(jqDeptManagerFee.getDeptManagerFeeLevel5());
-
-        insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptManagerRadioLevel1());
-        insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptManagerRadioLevel2());
-        insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptManagerRadioLevel3());
-        insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptManagerRadioLevel4());
-        insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptManagerRadioLevel5());
-        insFeeOrderNew.setSyDeptPremiumsLevel1(syDeptManagerFee.getDeptManagerFeeLevel1());
-        insFeeOrderNew.setSyDeptPremiumsLevel2(syDeptManagerFee.getDeptManagerFeeLevel2());
-        insFeeOrderNew.setSyDeptPremiumsLevel3(syDeptManagerFee.getDeptManagerFeeLevel3());
-        insFeeOrderNew.setSyDeptPremiumsLevel4(syDeptManagerFee.getDeptManagerFeeLevel4());
-        insFeeOrderNew.setSyDeptPremiumsLevel5(syDeptManagerFee.getDeptManagerFeeLevel5());
-        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelOne(syDeptManagerFee.getDeptManagerFeeLevel1());
-        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelTwo(syDeptManagerFee.getDeptManagerFeeLevel2());
-        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelThree(syDeptManagerFee.getDeptManagerFeeLevel3());
-        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelFoure(syDeptManagerFee.getDeptManagerFeeLevel4());
-        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelFive(syDeptManagerFee.getDeptManagerFeeLevel5());
-
-        insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptManagerRadioLevel1());
-        insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptManagerRadioLevel2());
-        insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptManagerRadioLevel3());
-        insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptManagerRadioLevel4());
-        insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptManagerRadioLevel5());
-        insFeeOrderNew.setNoDeptPremiumsLevel1(noDeptManagerFee.getDeptManagerFeeLevel1());
-        insFeeOrderNew.setNoDeptPremiumsLevel2(noDeptManagerFee.getDeptManagerFeeLevel2());
-        insFeeOrderNew.setNoDeptPremiumsLevel3(noDeptManagerFee.getDeptManagerFeeLevel3());
-        insFeeOrderNew.setNoDeptPremiumsLevel4(noDeptManagerFee.getDeptManagerFeeLevel4());
-        insFeeOrderNew.setNoDeptPremiumsLevel5(noDeptManagerFee.getDeptManagerFeeLevel5());
-        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelOne(noDeptManagerFee.getDeptManagerFeeLevel1());
-        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelTwo(noDeptManagerFee.getDeptManagerFeeLevel2());
-        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelThree(noDeptManagerFee.getDeptManagerFeeLevel3());
-        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelFoure(noDeptManagerFee.getDeptManagerFeeLevel4());
-        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelFive(noDeptManagerFee.getDeptManagerFeeLevel5());
+        insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setJqDeptPremiumsLevel1(jqDeptManagerFee.getDeptPremiumsLevelOne());
+        insFeeOrderNew.setJqDeptPremiumsLevel2(jqDeptManagerFee.getDeptPremiumsLevelTwo());
+        insFeeOrderNew.setJqDeptPremiumsLevel3(jqDeptManagerFee.getDeptPremiumsLevelThree());
+        insFeeOrderNew.setJqDeptPremiumsLevel4(jqDeptManagerFee.getDeptPremiumsLevelFoure());
+        insFeeOrderNew.setJqDeptPremiumsLevel5(jqDeptManagerFee.getDeptPremiumsLevelFive());
+        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelOne(jqDeptManagerFee.getDeptPremiumsLevelOne());
+        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelTwo(jqDeptManagerFee.getDeptPremiumsLevelTwo());
+        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelThree(jqDeptManagerFee.getDeptPremiumsLevelThree());
+        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelFoure(jqDeptManagerFee.getDeptPremiumsLevelFoure());
+        feeOrderNewVo.getDeptManagerFee().get(0).setDeptPremiumsLevelFive(jqDeptManagerFee.getDeptPremiumsLevelFive());
+
+        insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setSyDeptPremiumsLevel1(syDeptManagerFee.getDeptPremiumsLevelOne());
+        insFeeOrderNew.setSyDeptPremiumsLevel2(syDeptManagerFee.getDeptPremiumsLevelTwo());
+        insFeeOrderNew.setSyDeptPremiumsLevel3(syDeptManagerFee.getDeptPremiumsLevelThree());
+        insFeeOrderNew.setSyDeptPremiumsLevel4(syDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setSyDeptPremiumsLevel5(syDeptManagerFee.getDeptPremiumsLevelFive());
+        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelOne(syDeptManagerFee.getDeptPremiumsLevelOne());
+        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelTwo(syDeptManagerFee.getDeptPremiumsLevelTwo());
+        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelThree(syDeptManagerFee.getDeptPremiumsLevelThree());
+        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelFoure(syDeptManagerFee.getDeptPremiumsLevelFoure());
+        feeOrderNewVo.getDeptManagerFee().get(1).setDeptPremiumsLevelFive(syDeptManagerFee.getDeptPremiumsLevelFive());
+
+        insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setNoDeptPremiumsLevel1(noDeptManagerFee.getDeptPremiumsLevelOne());
+        insFeeOrderNew.setNoDeptPremiumsLevel2(noDeptManagerFee.getDeptPremiumsLevelTwo());
+        insFeeOrderNew.setNoDeptPremiumsLevel3(noDeptManagerFee.getDeptPremiumsLevelThree());
+        insFeeOrderNew.setNoDeptPremiumsLevel4(noDeptManagerFee.getDeptPremiumsLevelFoure());
+        insFeeOrderNew.setNoDeptPremiumsLevel5(noDeptManagerFee.getDeptPremiumsLevelFive());
+        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelOne(noDeptManagerFee.getDeptPremiumsLevelOne());
+        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelTwo(noDeptManagerFee.getDeptPremiumsLevelTwo());
+        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelThree(noDeptManagerFee.getDeptPremiumsLevelThree());
+        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelFoure(noDeptManagerFee.getDeptPremiumsLevelFoure());
+        feeOrderNewVo.getDeptManagerFee().get(2).setDeptPremiumsLevelFive(noDeptManagerFee.getDeptPremiumsLevelFive());
 
 
         //保存新的比例
@@ -1156,6 +1202,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
     }
 
+
     public Page<PtlAgreementProductCostsNew> getCostsAuditList(Page page, AgreementProductQueryVo agreementProductQueryVo){
         LambdaQueryWrapper<PtlAgreementProductCostsNew> ptlAgreementProductCostsNewLambdaQueryWrapper = new LambdaQueryWrapper<>();
 //        ptlAgreementProductCostsNewLambdaQueryWrapper.eq(PtlAgreementProductCostsNew::getAgreementId, agreementProductQueryVo.getAgreementId());

+ 33 - 0
src/main/resources/mapper/modules/admin/SysDeptMapper.xml

@@ -47,4 +47,37 @@
         WHERE parent_id = #{deptId}
     </select>
 
+
+    <select id="queryListByParentId" resultType="com.ydtech.modules.admin.model.SysDept">
+        SELECT
+            dept.*
+        FROM
+            sys_dept dept
+        WHERE
+            dept.del_flag = 0
+        <if test='level == "1"'>
+            AND dept.province IN ( SELECT area_code FROM sys_area WHERE LEVEL = 1 )
+            AND LENGTH(
+            IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
+            IFNULL( dept.area, '' ))=6
+            AND dept.parent_id = #{parentId}
+        </if>
+        <if test='level == "2"'>
+            AND dept.city IN ( SELECT area_code FROM sys_area WHERE LEVEL = 2 )
+            AND LENGTH(
+            IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
+            IFNULL( dept.area, '' ))= 12
+            AND dept.parent_id = #{parentId}
+        </if>
+        <if test='level == "3"'>
+            AND dept.area IN ( SELECT area_code FROM sys_area WHERE LEVEL = 3)
+            AND LENGTH(
+            IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
+            IFNULL( dept.area, '' ))= 18
+            AND dept.parent_id = #{parentId}
+        </if>
+        <if test='level == "4"'>
+            AND dept.parent_id = #{parentId}
+        </if>
+    </select>
 </mapper>

+ 23 - 18
src/main/resources/mapper/modules/admin/SysUserLinkAreaMapper.xml

@@ -5,8 +5,8 @@
 <mapper namespace="com.ydtech.modules.admin.dao.SysUserLinkAreaMapper">
     <sql id="Base_Column_List">
             link.id as id,
-            user.id as "sysUser.id",
-            user.name as "sysUser.name",
+            u.id as "sysUser.id",
+            u.name as "sysUser.name",
             t2.id AS "sysUser.deptId",
             t2.`name` AS "sysUser.deptName",
             area.id as  "area.id",
@@ -20,8 +20,8 @@
           <include refid="Base_Column_List"/>
         FROM
         sys_user_link_area link
-        LEFT JOIN sys_user USER ON link.user_id = USER.id
-        LEFT JOIN sys_dept t2 ON USER.dept_id = t2.id
+        LEFT JOIN sys_user u ON link.user_id = u.id
+        LEFT JOIN sys_dept t2 ON u.dept_id = t2.id
         LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
         LEFT JOIN sys_area area ON link.area_code = area.area_code
         LEFT JOIN sys_area pArea ON pArea.area_code = area.upper_code
@@ -31,7 +31,7 @@
                 and  link.user_id =  #{vo.userId}
             </if>
             <if test="vo.userName != null and vo.userName != ''">
-                and  USER.name  like CONCAT('%', #{vo.userName}, '%')
+                and  u.name  like CONCAT('%', #{vo.userName}, '%')
             </if>
             <if test="vo.areaCode != null and vo.areaCode != ''">
                 and   EXISTS (
@@ -80,19 +80,24 @@
                 AND sd.del_flag = '0'
         WHERE
             t3.role_id = 20
-          AND sd.management_source = 2
-          AND
-            (CONCAT( SUBSTRING(RPAD(su.dept_id, 8, '0'), 3, 2), SUBSTRING(RPAD(su.dept_id, 8, '0'), 5, 2), SUBSTRING(RPAD(su.dept_id, 8, '0'), 7, 2) ) ) IN
+           AND sd.management_source = 2
+            <if test="areaCodes != null and areaCodes.size>0" >
+                AND (
+                <foreach collection="areaCodes" item="item" open=" instr( " separator="||" close=") ">
+                   su.dept_id, TRIM( TRAILING '0' FROM #{item} )
+                </foreach>
+                ) > 0
+            </if>
+    </select>
 
-            (
-                SELECT
-                    DISTINCT link.area_code
-                FROM
-                    sys_user_link_area link
-                WHERE
-                    link.user_id = #{userId}
-                ORDER BY
-                    link.area_code
-            )
+    <select id="findAreaCodeByUserId"  resultType="String">
+        SELECT
+            DISTINCT link.area_code
+        FROM
+            sys_user_link_area link
+        WHERE
+            link.user_id = #{userId}
+        ORDER BY
+            link.area_code
     </select>
 </mapper>

+ 7 - 7
src/main/resources/mapper/modules/admin/SysUserLinkPtlAgreementMapper.xml

@@ -5,8 +5,8 @@
 <mapper namespace="com.ydtech.modules.admin.dao.SysUserLinkPtlAgreementMapper">
     <sql id="Base_Column_List">
         link.id as id,
-            user.id as "sysUser.id",
-            user.name as "sysUser.name",
+            u.id as "sysUser.id",
+            u.name as "sysUser.name",
             t2.id AS "sysUser.deptId",
             t2.`name` AS "sysUser.deptName",
             agree.id as  "ptlAgreement.id",
@@ -41,8 +41,8 @@
           <include refid="Base_Column_List"/>
         FROM
         sys_user_link_pl_agreement link
-        LEFT JOIN sys_user USER ON link.user_id = USER.id
-        LEFT JOIN sys_dept t2 ON USER.dept_id = t2.id
+        LEFT JOIN sys_user u ON link.user_id = u.id
+        LEFT JOIN sys_dept t2 ON u.dept_id = t2.id
         LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
         LEFT JOIN ptl_agreement agree ON link.ptl_agreement_id = agree.id
         left join esm_ins_company com on com.id = agree.partner_companies_id
@@ -51,7 +51,7 @@
                 and  link.user_id =  #{vo.userId}
             </if>
             <if test="vo.userName != null and vo.userName != ''">
-                and  USER.name  like CONCAT('%', #{vo.userName}, '%')
+                and  u.name  like CONCAT('%', #{vo.userName}, '%')
             </if>
             <if test="ids != null and ids.size>0">
                 and  agree.partner_companies_id in
@@ -73,8 +73,8 @@
              <include refid="Base_Column_List"/>
         FROM
         sys_user_link_pl_agreement link
-        LEFT JOIN sys_user USER ON link.user_id = USER.id
-        LEFT JOIN sys_dept t2 ON USER.dept_id = t2.id
+        LEFT JOIN sys_user u ON link.user_id = u.id
+        LEFT JOIN sys_dept t2 ON u.dept_id = t2.id
         LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
         LEFT JOIN ptl_agreement agree ON link.ptl_agreement_id = agree.id
         left join esm_ins_company com on link.id = agree.partner_companies_id

+ 229 - 3
src/main/resources/mapper/modules/admin/SysUserMapper.xml

@@ -388,6 +388,9 @@
         COUNT(*) AS quoteNum,
         SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END + CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS submitNum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS hasInsuredNum,
+        SUM(CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS subWaitAuditSum,
+        SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END) AS subWaitPaySum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS subAcceptInsuranceSum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium ELSE 0 END) AS jqpremiumsum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium ELSE 0 END) AS sypremiumsum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.taxamount ELSE 0 END) AS taxamountsum,
@@ -396,7 +399,7 @@
         ins_orders io
         RIGHT JOIN ins_area_company iac ON iac.orderno = io.orderno
         WHERE
-        iac.orderstatus IN ( 1, 2, 3 )
+        iac.orderstatus IN ( 0 ,1, 2, 3, 4 )
         <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
             and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
         </if>
@@ -410,6 +413,29 @@
         SUBSTRING(io.userid, 3, #{quUserNumDto.grouping})
     </select>
 
+    <select id="getMainOrderDetails" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+            SUBSTRING(io.userid, 3, #{quUserNumDto.grouping}) AS areacode,
+            SUM(CASE WHEN io.orderstatus = 1 THEN 1 ELSE 0 END) AS mainWaitAuditSum,
+            SUM(CASE WHEN io.orderstatus = 2 THEN 1 ELSE 0 END) AS mainWaitPaySum,
+            SUM(CASE WHEN io.orderstatus = 3 THEN 1 ELSE 0 END) AS mainAcceptInsuranceSum
+        FROM
+            ins_orders io
+        WHERE
+            io.orderstatus IN (1,2,3)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+            SUBSTRING(io.userid, 3, #{quUserNumDto.grouping})
+    </select>
+
     <select id="getUserByCompany" resultType="com.ydtech.modules.admin.model.QuUserNum">
         SELECT
         iac.company_id as companyId,
@@ -417,6 +443,117 @@
         COUNT(*) AS quoteNum,
         SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END + CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS submitNum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS hasInsuredNum,
+        SUM(CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS subWaitAuditSum,
+        SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END) AS subWaitPaySum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS subAcceptInsuranceSum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium ELSE 0 END) AS jqpremiumsum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium ELSE 0 END) AS sypremiumsum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN iac.taxamount ELSE 0 END) AS taxamountsum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium ELSE 0 END + CASE WHEN iac.orderstatus = 3 THEN iac.sypremium ELSE 0 END) AS totalSumpremium
+        FROM
+        ins_orders io
+        LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN ( 0, 1, 2, 3, 4 )
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+    <select id="getComMainWaitAuditSum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        SUM(CASE WHEN io.orderstatus = 1 THEN 1 ELSE 0 END) AS mainWaitAuditSum
+        FROM
+        ins_orders io
+        LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (1)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+    <select id="getComMainWaitPaySum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        SUM(CASE WHEN io.orderstatus = 2 THEN 1 ELSE 0 END) AS mainWaitPaySum
+        FROM
+        ins_orders io
+        LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (2)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+
+    <select id="getComMainAcceptInsuranceSum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        SUM(CASE WHEN io.orderstatus = 3 THEN 1 ELSE 0 END) AS mainAcceptInsuranceSum
+        FROM
+        ins_orders io
+        LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (3)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+    <select id="getUserDetail" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        io.userid,
+        io.username,
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        COUNT(*) AS quoteNum,
+        SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END + CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS submitNum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS hasInsuredNum,
+        SUM(CASE WHEN iac.orderstatus = 1 THEN 1 ELSE 0 END) AS subWaitAuditSum,
+        SUM(CASE WHEN iac.orderstatus = 2 THEN 1 ELSE 0 END) AS subWaitPaySum,
+        SUM(CASE WHEN iac.orderstatus = 3 THEN 1 ELSE 0 END) AS subAcceptInsuranceSum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium ELSE 0 END) AS jqpremiumsum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium ELSE 0 END) AS sypremiumsum,
         SUM(CASE WHEN iac.orderstatus = 3 THEN iac.taxamount ELSE 0 END) AS taxamountsum,
@@ -425,7 +562,7 @@
         ins_orders io
         RIGHT JOIN ins_area_company iac ON iac.orderno = io.orderno
         WHERE
-        iac.orderstatus IN ( 1, 2, 3 )
+        iac.orderstatus IN ( 0 ,1, 2, 3, 4 )
         <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
             and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
         </if>
@@ -436,10 +573,99 @@
             </foreach>
         </if>
         GROUP BY
+        io.userid,
+        io.username,
         iac.company_id,
         iac.inscompany
     </select>
 
+    <select id="getUserMainWaitAuditSum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        io.userid,
+        io.username,
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        COUNT(*) AS quoteNum,
+        SUM(CASE WHEN io.orderstatus = 1 THEN 1 ELSE 0 END) AS mainWaitAuditSum
+        FROM
+        ins_orders io
+        RIGHT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (1)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        io.userid,
+        io.username,
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+    <select id="getUserMainWaitPaySum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        io.userid,
+        io.username,
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        COUNT(*) AS quoteNum,
+        SUM(CASE WHEN io.orderstatus = 2 THEN 1 ELSE 0 END) AS mainWaitPaySum
+        FROM
+        ins_orders io
+        RIGHT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (2)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        io.userid,
+        io.username,
+        iac.company_id,
+        iac.inscompany
+    </select>
+
+
+    <select id="getUserMainAcceptInsuranceSum" resultType="com.ydtech.modules.admin.model.QuUserNum">
+        SELECT
+        io.userid,
+        io.username,
+        iac.company_id as companyId,
+        iac.inscompany as insCompany,
+        COUNT(*) AS quoteNum,
+        SUM(CASE WHEN io.orderstatus = 3 THEN 1 ELSE 0 END) AS mainAcceptInsuranceSum
+        FROM
+        ins_orders io
+        RIGHT JOIN ins_area_company iac ON iac.orderno = io.orderno
+        WHERE
+        iac.orderstatus IN (3)
+        <if test="quUserNumDto.createTimeStart != null and quUserNumDto.createTimeEnd != null">
+            and io.createtime BETWEEN #{quUserNumDto.createTimeStart} AND #{quUserNumDto.createTimeEnd}
+        </if>
+        <if test="quUserNumDto.userIds != null">
+            and io.userid IN
+            <foreach collection="quUserNumDto.userIds" item="id" index="index" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY
+        io.userid,
+        io.username,
+        iac.company_id,
+        iac.inscompany
+    </select>
 
     <select id="getAllUsersByHospitality" resultType="com.ydtech.modules.admin.model.vo.SysUserBaseVO">
         SELECT
@@ -658,7 +884,7 @@
 
     <select id="getAgentUserIdsByAreaIds" resultType="com.ydtech.modules.admin.model.vo.SysUserBaseVO">
         SELECT
-            su.id,
+            su.id AS userId,
             su.dept_id AS deptId
         FROM
             sys_user su

+ 579 - 36
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -34,10 +34,41 @@
         <result column="sy_policyno" property="syPolicyno"/>
         <result column="is_not_car" property="isNotCar"/>
         <result column="is_not_documentary" property="isNotDocumentary"/>
+        <result column="invoic_amount" property="invoicAmount"/>
+        <result column="invoic_id" property="invoicId"/>
+        <result column="tax_premium" property="taxPremium"/>
+        <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
+        <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
+        <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
+        <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
+        <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
+        <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
+        <result column="jq_premium" property="jqPremium"/>
+        <result column="sy_premium" property="syPremium"/>
+        <result column="no_premium" property="noPremium"/>
+        <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
+        <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
+        <result column="no_no_tax_premium" property="noNoTaxPremium"/>
+        <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
+        <result column="sy_receivable_proportion" property="syReceivableProportion"/>
+        <result column="no_receivable_proportion" property="noReceivableProportion"/>
+        <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
+        <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
+        <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
+        <result column="settlement_time" property="settlementTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="settlement_user_id" property="settlementUserId"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
+        <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
+        <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
+        <result column="user_id" property="userId"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="partner_companies_id" property="partnerCompaniesId"/>
+        <result column="partner_companies_name" property="partnerCompaniesName"/>
+        <result column="receivable_amount" property="receivableAmount"/>
     </resultMap>
-
-    <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
-            select
+    <sql id="income_com">
                 a.id      as  "id",
                 a.orderno  as  "orderno",
                 a.policyno  as  "policyno",
@@ -66,7 +97,43 @@
                 a.documentary_fees_status  as  "documentaryFeesStatus",
                 a.is_not_car  as  "isNotCar",
                 a.is_not_documentary  as  "isNotDocumentary",
+                a.invoic_amount  as  "invoicAmount",
+                a.invoic_id  as  "invoicId",
+                a.tax_premium  as  "taxPremium",
+                a.jq_supervise_costs_premiums  as  "jqSuperviseCostsPremiums",
+                a.jq_supervise_costs_proportion  as  "jqSuperviseCostsProportion",
+                a.sy_supervise_costs_premiums  as  "sySuperviseCostsPremiums",
+                a.sy_supervise_costs_proportion  as  "sySuperviseCostsProportion",
+                a.no_supervise_costs_premiums  as  "noSuperviseCostsPremiums",
+                a.no_supervise_costs_proportion  as  "noSuperviseCostsProportion",
+                a.jq_premium  as  "jqPremium",
+                a.sy_premium  as  "syPremium",
+                a.no_premium  as  "noPremium",
+                a.jq_no_tax_premium  as  "jqNoTaxPremium",
+                a.sy_no_tax_premium  as  "syNoTaxPremium",
+                a.no_no_tax_premium  as  "noNoTaxPremium",
+                a.jq_receivable_proportion  as  "jqReceivableProportion",
+                a.sy_receivable_proportion  as  "syReceivableProportion",
+                a.no_receivable_proportion  as  "noReceivableProportion",
+                a.jq_other_costs_proportion  as  "jqOtherCostsProportion",
+                a.sy_other_costs_proportion  as  "syOtherCostsProportion",
+                a.no_other_costs_proportion  as  "noOtherCostsProportion",
+                a.settlement_time  as  "settlementTime",
+                a.update_time  as  "updateTime",
+                a.settlement_user_id  as  "settlementUserId",
+                a.update_user_id  as  "updateUserId",
+                a.jq_other_costs_premium  as  "jqOtherCostsPremium",
+                a.sy_other_costs_premium  as  "syOtherCostsPremium",
+                a.no_other_costs_premium  as  "noOtherCostsPremium",
+                a.receivable_amount  as  "receivableAmount",
+                a.invoic_time  as  "invoicTime",
+                a.user_id  as  "userId",
                 a.create_time  as  "createTime"
+    </sql>
+
+    <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+            select
+                <include refid="income_com"/>
                 from  ins_ply_income a
                 LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
             <where>
@@ -77,7 +144,7 @@
                     and pa.agreement_type =#{agreementType}
                 </if>
 
-               <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
                     and a.handling_fees_status =#{handlingFeesStatus}
                 </if>
 
@@ -99,7 +166,65 @@
                 <if test="isOther !=null  and  isOther  !=''">
                     and a.is_not_documentary   =#{isOther}
                 </if>
+                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                    and a.licenseno in
+                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
 
+                <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                    and a.policyno in
+                    <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                    and a.sy_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                    and a.no_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="signdate !=null  and  signdate  !=''">
+                    a.signdate =#{signdate}
+                </if>
+                <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                    a.partner_companies_id =#{partnerCompaniesId}
+                </if>
+
+                <if test="createTime !=null  and  createTime  !=''">
+                    a.create_time =#{createTime}
+                </if>
+                <if test="settlementTime !=null  and  settlementTime  !=''">
+                    a.settlement_time =#{settlementTime}
+                </if>
+
+                <if test="userId !=null  and  userId  !=''">
+                    and a.userId   =#{userId}
+                </if>
+                <if test="companyId !=null  and  companyId  !=''">
+                    and a.company_id   =#{companyId}
+                </if>
+                <if test="riskcode !=null  and  riskcode  !=''">
+                    and a.riskcode   =#{riskcode}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
             </where>
     </select>
 
@@ -148,10 +273,10 @@
                 contract_file_id = #{contractFileId},
             </if>
             <if test="handlingFeesStatus != null">
-                handling_fees_status = #{handlingFeesStatus},
+                handling_fees_status = #{handlingFeesStatus}
             </if>
             <if test="documentaryFeesStatus != null">
-                documentary_fees_status = #{documentaryFeesStatus},
+                documentary_fees_status = #{documentaryFeesStatus}
             </if>
         </set>
         where  orderno  =#{orderno}
@@ -180,7 +305,7 @@
                 and a.is_not_car =#{isNotCar}
         </if>
         <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
-            AND  a.documentary_fees_status = #{documentaryFeesStatus},
+            AND  a.documentary_fees_status = #{documentaryFeesStatus}
         </if>
 
         <if test="isOther !=null  and  isOther  !=''">
@@ -192,6 +317,9 @@
         <if test="year !=null  and  year  !=''">
             and YEAR(a.signdate) =#{year}
         </if>
+        <if test="month !=null  and  month !=''">
+            and month(a.signdate) =#{month}
+        </if>
         GROUP BY
         a.company_id
         ) a
@@ -200,40 +328,455 @@
 
     <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
        select
-            a.id      as  "id",
-            a.orderno  as  "orderno",
-            a.policyno  as  "policyno",
-            a.dept_id  as  "deptId",
-            a.riskcode  as  "riskcode",
-            a.pay_date  as  "payDate",
-            a.signdate  as  "signdate",
-            a.company_id  as  "companyId",
-            a.agreement_id  as  "agreementId",
-            a.licenseno  as  "licenseno",
-            a.taxamount  as  "taxamount",
-            a.no_tax_premium  as  "noTaxPremium",
-            a.commission_feerate  as  "commissionFeerate",
-            a.other_feerate  as  "otherFeerate",
-            a.commission_feevalue  as  "commissionFeevalue",
-            a.other_feevalue  as  "otherFeevalue",
-            a.all_fee_value  as  "allFeeValue",
-            a.final_fee_value  as  "finalFeeValue",
-            a.doing_fee_value  as  "doingFeeValue",
-            a.voucher_number  as  "voucherNumber",
-            a.contract_id  as  "contractId",
-            a.contract_file_id  as  "contractFileId",
-            a.handling_fees_status  as  "handlingFeesStatus",
-            a.no_policyno  as  "noPolicyno",
-            a.sy_policyno  as  "syPolicyno",
-            a.documentary_fees_status  as  "documentaryFeesStatus",
-            a.is_not_car  as  "isNotCar",
-            a.is_not_documentary  as  "isNotDocumentary",
-            a.create_time  as  "createTime"
+        <include refid="income_com"/>
         from  ins_ply_income a
         <where>
             <if test="licenseno !=null  and  licenseno !=''">
                 a.licenseno=#{licenseno}
             </if>
+            <if test="policyno !=null  and  policyno !=''">
+                a.policyno=#{policyno}
+            </if>
+            <if test="syPolicyno !=null  and  syPolicyno !=''">
+                a.sy_policyno=#{syPolicyno}
+            </if>
+            <if test="noPolicyno !=null  and  noPolicyno !=''">
+                a.no_policyno=#{noPolicyno}
+            </if>
         </where>
     </select>
+
+    <select id="totalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+            select
+                sum(a.commission_feevalue) as "commissionFeevalue",
+                sum(a.other_feevalue)  as "otherFeevalue",
+                SUM(a.commission_feevalue + a.other_feevalue) as "totalFeevalue"
+            from  ins_ply_income a
+            LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+            <where>
+                1=1
+                <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
+                    and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+                </if>
+                <if test="agreementType !=null  and  agreementType  !=''">
+                    and pa.agreement_type =#{agreementType}
+                </if>
+
+                <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                    and a.handling_fees_status =#{handlingFeesStatus}
+                </if>
+
+                <if test="orderno !=null  and  orderno  !=''">
+                    and a.orderno =#{orderno}
+                </if>
+
+                <if test="policyno !=null  and  policyno  !=''">
+                    and a.policyno =#{policyno}
+                </if>
+                <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                    and a.documentary_fees_status =#{documentaryFeesStatus}
+                </if>
+
+                <if test="isNotCar !=null  and  isNotCar  !=''">
+                    and a.is_not_car =#{isNotCar}
+                </if>
+
+                <if test="isOther !=null  and  isOther  !=''">
+                    and a.is_not_documentary   =#{isOther}
+                </if>
+                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                    and a.licenseno in
+                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                    and a.policyno in
+                    <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                    and a.sy_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                    and a.no_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="signdate !=null  and  signdate  !=''">
+                    a.signdate =#{signdate}
+                </if>
+                <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                    a.partner_companies_id =#{partnerCompaniesId}
+                </if>
+
+                <if test="createTime !=null  and  createTime  !=''">
+                    a.create_time =#{createTime}
+                </if>
+                <if test="settlementTime !=null  and  settlementTime  !=''">
+                    a.settlement_time =#{settlementTime}
+                </if>
+
+                <if test="userId !=null  and  userId  !=''">
+                    and a.userId   =#{userId}
+                </if>
+                <if test="companyId !=null  and  companyId  !=''">
+                    and a.company_id   =#{companyId}
+                </if>
+                <if test="riskcode !=null  and  riskcode  !=''">
+                    and a.riskcode   =#{riskcode}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
+            </where>
+    </select>
+
+
+    <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+                select
+                MAX( a.company_name ) AS "companyName",
+                sum( a.commission_feevalue ) AS "commissionFeevalue",
+                sum( a.other_feevalue ) AS "otherFeevalue",
+                SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
+                GROUP_CONCAT(a.id) as  "ids",
+                MAX( a.partner_companies_name) as "partnerCompaniesName",
+                a.agreement_id AS "agreementId"
+                from  ins_ply_income a
+                LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+                <where>
+                    1=1
+                <if test="agreementType !=null  and agreementType!='' ">
+                    AND pa.agreement_type =#{agreementType}
+                </if>
+                <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                    AND   a.documentary_fees_status = #{documentaryFeesStatus}
+                </if>
+                <if test="handlingFeesStatus != null  and  handlingFeesStatus != ''">
+                    AND   handling_fees_status = #{handlingFeesStatus}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
+                </where>
+            GROUP BY  a.agreement_id
+    </select>
+
+    <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+            sum(a.commission_feevalue) as "commissionFeevalue",
+            sum(a.invoic_amount) as "invoicAmount"
+            from  ins_ply_income a
+            LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
+                and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+            </if>
+            <if test="agreementType !=null  and  agreementType  !=''">
+                and pa.agreement_type =#{agreementType}
+            </if>
+
+            <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                and a.handling_fees_status =#{handlingFeesStatus}
+            </if>
+
+            <if test="orderno !=null  and  orderno  !=''">
+                and a.orderno =#{orderno}
+            </if>
+
+            <if test="policyno !=null  and  policyno  !=''">
+                and a.policyno =#{policyno}
+            </if>
+            <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                and a.documentary_fees_status =#{documentaryFeesStatus}
+            </if>
+
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                and a.licenseno in
+                <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                and a.policyno in
+                <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                and a.sy_policyno in
+                <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                and a.no_policyno in
+                <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="signdate !=null  and  signdate  !=''">
+                a.signdate =#{signdate}
+            </if>
+            <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+
+            <if test="createTime !=null  and  createTime  !=''">
+                a.create_time =#{createTime}
+            </if>
+            <if test="settlementTime !=null  and  settlementTime  !=''">
+                a.settlement_time =#{settlementTime}
+            </if>
+
+            <if test="userId !=null  and  userId  !=''">
+                and a.userId   =#{userId}
+            </if>
+            <if test="companyId !=null  and  companyId  !=''">
+                and a.company_id   =#{companyId}
+            </if>
+            <if test="riskcode !=null  and  riskcode  !=''">
+                and a.riskcode   =#{riskcode}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+    </select>
+
+
+    <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+        MAX( a.company_name ) AS "companyName",
+        sum( a.commission_feevalue ) AS "commissionFeevalue",
+        MAX( a.partner_companies_name) as "partnerCompaniesName",
+        SUM(b.readyCommissionFeevalue)  as "readyCommissionFeevalue",
+        SUM(c.invoicCommissionFeevalue) as "invoicCommissionFeevalue",
+        SUM(d.noInvoicCommissionFeevalue) as "noInvoicCommissionFeevalue",
+        MAX(b.ids) as "ids",
+        a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        LEFT JOIN   (
+            select
+            MAX( a.company_name ) AS "companyName",
+            sum( a.commission_feevalue ) AS "readyCommissionFeevalue",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            GROUP_CONCAT(a.id) as  "ids",
+            a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            AND   a.handling_fees_status = '1'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  b  on  a.agreement_id =b.agreementId
+        LEFT JOIN   (
+            select
+            MAX( a.company_name ) AS "companyName",
+            sum( a.commission_feevalue ) AS "invoicCommissionFeevalue",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            GROUP_CONCAT(a.id) as  "ids",
+            a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            AND   a.handling_fees_status = '2'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  c  on  a.agreement_id =c.agreementId
+        LEFT JOIN   (
+        select
+        MAX( a.company_name ) AS "companyName",
+        sum( a.commission_feevalue ) AS "noInvoicCommissionFeevalue",
+        MAX( a.partner_companies_name) as "partnerCompaniesName",
+        GROUP_CONCAT(a.id) as  "ids",
+        a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+
+            AND   a.handling_fees_status = '0'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  d  on  a.agreement_id =d.agreementId
+        <where>
+            1=1
+
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+    </select>
+    <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        SELECT
+            a.company_id AS "companyId",
+            MAX( a.company_name ) AS "companyName",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            IF(SUM( c.unsettledAmount ) IS NULL , sum( a.other_feevalue ),  SUM( c.unsettledAmount )  ) AS "noInvoicCommissionFeevalue",
+            GROUP_CONCAT(a.id) as  "incomeIds",
+            MAX(d.settleMentAmount) as "invoicCommissionFeevalue",
+            MAX(e.settleMentAmount) as "settleMentAmount",
+            IF(MAX( f.unSettledAmount ) is null ,MAX( d.settleMentAmount ) ,MAX( f.unSettledAmount )) AS "unSettledAmount",
+            sum( a.other_feevalue ) AS "otherFeevalue"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( a.unsettled_amount ) AS "unsettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) c ON c.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) d ON d.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) e ON e.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( unsettled_amount ) AS "unSettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
+       <where>
+           1=1
+           <if test="agreementType !=null  and agreementType!='' ">
+               AND pa.agreement_type =#{agreementType}
+           </if>
+           <if test="year !=null  and  year  !=''">
+               AND YEAR(a.signdate) =#{year}
+           </if>
+           <if test="isOther !=null  and  isOther  !=''">
+               and a.is_not_documentary   =#{isOther}
+           </if>
+           <if test="isNotCar !=null  and  isNotCar  !=''">
+               and a.is_not_car =#{isNotCar}
+           </if>
+           <if test="month !=null  and  month !=''">
+               AND month(a.signdate) =#{month}
+           </if>
+           <if test="day !=null  and  day !=''">
+               AND day(a.signdate) =#{day}
+           </if>
+           <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+               AND   a.documentary_fees_status = #{documentaryFeesStatus}
+           </if>
+       </where>
+        GROUP BY
+            a.company_id
+    </select>
+
+
 </mapper>

+ 5 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml

@@ -14,6 +14,10 @@
         <result column="settlement_amount" property="settlementAmount"/>
         <result column="unsettled_amount" property="unsettledAmount"/>
         <result column="company_id" property="companyId"/>
+        <result column="year" property="year"/>
+        <result column="month" property="month"/>
+        <result column="day" property="day"/>
+        <result column="agree_ment_id" property="agreeMentId"/>
     </resultMap>
 
 
@@ -28,6 +32,7 @@
             a.start_time as "startTime",
             a.end_time as "endTime",
             a.settlement_amount as "settlementAmount",
+            a.agree_ment_id as "agreeMentId",
             a.unsettled_amount as "unsettledAmount"
             from  settlement_documentary_fees  a
     </select>

+ 3 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryLogMapper.xml

@@ -11,6 +11,9 @@
         <result column="create_time" property="createTime"/>
         <result column="handing_amount" property="handingAmount"/>
         <result column="crud_status" property="crudStatus"/>
+        <result column="crud_status" property="crudStatus"/>
+        <result column="ids" property="ids"/>
+        <result column="company_id" property="companyId"/>
     </resultMap>
 
 

+ 126 - 69
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -103,12 +103,12 @@
         SELECT iac.*, pa.agreement_name
         FROM ins_area_company as iac
                  left join ptl_agreement as pa on pa.id = iac.agreement_id
-        WHERE iac.orderstatus = 3 and orderno = #{orderNo};
+        WHERE iac.orderstatus = 3
+          and orderno = #{orderNo};
     </select>
 
 
-
-    <select id="queryLatestStatus"  resultType="java.lang.String">
+    <select id="queryLatestStatus" resultType="java.lang.String">
         SELECT iac.orderstatus
         FROM ins_area_company as iac
                  INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
@@ -120,54 +120,97 @@
         ORDER BY orderstatus DESC
         LIMIT 1
     </select>
-    <select id="getorDerIds"    resultType="com.ydtech.modules.order.entity.InsAreaCompany">
-        SELECT
-            a.id  as  "id" ,
-            a.orderno as  "orderno"
-        FROM
-            ins_area_company a
-                LEFT JOIN ins_fee_order_new b ON  a.id =b.ins_order_no
-        WHERE
-            a.orderstatus = '3' or a.orderstatus = '2'
-            and  b.id is not  null
+    <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
+        SELECT a.id      as "id",
+               a.orderno as "orderno"
+        FROM ins_area_company a
+                 LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
+        WHERE a.orderstatus = '3'
+           or a.orderstatus = '2'
+            and b.id is not null
     </select>
 
-    <select id="getPendingAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
+    <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
         SELECT
         io.*,
-        sd.management_source
-        FROM
-        ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
-        WHERE
-        orderno IN (
-        SELECT
-        orderno
+        sd.management_source,
+        su2.name AS auditUser,
+        ifa.audittime as auditTime,
+        ifa.auditstatus as auditStatus
         FROM
-        ins_area_company
+        ins_orders io
+        LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
+        LEFT JOIN sys_user su ON su.id = io.userid
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
+        LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
+        LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno and iac.orderstatus = 3
         WHERE
-        id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE ins_order_no NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
-        AND orderstatus = 3
-        )
-        AND
-        orderstatus= 3
-<!--        <if test="params.orderNo != null and params.orderNo != ''">-->
-<!--            AND orderno = #{params.orderNo}-->
-<!--        </if>-->
+        io.orderno IN ( SELECT orderno FROM ins_area_company WHERE id IN (
+        SELECT ins_order_no FROM ins_fee_order_new
+        WHERE ins_order_no
+        <if test="params.auditStatus != null and params.auditStatus == 0">
+            NOT
+        </if>
+        IN ( SELECT ins_order_no FROM ins_fee_audit) ) AND orderstatus = 3 )
+        AND io.orderstatus = 3
+        <if test="params.taskNo != null and params.taskNo != ''">
+            AND io.orderno = #{params.taskNo}
+        </if>
+        <if test="params.orderNo != null and params.orderNo != ''">
+            AND iac.id = #{params.orderNo}
+        </if>
         <if test="params.licenseNo != null and params.licenseNo != ''">
-            AND licenseno = #{params.licenseNo}
+            AND io.licenseno = #{params.licenseNo}
         </if>
         <if test="params.frameNo != null and params.frameNo != ''">
-            AND frameno = #{params.frameNo}
+            AND io.frameno = #{params.frameNo}
         </if>
         <if test="params.insuredName != null and params.insuredName != ''">
-            AND insuredname = #{params.insuredName}
+            AND io.insuredname = #{params.insuredName}
         </if>
         <if test="params.companyId != null and params.companyId != ''">
-            AND company_id = #{params.companyId}
+            AND io.company_id = #{params.companyId}
+        </if>
+        <if test="params.engineNo != null and params.engineNo != ''">
+            and JSON_EXTRACT( io.carinfo, '$.engineNo' )  = #{params.engineNo}
+        </if>
+        <if test="params.riskCode != null and params.riskCode != ''">
+            and io.product = #{params.riskCode}
+        </if>
+        <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != ''">
+            AND iac.createtime BETWEEN #{params.quoteStartDateStr} and #{params.quoteEndDateStr}
+        </if>
+        <if test="params.attachStartDateStr != null and params.attachStartDateStr != ''">
+            AND iac.signing_time BETWEEN #{params.attachStartDateStr} and #{params.attachEndDateStr}
         </if>
         <if test="params.startDateStr != null and params.startDateStr != ''">
             AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
         </if>
+        <if test="params.provinceId != null and params.provinceId != ''">
+            and io.deptid like "${params.provinceId}%"
+        </if>
+        <if test="params.cityId != null and params.cityId != ''">
+            and io.deptid like "${params.cityId}%"
+        </if>
+        <if test="params.countyId != null and params.countyId != ''">
+            and io.deptid like "${params.countyId}%"
+        </if>
+        <if test="params.houseId != null and params.houseId != ''">
+            and io.deptid like "${params.houseId}%"
+        </if>
+        <if test="params.operatorId != null and params.operatorId != ''">
+            and iac.operator_id = #{params.operatorId}
+        </if>
+        <if test="params.operatorName != null and params.operatorName != ''">
+            and iac.operator_name = #{params.operatorName}
+        </if>
+        <if test="params.auditId != null and params.auditId != ''">
+            and iac.new_operator_id = #{params.auditId}
+        </if>
+        <if test="params.agreeId != null and params.agreeId != ''">
+            and iac.agreement_id = #{params.agreeId}
+        </if>
+
     </select>
 
     <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
@@ -187,7 +230,7 @@
         AND orderstatus = 3
         )
         AND
-        orderstatus= 3
+        io.orderstatus= 3
         <if test="orderNo != null and orderNo != ''">
             AND orderno = #{orderNo}
         </if>
@@ -213,10 +256,10 @@
 
     <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
         SELECT
-        sum(a.first_detail_premiums) as  "willFirstPremiums"
+        sum(a.first_detail_premiums) as "willFirstPremiums"
         FROM
-        ins_fee_order_new  a
-        LEFT JOIN  ins_area_company  iac  on  iac.id=a.ins_order_no
+        ins_fee_order_new a
+        LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
         WHERE
         a.id NOT IN (
         SELECT
@@ -224,28 +267,28 @@
         FROM
         ins_fee_audit
         )
-        AND   iac.orderstatus =3
+        AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
-             AND  a.first_level_user_id = #{firstUserId}
+            AND a.first_level_user_id = #{firstUserId}
         </if>
         <if test="secondUserId != null and secondUserId != ''">
-             AND  a.two_level_user_id = #{secondUserId}
+            AND a.two_level_user_id = #{secondUserId}
         </if>
 
         <if test="thirdUserId != null and thirdUserId != ''">
-             AND  a.three_level_user_id = #{thirdUserId}
+            AND a.three_level_user_id = #{thirdUserId}
         </if>
 
-         <if test="id != null and id != ''">
-             AND  a.id = #{id}
+        <if test="id != null and id != ''">
+            AND a.id = #{id}
         </if>
     </select>
     <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
         SELECT
-        sum(a.second_detail_premiums) as  "willSecondPremiums"
+        sum(a.second_detail_premiums) as "willSecondPremiums"
         FROM
-        ins_fee_order_new  a
-        LEFT JOIN  ins_area_company  iac  on  iac.id=a.ins_order_no
+        ins_fee_order_new a
+        LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
         WHERE
         a.id NOT IN (
         SELECT
@@ -253,29 +296,29 @@
         FROM
         ins_fee_audit
         )
-        AND   iac.orderstatus =3
+        AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
-             AND  a.first_level_user_id = #{firstUserId}
+            AND a.first_level_user_id = #{firstUserId}
         </if>
         <if test="secondUserId != null and secondUserId != ''">
-             AND  a.two_level_user_id = #{secondUserId}
+            AND a.two_level_user_id = #{secondUserId}
         </if>
 
         <if test="thirdUserId != null and thirdUserId != ''">
-             AND  a.three_level_user_id = #{thirdUserId}
+            AND a.three_level_user_id = #{thirdUserId}
         </if>
         <if test="id != null and id != ''">
-            AND  a.id = #{id}
+            AND a.id = #{id}
         </if>
 
     </select>
     <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
         SELECT
-        sum(a.third_detail_premiums) as  "willThreePremiums"
+        sum(a.third_detail_premiums) as "willThreePremiums"
 
         FROM
-        ins_fee_order_new  a
-        LEFT JOIN  ins_area_company  iac  on  iac.id=a.ins_order_no
+        ins_fee_order_new a
+        LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
         WHERE
         a.id NOT IN (
         SELECT
@@ -283,19 +326,19 @@
         FROM
         ins_fee_audit
         )
-        AND   iac.orderstatus =3
+        AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
-             AND  a.first_level_user_id = #{firstUserId}
+            AND a.first_level_user_id = #{firstUserId}
         </if>
         <if test="secondUserId != null and secondUserId != ''">
-             AND  a.two_level_user_id = #{secondUserId}
+            AND a.two_level_user_id = #{secondUserId}
         </if>
 
         <if test="thirdUserId != null and thirdUserId != ''">
-             AND  a.three_level_user_id = #{thirdUserId}
+            AND a.three_level_user_id = #{thirdUserId}
         </if>
         <if test="id != null and id != ''">
-            AND  a.id = #{id}
+            AND a.id = #{id}
         </if>
 
     </select>
@@ -304,22 +347,36 @@
     <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
         SELECT
         io.*,
-        sd.management_source
+        sd.management_source,
+        su2.name AS auditUser,
+        ifa.audittime as auditTime
         FROM
-        ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
+        ins_orders io
+        LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
+        LEFT JOIN sys_user su ON su.id = io.userid
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
+        LEFT JOIN sys_user su2 on ifa.audituser = su2.id
         WHERE
-        orderno IN (
+        io.orderno IN (
         SELECT
         orderno
         FROM
         ins_area_company
         WHERE
-        id IN ( SELECT ifon.ins_order_no FROM ins_fee_order_new ifon RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no where ifa.auditstatus = #{params.auditStatus} ))
-          AND
-            orderstatus = 3
-<!--        <if test="params.orderNo != null and params.orderNo != ''">-->
-<!--            AND orderno = #{params.orderNo}-->
-<!--        </if>-->
+        id IN (
+        SELECT
+        ifon.ins_order_no
+        FROM
+        ins_fee_order_new ifon
+        RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
+        WHERE
+        ifa.auditstatus = #{params.auditStatus}
+        )
+        )
+        AND orderstatus = 3
+        <!--        <if test="params.orderNo != null and params.orderNo != ''">-->
+        <!--            AND orderno = #{params.orderNo}-->
+        <!--        </if>-->
         <if test="params.licenseNo != null and params.licenseNo != ''">
             AND licenseno = #{params.licenseNo}
         </if>

+ 98 - 21
src/main/resources/mapper/modules/order/InsOrdersMapper.xml

@@ -42,6 +42,9 @@
                 javaType="com.alibaba.fastjson.JSONObject"
                 typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
         <result property="subOrderId" column="subOrderId" jdbcType="VARCHAR"/>
+        <result property="agreementCode" column="agreementCode" jdbcType="VARCHAR"/>
+        <result property="agreementName" column="agreementName" jdbcType="VARCHAR"/>
+
     </resultMap>
     <resultMap id="OrderResultMap" type="com.ydtech.modules.order.entity.vo.OrderVo">
         <id property="orderno" column="orderno" jdbcType="VARCHAR"/>
@@ -293,12 +296,12 @@
                 <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                     and iac.company_id = #{orderQueryVo.companyId}
                 </if>
-                <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
-                    and io.operatorid = #{orderQueryVo.userId}
-                </if>
-                <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
-                    and io.userid = #{orderQueryVo.userId}
-                </if>
+<!--                <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">-->
+<!--                    and io.operatorid = #{orderQueryVo.userId}-->
+<!--                </if>-->
+<!--                <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">-->
+<!--                    and io.userid = #{orderQueryVo.userId}-->
+<!--                </if>-->
             </where>
             group by io.orderno
         ) as s
@@ -318,9 +321,9 @@
             <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
                 and io.orderno = #{orderQueryVo.orderNo}
             </if>
-            <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' and isTeamLeader">
-                and io.deptid like "${orderQueryVo.deptId}%"
-            </if>
+<!--            <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' and isTeamLeader">-->
+<!--                and io.deptid like "${orderQueryVo.deptId}%"-->
+<!--            </if>-->
             <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
                 and io.orderstatus = #{orderQueryVo.orderStatus}
             </if>
@@ -339,9 +342,9 @@
             <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                 and iac.company_id = #{orderQueryVo.companyId}
             </if>
-            <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
-                and io.operatorid = #{orderQueryVo.userId}
-            </if>
+<!--            <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">-->
+<!--                and io.operatorid = #{orderQueryVo.userId}-->
+<!--            </if>-->
             <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
                 and io.userid = #{orderQueryVo.userId}
             </if>
@@ -805,12 +808,16 @@
         io.king as king,
         io.vehicle_and_vessel_tax as vehicleAndVesselTax,
         iac.id as subOrderId,
-        iac.id as company_id,
-        iac.inscompany as ins_company
+        iac.company_id as company_id,
+        iac.inscompany as ins_company,
+        agree.agreement_code as agreementCode,
+        agree.agreement_name as agreementName
         from
             ins_area_company iac
         left JOIN
              ins_orders io  on iac.orderno = io.orderno
+        left join
+            ptl_agreement   agree  on  iac.agreement_id= agree.id
         <where>
             <if test="agentUserIds != null and agentUserIds.size>0" >
                 AND (
@@ -845,13 +852,13 @@
                 )
             </if>
             <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
-                and io.orderno = #{orderQueryVo.orderNo}
+                and iac.id = #{orderQueryVo.orderNo}
             </if>
             <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
                 and io.deptid like "${orderQueryVo.deptId}%"
             </if>
             <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
-                and iac.orderstatus = #{orderQueryVo.orderStatus}
+                and iac.orderstatus= #{orderQueryVo.orderStatus}
             </if>
             <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
                 and io.frameno = #{orderQueryVo.frameNo}
@@ -862,8 +869,8 @@
             <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
                 and io.insuredname = #{orderQueryVo.insuredName}
             </if>
-            <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
-                and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
+            <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
+                and  DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
             </if>
             <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                 and iac.company_id = #{orderQueryVo.companyId}
@@ -874,6 +881,41 @@
             <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
                 and io.username = #{orderQueryVo.operatorName}
             </if>
+            <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
+                and JSON_EXTRACT( io.carinfo, '$.engineNo' )  = #{orderQueryVo.engineNo}
+            </if>
+            <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
+                and io.deptid like "${orderQueryVo.provinceId}%"
+            </if>
+            <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
+                and io.deptid like "${orderQueryVo.cityId}%"
+            </if>
+            <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
+                and io.deptid like "${orderQueryVo.countyId}%"
+            </if>
+            <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
+                and io.deptid like "${orderQueryVo.houseId}%"
+            </if>
+            <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
+                and iac.agreement_id = #{orderQueryVo.agreeId}
+            </if>
+            <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
+                and io.orderno = #{orderQueryVo.taskNo}
+            </if>
+            <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
+                and io.product = #{orderQueryVo.riskCode}
+            </if>
+            <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
+                and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
+            </if>
+            <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
+                and  ((
+                DATE_FORMAT(io.jqstartdate, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
+                AND #{orderQueryVo.attachEndDateStr}
+                )
+                OR ( DATE_FORMAT(io.systartdate, '%Y-%m-%d')  BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
+                )
+            </if>
         </where>
         order by io.createtime desc
     </select>
@@ -922,7 +964,7 @@
                 )
             </if>
             <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
-                and io.orderno = #{orderQueryVo.orderNo}
+                and iac.id = #{orderQueryVo.orderNo}
             </if>
             <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
                 and io.deptid like "${orderQueryVo.deptId}%"
@@ -939,8 +981,8 @@
             <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
                 and io.insuredname = #{orderQueryVo.insuredName}
             </if>
-            <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
-                and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
+            <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
+                and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
             </if>
             <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                 and iac.company_id = #{orderQueryVo.companyId}
@@ -951,6 +993,41 @@
             <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
                 and io.username = #{orderQueryVo.operatorName}
             </if>
+            <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
+                and JSON_EXTRACT( io.carinfo, '$.engineNo' )  = #{orderQueryVo.engineNo}
+            </if>
+            <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
+                and io.deptid like "${orderQueryVo.provinceId}%"
+            </if>
+            <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
+                and io.deptid like "${orderQueryVo.cityId}%"
+            </if>
+            <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
+                and io.deptid like "${orderQueryVo.countyId}%"
+            </if>
+            <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
+                and io.deptid like "${orderQueryVo.houseId}%"
+            </if>
+            <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
+                and iac.agreement_id = #{orderQueryVo.agreeId}
+            </if>
+            <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
+                and io.orderno = #{orderQueryVo.taskNo}
+            </if>
+            <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
+                and io.product = #{orderQueryVo.riskCode}
+            </if>
+            <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
+                and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
+            </if>
+            <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
+                and  ((
+                DATE_FORMAT(io.jqstartdate, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
+                AND #{orderQueryVo.attachEndDateStr}
+                )
+                OR ( DATE_FORMAT(io.systartdate, '%Y-%m-%d')  BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
+                )
+            </if>
         </where>
         ) as s
     </select>

+ 11 - 0
src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

@@ -103,5 +103,16 @@
         )
         order by pa.serial_number
     </select>
+    <select id="getByAgreementIdNew" resultType="com.ydtech.modules.protocol.entity.po.PtlAgreement">
+        select
+            partner_companies_id  as  "partnercompaniesId"
+            association_companies_id  as  "associationCompaniesId"
+        from  ptl_agreement_dept
+        <where>
+            <if test="agreementId!=null  and  agreementId !=''">
+                id=#{agreementId}
+            </if>
+        </where>
+    </select>
 
 </mapper>