|
|
@@ -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();
|