Explorar o código

缺失功能:
私有协议--手续费应收-应收订单,批量修改比例-导出修改功能未实现

jiakai hai 4 meses
pai
achega
bcb29150d4

+ 304 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/InsPlyIncomeExportVo.java

@@ -0,0 +1,304 @@
+package com.jzg.commons.entity.finance.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.jzg.commons.core.base.BaseModel;
+import com.jzg.commons.entity.po.InsFeeOrders;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Schema(description = "财务应收表")
+public class InsPlyIncomeExportVo extends BaseModel {
+    @Serial
+    private static final long serialVersionUID = 6161862008963938376L;
+
+    @ExcelIgnore
+    private String id;
+
+    @Schema(description = "订单号")
+    @ExcelProperty("订单号")
+    private String orderNo;
+
+    @Schema(description = "协议类型")
+    @ExcelProperty("协议类型")
+    private String agreementType;
+
+    @Schema(description = "机构")
+    @ExcelProperty("机构id")
+    private String deptId;
+
+    @Schema(description = "机构名称")
+    @ExcelProperty("机构名称")
+    private String deptName;
+
+    @Schema(description = "产品id")
+    @ExcelProperty("产品id")
+    private String productId;
+
+    @Schema(description = "产品名称")
+    @ExcelProperty("产品名称")
+    private String productName;
+
+    @Schema(description = "险种")
+    @ExcelProperty("险种")
+    private String riskCode;
+
+    @Schema(description = "签单时间")
+    @TableField(exist = false)
+    @ExcelProperty("签单时间")
+    private String signingTime;
+
+    @Schema(description = "签单年份")
+    @TableField(exist = false)
+    private String signYear;
+
+    @Schema(description = "签单日期 yyyy-mm-dd 格式")
+    @TableField(exist = false)
+    private String signDate;
+
+    @Schema(description = "保司ID")
+    @ExcelProperty("保司ID")
+    private String companyId;
+
+    @Schema(description = "保司名称")
+    @TableField(exist = false)
+    @ExcelProperty("保司名称")
+    private String companyName;
+
+    @Schema(description = "协议Id")
+    @ExcelProperty("协议Id")
+    private String agreementId;
+
+    @Schema(description = "协议名称")
+    @ExcelProperty("协议名称")
+    private String agreementName;
+
+    @Schema(description = "被保人")
+    @ExcelProperty("被保人")
+    private String insuredPerson;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty("车牌号")
+    private String licenseNo;
+
+    @Schema(description = "车船税")
+    @ExcelProperty("车船税")
+    private String taxPremium;
+
+    @Schema(description = "交强保单号")
+    @ExcelProperty("交强保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty("商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "驾意保单号")
+    @ExcelProperty("驾意保单号")
+    private String jyPolicyNo;
+
+    @Schema(description = "交强保费")
+    @ExcelProperty("交强保费")
+    private String jqPremium;
+
+    @Schema(description = "商业保费")
+    @ExcelProperty("商业保费")
+    private String syPremium;
+
+    @Schema(description = "驾意保费")
+    @ExcelProperty("驾意保费")
+    private String jyPremium;
+
+    @Schema(description = "交强手续费")
+    @ExcelProperty("交强手续费")
+    private String jqSuperviseCostsPremiums;
+
+    @Schema(description = "交强手续费比例")
+    @ExcelProperty("交强手续费比例")
+    private String jqSuperviseCostsProportion;
+
+    @Schema(description = "商业手续费")
+    @ExcelProperty("商业手续费")
+    private String sySuperviseCostsPremiums;
+
+    @Schema(description = "商业手续费比例")
+    @ExcelProperty("商业手续费比例")
+    private String sySuperviseCostsProportion;
+
+    @Schema(description = "驾意手续费")
+    @ExcelProperty("驾意手续费")
+    private String jySuperviseCostsPremiums;
+
+    @Schema(description = "驾意手续费比例")
+    @ExcelProperty("驾意手续费比例")
+    private String jySuperviseCostsProportion;
+
+    @TableField(exist = false)
+    @Schema(description = "应收手续费")
+    @ExcelProperty("应收手续费")
+    private String superviseCostsPremiums;
+
+    @TableField(exist = false)
+    @Schema(description = "应收跟单费")
+    @ExcelProperty("应收跟单费")
+    private String otherCostsPremiums;
+
+    @Schema(description = "交强跟单费比例")
+    @ExcelProperty("交强跟单费比例")
+    private String jqOtherCostsProportion;
+
+    @Schema(description = "交强跟单费")
+    @ExcelProperty("交强跟单费")
+    private String jqOtherCostsPremiums;
+
+    @Schema(description = "商业跟单费比例")
+    @ExcelProperty("商业跟单费比例")
+    private String syOtherCostsProportion;
+
+    @Schema(description = "商业跟单费")
+    @ExcelProperty("商业跟单费")
+    private String syOtherCostsPremiums;
+
+    @Schema(description = "驾意跟单费比例")
+    @ExcelProperty("驾意跟单费比例")
+    private String jyOtherCostsProportion;
+
+    @Schema(description = "驾意跟单费")
+    @ExcelProperty("驾意跟单费")
+    private String jyOtherCostsPremiums;
+
+    @Schema(description = "交强应收费用")
+    @ExcelProperty("交强应收费用")
+    private String jqReceivablePremium;
+
+    @Schema(description = "商业应收费用")
+    @ExcelProperty("商业应收费用")
+    private String syReceivablePremium;
+
+    @Schema(description = "驾意应收费用")
+    @ExcelProperty("驾意应收费用")
+    private String jyReceivablePremium;
+
+    @TableField(exist = false)
+    @Schema(description = "总应收金额")
+    @ExcelProperty("总应收金额")
+    private String receivableAmount;
+
+    @Schema(description = "手续费是否已经结算")
+    @ExcelProperty("手续费是否已经结算")
+    private String superviseSettlement;
+
+    @Schema(description = "跟单费是否已经结算")
+    @ExcelProperty("跟单费是否已经结算")
+    private String otherSettlement;
+
+    @Schema(description = "驾意险手续费是否已经结算")
+    @ExcelProperty("驾意险手续费是否已经结算")
+    private String jySuperviseSettlement;
+
+    @Schema(description = "驾意跟单位是否已经结算")
+    @ExcelProperty("驾意跟单位是否已经结算")
+    private String jyOtherSettlement;
+
+    @Schema(description = "平台协议车险应收是否已经结算  0 未结算  1 结算")
+    @ExcelProperty("平台协议车险应收是否已经结算")
+    private String platformSuperviseSettlement;
+
+    @Schema(description = "平台协议非车险应收是否已经结算  0 未结算  1 结算")
+    @ExcelProperty("平台协议非车险应收是否已经结算")
+    private String platformOtherSettlement;
+
+    @Schema(description = "维护人工号")
+    @ExcelProperty("维护人工号")
+    private String leaderId;
+
+    @Schema(description = "维护人名称")
+    @ExcelProperty("维护人名称")
+    private String leaderName;
+
+    @Schema(description = "对接人")
+    @ExcelProperty("对接人")
+    private String contactPerson;
+
+    @Schema(description = "对接人手机号")
+    private String contactPersonPhone;
+
+    @Schema(description = "系统code")
+    @ExcelProperty("系统code")
+    private String systemCode;
+
+    @Schema(description = "业务来源")
+    @ExcelProperty("业务来源")
+    private String businessSource;
+
+    // 设置初始值为0, 未结算
+    @Schema(description = "结算状态(编码)")
+    @ExcelProperty("结算状态(编码)")
+    private String settlementStatus="0";
+
+    @Schema(description = "结算状态(转义后)")
+    @ExcelProperty("结算状态(转义后)")
+    private String settlementStatusName;
+
+    @Schema(description = "增加类型")
+    @ExcelProperty("增加类型")
+    private String addType;
+
+    @TableField(exist = false)
+    @Schema(description = "交强起保日期")
+    @ExcelProperty("交强起保日期")
+    private String jqStartDate;
+
+    @TableField(exist = false)
+    @Schema(description = "商业起保日期")
+    @ExcelProperty("商业起保日期")
+    private String syStartDate;
+
+    @TableField(exist = false)
+    @Schema(description = "订单类型")
+    @ExcelProperty("订单类型")
+    private String orderType;
+
+    @TableField(exist = false)
+    @Schema(description = "订单类型(code)")
+    private String entryStatus;
+
+    @TableField(exist = false)
+    @Schema(description = "业务员类型 团队/渠道/电销/个代 5:团队 6:个代 7:渠道 8 :电销")
+    private String typeAttr;
+
+    @TableField(exist = false)
+    @Schema(description = "业务员类型 团队/渠道/电销/个代 5:团队 6:个代 7:渠道 8 :电销")
+    private String typeAttrName;
+
+    @TableField(exist = false)
+    @Schema(description = "实际签单用户手机号2")
+    private String realQuoteUserId;
+
+    @TableField(exist = false)
+    @Schema(description = "实际签单用户手机号")
+    private String realQuoteUserName;
+
+    @TableField(exist = false)
+    @Schema(description = "订单费用表")
+    private InsFeeOrders insFeeOrders;
+
+    @TableField(exist = false)
+    @Schema(description = "是否已经开票")
+    private String invoiceStatusName;
+
+    @TableField(exist = false)
+    @Schema(description = "订单关联的发票信息")
+    private String invoiceId;
+
+    @TableField(exist = false)
+    @Schema(description = "地区归属")
+    private String companyNameSimple;
+
+}

+ 26 - 4
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -93,6 +93,20 @@ public class ReceivableController {
         return HttpResult.ok(new InsPlyIncomeVO(data, receivablePageIds));
     }
 
+    @PostMapping("/exportTemplateReceivableList")
+    @Operation(summary = "导出模板私有协议手续费")
+    public HttpResult<String> exportTemplateReceivableList(){
+        String receivablePageIds = receivableService.exportTemplateReceivableList();
+        return HttpResult.ok(receivablePageIds);
+    }
+
+    @PostMapping("/importReceivableListUpdate")
+    @Operation(summary = "导入私有协议手续费修改")
+    public HttpResult<ImportUpdateExcelResultVo> importReceivableListUpdate(@RequestParam("file") MultipartFile file){
+        ImportUpdateExcelResultVo importExcelResultVo = receivableService.importReceivableListUpdate(file);
+        return HttpResult.ok(importExcelResultVo);
+    }
+
     /**
      *
      * @author lipf
@@ -332,16 +346,24 @@ public class ReceivableController {
     @PostMapping("exportSuperviseExcel")
     @Operation(summary = "导出应收手续费excel文件(车险)")
     public void exportSuperviseExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        receivableQueryVo.setAgreementType("2");
-        receivableQueryVo.setQueryType("1");
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())){
+            receivableQueryVo.setAgreementType("2");
+        }
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("1");
+        }
         receivableService.exportSuperviseExcel(receivableQueryVo);
     }
 
     @PostMapping("exportSuperviseJyExcel")
     @Operation(summary = "导出应收手续费excel文件(非车险)")
     public void exportSuperviseJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        receivableQueryVo.setAgreementType("2");
-        receivableQueryVo.setQueryType("3");
+        if (StrUtil.isBlank(receivableQueryVo.getAgreementType())){
+            receivableQueryVo.setAgreementType("2");
+        }
+        if (StrUtil.isBlank(receivableQueryVo.getQueryType())){
+            receivableQueryVo.setQueryType("3");
+        }
         receivableService.exportSuperviseJyExcel(receivableQueryVo);
     }
 

+ 13 - 0
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -355,4 +355,17 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      * @return
      */
     boolean platformSettlement(PlatformSettlementVo platformSettlementVo);
+
+    /**
+     * 导出模板私有协议手续费
+     * @return
+     */
+    String exportTemplateReceivableList();
+
+    /**
+     * 导入私有协议手续费修改
+     * @param file
+     * @return
+     */
+    ImportUpdateExcelResultVo importReceivableListUpdate(MultipartFile file);
 }

+ 130 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -885,6 +885,136 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         }
     }
 
+    @Override
+    public String exportTemplateReceivableList() {
+        List<InsPlyIncomeExportVo> emptyList = ListUtil.empty();
+
+        // 调用动态导出
+        return exportBaseService.upLoadFile(
+                InsPlyIncomeExportVo.class,
+                emptyList,
+                "私有协议应收-批量修改-导出模板-" + Instant.now()
+        );
+    }
+
+    @Override
+    public ImportUpdateExcelResultVo importReceivableListUpdate(MultipartFile file) {
+        String userName = baseController.getUserName();
+        log.info("用户[{}]导入平台协议文件",userName);
+        ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
+        List<ReceivableExportExcelVo> receivableExportExcelVos = importReceivableExcel(file);
+        if (CollUtil.isEmpty(receivableExportExcelVos)){
+            throw new SystemException("数据不能为空,导入失败");
+        }
+        AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
+        // 获取保司名称
+        HttpResult<List<EsmInsCompany>> listHttpResult = esmInsCompanyClient.liveCompanyList();
+        AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
+
+        int failedNumber = 0;
+        List<ReceivableExportExcelVo> failedExcel = new ArrayList<>();
+        // 只存储需要【修改】的数据
+        List<InsPlyIncome> updateExcel = new ArrayList<>();
+
+        // 校验Excel内部保单号重复
+        Set<String> existPolicyNoSet = new HashSet<>();
+        Set<String> repeatPolicyNoSet = new HashSet<>();
+
+        for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
+            String orderNo = vo.getOrderNo();
+            if (existPolicyNoSet.contains(orderNo)) {
+                repeatPolicyNoSet.add(orderNo);
+            } else {
+                existPolicyNoSet.add(orderNo);
+            }
+        }
+
+        // 处理数据
+        for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
+            // 1. 空数据校验
+            ImportResultVo resultVo = vo.checkEmpty();
+            if (!resultVo.isSuccess()) {
+                failedNumber++;
+                vo.setErrorMessage(resultVo.getMessage());
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 2. Excel内部保单号重复
+            if (repeatPolicyNoSet.contains(vo.getOrderNo())) {
+                failedNumber++;
+                vo.setErrorMessage("订单号重复");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 3. 查询数据库中是否已存在该订单号
+            InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
+                    .eq(InsPlyIncome::getOrderNo, vo.getOrderNo()));
+
+            // 数据库不存在 → 直接失败
+            if (Objects.isNull(existIncome)) {
+                failedNumber++;
+                vo.setErrorMessage("订单号不存在,不允许新增");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 数据库已存在 → 继续后续校验
+            // 判断已开票 / 已结算
+            if ("1".equals(existIncome.getSuperviseSettlement()) || "1".equals(existIncome.getOtherSettlement())
+                    || "1".equals(existIncome.getJySuperviseSettlement()) || "1".equals(existIncome.getJyOtherSettlement())
+                    || "1".equals(existIncome.getPlatformSuperviseSettlement()) || "1".equals(existIncome.getPlatformOtherSettlement())) {
+                failedNumber++;
+                vo.setErrorMessage("应收数据已结算");
+                failedExcel.add(vo);
+                continue;
+            }
+
+            // 封装修改数据
+            InsPlyIncome insPlyIncome = new InsPlyIncome();
+            insPlyIncome.setId(existIncome.getId());
+            insPlyIncome.setLicenseNo(vo.getLicenseNo());
+            insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
+            insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
+            insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherCostsProportion());
+            insPlyIncome.setSyPolicyNo(vo.getSyPolicyNo());
+            insPlyIncome.setSySuperviseCostsProportion(vo.getSySuperviseCostsProportion());
+            insPlyIncome.setSyOtherCostsProportion(vo.getSyOtherCostsProportion());
+            insPlyIncome.setJyPolicyNo(vo.getJyPolicyNo());
+            insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
+            insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
+            insPlyIncome.setContactPerson(vo.getDockingPerson());
+
+            // 加入修改列表
+            updateExcel.add(insPlyIncome);
+        }
+
+        // 执行批量更新(只更新,不新增)
+        if (CollUtil.isNotEmpty(updateExcel)) {
+            baseMapper.updateById(updateExcel);
+        }
+
+        // ===================== 生成失败数据下载链接 =====================
+        String failFileUrl = "";
+        if (CollUtil.isNotEmpty(failedExcel)) {
+            failFileUrl = exportBaseService.upLoadFile(
+                    ReceivableExportExcelVo.class,
+                    failedExcel,
+                    "平台协议应收-导入失败-" + Instant.now()
+            );
+        }
+
+        // 返回结果
+        importExcelResultVo.setFailedData(failedExcel);
+        importExcelResultVo.setFailFileUrl(failFileUrl);
+        importExcelResultVo.setSuccessNumber(updateExcel.size());
+        importExcelResultVo.setFailedNumber(failedNumber);
+
+        return importExcelResultVo;
+    }
+
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean settlement(SettlementVo settlementVo) {

+ 1 - 3
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -382,9 +382,7 @@
         LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
         LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
         LEFT JOIN ins_orders_policy iop ON ipi.order_no = iop.order_no
-        WHERE
-        1=1
-        AND NOT EXISTS ( SELECT 1 FROM ins_ply_income_invoice_link ipil WHERE ipil.income_id = ipi.id )
+        WHERE 1=1 and ipi.settlement_status = '0' and ipi.is_delete  = 0
         <if test="receivableQueryVo.queryType != null and receivableQueryVo.queryType == 1">
             AND ipi.supervise_settlement = 0
         </if>