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