From 182248f071a545649f2ce60ee1aa21b653a97c84 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 14 Jul 2021 11:12:21 +0800 Subject: [PATCH] add distrib/join --- gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java index c363462..e06dd0d 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java +++ b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java @@ -1,16 +1,80 @@ package com.xzx.gc.user.service; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.xzx.gc.common.exception.RestException; +import com.xzx.gc.entity.AccountInfo; +import com.xzx.gc.entity.SysMessage; +import com.xzx.gc.entity.UserHeadRelate; +import com.xzx.gc.entity.UserShareInfo; +import com.xzx.gc.user.mapper.AccountMapper; +import com.xzx.gc.user.mapper.SysMessageMapper; +import com.xzx.gc.user.mapper.UserHeadRelateMapper; +import com.xzx.gc.user.mapper.UserShareInfoMapper; import com.xzx.gc.user.vo.ViewSettingVo; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.Date; @Service @Transactional public class DistribService { + @Autowired + private UserHeadRelateMapper userHeadRelateMapper; + + @Autowired + private AccountMapper accountMapper; + + @Autowired + private UserShareInfoMapper userShareInfoMapper; + @Autowired + private SysMessageMapper sysMessageMapper; public ViewSettingVo viewSetting(Long id) { ViewSettingVo viewSettingVo = new ViewSettingVo(); return viewSettingVo; } + + + public void join(String headId, String userId) { + AccountInfo headInfo = accountMapper.selectOneByUserId(headId); + if (AccountInfo.IS_HEAD_N.equals(headInfo.getIsHead())) { + throw new RestException(-3, "不是团长"); + } + + if (AccountInfo.IS_PROHIBIT_Y.equals(headInfo.getIsProhibit())) { + throw new RestException(-3, "该用户被冻结"); + } + + UserHeadRelate existHeadRelate = userHeadRelateMapper.selectMemberByUserId(userId); + if (existHeadRelate != null) { + throw new RestException(-3, "已加入其他团队"); + } + + AccountInfo accountInfo = accountMapper.selectOneByUserId(userId); + UserShareInfo userShareInfo = userShareInfoMapper.selectByRegistPhone(accountInfo.getAccountName()); + if (userShareInfo != null) { + throw new RestException(-3, "您已与推广员绑定, 无法加入"); + } + + UserHeadRelate userHeadRelate = new UserHeadRelate(); + userHeadRelate.setHeadUserId(headId); + userHeadRelate.setUserId(userId); + userHeadRelate.setScore(BigDecimal.ZERO); + userHeadRelate.setAmount(BigDecimal.ZERO); + userHeadRelateMapper.insert(userHeadRelate); + + SysMessage sysMessage = new SysMessage(); + sysMessage.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + sysMessage.setCreateUserId(userId); + sysMessage.setMobilePhone(accountInfo.getAccountName()); + sysMessage.setMessageType("4"); + sysMessage.setMessage("手机号:" + accountInfo.getAccountName() + "的用户, 成功加入您的团队"); + sysMessage.setFlag("2"); + sysMessageMapper.insert(sysMessage); + } } -- Gitblit v1.9.1