邀请人列表
This commit is contained in:
@@ -5,6 +5,7 @@ import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.market.dto.MkDistributionUserDTO;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.vo.InviteUserVO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.AssertUtil;
|
||||
@@ -36,6 +37,18 @@ public class DistributionUserController {
|
||||
return CzgResult.success(distributionUserService.getDistributionUser(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员:获取邀请人分页列表
|
||||
*/
|
||||
@GetMapping("/inviteUser")
|
||||
public CzgResult<Page<InviteUserVO>> getInviteUser(
|
||||
@RequestParam Long id,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
AssertUtil.isNull(id, "邀请人ID");
|
||||
return CzgResult.success(distributionUserService.getInviteUser(id, page, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员:添加分销员
|
||||
*
|
||||
|
||||
@@ -3,12 +3,15 @@ package com.czg.controller.user;
|
||||
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.market.dto.MkDistributionUserDTO;
|
||||
import com.czg.market.entity.MkDistributionConfig;
|
||||
import com.czg.market.entity.MkDistributionWithdrawFlow;
|
||||
import com.czg.market.service.MkDistributionConfigService;
|
||||
import com.czg.market.service.MkDistributionFlowService;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.service.MkDistributionWithdrawFlowService;
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.czg.market.vo.InviteUserVO;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
@@ -31,6 +34,8 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/user/distribution")
|
||||
public class UDistributionController {
|
||||
@Resource
|
||||
private MkDistributionConfigService distributionConfigService;
|
||||
@Resource
|
||||
private MkDistributionUserService distributionUserService;
|
||||
@Resource
|
||||
@@ -41,11 +46,11 @@ public class UDistributionController {
|
||||
private MkDistributionFlowService distributionFlowService;
|
||||
|
||||
/**
|
||||
* 分销员购买
|
||||
* 分销员中心-获取配置
|
||||
*/
|
||||
@PostMapping("/pay")
|
||||
public CzgResult<Map<String, Object>> pay(@Validated @RequestBody MkDistributionPayDTO payDTO) {
|
||||
return CzgResult.success(distributionUserService.pay(StpKit.USER.getLoginIdAsLong(), payDTO));
|
||||
@GetMapping("/getConfig")
|
||||
public CzgResult<MkDistributionConfigVO> getConfig(@RequestParam Long shopId) {
|
||||
return CzgResult.success(distributionConfigService.detail(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,15 +86,23 @@ public class UDistributionController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户提现
|
||||
* @param withdrawFlowDTO 提现信息
|
||||
* @return 是否成功
|
||||
* 分销员中心-获取邀请码
|
||||
*/
|
||||
@PostMapping("/withdraw")
|
||||
public CzgResult<Boolean> withdraw(@Validated @RequestBody MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
|
||||
return CzgResult.success(distributionUserService.withdraw(StpKit.USER.getLoginIdAsLong(), withdrawFlowDTO));
|
||||
@GetMapping("/getInviteCode")
|
||||
public CzgResult<String> getInviteCode(@RequestParam Long shopId,@RequestParam Long shopUserId) {
|
||||
return CzgResult.success(distributionUserService.getInviteCode(shopId,shopUserId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销员购买
|
||||
*/
|
||||
@PostMapping("/pay")
|
||||
public CzgResult<Map<String, Object>> pay(@Validated @RequestBody MkDistributionPayDTO payDTO) {
|
||||
return CzgResult.success(distributionUserService.pay(StpKit.USER.getLoginIdAsLong(), payDTO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销员中心-实名认证
|
||||
*/
|
||||
@@ -102,7 +115,7 @@ public class UDistributionController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 分销员中心-绑定邀请人
|
||||
*/
|
||||
@PostMapping("/bindInviteUser")
|
||||
@@ -114,16 +127,6 @@ public class UDistributionController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员:获取下级分销员分页列表
|
||||
*/
|
||||
@GetMapping("/childUser")
|
||||
public CzgResult<Page<MkDistributionUserDTO>> getDistributionUser(MkDistributionUserDTO param) {
|
||||
AssertUtil.isNull(param.getShopId(), "店铺ID不能为空");
|
||||
AssertUtil.isNull(param.getParentId(), "父级ID不能为空");
|
||||
return CzgResult.success(distributionUserService.getDistributionUser(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员:获取邀请人分页列表
|
||||
*/
|
||||
@@ -136,6 +139,16 @@ public class UDistributionController {
|
||||
return CzgResult.success(distributionUserService.getInviteUser(id, page, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户提现
|
||||
* @param withdrawFlowDTO 提现信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping("/withdraw")
|
||||
public CzgResult<Boolean> withdraw(@Validated @RequestBody MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
|
||||
return CzgResult.success(distributionUserService.withdraw(StpKit.USER.getLoginIdAsLong(), withdrawFlowDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.account.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
@@ -167,6 +168,8 @@ public class ShopUser implements Serializable {
|
||||
private Integer discount;
|
||||
@Column(ignore = true)
|
||||
private Integer isMemberPrice;
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime inviteTime;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,11 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
*/
|
||||
Map<String, Object> centerConfig(Long userId, Long shopId);
|
||||
|
||||
/**
|
||||
* 分销员中心-获取邀请码
|
||||
*/
|
||||
String getInviteCode(Long shopId, Long shopUserId);
|
||||
|
||||
/**
|
||||
* 分销员中心-实名认证
|
||||
*/
|
||||
@@ -72,7 +77,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
* shop_id 和 shop_user_id 必填 opening_method 必填
|
||||
* 如果distribution_level_id指定 则 distribution_level_name 也填
|
||||
*/
|
||||
void addDistributionUser(MkDistributionUser param);
|
||||
MkDistributionUser addDistributionUser(MkDistributionUser param);
|
||||
|
||||
/**
|
||||
* 更新分销员
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
@@ -29,4 +30,20 @@ public class InviteUserVO implements Serializable {
|
||||
* 一级收益
|
||||
*/
|
||||
private BigDecimal oneIncome;
|
||||
/**
|
||||
* 邀请时间
|
||||
*/
|
||||
private LocalDateTime inviteTime;
|
||||
/**
|
||||
* 等级id
|
||||
*/
|
||||
private Integer levelId;
|
||||
/**
|
||||
* 等级名称
|
||||
*/
|
||||
private String levelName;
|
||||
/**
|
||||
* 是否分销员
|
||||
*/
|
||||
private Integer isDistribution;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.czg.market.vo.InviteUserVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -62,4 +63,12 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
||||
@Param("param") SmsPushEventUser smsPushEventUser
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 查询邀请用户
|
||||
*
|
||||
* @param distributionUserId 分销员ID
|
||||
* @return 分页结果
|
||||
*/
|
||||
List<InviteUserVO> getInviteUser(Long distributionUserId);
|
||||
}
|
||||
|
||||
@@ -100,12 +100,10 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Integer page, Integer size) {
|
||||
Page<InviteUserVO> pages = pageAs(new Page<>(page, size),QueryWrapper.create()
|
||||
.select("head_img as headImg,nick_name as shopUserName,phone as shopUserPhone,one_income as oneIncome")
|
||||
.eq(ShopUser::getDistributionUserId, getDistributionUserId)
|
||||
.orderBy(ShopUser::getCreateTime).desc(), InviteUserVO.class);
|
||||
return pages;
|
||||
public Page<InviteUserVO> getInviteUser(Long distributionUserId, Integer page, Integer size) {
|
||||
PageHelper.startPage(page, size);
|
||||
List<InviteUserVO> inviteUser = mapper.getInviteUser(distributionUserId);
|
||||
return PageUtil.convert(new PageInfo<>(inviteUser));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -262,4 +262,18 @@
|
||||
</if>
|
||||
order by u.create_time desc
|
||||
</select>
|
||||
<select id="getInviteUser" resultType="com.czg.market.vo.InviteUserVO">
|
||||
SELECT user.head_img AS headImg,
|
||||
user.nick_name AS shopUserName,
|
||||
user.phone AS shopUserPhone,
|
||||
user.one_income AS oneIncome,
|
||||
user.invite_time AS inviteTime,
|
||||
dist.distribution_level_id AS levelId,
|
||||
dist.distribution_level_name AS levelName,
|
||||
CASE WHEN dist.id IS NOT NULL THEN 1 ELSE 0 END AS isDistribution
|
||||
FROM `tb_shop_user` user
|
||||
left join mk_distribution_user dist on user.id = dist.id
|
||||
WHERE user.`distribution_user_id` = #{distributionUserId}
|
||||
ORDER BY `create_time` DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
@@ -205,6 +206,30 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String getInviteCode(Long shopId, Long shopUserId) {
|
||||
ShopUser shopUser = shopUserService.getById(shopUserId);
|
||||
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
||||
MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId);
|
||||
if (mkDistributionConfigVO == null || mkDistributionConfigVO.getIsEnable() == 0) {
|
||||
throw new CzgException("店铺分销功能未开启");
|
||||
}
|
||||
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
|
||||
throw new CzgException("该店铺不可自行成为分销员");
|
||||
}
|
||||
MkDistributionUser mkDistributionUser = this.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionUser::getId, shopUser.getId()).eq(MkDistributionUser::getShopId, shopId));
|
||||
if(mkDistributionUser == null){
|
||||
mkDistributionUser= new MkDistributionUser();
|
||||
mkDistributionUser.setId(shopUser.getId());
|
||||
mkDistributionUser.setShopId(shopId);
|
||||
mkDistributionUser.setOpeningMethod("自主申请");
|
||||
mkDistributionUser = addDistributionUser(mkDistributionUser);
|
||||
}
|
||||
return mkDistributionUser.getInviteCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void realNameAuth(UserInfo userInfo) {
|
||||
AssertUtil.isTrue(IdcardUtil.isValidCard(userInfo.getIdCard()), "身份证号格式错误");
|
||||
@@ -225,6 +250,12 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode()));
|
||||
AssertUtil.isNull(parent, "邀请人不存在");
|
||||
if (!parent.getShopId().equals(param.getShopId())) {
|
||||
throw new CzgException("邀请人不是本店铺的分销员");
|
||||
}
|
||||
if (parent.getId().equals(shopUser.getId())) {
|
||||
throw new CzgException("不能绑定自己为上级");
|
||||
}
|
||||
if (parent.getStatus() == 9) {
|
||||
throw new CzgException("绑定失败该邀请人分销身份已被取消");
|
||||
}
|
||||
@@ -232,6 +263,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
newShopUser.setId(shopUser.getId());
|
||||
newShopUser.setDistributionUserId(parent.getId());
|
||||
newShopUser.setDistributionUserParentId(parent.getParentId());
|
||||
newShopUser.setInviteTime(LocalDateTime.now());
|
||||
shopUserService.updateById(newShopUser);
|
||||
MkDistributionUser newDistributionUser = new MkDistributionUser();
|
||||
newDistributionUser.setId(parent.getId());
|
||||
@@ -353,10 +385,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDistributionUser(MkDistributionUser param) {
|
||||
public MkDistributionUser addDistributionUser(MkDistributionUser param) {
|
||||
AssertUtil.isNull(param.getShopId(), "店铺ID不能为空");
|
||||
AssertUtil.isNull(param.getOpeningMethod(), "开通方式不能为空");
|
||||
AssertUtil.isNull(param.getUserId(), "用户ID不能为空");
|
||||
AssertUtil.isNull(param.getId(), "店铺用户ID不能为空");
|
||||
ShopUser shopUser = shopUserService.getById(param.getId());
|
||||
AssertUtil.isNull(shopUser, "店铺用户ID不能为空");
|
||||
@@ -379,12 +410,14 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
param.setDistributionLevelName(levelConfig.getName());
|
||||
}
|
||||
param.setId(param.getId());
|
||||
param.setUserId(shopUser.getUserId());
|
||||
param.setInviteCode(CzgRandomUtils.randomString(10));
|
||||
save(param);
|
||||
ShopUser shopUser2 = new ShopUser();
|
||||
shopUser2.setId(shopUser.getId());
|
||||
shopUser2.addDistributionShop(param.getShopId());
|
||||
shopUserService.updateById(shopUser2);
|
||||
return param;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user