Commit 09e2841f authored by m1991's avatar m1991

Merge remote-tracking branch 'origin/master'

parents 558b2f11 89927325
...@@ -41,7 +41,6 @@ public interface UsersMapper extends BaseMapper<User> { ...@@ -41,7 +41,6 @@ public interface UsersMapper extends BaseMapper<User> {
*/ */
int delById(@Param("id") Integer id); int delById(@Param("id") Integer id);
List<User> getList(Map<String, Object> map); List<User> getList(Map<String, Object> map);
List<User> findAll(); List<User> findAll();
...@@ -52,6 +51,12 @@ public interface UsersMapper extends BaseMapper<User> { ...@@ -52,6 +51,12 @@ public interface UsersMapper extends BaseMapper<User> {
void save(User user); void save(User user);
/**
* 获取用户信息
* @return 用户信息
*/
User getUserById(@Param("id") Long id);
/** /**
* 获取用户信息 * 获取用户信息
* *
......
...@@ -106,6 +106,16 @@ ...@@ -106,6 +106,16 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="getUserById" resultType="cn.wisenergy.model.app.User" parameterType="java.lang.Long">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
id=#{id}
</where>
</select>
<select id="getByUserId" resultType="cn.wisenergy.model.app.User" parameterType="string"> <select id="getByUserId" resultType="cn.wisenergy.model.app.User" parameterType="string">
select select
id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code, id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
......
...@@ -232,7 +232,7 @@ public class AccountManager { ...@@ -232,7 +232,7 @@ public class AccountManager {
//更新月收益 //更新月收益
if (!CollectionUtils.isEmpty(accountInfoList)) { if (!CollectionUtils.isEmpty(accountInfoList)) {
for (AccountInfo accountInfo : accountInfoList) { for (AccountInfo accountInfo : accountInfoList) {
int count = accountMapper.updateById(accountInfo); int count = accountMapper.edit(accountInfo);
if (count == 0) { if (count == 0) {
return false; return false;
} }
......
...@@ -7,26 +7,30 @@ import cn.wisenergy.model.vo.AerialDeliveryVo; ...@@ -7,26 +7,30 @@ import cn.wisenergy.model.vo.AerialDeliveryVo;
import java.util.Map; import java.util.Map;
/** /**
* @author 86187
* @author 86187 * @author 86187
* @ Description: 用户接口 * @ Description: 用户接口
* @ Author : 86187 * @ Author : 86187
* @ Date : 2021/1/6 16:08 * @ Date : 2021/1/6 16:08
* @author 86187
*/ */
public interface UserService { public interface UserService {
/** /**
* 获取用户信息 * 获取用户信息
*
* @param userId 用户id * @param userId 用户id
* @return 用户信息 * @return 用户信息
*/ */
User getById(String userId); User getById(String userId);
R<Integer> getById1(String userId); R<Integer> getById1(String userId);
User getUserById(Long id);
/** /**
* 获取用户信息 * 获取用户信息
*
* @param userId 用户id * @param userId 用户id
* @return 用户信息 * @return 用户信息
*/ */
...@@ -65,7 +69,8 @@ public interface UserService { ...@@ -65,7 +69,8 @@ public interface UserService {
/** /**
* 设置用户头像 * 设置用户头像
* @param userId 用户id *
* @param userId 用户id
* @param headImage 头像图片地址 * @param headImage 头像图片地址
* @return true or false * @return true or false
*/ */
...@@ -73,7 +78,8 @@ public interface UserService { ...@@ -73,7 +78,8 @@ public interface UserService {
/** /**
* 设置页面 -邀请码填写 * 设置页面 -邀请码填写
* @param userId 用户id *
* @param userId 用户id
* @param inviteCode 邀请人邀请码 * @param inviteCode 邀请人邀请码
* @return true or false * @return true or false
*/ */
......
...@@ -5,10 +5,7 @@ import cn.wisenergy.common.utils.R; ...@@ -5,10 +5,7 @@ import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.*; import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.MemberPercentEnum; import cn.wisenergy.model.enums.*;
import cn.wisenergy.model.enums.RebateStatusEnum;
import cn.wisenergy.model.enums.TradeRecordEnum;
import cn.wisenergy.model.enums.TradeStatusEnum;
import cn.wisenergy.model.vo.TeamPerformanceSortVo; import cn.wisenergy.model.vo.TeamPerformanceSortVo;
import cn.wisenergy.service.Manager.PublicManager; import cn.wisenergy.service.Manager.PublicManager;
import cn.wisenergy.service.app.AccountService; import cn.wisenergy.service.app.AccountService;
...@@ -159,7 +156,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -159,7 +156,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
String userId = entity.getKey(); String userId = entity.getKey();
//1)、统计当前用户月度业绩 //1)、统计当前用户月度业绩
double userCount = entity.getValue(); double userCount = entity.getValue();
tempMap.put(userId, userCount); if (tempMap.containsKey(entity.getKey())) {
double teamMoney = userCount + tempMap.get(entity.getKey());
tempMap.put(entity.getKey(), teamMoney);
} else {
//key 不存在,加入集合 当前用户团队绩效
tempMap.put(entity.getKey(), userCount);
}
//2)、获取当前用户的上级用户列表 //2)、获取当前用户的上级用户列表
List<User> userList = getByList(userId); List<User> userList = getByList(userId);
...@@ -171,11 +174,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -171,11 +174,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//3)、统计当前用户的上级用户团队绩效 //3)、统计当前用户的上级用户团队绩效
//key 存在 当前用户团队绩效 + 上级用户团队绩效 //key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(userInfo.getUserId())) { if (tempMap.containsKey(userInfo.getUserId())) {
double teamMoney = userCount + map.get(userInfo.getUserId()); double teamMoney = userCount + tempMap.get(userInfo.getUserId());
map.put(userInfo.getUserId(), teamMoney); tempMap.put(userInfo.getUserId(), teamMoney);
} else { } else {
//key 不存在,加入集合 当前用户团队绩效 //key 不存在,加入集合 当前用户团队绩效
map.put(userInfo.getUserId(), userCount); tempMap.put(userInfo.getUserId(), userCount);
} }
} }
} }
...@@ -196,7 +199,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -196,7 +199,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
performance.setUserLevel(user.getUserLevel()); performance.setUserLevel(user.getUserLevel());
performance.setYearMonth(yearMonth); performance.setYearMonth(yearMonth);
teamPerformanceMapper.add(performance);
addList.add(performance); addList.add(performance);
} else { } else {
teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
...@@ -267,6 +269,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -267,6 +269,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
List<AccountInfo> accountInfoList = new ArrayList<>(); List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>(); List<TradeRecord> tradeRecordList = new ArrayList<>();
for (TeamPerformance user : list) { for (TeamPerformance user : list) {
//用户是普通用户的,不计算最大进步奖
if (user.getUserLevel().equals(UserLevelEnum.NORMAL_USER.getCode())) {
continue;
}
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3); MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3);
...@@ -274,11 +281,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -274,11 +281,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
double userTeamPerformance = user.getMonthTeamPerformance().doubleValue(); double userTeamPerformance = user.getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue(); double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / twentyTotal; double income = Math.floor(number * 3980 * percent * userTeamPerformance / twentyTotal);
//获取账户信息 //获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId()); AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
accountInfo.setEarningsMonth(new BigDecimal(income));
//用户月收益 =其他收益+最大进步奖收益
BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(BigDecimal.valueOf(income));
accountInfo.setEarningsMonth(earningsMonth);
//用户总收益 =其他总收益 + earningsMonth
BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(BigDecimal.valueOf(income));
accountInfo.setEarningsTotal(earningsTotal);
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
//添加交易流水记录 //添加交易流水记录
...@@ -286,7 +300,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -286,7 +300,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
tradeRecord.setUserId(user.getUserId()); tradeRecord.setUserId(user.getUserId());
tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode()); tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode());
tradeRecord.setTradeNo(null); tradeRecord.setTradeNo(null);
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode()); tradeRecord.setStatus(TradeStatusEnum.NO_SETTLE_ACCOUNTS.getCode());
tradeRecord.setMoney(BigDecimal.valueOf(income));
tradeRecordList.add(tradeRecord); tradeRecordList.add(tradeRecord);
} }
......
...@@ -114,7 +114,14 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -114,7 +114,14 @@ public class MonthTaskServiceImpl implements MonthTaskService {
String userId = entity.getKey(); String userId = entity.getKey();
//1)、统计当前用户月度业绩 //1)、统计当前用户月度业绩
double userCount = entity.getValue(); double userCount = entity.getValue();
tempMap.put(userId, userCount); //key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(entity.getKey())) {
double teamMoney = userCount + tempMap.get(entity.getKey());
tempMap.put(entity.getKey(), teamMoney);
} else {
//key 不存在,加入集合 当前用户团队绩效
tempMap.put(entity.getKey(), userCount);
}
//2)、获取当前用户的上级用户列表 //2)、获取当前用户的上级用户列表
List<User> userList = accountService.getByList(userId); List<User> userList = accountService.getByList(userId);
...@@ -126,11 +133,11 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -126,11 +133,11 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//3)、统计当前用户的上级用户团队绩效 //3)、统计当前用户的上级用户团队绩效
//key 存在 当前用户团队绩效 + 上级用户团队绩效 //key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(userInfo.getUserId())) { if (tempMap.containsKey(userInfo.getUserId())) {
double teamMoney = userCount + map.get(userInfo.getUserId()); double teamMoney = userCount + tempMap.get(userInfo.getUserId());
map.put(userInfo.getUserId(), teamMoney); tempMap.put(userInfo.getUserId(), teamMoney);
} else { } else {
//key 不存在,加入集合 当前用户团队绩效 //key 不存在,加入集合 当前用户团队绩效
map.put(userInfo.getUserId(), userCount); tempMap.put(userInfo.getUserId(), userCount);
} }
} }
} }
...@@ -151,7 +158,6 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -151,7 +158,6 @@ public class MonthTaskServiceImpl implements MonthTaskService {
performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
performance.setUserLevel(user.getUserLevel()); performance.setUserLevel(user.getUserLevel());
performance.setYearMonth(yearMonth); performance.setYearMonth(yearMonth);
teamPerformanceMapper.add(performance);
addList.add(performance); addList.add(performance);
} else { } else {
teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue())); teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
...@@ -160,8 +166,8 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -160,8 +166,8 @@ public class MonthTaskServiceImpl implements MonthTaskService {
} }
//4、更新账户月度绩效 //4、更新账户月度绩效
boolean updateBool=accountManager.updateAccountPerformanceMonth(addList, updateList); boolean updateBool = accountManager.updateAccountPerformanceMonth(addList, updateList);
if(!updateBool){ if (!updateBool) {
return R.ok(1, false); return R.ok(1, false);
} }
...@@ -214,6 +220,11 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -214,6 +220,11 @@ public class MonthTaskServiceImpl implements MonthTaskService {
List<AccountInfo> accountInfoList = new ArrayList<>(); List<AccountInfo> accountInfoList = new ArrayList<>();
List<TradeRecord> tradeRecordList = new ArrayList<>(); List<TradeRecord> tradeRecordList = new ArrayList<>();
for (TeamPerformance user : list) { for (TeamPerformance user : list) {
//用户是普通用户的,不计算最大进步奖
if (user.getUserLevel().equals(UserLevelEnum.NORMAL_USER.getCode())) {
continue;
}
//获取最大进步奖 百分比 //获取最大进步奖 百分比
MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3); MemberPercent memberPercent = memberPercentMapper.getByLevelAndType(user.getUserLevel(), 3);
...@@ -221,11 +232,18 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -221,11 +232,18 @@ public class MonthTaskServiceImpl implements MonthTaskService {
double userTeamPerformance = user.getMonthTeamPerformance().doubleValue(); double userTeamPerformance = user.getMonthTeamPerformance().doubleValue();
double percent = memberPercent.getPercent().doubleValue(); double percent = memberPercent.getPercent().doubleValue();
double income = number * 3980 * percent * userTeamPerformance / twentyTotal; double income = Math.floor(number * 3980 * percent * userTeamPerformance / twentyTotal);
//获取账户信息 //获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId()); AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
accountInfo.setEarningsMonth(new BigDecimal(income));
//用户月收益 =其他收益+最大进步奖收益
BigDecimal earningsMonth = accountInfo.getEarningsMonth().add(BigDecimal.valueOf(income));
accountInfo.setEarningsMonth(earningsMonth);
//用户总收益 =其他总收益 + earningsMonth
BigDecimal earningsTotal = accountInfo.getEarningsTotal().add(BigDecimal.valueOf(income));
accountInfo.setEarningsTotal(earningsTotal);
accountInfoList.add(accountInfo); accountInfoList.add(accountInfo);
//添加交易流水记录 //添加交易流水记录
...@@ -234,6 +252,7 @@ public class MonthTaskServiceImpl implements MonthTaskService { ...@@ -234,6 +252,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode()); tradeRecord.setTradeType(TradeRecordEnum.PROGRESS_PRIZE.getCode());
tradeRecord.setTradeNo(null); tradeRecord.setTradeNo(null);
tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode()); tradeRecord.setStatus(TradeStatusEnum.ALREADY_SETTLE_ACCOUNTS.getCode());
tradeRecord.setMoney(BigDecimal.valueOf(income));
tradeRecordList.add(tradeRecord); tradeRecordList.add(tradeRecord);
} }
......
...@@ -56,6 +56,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -56,6 +56,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
@Override @Override
public void userLevelUp(){ public void userLevelUp(){
//1.获取数据库订单数据 //1.获取数据库订单数据
log.info("------------------------用户升级开始----------------------------------");
List<OrderInfo> ordersByLevelStatus = orderMapper.getByLevelStatus(0); List<OrderInfo> ordersByLevelStatus = orderMapper.getByLevelStatus(0);
for (OrderInfo orderInfo : ordersByLevelStatus) { for (OrderInfo orderInfo : ordersByLevelStatus) {
String buyerId = orderInfo.getBuyerId(); String buyerId = orderInfo.getBuyerId();
...@@ -64,6 +65,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -64,6 +65,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
orderInfo.setLevelStatus(1); orderInfo.setLevelStatus(1);
orderMapper.updateById(orderInfo); orderMapper.updateById(orderInfo);
} }
log.info("-------------------------用户升级结束--------------------------------------");
} }
@Override @Override
...@@ -605,7 +607,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -605,7 +607,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != bronzeTree) { if (1 != bronzeTree) {
//给上级用户幼苗等级培育奖 //给上级用户青铜等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -625,7 +627,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -625,7 +627,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
bronzeTree = 1; bronzeTree = 1;
cultivatingPrizeInfo.setSeedling(bronzeTree); cultivatingPrizeInfo.setBronzeTree(bronzeTree);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} else if (3 == level) { } else if (3 == level) {
...@@ -634,7 +636,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -634,7 +636,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != silverTree) { if (1 != silverTree) {
//给上级用户幼苗等级培育奖 //给上级用户白银等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -654,7 +656,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -654,7 +656,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
silverTree = 1; silverTree = 1;
cultivatingPrizeInfo.setSeedling(silverTree); cultivatingPrizeInfo.setSilverTree(silverTree);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} else if (4 == level) { } else if (4 == level) {
...@@ -663,7 +665,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -663,7 +665,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != goldTree) { if (1 != goldTree) {
//给上级用户幼苗等级培育奖 //给上级用户黄金等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -683,7 +685,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -683,7 +685,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
goldTree = 1; goldTree = 1;
cultivatingPrizeInfo.setSeedling(goldTree); cultivatingPrizeInfo.setGoldTree(goldTree);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} else if (5 == level) { } else if (5 == level) {
...@@ -692,7 +694,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -692,7 +694,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != farmer) { if (1 != farmer) {
//给上级用户幼苗等级培育奖 //给上级用户农场主等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -712,7 +714,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -712,7 +714,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
farmer = 1; farmer = 1;
cultivatingPrizeInfo.setSeedling(farmer); cultivatingPrizeInfo.setFarmer(farmer);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} else if (6 == level) { } else if (6 == level) {
...@@ -721,7 +723,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -721,7 +723,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != forestStart) { if (1 != forestStart) {
//给上级用户幼苗等级培育奖 //给上级用户森林之星等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -741,7 +743,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -741,7 +743,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
forestStart = 1; forestStart = 1;
cultivatingPrizeInfo.setSeedling(forestStart); cultivatingPrizeInfo.setForestStart(forestStart);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} else if (7 == level) { } else if (7 == level) {
...@@ -750,7 +752,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -750,7 +752,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize(); BigDecimal cultivatingPrize = cultivatingPrizeMapper.getcultivatingPrizeByUserLevel(level).getCultivatingPrize();
if (1 != partner) { if (1 != partner) {
//给上级用户幼苗等级培育奖 //给上级用户西田森合伙人等级培育奖
//1.上级用户本月收益 ++ //1.上级用户本月收益 ++
AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId); AccountInfo beIntivedUserAccount = accountMapper.getByUserId(inviteUserId);
BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth(); BigDecimal earningsMonth = beIntivedUserAccount.getEarningsMonth();
...@@ -770,7 +772,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen ...@@ -770,7 +772,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//3.修改培育奖记录状态 ==1 //3.修改培育奖记录状态 ==1
partner = 1; partner = 1;
cultivatingPrizeInfo.setSeedling(partner); cultivatingPrizeInfo.setPartner(partner);
cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo); cultivatingPrizeInfoMapper.updateById(cultivatingPrizeInfo);
} }
} }
......
package cn.wisenergy.service.app.impl; package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.*; import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.RedisKeyUtils;
import cn.wisenergy.common.utils.RedisUtils;
import cn.wisenergy.common.utils.ShareCodeUtil;
import cn.wisenergy.mapper.RecommendUserMapper; import cn.wisenergy.mapper.RecommendUserMapper;
import cn.wisenergy.mapper.TeamUserInfoMapper; import cn.wisenergy.mapper.TeamUserInfoMapper;
import cn.wisenergy.mapper.UsersMapper; import cn.wisenergy.mapper.UsersMapper;
...@@ -17,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
/** /**
...@@ -53,6 +55,11 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -53,6 +55,11 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
return R.ok(usersMapper.ByUserId(userId)); return R.ok(usersMapper.ByUserId(userId));
} }
@Override
public User getUserById(Long id) {
return this.usersMapper.getUserById(id);
}
@Override @Override
public User getByUserId(String userId) { public User getByUserId(String userId) {
......
...@@ -20,23 +20,19 @@ import org.springframework.http.HttpHeaders; ...@@ -20,23 +20,19 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
*
* Created by m1991 on 2021/3/2 13:35 * Created by m1991 on 2021/3/2 13:35
*/ */
@Api(tags = "登录/注册") @Api(tags = "登录/注册")
...@@ -46,7 +42,6 @@ import java.util.Map; ...@@ -46,7 +42,6 @@ import java.util.Map;
public class LoginController { public class LoginController {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -58,6 +53,7 @@ public class LoginController { ...@@ -58,6 +53,7 @@ public class LoginController {
/** /**
* 手机登录接口 * 手机登录接口
*
* @param userId * @param userId
* @param sms * @param sms
* @return * @return
...@@ -69,87 +65,94 @@ public class LoginController { ...@@ -69,87 +65,94 @@ public class LoginController {
@ApiImplicitParam(name = "sms", value = "验证码", dataType = "String"), @ApiImplicitParam(name = "sms", value = "验证码", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String")}) @ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String")})
@RequestMapping("/login") @RequestMapping("/login")
public Map loginBySms(@RequestParam String userId, @RequestParam String sms)throws Exception{ public Map loginBySms(@RequestParam String userId, @RequestParam String sms) throws Exception {
User users=null; User users = null;
Map map=new HashMap(); Map map = new HashMap();
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+""); String key = StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX, Constants.RedisKey.SMS_PRIFIX, userId, Constants.Sms.CodeType.LOGIN_OR_REGISTER + "");
String redisCode=redisUtils.getValue(key); String redisCode = redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){ if (StringUtil.isBlank(redisCode) || !sms.equals(redisCode)) {
map.put("code","1003"); map.put("code", "1003");
map.put("msg","验证码错误"); map.put("msg", "验证码错误");
// throw new BaseException(ResultEnum.FAIL_VERIFY); // throw new BaseException(ResultEnum.FAIL_VERIFY);
return map; return map;
} }
redisUtils.delete(key); redisUtils.delete(key);
//根据手机号判断用户是否存在 //根据手机号判断用户是否存在
//不存在则保存用户信息--修改为提示用户注册 //不存在则保存用户信息--修改为提示用户注册
users=usersService.queryUsersByPhone(userId); users = usersService.queryUsersByPhone(userId);
if(null==users){ if (null == users) {
//throw new BaseException(ResultEnum.FAIL_ACCOUNT_NOT_EXIST); //throw new BaseException(ResultEnum.FAIL_ACCOUNT_NOT_EXIST);
map.put("code","1005"); map.put("code", "1005");
map.put("msg","账号不存在,请注册"); map.put("msg", "账号不存在,请注册");
return map; return map;
} }
String token= null; String token = null;
token = createToken(users); token = createToken(users);
if(!StringUtil.isBlank(token)){ if (!StringUtil.isBlank(token)) {
String wyz=users.getInviteCode(); String wyz = users.getInviteCode();
Map<String, Object> map1=StringUtil.createSimpleMap("token",token); Map<String, Object> map1 = StringUtil.createSimpleMap("token", token);
map1.put("wyz",wyz); map1.put("wyz", wyz);
map1.put("code",0); map1.put("code", 0);
map1.put("msg","成功!"); map1.put("msg", "成功!");
return map1; return map1;
} }
return (Map) ResultUtils.returnFail(); return (Map) ResultUtils.returnFail();
} }
public String createToken(User users)throws Exception{ public String createToken(User users) throws Exception {
String token=StringUtil.createToken(); String token = StringUtil.createToken();
//保存token //保存token
String tokenKey=StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.TOKEN_PRIFIX,token); String tokenKey = StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX, Constants.RedisKey.TOKEN_PRIFIX, token);
UsersDto usersDto=new UsersDto(); UsersDto usersDto = new UsersDto();
BeanUtils.copyProperties(users,usersDto); BeanUtils.copyProperties(users, usersDto);
redisUtils.set(tokenKey, JSONObject.toJSONString(usersDto),Constants.Duration.HALF_HOUR_INT); redisUtils.set(tokenKey, JSONObject.toJSONString(usersDto), Constants.Duration.HALF_HOUR_INT);
return token; return token;
} }
@ApiOperation(value = "获取用户登录token信息", notes = "获取用户登录token信息", httpMethod = "POST", produces = "application/json; charset=UTF-8") @ApiOperation(value = "获取用户登录token信息", notes = "获取用户登录token信息", httpMethod = "POST", produces = "application/json; charset=UTF-8")
@RequestMapping("/info") @RequestMapping("/info")
public Map info(HttpServletRequest request)throws Exception{ public Map info(HttpServletRequest request) throws Exception {
String token=request.getHeader("token"); String token = request.getHeader("token");
String tokenKey=StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.TOKEN_PRIFIX,token); String tokenKey = StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX, Constants.RedisKey.TOKEN_PRIFIX, token);
String userDtoJson=redisUtils.getValue(tokenKey); String userDtoJson = redisUtils.getValue(tokenKey);
if(StringUtil.isBlank(userDtoJson)){ if (StringUtil.isBlank(userDtoJson)) {
Map map=new HashMap(); Map map = new HashMap();
map.put("code","2001"); map.put("code", "2001");
map.put("msg","未登录"); map.put("msg", "未登录");
return map; return map;
} }
UsersDto usersDto=JSONObject.parseObject(userDtoJson,UsersDto.class); UsersDto usersDto = JSONObject.parseObject(userDtoJson, UsersDto.class);
usersDto.setPassword(null); usersDto.setPassword(null);
return (Map) ResultUtils.returnDataSuccess(userDtoJson); return (Map) ResultUtils.returnDataSuccess(userDtoJson);
} }
@ApiOperation(value = "二维码邀请注册", notes = "二维码邀请注册", httpMethod = "POST") @ApiOperation(value = "二维码邀请注册", notes = "二维码邀请注册", httpMethod = "GET")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String") @ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String")
}) })
@PostMapping(value = "/registerByQrCode") @GetMapping(value = "/registerByQrCode")
public ResponseEntity<byte[]> registerByQrCode(@RequestParam("userId") String userId, HttpServletRequest request) throws IOException { public ResponseEntity<byte[]> registerByQrCode(@RequestParam("userId") String userId,
@RequestParam(value = "width", required = false, defaultValue = "120") int width,
@RequestParam(value = "height", required = false, defaultValue = "120") int height,
HttpServletRequest request) throws IOException {
User user = this.usersService.getByUserId(userId); User user = this.usersService.getByUserId(userId);
if (user != null) { if (user != null) {
String regFullUrl = request.getScheme() + "://" + request.getServerName() + ":"+request.getServerPort() String regFullUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ "/regist?beInvitedCode=" + user.getInviteCode(); + "/front/register?beInvitedCode=" + user.getInviteCode();
final InputStream is = new ClassPathResource("templates/background.jpg").getInputStream(); final InputStream is = new ClassPathResource("templates/background.jpg").getInputStream();
BufferedImage srcImage = ImageIO.read(is); BufferedImage srcImage = ImageIO.read(is);
QrConfig config = new QrConfig(130, 130); QrConfig config = new QrConfig(width, height);
config.setCharset(StandardCharsets.UTF_8); config.setCharset(StandardCharsets.UTF_8);
config.setMargin(0); config.setMargin(0);
BufferedImage waterImage = QrCodeUtil.generate(regFullUrl,config); BufferedImage waterImage = QrCodeUtil.generate(regFullUrl, config);
byte[] bytes = ImageUtil.watermarkImageSimple1(srcImage, waterImage); //byte[] bytes = ImageUtil.watermarkImageSimple1(srcImage, waterImage);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(waterImage, "jpg", out);
byte[] bytes = out.toByteArray();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_JPEG); headers.setContentType(MediaType.IMAGE_JPEG);
...@@ -163,45 +166,46 @@ public class LoginController { ...@@ -163,45 +166,46 @@ public class LoginController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String"), @ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String"),
@ApiImplicitParam(name = "beInvitedCode", value = "推荐人邀请码", required = false, dataType = "String"), @ApiImplicitParam(name = "beInvitedCode", value = "推荐人邀请码", required = false, dataType = "String"),
@ApiImplicitParam(name = "sms", value = "验证码",required = true, dataType = "String") @ApiImplicitParam(name = "sms", value = "验证码", required = true, dataType = "String")
}) })
@RequestMapping("/register") @RequestMapping("/register")
public Map register(@RequestParam String userId,@RequestParam String beInvitedCode, @RequestParam String sms)throws Exception { public Map register(@RequestParam String userId, @RequestParam String beInvitedCode, @RequestParam String sms) throws Exception {
User users=null; User users = null;
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+""); String key = StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX, Constants.RedisKey.SMS_PRIFIX, userId, Constants.Sms.CodeType.LOGIN_OR_REGISTER + "");
String redisCode=redisUtils.getValue(key); String redisCode = redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){ if (StringUtil.isBlank(redisCode) || !sms.equals(redisCode)) {
Map map=new HashMap(); Map map = new HashMap();
map.put("code","1003"); map.put("code", "1003");
map.put("msg","验证码错误"); map.put("msg", "验证码错误");
return map; return map;
} }
redisUtils.delete(key); redisUtils.delete(key);
//判断phone是否符合输入类型 //判断phone是否符合输入类型
if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){ if (!userId.matches(Constants.RegConstant.PHONE_REGSTR)) {
Map map=new HashMap(); Map map = new HashMap();
map.put("code","1008"); map.put("code", "1008");
map.put("msg","手机号码格式不正确"); map.put("msg", "手机号码格式不正确");
return map; return map;
} }
return usersService.userByZx(userId,beInvitedCode); return usersService.userByZx(userId, beInvitedCode);
} }
/** /**
* 退出登录 * 退出登录
*
* @param request * @param request
* @return * @return
*/ */
@ApiOperation(value = "退出登录", produces = "application/json", notes = "退出登录") @ApiOperation(value = "退出登录", produces = "application/json", notes = "退出登录")
@ApiImplicitParam(paramType = "header",name = "token", value = "用户token", required = true, dataType = "String") @ApiImplicitParam(paramType = "header", name = "token", value = "用户token", required = true, dataType = "String")
@PostMapping("/logout") @PostMapping("/logout")
public Result logout(HttpServletRequest request) { public Result logout(HttpServletRequest request) {
log.info("退出登录"); log.info("退出登录");
Result result = ResultUtils.returnFail(); Result result = ResultUtils.returnFail();
String token = request.getHeader("token"); String token = request.getHeader("token");
String key = RedisKeyUtils.formatKeyWithPrefix(Constants.Redis.PREFIX_TOKEN, token); String key = RedisKeyUtils.formatKeyWithPrefix(Constants.Redis.PREFIX_TOKEN, token);
if(redisUtils.getValue(key) == null){ if (redisUtils.getValue(key) == null) {
log.info("要退出登录的用户未登录"); log.info("要退出登录的用户未登录");
return ResultUtils.returnResult(ResultEnum.FILE_NOT_LOGIN); return ResultUtils.returnResult(ResultEnum.FILE_NOT_LOGIN);
} }
......
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