Bladeren bron

Merge remote-tracking branch 'origin/master'

lixiaolong 3 maanden geleden
bovenliggende
commit
50aeb42876
20 gewijzigde bestanden met toevoegingen van 334 en 49 verwijderingen
  1. 5 1
      commons/src/main/java/com/jzg/commons/entity/finance/vo/FollowCompanyFeeVO.java
  2. 4 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/PlatformCompanyFeeVO.java
  3. 9 0
      tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java
  4. 26 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/client/SysUserClient.java
  5. 109 19
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeAuditServiceImpl.java
  6. 28 7
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java
  7. 2 2
      tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeAuditMapper.xml
  8. 1 1
      tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java
  9. 16 0
      tenant/organization/src/main/java/com/jzg/organization/controller/SysUserJzgInfoController.java
  10. 15 0
      tenant/organization/src/main/java/com/jzg/organization/controller/UserController.java
  11. 11 1
      tenant/organization/src/main/java/com/jzg/organization/mapper/InsPlyIncomeInvoiceSettlementMapper.java
  12. 1 1
      tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java
  13. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java
  14. 9 0
      tenant/organization/src/main/java/com/jzg/organization/service/SysUserJzgInfoService.java
  15. 8 0
      tenant/organization/src/main/java/com/jzg/organization/service/SysUserService.java
  16. 18 9
      tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java
  17. 29 0
      tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserJzgInfoServiceImpl.java
  18. 11 0
      tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserServiceImpl.java
  19. 23 0
      tenant/organization/src/main/resources/mapper/InsPlyIncomeInvoiceSettlementMapper.xml
  20. 8 7
      tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

+ 5 - 1
commons/src/main/java/com/jzg/commons/entity/finance/vo/FollowCompanyFeeVO.java

@@ -1,6 +1,5 @@
 package com.jzg.commons.entity.finance.vo;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -37,6 +36,11 @@ public class FollowCompanyFeeVO {
     /** 未结算总金额  totalInvoiced - totalSettlementAmount */
     private BigDecimal totalUnSettlementAmount;
 
+    /**
+     * 已结算记录的序号集
+     */
+    private String settleIdsStr;
+
     /** 回款差额 */
     private BigDecimal totalPaymentDifference;
 

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/PlatformCompanyFeeVO.java

@@ -0,0 +1,4 @@
+package com.jzg.commons.entity.finance.vo;
+
+public class PlatformCompanyFeeVO extends FollowCompanyFeeVO{
+}

+ 9 - 0
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java

@@ -236,4 +236,13 @@ public interface OrgClient {
      */
     @PostMapping("/userAccount/addUserAccountChangeLog")
     HttpResult<String> addUserAccountChangeLog(@RequestBody SysUserAccountChangeLog changeLog);
+
+    /**
+     * 查询sys_user_jzg_info 表的id和userId的对应关系
+     *
+     * @author lipf
+     * @date 2026/6/30 14:15
+     */
+    @PostMapping("/api/v1/organization/queryJzgInfoId2UserId")
+    public HttpResult<Map<String,String>> queryJzgInfoId2UserId(@RequestBody List<String> jzgInfoTids);
 }

+ 26 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/client/SysUserClient.java

@@ -0,0 +1,26 @@
+package com.jzg.quotation.summary.client;
+
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.po.SysUser;
+import com.jzg.quotation.summary.utils.FeignConfig;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+
+/**
+ * 调用生活服务平台client
+ */
+@FeignClient(value = "jzg-organization", configuration = FeignConfig.class)
+public interface SysUserClient {
+
+
+    /**
+     * 根据userId查询用户信息SysUser
+     *
+     * @author lipf
+     * @date 2026/6/30 11:27
+     */
+    @GetMapping(value = "/userInfo/querySysUserByUserId")
+    public HttpResult<SysUser> querySysUserByUserId(@RequestParam String userId);
+}

+ 109 - 19
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeAuditServiceImpl.java

@@ -1,6 +1,7 @@
 package com.jzg.quotation.summary.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -35,6 +36,7 @@ import com.jzg.quotation.commons.client.PartnerDistributionClient;
 import com.jzg.quotation.commons.client.PlatformClient;
 import com.jzg.quotation.summary.client.EsmInsCompanyClient;
 import com.jzg.quotation.summary.client.LocalLivingClient;
+import com.jzg.quotation.summary.client.SysUserClient;
 import com.jzg.quotation.summary.entity.Result;
 import com.jzg.quotation.summary.entity.dto.ChannelRightsApiGrantReceiverDTO;
 import com.jzg.quotation.summary.entity.dto.ChannelRightsApiGrantRecordDTO;
@@ -121,6 +123,9 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     @Autowired
     private InsOrderRightsPackageMapper insOrderRightsPackageMapper;
 
+    @Autowired
+    private SysUserClient sysUserClient;
+
     @Autowired
     private ExportBaseServiceImpl exportBaseService;
 
@@ -130,6 +135,19 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 
     private final PartnerDistributionClient partnerDistributionClient;
 
+    /**
+     * 订单审核-任务中心,查询待审核任务
+     * <p>
+     * 功能说明:
+     * 1. 根据查询条件分页获取待审核的订单费用审计任务
+     * 2. 若指定了保险公司ID,则自动包含其下级保险公司的数据
+     * 3. 为每条记录填充保险公司完整层级路径名称
+     * 4. 计算每条订单的权益金额:
+     *    权益金额 = (交强出口费用 + 商业出口费用 + 驾意出口费用) - (交强出口留点费用 + 商业出口留点费用 + 驾意出口留点费用)
+     *
+     * @param param 查询参数,包含分页信息和筛选条件
+     * @return 分页结果,包含订单审核信息及计算后的权益金额
+     */
     @Override
     public Page<FeeAuditVo> queryPage(FeeAuditParam param) {
         log.info("订单审核-任务中心,查询待审核任务。param=[{}]", JSONUtil.toJsonStr(param));
@@ -261,6 +279,15 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 
     /**
      * 领取审核订单
+     * <p>
+     * 功能说明:
+     * 1. 检查订单是否已被Redis锁定,防止重复领取
+     * 2. 验证订单审核状态,已审核的订单不允许领取
+     * 3. 处理订单领取逻辑:
+     *    - 若订单已被当前用户领取,则刷新Redis锁
+     *    - 若订单已被其他用户领取,则拒绝操作
+     *    - 若订单未被领取,则在满足条件下进行领取
+     * 4. 限制每个用户最多同时领取10个未审核订单
      *
      * @param orderNo 订单编号
      */
@@ -299,6 +326,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
                 // 领取订单
                 audit.setReceiveUser(userName);
                 audit.setReceiveTime(LocalDateTime.now());
+//                audit.setAuditStatus(1);
                 this.updateById(audit);
 
                 // redis 锁定按钮
@@ -501,7 +529,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
             exportChangeLog.setAmount(feeOrders.getTotalPayablePremium());
             exportChangeLog.setOperType(1);
             exportChangeLog.setIsDelete(0);
-            exportChangeLog.setRemark("订单提成");
+            exportChangeLog.setRemark("保单费用");
             exportChangeLog.setAmountBefore(sumAmountUnpaid);
             orgClient.addUserAccountChangeLog(exportChangeLog);
 
@@ -560,6 +588,38 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     private void dealDistribution(InsFeeOrders feeOrders, SysUserAccount userAccount){
         log.info("处理分销逻辑。 feeOrders=[{}],userAccount=[{}]", JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount));
         SysUserAccount distributor1 = null,distributor2 = null,distributor3 = null;
+        List<String> jzgInfoTids = new ArrayList<>();
+        if(StrUtil.isNotEmpty(feeOrders.getFirstDistributorId())){
+            jzgInfoTids.add(feeOrders.getFirstDistributorId());
+        }
+        if(StrUtil.isNotEmpty(feeOrders.getSecondDistributorId())){
+            jzgInfoTids.add(feeOrders.getSecondDistributorId());
+        }
+        if(StrUtil.isNotEmpty(feeOrders.getThirdDistributorId())){
+            jzgInfoTids.add(feeOrders.getThirdDistributorId());
+        }
+        List<SysUserAccountChangeLog> builderIncomeLog =  new ArrayList<>();
+        if(CollUtil.isNotEmpty(jzgInfoTids)){
+            HttpResult<Map<String, String>> mapHttpResult = orgClient.queryJzgInfoId2UserId(jzgInfoTids);
+            if(mapHttpResult.getCode() != 200){
+                throw new ServiceException("服务间调用异常");
+            }
+            Map<String, String> idMaps = mapHttpResult.getData();
+            String distributor1UserId = "";
+            String distributor2UserId = "";
+            String distributor3UserId = "";
+            if(StrUtil.isNotEmpty(feeOrders.getFirstDistributorId())){
+                distributor1UserId = idMaps.getOrDefault(feeOrders.getFirstDistributorId(),"");
+            }
+            if(StrUtil.isNotEmpty(feeOrders.getSecondDistributorId())){
+                distributor2UserId = idMaps.getOrDefault(feeOrders.getSecondDistributorId(),"");
+            }
+            if(StrUtil.isNotEmpty(feeOrders.getThirdDistributorId())){
+                distributor3UserId = idMaps.getOrDefault(feeOrders.getThirdDistributorId(),"");
+            }
+            builderIncomeLog = this.builderIncomeLog(feeOrders.getOrderNo(),feeOrders,userAccount,distributor1UserId,distributor2UserId,distributor3UserId);
+        }
+
         // 一级分销费用户进账
         if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
             HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getFirstDistributorId());
@@ -592,7 +652,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         }
         // 增加账户的金额记录
         // modify by lipf, 2026年5月20日11:31:59 审核通过后,才需要 生成收入明细日志
-        List<SysUserAccountChangeLog>builderIncomeLog = this.builderIncomeLog(feeOrders.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
+
         HttpResult result2 = orgClient.addUserAccountIncomeLog(builderIncomeLog);
         AssertionUtils.isFail(result2.getCode() != 200,"账户记录添加失败,审核失败");
     }
@@ -711,39 +771,58 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
      * @param orderNo      订单号
      * @param feeOrders    费用
      * @param userAccount  分账用户
-     * @param distributor1 1级分销人员
-     * @param distributor2 2级分销人员
-     * @param distributor3 3级分销人员
-     * @return
+     * @param distributor1UserId 1级分销人员
+     * @param distributor2UserId 2级分销人员
+     * @param distributor3UserId 3级分销人员
      */
     private List<SysUserAccountChangeLog> builderIncomeLog(String orderNo,
                                                            InsFeeOrders feeOrders,
                                                            SysUserAccount userAccount,
-                                                           SysUserAccount distributor1,
-                                                           SysUserAccount distributor2,
-                                                           SysUserAccount distributor3){
+                                                           String distributor1UserId,
+                                                           String distributor2UserId,
+                                                           String distributor3UserId){
         log.info("生成收入明细日志:feeOrders=[{}],userAccount=[{}],distributor1=[{}],distributor2=[{}],distributor3=[{}]",
-                JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount), JSONUtil.toJsonStr(distributor1), JSONUtil.toJsonStr(distributor2), JSONUtil.toJsonStr(distributor3));
+                JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount), distributor1UserId, distributor2UserId, distributor3UserId);
         List<SysUserAccountChangeLog> incomeLogs = new ArrayList<>();
         // 1级分销费
         if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
             SysUserAccountChangeLog distributor1IncomeLog = new SysUserAccountChangeLog();
             distributor1IncomeLog.setRelatedOrderId(orderNo);
-            distributor1IncomeLog.setUserId(distributor1.getUserId());
+            distributor1IncomeLog.setUserId(distributor1UserId);
             distributor1IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor1IncomeLog.setAmountBefore(userAccount.getSumAmount());
-            //distributor1IncomeLog.setUserName(); TODO
+            HttpResult<SysUserAccount> result = orgClient.accountGet(distributor1UserId);
+            if(result.getCode() == 200 && result.getData() != null){
+                distributor1IncomeLog.setAmountBefore(result.getData().getSumAmountUnpaid());
+            }
+            distributor1IncomeLog.setOperType(2);
+            distributor1IncomeLog.setRemark("订单提成");
+            distributor1IncomeLog.setIsDelete(0);
+            HttpResult<SysUser> sysUserHttpResult = sysUserClient.querySysUserByUserId(distributor1UserId);
+            if(sysUserHttpResult.isSuccess() && sysUserHttpResult.getData() != null ){
+                distributor1IncomeLog.setUserName(sysUserHttpResult.getData().getUsername());
+            }
             incomeLogs.add(distributor1IncomeLog);
+
         }
 
         // 2级分销费
         if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
             SysUserAccountChangeLog distributor2IncomeLog = new SysUserAccountChangeLog();
             distributor2IncomeLog.setRelatedOrderId(orderNo);
-            distributor2IncomeLog.setUserId(distributor2.getUserId());
+            distributor2IncomeLog.setUserId(distributor2UserId);
             distributor2IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor2IncomeLog.setAmountBefore(userAccount.getSumAmount());
-            //distributor2IncomeLog.setUserName(); TODO
+            HttpResult<SysUserAccount> result = orgClient.accountGet(distributor2UserId);
+            if(result.getCode() == 200 && result.getData() != null){
+                distributor2IncomeLog.setAmountBefore(result.getData().getSumAmountUnpaid());
+            }
+
+            distributor2IncomeLog.setOperType(2);
+            distributor2IncomeLog.setRemark("订单提成");
+            distributor2IncomeLog.setIsDelete(0);
+            HttpResult<SysUser> sysUserHttpResult = sysUserClient.querySysUserByUserId(distributor2UserId);
+            if(sysUserHttpResult.isSuccess() && sysUserHttpResult.getData() != null ){
+                distributor2IncomeLog.setUserName(sysUserHttpResult.getData().getUsername());
+            }
             incomeLogs.add(distributor2IncomeLog);
         }
 
@@ -751,10 +830,19 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
             SysUserAccountChangeLog distributor3IncomeLog = new SysUserAccountChangeLog();
             distributor3IncomeLog.setRelatedOrderId(orderNo);
-            distributor3IncomeLog.setUserId(distributor3.getUserId());
+            distributor3IncomeLog.setUserId(distributor3UserId);
             distributor3IncomeLog.setAmount(feeOrders.getFirstDistributionFee());
-            distributor3IncomeLog.setAmountBefore(userAccount.getSumAmount());
-            //distributor3IncomeLog.setUserName(); TODO
+            HttpResult<SysUserAccount> result = orgClient.accountGet(distributor3UserId);
+            if(result.getCode() == 200 && result.getData() != null){
+                distributor3IncomeLog.setAmountBefore(result.getData().getSumAmountUnpaid());
+            }
+            distributor3IncomeLog.setOperType(2);
+            distributor3IncomeLog.setRemark("订单提成");
+            distributor3IncomeLog.setIsDelete(0);
+            HttpResult<SysUser> sysUserHttpResult = sysUserClient.querySysUserByUserId(distributor3UserId);
+            if(sysUserHttpResult.isSuccess() && sysUserHttpResult.getData() != null ){
+                distributor3IncomeLog.setUserName(sysUserHttpResult.getData().getUsername());
+            }
             incomeLogs.add(distributor3IncomeLog);
         }
         return incomeLogs;
@@ -906,6 +994,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         param.getPage().setPages(1);
         param.getPage().setSize(Integer.MAX_VALUE);
         param.setPages(1);
+        param.setSystemCode(baseController.getUserSystemCode());
+        param.setAuditStatus(param.getAuditStatus());
         param.setSize(Integer.MAX_VALUE);
         Page<FeeAuditVo> feeAuditVoPage = this.queryPage(param);
         List<FeeAuditVo> result = feeAuditVoPage.getRecords();

+ 28 - 7
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java

@@ -379,20 +379,41 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         BigDecimal jqCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJqCommissionRatio());
         BigDecimal syCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getSyCommissionRatio());
         BigDecimal jyCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJyCommissionRatio());
-        insFeeOrders.setJqCommissionRatio(jqCommissionRatio);
-        insFeeOrders.setSyCommissionRatio(syCommissionRatio);
-        insFeeOrders.setJyCommissionRatio(jyCommissionRatio);
+
         // 入口比例
         BigDecimal jqInletRatio = covertPercent(ptlAgreementCostRatioVo.getJqInletRatio());
         BigDecimal syInletRatio = covertPercent(ptlAgreementCostRatioVo.getSyInletRatio());
         BigDecimal jyInletRatio = covertPercent(ptlAgreementCostRatioVo.getJyInletRatio());
+
+        BigDecimal jqFollowRatio = BigDecimal.ZERO;
+        BigDecimal syFollowRatio = BigDecimal.ZERO;
+        BigDecimal jyFollowRatio = BigDecimal.ZERO;
+        // 跟单比例
+        if (jqInletRatio.compareTo(jqCommissionRatio) > 0){
+            jqFollowRatio = jqInletRatio.subtract(jqCommissionRatio);
+        }else{
+            jqCommissionRatio = jqInletRatio;
+        }
+        if (syInletRatio.compareTo(syCommissionRatio) > 0){
+            syFollowRatio = syInletRatio.subtract(syCommissionRatio);
+        }else{
+            syCommissionRatio = syInletRatio;
+        }
+        if (jyInletRatio.compareTo(jyCommissionRatio) > 0){
+            jyFollowRatio = jyInletRatio.subtract(jyCommissionRatio);
+        }else{
+            jyCommissionRatio = jyInletRatio;
+        }
+
+        // 手续费
+        insFeeOrders.setJqCommissionRatio(jqCommissionRatio);
+        insFeeOrders.setSyCommissionRatio(syCommissionRatio);
+        insFeeOrders.setJyCommissionRatio(jyCommissionRatio);
+        // 入口费用
         insFeeOrders.setJqInletRatio(jqInletRatio);
         insFeeOrders.setSyInletRatio(syInletRatio);
         insFeeOrders.setJyInletRatio(jyInletRatio);
-        // 跟单比例 
-        BigDecimal jqFollowRatio = jqInletRatio.subtract(jqCommissionRatio);
-        BigDecimal syFollowRatio = syInletRatio.subtract(syCommissionRatio);
-        BigDecimal jyFollowRatio = jyInletRatio.subtract(jyCommissionRatio);
+        // 跟单费
         insFeeOrders.setJqFollowRatio(jqFollowRatio);
         insFeeOrders.setSyFollowRatio(syFollowRatio);
         insFeeOrders.setJyFollowRatio(jyFollowRatio);

+ 2 - 2
tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeAuditMapper.xml

@@ -89,9 +89,9 @@
             <if test="param.receiveUser != null and param.receiveUser != ''">
                 and ifa.receive_user = #{param.receiveUser}
             </if>
-            <if test="param.receiveUser == null or param.receiveUser == ''">
+            <!--<if test="param.receiveUser == null or param.receiveUser == ''">
                 and ifa.receive_user is null
-            </if>
+            </if>-->
             <if test="param.allTodoReceive != null and param.allTodoReceive == true">
                 and ifa.receive_user is null
             </if>

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

@@ -732,7 +732,7 @@ public class ReceivableController {
      */
     @PostMapping("/platformCompanySuperviseSettlementReport")
     @Operation(summary = "平台公司结算报表")
-    public HttpResult<List<FollowCompanyFeeVO>> platformCompanySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+    public HttpResult<List<PlatformCompanyFeeVO>> platformCompanySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
         return HttpResult.ok(receivableService.platformCompanySuperviseSettlementReport(settlementReportQueryVo));
     }
 

+ 16 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/SysUserJzgInfoController.java

@@ -9,8 +9,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+
 
 @RestController
 public class SysUserJzgInfoController {
@@ -34,4 +39,15 @@ public class SysUserJzgInfoController {
         SysUserJzgInfo jzgInfo = sysUserJzgInfoService.getUserByUserId(userId);
         return  HttpResult.ok(jzgInfo);
     }
+
+    /**
+     * 查询sys_user_jzg_info 表的id和userId的对应关系
+     *
+     * @author lipf
+     * @date 2026/6/30 14:15
+     */
+    @PostMapping("/api/v1/organization/queryJzgInfoId2UserId")
+    public HttpResult<Map<String,String>> queryJzgInfoId2UserId(@RequestBody List<String> jzgInfoTids){
+        return HttpResult.ok(sysUserJzgInfoService.queryJzgInfoId2UserId(jzgInfoTids));
+    }
 }

+ 15 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/UserController.java

@@ -337,4 +337,19 @@ public class UserController extends BaseController {
         return sysUserService.getPartUserInfoByMobile(mobile);
     }
 
+
+    /**
+     * 根据userId查询用户信息SysUser
+     *
+     * @author lipf
+     * @date 2026/6/30 11:27
+     */
+    @Operation(summary = "根据userId查询用户信息SysUser", description = "根据userId查询用户信息SysUser")
+    @GetMapping(value = "/querySysUserByUserId")
+    public HttpResult<SysUser> querySysUserByUserId(@RequestParam String userId){
+        SysUser sysUser = sysUserService.querySysUserByUserId(userId);
+        return HttpResult.ok(sysUser);
+    }
+
+
 }

+ 11 - 1
tenant/organization/src/main/java/com/jzg/organization/mapper/InsPlyIncomeInvoiceSettlementMapper.java

@@ -1,11 +1,21 @@
 package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoice;
 import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoiceSettlement;
+import com.jzg.commons.entity.finance.vo.SettlementVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 public interface InsPlyIncomeInvoiceSettlementMapper extends BaseMapper<InsPlyIncomeInvoiceSettlement> {
 
+    /**
+     * 查询所有已结算记录的结算金额和回款差额的汇总值
+     *
+     * @author lipf
+     * @date 2026/6/30 15:39
+     */
+    SettlementVo querySettlementAndDiff(@Param("settlementIds") List<String> settlementIds);
 }

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

@@ -286,5 +286,5 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
     InsPlyIncomeInvoiceSettlementVo querySettledAmountByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
 
-    List<FollowCompanyFeeVO> selectPlatformCompanySettlementReport(@Param("query") SettlementReportQueryVo settlementReportQueryVo);
+    List<PlatformCompanyFeeVO> selectPlatformCompanySettlementReport(@Param("query") SettlementReportQueryVo settlementReportQueryVo);
 }

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

@@ -511,5 +511,5 @@ public interface ReceivableService extends IService<InsPlyIncome> {
 
     List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
 
-    List<FollowCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
+    List<PlatformCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
 }

+ 9 - 0
tenant/organization/src/main/java/com/jzg/organization/service/SysUserJzgInfoService.java

@@ -7,6 +7,7 @@ import com.jzg.commons.entity.po.SysUserJzgInfo;
 import com.jzg.commons.entity.vo.PartnerRecommenderVo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface SysUserJzgInfoService extends IService<SysUserJzgInfo> {
 
@@ -61,4 +62,12 @@ public interface SysUserJzgInfoService extends IService<SysUserJzgInfo> {
      * @date 2026/4/24 15:29
      */
     void logicDeleteJzgInfo(Long userId);
+
+    /**
+     * 查询sys_user_jzg_info 表的id和userId的对应关系
+     *
+     * @author lipf
+     * @date 2026/6/30 14:15
+     */
+    Map<String, String> queryJzgInfoId2UserId(List<String> jzgInfoTids);
 }

+ 8 - 0
tenant/organization/src/main/java/com/jzg/organization/service/SysUserService.java

@@ -286,4 +286,12 @@ public interface SysUserService extends IService<SysUser> {
     SysUserJzgInfo selectByUserIdInfo(String userId);
 
     SysUserJzgInfo getPartUserInfoByMobile(String mobile);
+
+    /**
+     * 根据userId查询用户信息 SysUser
+     *
+     * @author lipf
+     * @date 2026/6/30 11:27
+     */
+    SysUser querySysUserByUserId(String userId);
 }

+ 18 - 9
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -761,20 +761,29 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * - companyName: 保险公司名称  - companyId: 保险公司ID - contactPerson: 对接人   - contactPersonPhone: 对接人手机号  - partnerCompanyId: 分支保险公司ID  - totalInvoiced: 已开票总金额  - totalUnInvoiced: 未开票总金额  - totalSettlementAmount: 已结算总金额  - totalUnSettlementAmount: 未结算总金额(统一设置为0) - totalPaymentDifference: 回款差额  - totalReceivable: 累计应收
      */
     @Override
-    public List<FollowCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
+    public List<PlatformCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
         log.info("平台协议-结算记录-结算报表: settlementReportQueryVo=[{}]", JSONUtil.toJsonStr(settlementReportQueryVo));
-
-        List<FollowCompanyFeeVO> platformCompanyFeeVos = baseMapper.selectPlatformCompanySettlementReport(settlementReportQueryVo);
+        List<PlatformCompanyFeeVO> platformCompanyFeeVos = baseMapper.selectPlatformCompanySettlementReport(settlementReportQueryVo);
         // 过滤掉对接人和对接人手机号为空的数据
-        List<FollowCompanyFeeVO> list = platformCompanyFeeVos.stream().filter(plat -> StrUtil.isNotBlank(plat.getContactPerson()) && StrUtil.isNotBlank(plat.getContactPersonPhone())).toList();
+        // List<PlatformCompanyFeeVO> list = platformCompanyFeeVos.stream().filter(plat -> StrUtil.isNotBlank(plat.getContactPerson()) && StrUtil.isNotBlank(plat.getContactPersonPhone())).toList();
         // 查询所有保险公司,匹配保险公司的id和名称
         HttpResult<Map<String, EsmInsCompany>> mapHttpResult = esmInsCompanyClient.queryAllCompanyMap();
         Map<String, EsmInsCompany> data = mapHttpResult.getData();
-        for (FollowCompanyFeeVO platformCompanyFeeVo : list) {
+        for (PlatformCompanyFeeVO platformCompanyFeeVo : platformCompanyFeeVos) {
             platformCompanyFeeVo.setCompanyName(null != data.get(platformCompanyFeeVo.getCompanyId()) ? data.get(platformCompanyFeeVo.getCompanyId()).getName() : "");
-            platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
+            String settleIdsStr = platformCompanyFeeVo.getSettleIdsStr();
+            if(StrUtil.isNotEmpty(settleIdsStr)){
+                List<String> settlementIds = Arrays.asList(settleIdsStr.split(","));
+                SettlementVo vo =  insPlyIncomeInvoiceSettlementMapper.querySettlementAndDiff(settlementIds);
+                platformCompanyFeeVo.setTotalSettlementAmount(vo.getActualReceivedAmount());
+                platformCompanyFeeVo.setTotalPaymentDifference(vo.getSettlementPaymentDifference());
+            }else{
+                platformCompanyFeeVo.setTotalSettlementAmount(BigDecimal.ZERO);
+                platformCompanyFeeVo.setTotalPaymentDifference(BigDecimal.ZERO);
+            }
+            platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimalUtil.subtract(BigDecimalUtil.subtract(platformCompanyFeeVo.getTotalReceivable(),platformCompanyFeeVo.getTotalSettlementAmount()), platformCompanyFeeVo.getTotalPaymentDifference()));
         }
-        return list;
+        return platformCompanyFeeVos;
     }
 
 
@@ -2970,7 +2979,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         BigDecimal jqCommissionRatio = BigDecimal.ZERO;
         BigDecimal jqFollowRatio = BigDecimal.ZERO;
         if(batchModifyVo.getJqSuperviseCostsProportion() != null && batchModifyVo.getJqOtherCostsProportion() == null){
-            jqInletRatio = insFeeOrders .getJqInletRatio();
+            jqInletRatio = insFeeOrders.getJqInletRatio();
             jqCommissionRatio = batchModifyVo.getJqSuperviseCostsProportion();
             if (jqCommissionRatio.compareTo(jqInletRatio) > 0){
                 jqCommissionRatio = jqInletRatio;
@@ -3070,7 +3079,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      */
     private PtlAgreementCostRatioVo calRatio(InsPlyIncome insPlyIncome, BatchModifyVo batchModifyVo) {
         log.info("batchModifyVo.转换百分比之前的数据=【{}】", JSONUtil.toJsonStr(batchModifyVo));
-        batchModifyVo.divide100();
         PtlAgreementCostRatioVo vo = new PtlAgreementCostRatioVo();
         vo.setOrderNo(insPlyIncome.getOrderNo());
 
@@ -3161,6 +3169,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
         // 准备批量更新的实体列表
         List<InsPlyIncome> updateList = new ArrayList<>();
+        batchModifyVo.divide100();
 
         for (InsPlyIncome income : incomeList) {
             BigDecimal taxRate = taxRateMap.getOrDefault(income.getOrderNo(), BigDecimal.ONE);

+ 29 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserJzgInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jzg.organization.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -11,7 +12,10 @@ import com.jzg.organization.service.SysUserJzgInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author quchen
@@ -102,4 +106,29 @@ public class SysUserJzgInfoServiceImpl extends ServiceImpl<SysUserJzgInfoMapper,
     public void logicDeleteJzgInfo(Long userId) {
         sysUserJzgInfoMapper.updateUserByUserId(String.valueOf(userId));
     }
+
+    /**
+     * 查询sys_user_jzg_info 表的id和userId的对应关系
+     *
+     * @param jzgInfoTids sys_user_jzg_info 表的序号集
+     * @author lipf
+     * @date 2026/6/30 14:15
+     */
+    @Override
+    public Map<String, String> queryJzgInfoId2UserId(List<String> jzgInfoTids) {
+        if(CollUtil.isEmpty(jzgInfoTids)){
+            return Collections.emptyMap();
+        }
+
+        Map<String,String> res = new HashMap<>();
+        for (String jzgInfoTid : jzgInfoTids) {
+            SysUserJzgInfo sysUserJzgInfo = baseMapper.selectById(jzgInfoTid);
+            if(sysUserJzgInfo == null){
+                continue;
+            }
+            res.put(jzgInfoTid,sysUserJzgInfo.getUserId());
+
+        }
+        return res;
+    }
 }

+ 11 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserServiceImpl.java

@@ -1539,6 +1539,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return sysUserJzgInfoMapper.getPartUserInfoByMobile(mobile);
     }
 
+    /**
+     * 根据userId查询用户信息 SysUser
+     *
+     * @param userId sys_user 表的序号
+     * @author lipf
+     * @date 2026/6/30 11:27
+     */
+    @Override
+    public SysUser querySysUserByUserId(String userId) {
+        return baseMapper.selectById(userId);
+    }
 
     public void addPartner(SysUserVo sysUserVo){
         String referrerId = sysUserVo.getReferrerId();

+ 23 - 0
tenant/organization/src/main/resources/mapper/InsPlyIncomeInvoiceSettlementMapper.xml

@@ -0,0 +1,23 @@
+<?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.jzg.organization.mapper.InsPlyIncomeInvoiceSettlementMapper">
+    <!-- 查询所有已结算记录的结算金额和回款差额的汇总值 lipf 2026年6月30日15:43:15  -->
+    <select id="querySettlementAndDiff" resultType="com.jzg.commons.entity.finance.vo.SettlementVo">
+        select
+            sum(COALESCE(ipiis.actual_received_amount, 0.0)) as actual_received_amount ,
+            sum(COALESCE(ipiis.settlement_payment_difference,0.0) ) AS settlement_payment_difference
+        from
+            ins_ply_income_invoice_settlement ipiis
+        <where>
+            ipiis.is_delete = 0
+            <if test="settlementIds != null and settlementIds.size() > 0 ">
+                AND ipiis.id in
+                <foreach collection="settlementIds" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+    </select>
+</mapper>

+ 8 - 7
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -2087,18 +2087,18 @@
     </select>
 
 
-    <select id="selectPlatformCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
+    <select id="selectPlatformCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.PlatformCompanyFeeVO">
         SELECT
         ipi.company_id,
-        ipii.contact_person,
-        ipii.contact_person_phone,
-        COALESCE(SUM(sett.actual_received_amount), 0.00) AS totalSettlementAmount,
-        COALESCE(SUM(ipii.receivable_supervise_premium), 0.00) AS totalReceivable,
-        COALESCE(SUM(sett.settlement_payment_difference), 0.00) AS totalPaymentDifference
+        io.docking_person as contact_person ,
+        io.docking_person_phone as contact_person_phone,
+        SUM(COALESCE(ipi.jq_receivable_premium,0) + COALESCE(ipi.sy_receivable_premium,0) + COALESCE(ipi.jy_receivable_premium,0)) AS totalReceivable,
+        group_concat(distinct sett.id) as settle_idsStr
         FROM ins_ply_income ipi
         LEFT JOIN ins_ply_income_invoice_link ipil ON ipi.id = ipil.income_id AND ipil.is_delete = 0
         LEFT JOIN ins_ply_income_invoice ipii ON ipil.invoice_id = ipii.id AND ipii.is_delete = 0
         LEFT JOIN ins_ply_income_invoice_settlement sett ON ipii.id = sett.invoice_id AND sett.is_delete = 0
+        left join ins_orders io on ipi.order_no = io.id
         <where>
             ipi.is_delete = 0
             <if test="query.companyId != null and query.companyId != ''">
@@ -2127,7 +2127,8 @@
                 AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
             </if>
         </where>
-        GROUP BY ipii.contact_person_phone, ipii.contact_person, ipi.company_id
+        GROUP BY ipi.company_id, io.docking_person,io.docking_person_phone
+        order by settle_idsStr desc
     </select>