Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
data-server
Commits
ac964a71
Commit
ac964a71
authored
Mar 17, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户注册
parent
2cffcd26
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
13 deletions
+202
-13
CultivatingPrizeInfoMapper.java
.../java/cn/wisenergy/mapper/CultivatingPrizeInfoMapper.java
+1
-1
TeamUserInfoMapper.java
...src/main/java/cn/wisenergy/mapper/TeamUserInfoMapper.java
+1
-1
LoginManager.java
.../main/java/cn/wisenergy/service/Manager/LoginManager.java
+136
-0
LoginServiceImpl.java
.../java/cn/wisenergy/service/app/impl/LoginServiceImpl.java
+64
-11
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/CultivatingPrizeInfoMapper.java
View file @
ac964a71
...
...
@@ -14,5 +14,5 @@ public interface CultivatingPrizeInfoMapper extends BaseMapper<CultivatingPrizeI
CultivatingPrizeInfo
getOneByUserId
(
String
userId
);
void
add
(
CultivatingPrizeInfo
cultivatingPrizeInfo
);
int
add
(
CultivatingPrizeInfo
cultivatingPrizeInfo
);
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/TeamUserInfoMapper.java
View file @
ac964a71
...
...
@@ -27,5 +27,5 @@ public interface TeamUserInfoMapper extends BaseMapper<TeamUserInfo> {
*/
Integer
getTeamUserCount
(
String
userId
);
void
add
(
TeamUserInfo
teamUserInfo
);
int
add
(
TeamUserInfo
teamUserInfo
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/LoginManager.java
0 → 100644
View file @
ac964a71
package
cn
.
wisenergy
.
service
.
Manager
;
import
cn.wisenergy.common.utils.DateUtil
;
import
cn.wisenergy.mapper.*
;
import
cn.wisenergy.model.app.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @author 86187
* @ Description: 用户登录注册事务管理
* @ Author : 86187
* @ Date : 2021/3/17 11:32
*/
@Component
@Slf4j
public
class
LoginManager
{
@Autowired
private
RecommendUserMapper
recommendUserMapper
;
@Autowired
private
TeamUserInfoMapper
teamUserInfoMapper
;
@Autowired
private
CultivatingPrizeInfoMapper
cultivatingPrizeInfoMapper
;
@Autowired
private
AccountMapper
accountMapper
;
@Autowired
private
TeamPerformanceMapper
teamPerformanceMapper
;
@Autowired
private
UsersMapper
usersMapper
;
/**
* 用户注册初始化信息
*
* @param user 用户信息
* @return true or false
*/
public
boolean
initUserInfo
(
User
user
)
{
String
userId
=
user
.
getUserId
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
new
Date
(),
"yyyy-MM"
);
//保存用户信息
int
userCount
=
usersMapper
.
add
(
user
);
if
(
userCount
==
0
)
{
return
false
;
}
//直推用户表维护
RecommendUser
recommendUser
=
new
RecommendUser
();
recommendUser
.
setUserId
(
userId
);
recommendUser
.
setNormalUserNum
(
0
);
recommendUser
.
setSeedlingNum
(
0
);
recommendUser
.
setBronzeTreeNum
(
0
);
recommendUser
.
setSilverTreeNum
(
0
);
recommendUser
.
setGoldTreeNum
(
0
);
recommendUser
.
setFarmerNum
(
0
);
recommendUser
.
setForestStartNum
(
0
);
recommendUser
.
setPartnerNum
(
0
);
recommendUser
.
setMonthyCount
(
new
BigDecimal
(
0
));
recommendUser
.
setHistoryCount
(
new
BigDecimal
(
0
));
int
count
=
recommendUserMapper
.
add
(
recommendUser
);
if
(
count
==
0
)
{
return
false
;
}
//团队用户表数据维护
TeamUserInfo
teamUserInfo
=
new
TeamUserInfo
();
teamUserInfo
.
setUserId
(
userId
);
teamUserInfo
.
setNormalUserNum
(
0
);
teamUserInfo
.
setSeedlingNum
(
0
);
teamUserInfo
.
setBronzeTreeNum
(
0
);
teamUserInfo
.
setSilverTreeNum
(
0
);
teamUserInfo
.
setGoldTreeNum
(
0
);
teamUserInfo
.
setFarmerNum
(
0
);
teamUserInfo
.
setForestStartNum
(
0
);
teamUserInfo
.
setPartnerNum
(
0
);
int
teamAdd
=
teamUserInfoMapper
.
add
(
teamUserInfo
);
if
(
teamAdd
==
0
)
{
return
false
;
}
//培育奖记录数据维护
CultivatingPrizeInfo
cultivatingPrizeInfo
=
new
CultivatingPrizeInfo
();
cultivatingPrizeInfo
.
setUserId
(
userId
);
cultivatingPrizeInfo
.
setSeedling
(
0
);
cultivatingPrizeInfo
.
setBronzeTree
(
0
);
cultivatingPrizeInfo
.
setSilverTree
(
0
);
cultivatingPrizeInfo
.
setGoldTree
(
0
);
cultivatingPrizeInfo
.
setFarmer
(
0
);
cultivatingPrizeInfo
.
setForestStart
(
0
);
cultivatingPrizeInfo
.
setPartner
(
0
);
int
prize
=
cultivatingPrizeInfoMapper
.
add
(
cultivatingPrizeInfo
);
if
(
prize
==
0
)
{
return
false
;
}
//账户表记录数据维护
AccountInfo
accountInfo
=
new
AccountInfo
();
accountInfo
.
setUserId
(
userId
);
accountInfo
.
setUserLevel
(
0
);
accountInfo
.
setYearMonth
(
yearMonth
);
accountInfo
.
setExtractMoney
(
new
BigDecimal
(
0
));
accountInfo
.
setEarningsMonth
(
new
BigDecimal
(
0
));
accountInfo
.
setFrozenMoney
(
new
BigDecimal
(
0
));
accountInfo
.
setEarningsTotal
(
new
BigDecimal
(
0
));
int
sum
=
accountMapper
.
add
(
accountInfo
);
if
(
sum
==
0
)
{
return
false
;
}
//团队业绩表数据维护
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
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/LoginServiceImpl.java
View file @
ac964a71
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.utils.Constants
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.common.utils.RedisUtils
;
import
cn.wisenergy.common.utils.ShareCodeUtil
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.mapper.*
;
import
cn.wisenergy.model.app.*
;
import
cn.wisenergy.model.vo.UserRegisterVo
;
import
cn.wisenergy.service.Manager.LoginManager
;
import
cn.wisenergy.service.app.LoginService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author 86187
...
...
@@ -26,6 +27,12 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
private
LoginManager
loginManager
;
@Autowired
private
TeamUserInfoMapper
teamUserInfoMapper
;
@Override
public
R
<
Boolean
>
userRegister
(
UserRegisterVo
userVo
)
{
log
.
info
(
"shop-mall[]LoginServiceImpl[]userRegister[]input.param.userVo:"
+
userVo
);
...
...
@@ -56,8 +63,16 @@ public class LoginServiceImpl implements LoginService {
user
.
setUserId
(
userVo
.
getUserId
());
user
.
setHeadImage
(
Constants
.
Common
.
HEAD_POTRAIT
);
user
.
setUserLevel
(
0
);
String
inviteCode
=
ShareCodeUtil
.
idToCode
(
Long
.
parseLong
(
userVo
.
getUserId
()));
user
.
setInviteCode
(
inviteCode
);
if
(
StringUtils
.
isBlank
(
userVo
.
getBeInvitedCode
()))
{
user
.
setBeInvitedCode
(
"1"
);
//初始化用户信息
boolean
initUser
=
loginManager
.
initUserInfo
(
user
);
if
(!
initUser
)
{
return
R
.
ok
(
1
,
false
);
}
}
else
{
//判断推荐人邀请码信息是否正确
User
userCode
=
usersMapper
.
queryByInviteCode
(
userVo
.
getBeInvitedCode
());
...
...
@@ -65,17 +80,55 @@ public class LoginServiceImpl implements LoginService {
return
R
.
error
(
"邀请码填写无效,邀请人不存在,请重新填写!"
);
}
user
.
setBeInvitedCode
(
userVo
.
getBeInvitedCode
());
}
//todo 当id大于千万级别是 邀请码的位数会大于六位
String
inviteCode
=
ShareCodeUtil
.
idToCode
(
""
);
user
.
setInviteCode
(
inviteCode
);
return
null
;
//4、根据推荐人邀请码,获取用户的上级列表
//初始化用户信息
boolean
initBool
=
loginManager
.
initUserInfo
(
user
);
if
(!
initBool
)
{
return
R
.
ok
(
1
,
false
);
}
}
return
R
.
ok
(
0
,
true
);
}
/**
* 检查用户手机号是否已注册
*
* @param userId 用户手机号
* @return true or false
*/
private
Boolean
checkPhone
(
String
userId
)
{
//根据userId,获取用户信息
User
user
=
usersMapper
.
getByUserId
(
userId
);
return
null
==
user
;
}
private
List
<
TeamUserInfo
>
getTeamUserList
(
String
beInvitedCode
)
{
List
<
TeamUserInfo
>
list
=
new
ArrayList
<>();
//根据邀请码查询上级用户的id
String
teamUserId
=
usersMapper
.
getUserByIntiveCode
(
beInvitedCode
);
//查询上级用户的团队信息表
TeamUserInfo
teamUserInfoByUserId
=
teamUserInfoMapper
.
getByUserId
(
teamUserId
);
return
list
;
}
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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment