Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
lanbaoming
jiedao-api-boot-master
Commits
55dcf89a
Commit
55dcf89a
authored
Aug 05, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户注册新增注册平台
parent
62c2c69f
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
165 additions
and
80 deletions
+165
-80
ScoreProducerApi.java
.../cn/iocoder/yudao/module/member/api/ScoreProducerApi.java
+5
-2
AppAuthRegReqVO.java
...module/member/controller/app/auth/vo/AppAuthRegReqVO.java
+2
-0
AppAuthSmsLoginReqVO.java
...e/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java
+3
-0
MemberUserDO.java
...yudao/module/member/dal/dataobject/user/MemberUserDO.java
+7
-0
AbstractScoreRuleStrategy.java
...ber/mq/consumer/score/core/AbstractScoreRuleStrategy.java
+30
-3
OderVStrategy.java
...o/module/member/mq/consumer/score/core/OderVStrategy.java
+3
-15
RecommendStrategy.java
...dule/member/mq/consumer/score/core/RecommendStrategy.java
+7
-19
RegisterStrategy.java
...odule/member/mq/consumer/score/core/RegisterStrategy.java
+13
-3
ScoreMessage.java
.../iocoder/yudao/module/member/mq/message/ScoreMessage.java
+10
-6
ScoreProducer.java
.../yudao/module/member/mq/producer/score/ScoreProducer.java
+19
-4
MemberAuthServiceImpl.java
...dao/module/member/service/auth/MemberAuthServiceImpl.java
+32
-13
MemberUserService.java
...r/yudao/module/member/service/user/MemberUserService.java
+12
-11
MemberUserServiceImpl.java
...dao/module/member/service/user/MemberUserServiceImpl.java
+5
-4
ReferralCodeUtils.java
...n/iocoder/yudao/module/member/util/ReferralCodeUtils.java
+17
-0
No files found.
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/ScoreProducerApi.java
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
api
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
/**
* @author zhangfeng
*/
public
interface
ScoreProducerApi
{
void
sendOderMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
orderId
);
void
sendRecommendMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
);
void
sendRegisterMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
);
void
sendRecommendMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
,
String
referralCode
);
void
sendRegisterMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
,
String
userNameZh
,
String
userNameEn
,
String
phone
,
Integer
registerPlatform
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthRegReqVO.java
View file @
55dcf89a
...
...
@@ -45,5 +45,7 @@ public class AppAuthRegReqVO {
private
String
englishName
;
@ApiModelProperty
(
value
=
"推荐码"
,
required
=
false
)
private
String
referralCode
;
@ApiModelProperty
(
value
=
"注册平台(2APP,3WEB)"
,
required
=
true
)
private
Integer
registerPlatform
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java
View file @
55dcf89a
...
...
@@ -34,4 +34,7 @@ public class AppAuthSmsLoginReqVO {
@Pattern
(
regexp
=
"^[0-9]+$"
,
message
=
"{app.auth.captcha.pattern}"
)
private
String
code
;
@ApiModelProperty
(
value
=
"登录平台(2APP,3WEB)"
,
required
=
true
,
example
=
"1"
)
private
Integer
loginPlatform
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
View file @
55dcf89a
...
...
@@ -95,7 +95,14 @@ public class MemberUserDO extends TenantBaseDO {
*/
private
String
controlPassword
;
/**
* 推荐码
*/
private
String
referralCode
;
/**
* 注册平台
*/
private
Integer
registerPlatform
;
///**
// * 是否身份认证
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/AbstractScoreRuleStrategy.java
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.dal.redis.scoreRule.ScoreRuleRedisDao
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportTypeEnum
;
import
cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author zhangfeng
...
...
@@ -18,16 +23,18 @@ import java.util.Date;
public
abstract
class
AbstractScoreRuleStrategy
implements
ScoreRuleStrategy
{
protected
ScoreRuleService
scoreRuleService
;
protected
MemberUserScoreLogService
memberUserScoreLogService
;
@Autowired
public
AbstractScoreRuleStrategy
(
ScoreRuleService
scoreRuleService
)
{
public
AbstractScoreRuleStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
)
{
this
.
scoreRuleService
=
scoreRuleService
;
this
.
memberUserScoreLogService
=
memberUserScoreLogService
;
}
@Resource
ScoreRuleRedisDao
scoreRuleRedisDao
;
p
ublic
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
)
{
p
rotected
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
)
{
ScoreRuleDO
enableScoreRule
;
enableScoreRule
=
scoreRuleRedisDao
.
getEnableScoreRule
(
scoreRuleType
);
if
(
enableScoreRule
==
null
)
{
...
...
@@ -50,7 +57,7 @@ public abstract class AbstractScoreRuleStrategy implements ScoreRuleStrategy {
return
enableScoreRule
;
}
p
ublic
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
,
TransportTypeEnum
transportType
)
{
p
rotected
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
,
TransportTypeEnum
transportType
)
{
ScoreRuleDO
enableScoreRule
;
switch
(
scoreRuleType
)
{
case
ORDER_V:
...
...
@@ -76,5 +83,25 @@ public abstract class AbstractScoreRuleStrategy implements ScoreRuleStrategy {
}
return
null
;
}
/**
* 计算用户在某一活动获得积分总数
* @param scoreRuleId
* @param userId
* @return
*/
protected
Integer
getUserScoreTotalCount
(
Long
scoreRuleId
,
Long
userId
)
{
Integer
userScoreTotalCount
=
0
;
LambdaQueryWrapper
<
MemberUserScoreLogDO
>
scoreLogQueryWrapper
=
new
LambdaQueryWrapper
<>();
scoreLogQueryWrapper
.
eq
(
MemberUserScoreLogDO:
:
getMemberId
,
userId
)
.
eq
(
MemberUserScoreLogDO:
:
getRuleId
,
scoreRuleId
);
List
<
MemberUserScoreLogDO
>
memberUserScoreLogs
=
memberUserScoreLogService
.
selectList
(
scoreLogQueryWrapper
);
if
(
CollUtil
.
isNotEmpty
(
memberUserScoreLogs
))
{
for
(
MemberUserScoreLogDO
memberUserScoreLog
:
memberUserScoreLogs
)
{
userScoreTotalCount
+=
memberUserScoreLog
.
getScoreCount
();
}
}
return
userScoreTotalCount
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/OderVStrategy.java
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.json.JSONUtil
;
...
...
@@ -12,14 +11,12 @@ import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.Customer
import
cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContactsService
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.enums.*
;
import
cn.iocoder.yudao.module.member.mq.message.ScoreMessage
;
import
cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -46,8 +43,8 @@ public class OderVStrategy extends AbstractScoreRuleStrategy {
@Resource
private
CustomerContactsService
customerContactsService
;
public
OderVStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
public
OderVStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
);
}
@Override
...
...
@@ -150,16 +147,7 @@ public class OderVStrategy extends AbstractScoreRuleStrategy {
}
}
// 校验累计最高分
Integer
userScoreTotalCount
=
0
;
LambdaQueryWrapper
<
MemberUserScoreLogDO
>
scoreLogQueryWrapper
=
new
LambdaQueryWrapper
<>();
scoreLogQueryWrapper
.
eq
(
MemberUserScoreLogDO:
:
getMemberId
,
userId
)
.
eq
(
MemberUserScoreLogDO:
:
getRuleId
,
scoreRuleDO
.
getId
());
List
<
MemberUserScoreLogDO
>
memberUserScoreLogs
=
memberUserScoreLogService
.
selectList
(
scoreLogQueryWrapper
);
if
(
CollUtil
.
isNotEmpty
(
memberUserScoreLogs
))
{
for
(
MemberUserScoreLogDO
memberUserScoreLog
:
memberUserScoreLogs
)
{
userScoreTotalCount
+=
memberUserScoreLog
.
getScoreCount
();
}
}
Integer
userScoreTotalCount
=
getUserScoreTotalCount
(
scoreRuleDO
.
getId
(),
userId
);
if
(
userScoreTotalCount
>=
scoreRuleDO
.
getMaxScoreTotal
())
{
log
.
info
(
"Order in shipping listener: The user has reached the maximum score,userId:{},scoreRuleId:{}"
,
userId
,
scoreRuleDO
.
getId
());
return
;
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/RecommendStrategy.java
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
...
...
@@ -12,13 +10,12 @@ import cn.iocoder.yudao.module.member.mq.message.ScoreMessage;
import
cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.service.user.MemberUserService
;
import
c
om.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
c
n.iocoder.yudao.module.member.util.ReferralCodeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* @author zhangfeng
...
...
@@ -32,14 +29,14 @@ public class RecommendStrategy extends AbstractScoreRuleStrategy {
private
MemberUserService
memberUserService
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
public
RecommendStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
public
RecommendStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
);
}
@Override
public
void
addScore
(
ScoreMessage
message
)
{
Long
userId
=
message
.
getUserId
();
// 根据推荐码获取推荐用户id
Long
userId
=
ReferralCodeUtils
.
getUserId
(
message
.
getReferralCode
());
log
.
info
(
"Received Recommend message,userID:{}"
,
userId
);
ScoreRuleDO
scoreRuleDO
=
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
.
RECOMMEND
);
if
(
scoreRuleDO
==
null
)
{
...
...
@@ -48,20 +45,11 @@ public class RecommendStrategy extends AbstractScoreRuleStrategy {
}
MemberUserDO
memberUserDO
=
memberUserService
.
getUser
(
userId
);
if
(
memberUserDO
==
null
)
{
log
.
info
(
"Recommend listener: The user does not exist,userID:{}"
,
userId
);
log
.
info
(
"Recommend listener: The
recommend
user does not exist,userID:{}"
,
userId
);
return
;
}
// 校验累计最高分
Integer
userScoreTotalCount
=
0
;
LambdaQueryWrapper
<
MemberUserScoreLogDO
>
scoreLogQueryWrapper
=
new
LambdaQueryWrapper
<>();
scoreLogQueryWrapper
.
eq
(
MemberUserScoreLogDO:
:
getMemberId
,
userId
)
.
eq
(
MemberUserScoreLogDO:
:
getRuleId
,
scoreRuleDO
.
getId
());
List
<
MemberUserScoreLogDO
>
memberUserScoreLogs
=
memberUserScoreLogService
.
selectList
(
scoreLogQueryWrapper
);
if
(
CollUtil
.
isNotEmpty
(
memberUserScoreLogs
))
{
for
(
MemberUserScoreLogDO
memberUserScoreLog
:
memberUserScoreLogs
)
{
userScoreTotalCount
+=
memberUserScoreLog
.
getScoreCount
();
}
}
Integer
userScoreTotalCount
=
getUserScoreTotalCount
(
scoreRuleDO
.
getId
(),
userId
);
if
(
userScoreTotalCount
>=
scoreRuleDO
.
getMaxScoreTotal
())
{
log
.
info
(
"Recommend listener: The user has reached the maximum score,userId:{},scoreRuleId:{}"
,
userId
,
scoreRuleDO
.
getId
());
return
;
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/RegisterStrategy.java
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
...
...
@@ -7,8 +8,10 @@ import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.mq.message.ScoreMessage
;
import
cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.service.user.MemberUserService
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
...
...
@@ -26,8 +29,8 @@ public class RegisterStrategy extends AbstractScoreRuleStrategy {
@Resource
private
MemberUserService
memberUserService
;
public
RegisterStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
public
RegisterStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
);
}
@Override
...
...
@@ -44,7 +47,14 @@ public class RegisterStrategy extends AbstractScoreRuleStrategy {
log
.
info
(
"Register listener: The user does not exist,userID:{}"
,
userId
);
return
;
}
//TODO:校验注册入口,目前表没加
// 校验注册平台
ScoreRuleRegisterExtraVO
scoreRuleRegisterExtraVO
=
JsonUtils
.
parseObject
(
scoreRuleDO
.
getExtra
(),
ScoreRuleRegisterExtraVO
.
class
);
if
(
scoreRuleRegisterExtraVO
!=
null
&&
!
"2,3"
.
equals
(
scoreRuleRegisterExtraVO
.
getRegisterPlatform
()))
{
if
(!
scoreRuleRegisterExtraVO
.
getRegisterPlatform
().
contains
(
String
.
valueOf
(
message
.
getRegisterPlatform
())))
{
log
.
info
(
"Register listener: The register platform does not match,userID:{}"
,
userId
);
return
;
}
}
try
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"userId"
,
userId
);
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/message/ScoreMessage.java
View file @
55dcf89a
...
...
@@ -21,7 +21,7 @@ public class ScoreMessage extends AbstractStreamMessage {
*/
private
Long
orderId
;
/**
* userID:注册
,推荐必填(加分的人)
* userID:注册
必填
*/
private
Long
userId
;
/**
...
...
@@ -29,21 +29,25 @@ public class ScoreMessage extends AbstractStreamMessage {
*/
private
Long
recommendUserId
;
/**
* 中文名:注册,推荐必填,推荐时填推荐人的信息
* 推荐码:推荐必填
*/
private
String
referralCode
;
/**
* 中文名:注册必填
*/
private
String
userNameZh
;
/**
* 英文名:注册
,推荐必填,推荐时填推荐人的信息
* 英文名:注册
必填
*/
private
String
userNameEn
;
/**
*
userID:注册,推荐必填,推荐时填推荐人的信息
*
电话:注册必填
*/
private
String
phone
;
/**
*
推荐码:推荐
必填
*
注册平台:注册
必填
*/
private
String
recommendCode
;
private
Integer
registerPlatform
;
@Override
public
String
getStreamKey
()
{
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/producer/score/ScoreProducer.java
View file @
55dcf89a
...
...
@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author zhangfeng
*/
...
...
@@ -16,6 +17,7 @@ import javax.annotation.Resource;
public
class
ScoreProducer
implements
ScoreProducerApi
{
@Resource
private
RedisMQTemplate
redisMQTemplate
;
@Override
public
void
sendOderMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
orderId
)
{
ScoreMessage
message
=
ScoreMessage
.
builder
()
...
...
@@ -26,12 +28,25 @@ public class ScoreProducer implements ScoreProducerApi {
}
@Override
public
void
sendRecommendMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
)
{
public
void
sendRecommendMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
,
String
referralCode
)
{
ScoreMessage
message
=
ScoreMessage
.
builder
()
.
scoreRuleType
(
scoreRuleType
)
.
recommendUserId
(
userId
)
.
referralCode
(
referralCode
)
.
build
();
redisMQTemplate
.
send
(
message
);
}
@Override
public
void
sendRegisterMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
)
{
public
void
sendRegisterMessage
(
ScoreRuleTypeEnum
scoreRuleType
,
Long
userId
,
String
userNameZh
,
String
userNameEn
,
String
phone
,
Integer
registerPlatform
)
{
ScoreMessage
message
=
ScoreMessage
.
builder
()
.
scoreRuleType
(
scoreRuleType
)
.
userId
(
userId
)
.
userNameZh
(
userNameZh
)
.
userNameEn
(
userNameEn
)
.
phone
(
phone
)
.
registerPlatform
(
registerPlatform
)
.
build
();
redisMQTemplate
.
send
(
message
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java
View file @
55dcf89a
...
...
@@ -13,10 +13,12 @@ import cn.iocoder.yudao.framework.security.core.authentication.MultiUsernamePass
import
cn.iocoder.yudao.module.ecw.api.internalMessage.ClientInternalMessageApi
;
import
cn.iocoder.yudao.module.ecw.api.internalMessage.dto.InternalMessageCreateDto
;
import
cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi
;
import
cn.iocoder.yudao.module.member.api.ScoreProducerApi
;
import
cn.iocoder.yudao.module.member.controller.app.auth.vo.*
;
import
cn.iocoder.yudao.module.member.convert.auth.AuthConvert
;
import
cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO
;
import
cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.UserOperationLogTypeEnum
;
import
cn.iocoder.yudao.module.member.service.user.MemberUserService
;
import
cn.iocoder.yudao.module.member.service.userOperationLog.UserOperationLogService
;
...
...
@@ -94,6 +96,8 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Resource
private
ParamValidatorApi
paramValidatorApi
;
@Resource
private
ScoreProducerApi
scoreProducerApi
;
@Override
public
UserDetails
loadUserByUsername
(
String
mobile
)
throws
UsernameNotFoundException
{
...
...
@@ -111,13 +115,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
// 校验验证码
smsCodeApi
.
useSmsCode
(
AuthConvert
.
INSTANCE
.
convert
(
reqVO
,
SmsSceneEnum
.
MEMBER_REG
.
getScene
(),
userIp
));
MemberUserDO
userByMobile
=
userService
.
checkPhoneUnique
(
reqVO
.
getAreaCode
(),
reqVO
.
getMobile
());
MemberUserDO
userByMobile
=
userService
.
checkPhoneUnique
(
reqVO
.
getAreaCode
(),
reqVO
.
getMobile
());
if
(
userByMobile
!=
null
)
{
throw
exception
(
MEMBER_USER_MOBILE_EXIST
);
}
// 获得获得注册用户
MemberUserDO
user
=
userService
.
createUser
(
reqVO
.
getMobile
(),
userIp
,
reqVO
.
getPassword
(),
reqVO
.
getAreaCode
(),
reqVO
.
getEnglishName
(),
reqVO
.
getReferralCode
());
MemberUserDO
user
=
userService
.
createUser
(
reqVO
.
getMobile
(),
userIp
,
reqVO
.
getPassword
(),
reqVO
.
getAreaCode
(),
reqVO
.
getEnglishName
(),
reqVO
.
getReferralCode
(),
reqVO
.
getRegisterPlatform
());
Assert
.
notNull
(
user
,
"创建用户失败,结果为空"
);
//记录日志
...
...
@@ -140,8 +144,8 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Override
public
boolean
checkPhoneUnique
(
String
areaCode
,
String
mobile
)
{
MemberUserDO
memberUserDO
=
userService
.
checkPhoneUnique
(
areaCode
,
mobile
);
return
memberUserDO
!=
null
;
MemberUserDO
memberUserDO
=
userService
.
checkPhoneUnique
(
areaCode
,
mobile
);
return
memberUserDO
!=
null
;
}
@Override
...
...
@@ -160,7 +164,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
smsCodeApi
.
useSmsCode
(
AuthConvert
.
INSTANCE
.
convert
(
reqVO
,
SmsSceneEnum
.
MEMBER_LOGIN
.
getScene
(),
userIp
));
// 获得获得注册用户
MemberUserDO
user
=
userService
.
createUserIfAbsent
(
reqVO
.
getMobile
(),
reqVO
.
getAreaCode
(),
userIp
);
MemberUserDO
user
=
userService
.
createUserIfAbsent
(
reqVO
.
getMobile
(),
reqVO
.
getAreaCode
(),
userIp
,
reqVO
.
getLoginPlatform
()
);
Assert
.
notNull
(
user
,
"获取用户失败,结果为空"
);
// 执行登陆
...
...
@@ -273,6 +277,9 @@ public class MemberAuthServiceImpl implements MemberAuthService {
loginLogApi
.
createLoginLog
(
reqDTO
);
// 更新最后登录时间
if
(
user
!=
null
&&
Objects
.
equals
(
LoginResultEnum
.
SUCCESS
.
getResult
(),
loginResult
.
getResult
()))
{
// 注册,推荐积分规则触发判断
scoreRuleCheck
(
user
);
userService
.
updateUserLogin
(
user
.
getId
(),
getClientIP
());
}
...
...
@@ -452,14 +459,14 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Override
public
void
sendEmailCode
(
Long
loginUserId
,
AppEmailReqVO
reqVO
)
{
MemberUserDO
userVo
=
userService
.
getUserByEmail
(
reqVO
.
getEmail
());
if
(
userVo
!=
null
)
{
if
(
userVo
!=
null
)
{
throw
exception
(
USER_EMAIL_ALREADY_EXISTS
);
}
MemberUserDO
user
=
userService
.
getUser
(
loginUserId
);
Map
<
String
,
String
>
tempalteParam
=
new
HashMap
<>();
tempalteParam
.
put
(
"name"
,
user
.
getEnglishName
());
Map
<
String
,
String
>
tempalteParam
=
new
HashMap
<>();
tempalteParam
.
put
(
"name"
,
user
.
getEnglishName
());
//todo 生成验证码逻辑
tempalteParam
.
put
(
"code"
,
"9999"
);
tempalteParam
.
put
(
"code"
,
"9999"
);
tempalteParam
.
put
(
"date"
,
DateUtils
.
getDate
());
MailTemplateSendReqVO
reqVO1
=
new
MailTemplateSendReqVO
();
reqVO1
.
setTemplateCode
(
"bindEmail"
);
...
...
@@ -489,11 +496,11 @@ public class MemberAuthServiceImpl implements MemberAuthService {
if
(
user
==
null
)
{
throw
exception
(
USER_NOT_EXISTS
);
}
if
(
StringUtils
.
isBlank
(
user
.
getPassword
()))
{
if
(
StringUtils
.
isBlank
(
user
.
getPassword
()))
{
return
user
;
}
// 参数:未加密密码,编码后的密码
if
(!
passwordEncoder
.
matches
(
oldPassword
,
user
.
getPassword
()))
{
if
(!
passwordEncoder
.
matches
(
oldPassword
,
user
.
getPassword
()))
{
throw
exception
(
USER_PASSWORD_FAILED
);
}
return
user
;
...
...
@@ -512,11 +519,11 @@ public class MemberAuthServiceImpl implements MemberAuthService {
if
(
user
==
null
)
{
throw
exception
(
USER_NOT_EXISTS
);
}
if
(
StringUtils
.
isBlank
(
user
.
getControlPassword
()))
{
if
(
StringUtils
.
isBlank
(
user
.
getControlPassword
()))
{
return
user
;
}
// 参数:未加密密码,编码后的密码
if
(!
passwordEncoder
.
matches
(
oldPassword
,
user
.
getControlPassword
()))
{
if
(!
passwordEncoder
.
matches
(
oldPassword
,
user
.
getControlPassword
()))
{
throw
exception
(
USER_PASSWORD_FAILED
);
}
return
user
;
...
...
@@ -543,4 +550,16 @@ public class MemberAuthServiceImpl implements MemberAuthService {
loginLogApi
.
createLoginLog
(
reqDTO
);
}
private
void
scoreRuleCheck
(
MemberUserDO
user
)
{
// 首次登陆发获取注册积分
if
(
user
.
getLoginDate
()
==
null
)
{
scoreProducerApi
.
sendRegisterMessage
(
ScoreRuleTypeEnum
.
REGISTER
,
user
.
getId
(),
user
.
getNickname
(),
user
.
getEnglishName
(),
user
.
getMobile
(),
user
.
getRegisterPlatform
());
}
// 首次登陆且有推荐码获取推荐积分
if
(
user
.
getLoginDate
()
==
null
&&
user
.
getReferralCode
()
!=
null
)
{
scoreProducerApi
.
sendRecommendMessage
(
ScoreRuleTypeEnum
.
RECOMMEND
,
user
.
getId
(),
user
.
getReferralCode
());
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
View file @
55dcf89a
...
...
@@ -29,9 +29,10 @@ public interface MemberUserService {
* @return 用户对象
*/
MemberUserDO
getUserByMobile
(
String
mobile
);
MemberUserDO
checkPhoneUnique
(
String
areaCode
,
String
mobile
);
MemberUserDO
getUserByMobile
(
String
areaCode
,
String
mobile
);
MemberUserDO
checkPhoneUnique
(
String
areaCode
,
String
mobile
);
MemberUserDO
getUserByMobile
(
String
areaCode
,
String
mobile
);
MemberUserDO
getUserByEmail
(
String
email
);
...
...
@@ -43,7 +44,7 @@ public interface MemberUserService {
* @param registerIp 注册 IP
* @return 用户对象
*/
MemberUserDO
createUserIfAbsent
(
String
mobile
,
String
areaCode
,
String
registerIp
);
MemberUserDO
createUserIfAbsent
(
String
mobile
,
String
areaCode
,
String
registerIp
,
Integer
platform
);
/****
* 基于手机号创建用户
...
...
@@ -53,7 +54,7 @@ public interface MemberUserService {
* @param referralCode
* @return
*/
MemberUserDO
createUser
(
String
mobile
,
String
registerIp
,
String
password
,
String
areaCode
,
String
englishName
,
String
referralCode
);
MemberUserDO
createUser
(
String
mobile
,
String
registerIp
,
String
password
,
String
areaCode
,
String
englishName
,
String
referralCode
,
Integer
registerPlatform
);
/**
* 更新用户的最后登陆信息
...
...
@@ -75,7 +76,7 @@ public interface MemberUserService {
* 通过用户 ID 查询用户
*
* @param id 用户ID
* @return 用户对象信息,包括公司信息
* @return 用户对象信息,
包括公司信息
*/
MemberUserDO
info
(
Long
id
);
...
...
@@ -182,18 +183,18 @@ public interface MemberUserService {
* 会员发出的订单统计
* TODO 分布式系统可能需要在分库分表时将此方法实现切换到订单模块,现在未避免循环依赖故将实现方法放在此处,也可用使用监听去实现
*
* @param mobile 用户手机号
* @param userId 用户ID
* @param mobile
用户手机号
* @param userId
用户ID
* @param customerContactsIds 客户联系人ids
* @return 会员发出的订单数量统计
*/
Integer
appIssuedOrderCount
(
String
mobile
,
Long
userId
,
Collection
<
Long
>
customerContactsIds
);
Integer
appIssuedOrderCount
(
String
mobile
,
Long
userId
,
Collection
<
Long
>
customerContactsIds
);
/**
* 会员收到的订单统计
* TODO 分布式系统可能需要在分库分表时将此方法实现切换到订单模块,现在未避免循环依赖故将实现方法放在此处,也可用使用监听去实现
*
* @param phone 会员电话
* @param phone
会员电话
* @param customerContactsIds 客户联系人ids
* @return 会员收到的订单数量统计
*/
...
...
@@ -203,8 +204,8 @@ public interface MemberUserService {
* 会员收到的订单统计
* TODO 分布式系统可能需要在分库分表时将此方法实现切换到订单模块,现在未避免循环依赖故将实现方法放在此处,也可用使用监听去实现
*
* @param userId 用户ID
* @param phone 会员电话
* @param userId
用户ID
* @param phone
会员电话
* @param customerContactsIds 客户联系人ids
* @return 会员收到的订单数量统计
*/
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
View file @
55dcf89a
...
...
@@ -153,7 +153,7 @@ public class MemberUserServiceImpl implements MemberUserService {
}
@Override
public
MemberUserDO
createUserIfAbsent
(
String
mobile
,
String
areaCode
,
String
registerIp
)
{
public
MemberUserDO
createUserIfAbsent
(
String
mobile
,
String
areaCode
,
String
registerIp
,
Integer
platform
)
{
try
{
String
mobileCode
=
areaCode
+
StrUtil
.
COLON
+
mobile
;
...
...
@@ -172,7 +172,7 @@ public class MemberUserServiceImpl implements MemberUserService {
}
String
englishName
=
maskMobileNumber
(
mobile
);
// 用户不存在,则进行创建
user
=
this
.
createUser
(
mobile
,
registerIp
,
null
,
areaCode
,
englishName
,
null
);
user
=
this
.
createUser
(
mobile
,
registerIp
,
null
,
areaCode
,
englishName
,
null
,
platform
);
//记录日志
UserOperationLogCreateReqVO
userOperationLogCreateReqVO
=
new
UserOperationLogCreateReqVO
();
...
...
@@ -202,7 +202,7 @@ public class MemberUserServiceImpl implements MemberUserService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
MemberUserDO
createUser
(
String
mobile
,
String
registerIp
,
String
password
,
String
areacode
,
String
englishName
,
String
referralCode
)
{
public
MemberUserDO
createUser
(
String
mobile
,
String
registerIp
,
String
password
,
String
areacode
,
String
englishName
,
String
referralCode
,
Integer
registerPlatform
)
{
// 生成密码
/* if (StrUtil.isBlank(password)) {
password = IdUtil.fastSimpleUUID();
...
...
@@ -223,6 +223,7 @@ public class MemberUserServiceImpl implements MemberUserService {
user
.
setNickname
(
englishName
);
user
.
setCode
(
getNextMemberCode
());
user
.
setReferralCode
(
referralCode
);
user
.
setRegisterPlatform
(
registerPlatform
);
memberUserMapper
.
insert
(
user
);
//站内信
InternalMessageCreateDto
dto
=
InternalMessageCreateDto
.
builder
().
toIdList
(
Arrays
.
asList
(
user
.
getId
()))
...
...
@@ -563,7 +564,7 @@ public class MemberUserServiceImpl implements MemberUserService {
long
limit
=
500
;
memberUserMapper
.
clearMemberCode
();
redisHelper
.
delete
(
"memberCode:max:number"
);
while
(
true
)
{
while
(
true
)
{
List
<
MemberUserDO
>
result
=
this
.
getByCursor
(
startUserId
,
limit
);
if
(
CollectionUtils
.
isEmpty
(
result
))
{
break
;
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/util/ReferralCodeUtils.java
0 → 100644
View file @
55dcf89a
package
cn
.
iocoder
.
yudao
.
module
.
member
.
util
;
public
class
ReferralCodeUtils
{
/**
* 根据用户id生成推荐码
*/
public
static
String
generateReferralCode
(
Long
userId
)
{
return
userId
.
toString
();
}
/**
* 根据推荐码获取用户id
*/
public
static
Long
getUserId
(
String
referralCode
)
{
return
Long
.
parseLong
(
referralCode
);
}
}
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