Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
9a99cc6e1d
|
|
@ -62,6 +62,11 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
*/
|
||||
Page<InviteUserVO> getInviteUser(Long id, Integer page, Integer size);
|
||||
|
||||
/**
|
||||
* 分销员:按消费金额升级等级
|
||||
*/
|
||||
void costUpgradeLevelBefore(Long userId, Long shopId);
|
||||
|
||||
/**
|
||||
* 添加分销员
|
||||
* shop_id 和 shop_user_id 必填 opening_method 必填
|
||||
|
|
|
|||
|
|
@ -263,31 +263,50 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
this.updateById(newDistributionUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void costUpgradeLevelBefore(Long userId, Long shopId) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
||||
costUpgradeLevel(shopUser.getId(), shopId);
|
||||
if (shopUser.getDistributionUserId() != null) {
|
||||
costUpgradeLevel(shopUser.getDistributionUserParentId(), shopId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按消费金额升级等级
|
||||
*
|
||||
* @param distributionUserId 分销员Id
|
||||
* 分销员:按消费金额升级等级
|
||||
*/
|
||||
public void costUpgradeLevel(Long distributionUserId) {
|
||||
MkDistributionUser distributionUser = getById(distributionUserId);
|
||||
public void costUpgradeLevel(Long shopUserId, Long shopId) {
|
||||
MkDistributionUser distributionUser = getById(shopUserId);
|
||||
if (distributionUser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MkDistributionConfig mkDistributionConfig = mkDistributionConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionConfig::getShopId, distributionUser.getShopId()));
|
||||
AssertUtil.isNull(mkDistributionConfig, "升级失败,店铺未配置分销");
|
||||
AssertUtil.isNotEqual(mkDistributionConfig.getUpgradeType(), "cost", "升级失败");
|
||||
|
||||
if (mkDistributionConfig == null || !"cost".equals(mkDistributionConfig.getUpgradeType())) {
|
||||
return;
|
||||
}
|
||||
List<Long> userIds = shopUserService.listAs(QueryWrapper.create()
|
||||
.select(ShopUser::getUserId)
|
||||
.eq(ShopUser::getDistributionUserId, shopUserId), Long.class);
|
||||
BigDecimal totalAmount = orderInfoService.getOneAs(QueryWrapper.create()
|
||||
.select("sum(pay_amount)")
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
.in(OrderInfo::getUserId, userIds), BigDecimal.class);
|
||||
MkDistributionLevelConfig levelConfig = levelConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionLevelConfig::getShopId, distributionUser.getShopId())
|
||||
.le(MkDistributionLevelConfig::getInviteCount, distributionUser.getInviteCount())
|
||||
.gt(MkDistributionLevelConfig::getId, distributionUser.getDistributionLevelId())
|
||||
.orderBy(MkDistributionLevelConfig::getLevel).desc().limit(1));
|
||||
if (levelConfig != null) {
|
||||
distributionUser.setDistributionLevelId(levelConfig.getId());
|
||||
distributionUser.setDistributionLevelName(levelConfig.getName());
|
||||
if (totalAmount.compareTo(levelConfig.getCostAmount()) >= 0) {
|
||||
MkDistributionUser newDistributionUser = new MkDistributionUser();
|
||||
newDistributionUser.setId(shopUserId);
|
||||
newDistributionUser.setDistributionLevelId(levelConfig.getId());
|
||||
newDistributionUser.setDistributionLevelName(levelConfig.getName());
|
||||
updateById(newDistributionUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -332,8 +351,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
public Page<InviteUserVO> getInviteUser(Long id, Integer page, Integer size) {
|
||||
return pageAs(new Page<>(page, size), QueryWrapper.create()
|
||||
.select("head_img as headImg,nick_name as shopUserName,phone as shopUserPhone,one_income as oneIncome")
|
||||
.eq(MkDistributionUser::getShopId, id)
|
||||
.eq(MkDistributionUser::getParentId, id)
|
||||
.eq(ShopUser::getDistributionUserId, id)
|
||||
.orderBy(MkDistributionUser::getCreateTime).desc(), InviteUserVO.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1059,11 +1059,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
||||
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
||||
|
||||
// 会员加入
|
||||
memberConfigService.joinMemberByCondition(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
// 会员消费赠送成长值
|
||||
memberConfigService.deliver(orderInfo.getShopId(), orderInfo.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getPayAmount(), null, orderInfo.getId());
|
||||
// 分销员升级等级
|
||||
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
|
||||
// 分销奖励
|
||||
distributionUserService.distribute(orderInfo.getId(), payment.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
|
||||
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue