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
f2dce7cb
Commit
f2dce7cb
authored
Aug 02, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refs/heads/feature_member_score_zhangfeng' into feature_member_score
parents
e7c3e928
d7e8488e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
288 additions
and
18 deletions
+288
-18
AbstractScoreRuleStrategy.java
...ber/mq/consumer/score/core/AbstractScoreRuleStrategy.java
+89
-0
OderVStrategy.java
...o/module/member/mq/consumer/score/core/OderVStrategy.java
+15
-10
RecommendStrategy.java
...dule/member/mq/consumer/score/core/RecommendStrategy.java
+86
-3
RegisterStrategy.java
...odule/member/mq/consumer/score/core/RegisterStrategy.java
+64
-3
ScoreRuleStrategy.java
...dule/member/mq/consumer/score/core/ScoreRuleStrategy.java
+2
-1
ScoreRuleStrategyFactory.java
...mber/mq/consumer/score/core/ScoreRuleStrategyFactory.java
+1
-1
ScoreMessage.java
.../iocoder/yudao/module/member/mq/message/ScoreMessage.java
+31
-0
No files found.
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/AbstractScoreRuleStrategy.java
0 → 100644
View file @
f2dce7cb
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
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.scoreRule.ScoreRuleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Date
;
/**
* 半成品
* @author zhangfeng
*/
public
abstract
class
AbstractScoreRuleStrategy
implements
ScoreRuleStrategy
{
private
static
ScoreRuleDO
orderVShipScoreRule
=
null
;
private
static
ScoreRuleDO
orderVFlyScoreRule
=
null
;
private
static
ScoreRuleDO
registerScoreRule
=
null
;
private
static
ScoreRuleDO
recommendScoreRule
=
null
;
protected
ScoreRuleService
scoreRuleService
;
@Autowired
public
AbstractScoreRuleStrategy
(
ScoreRuleService
scoreRuleService
)
{
this
.
scoreRuleService
=
scoreRuleService
;
}
public
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
)
{
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
selectOne
(
new
LambdaQuery
<
ScoreRuleDO
>()
.
eq
(
ScoreRuleDO:
:
getType
,
scoreRuleType
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()));
if
(
scoreRuleDO
!=
null
)
{
// 校验一下活动开始结束时间
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
return
null
;
}
else
{
recommendScoreRule
=
scoreRuleDO
;
return
recommendScoreRule
;
}
}
return
null
;
}
public
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
,
TransportTypeEnum
transportType
)
{
ScoreRuleDO
scoreRuleDO
=
null
;
switch
(
scoreRuleType
)
{
case
ORDER_V:
scoreRuleDO
=
scoreRuleService
.
getEnabledOrderVScoreRuleByTransportType
(
transportType
.
getValue
());
if
(
scoreRuleDO
!=
null
)
{
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
return
null
;
}
if
(
transportType
==
TransportTypeEnum
.
OCEAN_LCL
)
{
orderVShipScoreRule
=
scoreRuleDO
;
return
orderVShipScoreRule
;
}
if
(
transportType
==
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
)
{
orderVFlyScoreRule
=
scoreRuleDO
;
return
orderVFlyScoreRule
;
}
}
break
;
case
RECOMMEND:
case
REGISTER:
return
getEnableScoreRuleByType
(
scoreRuleType
);
}
return
null
;
}
@Override
public
void
refreshScoreRule
(
ScoreRuleTypeEnum
scoreRuleType
)
{
switch
(
scoreRuleType
)
{
case
ORDER_V:
orderVShipScoreRule
=
null
;
orderVFlyScoreRule
=
null
;
break
;
case
RECOMMEND:
recommendScoreRule
=
null
;
break
;
case
REGISTER:
registerScoreRule
=
null
;
break
;
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/OderVStrategy.java
View file @
f2dce7cb
...
@@ -37,27 +37,29 @@ import java.util.Objects;
...
@@ -37,27 +37,29 @@ import java.util.Objects;
*/
*/
@Service
@Service
@Slf4j
@Slf4j
public
class
OderVStrategy
implements
ScoreRuleStrategy
{
public
class
OderVStrategy
extends
Abstract
ScoreRuleStrategy
{
@Resource
@Resource
private
OrderApi
orderApi
;
private
OrderApi
orderApi
;
@Resource
@Resource
private
ScoreRuleService
scoreRuleService
;
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
private
MemberUserScoreLogService
memberUserScoreLogService
;
@Resource
@Resource
private
CustomerContactsService
customerContactsService
;
private
CustomerContactsService
customerContactsService
;
public
OderVStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
}
@Override
@Override
public
void
addScore
(
ScoreMessage
message
)
{
public
void
addScore
(
ScoreMessage
message
)
{
log
.
info
(
"
订单V值增加积分"
);
log
.
info
(
"
Received order V message,orderID:{}"
,
message
.
getOrderId
()
);
Long
orderId
=
message
.
getOrderId
();
Long
orderId
=
message
.
getOrderId
();
OrderRespDTO
order
;
OrderRespDTO
order
;
try
{
try
{
order
=
orderApi
.
getOrder
(
orderId
,
""
);
order
=
orderApi
.
getOrder
(
orderId
,
""
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Order in shipping listener: Get order error,orderId:{}
,orderNo:{}"
,
orderId
,
""
);
log
.
error
(
"Order in shipping listener: Get order error,orderId:{}
"
,
orderId
,
e
);
return
;
return
;
}
}
if
(
Objects
.
isNull
(
order
))
{
if
(
Objects
.
isNull
(
order
))
{
...
@@ -72,12 +74,12 @@ public class OderVStrategy implements ScoreRuleStrategy {
...
@@ -72,12 +74,12 @@ public class OderVStrategy implements ScoreRuleStrategy {
Integer
transportId
=
order
.
getTransportId
();
Integer
transportId
=
order
.
getTransportId
();
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnabledOrderVScoreRuleByTransportType
(
transportId
);
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnabledOrderVScoreRuleByTransportType
(
transportId
);
if
(
Objects
.
isNull
(
scoreRuleDO
))
{
if
(
Objects
.
isNull
(
scoreRuleDO
))
{
log
.
info
(
"Order in shipping listener: No score rule match
"
);
log
.
info
(
"Order in shipping listener: No score rule match
,orderID:{}"
,
orderId
);
return
;
return
;
}
}
// 是否过期,或者活动还没开始
// 是否过期,或者活动还没开始
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
log
.
info
(
"Order in shipping listener: The score rule has expired
"
);
log
.
info
(
"Order in shipping listener: The score rule has expired
,scoreRuleID:{}"
,
scoreRuleDO
.
getId
()
);
return
;
return
;
}
}
// 目的地信息
// 目的地信息
...
@@ -117,7 +119,7 @@ public class OderVStrategy implements ScoreRuleStrategy {
...
@@ -117,7 +119,7 @@ public class OderVStrategy implements ScoreRuleStrategy {
// 订单入口
// 订单入口
String
orderEntryString
=
extraInfo
.
getOrderEntry
();
String
orderEntryString
=
extraInfo
.
getOrderEntry
();
if
(
StringUtils
.
isBlank
(
orderEntryString
))
{
if
(
StringUtils
.
isBlank
(
orderEntryString
))
{
log
.
info
(
"Order in shipping listener: orderEntry is null
"
);
log
.
info
(
"Order in shipping listener: orderEntry is null
,scoreRuleID:{}"
,
scoreRuleDO
.
getId
()
);
return
;
return
;
}
}
String
[]
orderEntry
=
orderEntryString
.
split
(
","
);
String
[]
orderEntry
=
orderEntryString
.
split
(
","
);
...
@@ -149,7 +151,7 @@ public class OderVStrategy implements ScoreRuleStrategy {
...
@@ -149,7 +151,7 @@ public class OderVStrategy implements ScoreRuleStrategy {
// 是否首单,首单只加一次
// 是否首单,首单只加一次
if
(
extraInfo
.
getFirstOrder
()
==
YesOrNoTypeEnum
.
YES
.
ordinal
())
{
if
(
extraInfo
.
getFirstOrder
()
==
YesOrNoTypeEnum
.
YES
.
ordinal
())
{
if
(!
orderApi
.
isFirstOrder
(
userId
))
{
if
(!
orderApi
.
isFirstOrder
(
userId
))
{
log
.
info
(
"Order in shipping listener: Not first order
"
);
log
.
info
(
"Order in shipping listener: Not first order
,userId:{}"
,
userId
);
return
;
return
;
}
}
}
}
...
@@ -182,16 +184,19 @@ public class OderVStrategy implements ScoreRuleStrategy {
...
@@ -182,16 +184,19 @@ public class OderVStrategy implements ScoreRuleStrategy {
.
sourceType
(
ScoreSourceTypeEnum
.
ORDER_V
)
.
sourceType
(
ScoreSourceTypeEnum
.
ORDER_V
)
.
ruleId
(
scoreRuleDO
.
getId
())
.
ruleId
(
scoreRuleDO
.
getId
())
.
expireDays
(
scoreRuleDO
.
getScorePeriod
())
.
expireDays
(
scoreRuleDO
.
getScorePeriod
())
.
releationId
(
String
.
valueOf
(
orderId
))
.
uniqueId
(
String
.
valueOf
(
orderId
))
.
extParam
(
map
)
.
extParam
(
map
)
.
build
()
.
build
()
);
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Order in shipping listener: operateScore error"
,
e
);
log
.
error
(
"Order in shipping listener: operateScore error"
,
e
);
}
}
log
.
info
(
"Order V rule add score success,ruleID:{},orderID:{},userID:{}"
,
scoreRuleDO
.
getId
(),
message
.
getOrderId
(),
userId
);
}
}
@Override
@Override
public
ScoreRuleTypeEnum
getScoreRuleType
()
{
public
ScoreRuleTypeEnum
getS
trategyS
coreRuleType
()
{
return
ScoreRuleTypeEnum
.
ORDER_V
;
return
ScoreRuleTypeEnum
.
ORDER_V
;
}
}
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/RecommendStrategy.java
View file @
f2dce7cb
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
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.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.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
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.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
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
/**
/**
* @author zhangfeng
* @author zhangfeng
*/
*/
@Service
@Service
@Slf4j
@Slf4j
public
class
RecommendStrategy
implements
ScoreRuleStrategy
{
public
class
RecommendStrategy
extends
AbstractScoreRuleStrategy
{
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
private
MemberUserService
memberUserService
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
public
RecommendStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
}
@Override
@Override
public
void
addScore
(
ScoreMessage
message
)
{
public
void
addScore
(
ScoreMessage
message
)
{
log
.
info
(
"推荐增加积分"
);
Long
userId
=
message
.
getUserId
();
log
.
info
(
"Received Recommend message,userID:{}"
,
userId
);
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
selectOne
(
new
LambdaQuery
<
ScoreRuleDO
>()
.
eq
(
ScoreRuleDO:
:
getType
,
ScoreRuleTypeEnum
.
RECOMMEND
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()));
if
(
scoreRuleDO
==
null
)
{
log
.
info
(
"Recommend rule is not exist,userID:{}"
,
userId
);
return
;
}
// 是否过期,或者活动还没开始
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
log
.
info
(
"Recommend listener: The score rule has expired,scoreRuleID:{}"
,
scoreRuleDO
.
getId
());
return
;
}
MemberUserDO
memberUserDO
=
memberUserService
.
getUser
(
userId
);
if
(
memberUserDO
==
null
)
{
log
.
info
(
"Recommend listener: The 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
();
}
}
if
(
userScoreTotalCount
>=
scoreRuleDO
.
getMaxScoreTotal
())
{
log
.
info
(
"Recommend listener: The user has reached the maximum score,userId:{},scoreRuleId:{}"
,
userId
,
scoreRuleDO
.
getId
());
return
;
}
try
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"userId"
,
userId
);
map
.
put
(
"userNameZh"
,
message
.
getUserNameZh
());
map
.
put
(
"userNameEn"
,
message
.
getUserNameEn
());
String
desensitizedPhoneNumber
=
message
.
getPhone
().
replaceAll
(
"(\\d{3})\\d{4}(\\d{4})"
,
"$1****$2"
);
map
.
put
(
"phone"
,
desensitizedPhoneNumber
);
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
userId
)
.
scoreCount
(
scoreRuleDO
.
getGetScoreOnce
())
.
sourceType
(
ScoreSourceTypeEnum
.
RECOMMEND
)
.
ruleId
(
scoreRuleDO
.
getId
())
.
uniqueId
(
userId
+
"_"
+
message
.
getRecommendUserId
())
.
expireDays
(
scoreRuleDO
.
getScorePeriod
())
.
build
());
}
catch
(
Exception
e
)
{
log
.
error
(
"Recommend listener: operateScore error"
,
e
);
}
log
.
info
(
"Recommend rule add score success,ruleID:{},userID:{}"
,
scoreRuleDO
.
getId
(),
userId
);
}
}
@Override
@Override
public
ScoreRuleTypeEnum
getScoreRuleType
()
{
public
ScoreRuleTypeEnum
getS
trategyS
coreRuleType
()
{
return
ScoreRuleTypeEnum
.
RECOMMEND
;
return
ScoreRuleTypeEnum
.
RECOMMEND
;
}
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/RegisterStrategy.java
View file @
f2dce7cb
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
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
;
import
cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
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.mq.message.ScoreMessage
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.service.user.MemberUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
/**
/**
* @author zhangfeng
* @author zhangfeng
*/
*/
@Service
@Service
@Slf4j
@Slf4j
public
class
RegisterStrategy
implements
ScoreRuleStrategy
{
public
class
RegisterStrategy
extends
AbstractScoreRuleStrategy
{
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
private
MemberUserService
memberUserService
;
public
RegisterStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
}
@Override
@Override
public
void
addScore
(
ScoreMessage
message
)
{
public
void
addScore
(
ScoreMessage
message
)
{
log
.
info
(
"注册增加积分"
);
Long
userId
=
message
.
getUserId
();
log
.
info
(
"Received register message,userID:{}"
,
userId
);
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
selectOne
(
new
LambdaQuery
<
ScoreRuleDO
>()
.
eq
(
ScoreRuleDO:
:
getType
,
ScoreRuleTypeEnum
.
REGISTER
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()));
if
(
scoreRuleDO
==
null
)
{
log
.
info
(
"Register rule is not exist,userID:{}"
,
userId
);
return
;
}
// 是否过期,或者活动还没开始
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
log
.
info
(
"Register listener: The score rule has expired,scoreRuleID:{}"
,
scoreRuleDO
.
getId
());
return
;
}
MemberUserDO
memberUserDO
=
memberUserService
.
getUser
(
userId
);
if
(
memberUserDO
==
null
)
{
log
.
info
(
"Register listener: The user does not exist,userID:{}"
,
userId
);
return
;
}
//TODO:校验注册入口,目前表没加
try
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"userId"
,
userId
);
map
.
put
(
"userNameZh"
,
message
.
getUserNameZh
());
map
.
put
(
"userNameEn"
,
message
.
getUserNameEn
());
String
desensitizedPhoneNumber
=
message
.
getPhone
().
replaceAll
(
"(\\d{3})\\d{4}(\\d{4})"
,
"$1****$2"
);
map
.
put
(
"phone"
,
desensitizedPhoneNumber
);
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
userId
)
.
scoreCount
(
scoreRuleDO
.
getGetScoreOnce
())
.
sourceType
(
ScoreSourceTypeEnum
.
REGISTER
)
.
ruleId
(
scoreRuleDO
.
getId
())
.
uniqueId
(
String
.
valueOf
(
userId
))
.
expireDays
(
scoreRuleDO
.
getScorePeriod
())
.
build
());
}
catch
(
Exception
e
)
{
log
.
error
(
"Register listener: operateScore error"
,
e
);
}
log
.
info
(
"Register rule add score success,ruleID:{},userID:{}"
,
scoreRuleDO
.
getId
(),
userId
);
}
}
@Override
@Override
public
ScoreRuleTypeEnum
getScoreRuleType
()
{
public
ScoreRuleTypeEnum
getS
trategyS
coreRuleType
()
{
return
ScoreRuleTypeEnum
.
REGISTER
;
return
ScoreRuleTypeEnum
.
REGISTER
;
}
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/ScoreRuleStrategy.java
View file @
f2dce7cb
...
@@ -7,5 +7,6 @@ import cn.iocoder.yudao.module.member.mq.message.ScoreMessage;
...
@@ -7,5 +7,6 @@ import cn.iocoder.yudao.module.member.mq.message.ScoreMessage;
*/
*/
public
interface
ScoreRuleStrategy
{
public
interface
ScoreRuleStrategy
{
void
addScore
(
ScoreMessage
message
);
void
addScore
(
ScoreMessage
message
);
ScoreRuleTypeEnum
getScoreRuleType
();
ScoreRuleTypeEnum
getStrategyScoreRuleType
();
void
refreshScoreRule
(
ScoreRuleTypeEnum
scoreRuleType
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/ScoreRuleStrategyFactory.java
View file @
f2dce7cb
...
@@ -17,7 +17,7 @@ public class ScoreRuleStrategyFactory {
...
@@ -17,7 +17,7 @@ public class ScoreRuleStrategyFactory {
@Autowired
@Autowired
public
void
setStrategyFactory
(
List
<
ScoreRuleStrategy
>
strategyList
)
{
public
void
setStrategyFactory
(
List
<
ScoreRuleStrategy
>
strategyList
)
{
for
(
ScoreRuleStrategy
strategy
:
strategyList
)
{
for
(
ScoreRuleStrategy
strategy
:
strategyList
)
{
strategies
.
put
(
strategy
.
getScoreRuleType
(),
strategy
);
strategies
.
put
(
strategy
.
getS
trategyS
coreRuleType
(),
strategy
);
}
}
}
}
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/message/ScoreMessage.java
View file @
f2dce7cb
...
@@ -12,8 +12,39 @@ import lombok.*;
...
@@ -12,8 +12,39 @@ import lombok.*;
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
public
class
ScoreMessage
extends
AbstractStreamMessage
{
public
class
ScoreMessage
extends
AbstractStreamMessage
{
/**
* 积分规则类型所有消息必填
*/
private
ScoreRuleTypeEnum
scoreRuleType
;
private
ScoreRuleTypeEnum
scoreRuleType
;
/**
* 订单ID:订单V值消息必填
*/
private
Long
orderId
;
private
Long
orderId
;
/**
* userID:注册,推荐必填(加分的人)
*/
private
Long
userId
;
/**
* 被推荐的会员ID:推荐必填
*/
private
Long
recommendUserId
;
/**
* 中文名:注册,推荐必填,推荐时填推荐人的信息
*/
private
String
userNameZh
;
/**
* 英文名:注册,推荐必填,推荐时填推荐人的信息
*/
private
String
userNameEn
;
/**
* userID:注册,推荐必填,推荐时填推荐人的信息
*/
private
String
phone
;
/**
* 推荐码:推荐必填
*/
private
String
recommendCode
;
@Override
@Override
public
String
getStreamKey
()
{
public
String
getStreamKey
()
{
return
"member.score.add"
;
return
"member.score.add"
;
...
...
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