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

Merge remote-tracking branch 'origin/master'

Qchen 1 месяц назад
Родитель
Сommit
4c768352db

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/rights/vo/InsOrderRightsVo.java

@@ -3,7 +3,9 @@ package com.jzg.commons.entity.rights.vo;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.jzg.commons.entity.rights.po.InsOrderRights;
 import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
@@ -18,6 +20,8 @@ import java.util.Date;
  * @date 2026/3/13 16:46
  */
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class InsOrderRightsVo {
 
     @Schema(description = "id")

+ 9 - 6
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/service/Impl/HuaTaiCrawlerRequestImpl.java

@@ -853,7 +853,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
             Map<String, Object> body = exchangeForm(url, Map.of("cmd", "submitZRG"), data, buildManualUwHeaders());
 
             UnderwritingResultsVo r = new UnderwritingResultsVo();
-            r.setUnderwritingStatus(InsOrderStatusEnum.PAY_PENDING);
+            r.setUnderwritingStatus(InsOrderStatusEnum.AUDIT_FAIL);
             r.setCompanyOrderNo(str(body, "quotationno"));
             r.setJqApplyNo(str(body, "proposal_no_jq"));
             r.setSyApplyNo(str(body, "proposal_no_sy"));
@@ -872,7 +872,9 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
                 return r;
             }
             int s = html.indexOf("原因"), e = html.lastIndexOf("。");
-            throw new SystemException("审核未通过:" + (s >= 0 && e > s ? html.substring(s, e) : "审核未通过"));
+            // throw new SystemException("审核未通过:" + (s >= 0 && e > s ? html.substring(s, e) : "审核未通过"));
+            r.setUnderwritingResult(s >= 0 && e > s ? html.substring(s, e) : "审核未通过");
+            return r;
         } catch (Exception e) { throw new SystemException(e.getMessage()); }
     }
 
@@ -1018,19 +1020,20 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         String body = post(ORIGIN + "/htcsp/DocumentPrintAction.do?cmd=electronicPolicyEndorseDownload",
                 buildDocumentHeaders(req.getCookie()), fd);
         HtCrawlerDownloadPolicyResponse res = JSONObject.parseObject(body, HtCrawlerDownloadPolicyResponse.class);
-        log.info("下载保单响应结果,{}", JSONObject.toJSONString(res));
+        log.info("华泰电子保单---订单号{},保单号{},下载保单响应结果,{}", order.getOrdersNo(), no, JSONObject.toJSONString(res));
         DownloadPolicyResultVo r = new DownloadPolicyResultVo();
         List<HtCrawlerDownloadPolicyResponse.FtpdownloadJson> ftpdownloadJson = res.getFtpdownloadJson();
         if(!ftpdownloadJson.isEmpty()) {
             if (jq) {
                 r.setJqUrl(ftpdownloadJson.get(0).getDownurl());
                 r.setJqFlagUrl(ftpdownloadJson.get(1).getBzdownurl());
-                log.info("下载交强保单地址:{}", r.getJqUrl());
+                log.info("华泰电子保单---订单号{},保单号{},下载交强保单地址:{}", order.getOrdersNo(), no, r.getJqUrl());
             } else {
                 r.setSyUrl(ftpdownloadJson.get(0).getDownurl());
-                log.info("下载商业保单地址:{}", r.getSyUrl());
+                log.info("华泰电子保单---订单号{},保单号{},下载商业保单地址:{}", order.getOrdersNo(), no, r.getSyUrl());
             }
         }
+        // 下载驾意险保单
         if (StringUtils.isNotBlank(order.getJyPolicyno())) {
             // 1. 构造请求头
             HttpHeaders headers = getHeaders();
@@ -1116,7 +1119,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         String jqApplication = "";
         String fcxApplication = "";
         if ("已通过核保已实收".equals(orderStatus)) {
-            orderStatusEnum = InsOrderStatusEnum.valueOf("PAY_PENDING");
+            orderStatusEnum = InsOrderStatusEnum.valueOf("UNDERWRITED"); // 已承保
             orderStatus = orderStatusEnum.getCode();
             List<Map<String, String>> fcxList = new ArrayList<>();
             // 1. 构建请求头 headers

+ 1 - 1
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java

@@ -1008,7 +1008,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
                                 kind.setPremium(new BigDecimal(kindInfoVo.getPremium()));
                             }
                         }
-                        if (kind.getKindCode().equals("A")) {
+                        if (kind.getKindCode().equals("A") && quoteResponse.getCarActualValue() != null) {
                             kind.setAmount(new BigDecimal(String.valueOf(quoteResponse.getCarActualValue())));
                         }
                     });

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

@@ -573,7 +573,7 @@ public class ReceivableController {
             module = "私有/平台协议应收",
             subModule = "订单审核",
             optType = QuoteNumberConstant.QuoteOptType.OPT_TYPE_16,
-            description = "批量修改",
+            description = "应收调整",
             orderSpEl = "#batchModifyVo",
             feedbackSpEl = "#ret.code + ' - ' + #ret.msg+ ' - ' + #ret.data"
     )

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

@@ -285,4 +285,12 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
     InsPlyIncomeInvoiceSettlementVo querySettledAmountByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
 
     List<PlatformCompanyFeeVO> selectPlatformCompanySettlementReport(@Param("query") SettlementReportQueryVo settlementReportQueryVo);
+
+    /**
+     * 查询应收涉及到的保险机构
+     *
+     * @author lipf
+     * @date 2026/8/6 9:38
+     */
+    List<String> queryDistinctParternerCompanyId(@Param("incomeIds") List<String> incomeIds);
 }

+ 38 - 6
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -906,15 +906,19 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         // 提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
         Set<String> allFollowIds = new HashSet<>();
         Set<String> allSettlementIds = new HashSet<>();
+        Set<String> allInvoiceIds = new HashSet<>();
         followGroupMap.values().forEach(list -> {
             list.forEach(vo -> {
                 allFollowIds.add(vo.getFollowId());
                 allSettlementIds.add(vo.getSettlementId());
+                allInvoiceIds.add(vo.getInvoiceId());
             });
         });
 
         // 批量查询跟单订单
         Map<String, InsFeeFollowOrder> followOrderMap = batchQueryFollowOrder(allFollowIds);
+        // 批量查询未结算的开票信息
+        Map<String, InsPlyIncomeInvoice> invoiceMap = batchQueryInvoice(allInvoiceIds);
         // 批量查询结算单
         Map<String, InsPlyIncomeInvoiceSettlement> settlementMap = batchQuerySettlement(allSettlementIds);
 
@@ -937,6 +941,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
             // 汇总当前分组所有followId、settlementId
             List<String> followIds = voList.stream().map(FollowCompanyFeeVO::getFollowId).distinct().toList();
+            List<String> invoiceIds = voList.stream().map(FollowCompanyFeeVO::getInvoiceId).distinct().toList();
             List<String> settlementIds = voList.stream().map(FollowCompanyFeeVO::getSettlementId).distinct().toList();
 
             // 应收金额(取第任意一条就行了)
@@ -983,7 +988,13 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             if (insFeeFollowOrderList.size() == insFeeFollowOrderList.stream().filter(insFeeFollowOrder -> SettlementIdentificationEnum.SETTLED.getCode().equals(insFeeFollowOrder.getSettlementIdentification())).count()){
                 vo.setTotalUnSettlementAmount(BigDecimal.ZERO);
             }else{
-                vo.setTotalUnSettlementAmount(totalInvoiced.subtract(totalSettlementAmount));
+                // 和wwq讨论过了,这个就是统计已开票未结算的数据
+                BigDecimal invoiceNoSettlement = invoiceIds.stream()
+                        .map(invoiceMap::get)
+                        .filter(Objects::nonNull)
+                        .map(InsPlyIncomeInvoice::getReceivableSupervisePremium)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                vo.setTotalUnSettlementAmount(invoiceNoSettlement);
             }
 
             aggResult.add(vo);
@@ -1005,6 +1016,21 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 .collect(Collectors.toMap(InsFeeFollowOrder::getId, Function.identity(), (k1, k2) -> k1));
     }
 
+    /**
+     * 批量查询未结算的开票信息
+     */
+    private Map<String, InsPlyIncomeInvoice> batchQueryInvoice(Set<String> invoiceIdSet) {
+        if (CollUtil.isEmpty(invoiceIdSet)) {
+            return new HashMap<>(0);
+        }
+        LambdaQueryWrapper<InsPlyIncomeInvoice> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(InsPlyIncomeInvoice::getId, invoiceIdSet);
+        wrapper.eq(InsPlyIncomeInvoice::getStatus, "0");
+        List<InsPlyIncomeInvoice> insPlyIncomeInvoices = insPlyIncomeInvoiceMapper.selectList(wrapper);
+        return insPlyIncomeInvoices.stream()
+                .collect(Collectors.toMap(InsPlyIncomeInvoice::getId, Function.identity(), (k1, k2) -> k1));
+    }
+
     /**
      * 批量查询结算单,返回ID->实体Map
      */
@@ -1191,7 +1217,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 newVo.setTotalReceivable(totalOtherReceivable);
                 newVo.setInvoiceType(invoiceType);
                 newVo.setTotalInvoiced(BigDecimal.ZERO);
-                newVo.setTotalUnInvoiced(BigDecimal.ZERO);
+                newVo.setTotalUnInvoiced(totalOtherReceivable);
                 newVo.setTotalSettlementAmount(BigDecimal.ZERO);
                 newVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
 
@@ -1205,6 +1231,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 if (CollUtil.isNotEmpty(insFeeFollowOrderReconciliations)){
                     InsFeeFollowOrderReconciliation insFeeFollowOrderReconciliation = CollUtil.getFirst(insFeeFollowOrderReconciliations);
                     newVo.setTotalReconciliationAmount(insFeeFollowOrderReconciliation.getReconciliationAmount());
+                    newVo.setTotalUnInvoiced(insFeeFollowOrderReconciliation.getReconciliationAmount());
                 }
 
                 newVo.setCompanyName(getCompanyName(partnerCompanyId, companyMap));
@@ -1789,9 +1816,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 //            String incomeId = invoicingVo.getIncomeIds().get(0);
 
             // 这里的公司应该是支公司的公司
-            invoice.setCompanyId(invoicingVo.getCompanyId());
-
-            
+            List<String> parternerCompanyId = baseMapper.queryDistinctParternerCompanyId(invoicingVo.getIncomeIds());
+            if(CollUtil.size(parternerCompanyId) >1 || CollUtil.size(parternerCompanyId) == 0){
+                throw new ServiceException("勾选的应收订单对应的保险机构不唯一");
+            }
+            invoice.setCompanyId(parternerCompanyId.get(0));
             invoice.setInvoiceType(invoicingVo.getInvoiceType());
             //  开票类型  1、手续费  2、跟单费  3、驾意险手续费 4、驾意险跟单费 5、平台应收-车险 6、平台应收-非车险
             if("1".equals(invoicingVo.getInvoiceType()) || "2".equals(invoicingVo.getInvoiceType())){
@@ -1840,6 +1869,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         if(invoicingVo == null){
             throw new ServiceException("无法开票,开票参数为空");
         }
+        if(CollUtil.isEmpty(invoicingVo.getIncomeIds())){
+            throw new SystemException("只选择要开票的应收数据");
+        }
 //        if(StrUtil.isEmpty(invoicingVo.getInvoiceNo())){
 //            throw new ServiceException("发票号不能为空");
 //        }
@@ -4596,7 +4628,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         vo.setPartnerCompanyId(partnerCompanyId);
         vo.setReceivablePremium(receivable);
         vo.setInvoiced(invoiced);
-        vo.setUninvoiced(BigDecimal.ZERO);
+        vo.setUninvoiced(receivable);
 
         // --- 查询数据库获取对账信息 ---
         // 构造查询条件:年、月、合作方ID

+ 66 - 43
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserAccountServiceImpl.java

@@ -279,42 +279,10 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
      */
     @Override
     public List<IncomeAndExpenseVo> getIncomeAndExpense(IncomeAndExpenseParam param){
-        log.info("查询收支明细记录:param=[{}]", JSONUtil.toJsonStr(param));
-        // 处理月份筛选参数
-        String createTimeStart = param.getCreateTimeStart();
-        String createTimeEnd = param.getCreateTimeEnd();
-        String userId = baseController.getUserId();
-        param.setUserId(userId);
-        param.setSystemCode(baseController.getSystemCode());
-        if (param.getMonth() != null && !param.getMonth().isEmpty()) {
-            // 如果传入了月份参数,计算该月的开始和结束时间
-            String monthStr = param.getMonth();
-            DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
-            YearMonth yearMonth = YearMonth.parse(monthStr, monthFormatter);
-            LocalDateTime monthStart = yearMonth.atDay(1).atStartOfDay();
-            LocalDateTime monthEnd = yearMonth.atEndOfMonth().atTime(23, 59, 59, 999999999);
 
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-            createTimeStart = monthStart.format(formatter);
-            createTimeEnd = monthEnd.format(formatter);
-            param.setCreateTimeStart(createTimeStart);
-            param.setCreateTimeEnd(createTimeEnd);
-        }
-        if (createTimeStart != null && !createTimeStart.isEmpty()) {
-            log.info("createTimeStart=[{}]", createTimeStart);
-            if(StrUtil.length(createTimeStart) < "2026-07-15 23:59:59".length()){
-                createTimeStart += " 00:00:00";
-            }
-        }
-        if (createTimeEnd != null && !createTimeEnd.isEmpty()) {
-            log.info("createTimeEnd=[{}]",createTimeEnd);
-            if(StrUtil.length(createTimeEnd) < "2026-07-15 23:59:59".length()){
-                createTimeEnd += " 23:59:59";
-            }
-        }
-        param.setCreateTimeStart(createTimeStart);
-        param.setCreateTimeEnd(createTimeEnd);
-        List<IncomeAndExpenseList> recordsWithOutParam = sysAmountAuditingService.getIncomeAndExpense(new IncomeAndExpenseParam(param.getUserId(),param.getSystemCode()));
+        log.info("查询收支明细记录:param=[{}]", JSONUtil.toJsonStr(param));
+        String key = this.populateParam(param);
+        //List<IncomeAndExpenseList> recordsWithOutParam = sysAmountAuditingService.getIncomeAndExpense(new IncomeAndExpenseParam(param.getUserId(),param.getSystemCode()));
         List<IncomeAndExpenseList> allRecords = sysAmountAuditingService.getIncomeAndExpense(param);
         allRecords = allRecords.stream().peek(action->{
             if("0".equals(action.getStatus())){
@@ -364,20 +332,17 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
 
         // 按月份分组统计
         Map<String, IncomeAndExpenseVo.IncomeAndExpense> monthSummaryMap = new TreeMap<>(Collections.reverseOrder());
-        for (IncomeAndExpenseList record : recordsWithOutParam) {
+        for (IncomeAndExpenseList record : allRecords) {
             if (record.getCreateTime() == null) continue;
-            // 获取月份(格式:yyyy-MM)
-            String month = record.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM"));
-
             // 获取或创建月度汇总对象
-            IncomeAndExpenseVo.IncomeAndExpense summary = monthSummaryMap.get(month);
+            IncomeAndExpenseVo.IncomeAndExpense summary = monthSummaryMap.get(key);
             if (summary == null) {
                 summary = new IncomeAndExpenseVo.IncomeAndExpense();
-                summary.setMonth(month);
+                summary.setMonth(key);
                 summary.setIncome(BigDecimal.ZERO);
                 summary.setExpense(BigDecimal.ZERO);
                 summary.setBalance(BigDecimal.ZERO);
-                monthSummaryMap.put(month, summary);
+                monthSummaryMap.put(key, summary);
             }
 
             // 更新收入或支出
@@ -424,7 +389,12 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
 
             // 筛选当前月份的明细记录
             List<IncomeAndExpenseVo.IncomeAndExpenseList> monthRecords = allRecords.stream()
-                    .filter(record -> entry.getKey().equals(record.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM"))))
+                    .filter(record -> {
+                        if(StrUtil.isEmpty(entry.getKey())){
+                            return true;
+                        }
+                        return entry.getKey().equals(record.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM")));
+                    })
                     .map(action->{
                         IncomeAndExpenseVo.IncomeAndExpenseList a = new IncomeAndExpenseVo.IncomeAndExpenseList();
                         BeanUtils.copyProperties(action,a);
@@ -437,6 +407,59 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
         return result;
     }
 
+    /**
+     * 对查询参数进行预处理
+     *
+     * @author lipf
+     * @date 2026/8/6 9:51
+     */
+    private String populateParam(IncomeAndExpenseParam param){
+         String key  = "-";
+        if(StrUtil.isEmpty(param.getCreateTimeStart()) && StrUtil.isEmpty(param.getCreateTimeEnd())){
+            //key=  "全量汇总数据";
+            key = "";
+        }else{
+            key = String.format("%s到%s",Objects.toString(param.getCreateTimeStart(),""),Objects.toString(param.getCreateTimeEnd(),""));
+        }
+
+        // 处理月份筛选参数
+        String createTimeStart = param.getCreateTimeStart();
+        String createTimeEnd = param.getCreateTimeEnd();
+        String userId = baseController.getUserId();
+        param.setUserId(userId);
+        param.setSystemCode(baseController.getSystemCode());
+        if (param.getMonth() != null && !param.getMonth().isEmpty()) {
+            // 如果传入了月份参数,计算该月的开始和结束时间
+            String monthStr = param.getMonth();
+            DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
+            YearMonth yearMonth = YearMonth.parse(monthStr, monthFormatter);
+            LocalDateTime monthStart = yearMonth.atDay(1).atStartOfDay();
+            LocalDateTime monthEnd = yearMonth.atEndOfMonth().atTime(23, 59, 59, 999999999);
+
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            createTimeStart = monthStart.format(formatter);
+            createTimeEnd = monthEnd.format(formatter);
+            param.setCreateTimeStart(createTimeStart);
+            param.setCreateTimeEnd(createTimeEnd);
+            key= String.format("%d-%02d", yearMonth.getYear(), yearMonth.getMonthValue());
+        }
+        if (createTimeStart != null && !createTimeStart.isEmpty()) {
+            log.info("createTimeStart=[{}]", createTimeStart);
+            if(StrUtil.length(createTimeStart) < "2026-07-15 23:59:59".length()){
+                createTimeStart += " 00:00:00";
+            }
+        }
+        if (createTimeEnd != null && !createTimeEnd.isEmpty()) {
+            log.info("createTimeEnd=[{}]",createTimeEnd);
+            if(StrUtil.length(createTimeEnd) < "2026-07-15 23:59:59".length()){
+                createTimeEnd += " 23:59:59";
+            }
+        }
+        param.setCreateTimeStart(createTimeStart);
+        param.setCreateTimeEnd(createTimeEnd);
+        return key;
+    }
+
     @Override
     public List<IncomeAndExpenseVo> getIncomeAndExpenseOld(IncomeAndExpenseParam param) {
         log.info("查询收支明细记录:param=[{}]", JSONUtil.toJsonStr(param));

+ 13 - 0
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -330,6 +330,9 @@
     <select id="getReceivablePage" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
         <include refid="query"/>
         and ipi.system_code = #{receivableQueryVo.systemCode}
+        <if test="receivableQueryVo.riskCode != null and receivableQueryVo.riskCode != '' ">
+            and io.product_name = #{receivableQueryVo.riskCode}
+        </if>
         <if test="receivableQueryVo.invoiceId != null and receivableQueryVo.invoiceId != ''" >
             AND ipi.id  in (
             select ipiil.income_id  from ins_ply_income_invoice_link ipiil where ipiil.invoice_id  = #{receivableQueryVo.invoiceId} and ipiil.is_delete = 0
@@ -2211,6 +2214,16 @@
         GROUP BY ipi.company_id, io.docking_person,io.docking_person_phone
         order by settle_idsStr desc
     </select>
+    <!-- 查询应收涉及到的保险机构 lipf 2026年8月6日09:38:54 -->
+    <select id="queryDistinctParternerCompanyId" resultType="java.lang.String">
+        select distinct ipi.partner_company_id  from ins_ply_income ipi
+        <where>
+            ipi.id in
+            <foreach collection="incomeIds" separator="," close=")" open="(" item="id">
+                #{id}
+            </foreach>
+        </where>
+    </select>
 
 
 </mapper>