Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
ea1c656034
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
|
|
@ -12,8 +13,9 @@ import lombok.experimental.Accessors;
|
|||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 商户储值会员 实体类。
|
||||
|
|
@ -22,7 +24,6 @@ import java.time.LocalDateTime;
|
|||
* @since 2025-02-08
|
||||
*/
|
||||
@Data
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_user")
|
||||
|
|
@ -157,7 +158,7 @@ public class ShopUser implements Serializable {
|
|||
//邀请人上级累计收益/二级分润
|
||||
private BigDecimal twoIncome;
|
||||
// 是否分销员
|
||||
private Integer isDistribution;
|
||||
private String distributionShops;
|
||||
|
||||
@Column(ignore = true)
|
||||
private String memberName;
|
||||
|
|
@ -167,4 +168,44 @@ public class ShopUser implements Serializable {
|
|||
@Column(ignore = true)
|
||||
private Integer isMemberPrice;
|
||||
|
||||
|
||||
/**
|
||||
* 检查分销店铺是否包含当前店铺
|
||||
*/
|
||||
public boolean checkDistributionShops(String shopId) {
|
||||
if (distributionShops == null || StrUtil.isEmpty(shopId)) {
|
||||
return false;
|
||||
}
|
||||
// 按逗号分割并检查每个元素是否完全匹配
|
||||
String[] shopIds = distributionShops.split(",");
|
||||
for (String id : shopIds) {
|
||||
if (shopId.equals(id.trim())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addDistributionShop(Long shopId) {
|
||||
if (shopId == null) {
|
||||
return;
|
||||
}
|
||||
String targetId = shopId.toString().trim();
|
||||
if (targetId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 解析原有字符串为Set(去重+方便判断)
|
||||
Set<String> shopSet = new HashSet<>();
|
||||
if (distributionShops != null && !distributionShops.trim().isEmpty()) {
|
||||
for (String id : distributionShops.split(",")) {
|
||||
String trimmedId = id.trim();
|
||||
if (!trimmedId.isEmpty()) {
|
||||
shopSet.add(trimmedId);
|
||||
}
|
||||
}
|
||||
}
|
||||
shopSet.add(targetId);
|
||||
distributionShops = String.join(",", shopSet);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
// distributionUser.setDistributionLevelId(levelConfig.getId());
|
||||
// distributionUser.setDistributionLevelName(levelConfig.getName());
|
||||
// }
|
||||
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
|
|
@ -279,6 +279,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
queryWrapper.eq(MkDistributionUser::getId, param.getId());
|
||||
queryWrapper.eq(MkDistributionUser::getShopId, param.getShopId());
|
||||
queryWrapper.eq(MkDistributionUser::getParentId, param.getParentId());
|
||||
queryWrapper.eq(MkDistributionUser::getDistributionLevelId, param.getDistributionLevelId());
|
||||
queryWrapper.ge(MkDistributionUser::getCreateTime, param.getStartTime());
|
||||
queryWrapper.le(MkDistributionUser::getCreateTime, param.getEndTime());
|
||||
queryWrapper.orderBy(MkDistributionUser::getCreateTime).desc();
|
||||
|
|
@ -323,12 +324,11 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
AssertUtil.isNull(param.getOpeningMethod(), "开通方式不能为空");
|
||||
AssertUtil.isNull(param.getUserId(), "用户ID不能为空");
|
||||
AssertUtil.isNull(param.getId(), "店铺用户ID不能为空");
|
||||
long count = count(QueryWrapper.create()
|
||||
.eq(MkDistributionUser::getId, param.getId())
|
||||
.eq(MkDistributionUser::getShopId, param.getShopId())
|
||||
.eq(MkDistributionUser::getUserId, param.getUserId()));
|
||||
if (count > 0) {
|
||||
throw new CzgException("该用户已被添加为分销员");
|
||||
ShopUser shopUser = shopUserService.getById(param.getId());
|
||||
AssertUtil.isNull(shopUser, "店铺用户ID不能为空");
|
||||
boolean isExits = shopUser.checkDistributionShops(param.getShopId().toString());
|
||||
if(isExits){
|
||||
throw new CzgException("该用户已被添加为分销员,不可重复添加");
|
||||
}
|
||||
MkDistributionConfig config = mkDistributionConfigService.getOne(
|
||||
QueryWrapper.create().eq(MkDistributionConfig::getShopId, param.getShopId())
|
||||
|
|
@ -347,6 +347,10 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
param.setId(param.getId());
|
||||
param.setInviteCode(CzgRandomUtils.randomString(10));
|
||||
save(param);
|
||||
ShopUser shopUser2 = new ShopUser();
|
||||
shopUser2.setId(shopUser.getId());
|
||||
shopUser2.addDistributionShop(param.getShopId());
|
||||
shopUserService.updateById(shopUser2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue