Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -494,6 +494,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
|
||||
private void deepReward(MkDistributionConfigVO config, ShopUser sourceShopUser, BigDecimal amount, Long sourceId, String type, String orderNo, Integer currentLevel) {
|
||||
if (currentLevel > 2) {
|
||||
return;
|
||||
}
|
||||
MkDistributionUser distributionUser = getOne(new QueryWrapper().eq(MkDistributionUser::getId, sourceShopUser.getId()));
|
||||
AssertUtil.isNull(distributionUser, "分销员不存在");
|
||||
AssertUtil.isTrue(distributionUser.getStatus() != 1, "分销员未开启");
|
||||
@@ -526,16 +529,17 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
// 店铺信息
|
||||
BigDecimal rewardAmount;
|
||||
if (currentLevel == 1) {
|
||||
rewardAmount = amount.multiply(level.getLevelOneCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
} else {
|
||||
rewardAmount = amount.multiply(level.getLevelTwoCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
}
|
||||
// if (currentLevel == 1) {
|
||||
// rewardAmount = amount.multiply(level.getLevelOneCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
// } else {
|
||||
// rewardAmount = amount.multiply(level.getLevelTwoCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
// }
|
||||
rewardAmount = amount.multiply(level.getLevelTwoCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
|
||||
boolean flag = true;
|
||||
BigDecimal finalAmount = BigDecimal.ZERO;
|
||||
try {
|
||||
shopInfoService.updateAmount(distributionUser.getShopId(), rewardAmount.negate());
|
||||
finalAmount = shopInfoService.updateAmount(distributionUser.getShopId(), rewardAmount.negate());
|
||||
} catch (Exception e) {
|
||||
flag = false;
|
||||
}
|
||||
@@ -554,9 +558,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
if (flag) {
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
.setType(TableValueConstant.DistributionAmountFlow.Type.SELF_RECHARGE.getCode())
|
||||
.setShopId(config.getShopId()).setAmount(finalAmount).setChangeAmount(amount).setSourceId(mkDistributionFlow.getId())
|
||||
.setRemark("自助充值").setOpAccount(StpKit.USER.getAccount()));
|
||||
.setType(TableValueConstant.DistributionAmountFlow.Type.SUB.getCode())
|
||||
.setShopId(config.getShopId()).setAmount(finalAmount).setChangeAmount(rewardAmount).setSourceId(mkDistributionFlow.getId())
|
||||
.setRemark("分账扣除"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -574,14 +578,18 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
return;
|
||||
}
|
||||
|
||||
deepReward(config, sourceShopUserInfo, amount, sourceId, type, orderNo, 1);
|
||||
}, "分销方法执行失败");
|
||||
ShopUser parentUserInfo = shopUserService.getById(sourceShopUserInfo.getDistributionUserId());
|
||||
deepReward(config, parentUserInfo, amount, sourceId, type, orderNo, 1);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId) {
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
|
||||
if (!flag) {
|
||||
throw new CzgException("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
<mapper namespace="com.czg.service.market.mapper.MkDistributionUserMapper">
|
||||
<update id="updateIncome">
|
||||
update mk_distribution_user
|
||||
set total_income = total_income + #{pendingIncome},
|
||||
set
|
||||
<if test="pendingIncome != null">
|
||||
total_income = total_income + #{pendingIncome},
|
||||
</if>
|
||||
<if test="receivedIncome != null">
|
||||
total_income = total_income + #{receivedIncome},
|
||||
</if>
|
||||
pending_income = pending_income + #{pendingIncome},
|
||||
received_income = received_income + #{receivedIncome},
|
||||
withdrawn_income = withdrawn_income + #{withdrawIncome}
|
||||
|
||||
Reference in New Issue
Block a user