|
|
@@ -414,7 +414,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
AssertionUtils.isFail(true, "订单已被"+audit.getReceiveUser()+"领取返回待审核订单列表!");
|
|
|
}
|
|
|
InsFeeOrders feeOrders = null;
|
|
|
- SysUserAccount userAccount = null,distributor1 = null,distributor2 = null,distributor3 = null;
|
|
|
+ SysUserAccount userAccount = null;
|
|
|
if(param.getAuditStatus().equals(1)){
|
|
|
List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
|
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.SUCCESS_AUDIT,audit.getAuditStatus()+"");
|
|
|
@@ -447,7 +447,6 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
userAccount.setSumAmountUnpaid(feeOrders.getTotalReceivablePremium().add(userAccount.getSumAmount()));
|
|
|
}
|
|
|
orgClient.saveOrUpdate(userAccount);
|
|
|
-
|
|
|
// 进入应收表
|
|
|
List<String> orderNos = new ArrayList<>();
|
|
|
orderNos.add(audit.getOrderNo());
|
|
|
@@ -455,42 +454,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
requestData.put("orderNo",orderNos);
|
|
|
HttpResult httpResult = orgClient.addReceivable(requestData);
|
|
|
AssertionUtils.isFail(httpResult.getCode() == 500,"应收出错");
|
|
|
-
|
|
|
- // 一级分销费用户进账
|
|
|
- if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getFirstDistributorId());
|
|
|
- AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
- SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
- HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
- AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- distributor1 = jzgAccountResult.getData();
|
|
|
- verifySysAccount(distributor1,jzgInfo,feeOrders);
|
|
|
- }
|
|
|
- // 二级分销费用户进账
|
|
|
- if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getSecondDistributorId());
|
|
|
- AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
- SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
- HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
- AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- distributor2 = jzgAccountResult.getData();
|
|
|
- verifySysAccount(distributor2,jzgInfo,feeOrders);
|
|
|
- }
|
|
|
- // 三级分销费用户进账
|
|
|
- if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getThirdDistributorId());
|
|
|
- AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
- SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
- HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
- AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
- distributor3 = jzgAccountResult.getData();
|
|
|
- verifySysAccount(distributor3,jzgInfo,feeOrders);
|
|
|
- }
|
|
|
- // 增加账户的金额记录
|
|
|
- // modify by lipf, 2026年5月20日11:31:59 审核通过后,才需要 生成收入明细日志
|
|
|
- List<SysUserAccountIncomeLog>builderIncomeLog = this.builderIncomeLog(param.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
|
|
|
- HttpResult result2 = orgClient.addUserAccountIncomeLog(builderIncomeLog);
|
|
|
- AssertionUtils.isFail(result2.getCode() != 200,"账户记录添加失败,审核失败");
|
|
|
+ this.dealDistribution(feeOrders,userAccount);
|
|
|
}else{
|
|
|
log.info("订单审核驳回:param=[{}]", JSONUtil.toJsonStr(param));
|
|
|
StateResult stateFailResult = auditStateListener.statusChange(AuditState.AuditStateEnum.FAIL_AUDIT,audit.getAuditStatus()+"");
|
|
|
@@ -512,6 +476,56 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分销逻辑处理 (抽取原来的方法)
|
|
|
+ * 根据分销逻辑更新业务员账户的金额信息
|
|
|
+ *
|
|
|
+ * @param feeOrders 订单费用
|
|
|
+ * @param userAccount 业务员账户信息
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/6/6 10:49
|
|
|
+ */
|
|
|
+ private void dealDistribution(InsFeeOrders feeOrders, SysUserAccount userAccount){
|
|
|
+ log.info("处理分销逻辑。 feeOrders=[{}],userAccount=[{}]", JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount));
|
|
|
+ SysUserAccount distributor1 = null,distributor2 = null,distributor3 = null;
|
|
|
+ // 一级分销费用户进账
|
|
|
+ if (feeOrders.getFirstDistributorId() != null && feeOrders.getFirstDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getFirstDistributorId());
|
|
|
+ AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
+ SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
+ HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
+ AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
+ distributor1 = jzgAccountResult.getData();
|
|
|
+ updateSysAccount(distributor1,jzgInfo,feeOrders);
|
|
|
+ }
|
|
|
+ // 二级分销费用户进账
|
|
|
+ if (feeOrders.getSecondDistributorId() != null && feeOrders.getSecondDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getSecondDistributorId());
|
|
|
+ AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
+ SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
+ HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
+ AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
+ distributor2 = jzgAccountResult.getData();
|
|
|
+ updateSysAccount(distributor2,jzgInfo,feeOrders);
|
|
|
+ }
|
|
|
+ // 三级分销费用户进账
|
|
|
+ if (feeOrders.getThirdDistributorId() != null && feeOrders.getThirdDistributionFee().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ HttpResult<SysUserJzgInfo> jzgInfoResult = orgClient.getUserInfoById(feeOrders.getThirdDistributorId());
|
|
|
+ AssertionUtils.isFail(jzgInfoResult.getCode() != 200,"获取用户失败!");
|
|
|
+ SysUserJzgInfo jzgInfo = jzgInfoResult.getData();
|
|
|
+ HttpResult<SysUserAccount> jzgAccountResult = orgClient.accountGet(jzgInfo.getUserId());
|
|
|
+ AssertionUtils.isFail(jzgAccountResult.getCode() != 200,"获取用户账户失败!");
|
|
|
+ distributor3 = jzgAccountResult.getData();
|
|
|
+ updateSysAccount(distributor3,jzgInfo,feeOrders);
|
|
|
+ }
|
|
|
+ // 增加账户的金额记录
|
|
|
+ // modify by lipf, 2026年5月20日11:31:59 审核通过后,才需要 生成收入明细日志
|
|
|
+ List<SysUserAccountIncomeLog>builderIncomeLog = this.builderIncomeLog(feeOrders.getOrderNo(),feeOrders,userAccount,distributor1,distributor2,distributor3);
|
|
|
+ HttpResult result2 = orgClient.addUserAccountIncomeLog(builderIncomeLog);
|
|
|
+ AssertionUtils.isFail(result2.getCode() != 200,"账户记录添加失败,审核失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 处理订单关联的权益信息(将权益处理的逻辑抽取到一个单独的方法里面)
|
|
|
*
|
|
|
@@ -629,10 +643,15 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
* @param distributor3 3级分销人员
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<SysUserAccountIncomeLog> builderIncomeLog(String orderNo,InsFeeOrders feeOrders,SysUserAccount userAccount,SysUserAccount distributor1,
|
|
|
- SysUserAccount distributor2, SysUserAccount distributor3){
|
|
|
+ private List<SysUserAccountIncomeLog> builderIncomeLog(String orderNo,
|
|
|
+ InsFeeOrders feeOrders,
|
|
|
+ SysUserAccount userAccount,
|
|
|
+ SysUserAccount distributor1,
|
|
|
+ SysUserAccount distributor2,
|
|
|
+ SysUserAccount distributor3){
|
|
|
+ log.info("生成收入明细日志:feeOrders=[{}],userAccount=[{}],distributor1=[{}],distributor2=[{}],distributor3=[{}]",
|
|
|
+ JSONUtil.toJsonStr(feeOrders), JSONUtil.toJsonStr(userAccount), JSONUtil.toJsonStr(distributor1), JSONUtil.toJsonStr(distributor2), JSONUtil.toJsonStr(distributor3));
|
|
|
List<SysUserAccountIncomeLog> incomeLogs = new ArrayList<>();
|
|
|
-
|
|
|
// 出口费用
|
|
|
SysUserAccountIncomeLog exportIncomeLog = new SysUserAccountIncomeLog();
|
|
|
exportIncomeLog.setOrderId(orderNo);
|
|
|
@@ -678,11 +697,16 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
|
|
|
return incomeLogs;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // 验证用户账户
|
|
|
- public void verifySysAccount(SysUserAccount userAccount, SysUserJzgInfo jzgInfo, InsFeeOrders feeOrders) {
|
|
|
+ /**
|
|
|
+ * 更新分销账户的金额
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/6/6 11:20
|
|
|
+ */
|
|
|
+ void updateSysAccount(SysUserAccount userAccount, SysUserJzgInfo jzgInfo, InsFeeOrders feeOrders) {
|
|
|
if (Objects.isNull(userAccount)) {
|
|
|
+ userAccount = new SysUserAccount();
|
|
|
+ userAccount.setSystemCode(jzgInfo.getSystemCode());
|
|
|
userAccount.setUserId(jzgInfo.getUserId());
|
|
|
userAccount.setSumAmount(feeOrders.getFirstDistributionFee());
|
|
|
userAccount.setSumAmountUnpaid(feeOrders.getFirstDistributionFee());
|