分销修改
This commit is contained in:
@@ -79,9 +79,9 @@ public class DistributionTask {
|
|||||||
} else {
|
} else {
|
||||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||||
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId());
|
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId());
|
||||||
distributionUserService.updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO,
|
|
||||||
item.getDistributionUserId(), shopUser.getUserId(), item.getShopId(), item.getLevel());
|
|
||||||
distributionUserService.updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减");
|
distributionUserService.updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减");
|
||||||
|
distributionUserService.updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO,
|
||||||
|
item.getDistributionUserId(), shopUser.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||||
}
|
}
|
||||||
distributionFlowService.updateById(item);
|
distributionFlowService.updateById(item);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,5 +36,5 @@ public interface ShopUserService extends IService<ShopUser> {
|
|||||||
|
|
||||||
List<ShopUser> selectBirthdayUser(LocalDate current, Long mainShopId, String userType);
|
List<ShopUser> selectBirthdayUser(LocalDate current, Long mainShopId, String userType);
|
||||||
|
|
||||||
void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal bigDecimal, Integer isOne);
|
void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||||||
*/
|
*/
|
||||||
void distribute(Long sourceId, String orderNo, BigDecimal amount, Long userId, Long shopId, String type);
|
void distribute(Long sourceId, String orderNo, BigDecimal amount, Long userId, Long shopId, String type);
|
||||||
|
|
||||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopId, Integer isOne);
|
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne);
|
||||||
|
|
||||||
|
|
||||||
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
|
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
|
||||||
|
|||||||
@@ -72,6 +72,6 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
|||||||
*/
|
*/
|
||||||
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId);
|
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId);
|
||||||
|
|
||||||
void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal amount, Integer isOne);
|
void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal amount, Integer isOne);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal bigDecimal, Integer isOne) {
|
public void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne) {
|
||||||
mapper.updateOneOrTwoAmount(userId, mainShopId, bigDecimal, isOne);
|
mapper.updateOneOrTwoAmount(shopUserId, shopId, bigDecimal, isOne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
and amount - #{money} >= 0
|
and amount - #{money} >= 0
|
||||||
</update>
|
</update>
|
||||||
<update id="updateOneOrTwoAmount">
|
<update id="updateOneOrTwoAmount">
|
||||||
update tb_shop_user
|
update tb_shop_user_invite
|
||||||
<set>
|
<set>
|
||||||
<if test="isOne != null and isOne == 1">
|
<if test="isOne != null and isOne == 1">
|
||||||
one_income = one_income + #{amount}
|
one_income = one_income + #{amount}
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
two_income = two_income + #{amount}
|
two_income = two_income + #{amount}
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where shop_user_id = #{shopUserId}
|
||||||
and main_shop_id = #{mainShopId}
|
and shop_id = #{shopId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -578,7 +578,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
AssertUtil.isNull(currentDistributionUser, "分销员不存在");
|
AssertUtil.isNull(currentDistributionUser, "分销员不存在");
|
||||||
AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启");
|
AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启");
|
||||||
|
|
||||||
ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId());
|
// ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId());
|
||||||
|
ShopUserInvite currentShopUser = shopUserInviteService.getOneByShopIdAndShopUserId(config.getShopId(), currentDistributionUser.getId());
|
||||||
MkDistributionLevelConfig level = levelConfigService.getById(currentDistributionUser.getDistributionLevelId());
|
MkDistributionLevelConfig level = levelConfigService.getById(currentDistributionUser.getDistributionLevelId());
|
||||||
|
|
||||||
// 校验剩余分成比例
|
// 校验剩余分成比例
|
||||||
@@ -639,10 +640,10 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
log.info("即时分销开始");
|
log.info("即时分销开始");
|
||||||
try {
|
try {
|
||||||
updateShopInfoAmount(currentDistributionUser.getShopId(), rewardAmount.negate(), sourceId, TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣除");
|
updateShopInfoAmount(currentDistributionUser.getShopId(), rewardAmount.negate(), sourceId, TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣除");
|
||||||
updateIncome(BigDecimal.ZERO, rewardAmount, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
updateIncome(BigDecimal.ZERO, rewardAmount, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
||||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||||
distributionFlowService.updateById(mkDistributionFlow);
|
distributionFlowService.updateById(mkDistributionFlow);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -650,7 +651,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
||||||
distributionFlowService.save(mkDistributionFlow);
|
distributionFlowService.save(mkDistributionFlow);
|
||||||
log.info("延时分销开始");
|
log.info("延时分销开始");
|
||||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,11 +682,11 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
refundFlow.setUpdateTime(DateUtil.date().toLocalDateTime());
|
refundFlow.setUpdateTime(DateUtil.date().toLocalDateTime());
|
||||||
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
|
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
|
||||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||||
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||||
distributionFlowService.updateById(item);
|
distributionFlowService.updateById(item);
|
||||||
} else {
|
} else {
|
||||||
// 执行扣款
|
// 执行扣款
|
||||||
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(),item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||||
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
|
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
|
||||||
}
|
}
|
||||||
distributionFlowService.save(refundFlow);
|
distributionFlowService.save(refundFlow);
|
||||||
@@ -701,12 +702,13 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
|
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
|
||||||
// 当前用户上级分销员
|
// 当前用户上级分销员
|
||||||
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId);
|
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId);
|
||||||
if (sourceShopUserInfo.getDistributionUserId() == null) {
|
ShopUserInvite sourceInviteUser = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, sourceShopUserInfo.getId());
|
||||||
|
if (sourceInviteUser.getDistributionUserId() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceShopUserInfo.getDistributionUserId());
|
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceInviteUser.getDistributionUserId());
|
||||||
|
|
||||||
MkDistributionUser distributionUser = getById(sourceShopUserInfo.getDistributionUserId());
|
MkDistributionUser distributionUser = getById(sourceInviteUser.getDistributionUserId());
|
||||||
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
|
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
|
||||||
});
|
});
|
||||||
distributionDeliverService.save(deliver);
|
distributionDeliverService.save(deliver);
|
||||||
@@ -714,9 +716,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long mainShopId, Integer isOne) {
|
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne) {
|
||||||
// 用户收益信息
|
// 用户收益信息
|
||||||
shopUserService.updateOneOrTwoAmount(userId, mainShopId, receivedIncome, isOne);
|
shopUserService.updateOneOrTwoAmount(shopUserId, shopId, receivedIncome, isOne);
|
||||||
// 用户可提现余额
|
// 用户可提现余额
|
||||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||||
//分销员余额
|
//分销员余额
|
||||||
|
|||||||
Reference in New Issue
Block a user