分销日志
This commit is contained in:
parent
759a393b7d
commit
2c17e5dcdf
|
|
@ -25,6 +25,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
|
||||
Boolean getCode(Long userId, String type);
|
||||
|
||||
void updateDistributionAmount(long userId, BigDecimal amount);
|
||||
void updateDistributionAmount(long userId, BigDecimal amount, Integer isOne);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
*/
|
||||
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);
|
||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Integer isOne);
|
||||
|
||||
|
||||
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
int updateAmount(long userId, BigDecimal amount);
|
||||
int updateAmount(long userId, BigDecimal amount, Integer isOne);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateDistributionAmount(long userId, BigDecimal amount) {
|
||||
int b = mapper.updateAmount(userId, amount);
|
||||
public void updateDistributionAmount(long userId, BigDecimal amount, Integer isOne) {
|
||||
int b = mapper.updateAmount(userId, amount, isOne);
|
||||
if (b <= 0) {
|
||||
throw new CzgException("更新分销金额失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@
|
|||
|
||||
<update id="updateAmount">
|
||||
update tb_user_info set distribution_amount = distribution_amount + #{amount} where id = #{userId}
|
||||
<if test="isOne != null and isOne == 1">
|
||||
,one_income = one_income + #{amount}
|
||||
</if>
|
||||
<if test="isOne != null and isOne == 2">
|
||||
,two_income = two_income + #{amount}
|
||||
</if>
|
||||
and distribution_amount + #{amount} >= 0
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -579,6 +579,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
|
||||
MkDistributionLevelConfig level = levelConfigService.getById(distributionUser.getDistributionLevelId());
|
||||
AssertUtil.isNull(level, "分销等级不存在");
|
||||
log.info("当前分销员: {}, 上级分销员: {}, 分销等级: {}", distributionUser.getId(), sourceShopUser.getDistributionUserParentId(), level.getId());
|
||||
|
||||
if (config.getRewardCount() != null && config.getRewardCount() > 0) {
|
||||
long count = distributionFlowService.count(new QueryWrapper().eq(MkDistributionFlow::getSourceShopUserId, sourceShopUser.getId())
|
||||
|
|
@ -617,7 +618,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
distributionFlowService.save(mkDistributionFlow);
|
||||
|
||||
updateIncome(!flag ? rewardAmount : BigDecimal.ZERO,
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId());
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId(), currentLevel == 1 ? 1 : 2);
|
||||
|
||||
if (flag) {
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
|
|
@ -640,6 +641,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
if (sourceShopUserInfo.getDistributionUserId() == null) {
|
||||
return;
|
||||
}
|
||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceShopUserInfo.getDistributionUserId());
|
||||
|
||||
ShopUser parentUserInfo = shopUserService.getById(sourceShopUserInfo.getDistributionUserId());
|
||||
deepReward(config, parentUserInfo, amount, sourceId, type, orderNo, 1);
|
||||
|
|
@ -647,8 +649,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId) {
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Integer isOne) {
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome, isOne);
|
||||
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
|
||||
if (!flag) {
|
||||
throw new CzgException("操作失败");
|
||||
|
|
@ -674,7 +676,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
|
||||
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
|
||||
// 扣减余额
|
||||
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate());
|
||||
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate(), null);
|
||||
return withdrawFlowService.save(withdrawFlow);
|
||||
}
|
||||
|
||||
|
|
@ -705,7 +707,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
case "CANCELLED":
|
||||
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FAIL.getCode());
|
||||
// 扣减余额
|
||||
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()));
|
||||
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()), null);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue