Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260518'

jiakai 4 месяцев назад
Родитель
Сommit
d2d6e25781

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementExcelDto.java

@@ -52,6 +52,10 @@ public class ExportSuperviseSettlementExcelDto {
     @ExcelProperty(value = "实收金额")
     private String actualReceivedAmount;
 
+    @Schema(description = "应收金额")
+    @ExcelProperty(value = "应收金额")
+    private String receivableSupervisePremium;
+
     @Schema(description = "收款日期")
     @ExcelProperty(value = "收款日期")
     private String receivePaymentDate;

+ 0 - 1
platform/src/main/resources/mapper/PtlAgreementAttributionMapper.xml

@@ -37,7 +37,6 @@
         <if test="ptlAgreementAttributionQueryVo.username != null and ptlAgreementAttributionQueryVo.username != ''">
             and paa.username like concat('%',#{ptlAgreementAttributionQueryVo.username},'%')
             or paa.user_abbr like concat('%',#{ptlAgreementAttributionQueryVo.username},'%')
-            or eic.name_simple like concat('%',#{ptlAgreementAttributionQueryVo.username},'%')
         </if>
         <if test="ptlAgreementAttributionQueryVo.quoteStatus != null and ptlAgreementAttributionQueryVo.quoteStatus != ''">
             and paa.quote_status = #{ptlAgreementAttributionQueryVo.quoteStatus}

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/controller/PtlAgreementCostController.java

@@ -38,7 +38,7 @@ public class PtlAgreementCostController {
     @OperatorTrajectory(moduleName = "报价配置/费用管理/新增费用",OperationDict = OperationTypeEnum.IN_AGREEMENT,mapperClass = PtlAgreementCostMapper.class,entityClass = PtlAgreemenCostAdd.class)
     @Operation(summary = "协议费用管理新增")
     @PostMapping("save")
-    public HttpResult add(@RequestBody @Valid PtlAgreemenCostAdd ptlAgreemenCostAdd){
+    public HttpResult<String> add(@RequestBody @Valid PtlAgreemenCostAdd ptlAgreemenCostAdd){
         return ptlAgreementCostService.save(ptlAgreemenCostAdd);
     }
 

+ 14 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -349,6 +349,13 @@ public class ReceivableController {
         return HttpResult.ok(receivableService.superviseSettlementExcel(page,settlementQueryVo));
     }
 
+    @PostMapping("platformSettlementExcel")
+    @Operation(summary = "平台协议结算记录")
+    public HttpResult<Page<ExportSuperviseSettlementExcelDto>> platformSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) {
+        Page page = settlementQueryVo.getPage();
+        return HttpResult.ok(receivableService.platformSettlementExcel(page,settlementQueryVo));
+    }
+
 
     @PostMapping("exportSuperviseSettlementExcel")
     @Operation(summary = "导出应收手续费结算记录excel文件")
@@ -357,6 +364,13 @@ public class ReceivableController {
         receivableService.exportSuperviseSettlementExcel(page,settlementQueryVo);
     }
 
+    @PostMapping("exportPlatformSettlementExcel")
+    @Operation(summary = "导出平台结算记录excel文件")
+    public void exportPlatformSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportPlatformSettlementExcel(page,settlementQueryVo);
+    }
+
     @PostMapping("superviseSettlementDetailExcel")
     @Operation(summary = "应收手续费结算明细")
     public HttpResult superviseSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) {

+ 7 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -80,6 +80,13 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
     Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
+    /**
+     * 获取平台结算记录列表
+     * @param settlementQueryVo
+     * @return
+     */
+    Page<ExportSuperviseSettlementExcelDto> platformSettlementExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
     /**
      * 获取应收结算记录明细列表
      * @param settlementQueryVo

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostService.java

@@ -19,7 +19,7 @@ public interface PtlAgreementCostService extends IService<PtlAgreementCost> {
      * @author lipf
      * @date 2026/4/13 14:16
      */
-    HttpResult save(PtlAgreemenCostAdd ptlAgreemenCostAdd);
+    HttpResult<String> save(PtlAgreemenCostAdd ptlAgreemenCostAdd);
 
 
     /**

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

@@ -203,11 +203,23 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      */
     Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcel(Page page, SettlementQueryVo settlementQueryVo);
 
+    /**
+     * 平台协议结算记录
+     * @param settlementQueryVo
+     * @return
+     */
+    Page<ExportSuperviseSettlementExcelDto> platformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo);
+
     /**
      * 导出应收手续费结算记录excel
      */
     void exportSuperviseSettlementExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
+    /**
+     * 导出平台结算记录excel
+     */
+    void exportPlatformSettlementExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
+
     /**
      * 导出平台协议Excel模板
      */

+ 9 - 3
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -35,7 +35,6 @@ import com.jzg.organization.state.listener.CostStateListener;
 import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
-import org.redisson.api.IdGenerator;
 import org.redisson.api.RList;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -48,7 +47,6 @@ import org.springframework.util.CollectionUtils;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -99,8 +97,12 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HttpResult save(PtlAgreemenCostAdd ptlAgreemenCostAdd) {
+    public HttpResult<String> save(PtlAgreemenCostAdd ptlAgreemenCostAdd) {
         log.info("报价配置/费用管理/新增费用. ptlAgreemenCostAdd=[{}]", JSONUtil.toJsonStr(ptlAgreemenCostAdd));
+//        if(StrUtil.isEmpty(ptlAgreemenCostAdd.getPtlAgreementId()) || StrUtil.isEmpty(ptlAgreemenCostAdd.getPtlAgreementCode())){
+//            log.info("新增费用的时候,需要指定关联的协议信息。ptlAgreemenCostAdd=[{}]", JSONUtil.toJsonStr(ptlAgreemenCostAdd));
+//            return HttpResult.error("新增费用的时候,需要指定关联的协议信息");
+//        }
         List<CostAdd> costAddList = ptlAgreemenCostAdd.getCostAddList();
         if (costAddList.isEmpty()) {
             log.info("费用管理:保存数据不能为空");
@@ -111,6 +113,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
                 if (ListUtils.hasDuplicates(ptlAgreementCostAdd.getRuleConditions())){
                     throw new SystemException("添加数据存在相同费用规则,请检查");
                 }
+                if(StrUtil.isEmpty(costAdd.getPtlAgreementId())){
+                    log.info("新增费用的时候,需要指定关联的协议信息。ptlAgreemenCostAdd=[{}]", JSONUtil.toJsonStr(ptlAgreemenCostAdd));
+                    return HttpResult.error("新增费用的时候,需要指定关联的协议信息");
+                }
                 ptlAgreementCostAdd.setPtlAgreementId(costAdd.getPtlAgreementId());
                 ptlAgreementCostAdd.setProductId(costAdd.getProductId());
                 ptlAgreementCostAdd.setProductName(costAdd.getProductName());

+ 31 - 11
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementDispatchServiceImpl.java

@@ -1,6 +1,7 @@
 package com.jzg.organization.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -165,9 +166,26 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
                         String minName = ptlAreaLicenseService.convertAreaNumber2License(areaLicenseMap, attrlink.getMin());
                         attrlink.setMinName(minName);
                     }else{
-                        String minName = dictLabalId2Name.getOrDefault(attrlink.getMin(),attrlink.getMin());
+                        String minName = dictLabalId2Name.get(attrlink.getMin());
+                        if(StrUtil.isNotEmpty(minName)){
+                            attrlink.setMinName(minName);
+                        }else{
+                            List<String> names = new ArrayList<>();
+                            minName = attrlink.getMin();
+                            if(StrUtil.isNotEmpty(attrlink.getMin())){
+                                String[] split = attrlink.getMin().split(",");
+                                if(split.length >=2){
+                                    for (String s : split) {
+                                        names.add(dictLabalId2Name.get(s));
+                                    }
+                                    minName = String.join(",", names);
+                                }
+                            }
+                            attrlink.setMinName(minName);
+                        }
+
                         String maxName = dictLabalId2Name.getOrDefault(attrlink.getMax(),attrlink.getMax());
-                        attrlink.setMinName(minName);
+
                         attrlink.setMaxName(maxName);
                     }
                     PtlAgreementUndwrtRulesAttr undwrtRuleAttrByAttrCode = ptlAgreementUndwrtRulesAttrService.getUndwrtRuleAttrByAttrCode(attrlink.getAttrCode());
@@ -202,20 +220,22 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
                                 }
                             }
                         }else if("change_bs_account".equals(action.getActionCode())){
-                            String accountId = action.getActionJson().get("accountId").toString();
-                            if(Objects.nonNull(accountId)){
-                                HttpResult<PtlAgreementAttribution> agreementAttribution = platformClient.getAgreementAttribution2(accountId);
-                                //HttpResult<PtlAgreementAttribution> agreementAttribution = esmInsCompanyClient.getAgreementAttribution(accountId);
-                                if (agreementAttribution.getCode() == 200) {
-                                    PtlAgreementAttribution data = agreementAttribution.getData();
-                                    action.getActionJson().put("userName", data.getUsername());
-                                    action.getActionJson().put("companyName", data.getInsCompanyName());
+                            if (action.getActionJson() != null && !action.getActionJson().isEmpty()) {
+                                // 修改这里:直接使用 getString,即使值为 null 也不会报错
+                                String accountId = action.getActionJson().getString("accountId");
+                                // 你的 Objects.nonNull 判断依然有效且非常规范
+                                if (Objects.nonNull(accountId)) {
+                                    HttpResult<PtlAgreementAttribution> agreementAttribution = platformClient.getAgreementAttribution2(accountId);
+                                    if (agreementAttribution.getCode() == 200) {
+                                        PtlAgreementAttribution data = agreementAttribution.getData();
+                                        action.getActionJson().put("userName", data.getUsername());
+                                        action.getActionJson().put("companyName", data.getInsCompanyName());
+                                    }
                                 }
                             }
                         }
                     }
                 }
-
                 PtlAgreementDispatchVo.DispatchVo vo = new PtlAgreementDispatchVo.DispatchVo(dispatch,attrLinks,actions);
                 dispatchVos.getDispatchVos().add(vo);
             }

+ 54 - 16
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -1601,6 +1601,36 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     @Override
     public Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
         log.info("查询结算手续费结算记录:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
+        // 设置空条件
+        setNoneCondition(settlementQueryVo);
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.superviseSettlementExcelDtos(page, settlementQueryVo);
+        // 补充、转换列表的数据
+        supplementaryListData(exportSuperviseSettlementExcelDtos);
+        return exportSuperviseSettlementExcelDtos;
+    }
+
+    /**
+     * 平台协议结算记录
+     *
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public Page<ExportSuperviseSettlementExcelDto> platformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
+        log.info("查询平台结算记录:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
+        // 设置空条件
+        setNoneCondition(settlementQueryVo);
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.platformSettlementExcelDtos(page, settlementQueryVo);
+        // 补充、转换列表的数据
+        supplementaryListData(exportSuperviseSettlementExcelDtos);
+        return exportSuperviseSettlementExcelDtos;
+    }
+
+    /**
+     * 设置空条件
+     * @param settlementQueryVo
+     */
+    private static void setNoneCondition(SettlementQueryVo settlementQueryVo) {
         if("30".equals(settlementQueryVo.getInvoiceParty())){
             settlementQueryVo.setInvoiceParty(null);
         }
@@ -1610,7 +1640,13 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         if("30".equals(settlementQueryVo.getStatus())){
             settlementQueryVo.setStatus(null);
         }
-        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.superviseSettlementExcelDtos(page, settlementQueryVo);
+    }
+
+    /**
+     * 补充、转换列表的数据
+     * @param exportSuperviseSettlementExcelDtos
+     */
+    private void supplementaryListData(Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos) {
         exportSuperviseSettlementExcelDtos.getRecords().forEach(dto -> {
             if ("1".equals(dto.getInvoiceParty())) {
                 dto.setInvoiceParty("我方开票");
@@ -1644,7 +1680,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 }
             }
         });
-        return exportSuperviseSettlementExcelDtos;
     }
 
     /**
@@ -1656,20 +1691,23 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     @Override
     public void exportSuperviseSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
         Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.superviseSettlementExcelDtos(page, settlementQueryVo);
-        exportSuperviseSettlementExcelDtos.getRecords().forEach(dto -> {
-            if ("1".equals(dto.getInvoiceParty())) {
-                dto.setInvoiceParty("我方开票");
-            } else if ("2".equals(dto.getInvoiceParty())) {
-                dto.setInvoiceParty("保司开票");
-            }
-            dto.setInvoiceType(Objects.toString(dto.getInvoiceType(),""));
-            switch (dto.getInvoiceType()) {
-                case "1" -> dto.setInvoiceType("手续费");
-                case "2" -> dto.setInvoiceType("跟单费");
-                case "3" -> dto.setInvoiceType("驾意险手续费");
-                case "4" -> dto.setInvoiceType("驾意险跟单费");
-            }
-        });
+        // 补充、转换列表的数据
+        supplementaryListData(exportSuperviseSettlementExcelDtos);
+        List<ExportSuperviseSettlementExcelDto> list = exportSuperviseSettlementExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ExportSuperviseSettlementExcelDto.class, list, "车险手续费结算明细");
+    }
+
+    /**
+     * 导出平台结算记录excel文件
+     *
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public void exportPlatformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.platformSettlementExcelDtos(page, settlementQueryVo);
+        // 补充、转换列表的数据
+        supplementaryListData(exportSuperviseSettlementExcelDtos);
         List<ExportSuperviseSettlementExcelDto> list = exportSuperviseSettlementExcelDtos.getRecords();
         EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ExportSuperviseSettlementExcelDto.class, list, "车险手续费结算明细");
     }

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

@@ -512,6 +512,7 @@
         ipii.tax_point,
         ipi.order_no as orderNo,
         ipiis.actual_received_amount,
+        ipii.receivable_supervise_premium,
         ipiis.receive_payment_date,
         ipiis.create_by ,
         ipiis.create_time
@@ -572,6 +573,78 @@
         order by ipiis.create_time desc
     </select>
 
+    <select id="platformSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">
+        SELECT
+        ipiis.id AS settlementId,
+        -- 拼接需要合并的字段,DISTINCT 去重,SEPARATOR '、' 用顿号分隔
+        GROUP_CONCAT(DISTINCT ipiis.invoice_id SEPARATOR ',') AS invoiceId,
+        GROUP_CONCAT(DISTINCT io.company_id SEPARATOR ',') AS company_id,
+        GROUP_CONCAT(DISTINCT io.company_name SEPARATOR ',') AS company_name,
+        GROUP_CONCAT(DISTINCT ipii.invoice_type SEPARATOR ',') AS invoice_type,
+        GROUP_CONCAT(DISTINCT ipii.invoice_party SEPARATOR ',') AS invoice_party,
+        GROUP_CONCAT(DISTINCT ipii.tax_point SEPARATOR ',') AS tax_point,
+        GROUP_CONCAT(DISTINCT ipi.order_no SEPARATOR ',') AS orderNo,
+        -- 金额/日期这类同一settlementId相同的字段,直接取任意一个即可
+        MAX(ipiis.actual_received_amount) AS actual_received_amount,
+        MAX(ipiis.receive_payment_date) AS receive_payment_date,
+        MAX(ipiis.create_by) AS create_by,
+        MAX(ipiis.create_time) AS create_time
+        FROM ins_ply_income_invoice_settlement ipiis
+        LEFT JOIN ins_ply_income_invoice ipii ON ipii.id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        LEFT JOIN ptl_agreement agree ON io.agreement_id = agree.id
+        WHERE 1 = 1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipii.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
+            and io.company_id = #{settlementQueryVo.companyId}
+        </if>
+        <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
+            and ipii.invoice_party = #{settlementQueryVo.invoiceParty}
+        </if>
+        <if test="settlementQueryVo.invoiceRiskType != null and settlementQueryVo.invoiceRiskType != ''">
+            and ipii.invoice_risk_type = #{settlementQueryVo.invoiceRiskType}
+        </if>
+        <if test="settlementQueryVo.status != null and settlementQueryVo.status != ''">
+            and ipii.status = #{settlementQueryVo.status}
+        </if>
+        <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
+            and ipiis.create_by = #{settlementQueryVo.settlementPerson}
+        </if>
+        <if test="settlementQueryVo.agreementType != null and settlementQueryVo.agreementType != ''">
+            AND (agree.agreement_type = #{settlementQueryVo.agreementType} or agree.agreement_type is null)
+        </if>
+        <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
+            AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+        </if>
+        <if test="settlementQueryVo.settlementId != null and settlementQueryVo.settlementId != ''">
+            AND ipiis.id = #{settlementQueryVo.settlementId}
+        </if>
+        <if test="settlementQueryVo.settlementDateStart != null and settlementQueryVo.settlementDateStart != ''">
+            and ipiis.create_time >= date(#{settlementQueryVo.settlementDateStart})
+        </if>
+        <if test="settlementQueryVo.settlementDateEndStr != null and settlementQueryVo.settlementDateEndStr != ''">
+            and ipiis.create_time &lt;= date(#{settlementQueryVo.settlementDateEndStr})
+        </if>
+        <if test="settlementQueryVo.settlementId != null and settlementQueryVo.settlementId != ''">
+            AND ipiis.id = #{settlementQueryVo.settlementId}
+        </if>
+        GROUP BY ipiis.id
+        order by ipiis.create_time desc
+    </select>
+
 <!--    <select id="getSuperviseSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">-->
 <!--        select-->
 <!--            ipiis.id as settlementId,-->
@@ -639,7 +712,10 @@
         LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
         LEFT JOIN ins_orders io ON ipi.order_no = io.id
         WHERE
-        1=1
+        1 = 1
+        <if test="settlementQueryVo.settlementId != null and settlementQueryVo.settlementId != ''">
+            and ipiis.id = #{settlementQueryVo.settlementId}
+        </if>
         <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
             AND ipiis.id IN
             <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">