Commit 8470e7ae authored by licc's avatar licc

用户注册 接口提交

parent ac964a71
......@@ -28,4 +28,6 @@ public interface TeamUserInfoMapper extends BaseMapper<TeamUserInfo> {
Integer getTeamUserCount(String userId);
int add(TeamUserInfo teamUserInfo);
int edit(TeamUserInfo teamUserInfo);
}
......@@ -62,6 +62,17 @@
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<update id="edit">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<select id="getByUserId" resultType="cn.wisenergy.model.app.TeamUserInfo">
select
<include refid="cols_all"/>
......
......@@ -6,9 +6,11 @@ import cn.wisenergy.model.app.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author 86187
......@@ -44,7 +46,7 @@ public class LoginManager {
* @param user 用户信息
* @return true or false
*/
public boolean initUserInfo(User user) {
public boolean initUserInfo(User user, List<TeamUserInfo> list) {
String userId = user.getUserId();
String yearMonth = DateUtil.convertDateToStr(new Date(), "yyyy-MM");
......@@ -55,6 +57,51 @@ public class LoginManager {
}
//直推用户表维护
boolean bool = initRecommendUser(userId);
if (!bool) {
return false;
}
//团队用户表数据维护
boolean teamBool = initTeamUserInfo(userId);
if (!teamBool) {
return false;
}
//培育奖记录数据维护
boolean prizeBool = initCultivatingPrizeInfo(userId);
if (!prizeBool) {
return false;
}
//账户表记录数据维护
boolean accountBool = initAccountInfo(userId, yearMonth);
if (!accountBool) {
return false;
}
//团队业绩表数据维护
boolean perforBool = initTeamPerformance(userId, yearMonth);
if (!perforBool) {
return false;
}
//更新用户上级直推用户
if (!CollectionUtils.isEmpty(list)) {
for (TeamUserInfo teamUser : list) {
teamUser.setNormalUserNum(teamUser.getNormalUserNum() + 1);
int number = teamUserInfoMapper.edit(teamUser);
if (number == 0) {
return false;
}
}
}
return true;
}
private boolean initRecommendUser(String userId) {
RecommendUser recommendUser = new RecommendUser();
recommendUser.setUserId(userId);
recommendUser.setNormalUserNum(0);
......@@ -68,11 +115,10 @@ public class LoginManager {
recommendUser.setMonthyCount(new BigDecimal(0));
recommendUser.setHistoryCount(new BigDecimal(0));
int count = recommendUserMapper.add(recommendUser);
if (count == 0) {
return false;
return count != 0;
}
//团队用户表数据维护
private boolean initTeamUserInfo(String userId) {
TeamUserInfo teamUserInfo = new TeamUserInfo();
teamUserInfo.setUserId(userId);
teamUserInfo.setNormalUserNum(0);
......@@ -84,11 +130,10 @@ public class LoginManager {
teamUserInfo.setForestStartNum(0);
teamUserInfo.setPartnerNum(0);
int teamAdd = teamUserInfoMapper.add(teamUserInfo);
if (teamAdd == 0) {
return false;
return teamAdd != 0;
}
//培育奖记录数据维护
private boolean initCultivatingPrizeInfo(String userId) {
CultivatingPrizeInfo cultivatingPrizeInfo = new CultivatingPrizeInfo();
cultivatingPrizeInfo.setUserId(userId);
cultivatingPrizeInfo.setSeedling(0);
......@@ -99,11 +144,10 @@ public class LoginManager {
cultivatingPrizeInfo.setForestStart(0);
cultivatingPrizeInfo.setPartner(0);
int prize = cultivatingPrizeInfoMapper.add(cultivatingPrizeInfo);
if (prize == 0) {
return false;
return prize != 0;
}
//账户表记录数据维护
private boolean initAccountInfo(String userId, String yearMonth) {
AccountInfo accountInfo = new AccountInfo();
accountInfo.setUserId(userId);
accountInfo.setUserLevel(0);
......@@ -113,24 +157,16 @@ public class LoginManager {
accountInfo.setFrozenMoney(new BigDecimal(0));
accountInfo.setEarningsTotal(new BigDecimal(0));
int sum = accountMapper.add(accountInfo);
if (sum == 0) {
return false;
return sum != 0;
}
//团队业绩表数据维护
private boolean initTeamPerformance(String userId, String yearMonth) {
TeamPerformance teamPerformance = new TeamPerformance();
teamPerformance.setUserId(userId);
teamPerformance.setUserLevel(0);
teamPerformance.setYearMonth(yearMonth);
teamPerformance.setMonthTeamPerformance(new BigDecimal(0));
int teamCount = teamPerformanceMapper.add(teamPerformance);
if (teamCount == 0) {
return false;
}
//更新用户上级直推用户
return true;
return teamCount != 0;
}
}
......@@ -33,6 +33,8 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private TeamUserInfoMapper teamUserInfoMapper;
private static final String INVITE_CODE = "1";
@Override
public R<Boolean> userRegister(UserRegisterVo userVo) {
log.info("shop-mall[]LoginServiceImpl[]userRegister[]input.param.userVo:" + userVo);
......@@ -68,8 +70,9 @@ public class LoginServiceImpl implements LoginService {
if (StringUtils.isBlank(userVo.getBeInvitedCode())) {
user.setBeInvitedCode("1");
List<TeamUserInfo> list = new ArrayList<>();
//初始化用户信息
boolean initUser = loginManager.initUserInfo(user);
boolean initUser = loginManager.initUserInfo(user, list);
if (!initUser) {
return R.ok(1, false);
}
......@@ -81,12 +84,11 @@ public class LoginServiceImpl implements LoginService {
}
user.setBeInvitedCode(userVo.getBeInvitedCode());
//4、根据推荐人邀请码,获取用户的上级列表
List<TeamUserInfo> list = getTeamUserList(userVo.getBeInvitedCode());
//初始化用户信息
boolean initBool = loginManager.initUserInfo(user);
boolean initBool = loginManager.initUserInfo(user, list);
if (!initBool) {
return R.ok(1, false);
}
......@@ -106,29 +108,23 @@ public class LoginServiceImpl implements LoginService {
return null == user;
}
/**
* 获取当前用户直销用户列表
*
* @param beInvitedCode 邀请人邀请码
* @return 用户直销用户列表
*/
private List<TeamUserInfo> getTeamUserList(String beInvitedCode) {
List<TeamUserInfo> list = new ArrayList<>();
while (!INVITE_CODE.equals(beInvitedCode)) {
//根据邀请码查询上级用户的id
String teamUserId = usersMapper.getUserByIntiveCode(beInvitedCode);
User user = usersMapper.getByBeInvitedCode(beInvitedCode);
//查询上级用户的团队信息表
TeamUserInfo teamUserInfoByUserId = teamUserInfoMapper.getByUserId(teamUserId);
return list;
TeamUserInfo teamUserInfoByUserId = teamUserInfoMapper.getByUserId(user.getUserId());
list.add(teamUserInfoByUserId);
beInvitedCode = user.getInviteCode();
}
public static void main(String[] args) {
String str = "aa";
System.out.println("第一次输出:" + str);
str = "我爱你";
int i = 1;
while (!str.equals("aa")) {
if (i < 5) {
i++;
}
}
System.out.println(str);
return list;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment