Ver código fonte

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

Qchen 2 anos atrás
pai
commit
038fcbfd7c
69 arquivos alterados com 2110 adições e 435 exclusões
  1. 0 161
      sql/Online.sql
  2. 40 0
      src/main/java/com/ydtech/modules/admin/service/impl/AppReportServiceImpl.java
  3. 9 1
      src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeNewService.java
  4. 304 54
      src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java
  5. 19 4
      src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java
  6. 36 0
      src/main/java/com/ydtech/modules/fnc/controller/SettlementDocumentaryFeesSumController.java
  7. 1 0
      src/main/java/com/ydtech/modules/fnc/dao/ImportAsyncMapper.java
  8. 8 0
      src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java
  9. 15 0
      src/main/java/com/ydtech/modules/fnc/dao/SettlementDocumentaryFeesSumMapper.java
  10. 25 0
      src/main/java/com/ydtech/modules/fnc/dto/PlatformSettlementRecordDto.java
  11. 8 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java
  12. 80 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesSumEntity.java
  13. 2 0
      src/main/java/com/ydtech/modules/fnc/service/ImportAsyncService.java
  14. 11 5
      src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java
  15. 1 0
      src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesService.java
  16. 14 0
      src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesSumService.java
  17. 5 0
      src/main/java/com/ydtech/modules/fnc/service/impl/ImportAsyncServiceImpl.java
  18. 242 62
      src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java
  19. 72 0
      src/main/java/com/ydtech/modules/fnc/service/impl/SettlementDocumentaryFeesSumServiceImpl.java
  20. 10 3
      src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java
  21. 77 0
      src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesSumVo.java
  22. 4 0
      src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java
  23. 5 0
      src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java
  24. 2 0
      src/main/java/com/ydtech/modules/ins/model/yc/audit/Audit.java
  25. 2 2
      src/main/java/com/ydtech/modules/ins/model/yc/ruote/Ruote.java
  26. 4 1
      src/main/java/com/ydtech/modules/ins/model/yc/ruote/Vhl.java
  27. 2 1
      src/main/java/com/ydtech/modules/order/controller/BoHaiOrderApiController.java
  28. 47 0
      src/main/java/com/ydtech/modules/order/controller/ExternalOrderController.java
  29. 31 0
      src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyExternalFeeMapper.java
  30. 20 0
      src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyExternalPolicyMapper.java
  31. 65 0
      src/main/java/com/ydtech/modules/order/entity/InsAreaCompanyExternalFee.java
  32. 48 0
      src/main/java/com/ydtech/modules/order/entity/InsAreaCompanyExternalPolicy.java
  33. 0 1
      src/main/java/com/ydtech/modules/order/entity/InsDrivingIntentionInsurance.java
  34. 4 0
      src/main/java/com/ydtech/modules/order/entity/InsOrders.java
  35. 7 0
      src/main/java/com/ydtech/modules/order/entity/PtlAgreementNonCarProductRule.java
  36. 24 3
      src/main/java/com/ydtech/modules/order/entity/api/bohai/request/QuotationRequest.java
  37. 31 0
      src/main/java/com/ydtech/modules/order/entity/api/bohai/response/QuotationResponse.java
  38. 5 0
      src/main/java/com/ydtech/modules/order/entity/dto/InsAreaCompanyQueryDto.java
  39. 3 0
      src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteInfoVo.java
  40. 57 0
      src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteVo.java
  41. 11 0
      src/main/java/com/ydtech/modules/order/entity/vo/InsDrivingIntentionInsuranceVo.java
  42. 10 0
      src/main/java/com/ydtech/modules/order/entity/vo/NoCarInsuranceQueryVo.java
  43. 3 0
      src/main/java/com/ydtech/modules/order/entity/vo/OrderVo.java
  44. 24 0
      src/main/java/com/ydtech/modules/order/service/InsAreaCompanyExternalFeeService.java
  45. 16 0
      src/main/java/com/ydtech/modules/order/service/InsAreaCompanyExternalPolicyService.java
  46. 7 2
      src/main/java/com/ydtech/modules/order/service/InsAreaCompanyService.java
  47. 12 4
      src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java
  48. 60 0
      src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyExternalFeeServiceImpl.java
  49. 33 0
      src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyExternalPolicyServiceImpl.java
  50. 167 12
      src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java
  51. 4 0
      src/main/java/com/ydtech/modules/order/service/impl/InsDrivingIntentionInsuranceServiceImpl.java
  52. 5 3
      src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java
  53. 5 1
      src/main/java/com/ydtech/modules/order/service/impl/PtlAgreementNonCarProductRuleServiceImpl.java
  54. 58 10
      src/main/java/com/ydtech/modules/order/service/impl/YongchengOrderApiServiceImpl.java
  55. 10 0
      src/main/java/com/ydtech/modules/protocol/controller/TaxSourceController.java
  56. 3 0
      src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementMapper.java
  57. 3 0
      src/main/java/com/ydtech/modules/protocol/entity/dto/PtlAgreementSaveDto.java
  58. 6 0
      src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java
  59. 10 0
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java
  60. 64 1
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java
  61. 3 0
      src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductQueryVo.java
  62. 104 101
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java
  63. 38 0
      src/main/resources/mapper/modules/fnc/ImportAsyncMapper.xml
  64. 22 0
      src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml
  65. 4 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml
  66. 57 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesSumMapper.xml
  67. 4 2
      src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml
  68. 5 1
      src/main/resources/mapper/modules/order/InsOrdersMapper.xml
  69. 22 0
      src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

+ 0 - 161
sql/Online.sql

@@ -1,161 +0,0 @@
--- 协议调度表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_tax_source_new`;
-CREATE TABLE `ptl_tax_source_new`  (
-                                       `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
-                                       `ins_company_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '保险公司id',
-                                       `ins_company_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '保险公司名称',
-                                       `agreement_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '协议id',
-                                       `priority` int NULL DEFAULT NULL COMMENT '优先级',
-                                       `default_flag` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '是否默认',
-                                       `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
-                                       `create_user` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建人',
-                                       `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
-                                       `update_user` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '修改人',
-                                       `dispatch_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '调度内容',
-                                       PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '协议调度管理' ROW_FORMAT = Dynamic;
-
--- 协议调度历史记录表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_tax_source_new_history`;
-CREATE TABLE `ptl_tax_source_new_history`  (
-                                               `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
-                                               `ins_company_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '保险公司id',
-                                               `ins_company_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '保险公司名称',
-                                               `agreement_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '协议id',
-                                               `priority` int NULL DEFAULT NULL COMMENT '优先级',
-                                               `default_flag` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '是否默认',
-                                               `operator_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
-                                               `modifier` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建人',
-                                               `dispatch_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '调度内容',
-                                               `ptl_tax_source_new_id` bigint NULL DEFAULT NULL COMMENT '协议调度表id',
-                                               `batch_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '批次id',
-                                               `batch_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '批次类型',
-                                               PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '协议调度历史记录表' ROW_FORMAT = Dynamic;
-
--- 协议调度关联表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_agreement_dispatch_rules_attr_link`;
-CREATE TABLE `ptl_agreement_dispatch_rules_attr_link`  (
-                                                           `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                                           `rules_id` bigint NOT NULL COMMENT '协议规则id',
-                                                           `attr_id` bigint NULL DEFAULT NULL COMMENT '协议属性id',
-                                                           `attr_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '协议code',
-                                                           `min` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '左操作数',
-                                                           `operator` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '运算符\r\n1.等于\r\n2.不等于\r\n3.小于等于\r\n4.大于等于',
-                                                           `max` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '右操作符',
-                                                           PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '协议调度关联表' ROW_FORMAT = Dynamic;
-
--- 协议调度关联历史记录表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_agreement_dispatch_rules_attr_link_history`;
-CREATE TABLE `ptl_agreement_dispatch_rules_attr_link_history`  (
-                                                                   `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                                                   `rules_id` int NULL DEFAULT NULL COMMENT '承包规则id',
-                                                                   `attr_id` int NULL DEFAULT NULL COMMENT '属性id',
-                                                                   `attr_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性编码',
-                                                                   `min` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '左操作数',
-                                                                   `operator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作符',
-                                                                   `batch` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '右操作数',
-                                                                   `operator_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '批次',
-                                                                   `modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作类型',
-                                                                   `operator_time` datetime NULL DEFAULT NULL COMMENT '操作人',
-                                                                   `max` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作时间',
-                                                                   PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '协议调度关联历史记录表' ROW_FORMAT = Dynamic;
-
--- 协议调度规则属性   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_agreement_dispatch_rules_attr`;
-CREATE TABLE `ptl_agreement_dispatch_rules_attr`  (
-                                                      `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                                      `attr_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性名称',
-                                                      `attr_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性code',
-                                                      `attr_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单类型',
-                                                      `dict_id` bigint NULL DEFAULT NULL COMMENT '关联字典id',
-                                                      `attr_group` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分组',
-                                                      `company_ids` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '保险公司id',
-                                                      `sort` int NULL DEFAULT NULL COMMENT '排序',
-                                                      PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '协议调度规则属性' ROW_FORMAT = DYNAMIC;
-
-
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (1, '车牌号', 'LicenseNo', 'select', NULL, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (2, '座位数', 'PassengerCarSeatingCapacity', 'inputNumber', NULL, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (3, '排量', 'volume', 'inputNumber', NULL, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (4, '车辆大类', 'CarType', 'checkbox', 4, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (5, '使用性质', 'NatureOfUse', 'checkbox', 5, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (6, '交强投保', 'yqInsureFlag', 'radio', 1, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (7, '车损投保', 'cxInsureFlag', 'radio', 1, 'dispatch', 'all', NULL);
-INSERT INTO `ptl_agreement_dispatch_rules_attr` VALUES (8, '第三者责任险 ', 'ThirdPartyLiabilityInsurance', 'inputNumber', NULL, 'dispatch', 'all', NULL);
-
--- 协议调度属性字典表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_agreement_dispatch_rules_dict`;
-CREATE TABLE `ptl_agreement_dispatch_rules_dict`  (
-                                                      `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                                      `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典名称',
-                                                      `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典code',
-                                                      `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
-                                                      PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '协议调度属性字典表' ROW_FORMAT = Dynamic;
-
-
-INSERT INTO `ptl_agreement_dispatch_rules_dict` VALUES (1, '交强投保', 'yqInsureFlag', '是与否');
-INSERT INTO `ptl_agreement_dispatch_rules_dict` VALUES (4, '车辆大类', 'carType', '客车和货车');
-INSERT INTO `ptl_agreement_dispatch_rules_dict` VALUES (5, '使用性质', 'useDesc', '营业 非营业');
-
--- 协议调度字典详情   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_agreement_dispatch_rules_dict_labal`;
-CREATE TABLE `ptl_agreement_dispatch_rules_dict_labal`  (
-                                                            `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                                            `parent_id` bigint NULL DEFAULT 0 COMMENT '父id',
-                                                            `dict_id` bigint NULL DEFAULT NULL COMMENT '字典id',
-                                                            `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性名称',
-                                                            `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性code',
-                                                            `sort` int NULL DEFAULT NULL COMMENT '排序',
-                                                            PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '协议调度字典详情' ROW_FORMAT = Dynamic;
-
-
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (1, 0, 1, '是', '1', 1);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (2, 0, 1, '否', '0', 2);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (7, 0, 4, '客车', 'A0', 1);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (8, 0, 4, '货车', 'A1', 2);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (10, 0, 5, '家庭自用', '05', 1);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (11, 0, 5, '非营业机关', '06', 2);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (12, 0, 5, '非营业企业', '07', 3);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (13, 0, 5, '非营业货运', '08', 4);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (15, 0, 5, '营业出租租赁', '01', 1);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (17, 0, 5, '营业城市公交', '02', 3);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (18, 0, 5, '营业公路客运', '03', 4);
-INSERT INTO `ptl_agreement_dispatch_rules_dict_labal` VALUES (19, 0, 5, '营业货运', '04', 5);
-
--- 协议调度匹配信息记录表   add by hxl  2024-05-29
-DROP TABLE IF EXISTS `ptl_tax_source_new_record`;
-CREATE TABLE `ptl_tax_source_new_record`  (
-                                              `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键/自增',
-                                              `orderno` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '主订单编号',
-                                              `ptl_tax_source_new_str` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '调度协议对象信息',
-                                              `dispatch_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '调度协议规则内容',
-                                              `quote_info_msg` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '报价信息内容',
-                                              `mate_msg` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '匹配信息',
-                                              `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
-                                              `create_user` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建人',
-                                              PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '调度协议默认匹配信息记录表' ROW_FORMAT = Dynamic;
-
--- 费用审核轨迹表   add by hy  2024-06-3
-DROP TABLE IF EXISTS `ins_fee_audit_history`;
-CREATE TABLE `ins_fee_audit_history`  (
-                                          `id` int(0) NOT NULL COMMENT '主键ID',
-                                          `orderno` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '订单号',
-                                          `ins_order_no` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '保司订单号 关联ins_area_company表id',
-                                          `auditstatus` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '费用审核状态0未审核 1审核通过',
-                                          `audittime` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
-                                          `audituser` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审核人',
-                                          `operator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
-                                          `operatorTime` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
-                                          PRIMARY KEY (`id`) USING BTREE,
-                                          INDEX `ins_order_no`(`ins_order_no`) USING BTREE COMMENT 'ins_order_no'
-) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '费用审核表' ROW_FORMAT = Dynamic;
-
-
-

+ 40 - 0
src/main/java/com/ydtech/modules/admin/service/impl/AppReportServiceImpl.java

@@ -168,6 +168,9 @@ public class AppReportServiceImpl implements AppReportService {
                 list.add(new PremiumReportDto(str, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
             }
         }
+        //去除时间前面的数据
+        //短日期
+        dateStrs = getShortStrs(dateStrs, dateStr);
         return new PremiumReportAllDto(dateStr,jqPremium,syPremium,sumPremium,dateStrs,jqPremiumList,syPremiumList,sumPremiumList);
     }
     /**
@@ -201,9 +204,43 @@ public class AppReportServiceImpl implements AppReportService {
                 list.add(new EmployeeIncreaseReportDto(str,0));
             }
         }
+        //短日期
+        dateStrs = getShortStrs(dateStrs, dateStr);
         return new EmployeeIncreaseReportAllDto(dateStr,employeeIncreaseCount,dateStrs,employeeIncreaseList);
     }
 
+    private static List<String> getShortStrs(List<String> dateStrs, String dateStr) {
+        List<String> shortStrs=new ArrayList<>();
+        //去除时间前面的数据
+        for(String str: dateStrs) {
+            str = getStrBySize(str, dateStr);
+           shortStrs.add(str);
+        }
+        return shortStrs;
+    }
+
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/17 20:03
+     *  @Description:
+     */
+    public static String   getStrBySize(String str, String dateStr){
+        String[] strs = dateStr.split("-");
+        int size=strs.length;
+        //月
+        if(size==2){
+            str = str.split("-")[2];
+
+        }else if(size==3){
+            //日
+            str = str.split(" ")[1];
+        }else{
+            //年
+            str = str.split("-")[1];
+        }
+        return str;
+    }
     /**
      *  @version
      *  @author: hxl
@@ -247,6 +284,9 @@ public class AppReportServiceImpl implements AppReportService {
                 list.add(new RevenueReportDto(str,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO));
             }
         }
+        //去除时间前面的数据
+        //短日期
+        dateStrs = getShortStrs(dateStrs, dateStr);
         return new RevenueReportAllDto(dateStr,haldingAmount,documentaryAmount,promotionAmount,dateStrs,haldingAmountList,documentaryAmountList,promotionAmountList);
     }
     /**

+ 9 - 1
src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeNewService.java

@@ -7,6 +7,7 @@ import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeResultVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeVo;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
 
 import java.util.List;
 
@@ -62,5 +63,12 @@ public interface FeeRuleSchemeNewService {
      * 计算费用因子
      * @param costsId
      */
-    void calcCosts(String costsId,InsAreaCompany insAreaCOmpany);
+    void calcCosts(String costsId,InsAreaCompany insAreaCompany);
+
+    /**
+     * 计算费用因子  外部订单录入使用
+     * @param costsNew
+     * @param insAreaCompany
+     */
+    void calcCostsExternal(PtlAgreementProductCostsNew costsNew,InsAreaCompany insAreaCompany);
 }

+ 304 - 54
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -166,7 +166,8 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //获取协议信息
         PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
         BigDecimal taxRadio = new BigDecimal("1.00");
-        if (ptlAgreement.getWithTax().equals("否")) {
+        //如果是外部订单则 不含税
+        if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
             taxRadio = new BigDecimal("1.06");
         }
         //税比例 固定1.06
@@ -459,6 +460,303 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
     }
 
+    @Override
+    public void calcCostsExternal(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
+        //获取协议信息
+        PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
+        BigDecimal taxRadio = new BigDecimal("1.00");
+        //如果是外部订单则 不含税
+        if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
+            taxRadio = new BigDecimal("1.06");
+        }
+        //税比例 固定1.06
+        //查找入口与出口费用比例
+
+        //出口配置
+        PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
+                ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
+        InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
+        insFeeOrderNew.setId(IdGenerate.nextId());
+        insFeeOrderNew.setCostsId(ptlAgreementProductCostsNew.getId());
+        insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
+
+        //存储部门id与用户id
+        InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
+        InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
+        if (insFeeOrderNewByCompanyId != null) {
+            insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
+        }
+        insFeeOrderNew.setDeptId(order.getDeptid());
+        insFeeOrderNew.setUserId(order.getUserid());
+        insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
+        insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
+        insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
+        insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
+        //不含税
+        BigDecimal bigDecimal = new BigDecimal("1.06");
+        insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
+        insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
+        insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
+
+        //region 计算入口费用
+
+        //交强入口信息
+        FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
+                new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()), taxRadio);
+        insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
+        insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
+        insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
+        insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
+        insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
+        insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
+
+        //商业入口信息
+        FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
+                new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
+        insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
+        insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
+        insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
+        insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
+        insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
+        insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
+
+        //非车入口信息
+        FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
+                new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
+        insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
+        insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
+        insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
+        insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
+        insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
+        insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
+        //endregion
+
+        //region 计算分销费用
+        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+        SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
+
+        //获取分销比例
+        List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
+                new Object[]{sysUser.getDeptId()});
+
+        //分销总比例
+        BigDecimal retailRadio = new BigDecimal("0");
+        if (esmRetailList != null && !esmRetailList.isEmpty()) {
+            EsmRetail esmRetail = esmRetailList.get(0);
+            //分销等级
+            insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
+            //用户分销人员id
+            List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
+
+            if (esmRetail != null) {
+                BigDecimal sumPremium = insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium());
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
+                    insFeeOrderNew.setThirdDetailProportion(new BigDecimal(esmRetail.getDisrate3()));
+                    retailRadio = retailRadio.add(insFeeOrderNew.getThirdDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
+                    BigDecimal thirdDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getThirdDetailProportion());
+                    insFeeOrderNew.setThirdDetailPremiums(thirdDetailPremiums);
+                    if (parents != null && parents.size() > 2) {
+                        insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
+                    }
+                }else{
+                    insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
+                }
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
+                    insFeeOrderNew.setSecondDetailProportion(new BigDecimal(esmRetail.getDisrate2()));
+                    retailRadio = retailRadio.add(insFeeOrderNew.getSecondDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
+                    BigDecimal secondDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getSecondDetailProportion());
+                    insFeeOrderNew.setSecondDetailPremiums(secondDetailPremiums);
+                    if (parents != null && parents.size() > 1) {
+                        insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
+                    }
+                }else{
+                    insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
+                }
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
+                    insFeeOrderNew.setFirstDetailProportion(new BigDecimal(esmRetail.getDisrate1()));
+                    retailRadio = retailRadio.add(insFeeOrderNew.getFirstDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
+                    BigDecimal firstDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getFirstDetailProportion());
+                    insFeeOrderNew.setFirstDetailPremiums(firstDetailPremiums);
+                    if (parents != null && parents.size() > 0) {
+                        insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
+                    }
+                }else{
+                    insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
+                }
+            }else{
+                insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
+                insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
+                insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
+            }
+        }else{
+            insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
+            insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
+            insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
+        }
+
+
+        //endregion
+
+        //region 设置机构管理费
+
+        //交强机构管理费
+        BigDecimal jqDeptRadio =
+                ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
+        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
+                ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
+                ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
+                ptlAgreementProductCostsExport.getJqExportRadioLevel5());
+        insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
+        insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
+        insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
+        insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
+        insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
+
+        BigDecimal syDeptRadio =
+                ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
+        FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
+                ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
+                ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
+                ptlAgreementProductCostsExport.getSyExportRadioLevel5());
+        insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
+        insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
+        insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
+        insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
+        insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
+
+        BigDecimal noDeptRadio =
+                ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
+        FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
+                ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
+                ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
+                ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
+        insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
+        insFeeOrderNew.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
+        insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
+        insFeeOrderNew.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
+        insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
+        insFeeOrderNew.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
+        insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
+        insFeeOrderNew.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
+        insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
+        insFeeOrderNew.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
+
+        //endregion
+
+        //region 出口费用
+
+        //交强出口手续费比例
+        FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
+                insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio);
+
+        //商业出口手续费比例
+        FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
+                insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio);
+
+        //非车出口手续费比例
+        FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
+                insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio);
+
+        //出口手续费用
+        insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
+        insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
+        insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
+
+        //出口其他费用比例
+        insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
+        insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
+        insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
+
+        //出口其他费用
+        insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
+        insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
+        insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
+
+        //设置出口手续费比例
+        insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
+        insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
+        insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
+
+        //endregion
+
+        //region 计算利润差值
+        //入口 - 出口 - 机构管理费 1-5级 - 分销费  = 差值
+
+        //分销交强费用
+        //分开算  1  2 3 级
+        BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
+        //分销商业费用
+        BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
+        //分销非车费用
+        BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
+
+
+        BigDecimal jqDifference = jqEntranceFee.getTotalAmount().subtract(
+                        (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
+                .subtract(
+                        (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
+                )
+                .subtract(jqFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
+        insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
+
+        BigDecimal syDifference = syEntranceFee.getTotalAmount().subtract(
+                        (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
+                .subtract(
+                        (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
+                )
+                .subtract(syFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
+        insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
+
+
+        BigDecimal noDifference = noEntranceFee.getTotalAmount().subtract(
+                        (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
+                .subtract(
+                        (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
+                )
+                .subtract(noFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
+
+        insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
+
+        //endregion
+
+        //region 比例逆推是否等于0
+
+        if(!feeRuleSchemeService.calculateProportion(jqEntranceFee,jqDeptManagerFee,jqExportFee,retailRadio,taxRadio,insFeeOrderNew.getJqPremium()))
+            throw new SystemException("交强比例异常");
+
+        if(!feeRuleSchemeService.calculateProportion(syEntranceFee,syDeptManagerFee,syExportFee,retailRadio,taxRadio,insFeeOrderNew.getSyPremium()))
+            throw new SystemException("商业比例异常");
+
+        if(!feeRuleSchemeService.calculateProportion(noEntranceFee,noDeptManagerFee,noExportFee,retailRadio,taxRadio,insFeeOrderNew.getNoPremium()))
+            throw new SystemException("非车比例异常");
+
+        //endregion
+
+        insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
+    }
+
 
     /**
      * 判断是否包含非车险
@@ -493,45 +791,6 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders,
                 undwrtRulesAttrList, carJudgeRule);
 
-//        List<AgreementProductCosts> filterAgreementProductCosts = new ArrayList<>();
-
-//        boolean isNoCar = false;
-//        //查找是否有强制非车因子
-//        for(int i=0;i<agreementProductCosts.size();i++) {
-//            PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink =
-//                    agreementProductCosts.get(i).getCostsAttrLinks().stream().filter(x -> x.getAttrCode().equals("IsNonMotorInsurance")
-//                    ).findFirst().orElse(null);
-//
-//            if(!Objects.isNull(ptlAgreementProductCostsAttrLink)){
-//                if(ptlAgreementProductCostsAttrLink.getMin().equals("1")){
-//                    //只走强制非车的费用因子
-//                    AgreementProductCosts productCosts = agreementProductCosts.get(i);
-//                    filterAgreementProductCosts.add(productCosts);
-//                    isNoCar = true;
-//                }
-//
-//            }
-//        }
-//        if(filterAgreementProductCosts.isEmpty()){
-//            filterAgreementProductCosts = agreementProductCosts;
-//        }
-        //是否强制走非车
-//        if(isNoCar) {
-//            for(int i=0;i<filterAgreementProductCosts.size();i++) {
-//                if (judgementsIsNoCar(filterAgreementProductCosts.get(i).getCostsAttrLinks(), undwrtRulesAttrList,
-//                ruleAttrMappingVoList)) {
-//                    return filterAgreementProductCosts.get(i).getId();
-//                }
-//            }
-//        }else{
-//            for (int i = 0; i < filterAgreementProductCosts.size(); i++) {
-//                //判断是否匹配
-//                if (judgements(filterAgreementProductCosts.get(i).getCostsAttrLinks(), undwrtRulesAttrList, ruleAttrMappingVoList)) {
-//                    //返回 费用id   如果需要匹配非车的情况  将返回值返回list 后赛选
-//                    return filterAgreementProductCosts.get(i).getId();
-//                }
-//            }
-//        }
         for (int i = 0; i < agreementProductCosts.size(); i++) {
             //判断是否匹配
             log.debug("费用因子匹配开始:" + agreementProductCosts.get(i).getId());
@@ -909,20 +1168,11 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //将值进行分割
         String[] split = ptlAgreementProductCostsAttrLink.getMin().split(",");
         AtomicBoolean returnBool = new AtomicBoolean(false);
-        if(ptlAgreementProductCostsAttrLink.getAttrCode().equals("NatureOfUse")){
-            Arrays.stream(split).forEach(x -> {
-                if (value.equals(x)) {
-                    returnBool.set(true);
-                }
-            });
-        }else{
-            Arrays.stream(split).forEach(x -> {
-                if (value.contains(x)) {
-                    returnBool.set(true);
-                }
-            });
-        }
-
+        Arrays.stream(split).forEach(x -> {
+            if (value.equals(x)) {
+                returnBool.set(true);
+            }
+        });
         return returnBool.get();
     }
 

+ 19 - 4
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -2,6 +2,7 @@ package com.ydtech.modules.fnc.controller;
 
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.service.ImportAsyncService;
@@ -149,6 +150,13 @@ public class InsPlyIncomeController extends BaseController {
 
         return insPlyIncomeService.batchBalance(insPlyIncomeVo);
     }
+    @PutMapping("/batchSumBalance")
+    @ApiModelProperty(value = "批次批量結算")
+    public HttpResult<Object> batchSumBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+
+        return insPlyIncomeService.batchSumBalance(insPlyIncomeVo);
+    }
+
 
     @PutMapping("/batchPinBalance")
     @ApiModelProperty(value = "平台批量结算")
@@ -308,9 +316,7 @@ public class InsPlyIncomeController extends BaseController {
     @DeleteMapping("/delete")
     @ApiModelProperty(value = "删除")
     public HttpResult<InsPlyIncome> deleteById(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
-
         return insPlyIncomeService.deleteById(insPlyIncomeVo);
-
     }
 
     @GetMapping("/getById/{id}")
@@ -407,8 +413,17 @@ public class InsPlyIncomeController extends BaseController {
     public HttpResult<List<HashMap<String, Object>>> otherTimeDetail(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
         return insPlyIncomeService.otherTimeDetail(insPlyIncomeVo);
     }
-
-
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/18 10:27
+     *  @Description: 平台已结算-记录
+     */
+    @PostMapping("/platformSettlementRecord")
+    @ApiOperation(value = "平台已结算-记录")
+    public HttpResult<List<PlatformSettlementRecordDto>> platformSettlementRecord(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return HttpResult.ok(insPlyIncomeService.platformSettlementRecord(insPlyIncomeVo));
+    }
 }
 
 

+ 36 - 0
src/main/java/com/ydtech/modules/fnc/controller/SettlementDocumentaryFeesSumController.java

@@ -0,0 +1,36 @@
+package com.ydtech.modules.fnc.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity;
+import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesSumService;
+import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesSumVo;
+import com.ydtech.modules.order.entity.BasePageResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@RestController
+@Api(tags = "开票批次表结算")
+@RequestMapping("/fnc/SettlementSumFees")
+public class SettlementDocumentaryFeesSumController {
+    @Autowired
+    private SettlementDocumentaryFeesSumService settlementDocumentaryFeesSumService;
+
+
+    @PutMapping("/voidInvoicing")
+    @ApiModelProperty(value = "作废开票")
+    public HttpResult<Object> voidInvoicing(@RequestBody SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo) {
+        HttpResult<Object>  result= settlementDocumentaryFeesSumService.voidInvoicing(settlementDocumentaryFeesSumVo);
+        return HttpResult.ok(result);
+    }
+    @PostMapping("/query")
+    @ApiOperation(value = "[1]保司费用查询new")
+    public HttpResult<BasePageResult<SettlementDocumentaryFeesSumEntity>> query(@RequestBody @Valid SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo) {
+        HttpResult<BasePageResult<SettlementDocumentaryFeesSumEntity>> result = settlementDocumentaryFeesSumService.queryNew(settlementDocumentaryFeesSumVo);
+        return result;
+    }
+}

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/dao/ImportAsyncMapper.java

@@ -11,4 +11,5 @@ import java.util.List;
 public interface ImportAsyncMapper  extends BaseMapper<ImportResult> {
     List<ImportResult> queryNew(HashMap<String, Object> params);
 
+    List<ImportResult> selectByIncomeId(String incomeId);
 }

+ 8 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.fnc.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.InsPlySettleVo;
@@ -122,4 +123,11 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
     List<HashMap<String,Object>> otherTimeDetail(HashMap<String, Object> params);
 
     InsPlyIncome ptTotalAmount(HashMap<String, Object> params);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/18 10:15
+     *  @Description: 根据合作公司id和结算状态查询数据
+     */
+    List<PlatformSettlementRecordDto> platformSettlementRecord(@Param("partnerCompaniesId") String partnerCompaniesId, @Param("handlingFeesStatus") String handlingFeesStatus);
 }

+ 15 - 0
src/main/java/com/ydtech/modules/fnc/dao/SettlementDocumentaryFeesSumMapper.java

@@ -0,0 +1,15 @@
+package com.ydtech.modules.fnc.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity;
+import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesSumVo;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface SettlementDocumentaryFeesSumMapper extends BaseMapper<SettlementDocumentaryFeesSumEntity> {
+    List<SettlementDocumentaryFeesSumEntity> queryNew(SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo);
+
+}

+ 25 - 0
src/main/java/com/ydtech/modules/fnc/dto/PlatformSettlementRecordDto.java

@@ -0,0 +1,25 @@
+package com.ydtech.modules.fnc.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.poi.hpsf.Decimal;
+
+import java.io.Serializable;
+
+/**
+ *  @version
+ *  @author: hxl
+ *  @Date: 2024/6/18 10:07
+ *  @Description: 平台已结算的实体类
+ */
+@Data
+@ApiModel("平台已结算记录")
+public class PlatformSettlementRecordDto implements Serializable {
+
+    @ApiModelProperty(value = "进账时间")
+    private String settlementTime;
+
+    @ApiModelProperty(value = "进账金额")
+    private Decimal settlementAmount;
+}

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

@@ -153,6 +153,14 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     @TableField("completion_status")
     private String completionStatus;
 
+    @ApiModelProperty("开票号")
+    @TableField("invoice_id")
+    private String invoicId;
+
+    @ApiModelProperty("批次开票关联id")
+    @TableField("settlement_sum_id")
+    private String settlementSumId;
+
 
     @ApiModelProperty("图片路径")
     @TableField(exist = false)

+ 80 - 0
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesSumEntity.java

@@ -0,0 +1,80 @@
+package com.ydtech.modules.fnc.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Getter
+@Setter
+@TableName("settlement_documentary_fees_sum")
+@ApiModel(value = "settlementDocumentaryFeesSum", description = "开票批次表")
+public class SettlementDocumentaryFeesSumEntity   implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("主键")
+    @TableId("id")
+    private String id;
+
+    @ApiModelProperty("结算总金额")
+    @TableField("total_amount")
+    private BigDecimal totalAmount;
+
+
+    @ApiModelProperty("创建时间")
+    @TableField("create_time")
+    private Date createTime;
+
+    @ApiModelProperty("保险id")
+    @TableField("company_id")
+    private String companyId;
+
+    @ApiModelProperty("是否是开票 结算")
+    @TableField("settlement_status")
+    private String settlementStatus;
+
+
+    @ApiModelProperty("用户")
+    @TableField("user_id")
+    private String userId;
+
+
+    @ApiModelProperty("开票方式")
+    @TableField("invoicing_method")
+    private String invoicingMethod;
+
+
+    @ApiModelProperty("开票号")
+    @TableField("invoice_id")
+    private String invoicId;
+
+    @ApiModelProperty("是否是非车")
+    @TableField("is_not_car")
+    private String isNotCar;
+
+    @ApiModelProperty("合作公司id")
+    @TableField("partner_companies_id")
+    private String partnerCompaniesId;
+
+
+    @ApiModelProperty("已开票已结算")
+    @TableField("invoiced_settled_amount")
+    private BigDecimal invoicedSettledAmount;
+
+    @ApiModelProperty("已开票未结算")
+    @TableField("invoiced_not_settled_amount")
+    private BigDecimal invoicedNotSettledAmount;
+
+    @ApiModelProperty("结清状态")
+    @TableField("completion_status")
+    private String completionStatus;
+}

+ 2 - 0
src/main/java/com/ydtech/modules/fnc/service/ImportAsyncService.java

@@ -24,4 +24,6 @@ public interface ImportAsyncService   extends IService<ImportResult> {
 
     void bxImportNoData(List<InsBxNoPlyIncomeExcelDto> dtoList, MultipartFile multipartFile, String taskId);
 
+
+    List<ImportResult> selectByIncomeId(String incomeId);
 }

+ 11 - 5
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -1,12 +1,12 @@
 package com.ydtech.modules.fnc.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
-import com.ydtech.modules.inv.model.dto.InsBxPlyIncomeExcelDto;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
@@ -14,11 +14,8 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.concurrent.CompletableFuture;
 
 /**
  * <p>
@@ -139,4 +136,13 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     void batchUpdateVoucher(InsPlyIncomeVo insPlyIncomeVo);
 
     HttpResult<Object> reconciliation(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchSumBalance(InsPlyIncomeVo insPlyIncomeVo);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/18 10:10
+     *  @Description:  查询平台已结算记录
+     */
+    List<PlatformSettlementRecordDto> platformSettlementRecord(InsPlyIncomeVo insPlyIncomeV);
 }

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesService.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;

+ 14 - 0
src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesSumService.java

@@ -0,0 +1,14 @@
+package com.ydtech.modules.fnc.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity;
+import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesSumVo;
+import com.ydtech.modules.order.entity.BasePageResult;
+
+public interface SettlementDocumentaryFeesSumService extends IService<SettlementDocumentaryFeesSumEntity> {
+    HttpResult<Object> voidInvoicing(SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo);
+
+    HttpResult<BasePageResult<SettlementDocumentaryFeesSumEntity>> queryNew(SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo);
+
+}

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/ImportAsyncServiceImpl.java

@@ -563,4 +563,9 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setHandStatus("1");
         baseMapper.updateById(endTask);
     }
+
+    @Override
+    public List<ImportResult> selectByIncomeId(String incomeId) {
+        return   baseMapper.selectByIncomeId(incomeId);
+    }
 }

+ 242 - 62
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -4,10 +4,9 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ydtech.constants.InsuranceEnum;
@@ -18,6 +17,7 @@ import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.esm.service.EsmInsCompanyService;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
+import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
 import com.ydtech.modules.fnc.entity.*;
 import com.ydtech.modules.fnc.service.*;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
@@ -66,7 +66,9 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -103,6 +105,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     private ImportAsyncService importAsyncService;
     @Autowired
     private IncomeTaskRelationshipService incomeTaskRelationshipService;
+    @Autowired
+    private  SettlementDocumentaryFeesSumService settlementDocumentaryFeesSumService;
 
     @Value("${upload.file.path}")
     private String uploadPath;
@@ -125,8 +129,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             e.printStackTrace();
             return HttpResult.error("查询异常");
         }
-
-
     }
 
     @Override
@@ -519,6 +521,7 @@ handlingProportion,
                 if (!CollectionUtils.isEmpty(incomeIds)) {
                     params.put("incomeIds", incomeIds);
                     params.remove("handlingFeesStatus");
+                    params.remove("id");
                 }
             }
             List<InsPlyIncome> list = this.baseMapper.queryNew(params);
@@ -1211,28 +1214,33 @@ handlingProportion,
              noSuperviseCostsProportion));  //手续费比例 = 商业手续费比例 +  交强手续费比例 + 非车手续费比例
             if (jqSuperviseCostsProportion != null && jqPremium != null) {
                 insPlyIncome.setJqSuperviseCostsPremiums(this.algorithmAmount(jqPremium, jqSuperviseCostsProportion));  //交强手续费
+                insPlyIncome.setJqSuperviseCostsProportion(jqSuperviseCostsProportion);
+
             }
             if (sySuperviseCostsProportion != null && syPremium != null) {
                 insPlyIncome.setSySuperviseCostsPremiums(this.algorithmAmount(syPremium, sySuperviseCostsProportion)); //商业手续费
+                insPlyIncome.setSySuperviseCostsProportion(sySuperviseCostsProportion);
             }
             if (noSuperviseCostsProportion != null && noPremium != null) {
                 insPlyIncome.setNoSuperviseCostsPremiums(this.algorithmAmount(noPremium, noSuperviseCostsProportion));  //非车手续费
+                insPlyIncome.setNoSuperviseCostsProportion(noSuperviseCostsProportion);
             }
             if (jqOtherCostsProportion != null && jqPremium != null) {
                 insPlyIncome.setJqOtherCostsPremium(this.algorithmAmount(jqPremium, jqOtherCostsProportion));    //交强跟单费
+                insPlyIncome.setJqOtherCostsProportion(jqOtherCostsProportion);
             }
             if (syOtherCostsProportion != null && syPremium != null) {
                 insPlyIncome.setSyOtherCostsPremium(this.algorithmAmount(syPremium, syOtherCostsProportion));  //商业跟单费
+                insPlyIncome.setSyOtherCostsProportion(syOtherCostsProportion);
             }
             if (noOtherCostsProportion != null && noPremium != null) {
                 insPlyIncome.setNoOtherCostsPremium(this.algorithmAmount(noPremium, noOtherCostsProportion));   //非车跟单费
+                insPlyIncome.setNoOtherCostsProportion(noOtherCostsProportion);
             }
-            insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
-             insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
+            insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
             insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion, sySuperviseCostsProportion,
-             noSuperviseCostsProportion));  //手续费比例
-            insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
-             insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium()));  //跟单费金额
+                    noSuperviseCostsProportion));  //手续费比例
+            insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium()));  //跟单费金额
             insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, noOtherCostsProportion));
             //跟单费比例
             insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), insPlyIncome.getOtherFeevalue(), null)); // 总费用 =  手续费+跟单费
@@ -1248,7 +1256,7 @@ handlingProportion,
             BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoPremium();// 非车手续费  按照思路  非车不含税保费* 非车手续费比例  =非车手续费
             if (jqNoTaxPremium != null && insPlyIncomeVo.getJqSuperviseCostsProportion() != null && insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
 
-                insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(syNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
+                insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(jqNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
                 insPlyIncome.setJqSuperviseCostsProportion(insPlyIncomeVo.getJqSuperviseCostsProportion());
 
             }
@@ -1279,16 +1287,12 @@ handlingProportion,
             }
 
             if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) {  //保险  手续费 =不含税保费* 手续费比例
-                insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
-                 insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
-                insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),
-                 insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
+                insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
+                insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), null, null));//总金额
             } else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险跟单费  交强跟单+商业跟单
-                insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
-                 insPlyIncome.getSyOtherCostsPremium(), null));
-                insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),
-                 insPlyIncome.getSyOtherCostsProportion(), null));
+                insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), null));
+                insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(), insPlyIncome.getSyOtherCostsProportion(), null));
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(), null, null));//总金额
             }
             if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())) {// 非车
@@ -1352,16 +1356,49 @@ handlingProportion,
         Long id = new SnowFlakeUtil().nextId();
         InsPlyIncome insPlyIncome = new InsPlyIncome();
         insPlyIncomeVo.setOrderno(id.toString());
+        String signdateStr = insPlyIncomeVo.getSignDate();
+        LocalDateTime localDateTime = this.LocalDatePareLocalDateTime(signdateStr);
+        insPlyIncomeVo.setSignDate(null);
         BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
         insPlyIncome.setUserId(BaseController.getUser().getId());
         insPlyIncome.setDocumentaryFeesStatus("0");
         insPlyIncome.setHandlingFeesStatus("0");
         insPlyIncome.setIsNotCar(insPlyIncomeVo.getIsNotCar());   // 是否是非车
         insPlyIncome.setIsNotDocumentary(insPlyIncomeVo.getIsNotDocumentary());  //是否是跟单
+        insPlyIncome.setSignDate(localDateTime);
+        insPlyIncome.setDeptId(BaseController.getUser().getDeptId());
+
+        insPlyIncome.setCreateTime(LocalDate.now());
+        insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncomeVo.getJqOtherCostsProportion(),insPlyIncomeVo.getSyOtherCostsProportion(),insPlyIncomeVo.getNoOtherCostsProportion()));
+        insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncomeVo.getJqSuperviseCostsProportion(),insPlyIncomeVo.getSySuperviseCostsProportion(),insPlyIncomeVo.getNoSuperviseCostsProportion()));
+
+        if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqSuperviseCostsProportion() != null && insPlyIncome.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqSuperviseCostsProportion()));
+        }
+        if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSySuperviseCostsProportion() != null && insPlyIncome.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setSySuperviseCostsPremiums(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSySuperviseCostsProportion()));
+        }
+        if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoSuperviseCostsProportion() != null && insPlyIncome.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setNoSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoSuperviseCostsProportion()));
+        }
+        if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqOtherCostsProportion() != null && insPlyIncome.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setJqOtherCostsPremium(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqOtherCostsProportion()));
+        }
+        if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSyOtherCostsProportion() != null && insPlyIncome.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setSyOtherCostsPremium(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSyOtherCostsProportion()));
+        }
+        if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoOtherCostsProportion() != null && insPlyIncome.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
+            insPlyIncome.setNoOtherCostsPremium(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoOtherCostsProportion()));
+        }
+        insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null));
 
+        String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();
+        insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
+        EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
+        String name = esmInsCompany.getNamesimple();   //合作名称
+        insPlyIncome.setPartnerCompaniesName(name);
         HashMap<String, Object> params = new HashMap<>();
-        params.put("companyId", insPlyIncomeVo.getCompanyId());
-        params.put("partnerCompaniesId", insPlyIncomeVo.getPartnerCompaniesId());
+        params.put("agreeId",insPlyIncomeVo.getAgreeId());
 
         PtlAgreement ptlAgreement = ptlAgreementService.selectAgreeId(params);
         if (ObjectUtils.isEmpty(ptlAgreement)) {
@@ -1373,55 +1410,59 @@ handlingProportion,
         insPlyIncomeVo.setCrudStatus("1");
         this.saveLog(insPlyIncomeVo);   //添加日志
 
-//        HashMap<String, Object> params = new HashMap<>();
-//
-//        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
-//            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
-//        }
-//        params.put("isOther","1");
-//        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
-//            params.put("year",insPlyIncomeVo.getYear());
-//        }
-//        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
-//            params.put("companyId",insPlyIncomeVo.getCompanyId());
-//        }
-//
-//        List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
-//        if(!CollectionUtils.isEmpty(list)){
-//            for (InsPlyIncome item :list){
-//                return HttpResult.ok(item.getIds());
-//            }
-//        }
         return HttpResult.ok();
     }
 
+    private LocalDateTime LocalDatePareLocalDateTime(String signdateStr) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        // 将字符串解析为LocalDate
+        LocalDate signdate = LocalDate.parse(signdateStr, formatter);
+        // 创建一个 LocalTime 对象表示中午12点
+        LocalTime noon = LocalTime.of(12, 0);
+        // 使用 LocalDate 和 LocalTime 来创建 LocalDateTime
+        return  LocalDateTime.of(signdate, noon);
+    }
+
+    /**
+     *   删除id  已开票或者已结算都不可以进行 删除
+     *    因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去查询判断 保司机构 id
+     * @param insPlyIncomeVo
+     * @return
+     */
     @Override
     @Transactional
     public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
-
         HashMap<String, Object> params = new HashMap<>();
-        if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())) {
-            params.put("isNotCar", insPlyIncomeVo.getIsNotCar());
-        }
-        params.put("isOther", "1");
-        if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
-            params.put("year", insPlyIncomeVo.getYear());
-        }
-        if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())) {
-            params.put("companyId", insPlyIncomeVo.getCompanyId());
-        }
-        baseMapper.deleteById(insPlyIncomeVo.getId());
-        insPlyIncomeVo.setCrudStatus("3");
-        this.saveLog(insPlyIncomeVo);
-        List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
-        if (!CollectionUtils.isEmpty(list)) {
-            for (InsPlyIncome item : list) {
-                return HttpResult.ok(item.getIds());
+        params.put("id",insPlyIncomeVo.getId());
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+        InsPlyIncome insPlyIncome = insPlyIncomes.get(0);
+        if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "1".equals(insPlyIncome.getAgreementType())) {
+            if ("1".equals(insPlyIncome.getHandlingFeesStatus())) {
+                throw new SystemException("已结算不可以进行删除");
+            }
+        } else if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "2".equals(insPlyIncome.getAgreementType())) {
+            if ("0".equals(insPlyIncome.getIsNotDocumentary())) {
+                String taskId = insPlyIncome.getTaskId();
+                if (StringUtils.isNotEmpty(taskId)) {
+                    throw new SystemException("已开票不能进行删除");
+                }
+            } else {
+//                因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去进行判断
+                String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();   // 保司机构id
+                if (StringUtils.isEmpty(partnerCompaniesId)) {
+                    throw new SystemException("该单据没有保司机构id");
+                }
+                LambdaQueryWrapper<SettlementDocumentaryFeesEntity> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(SettlementDocumentaryFeesEntity::getPartnerCompaniesId, partnerCompaniesId)
+                        .eq(SettlementDocumentaryFeesEntity::getSettlementStatus, "2");
+                List<SettlementDocumentaryFeesEntity> settlementDocumentaryFeesEntities = settlementDocumentaryFeesService.getBaseMapper().selectList(queryWrapper);
+                if (settlementDocumentaryFeesEntities.size() > 0) {
+                    throw new SystemException("已开票不能进行删除");
+                }
             }
-        } else {
-            return HttpResult.ok(null);
-
         }
+        baseMapper.deleteById(insPlyIncomeVo.getId());   //删除 结算  然后删除结算表
         return HttpResult.ok("删除成功");
 
     }
@@ -1505,7 +1546,7 @@ handlingProportion,
 
         String id = insPlyIncomeVo.getId();   //  开票id
         SettlementDocumentaryFeesEntity settlementDocumentaryFeesServiceById = settlementDocumentaryFeesService.getById(id);  //
-        BigDecimal allAmount = settlementDocumentaryFeesServiceById.getTotalAmount();
+        BigDecimal allAmount = settlementDocumentaryFeesServiceById.getSettlementAmount();
 
 
         HashMap<String, Object> params = new HashMap<>();
@@ -1551,6 +1592,91 @@ handlingProportion,
         return HttpResult.ok();
     }
 
+    @Override
+    public HttpResult<Object> batchSumBalance(InsPlyIncomeVo insPlyIncomeVo) {
+
+        List<InsPlyIncomeVo> multipleSelection = insPlyIncomeVo.getMultipleSelection();
+        HashMap<String, Object> params = new HashMap<>();
+        BigDecimal settleMentAmount = BigDecimal.ZERO;
+        BigDecimal settleNotMentAmount = BigDecimal.ZERO;
+        for (InsPlyIncomeVo item :  multipleSelection){
+            SettlementDocumentaryFeesEntity settlementDocumentaryFeesVo = new SettlementDocumentaryFeesEntity();
+            if(item.getSettlementAmount()  ==null  ||  item .getSettlementAmount().compareTo(BigDecimal.ZERO) <0){
+                throw new SystemException("请输入正确金额");
+            }
+            String id = item.getId();
+            SettlementDocumentaryFeesEntity settlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getBaseMapper().selectById(id);   // 开票
+            BigDecimal invoicedNotSettledAmount = settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount();//未结算金额
+            if(item.getSettlementAmount().compareTo(invoicedNotSettledAmount) >0){
+                throw new SystemException("结算金额大于未结算金额");
+            }
+            if(item.getSettlementAmount().compareTo(BigDecimal.ZERO) >0){
+                settlementDocumentaryFeesVo.setInvoiceId(settlementDocumentaryFeesEntity.getInvoicId());   //开票号
+                settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime());   //结算时间
+                settlementDocumentaryFeesVo.setSettlementStatus("2");   //2为结算状态
+                settlementDocumentaryFeesVo.setCompanyId(settlementDocumentaryFeesEntity.getCompanyId());  // 保险公司id
+                settlementDocumentaryFeesVo.setPartnerCompaniesId(settlementDocumentaryFeesEntity.getPartnerCompaniesId());  //合作公司id
+                settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount()));  //未结算金额
+                settlementDocumentaryFeesVo.setIsNotCar(settlementDocumentaryFeesEntity.getIsNotCar()); // 是否是非车
+                settlementDocumentaryFeesVo.setInvoicingMethod(settlementDocumentaryFeesEntity.getInvoicingMethod());  //开票方式
+                settlementDocumentaryFeesVo.setTaxPoints(settlementDocumentaryFeesEntity.getTaxPoints());  //税点
+                settlementDocumentaryFeesVo.setSettlementImageId(settlementDocumentaryFeesEntity.getSettlementImageId());
+                if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
+                    settlementDocumentaryFeesVo.setExpendAmount(settlementDocumentaryFeesEntity.getSettlementAmount().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
+                } else {
+                    settlementDocumentaryFeesVo.setExpendAmount(settlementDocumentaryFeesEntity.getSettlementAmount());   //进账金额
+                }
+                settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());   //进账金额
+                settlementDocumentaryFeesVo.setHandlingFeesStatus(settlementDocumentaryFeesEntity.getHandlingFeesStatus());
+                settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
+                settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
+                settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
+                settlementDocumentaryFeesVo.setAgreementType("2");  //1平台 2  保险
+
+                //       生成跟单费结算记录
+                SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
+                settlementDocumentaryLogEntity.setAmount(settlementDocumentaryFeesVo.getSettlementAmount());  // 结算金额
+                settlementDocumentaryLogEntity.setSettlementDocumentaryId(settlementDocumentaryFeesEntity.getId()); // 关联id
+                settlementDocumentaryLogEntity.setAmountType("2");  //跟单费结算
+                settlementDocumentaryLogEntity.setCreateTime(new Date());
+                settlementDocumentaryFeesVo.setSettlementSumId(insPlyIncomeVo.getSettlementSumId());
+                settlementDocumentaryFeesService.getBaseMapper().insert(settlementDocumentaryFeesVo);
+                settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
+                //修改开票金额
+
+                BigDecimal add = settlementDocumentaryFeesEntity.getInvoicedSettledAmount().add(insPlyIncomeVo.getSettlementAmount());
+                settlementDocumentaryFeesEntity.setInvoicedSettledAmount(add);
+
+                BigDecimal subtract = settlementDocumentaryFeesEntity.getTotalAmount().subtract(add);
+                settlementDocumentaryFeesEntity.setInvoicedNotSettledAmount(subtract);
+
+                if (subtract.compareTo(BigDecimal.ZERO) == 0) {
+                    settlementDocumentaryFeesEntity.setCompletionStatus("2");
+                } else if (subtract.compareTo(BigDecimal.ZERO) != 0) {
+                    settlementDocumentaryFeesEntity.setCompletionStatus("1");
+                }
+                settlementDocumentaryFeesService.updateById(settlementDocumentaryFeesEntity);
+                settleMentAmount = settleMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedSettledAmount());
+                settleNotMentAmount = settleNotMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount());
+            }
+//             更新金额
+
+
+            SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = settlementDocumentaryFeesSumService.getById(insPlyIncomeVo.getSettlementSumId());
+            settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(settleMentAmount);
+            settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(settleNotMentAmount);
+            if (settleNotMentAmount.compareTo(BigDecimal.ZERO) == 0) {
+                settlementDocumentaryFeesSumEntity.setCompletionStatus("2");
+            } else if (settleNotMentAmount.compareTo(BigDecimal.ZERO) != 0) {
+                settlementDocumentaryFeesSumEntity.setCompletionStatus("1");
+            }
+            settlementDocumentaryFeesSumService.updateById(settlementDocumentaryFeesSumEntity);
+        }
+        return null;
+    }
+
+
+
     /**
      * @param insPlyIncomeVo
      * @return
@@ -1569,7 +1695,7 @@ handlingProportion,
             BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
             BigDecimal unSettledAmount; //未结算金额
             params.put("partnerCompaniesId", item.getPartnerCompaniesId());
-
+            params.remove("handlingFeesStatus");
             List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);  //金额总数
             for (InsPlyIncome all : insPlyIncomes) {
                 commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());
@@ -1933,9 +2059,41 @@ handlingProportion,
         } else {
             settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount());
         }
+//        跟单生成批次表
+        SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
+        if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
+            settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
+        }
         return settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
     }
 
+    private SettlementDocumentaryFeesSumEntity saveSumSettlement(InsPlyIncomeVo insPlyIncomeVo) {
+        String handlingFeesStatus = insPlyIncomeVo.getHandlingFeesStatus();
+        SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = new SettlementDocumentaryFeesSumEntity();
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        if("1".equals(handlingFeesStatus)){
+            List<InsPlyIncomeVo> nowInsPlyIncomeVo = insPlyIncomeVo.getMultipleSelection();
+            for (InsPlyIncomeVo  item:  nowInsPlyIncomeVo ){
+                totalAmount =  totalAmount.add(item.getSettlementAmount()) ;
+            }
+            settlementDocumentaryFeesSumEntity.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
+            settlementDocumentaryFeesSumEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
+            settlementDocumentaryFeesSumEntity.setCreateTime(new Date());
+            settlementDocumentaryFeesSumEntity.setInvoicId(insPlyIncomeVo.getInvoicId());
+            settlementDocumentaryFeesSumEntity.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod());
+            settlementDocumentaryFeesSumEntity.setIsNotCar(insPlyIncomeVo.getIsNotCar());
+            settlementDocumentaryFeesSumEntity.setSettlementStatus("1");
+            settlementDocumentaryFeesSumEntity.setUserId(BaseController.getUser().getId());
+            settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(BigDecimal.ZERO);
+            settlementDocumentaryFeesSumEntity.setCompletionStatus("0");
+            settlementDocumentaryFeesSumEntity.setTotalAmount(totalAmount);// 开票总额
+            settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(totalAmount);
+            settlementDocumentaryFeesSumService.getBaseMapper().insert(settlementDocumentaryFeesSumEntity);
+            return settlementDocumentaryFeesSumEntity;
+        }
+        return settlementDocumentaryFeesSumEntity;
+    }
+
     @Override
     public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
         HashMap<String, Object> params = new HashMap<>();
@@ -2216,11 +2374,14 @@ handlingProportion,
     }
 
     @Override
+    @Transactional
     public HttpResult<Object> singleInvoic(InsPlyIncomeVo insPlyIncomeVo) {
 
         //  通过ids 查出跟单非结算单
         SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
         if (!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())) {
+            SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
+
             for (InsPlyIncomeVo insPlyIncomeVo1 : insPlyIncomeVo.getMultipleSelection()) {
 
                 insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
@@ -2283,6 +2444,9 @@ handlingProportion,
                     BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
                     settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
                 }
+                if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
+                    settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
+                }
                 settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
             }
         }
@@ -2477,5 +2641,21 @@ handlingProportion,
         }
         return HttpResult.ok();
     }
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/18 10:14
+     *  @Description:  通过保险公司id和状态查询平台的记录
+     */
+    @Override
+    public List<PlatformSettlementRecordDto> platformSettlementRecord(InsPlyIncomeVo insPlyIncomeVo) {
+        if(insPlyIncomeVo.getPartnerCompaniesId()==null || "".equals(insPlyIncomeVo.getPartnerCompaniesId())){
+           throw new SystemException("合作公司编码(partnerCompaniesId)不能为空");
+        }
+        if(insPlyIncomeVo.getHandlingFeesStatus()==null || "".equals(insPlyIncomeVo.getHandlingFeesStatus())){
+            throw new SystemException("结算状态 0 未结算 1已结算(handlingFeesStatus)不能为空");
+        }
+        return baseMapper.platformSettlementRecord(insPlyIncomeVo.getPartnerCompaniesId(),insPlyIncomeVo.getHandlingFeesStatus());
+    }
 
 }

+ 72 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/SettlementDocumentaryFeesSumServiceImpl.java

@@ -0,0 +1,72 @@
+package com.ydtech.modules.fnc.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.fnc.dao.SettlementDocumentaryFeesSumMapper;
+import com.ydtech.modules.fnc.entity.InsPlyIncome;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity;
+import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
+import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesSumService;
+import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesSumVo;
+import com.ydtech.modules.order.entity.BasePageResult;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.List;
+
+@Service
+public class SettlementDocumentaryFeesSumServiceImpl extends ServiceImpl<SettlementDocumentaryFeesSumMapper, SettlementDocumentaryFeesSumEntity> implements SettlementDocumentaryFeesSumService {
+    @Autowired
+    private SettlementDocumentaryFeesService settlementDocumentaryFeesService;
+
+    @Override
+    @Transactional
+    public HttpResult<Object> voidInvoicing(SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo) {
+        String id = settlementDocumentaryFeesSumVo.getId();
+        SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = baseMapper.selectById(id);
+        settlementDocumentaryFeesSumEntity.getCompletionStatus();
+        if (!"0".equals(settlementDocumentaryFeesSumEntity.getCompletionStatus())) {
+            throw new SystemException("已结算不能进行作废");
+        }
+        settlementDocumentaryFeesSumEntity.setSettlementStatus("3");  // 作废
+        baseMapper.updateById(settlementDocumentaryFeesSumEntity);
+
+
+        LambdaQueryWrapper<SettlementDocumentaryFeesEntity> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SettlementDocumentaryFeesEntity::getSettlementSumId, id);
+        List<SettlementDocumentaryFeesEntity> settlementDocumentaryFeesEntities = settlementDocumentaryFeesService.getBaseMapper().selectList(queryWrapper);
+        for (SettlementDocumentaryFeesEntity item : settlementDocumentaryFeesEntities) {
+            item.setSettlementStatus("3");
+            settlementDocumentaryFeesService.updateById(item);
+        }
+        return HttpResult.ok();
+    }
+
+    @Override
+    public HttpResult<BasePageResult<SettlementDocumentaryFeesSumEntity>> queryNew(SettlementDocumentaryFeesSumVo settlementDocumentaryFeesSumVo) {
+        try {
+            PageInfo<List<SettlementDocumentaryFeesSumEntity>> pageHelper = null;
+
+            List<SettlementDocumentaryFeesSumEntity> list = this.baseMapper.queryNew(settlementDocumentaryFeesSumVo);
+
+            pageHelper = new PageInfo(list);
+            BasePageResult<SettlementDocumentaryFeesSumEntity> pageResult = new BasePageResult<SettlementDocumentaryFeesSumEntity>(settlementDocumentaryFeesSumVo.getPageNum(),
+                    settlementDocumentaryFeesSumVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
+            return HttpResult.ok(pageResult);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return HttpResult.error("查询异常");
+        }
+    }
+}

+ 10 - 3
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -50,9 +50,8 @@ public class InsPlyIncomeVo implements Serializable {
     private LocalDate endDate;
 
 
-//    @ApiModelProperty(value = "签单日期")
-//    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-//    private LocalDate signdate;
+    @ApiModelProperty(value = "签单日期")
+    private String signDate;
 
     @ApiModelProperty(value = "创建日期")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss ", timezone = "GMT+8")
@@ -254,6 +253,9 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("非车跟单比例")
     private BigDecimal noOtherCostsProportion;
 
+    @ApiModelProperty("车船税")
+    private BigDecimal taxamount;
+
 
     @ApiModelProperty("被保人名称")
     private String insuredName;
@@ -354,6 +356,11 @@ public class InsPlyIncomeVo implements Serializable {
 
     @ApiModelProperty(value = "年度结束")
     private String yearEnd;
+    @ApiModelProperty(value = "协议id")
+    private String agreeId;
+
+    @ApiModelProperty("批次开票关联id")
+    private String settlementSumId;
 
 
 

+ 77 - 0
src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesSumVo.java

@@ -0,0 +1,77 @@
+package com.ydtech.modules.fnc.vo;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel("开票批次表")
+public class SettlementDocumentaryFeesSumVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("id")
+    private String id;
+
+
+    @ApiModelProperty("结算总金额")
+    private BigDecimal totalAmount;
+
+
+    @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date createTime;
+
+    @ApiModelProperty("保险id")
+    private String companyId;
+
+    @ApiModelProperty("是否是开票 结算")
+    private String settlementStatus;
+
+
+    @ApiModelProperty("用户")
+    private String userId;
+
+
+    @ApiModelProperty("开票方式")
+    private String invoicingMethod;
+
+
+    @ApiModelProperty("开票号")
+    private String invoicId;
+
+    @ApiModelProperty("是否是非车")
+    private String isNotCar;
+
+    @ApiModelProperty("合作公司id")
+    private String partnerCompaniesId;
+
+
+    @ApiModelProperty("已开票已结算")
+    private BigDecimal invoicedSettledAmount;
+
+    @ApiModelProperty("已开票未结算")
+    private BigDecimal InvoicedNotSettledAmount;
+
+    @ApiModelProperty("结清状态")
+    private String completionStatus;
+
+    @ApiModelProperty(value = "每页页数")
+    @Min(value = 20, message = "页数最小为20")
+    @Max(value = 100, message = "页数最大为100")
+    private int pageSize=20;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum=1;
+
+}

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

@@ -129,4 +129,8 @@ public class SettlementDocumentaryFeesVo implements Serializable {
 
     @ApiModelProperty("结清状态")
     private String completionStatus;
+
+    @ApiModelProperty("批次开票关联id")
+    private String settlementSumId;
+
 }

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

@@ -169,6 +169,11 @@ public class QuoteRespVo {
     @ApiModelProperty("商业出险次数")
     private String syClaims;
 
+    @ApiModelProperty("期望折扣")
+    private String expectedDiscount;
+
+    @ApiModelProperty("初始建议折扣")
+    private String initialProposalDiscount;
 
     public void setJqClaims(String jqClaims) {
         this.jqClaims = StringUtils.isEmpty(jqClaims) ? null : jqClaims;

+ 2 - 0
src/main/java/com/ydtech/modules/ins/model/yc/audit/Audit.java

@@ -8,6 +8,7 @@ import com.ydtech.modules.ins.model.yc.YcBuildData;
 import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
 import com.ydtech.modules.ins.model.yc.YcConfigureParameters;
 import com.ydtech.modules.order.entity.InsAreaCompany;
+import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.utils.IDCardUtils;
 import lombok.Data;
 
@@ -250,6 +251,7 @@ public class Audit {
 
         condition.setCProdNoSY(condition.getSyFlag().equals("1") ? "0364" : "");
         condition.setCProdNoJQ(condition.getJqFlag().equals("1") ? "0326" : "");
+
         condition.setQuerySequenceNoSy(iac.getSyapplyno());
         condition.setQuerySequenceNoJq(iac.getJqapplyno());
 

+ 2 - 2
src/main/java/com/ydtech/modules/ins/model/yc/ruote/Ruote.java

@@ -156,7 +156,7 @@ public class Ruote {
      * @date: 2023年02月08日 0008
      */
     public static Ruote buildQuoteParam(YaQuoteInfoVo yaQuoteInfoVo, YcConfigureParameters ycConfigureParameters,
-                                        AccidentalDrivingVo adVo) {
+                                        AccidentalDrivingVo adVo,String cQryCdeJQ,String cQryCdeSY) {
 
         Ruote m = new Ruote();
         Ruote.RequestLabel requestLabel = new Ruote.RequestLabel();
@@ -181,7 +181,7 @@ public class Ruote {
          * 车辆信息
          * 代码:vhl
          */
-        Vhl vhl = Vhl.buildVhl(carInfo, ownerInfo);
+        Vhl vhl = Vhl.buildVhl(carInfo, ownerInfo,cQryCdeJQ,cQryCdeSY);
 
         String startTime = StringUtils.isNotEmpty(base.getTInsrncBgnTmJQ()) ? base.getTInsrncBgnTmJQ() : base.getTInsrncBgnTmSY();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 4 - 1
src/main/java/com/ydtech/modules/ins/model/yc/ruote/Vhl.java

@@ -330,7 +330,7 @@ public class Vhl {
     /**
      * @description: 车辆信息
      */
-    public static Vhl buildVhl(CarInfoVo carInfo, CustomerInfoVo ownerInfo) {
+    public static Vhl buildVhl(CarInfoVo carInfo, CustomerInfoVo ownerInfo,String cQryCdeJQ,String cQryCdeSY) {
         Vhl vhl = new Vhl();
 
         //        //3 车辆信息
@@ -419,6 +419,9 @@ public class Vhl {
         vhl.setCNewMrk("1");
         //轿车
         vhl.setCRegVhlTyp(carInfo.getCartype());
+
+        vhl.setCQryCdeJQ(cQryCdeJQ);
+        vhl.setCQryCdeSY(cQryCdeSY);
         return vhl;
     }
 

+ 2 - 1
src/main/java/com/ydtech/modules/order/controller/BoHaiOrderApiController.java

@@ -70,7 +70,8 @@ public class BoHaiOrderApiController {
     @PostMapping(value = "/submitImage")
     @ApiOperation(value = "提交影像信息")
     public HttpResult<Object> submitImage(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
-        return this.boHaiOrderApiService.submitImage(companyId);
+//        return this.boHaiOrderApiService.submitImage(companyId);
+        return HttpResult.ok();
     }
 
     @AuditVerification("核保")

+ 47 - 0
src/main/java/com/ydtech/modules/order/controller/ExternalOrderController.java

@@ -0,0 +1,47 @@
+package com.ydtech.modules.order.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.ins.model.vo.QuoteRespVo;
+import com.ydtech.modules.order.aop.QuoteVerification;
+import com.ydtech.modules.order.components.InsOrdersComponents;
+import com.ydtech.modules.order.entity.vo.AccidentalDrivingVo;
+import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
+import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
+import com.ydtech.modules.order.service.InsAreaCompanyExternalPolicyService;
+import com.ydtech.modules.order.service.InsAreaCompanyService;
+import com.ydtech.modules.order.service.InsOrdersService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "外部订单 api")
+@RestController
+@RequestMapping("/api/externalOrder")
+@RequiredArgsConstructor
+public class ExternalOrderController {
+
+    @Autowired
+    private InsAreaCompanyService insAreaCompanyService;
+
+    @Autowired
+    private InsOrdersComponents insOrdersComponents;
+
+    @Autowired
+    private InsAreaCompanyExternalPolicyService insAreaCompanyExternalPolicyService;
+
+    @PostMapping("/saveSubOrder")
+    @ApiOperation("保存子订单")
+    public HttpResult<QuoteRespVo> saveSubOrder(@RequestBody BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
+        BaseQuoteInfoVo quoteInfo = this.insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId());
+        boolean result = this.insAreaCompanyService.saveSubOrder(quoteInfo, quoteVo);
+        return result ? HttpResult.ok("添加订单成功") : HttpResult.error("添加订单失败");
+    }
+
+    @GetMapping("/getPolicyPrint")
+    @ApiOperation("获取保单信息")
+    public HttpResult getPolicyPrint(@RequestParam String subOrderNo) {
+        return HttpResult.ok(this.insAreaCompanyExternalPolicyService.getPolicyByCompanyId(subOrderNo));
+    }
+}

+ 31 - 0
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyExternalFeeMapper.java

@@ -0,0 +1,31 @@
+package com.ydtech.modules.order.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.admin.model.dto.AllpremiumDto;
+import com.ydtech.modules.admin.model.dto.PremiumReportDto;
+import com.ydtech.modules.admin.model.vo.SubOrder;
+import com.ydtech.modules.order.entity.InsAreaCompany;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
+import com.ydtech.modules.order.entity.vo.OrderQueryVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author Administrator
+ * @description 针对表【ins_area_company(报价渠道)】的数据库操作Mapper
+ * @createDate 2023-01-31 15:51:19
+ * @Entity generator.domain.InsAreaCompany
+ */
+public interface InsAreaCompanyExternalFeeMapper extends BaseMapper<InsAreaCompanyExternalFee> {
+
+
+}
+
+
+
+

+ 20 - 0
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyExternalPolicyMapper.java

@@ -0,0 +1,20 @@
+package com.ydtech.modules.order.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalPolicy;
+
+/**
+ * @author Administrator
+ * @description 针对表【ins_area_company(报价渠道)】的数据库操作Mapper
+ * @createDate 2023-01-31 15:51:19
+ * @Entity generator.domain.InsAreaCompany
+ */
+public interface InsAreaCompanyExternalPolicyMapper extends BaseMapper<InsAreaCompanyExternalPolicy> {
+
+
+}
+
+
+
+

+ 65 - 0
src/main/java/com/ydtech/modules/order/entity/InsAreaCompanyExternalFee.java

@@ -0,0 +1,65 @@
+package com.ydtech.modules.order.entity;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
+import com.ydtech.modules.ins.model.vo.QuoteRespVo;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
+import com.ydtech.utils.StringUtils;
+import com.ydtech.utils.idgen.IdGenerate;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 报价渠道
+ *
+ * @TableName ins_area_company
+ */
+@TableName(value = "ins_area_company_external_fee", autoResultMap = true)
+@Data
+@ApiModel(value = "外部订单费用表")
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsAreaCompanyExternalFee implements Serializable {
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = -6827009009645748787L;
+    /**
+     * 主键
+     */
+    @TableId(value = "sub_order_no")
+    private String subOrderNo;
+
+    @TableField(value = "jq_supervise_costs_proportion")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @TableField(value = "jq_other_costs_proportion")
+    private BigDecimal jqOtherCostsProportion;
+
+    @TableField(value = "sy_supervise_costs_proportion")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @TableField(value = "sy_other_costs_proportion")
+    private BigDecimal syOtherCostsProportion;
+
+    @TableField(value = "no_supervise_costs_proportion")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @TableField(value = "no_other_costs_proportion")
+    private BigDecimal noOtherCostsProportion;
+
+}
+

+ 48 - 0
src/main/java/com/ydtech/modules/order/entity/InsAreaCompanyExternalPolicy.java

@@ -0,0 +1,48 @@
+package com.ydtech.modules.order.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 报价渠道
+ *
+ * @TableName ins_area_company
+ */
+@TableName(value = "ins_area_company_external_policy", autoResultMap = true)
+@Data
+@ApiModel(value = "外部订单保单表")
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsAreaCompanyExternalPolicy implements Serializable {
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = -6827009009645748787L;
+    /**
+     * 主键
+     */
+    @TableId(value = "sub_order_no")
+    private String subOrderNo;
+
+    @TableField(value = "jq_policy")
+    private String jqPolicy;
+
+    @TableField(value = "sy_policy")
+    private String syPolicy;
+
+    @TableField(value = "no_policy")
+    private String noPolicy;
+
+    @TableField(value = "jq_sign")
+    private String jqSign;
+
+
+}
+

+ 0 - 1
src/main/java/com/ydtech/modules/order/entity/InsDrivingIntentionInsurance.java

@@ -73,5 +73,4 @@ public class InsDrivingIntentionInsurance implements Serializable {
     @TableField(value = "request_data")
     private String requestData;
 
-
 }

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

@@ -207,6 +207,9 @@ public class InsOrders implements Serializable {
     @TableField(value = "vehicle_and_vessel_tax", typeHandler = FastjsonTypeHandler.class)
     private JSONObject vehicleAndVesselTax;
 
+    @TableField(value = "is_external")
+    private Integer isExternal;
+
     @TableField(exist = false)
     private List<InsAreaCompany> insAreaCompanyList; //子级集合
 
@@ -261,6 +264,7 @@ public class InsOrders implements Serializable {
         this.setOrderstatus(InsOrderStatusEnum.QUOTE_ING.getCode());  // 0 报价 1 待核保 2 已核保待缴费 3 核保退回 4 核保不通过
         this.setFrameno(quoteInfoVo.getCarInfo().getFrameNo());
         this.setLicenseno(quoteInfoVo.getCarInfo().getLicenseNo());
+        this.setIsExternal(quoteInfoVo.getIsExternal() != null ? quoteInfoVo.getIsExternal() : 0);
 
         // 2.1 车辆信息
         this.setCarinfo(JSON.parseObject(JSON.toJSONString(quoteInfoVo.getCarInfo())));

+ 7 - 0
src/main/java/com/ydtech/modules/order/entity/PtlAgreementNonCarProductRule.java

@@ -110,6 +110,13 @@ public class PtlAgreementNonCarProductRule implements Serializable {
     @TableField(value = "third_party_lnsurance_max")
     private String thirdPartyLnsuranceMax;
 
+    /**
+     * 产品code
+     */
+    @ApiModelProperty(value = "产品code")
+    @TableField(value = "product_code")
+    private String productCode;
+
     /**
      * 排序
      */

+ 24 - 3
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/QuotationRequest.java

@@ -59,14 +59,15 @@ public class QuotationRequest extends BoHaiBaseRequest {
                             String currentValue,
                             String orderNO,
                             CarInfoVo carInfo,
-                            List<BoHaiQuoteAccidentVo> accidentVo) {
+                            List<BoHaiQuoteAccidentVo> accidentVo,
+                            String discount) {
         this.setBaseParam(parameters, orderNO);
         this.argueSolution = "1";
         for (RiskInfoVo riskInfoVo : riskList) {
             if (InsuranceRisk.TRAFFIC.getCode().equals(riskInfoVo.getRiskCode())) {
                 this.trafficPolicy = new TrafficPolicyDTO(riskInfoVo);
             } else if (InsuranceRisk.BUSINESS.getCode().equals(riskInfoVo.getRiskCode())) {
-                this.businessPolicy = new BusinessPolicyDTO(riskInfoVo, kindList, currentValue, carInfo);
+                this.businessPolicy = new BusinessPolicyDTO(riskInfoVo, kindList, currentValue, carInfo, discount);
             }
         }
         this.unAutos = accidentVo.stream().map(UnAutoDTO::new).collect(Collectors.toList());
@@ -150,10 +151,30 @@ public class QuotationRequest extends BoHaiBaseRequest {
         @JsonProperty("endDate")
         private String endDate;
 
-        public BusinessPolicyDTO(RiskInfoVo riskInfoVo, List<KindInfoVo> kindList, String currentValue, CarInfoVo carInfo) {
+        @JsonProperty("floatingRateOption")
+        private FloatingRateOptionDTO floatingRateOption;
+
+
+        public BusinessPolicyDTO(RiskInfoVo riskInfoVo, List<KindInfoVo> kindList, String currentValue, CarInfoVo carInfo, String floatingRate) {
             this.startDate = riskInfoVo.getStartDate();
             this.endDate = riskInfoVo.getEndDate();
             this.coverages = CoveragesDTO.toCoveragesDTOList(kindList, currentValue, carInfo);
+            this.floatingRateOption = new FloatingRateOptionDTO(floatingRate);
+        }
+
+
+        @NoArgsConstructor
+        @Data
+        public static class FloatingRateOptionDTO implements Serializable {
+
+            private static final long serialVersionUID = 7069606640083303229L;
+
+            @JsonProperty("floatingRate")
+            private String floatingRate;
+
+            public FloatingRateOptionDTO(String floatingRate) {
+                this.floatingRate = floatingRate;
+            }
         }
 
         @NoArgsConstructor

+ 31 - 0
src/main/java/com/ydtech/modules/order/entity/api/bohai/response/QuotationResponse.java

@@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.List;
 
 @EqualsAndHashCode(callSuper = true)
@@ -180,6 +181,36 @@ public class QuotationResponse extends BoHaiBaseResponse {
             @JsonProperty("errorMsg")
             private String errorMsg;
 
+            @JsonProperty("floatingRateOption")
+            private FloatingRateOptionDTO floatingRateOption;
+
+
+            @NoArgsConstructor
+            @Data
+            public static class FloatingRateOptionDTO implements Serializable {
+
+                private static final long serialVersionUID = -4148788116305981598L;
+
+                @JsonProperty("maxFloatingRate")
+                private String maxFloatingRate;
+
+                @JsonProperty("minFloatingRate")
+                private String minFloatingRate;
+
+                @JsonProperty("floatingRate")
+                private String floatingRate;
+
+                @JsonProperty("nonClaimDiscountRate")
+                private String nonClaimDiscountRate	;
+
+                @JsonProperty("trafficTransgressRate")
+                private String trafficTransgressRate;
+
+                @JsonProperty("adjustFactor")
+                private String adjustFactor;
+            }
+
+
             @NoArgsConstructor
             @Data
             public static class CoveragesDTO implements Serializable {

+ 5 - 0
src/main/java/com/ydtech/modules/order/entity/dto/InsAreaCompanyQueryDto.java

@@ -12,4 +12,9 @@ public class InsAreaCompanyQueryDto extends InsAreaCompany {
 
     private String agreementName;
 
+    /**
+     * 是否外部订单
+     */
+    private Integer isExternal;
+
 }

+ 3 - 0
src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteInfoVo.java

@@ -24,6 +24,9 @@ public class BaseQuoteInfoVo extends YaQuoteInfoVo {
     @ApiModelProperty("代客录单用-实际业务归属人")
     private String userId;
 
+    @ApiModelProperty("是否外部订单")
+    private Integer isExternal;
+
     public BaseQuoteInfoVo() {
     }
 

+ 57 - 0
src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteVo.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 @Data
 @ApiModel(value = "报价实体")
 public class BaseQuoteVo<T> {
@@ -52,4 +54,59 @@ public class BaseQuoteVo<T> {
     @ApiModelProperty("协议是否默认1.为是,其他为否")
     private String isTaxSource;
 
+
+    // 24-06-12 新增 外部订单录入字段
+
+    @ApiModelProperty("交强保单号")
+    private String jqpolicyno;
+
+    @ApiModelProperty("交强保单")
+    private String jqPolicy;
+
+    @ApiModelProperty("商业保单")
+    private String syPolicy;
+
+    @ApiModelProperty("非车保单")
+    private String noPolicy;
+
+    @ApiModelProperty("交强电子标志")
+    private String jqSign;
+
+
+    @ApiModelProperty("商业保单号")
+    private String sypolicyno;
+
+    @ApiModelProperty("驾意保单号")
+    private String jypolicyno;
+
+    @ApiModelProperty("交强险费用")
+    private BigDecimal jqpremium;
+
+    @ApiModelProperty("商业险费用")
+    private BigDecimal sypremium;
+
+    @ApiModelProperty("驾意险费用")
+    private BigDecimal jypremium;
+
+    @ApiModelProperty("车船税")
+    private BigDecimal taxamount;
+
+    @ApiModelProperty("交强险手续费比例")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @ApiModelProperty("商业险手续费比例")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @ApiModelProperty("非车手续费比例")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @ApiModelProperty("交强险其他费用比例")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业险其他费用比例")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("非车其他费用比例")
+    private BigDecimal noOtherCostsProportion;
+
 }

+ 11 - 0
src/main/java/com/ydtech/modules/order/entity/vo/InsDrivingIntentionInsuranceVo.java

@@ -3,6 +3,8 @@ package com.ydtech.modules.order.entity.vo;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
 import com.ydtech.modules.order.entity.InsDrivingIntentionInsurance;
 import com.ydtech.modules.order.entity.InsDrivingIntentionInsuranceSon;
 import io.swagger.annotations.ApiModelProperty;
@@ -68,6 +70,15 @@ public class InsDrivingIntentionInsuranceVo {
     @ApiModelProperty(value = "份数")
     private Integer quantity;
 
+    /**
+     * risk  king
+     */
+    @ApiModelProperty(value = "risks")
+    private List<RiskInfoVo> risks;
+
+    @ApiModelProperty(value = "kinds")
+    private List<KindInfoVo> kinds;
+
     /**
      * children对象
      */

+ 10 - 0
src/main/java/com/ydtech/modules/order/entity/vo/NoCarInsuranceQueryVo.java

@@ -1,8 +1,12 @@
 package com.ydtech.modules.order.entity.vo;
 
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 驾意险的查询VO
  */
@@ -29,4 +33,10 @@ public class NoCarInsuranceQueryVo {
 
     @ApiModelProperty(value = "规则三者保额")
     private String ruleThirdPartyInsurance;
+
+    @ApiModelProperty(value = "risk")
+    private List<RiskInfoVo> risk;
+
+    @ApiModelProperty(value = "kind")
+    private List<KindInfoVo> kind;
 }

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

@@ -498,4 +498,7 @@ public class OrderVo implements Serializable {
     @ApiModelProperty(value = "api类型")
     private int apiType;
 
+    @ApiModelProperty(value = "是否是外部订单")
+    private Integer isExternal;
+
 }

+ 24 - 0
src/main/java/com/ydtech/modules/order/service/InsAreaCompanyExternalFeeService.java

@@ -0,0 +1,24 @@
+package com.ydtech.modules.order.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.modules.order.entity.InsAreaCompany;
+import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
+import com.ydtech.modules.order.entity.vo.*;
+import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ * @description 针对表【ins_area_company_external_fee】的数据库操作Service
+ * @createDate 2023-01-31 15:51:19
+ */
+public interface InsAreaCompanyExternalFeeService extends IService<InsAreaCompanyExternalFee> {
+
+
+}

+ 16 - 0
src/main/java/com/ydtech/modules/order/service/InsAreaCompanyExternalPolicyService.java

@@ -0,0 +1,16 @@
+package com.ydtech.modules.order.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalPolicy;
+
+/**
+ * @author Administrator
+ * @description 针对表【ins_area_company_external_fee】的数据库操作Service
+ * @createDate 2023-01-31 15:51:19
+ */
+public interface InsAreaCompanyExternalPolicyService extends IService<InsAreaCompanyExternalPolicy> {
+
+    InsAreaCompanyExternalPolicy getPolicyByCompanyId(String companyId);
+
+}

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

@@ -8,8 +8,7 @@ import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
 import com.ydtech.modules.order.entity.InsAreaCompanyPosition;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
-import com.ydtech.modules.order.entity.vo.OrderQueryVo;
-import com.ydtech.modules.order.entity.vo.OrderVo;
+import com.ydtech.modules.order.entity.vo.*;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 
 import java.util.List;
@@ -128,4 +127,10 @@ public interface InsAreaCompanyService extends IService<InsAreaCompany> {
      *  @Description:  通过类型查询数据
      */
     InsOrders selectByInFeeOrderNewByType(InsFeeOrderNew insFeeOrderNew, String type);
+
+    /**
+     * 保存子订单信息
+     * @return
+     */
+    boolean saveSubOrder(BaseQuoteInfoVo quoteInfo, BaseQuoteVo<AccidentalDrivingVo> quoteVo);
 }

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

@@ -42,6 +42,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -140,8 +141,10 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         // 车辆实际价值
         String currentValue = vehicleConfirmationResponse.getData().getVehicleModels().get(0).getCurrentValue();
         // 4. 报价接口
+        String discount = quoteVo.getDiscount();
+
         QuotationRequest quotationRequest = new QuotationRequest(parameters, quoteInfoVo.getRiskList(), quoteInfoVo.getKindList(),
-                currentValue, orderNo, carInfo, quoteVo.getAccidentalDrivingVo());
+                currentValue, orderNo, carInfo, quoteVo.getAccidentalDrivingVo(), discount);
         QuotationResponse response = boHaiRequestApiComponent.quotation(quotationRequest, parameters.getSysSourceCode());
         //商业险重复投保  重复投保保单信息 :保单号:314042303060007485车牌号:晋A881SR车架号:LMGAC1381K1535834发动机号:F699317保险公司代码:YAIC签单日期:20230414起保日期:202305030000
         // 终保日期:202405030000险别:机动车第三者责任保险,附加医保外用药责任险(机动车第三者责任保险)
@@ -208,7 +211,7 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
      */
     private QuotationResponse getQuotationResponseNew(BaseQuoteInfoVo quoteInfoVo, BaseQuoteVo<List<BoHaiQuoteAccidentVo>> quoteVo,
                                                       BoHaiConfigureParameters parameters, String orderNo, CarInfoVo carInfo,
-                                                      String currentValue, QuotationResponse response) throws Exception {
+                                                      String currentValue, QuotationResponse response, String discount) throws Exception {
         VehicleCheckCodeRequest vehicleCheckCodeRequest = new VehicleCheckCodeRequest(parameters, orderNo, carInfo.getVinNo(),
                 carInfo.getEngineNo(), carInfo.getLicenseNo());
         VehicleCheckCodeResponse vehicleCheckCodeResponse = boHaiRequestApiComponent.getVehicleCheckCode(vehicleCheckCodeRequest,
@@ -217,7 +220,7 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
             String checkCode = vehicleCheckCodeResponse.getData().getCheckCode();
             //重新报价
             QuotationRequest quotationRequestNew = new QuotationRequest(parameters, quoteInfoVo.getRiskList(), quoteInfoVo.getKindList(),
-                    currentValue, orderNo, carInfo, quoteVo.getAccidentalDrivingVo());
+                    currentValue, orderNo, carInfo, quoteVo.getAccidentalDrivingVo(), discount);
             List<QuotationRequest.CheckInfoDTO> checkInfoList = new ArrayList<QuotationRequest.CheckInfoDTO>();
             QuotationRequest.CheckInfoDTO checkInfo = new QuotationRequest.CheckInfoDTO("2", checkCode, "N");
             checkInfoList.add(checkInfo);
@@ -608,7 +611,6 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
                 kindList1.add(kind);
             }
         }
-
         quoteRespVo.setKindList(kindList1);
 
         List<RiskInfoVo> riskList = yaQuoteInfoVo.getRiskList();
@@ -617,6 +619,12 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
         if (!ObjectUtils.isEmpty(unAutoPremium)) {
             jyPremium = StringUtils.isEmpty(unAutoPremium.getPremium()) ? 0 : Double.parseDouble(unAutoPremium.getPremium());
         }
+
+        // 保费浮动项信息
+        QuotationResponse.DataDTO.BusinessPolicyDTO.FloatingRateOptionDTO floatingRateOption = response.getData().getBusinessPolicy().getFloatingRateOption();
+        quoteRespVo.setExpectedDiscount(floatingRateOption.getAdjustFactor());
+        quoteRespVo.setInitialProposalDiscount(floatingRateOption.getNonClaimDiscountRate());
+
         //  报价险种放入保费
         List<QuoteRiskRespVo> riskList1 = QuoteRiskRespVo.toQuoteRiskRespVoList(riskList, jqPremium, syPremium);
 

+ 60 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyExternalFeeServiceImpl.java

@@ -0,0 +1,60 @@
+package com.ydtech.modules.order.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.dict.FeeAuditAuditstatus;
+import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
+import com.ydtech.modules.fnc.service.InsFeeAuditService;
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
+import com.ydtech.modules.message.constants.MessageTypeConstants;
+import com.ydtech.modules.message.service.MessageSecretaryService;
+import com.ydtech.modules.order.dao.InsAreaCompanyExternalFeeMapper;
+import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
+import com.ydtech.modules.order.dao.InsOrdersMapper;
+import com.ydtech.modules.order.entity.InsAreaCompany;
+import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
+import com.ydtech.modules.order.entity.vo.*;
+import com.ydtech.modules.order.service.*;
+import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.service.PtlAgreementService;
+import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
+import com.ydtech.modules.protocols.entity.vo.AgreementProductQueryVo;
+import com.ydtech.modules.protocols.service.PtlAgreementProductCostsNewService;
+import com.ydtech.utils.idgen.IdGenerate;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.util.*;
+
+/**
+ * @author Administrator
+ * @description 针对表【InsAreaCompanyExternalFee(报价渠道)】的数据库操作Service实现
+ * @createDate 2023-01-31 15:51:19
+ */
+@Service
+public class InsAreaCompanyExternalFeeServiceImpl extends ServiceImpl<InsAreaCompanyExternalFeeMapper, InsAreaCompanyExternalFee>
+        implements InsAreaCompanyExternalFeeService {
+
+
+}
+
+
+
+

+ 33 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyExternalPolicyServiceImpl.java

@@ -0,0 +1,33 @@
+package com.ydtech.modules.order.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.order.dao.InsAreaCompanyExternalFeeMapper;
+import com.ydtech.modules.order.dao.InsAreaCompanyExternalPolicyMapper;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalFee;
+import com.ydtech.modules.order.entity.InsAreaCompanyExternalPolicy;
+import com.ydtech.modules.order.service.InsAreaCompanyExternalFeeService;
+import com.ydtech.modules.order.service.InsAreaCompanyExternalPolicyService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Administrator
+ * @description 针对表【InsAreaCompanyExternalFee(报价渠道)】的数据库操作Service实现
+ * @createDate 2023-01-31 15:51:19
+ */
+@Service
+public class InsAreaCompanyExternalPolicyServiceImpl extends ServiceImpl<InsAreaCompanyExternalPolicyMapper, InsAreaCompanyExternalPolicy>
+        implements InsAreaCompanyExternalPolicyService {
+
+
+    @Override
+    public InsAreaCompanyExternalPolicy getPolicyByCompanyId(String companyId) {
+        InsAreaCompanyExternalPolicy insAreaCompanyExternalPolicy = baseMapper.selectOne(new LambdaQueryWrapper<InsAreaCompanyExternalPolicy>()
+                .eq(InsAreaCompanyExternalPolicy::getSubOrderNo, companyId));
+        return insAreaCompanyExternalPolicy;
+    }
+}
+
+
+
+

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

@@ -1,6 +1,7 @@
 package com.ydtech.modules.order.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -9,6 +10,7 @@ import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
 import com.ydtech.modules.fnc.service.InsFeeAuditService;
 import com.ydtech.modules.ins.model.vo.KindInfoVo;
 import com.ydtech.modules.ins.model.vo.RiskInfoVo;
@@ -16,19 +18,16 @@ import com.ydtech.modules.message.constants.MessageTypeConstants;
 import com.ydtech.modules.message.service.MessageSecretaryService;
 import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
 import com.ydtech.modules.order.dao.InsOrdersMapper;
-import com.ydtech.modules.order.entity.InsAreaCompany;
-import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
-import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.*;
 import com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto;
-import com.ydtech.modules.order.entity.vo.OrderQueryVo;
-import com.ydtech.modules.order.entity.vo.OrderVo;
-import com.ydtech.modules.order.service.InsAreaCompanyAccidentalDrivingService;
-import com.ydtech.modules.order.service.InsAreaCompanyService;
-import com.ydtech.modules.order.service.InsOrdersService;
-import com.ydtech.modules.order.service.InsOrdersTrackService;
+import com.ydtech.modules.order.entity.vo.*;
+import com.ydtech.modules.order.service.*;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
+import com.ydtech.modules.protocols.entity.vo.AgreementProductQueryVo;
+import com.ydtech.modules.protocols.service.PtlAgreementProductCostsNewService;
 import com.ydtech.utils.idgen.IdGenerate;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,11 +36,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.YearMonth;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * @author Administrator
@@ -71,6 +70,18 @@ public class InsAreaCompanyServiceImpl extends ServiceImpl<InsAreaCompanyMapper,
     @Autowired
     private MessageSecretaryService messageSecretaryService;
 
+    @Autowired
+    private FeeRuleSchemeNewService feeRuleSchemeNewService;
+
+    @Autowired
+    private PtlAgreementProductCostsNewService ptlAgreementProductCostsNewService;
+
+    @Autowired
+    private InsAreaCompanyExternalFeeService insAreaCompanyExternalFeeService;
+
+    @Autowired
+    private InsAreaCompanyExternalPolicyService insAreaCompanyExternalPolicyService;
+
     public InsAreaCompanyServiceImpl(@Lazy InsOrdersService insOrdersService, InsOrdersTrackService insOrdersTrackService) {
         this.insOrdersService = insOrdersService;
         this.insOrdersTrackService = insOrdersTrackService;
@@ -372,6 +383,150 @@ public class InsAreaCompanyServiceImpl extends ServiceImpl<InsAreaCompanyMapper,
         params.put("type", type);
         return baseMapper.selectSecondPromotionByNew(params);
     }
+
+    private BaseQuoteVo<AccidentalDrivingVo> checkQuoteVo(BaseQuoteVo<AccidentalDrivingVo> quoteVo){
+        if(quoteVo.getJqpremium() == null){
+            quoteVo.setJqpremium(new BigDecimal(0));
+        }
+        if(quoteVo.getSypremium() == null){
+            quoteVo.setSypremium(new BigDecimal(0));
+        }
+        if(quoteVo.getJypremium() == null){
+            quoteVo.setJypremium(new BigDecimal(0));
+        }
+        if(quoteVo.getTaxamount() == null){
+            quoteVo.setTaxamount(new BigDecimal(0));
+        }
+        if(quoteVo.getJqSuperviseCostsProportion() == null){
+            quoteVo.setJqSuperviseCostsProportion(new BigDecimal(0));
+        }
+        if(quoteVo.getJqOtherCostsProportion() == null){
+            quoteVo.setJqOtherCostsProportion(new BigDecimal(0));
+        }
+        if(quoteVo.getSySuperviseCostsProportion() == null){
+            quoteVo.setSySuperviseCostsProportion(new BigDecimal(0));
+        }
+        if(quoteVo.getSyOtherCostsProportion() == null){
+            quoteVo.setSyOtherCostsProportion(new BigDecimal(0));
+        }
+        if(quoteVo.getNoSuperviseCostsProportion() == null){
+            quoteVo.setNoSuperviseCostsProportion(new BigDecimal(0));
+        }
+        if(quoteVo.getNoOtherCostsProportion() == null){
+            quoteVo.setNoOtherCostsProportion(new BigDecimal(0));
+        }
+        return quoteVo;
+    }
+
+    @Override
+    @Transactional
+    public boolean saveSubOrder(BaseQuoteInfoVo quoteInfo, BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
+        InsOrders insOrders = insOrdersService.getById(quoteInfo.getOrderNo());
+        PtlAgreement byAgreementIdNew = ptlAgreementService.getByAgreementIdNew(quoteVo.getAgreementId());
+        quoteVo = checkQuoteVo(quoteVo);
+
+        //通过协议id 查询费用
+        PtlAgreement ptlAgreement = ptlAgreementService.getById(quoteVo.getAgreementId());
+
+        //查找协议的费用
+        AgreementProductQueryVo agreementProductQueryVo = new AgreementProductQueryVo();
+        List<String> productId = new ArrayList<>();
+        productId.add(insOrders.getProductid());
+        agreementProductQueryVo.setProductCode(productId);
+        agreementProductQueryVo.setIsAudit("1");
+        agreementProductQueryVo.setAgreementId(ptlAgreement.getId());
+
+        List<PtlAgreementProductCostsNew> costsNews = ptlAgreementProductCostsNewService.getByAgreementId(agreementProductQueryVo);
+
+        if(costsNews.isEmpty())
+        {
+            throw new SystemException("没有找到费用信息");
+        }
+
+        InsAreaCompany insAreaCompany = new InsAreaCompany();
+        String subOrderNo = IdGenerate.nextId();
+        insAreaCompany.setId(subOrderNo);
+        insAreaCompany.setOrderno(quoteVo.getOrderNo());
+        insAreaCompany.setAgreementId(quoteVo.getAgreementId());
+        //设置时间
+        insAreaCompany.setJqStartDate(insOrders.getJqstartdate());
+        insAreaCompany.setJqEndDate(insOrders.getJqenddate());
+        insAreaCompany.setSyStartDate(insOrders.getSystartdate());
+        insAreaCompany.setSyEndDate(insOrders.getSyenddate());
+
+        //设置为已承保状态
+        insAreaCompany.setOrderstatus(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode());
+        insAreaCompany.setCompanyId(byAgreementIdNew.getInsuranceCompanyId());
+        insAreaCompany.setInscompany(byAgreementIdNew.getInsuranceCompany());
+        //保单号
+        insAreaCompany.setJqpolicyno(quoteVo.getJqpolicyno());
+        insAreaCompany.setSypolicyno(quoteVo.getSypolicyno());
+        JSONArray noPolicyno = new JSONArray();
+        JSONObject noPolicy = new JSONObject();
+        noPolicy.put("application", quoteVo.getNoPolicy());
+        noPolicyno.add(noPolicyno);
+        insAreaCompany.setCrossInsurance(noPolicyno);
+
+        insAreaCompany.setRiskinfo(insOrders.getRisk());
+        insAreaCompany.setKindinfo(insOrders.getKing());
+
+        //设置保费
+        insAreaCompany.setJqpremium(quoteVo.getJqpremium());
+        insAreaCompany.setSypremium(quoteVo.getSypremium());
+        insAreaCompany.setJypremium(quoteVo.getJypremium());
+        insAreaCompany.setTaxamount(quoteVo.getTaxamount());
+        insAreaCompany.setSumpremium(insAreaCompany.getJqpremium()
+                        .add(insAreaCompany.getSypremium())
+                        .add(insAreaCompany.getJypremium())
+                        .add(insAreaCompany.getTaxamount()));
+
+        insAreaCompany.setOperatorId(BaseController.getUser().getId());
+        insAreaCompany.setOperatorName(BaseController.getUser().getName());
+        insAreaCompany.setOperatorTime(new Date());
+
+        insAreaCompany.setCreatetime(LocalDateTime.now());
+
+        //保存子订单
+        this.insertCompanyAndOrders(insAreaCompany);
+
+        //保存费用比例
+        InsAreaCompanyExternalFee insAreaCompanyExternalFee = new InsAreaCompanyExternalFee();
+        insAreaCompanyExternalFee.setSubOrderNo(subOrderNo);
+        insAreaCompanyExternalFee.setJqSuperviseCostsProportion(quoteVo.getJqSuperviseCostsProportion());
+        insAreaCompanyExternalFee.setJqOtherCostsProportion(quoteVo.getJqOtherCostsProportion());
+        insAreaCompanyExternalFee.setSySuperviseCostsProportion(quoteVo.getSySuperviseCostsProportion());
+        insAreaCompanyExternalFee.setSyOtherCostsProportion(quoteVo.getSyOtherCostsProportion());
+        insAreaCompanyExternalFee.setNoSuperviseCostsProportion(quoteVo.getNoSuperviseCostsProportion());
+        insAreaCompanyExternalFee.setNoOtherCostsProportion(quoteVo.getNoOtherCostsProportion());
+        this.insAreaCompanyExternalFeeService.save(insAreaCompanyExternalFee);
+
+
+        //保存保单
+        InsAreaCompanyExternalPolicy insAreaCompanyExternalPolicy = new InsAreaCompanyExternalPolicy();
+        insAreaCompanyExternalPolicy.setSubOrderNo(subOrderNo);
+        insAreaCompanyExternalPolicy.setJqPolicy(quoteVo.getJqPolicy());
+        insAreaCompanyExternalPolicy.setSyPolicy(quoteVo.getSyPolicy());
+        insAreaCompanyExternalPolicy.setNoPolicy(quoteVo.getNoPolicy());
+        insAreaCompanyExternalPolicy.setJqSign(quoteVo.getJqSign());
+        this.insAreaCompanyExternalPolicyService.save(insAreaCompanyExternalPolicy);
+
+
+
+        costsNews.get(0).setJqCarCostsProportion(quoteVo.getJqSuperviseCostsProportion().toString());
+        costsNews.get(0).setJqCarOtherCostsProportion(quoteVo.getJqOtherCostsProportion().toString());
+        costsNews.get(0).setSyCarCostsProportion(quoteVo.getSySuperviseCostsProportion().toString());
+        costsNews.get(0).setSyCarOtherCostsProportion(quoteVo.getSyOtherCostsProportion().toString());
+        costsNews.get(0).setNoCarCostsProportion(quoteVo.getNoSuperviseCostsProportion().toString());
+        costsNews.get(0).setNoCarOtherCostsProportion(quoteVo.getNoOtherCostsProportion().toString());
+
+        //计算费用
+        feeRuleSchemeNewService.calcCostsExternal(costsNews.get(0),insAreaCompany);
+
+        //审核表数据插入
+        insFeeAuditService.saveDefaultInsFeeAuditAndHistory(insAreaCompany.getOrderno(), insAreaCompany.getId(), FeeAuditAuditstatus.UNREVICEWED.getCode());
+
+        return true;
+    }
 }
 
 

+ 4 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsDrivingIntentionInsuranceServiceImpl.java

@@ -2,6 +2,8 @@ package com.ydtech.modules.order.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.InsuranceRisk;
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
 import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceMapper;
 import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceSonMapper;
@@ -98,6 +100,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
     @Override
     public List<InsDrivingIntentionInsuranceVo> getInsDrivingIntentionInsuranceRule(NoCarInsuranceQueryVo insuranceVo) {
         LambdaQueryWrapper<PtlAgreementNonCarProductRule> query = new LambdaQueryWrapper<PtlAgreementNonCarProductRule>();
+        ProductsType productType = InsuranceRisk.determineInsuranceInformation(insuranceVo.getKind(), insuranceVo.getRisk());
         if(insuranceVo.getCompanyCode() != null){
             List<PtlAgreement> byCompanyCode = ptlAgreementService.getByCompanyCode(insuranceVo.getCompanyCode());
             List<String> collect = byCompanyCode.stream().map(x -> x.getId()).collect(Collectors.toList());
@@ -111,6 +114,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
         query.le(PtlAgreementNonCarProductRule::getSeatNumMin, insuranceVo.getRuleSeatNum());
         query.ge(PtlAgreementNonCarProductRule::getSeatNumMax, insuranceVo.getRuleSeatNum());
         query.eq(PtlAgreementNonCarProductRule::getUseNature, insuranceVo.getRuleUseNature());
+        query.eq(PtlAgreementNonCarProductRule::getProductCode, productType.getCode());
         if(insuranceVo.getRuleThirdPartyInsurance() != null) {
             query.ge(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMin, insuranceVo.getRuleThirdPartyInsurance());
             query.le(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMax, insuranceVo.getRuleThirdPartyInsurance());

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

@@ -285,9 +285,11 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
                 daikeFlag = true;
             }
         }
-        //添加后线人员不能报价的验证
-        if(!"admin".equals(realUserId) && !realUserId.contains("M")){
-            throw new SystemException("后线人员不允许报价!!");
+        if(quoteInfoVo.getIsExternal() == null) {
+            //添加后线人员不能报价的验证
+            if (!"admin".equals(realUserId) && !realUserId.contains("M")) {
+                throw new SystemException("后线人员不允许报价!!");
+            }
         }
         // 1. 验证订单参数
         orderComponents.checkEmpty(quoteInfoVo);

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

@@ -43,7 +43,11 @@ public class PtlAgreementNonCarProductRuleServiceImpl extends ServiceImpl<PtlAgr
             wrapper.eq(PtlAgreementNonCarProductRule::getId, drivingInsuranceQueryVo.getId());
         }
         if(drivingInsuranceQueryVo.getAgreementId() != null){
-            wrapper.eq(PtlAgreementNonCarProductRule::getAgreementId, drivingInsuranceQueryVo.getAgreementId());
+            //查找保险公司所有的协议非车信息
+            PtlAgreement byAgreementIdNew = ptlAgreementService.getByAgreementIdNew(drivingInsuranceQueryVo.getAgreementId());
+            List<PtlAgreement> byCompanyCode = ptlAgreementService.getByCompanyCode(byAgreementIdNew.getInsuranceCompanyId());
+            List<String> agreementIds = byCompanyCode.stream().map(PtlAgreement::getId).collect(Collectors.toList());
+            wrapper.in(PtlAgreementNonCarProductRule::getAgreementId, agreementIds);
         }
         if(drivingInsuranceQueryVo.getRuleStartTime() != null && drivingInsuranceQueryVo.getRuleEndTime() != null){
             wrapper.ge(PtlAgreementNonCarProductRule::getRuleStartDate, drivingInsuranceQueryVo.getRuleStartTime());

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

@@ -71,6 +71,7 @@ import com.ydtech.modules.order.service.InsOrdersService;
 import com.ydtech.modules.order.service.InsTaskImagesService;
 import com.ydtech.modules.order.service.YongchengOrderApiService;
 import com.ydtech.modules.order.utils.InsuranceLog;
+import com.ydtech.modules.protocol.entity.constants.PtlApiType;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.DateTimeUtil;
 import com.ydtech.utils.StringUtils;
@@ -101,6 +102,12 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
 
     private static final Logger log = LoggerFactory.getLogger("alltrust");
 
+    private String REDIS_YONGCHENG_QUERY_CODE_JQ = "REDIS_YONGCHENG_QUERY_CODE_JQ:";
+
+    private String REDIS_YONGCHENG_QUERY_CODE_SY = "REDIS_YONGCHENG_QUERY_CODE_SY:";
+
+    private Integer REDIS_YONGCHENG_QUERY_CODE_EXPIRE = 7;
+
     @Value("${upload.file.path}")
     private String uploadFilePath;
 
@@ -227,8 +234,12 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         gainVehicleModel(ycConfigureParameters, carInfo, coreModelsVo);
         AccidentalDrivingVo adVo = quoteVo.getAccidentalDrivingVo();
 
+        //获取查询码
+        String cQryCdeJQ = redisTemplate.opsForValue().get(REDIS_YONGCHENG_QUERY_CODE_JQ +  yaQuoteInfoVo.getUserId() + carInfo.getVinNo() + carInfo.getLicenseNo());
+        String cQryCdeSY = redisTemplate.opsForValue().get(REDIS_YONGCHENG_QUERY_CODE_SY + yaQuoteInfoVo.getUserId() + carInfo.getVinNo() + carInfo.getLicenseNo());
+
         //组装参数
-        Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, adVo);
+        Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, adVo,cQryCdeJQ,cQryCdeSY);
         //构造地区
         buildRegion(m, yaQuoteInfoVo);
         return m;
@@ -242,15 +253,31 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
      * @return
      * @throws JsonProcessingException
      */
-    private RuoteResponse getResponse(Ruote m, String vinNo, List<String> requestInfoList) throws JsonProcessingException {
+    private RuoteResponse getResponse(Ruote m, String vinNo, List<String> requestInfoList,BaseQuoteInfoVo yaQuoteInfoVo) throws JsonProcessingException {
         boolean boo;
         RuoteResponse rr = yongchengRequestApiComponents.newPremiumXnyCalculation(m);
+        //存储 报价返回的查询码  交强和商业
+        if(rr.getVhl() != null) {
+            if(rr.getVhl().getCQryCdeJQ() != null) {
+                redisTemplate.opsForValue().set(REDIS_YONGCHENG_QUERY_CODE_JQ + yaQuoteInfoVo.getUserId() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo(),
+                        rr.getVhl().getCQryCdeJQ(), REDIS_YONGCHENG_QUERY_CODE_EXPIRE, TimeUnit.DAYS);
+            }
+            if(rr.getVhl().getCQryCdeSY() != null) {
+                redisTemplate.opsForValue().set(REDIS_YONGCHENG_QUERY_CODE_SY + yaQuoteInfoVo.getUserId() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo(),
+                        rr.getVhl().getCQryCdeSY(), REDIS_YONGCHENG_QUERY_CODE_EXPIRE, TimeUnit.DAYS);
+            }
+        }
+
+        //重新设置 请求的查询码
+        //读取缓存的查询码
+        String cQryCdeJQ = redisTemplate.opsForValue().get(REDIS_YONGCHENG_QUERY_CODE_JQ + yaQuoteInfoVo.getUserId() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo());
+        String cQryCdeSY = redisTemplate.opsForValue().get(REDIS_YONGCHENG_QUERY_CODE_SY + yaQuoteInfoVo.getUserId() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo());
         //交强
         m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ("");
-        m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ("");
+        m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(cQryCdeJQ);
         //商业
         m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY("");
-        m.getRequestLabel().getCondition().getVhl().setCQryCdeSY("");
+        m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(cQryCdeSY);
 
         if ("009999".equals(rr.getHead().getErrorCode()) && (rr.getHead().getErrorMessage().contains("车主") || rr.getHead().getErrorMessage().contains("投保人") || rr.getHead().getErrorMessage().contains("被保人"))) {
             return rr;
@@ -263,8 +290,16 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         if (rr.getHead().getErrorCode().equals("009999") && errorMsg.contains("重复投保")) {
             // 商业险
             boolean appSYFlag = "Y".equals(m.getRequestLabel().getCondition().getBase().getAppSYFlag());
+
             // 交强险
             boolean cAppJqFlag = "Y".equals(m.getRequestLabel().getCondition().getBase().getCAppJqFlag());
+            if(rr.getVhl() != null) {
+                m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(rr.getVhl().getCQryCdeJQ());
+                m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(rr.getVhl().getCQryCdeSY());
+            }else{
+                m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ("");
+                m.getRequestLabel().getCondition().getVhl().setCQryCdeSY("");
+            }
 
             if (errorMsg.contains("机动车综合商业保险")) {
                 cAppJqFlag = false;
@@ -279,14 +314,14 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
             boo = ciRepetitionInsure(rr, m, requestInfoList, cAppJqFlag);
             if (!boo) {
                 InsuranceLog.infoLog(InsuranceEnum.AICS.getPinyin(), "\n\n---------> {} - 交强险重复投保处理", vinNo);
-                return this.getResponse(m, vinNo, requestInfoList);
+                return this.getResponse(m, vinNo, requestInfoList,yaQuoteInfoVo);
             }
 
             //1、商业险重复投保处理
             boo = commerceRepetitionInsure(rr, m, requestInfoList, appSYFlag);
             if (!boo) {
                 InsuranceLog.infoLog(InsuranceEnum.AICS.getPinyin(), "\n\n---------> {} - 商业险重复投保处理", vinNo);
-                return this.getResponse(m, vinNo, requestInfoList);
+                return this.getResponse(m, vinNo, requestInfoList,yaQuoteInfoVo);
             }
 
         }
@@ -295,21 +330,21 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         boo = reinsurance(rr, m);
         if (!boo) {
             InsuranceLog.infoLog(InsuranceEnum.AICS.getPinyin(), "\n\n---------> {} - 转保处理", vinNo);
-            return this.getResponse(m, vinNo, requestInfoList);
+            return this.getResponse(m, vinNo, requestInfoList,yaQuoteInfoVo);
         }
 
         //3、商业险日期处理
         boo = biRepetitionInsure(rr, m, requestInfoList);
         if (!boo) {
             InsuranceLog.infoLog(InsuranceEnum.AICS.getPinyin(), "\n\n---------> {} - 商业险日期处理", vinNo);
-            return this.getResponse(m, vinNo, requestInfoList);
+            return this.getResponse(m, vinNo, requestInfoList,yaQuoteInfoVo);
         }
 
         // 转保验证码
         boo = reinsuranceCodeError(rr, m);
         if (!boo) {
             InsuranceLog.infoLog(InsuranceEnum.AICS.getPinyin(), "\n\n---------> {} - 转保处理", vinNo);
-            return this.getResponse(m, vinNo, requestInfoList);
+            return this.getResponse(m, vinNo, requestInfoList,yaQuoteInfoVo);
         }
         return rr;
     }
@@ -359,7 +394,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         Ruote m = this.builderParams(quoteVo, yaQuoteInfoVo, coreModelsVo);
 
         //递归报价
-        RuoteResponse rr = this.getResponse(m, yaQuoteInfoVo.getCarInfo().getVinNo(), requestInfoList);
+        RuoteResponse rr = this.getResponse(m, yaQuoteInfoVo.getCarInfo().getVinNo(), requestInfoList, yaQuoteInfoVo);
 
         //错误信息
         StringBuilder errorInfo = this.getErrorInfo(rr);
@@ -390,6 +425,18 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         //添加调用费用匹配功能
 //        feeRuleSchemeService.dealFeeOrderInfo(yaQuoteInfoVo, quoteRespVo, quoteVo.getAgreementId(), iac.getId());
 
+        //存储 报价返回的查询码  交强和商业
+        if(rr.getVhl() != null) {
+            if(rr.getVhl().getCQryCdeJQ() != null) {
+                redisTemplate.opsForValue().set(REDIS_YONGCHENG_QUERY_CODE_JQ + order.getUserid() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo(),
+                        rr.getVhl().getCQryCdeJQ(), REDIS_YONGCHENG_QUERY_CODE_EXPIRE, TimeUnit.DAYS);
+            }
+            if(rr.getVhl().getCQryCdeSY() != null) {
+                redisTemplate.opsForValue().set(REDIS_YONGCHENG_QUERY_CODE_SY + order.getUserid() + yaQuoteInfoVo.getCarInfo().getVinNo() + yaQuoteInfoVo.getCarInfo().getLicenseNo(),
+                        rr.getVhl().getCQryCdeSY(), REDIS_YONGCHENG_QUERY_CODE_EXPIRE, TimeUnit.DAYS);
+            }
+        }
+
         return HttpResult.ok("报价成功", quoteRespVo);
 
     }
@@ -1189,6 +1236,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         //保存订单信息
         InsAreaCompany insAreaCompany = new InsAreaCompany();
         insAreaCompany.setOrderno(insOrder.getOrderno());
+        insAreaCompany.setApiType(PtlApiType.PTL_API_1.getCode());
         insAreaCompany.setReptxt(JSON.parseObject(JSON.toJSONString(responseData)));
         insAreaCompany.setJqpremium(BigDecimal.valueOf(jqFalg ? jqPremium : 0));
         insAreaCompany.setSypremium(BigDecimal.valueOf(syPremium));

+ 10 - 0
src/main/java/com/ydtech/modules/protocol/controller/TaxSourceController.java

@@ -9,6 +9,7 @@ import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.protocol.entity.vo.TaxSourceVo;
 import com.ydtech.modules.protocol.service.ITaxSourceService;
+import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -25,6 +26,9 @@ public class TaxSourceController extends BaseController {
     @Autowired
     private ITaxSourceService taxSourceService;
 
+    @Autowired
+    private PtlAgreementService ptlAgreementService;
+
 
     @GetMapping("/license")
     @ApiOperation("车牌信息")
@@ -68,6 +72,12 @@ public class TaxSourceController extends BaseController {
         return HttpResult.ok(taxSourceService.getAllAgreement(deptId,userId));
     }
 
+    @GetMapping("/getExternalAgreement")
+    @ApiOperation("获取外部协议")
+    public HttpResult getExternalAgreement(){
+        return HttpResult.ok(ptlAgreementService.getExternalAgreement());
+    }
+
     @PostMapping("/saveTaxSource")
     @ApiOperation("保存税源")
     public HttpResult saveTaxSource(@RequestBody TaxSourceVo taxSourceVo) {

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

@@ -19,6 +19,9 @@ public interface PtlAgreementMapper extends BaseMapper<PtlAgreement> {
 
     List<PtlAgreementInsCompanyDto> getAgreementCompany(@Param("localDate") LocalDate localDate, @Param("deptId") String deptId);
 
+    List<PtlAgreementInsCompanyDto> getAgreementCompanyExternal(@Param("localDate") LocalDate localDate, @Param("deptId") String deptId);
+
+
     PtlAgreementInsCompanyDto getAgreementCompanyByCompanyId(@Param("localDate") LocalDate localDate, @Param("deptId") String deptId,@Param("companyId") String companyId);
 
     PtlAgreement getByAgreementIdNew(String agreementId);

+ 3 - 0
src/main/java/com/ydtech/modules/protocol/entity/dto/PtlAgreementSaveDto.java

@@ -76,4 +76,7 @@ public class PtlAgreementSaveDto implements Serializable {
 
     @ApiModelProperty("内部机构id")
     private String deptId;
+
+    @ApiModelProperty("外部订单协议")
+    private Integer isExternal;
 }

+ 6 - 0
src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java

@@ -215,6 +215,12 @@ public class PtlAgreement implements Serializable {
     @TableField(value = "update_time")
     private LocalDateTime updateTime;
 
+    /**
+     * 是否是外部订单费用
+     */
+    @TableField(value = "is_external")
+    private Integer isExternal;
+
     /**
      * 审核类型
      */

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

@@ -30,6 +30,13 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreementInsCompanyDto> getAgreementCompany(String deptId);
 
+    /**
+     * 获取可以报价的 可录入外部订单的协议
+     * @param deptId
+     * @return
+     */
+    List<PtlAgreementInsCompanyDto> getAgreementCompanyExternal(String deptId);
+
     PtlAgreementInsCompanyDto getAgreementCompany(String deptId,String companyId);
 
 
@@ -229,4 +236,7 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
 
     PtlAgreement selectAgreeId(HashMap<String, Object> params);
 
+
+    List<PtlAgreementInsCompanyDto> getExternalAgreement();
+
 }

+ 64 - 1
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -140,6 +140,35 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         return agreementCompany;
     }
 
+    @Override
+    public List<PtlAgreementInsCompanyDto> getAgreementCompanyExternal(String deptId) {
+        LocalDate localDate = LocalDate.now();
+        List<PtlAgreementInsCompanyDto> agreementCompany = baseMapper.getAgreementCompanyExternal(localDate, deptId);
+
+        for (PtlAgreementInsCompanyDto ptlAgreementInsCompanyDto : agreementCompany) {
+            List<PtlAgreementDto> agreement = ptlAgreementInsCompanyDto.getAgreement();
+            for (PtlAgreementDto ptlAgreementDto : agreement) {
+                if (ptlAgreementDto.getProductsCode() != null && !ptlAgreementDto.getProductsCode().equals("")) {
+                    String[] split = ptlAgreementDto.getProductsCode().split(",");
+                    ptlAgreementDto.setProductsCodes(split);
+                }
+            }
+        }
+
+        List<String> agreementIdList = agreementCompany.stream()
+                .flatMap(x -> x.getAgreement().stream().map(PtlAgreementDto::getId))
+                .collect(Collectors.toList());
+
+        /*Map<String, List<String>> licenseNoList = ptlAgreementUndwrtRulesService.getByLicenseNo(agreementIdList);
+
+        agreementCompany.forEach(
+                x -> x.getAgreement().forEach(a -> a.setLicenseNo(licenseNoList.get(a.getId())))
+        );*/
+
+        return agreementCompany;
+    }
+
+
     @Override
     public PtlAgreementInsCompanyDto getAgreementCompany(String deptId, String companyId) {
         LocalDate localDate = LocalDate.now();
@@ -559,7 +588,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         BeanUtils.copyProperties(agreementSaveDto, ptlAgreement);
         EsmInsCompany esmInsCompany = proxyObject.verifyLogin(ptlAgreement, agreementSaveDto, attribution,
                 "1".equals(ptlAgreement.getValidStatus()));
-
+        ptlAgreement.setIsExternal(agreementSaveDto.getIsExternal());
         ptlAgreement.setProductsCode(agreementSaveDto.getProductsCode());
         ptlAgreement.setModifiedBy(userName);
         ptlAgreement.setModifiedName(BaseController.getUser().getName());
@@ -786,5 +815,39 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         return baseMapper.selectAgreeId(params);
     }
 
+    @Override
+    public List<PtlAgreementInsCompanyDto> getExternalAgreement() {
+        LocalDate localDate = LocalDate.now();
+        List<PtlAgreement> list = this.list(new LambdaQueryWrapper<PtlAgreement>()
+                .eq(PtlAgreement::getIsExternal, "1")
+                .eq(PtlAgreement::getValidStatus, "1"));
+
+        List<String> agreementCompanys = list.stream().map(PtlAgreement::getInsuranceCompanyId).collect(Collectors.toList());
+
+        List<EsmInsCompany> companyList = esmInsCompanyService.list(new LambdaQueryWrapper<EsmInsCompany>().in(EsmInsCompany::getId, agreementCompanys));
+
+        List<PtlAgreementInsCompanyDto> result = new ArrayList<>();
+
+
+        companyList.forEach(item->{
+            PtlAgreementInsCompanyDto ptlAgreementInsCompanyDto = new PtlAgreementInsCompanyDto();
+            ptlAgreementInsCompanyDto.setId(item.getId());
+            ptlAgreementInsCompanyDto.setCnName(item.getCnName());
+            ptlAgreementInsCompanyDto.setLogo(item.getLogo());
+            ptlAgreementInsCompanyDto.setName(item.getName());
+            ptlAgreementInsCompanyDto.setNamesimple(item.getNamesimple());
+            List<PtlAgreement> collect = list.stream().filter(x -> x.getInsuranceCompanyId().equals(item.getId())).collect(Collectors.toList());
+            List<PtlAgreementDto> agreementDtos = new ArrayList<>();
+            collect.forEach(x->{
+                PtlAgreementDto ptlAgreementDto = new PtlAgreementDto();
+                BeanUtils.copyProperties(x,ptlAgreementDto);
+                agreementDtos.add(ptlAgreementDto);
+            });
+            ptlAgreementInsCompanyDto.setAgreement(agreementDtos);
+            result.add(ptlAgreementInsCompanyDto);
+        });
+        return result;
+    }
+
 
 }

+ 3 - 0
src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementProductQueryVo.java

@@ -46,6 +46,9 @@ public class AgreementProductQueryVo extends PageRequest {
     @ApiModelProperty(value = "费用描述")
     private String costsDescription;
 
+    @ApiModelProperty(value = "是否是外部协议")
+    private Integer isExternal;
+
     @ApiModelProperty("操作人")
     private String operator;
 

+ 104 - 101
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -198,7 +198,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
         //产品code
         if (agreementProductQueryVo.getProductCode() != null && !agreementProductQueryVo.getProductCode().isEmpty()) {
-            ptlAgreementProductCostsNewLambdaQueryWrapper.eq(PtlAgreementProductCostsNew::getProductId, agreementProductQueryVo.getProductCode());
+            ptlAgreementProductCostsNewLambdaQueryWrapper.in(PtlAgreementProductCostsNew::getProductId, agreementProductQueryVo.getProductCode());
         }
 
         //费用时间
@@ -465,105 +465,108 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 //                }
 //            }
 //        }
-        try {
-            for (int i = 0; i < agreementProductCosts.getProductId().size(); i++) {
-                PtlAgreementProductCostsNew ptlAgreementProductCostsNew = new PtlAgreementProductCostsNew();
-                BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNew);
-                ptlAgreementProductCostsNew.setId(null);
-                //设置默认优先级为1
-                if (ptlAgreementProductCostsNew.getPriorityLevel() == null) {
-                    ptlAgreementProductCostsNew.setPriorityLevel(1);
+        for (int i = 0; i < agreementProductCosts.getProductId().size(); i++) {
+            // 外部订单的检测  每个产品只可有一个费用
+            List<PtlAgreementProductCostsNew> list = ptlAgreementProductCostsNewService.list(new LambdaQueryWrapper<PtlAgreementProductCostsNew>()
+                    .eq(PtlAgreementProductCostsNew::getProductId, agreementProductCosts.getProductId().get(i))
+                    .eq(PtlAgreementProductCostsNew::getAgreementId, agreementProductCosts.getAgreementId())
+                    .eq(PtlAgreementProductCostsNew::getIsAudit, 1));
+            if (list.size() > 0) {
+                throw new SystemException(agreementProductCosts.getProductName().get(i) + "产品费用已存在,请勿重复添加!");
+            }
+            PtlAgreementProductCostsNew ptlAgreementProductCostsNew = new PtlAgreementProductCostsNew();
+            BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNew);
+            ptlAgreementProductCostsNew.setId(null);
+            //设置默认优先级为1
+            if (ptlAgreementProductCostsNew.getPriorityLevel() == null) {
+                ptlAgreementProductCostsNew.setPriorityLevel(1);
+            }
+            ptlAgreementProductCostsNew.setIsAudit(0);
+            ptlAgreementProductCostsNew.setProductId(agreementProductCosts.getProductId().get(i));
+            ptlAgreementProductCostsNew.setProductName(agreementProductCosts.getProductName().get(i));
+            ptlAgreementProductCostsNew.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+            ptlAgreementProductCostsNew.setCreateBy(BaseController.getUser().getId());
+            ptlAgreementProductCostsNew.blank();
+            int insert = baseMapper.insert(ptlAgreementProductCostsNew);
+
+            //添加费用出口信息
+            PtlAgreementProductCostsExport ptlAgreementProductCostsExport = new PtlAgreementProductCostsExport();
+            BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsExport);
+            ptlAgreementProductCostsExport.setCostsId(ptlAgreementProductCostsNew.getId());
+            ptlAgreementProductCostsExport.setId(null);
+            ptlAgreementProductCostsExport.blank();
+            ptlAgreementProductCostsExportService.save(ptlAgreementProductCostsExport);
+            //保存产品费用历史记录
+            PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
+            BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNewHistory);
+            //添加费用ID
+            ptlAgreementProductCostsNewHistory.setId(IdGenerate.nextId());
+            ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
+            //生成批次ID
+            String uuid = IdGenerate.nextId();
+            ptlAgreementProductCostsNewHistory.setPriorityLevel(ptlAgreementProductCostsNew.getPriorityLevel());
+            ptlAgreementProductCostsNewHistory.setBatch(uuid);
+            ptlAgreementProductCostsNewHistory.setOperatorType("add");
+            ptlAgreementProductCostsNewHistory.setProductId(agreementProductCosts.getProductId().get(i));
+            ptlAgreementProductCostsNewHistory.setProductName(agreementProductCosts.getProductName().get(i));
+            ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
+            ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
+            ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
+            //创建产品费用因子历史记录容器
+            List<PtlAgreementProductCostsAttrLinkHistory> costsAttrLinkHistories = new ArrayList<>();
+            //遍历费用属性
+            List<PtlAgreementProductCostsAttrLink> costsAttrLinks = agreementProductCosts.getCostsAttrLinks();
+            List<PtlAgreementProductCostsAttrLink> costsAttrLink = new ArrayList<>();
+            List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+            costsAttrLinks.forEach(x -> {
+                PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
+                //处理中文逗号
+                if (x.getMin() != null && x.getMin().contains(",")) {
+                    x.setMin(x.getMin().replace(",", ","));
                 }
-                ptlAgreementProductCostsNew.setIsAudit(0);
-                ptlAgreementProductCostsNew.setProductId(agreementProductCosts.getProductId().get(i));
-                ptlAgreementProductCostsNew.setProductName(agreementProductCosts.getProductName().get(i));
-                ptlAgreementProductCostsNew.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-                ptlAgreementProductCostsNew.setCreateBy(BaseController.getUser().getId());
-                ptlAgreementProductCostsNew.blank();
-                int insert = baseMapper.insert(ptlAgreementProductCostsNew);
-
-                //添加费用出口信息
-                PtlAgreementProductCostsExport ptlAgreementProductCostsExport = new PtlAgreementProductCostsExport();
-                BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsExport);
-                ptlAgreementProductCostsExport.setCostsId(ptlAgreementProductCostsNew.getId());
-                ptlAgreementProductCostsExport.setId(null);
-                ptlAgreementProductCostsExport.blank();
-                ptlAgreementProductCostsExportService.save(ptlAgreementProductCostsExport);
-                //保存产品费用历史记录
-                PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
-                BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNewHistory);
-                //添加费用ID
-                ptlAgreementProductCostsNewHistory.setId(IdGenerate.nextId());
-                ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
-                //生成批次ID
-                String uuid = IdGenerate.nextId();
-                ptlAgreementProductCostsNewHistory.setPriorityLevel(ptlAgreementProductCostsNew.getPriorityLevel());
-                ptlAgreementProductCostsNewHistory.setBatch(uuid);
-                ptlAgreementProductCostsNewHistory.setOperatorType("add");
-                ptlAgreementProductCostsNewHistory.setProductId(agreementProductCosts.getProductId().get(i));
-                ptlAgreementProductCostsNewHistory.setProductName(agreementProductCosts.getProductName().get(i));
-                ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
-                ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
-                ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
-                //创建产品费用因子历史记录容器
-                List<PtlAgreementProductCostsAttrLinkHistory> costsAttrLinkHistories = new ArrayList<>();
-                //遍历费用属性
-                List<PtlAgreementProductCostsAttrLink> costsAttrLinks = agreementProductCosts.getCostsAttrLinks();
-                List<PtlAgreementProductCostsAttrLink> costsAttrLink = new ArrayList<>();
-                List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
-                costsAttrLinks.forEach(x -> {
-                    PtlAgreementProductCostsAttrLinkHistory costsAttrLinkHistory = new PtlAgreementProductCostsAttrLinkHistory();
-                    //处理中文逗号
-                    if (x.getMin() != null && x.getMin().contains(",")) {
-                        x.setMin(x.getMin().replace(",", ","));
-                    }
-                    PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().get();
+                PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(y -> y.getAttrCode().equals(x.getAttrCode())).findFirst().get();
 
-                    //单独处理车牌号
-                    if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && !x.getMin().equals(""))) {
+                //单独处理车牌号
+                if ("LicenseNo".equals(x.getAttrCode()) && (x.getMin() != null && !x.getMin().equals(""))) {
 //                x.setOperator(x.getDictLabal().getJSONObject(0).getString("parentNumber"));
-                        x.setOperator("0");
-                        x.setCostsId(ptlAgreementProductCostsNew.getId());
-                        x.setId("0");
-                        costsAttrLink.add(x);
-                        BeanUtils.copyProperties(x, costsAttrLinkHistory);
-                        //设置产品费用因子历史记录
-                        costsAttrLinkHistory.setId(null);
-                        costsAttrLinkHistory.setBatch(uuid);
-                        costsAttrLinkHistory.setOperatorType("add");
-                        costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
-                        costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
-                        costsAttrLinkHistories.add(costsAttrLinkHistory);
-                    } else {
-                        if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio") || (!"0".equals(x.getMin()) && null != x.getMin()) || (!"0".equals(x.getMax()) && null != x.getMax())) {
-                            if (x.getMin() != null || x.getMax() != null) {
-                                x.setCostsId(ptlAgreementProductCostsNew.getId());
-                                x.setId("0");
-                                costsAttrLink.add(x);
-                                BeanUtils.copyProperties(x, costsAttrLinkHistory);
-                                //设置产品费用因子历史记录
-                                costsAttrLinkHistory.setId(null);
-                                costsAttrLinkHistory.setBatch(uuid);
-
-                                costsAttrLinkHistory.setOperatorType("add");
-                                costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
-                                costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
-                                costsAttrLinkHistories.add(costsAttrLinkHistory);
-                            }
+                    x.setOperator("0");
+                    x.setCostsId(ptlAgreementProductCostsNew.getId());
+                    x.setId("0");
+                    costsAttrLink.add(x);
+                    BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                    //设置产品费用因子历史记录
+                    costsAttrLinkHistory.setId(null);
+                    costsAttrLinkHistory.setBatch(uuid);
+                    costsAttrLinkHistory.setOperatorType("add");
+                    costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                    costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                    costsAttrLinkHistories.add(costsAttrLinkHistory);
+                } else {
+                    if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio") || (!"0".equals(x.getMin()) && null != x.getMin()) || (!"0".equals(x.getMax()) && null != x.getMax())) {
+                        if (x.getMin() != null || x.getMax() != null) {
+                            x.setCostsId(ptlAgreementProductCostsNew.getId());
+                            x.setId("0");
+                            costsAttrLink.add(x);
+                            BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                            //设置产品费用因子历史记录
+                            costsAttrLinkHistory.setId(null);
+                            costsAttrLinkHistory.setBatch(uuid);
+
+                            costsAttrLinkHistory.setOperatorType("add");
+                            costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                            costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                            costsAttrLinkHistories.add(costsAttrLinkHistory);
                         }
                     }
-                });
-                //保存产品费用因子历史记录
-                ptlAgreementProductCostsAttrLinkHistoryService.saveBatch(costsAttrLinkHistories);
-                ptlAgreementProductCostsAttrLinkService.saveBatch(costsAttrLink);
-                //添加费用因子轨迹
-                ptlAgreementProductCostsTrajectoryService.addCostsTrajectory(ptlAgreementProductCostsNew.getId(), "新增费用因子", BaseController.getUser().getId());
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
+                }
+            });
+            //保存产品费用因子历史记录
+            ptlAgreementProductCostsAttrLinkHistoryService.saveBatch(costsAttrLinkHistories);
+            ptlAgreementProductCostsAttrLinkService.saveBatch(costsAttrLink);
+            //添加费用因子轨迹
+            ptlAgreementProductCostsTrajectoryService.addCostsTrajectory(ptlAgreementProductCostsNew.getId(), "新增费用因子", BaseController.getUser().getId());
         }
+        return true;
     }
 
 
@@ -1219,14 +1222,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         //商业出口费用
         FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), feeOrderNewVo.getExportFee().get(1).getSuperviseCosts(),
                 feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(), syDeptManagerTotalProportion, retailStoreFee.getRetailStoreRadio(), taxRadio);
-        jqExportFee.setInsuranceType("商业险");
+        syExportFee.setInsuranceType("商业险");
         exportFeeList.add(syExportFee);
 
 
         //非车出口费用
         FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), feeOrderNewVo.getExportFee().get(2).getSuperviseCosts(),
                 feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(), noDeptManagerTotalProportion, retailStoreFee.getRetailStoreRadio(), taxRadio);
-        jqExportFee.setInsuranceType("非车险");
+        noExportFee.setInsuranceType("非车险");
         exportFeeList.add(noExportFee);
 
         //endregion
@@ -1237,7 +1240,6 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
         FeeOrderNewVo resultFeeOrderNewVo = new FeeOrderNewVo();
         resultFeeOrderNewVo.setEntranceFee(entranceFeeList);
-        resultFeeOrderNewVo.setDeptManagerFee(deptManagerFeeList);
         resultFeeOrderNewVo.setExportFee(exportFeeList);
 
 
@@ -1315,7 +1317,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNew.setNoExportOtherCostsProportion(exportFeeList.get(2).getOtherCostsProportion());
         insFeeOrderNew.setNoExportOtherCostsPremiums(exportFeeList.get(2).getOtherCostsPremiums());
 
-        //region 重新计算一级机构管理费
+        //region 计算差值
         //入口 - 出口 - 机构管理费 5级 - 分销费  = 差值
 
         //分销交强费用
@@ -1343,6 +1345,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 )
                 .subtract(jqFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
         insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
+        deptManagerFeeList.get(0).setProfitMarginPremiums(jqDifference);
 
         BigDecimal syDifference = syEntranceFee.getTotalAmount().subtract(
                         (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
@@ -1351,7 +1354,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 )
                 .subtract(syFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
         insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
-
+        deptManagerFeeList.get(1).setProfitMarginPremiums(syDifference);
 
         BigDecimal noDifference = noEntranceFee.getTotalAmount().subtract(
                         (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
@@ -1361,9 +1364,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 .subtract(noFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
 
         insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
-        deptManagerFeeList.get(2).setDeptPremiumsLevelOne(noDifference);
+        deptManagerFeeList.get(2).setProfitMarginPremiums(noDifference);
         //endregion
-
+        resultFeeOrderNewVo.setDeptManagerFee(deptManagerFeeList);
 
         //保存新的比例
         insFeeOrderNewService.updateById(insFeeOrderNew);

+ 38 - 0
src/main/resources/mapper/modules/fnc/ImportAsyncMapper.xml

@@ -46,6 +46,44 @@
             <if test="createTime !=null  and  createTime  !=''">
              AND   DATE(a.create_time) =#{createTime}
             </if>
+            <if test="incomeId !=null  and  incomeId  !=''">
+             AND    a.income_id  =#{incomeId}
+            </if>
+        </where>
+        order  by  a.create_time  desc
+    </select>
+
+
+    <select id="selectByIncomeId" resultType="com.ydtech.modules.fnc.entity.ImportResult">
+        select
+        a.id as "id",
+        a.create_time as "createTime",
+        a.created_at as "createdAt",
+        a.completed_at as "completedAt",
+        a.status as "status",
+        a.total_amount as "totalAmount",
+        a.upload_url as "uploadUrl",
+        a.company_id as "companyId",
+        a.partner_companies_id as "partnerCompaniesId",
+        a.agreement_id as "agreementId",
+        a.ids as "ids",
+        a.hand_status as "handStatus",
+        a.hand_status as "handStatus",
+        a.income_id as "incomeId",
+        eic.namesimple as "partnerCompaniesName"
+        from
+        import_task  a
+        LEFT  JOIN  esm_ins_company  eic  on  eic.id  = a.partner_companies_id
+        <where>
+            <if test="handStatus !=null  and  handStatus  !=''">
+               a.hand_status =#{handStatus}
+            </if>
+            <if test="createTime !=null  and  createTime  !=''">
+             AND   DATE(a.create_time) =#{createTime}
+            </if>
+            <if test="incomeId !=null  and  incomeId  !=''">
+             AND    a.income_id  =#{incomeId}
+            </if>
         </where>
         order  by  a.create_time  desc
     </select>

+ 22 - 0
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -186,6 +186,10 @@
                 and a.handling_fees_status =#{handlingFeesStatus}
             </if>
 
+            <if test="id !=null  and  id  !=''">
+                and a.id =#{id}
+            </if>
+
             <if test="allPartnerCompaniesId !=null  and  allPartnerCompaniesId  !=''">
                 AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
             </if>
@@ -1684,5 +1688,23 @@
       ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
       ORDER BY i.YEAR, i.monthNumber;
     </select>
+    <select id="platformSettlementRecord" resultType="com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto">
+        SELECT
+            DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
+            SUM( a.commission_feevalue + a.other_feevalue ) AS "settlementAmount"
+        FROM
+            ins_ply_income a
+            LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
+        <where>
+            pa.agreement_type ='1'
+            <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                AND a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+            <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                and a.handling_fees_status =#{handlingFeesStatus}
+            </if>
+
+        </where>
+    </select>
 
 </mapper>

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

@@ -61,6 +61,7 @@
             a.invoiced_settled_amount as "invoicedSettledAmount",
             a.Invoiced_not_settled_amount as "InvoicedNotSettledAmount",
             a.completion_status as "completionStatus",
+            a.settlement_sum_id as "settlementSumId",
             upf.url as "imageUrl",
             a.unsettled_amount as "unsettledAmount"
             from  settlement_documentary_fees  a
@@ -88,6 +89,9 @@
             <if test="completionStatus !=null  and  completionStatus  !=''">
                 and a.completion_status =#{completionStatus}
             </if>
+            <if test="settlementSumId !=null  and  settlementSumId  !=''">
+                and a.settlement_sum_id =#{settlementSumId}
+            </if>
         </where>
         ORDER  BY  a.create_time desc
     </select>

+ 57 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesSumMapper.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydtech.modules.fnc.dao.SettlementDocumentaryFeesSumMapper">
+
+
+    <sql id="income_com">
+                a.id as  "id",
+                a.total_amount  as  "totalAmount",
+                a.create_time  as  "createTime"
+                a.company_id  as  "companyId",
+                a.settlement_status  as  "settlementStatus",
+                a.user_id  as  "userId",
+                a.invoicing_method  as  "invoicingMethod",
+                a.invoice_id  as  "invoicId",
+                a.is_not_car  as  "isNotCar",
+                a.partner_companies_id  as  "partnerCompaniesId",
+                a.invoiced_settled_amount  as  "invoicedSettledAmount",
+                a.invoiced_not_settled_amount  as  "invoicedNotSettledAmount",
+                a.completion_status  as  "completionStatus"
+    </sql>
+
+    <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity">
+        select
+        <include refid="income_com"/>
+        from
+        settlement_documentary_fees_sum a
+        <where>
+            1=1
+            <if test="companyId  !=null  and  companyId  !=''">
+                AND a.company_id =#{companyId}
+            </if>
+            <if test="settlementStatus  !=null  and  settlementStatus  !=''">
+                AND a.settlement_status =#{settlementStatus}
+            </if>
+            <if test="invoicingMethod  !=null  and  invoicingMethod  !=''">
+                AND a.invoicing_method =#{invoicingMethod}
+            </if>
+            <if test="invoicId  !=null  and  invoicId  !=''">
+                AND a.invoice_id =#{invoicId}
+            </if>
+            <if test="isNotCar  !=null  and  isNotCar  !=''">
+                AND a.is_not_car =#{isNotCar}
+            </if>
+            <if test="partnerCompaniesId  !=null  and  partnerCompaniesId  !=''">
+                AND a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+          <if test="partnerCompaniesId  !=null  and  partnerCompaniesId  !=''">
+                AND a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+        <if test="completionStatus  !=null  and  completionStatus  !=''">
+                AND a.completion_status =#{completionStatus}
+            </if>
+        </where>
+    </select>
+
+
+</mapper>

+ 4 - 2
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -104,11 +104,12 @@
     </select>
 
     <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
-        SELECT iac.*, pa.agreement_name
+        SELECT iac.*, pa.agreement_name,io.is_external
         FROM ins_area_company as iac
                  left join ptl_agreement as pa on pa.id = iac.agreement_id
+                left join ins_orders io on iac.orderno=io.orderno
         WHERE iac.orderstatus = 3
-          and orderno = #{orderNo};
+          and iac.orderno = #{orderNo};
     </select>
 
 
@@ -153,6 +154,7 @@
         io.frameno,
         io.licenseno,
         io.insuredname,
+        io.is_external,
         iac.jq_start_date as jqstartdate,
         iac.jq_end_date as jqenddate,
         iac.sy_start_date as systartdate,

+ 5 - 1
src/main/resources/mapper/modules/order/InsOrdersMapper.xml

@@ -191,6 +191,7 @@
                o.licenseno,
                o.insuredname,
                o.vehicle_and_vessel_tax,
+               o.is_external,
                iac.jq_start_date as jqstartdate,
                iac.jq_end_date   as jqenddate,
                iac.sy_start_date as systartdate,
@@ -832,6 +833,7 @@
         agree.agreement_name as agreementName,
         company.namesimple as partnerCompaniesName,
         iac.api_type,
+        io.is_external,
         CASE dept.management_source
         WHEN '1' THEN '渠道'
         WHEN '2' THEN '个代'
@@ -1295,7 +1297,9 @@
         <if test="param != null and param != ''">
         AND (a.licenseno = #{param} or a.ins_company = #{param})
         </if>
-
+        <if test="userId != null and userId != ''">
+            AND a.userid = #{userId}
+        </if>
         ORDER BY
             difference DESC
     </select>

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

@@ -84,6 +84,25 @@
           order by pa.serial_number
     </select>
 
+
+    <select id="getAgreementCompanyExternal" resultMap="AgreementCompanyResultMap">
+        select eic.*, pa.id as agreement_id, pa.agreement_name,pa.products_code, paa.api_type, pa.underwriting_description
+        from esm_ins_company as eic
+        left join ptl_agreement as pa on pa.insurance_company_id = eic.id
+        left join ptl_agreement_attribution as paa on paa.id = pa.id
+        where (#{localDate} between start_date and end_date)
+        and (paa.template_id is not null)
+        and pa.valid_status = 1
+        and pa.is_external = 1
+        and pa.id in (select distinct agreement_id
+        from ptl_agreement_dept
+        <if test="deptId != null and deptId != ''">
+            where dept_id = #{deptId}
+        </if>
+        )
+        order by pa.serial_number
+    </select>
+
     <select id="getAgreementCompanyByCompanyId" resultMap="AgreementCompanyResultMap">
         select eic.*, pa.id as agreement_id, pa.agreement_name, paa.api_type, pa.underwriting_description
         from esm_ins_company as eic
@@ -132,6 +151,9 @@
             <if test="partnerCompaniesId  !=null  and   partnerCompaniesId  !=''" >
                   and   a.partner_companies_id =#{partnerCompaniesId}
             </if>
+          <if test="agreeId  !=null  and   agreeId  !=''" >
+                  and   a.id =#{agreeId}
+            </if>
         </where>
         limit  1
     </select>