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
adba3fe8
Commit
adba3fe8
authored
Aug 06, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refs/heads/feature_member_score' into dev
parents
36e2eb2c
7ff95b93
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
827 additions
and
195 deletions
+827
-195
WarehouseMapper.java
...odule/depository/dal/mysql/warehouse/WarehouseMapper.java
+3
-1
WarehouseTreeRegionVO.java
...module/depository/vo/warehouse/WarehouseTreeRegionVO.java
+2
-0
ScoreProducerApi.java
.../cn/iocoder/yudao/module/member/api/ScoreProducerApi.java
+5
-2
ScoreSourceTypeEnum.java
...ocoder/yudao/module/member/enums/ScoreSourceTypeEnum.java
+4
-0
TransportTypeEnum.java
.../iocoder/yudao/module/member/enums/TransportTypeEnum.java
+5
-0
pom.xml
yudao-module-member/yudao-module-member-impl/pom.xml
+5
-0
ScoreRuleController.java
...ember/controller/admin/scoreRule/ScoreRuleController.java
+2
-6
AppAuthRegReqVO.java
...module/member/controller/app/auth/vo/AppAuthRegReqVO.java
+2
-0
AppAuthSmsLoginReqVO.java
...e/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java
+3
-0
AppMemberUserScoreController.java
...ontroller/app/userScore/AppMemberUserScoreController.java
+53
-0
AppMemberUserIdQueryVO.java
...r/controller/app/userScore/vo/AppMemberUserIdQueryVO.java
+18
-0
AppMemberUserScoreInfoRespVO.java
...roller/app/userScore/vo/AppMemberUserScoreInfoRespVO.java
+26
-0
AppMemberUserScoreLogRespVO.java
...troller/app/userScore/vo/AppMemberUserScoreLogRespVO.java
+44
-0
MemberUserDO.java
...yudao/module/member/dal/dataobject/user/MemberUserDO.java
+7
-0
RedisKeyConstant.java
...coder/yudao/module/member/dal/redis/RedisKeyConstant.java
+8
-0
ScoreRuleRedisDao.java
.../module/member/dal/redis/scoreRule/ScoreRuleRedisDao.java
+78
-0
AbstractScoreRuleStrategy.java
...ber/mq/consumer/score/core/AbstractScoreRuleStrategy.java
+27
-68
OrderVStrategy.java
.../module/member/mq/consumer/score/core/OrderVStrategy.java
+6
-26
RecommendStrategy.java
...dule/member/mq/consumer/score/core/RecommendStrategy.java
+8
-31
RegisterStrategy.java
...odule/member/mq/consumer/score/core/RegisterStrategy.java
+14
-14
ScoreRuleStrategy.java
...dule/member/mq/consumer/score/core/ScoreRuleStrategy.java
+0
-1
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
MemberUserScoreService.java
...o/module/member/service/score/MemberUserScoreService.java
+9
-0
MemberUserScoreServiceImpl.java
...dule/member/service/score/MemberUserScoreServiceImpl.java
+26
-0
MemberUserScoreLogService.java
...le/member/service/scoreLog/MemberUserScoreLogService.java
+6
-0
MemberUserScoreLogServiceImpl.java
...ember/service/scoreLog/MemberUserScoreLogServiceImpl.java
+106
-5
ScoreRuleService.java
...dao/module/member/service/scoreRule/ScoreRuleService.java
+27
-0
ScoreRuleServiceImpl.java
...module/member/service/scoreRule/ScoreRuleServiceImpl.java
+147
-2
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
ScoreDelayReqVO.java
...der/yudao/module/member/vo/scoreRule/ScoreDelayReqVO.java
+1
-1
WarehouseTreeRegionSimpleVO.java
...dule/member/vo/scoreRule/WarehouseTreeRegionSimpleVO.java
+55
-0
ScoreRuleOrderVExtraVO.java
...ule/member/vo/scoreRule/extra/ScoreRuleOrderVExtraVO.java
+2
-0
RedeemRewardApi.java
...coder/yudao/module/reward/api/reward/RedeemRewardApi.java
+2
-0
RedeemDetailForUserDTO.java
.../module/reward/api/reward/dto/RedeemDetailForUserDTO.java
+16
-0
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+15
-0
No files found.
yudao-module-depository/yudao-module-depository-core/src/main/java/cn/iocoder/yudao/module/depository/dal/mysql/warehouse/WarehouseMapper.java
View file @
adba3fe8
...
...
@@ -123,7 +123,9 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
@Select
({
"SELECT w.*, "
,
"r1.title_zh as guojiaName,"
,
"r2.title_zh as shiName "
,
"r1.title_en as guojiaNameEn,"
,
"r2.title_zh as shiName, "
,
"r2.title_en as shiNameEn "
,
"FROM ecw_warehouse w "
,
"LEFT JOIN ecw_region r1 "
,
"ON w.guojia = r1.id "
,
...
...
yudao-module-depository/yudao-module-depository-core/src/main/java/cn/iocoder/yudao/module/depository/vo/warehouse/WarehouseTreeRegionVO.java
View file @
adba3fe8
...
...
@@ -9,8 +9,10 @@ import java.util.List;
public
class
WarehouseTreeRegionVO
extends
WarehouseRespVO
{
private
String
guojiaName
;
private
String
guojiaNameEn
;
private
String
shiName
;
private
String
shiNameEn
;
private
Long
pid
;
...
...
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/ScoreProducerApi.java
View file @
adba3fe8
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-api/src/main/java/cn/iocoder/yudao/module/member/enums/ScoreSourceTypeEnum.java
View file @
adba3fe8
...
...
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.enums;
import
com.google.common.collect.Sets
;
import
java.util.Set
;
import
java.util.stream.Stream
;
public
enum
ScoreSourceTypeEnum
{
MANUAL_OPERATE
(
1
,
"人工操作"
,
null
,
null
),
...
...
@@ -53,4 +54,7 @@ public enum ScoreSourceTypeEnum {
public
static
Set
<
ScoreSourceTypeEnum
>
getInvalidScoreStatusSourceType
()
{
return
Sets
.
newHashSet
(
MANUAL_OPERATE
,
SYSTEM_EXPIRED
);
}
public
static
ScoreSourceTypeEnum
parseByValue
(
int
value
)
{
return
Stream
.
of
(
values
()).
filter
(
e
->
e
.
getValue
()
==
value
).
findAny
().
orElse
(
null
);
}
}
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/TransportTypeEnum.java
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
;
import
java.util.stream.Stream
;
public
enum
TransportTypeEnum
{
OCEAN_LCL
(
1
,
"海运拼柜"
),
SPECIAL_LINE_AIR_FREIGHT
(
3
,
"专线空运"
);
...
...
@@ -20,4 +22,7 @@ public enum TransportTypeEnum {
public
String
getName
()
{
return
name
;
}
public
static
TransportTypeEnum
parseByValue
(
int
value
)
{
return
Stream
.
of
(
values
()).
filter
(
e
->
e
.
getValue
()
==
value
).
findAny
().
orElse
(
null
);
}
}
yudao-module-member/yudao-module-member-impl/pom.xml
View file @
adba3fe8
...
...
@@ -59,5 +59,10 @@
<artifactId>
yudao-module-customer-core
</artifactId>
<version>
${revision}
</version>
</dependency>
<dependency>
<groupId>
cn.iocoder.boot
</groupId>
<artifactId>
yudao-module-reward-api
</artifactId>
<version>
${revision}
</version>
</dependency>
</dependencies>
</project>
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/scoreRule/ScoreRuleController.java
View file @
adba3fe8
...
...
@@ -43,8 +43,6 @@ public class ScoreRuleController {
@Resource
private
ScoreRuleService
scoreRuleService
;
@Resource
private
WarehouseService
warehouseService
;
@Resource
private
ApplicationContext
applicationContext
;
@Resource
private
ScoreProducerApi
scoreProducerApi
;
...
...
@@ -122,10 +120,8 @@ public class ScoreRuleController {
@GetMapping
(
"/warehouse-tree-region-list"
)
@ApiOperation
(
"获得目的国、目的城市、目的仓列表"
)
public
CommonResult
<
List
<
WarehouseTreeRegionVO
>>
warehouseTreeRegionList
()
{
List
<
WarehouseTreeRegionVO
>
listIn
=
warehouseService
.
getWarehouseTreeRegionList
(
1
);
List
<
WarehouseTreeRegionVO
>
listOut
=
warehouseService
.
getWarehouseTreeRegionList
(
2
);
List
<
WarehouseTreeRegionVO
>
list
=
ListUtils
.
sum
(
listIn
,
listOut
);
public
CommonResult
<
List
<
WarehouseTreeRegionSimpleVO
>>
warehouseTreeRegionList
()
{
List
<
WarehouseTreeRegionSimpleVO
>
list
=
scoreRuleService
.
getWarehouseTreeRegionListSimple
();
return
success
(
list
);
}
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthRegReqVO.java
View file @
adba3fe8
...
...
@@ -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 @
adba3fe8
...
...
@@ -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/controller/app/userScore/AppMemberUserScoreController.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
controller
.
app
.
userScore
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApiImpl
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO
;
import
cn.iocoder.yudao.module.member.service.score.MemberUserScoreService
;
import
cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
@Validated
@RestController
@Api
(
tags
=
"用户 APP - 会员积分"
)
@RequestMapping
(
"/member/user-score"
)
public
class
AppMemberUserScoreController
{
@Resource
private
MemberUserScoreService
userScoreService
;
@Resource
private
MemberUserScoreApiImpl
scoreApi
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
@PostMapping
(
"/info"
)
@ApiOperation
(
"获得会员积分基本信息"
)
//@PreAuthenticated
public
CommonResult
<
AppMemberUserScoreInfoRespVO
>
getUserScoreInfo
(
@Valid
@RequestBody
AppMemberUserIdQueryVO
idQuery
)
{
AppMemberUserScoreInfoRespVO
scoreInfo
=
userScoreService
.
getUserScoreInfo
(
idQuery
);
return
success
(
scoreInfo
);
}
@PostMapping
(
"/log"
)
@ApiOperation
(
"获取会员积分日志列表"
)
//@PreAuthenticated
public
CommonResult
<
List
<
AppMemberUserScoreLogRespVO
>>
getUserScoreLogList
(
@Valid
@RequestBody
AppMemberUserIdQueryVO
query
)
{
return
success
(
memberUserScoreLogService
.
getUserScoreLogList
(
query
));
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/userScore/vo/AppMemberUserIdQueryVO.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
controller
.
app
.
userScore
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
/**
* @author zhaobiyan
*/
@Data
@ApiModel
(
"用户 APP - 会员积分 id查询 VO"
)
public
class
AppMemberUserIdQueryVO
{
@ApiModelProperty
(
value
=
"会员id"
)
@NotNull
private
Long
id
;
}
\ No newline at end of file
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/userScore/vo/AppMemberUserScoreInfoRespVO.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
controller
.
app
.
userScore
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@ApiModel
(
"用户 APP - 会员积分基本信息返回 VO"
)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
AppMemberUserScoreInfoRespVO
{
@ApiModelProperty
(
value
=
"会员id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"当前积分"
)
private
Integer
holdScore
;
@ApiModelProperty
(
value
=
"已兑换积分"
)
private
Integer
usedScore
;
@ApiModelProperty
(
value
=
"历史总积分"
)
private
Integer
totalScore
;
@ApiModelProperty
(
value
=
"会员等级名称"
)
private
String
levelName
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/userScore/vo/AppMemberUserScoreLogRespVO.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
controller
.
app
.
userScore
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Data
@ApiModel
(
"用户 APP - 会员积分日志返回 VO"
)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
AppMemberUserScoreLogRespVO
{
@ApiModelProperty
(
value
=
"积分数量"
)
private
Integer
scoreCount
;
@ApiModelProperty
(
value
=
"操作类型"
)
private
String
operateType
;
@ApiModelProperty
(
value
=
"积分来源"
)
private
String
sourceTypeZh
;
@ApiModelProperty
(
value
=
"积分来源"
)
private
String
sourceTypeEn
;
@ApiModelProperty
(
value
=
"积分规则id"
)
private
Long
ruleId
;
@ApiModelProperty
(
value
=
"积分规则名称中文"
)
private
String
ruleNameZh
;
@ApiModelProperty
(
value
=
"积分规则名称英文"
)
private
String
ruleNameEn
;
@ApiModelProperty
(
value
=
"日志时间"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"描述信息中文"
)
private
String
descZh
=
""
;
@ApiModelProperty
(
value
=
"描述信息英文"
)
private
String
descEn
=
""
;
@ApiModelProperty
(
value
=
"礼品兑换数量"
)
private
Integer
rewardCount
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
View file @
adba3fe8
...
...
@@ -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/dal/redis/
package-info
.java
→
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/redis/
RedisKeyConstant
.java
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
dal
.
redis
;
/**
*
占位,后续有类后,可以删除,避免 package 无法提交到 Git 上
*
Redis Key 枚举类
*/
package
cn
.
iocoder
.
yudao
.
module
.
member
.
dal
.
redis
;
public
interface
RedisKeyConstant
{
String
MEMBER_USER_SCORE_RULE
=
"member:user:score:rule:"
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/redis/scoreRule/ScoreRuleRedisDao.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
dal
.
redis
.
scoreRule
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.dal.redis.RedisKeyConstant
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportTypeEnum
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Repository
;
import
javax.annotation.Resource
;
/**
* 会员积分规则 Redis DAO
*/
@Repository
public
class
ScoreRuleRedisDao
{
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
public
ScoreRuleDO
getEnableScoreRule
(
ScoreRuleTypeEnum
type
,
TransportTypeEnum
transportType
)
{
// 如果transportType不为空则是订单V值类型
if
(
transportType
==
null
)
{
String
redisKey
=
formatKey
(
type
.
getValue
(),
null
);
String
scoreRuleJson
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
scoreRuleJson
==
null
)
{
return
null
;
}
return
JsonUtils
.
parseObject
(
scoreRuleJson
,
ScoreRuleDO
.
class
);
}
else
{
String
redisKey
=
formatKey
(
type
.
getValue
(),
transportType
.
getValue
());
String
scoreRuleJson
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
scoreRuleJson
==
null
)
{
return
null
;
}
return
JsonUtils
.
parseObject
(
scoreRuleJson
,
ScoreRuleDO
.
class
);
}
}
public
ScoreRuleDO
getEnableScoreRule
(
ScoreRuleTypeEnum
type
)
{
return
getEnableScoreRule
(
type
,
null
);
}
public
void
setEnableScoreRule
(
ScoreRuleDO
scoreRuleDO
)
{
// 多余字段置空
scoreRuleDO
.
setCreator
(
null
);
scoreRuleDO
.
setUpdater
(
null
);
scoreRuleDO
.
setUpdateTime
(
null
);
scoreRuleDO
.
setCreateTime
(
null
);
scoreRuleDO
.
setDeleted
(
null
);
scoreRuleDO
.
setCoverImageEn
(
null
);
scoreRuleDO
.
setCoverImageZh
(
null
);
scoreRuleDO
.
setDescEn
(
null
);
scoreRuleDO
.
setDescZh
(
null
);
if
(
scoreRuleDO
.
getType
()
==
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
())
{
ScoreRuleOrderVExtraVO
scoreRuleOrderVExtraVO
=
JsonUtils
.
parseObject
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
stringRedisTemplate
.
opsForValue
().
set
(
formatKey
(
scoreRuleDO
.
getType
(),
scoreRuleOrderVExtraVO
.
getTransportType
()),
JsonUtils
.
toJsonString
(
scoreRuleDO
));
}
stringRedisTemplate
.
opsForValue
().
set
(
formatKey
(
scoreRuleDO
.
getType
(),
null
),
JsonUtils
.
toJsonString
(
scoreRuleDO
));
}
public
void
deleteEnableScoreRule
(
Integer
type
)
{
if
(
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
()
==
type
)
{
stringRedisTemplate
.
delete
(
formatKey
(
type
,
1
));
stringRedisTemplate
.
delete
(
formatKey
(
type
,
3
));
}
String
redisKey
=
formatKey
(
type
,
null
);
stringRedisTemplate
.
delete
(
redisKey
);
}
private
static
String
formatKey
(
Integer
type
,
Integer
transportType
)
{
if
(
transportType
==
null
)
{
return
RedisKeyConstant
.
MEMBER_USER_SCORE_RULE
+
type
;
}
return
RedisKeyConstant
.
MEMBER_USER_SCORE_RULE
+
type
+
":"
+
transportType
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/AbstractScoreRuleStrategy.java
View file @
adba3fe8
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.hutool.core.collection.CollUtil
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
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
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.
Date
;
import
java.util.
List
;
/**
* 半成品
* @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
;
protected
MemberUserScoreLogService
memberUserScoreLogService
;
protected
MemberUserService
memberUserService
;
@Autowired
public
AbstractScoreRuleStrategy
(
ScoreRuleService
scoreRuleService
)
{
public
AbstractScoreRuleStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
,
MemberUserService
memberUserService
)
{
this
.
scoreRuleService
=
scoreRuleService
;
this
.
memberUserScoreLogService
=
memberUserScoreLogService
;
this
.
memberUserService
=
memberUserService
;
}
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
;
/**
* 计算用户在某一活动获得积分总数
* @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
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
;
}
return
userScoreTotalCount
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/OderVStrategy.java
→
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/O
r
derVStrategy.java
View file @
adba3fe8
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,13 @@ 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.service.user.MemberUserService
;
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
;
...
...
@@ -27,7 +25,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -37,18 +34,16 @@ import java.util.Objects;
*/
@Service
@Slf4j
public
class
OderVStrategy
extends
AbstractScoreRuleStrategy
{
public
class
O
r
derVStrategy
extends
AbstractScoreRuleStrategy
{
@Resource
private
OrderApi
orderApi
;
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
@Resource
private
CustomerContactsService
customerContactsService
;
public
O
derVStrategy
(
ScoreRuleService
scoreRule
Service
)
{
super
(
scoreRuleService
);
public
O
rderVStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
,
MemberUserService
memberUser
Service
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
,
memberUserService
);
}
@Override
...
...
@@ -72,16 +67,11 @@ public class OderVStrategy extends AbstractScoreRuleStrategy {
}
// 判断海运空运
Integer
transportId
=
order
.
getTransportId
();
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnable
dOrderVScoreRuleByTransportType
(
transportId
);
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnable
ScoreRuleByType
(
ScoreRuleTypeEnum
.
ORDER_V
,
TransportTypeEnum
.
parseByValue
(
transportId
)
);
if
(
Objects
.
isNull
(
scoreRuleDO
))
{
log
.
info
(
"Order in shipping listener: No score rule match,orderID:{}"
,
orderId
);
return
;
}
// 是否过期,或者活动还没开始
if
(!
scoreRuleDO
.
getEndTime
().
after
(
new
Date
())
||
!
scoreRuleDO
.
getStartTime
().
before
(
new
Date
()))
{
log
.
info
(
"Order in shipping listener: The score rule has expired,scoreRuleID:{}"
,
scoreRuleDO
.
getId
());
return
;
}
// 目的地信息
OrderObjectiveApiDO
orderObjectiveDO
=
order
.
getOrderObjectiveDO
();
ScoreRuleOrderVExtraVO
extraInfo
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
...
...
@@ -156,16 +146,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
;
...
...
@@ -177,7 +158,6 @@ public class OderVStrategy extends AbstractScoreRuleStrategy {
try
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"orderId"
,
orderId
);
// TODO:增加订单号和唯一键
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
userId
)
.
scoreCount
(
scoreCount
)
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/score/core/RecommendStrategy.java
View file @
adba3fe8
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.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
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.Date
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* @author zhangfeng
...
...
@@ -33,45 +27,28 @@ public class RecommendStrategy extends AbstractScoreRuleStrategy {
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
private
MemberUserService
memberUserService
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
public
RecommendStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
public
RecommendStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
,
MemberUserService
memberUserService
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
,
memberUserService
);
}
@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
=
scoreRuleService
.
selectOne
(
new
LambdaQuery
<
ScoreRuleDO
>()
.
eq
(
ScoreRuleDO:
:
getType
,
ScoreRuleTypeEnum
.
RECOMMEND
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()));
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
.
RECOMMEND
);
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
);
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 @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
mq
.
consumer
.
score
.
core
;
import
cn.iocoder.yudao.framework.
mybatis.core.query.LambdaQuery
;
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
;
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.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
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
/**
...
...
@@ -29,32 +29,32 @@ public class RegisterStrategy extends AbstractScoreRuleStrategy {
@Resource
private
MemberUserService
memberUserService
;
public
RegisterStrategy
(
ScoreRuleService
scoreRuleService
)
{
super
(
scoreRuleService
);
public
RegisterStrategy
(
ScoreRuleService
scoreRuleService
,
MemberUserScoreLogService
memberUserScoreLogService
,
MemberUserService
memberUserService
)
{
super
(
scoreRuleService
,
memberUserScoreLogService
,
memberUserService
);
}
@Override
public
void
addScore
(
ScoreMessage
message
)
{
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
()));
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
.
REGISTER
);
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:校验注册入口,目前表没加
// 校验注册平台
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/consumer/score/core/ScoreRuleStrategy.java
View file @
adba3fe8
...
...
@@ -8,5 +8,4 @@ import cn.iocoder.yudao.module.member.mq.message.ScoreMessage;
public
interface
ScoreRuleStrategy
{
void
addScore
(
ScoreMessage
message
);
ScoreRuleTypeEnum
getStrategyScoreRuleType
();
void
refreshScoreRule
(
ScoreRuleTypeEnum
scoreRuleType
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/mq/message/ScoreMessage.java
View file @
adba3fe8
...
...
@@ -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 @
adba3fe8
...
...
@@ -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 @
adba3fe8
...
...
@@ -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/score/MemberUserScoreService.java
View file @
adba3fe8
...
...
@@ -4,6 +4,8 @@ import java.util.*;
import
cn.iocoder.yudao.framework.mybatis.core.service.IService
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.*
;
import
cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
...
...
@@ -50,4 +52,11 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> {
List
<
MemberUserScoreDO
>
getUserScoreList
(
MemberUserScoreQueryVO
query
);
void
updateUserScore
(
MemberUserScoreUpdateReqDTO
query
);
/**
* 获取会员积分及会员等级信息
* @param id
* @return
*/
AppMemberUserScoreInfoRespVO
getUserScoreInfo
(
AppMemberUserIdQueryVO
id
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/score/MemberUserScoreServiceImpl.java
View file @
adba3fe8
...
...
@@ -3,12 +3,16 @@ package cn.iocoder.yudao.module.member.service.score;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.mybatis.core.service.AbstractService
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO
;
import
cn.iocoder.yudao.module.member.dal.mysql.memberUserScore.MemberUserScoreMapper
;
import
cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.service.level.MemberUserLevelConfigService
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO
;
import
cn.iocoder.yudao.module.member.vo.userLevel.MemberUserLevelConfigBaseRespVO
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -34,6 +38,8 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
@Resource
private
MemberUserScoreMapper
userScoreMapper
;
@Resource
private
MemberUserLevelConfigService
memberUserLevelConfigService
;
@Override
public
void
deleteUserScore
(
Long
id
)
{
...
...
@@ -103,6 +109,26 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
}
}
@Override
public
AppMemberUserScoreInfoRespVO
getUserScoreInfo
(
AppMemberUserIdQueryVO
id
)
{
MemberUserScoreDO
userScoreDO
=
userScoreMapper
.
getByMemberId
(
id
.
getId
());
if
(
userScoreDO
==
null
)
{
throw
exception
(
MEMBER_ID_IS_NULL
);
}
Integer
userScoreTotal
=
userScoreDO
.
getHoldScore
()
+
userScoreDO
.
getUsedScore
()
+
userScoreDO
.
getExpiredScore
();
AppMemberUserScoreInfoRespVO
infoRespVO
=
AppMemberUserScoreInfoRespVO
.
builder
()
.
holdScore
(
userScoreDO
.
getHoldScore
())
.
id
(
userScoreDO
.
getId
())
.
totalScore
(
userScoreTotal
)
.
usedScore
(
userScoreDO
.
getUsedScore
())
.
build
();
MemberUserLevelConfigBaseRespVO
level
=
memberUserLevelConfigService
.
getLevelByCount
(
userScoreTotal
);
if
(
level
!=
null
)
{
infoRespVO
.
setLevelName
(
level
.
getName
());
}
return
infoRespVO
;
}
private
MemberUserScoreDO
initMemberUserScore
(
Long
memberId
)
{
MemberUserScoreDO
memberUserScoreDO
=
new
MemberUserScoreDO
();
memberUserScoreDO
.
setMemberId
(
memberId
);
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreLog/MemberUserScoreLogService.java
View file @
adba3fe8
...
...
@@ -2,11 +2,15 @@ package cn.iocoder.yudao.module.member.service.scoreLog;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.mybatis.core.service.IService
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO
;
import
java.util.List
;
/**
* 会员积分日志 Service 接口
*
...
...
@@ -19,4 +23,6 @@ public interface MemberUserScoreLogService extends IService<MemberUserScoreLogDO
Long
createScoreLog
(
MemberUserScoreLogCreateReq
createReq
);
MemberUserScoreLogDO
getByUniqueId
(
String
uniqueId
);
List
<
AppMemberUserScoreLogRespVO
>
getUserScoreLogList
(
AppMemberUserIdQueryVO
query
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreLog/MemberUserScoreLogServiceImpl.java
View file @
adba3fe8
...
...
@@ -3,12 +3,22 @@ package cn.iocoder.yudao.module.member.service.scoreLog;
import
cn.hutool.core.lang.generator.SnowflakeGenerator
;
import
cn.hutool.json.JSONUtil
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils
;
import
cn.iocoder.yudao.framework.mybatis.core.service.AbstractService
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO
;
import
cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog.MemberUserScoreLogMapper
;
import
cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackDetailVO
;
import
cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO
;
import
cn.iocoder.yudao.module.system.service.dict.DictTypeService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -16,7 +26,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.validation.annotation.Validated
;
import
javax.annotation.Resource
;
import
java.util.
List
;
import
java.util.
*
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_ID_IS_NULL
;
...
...
@@ -32,12 +42,12 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco
@Resource
private
MemberUserScoreLogMapper
userScoreLogMapper
;
@Resource
private
DictTypeService
dictTypeService
;
@Resource
private
SnowflakeGenerator
snowflakeGenerator
;
@Resource
private
ScoreRuleService
scoreRuleService
;
@Resource
RedeemRewardApi
redeemRewardApi
;
@Override
...
...
@@ -75,4 +85,95 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco
wrapper
.
eq
(
MemberUserScoreLogDO:
:
getUniqueId
,
uniqueId
);
return
this
.
selectOne
(
wrapper
);
}
@Override
public
List
<
AppMemberUserScoreLogRespVO
>
getUserScoreLogList
(
AppMemberUserIdQueryVO
query
)
{
List
<
MemberUserScoreLogDO
>
userScoreLogDOS
=
userScoreLogMapper
.
selectList
(
"member_id"
,
query
.
getId
());
if
(
userScoreLogDOS
==
null
||
userScoreLogDOS
.
isEmpty
())
{
return
Collections
.
EMPTY_LIST
;
}
ArrayList
<
AppMemberUserScoreLogRespVO
>
appMemberUserScoreLogRespVOS
=
new
ArrayList
<>();
for
(
MemberUserScoreLogDO
userScoreLogDO
:
userScoreLogDOS
)
{
setScoreRuleLogDetail
(
userScoreLogDO
,
appMemberUserScoreLogRespVOS
);
}
return
appMemberUserScoreLogRespVOS
;
}
private
void
setScoreRuleLogDetail
(
MemberUserScoreLogDO
userScoreLogDO
,
ArrayList
<
AppMemberUserScoreLogRespVO
>
appMemberUserScoreLogRespVOS
)
{
AppMemberUserScoreLogRespVO
appMemberUserScoreLogRespVO
=
new
AppMemberUserScoreLogRespVO
();
appMemberUserScoreLogRespVO
.
setScoreCount
(
userScoreLogDO
.
getScoreCount
());
appMemberUserScoreLogRespVO
.
setOperateType
(
userScoreLogDO
.
getOperateType
()
==
1
?
"+"
:
"-"
);
appMemberUserScoreLogRespVO
.
setCreateTime
(
userScoreLogDO
.
getCreateTime
());
// 增加积分日志
if
(
Objects
.
equals
(
userScoreLogDO
.
getOperateType
(),
ScoreOperateTypeEnum
.
ADD
.
getValue
()))
{
switch
(
userScoreLogDO
.
getSourceType
())
{
// 人工操作
case
1
:
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"1"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"1"
).
getLabelEn
());
appMemberUserScoreLogRespVO
.
setDescZh
(
"人工积分"
);
appMemberUserScoreLogRespVO
.
setDescEn
(
"Manually add points"
);
break
;
// 撤销兑换
case
4
:
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"4"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"4"
).
getLabelEn
());
// TODO:补充描述
appMemberUserScoreLogRespVO
.
setDescZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"4"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setDescEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"4"
).
getLabelEn
());
break
;
// 活动积分
case
5
:
case
6
:
case
7
:
case
8
:
ScoreSourceTypeEnum
scoreSourceTypeEnum
=
ScoreSourceTypeEnum
.
parseByValue
(
userScoreLogDO
.
getSourceType
());
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
String
.
valueOf
(
scoreSourceTypeEnum
.
getValue
())).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
String
.
valueOf
(
scoreSourceTypeEnum
.
getValue
())).
getLabelEn
());
ScoreRuleBackDetailVO
scoreRule
=
scoreRuleService
.
getScoreRule
(
userScoreLogDO
.
getRuleId
());
if
(
scoreRule
!=
null
)
{
appMemberUserScoreLogRespVO
.
setRuleId
(
userScoreLogDO
.
getRuleId
());
appMemberUserScoreLogRespVO
.
setRuleNameEn
(
scoreRule
.
getTitleEn
());
appMemberUserScoreLogRespVO
.
setRuleNameZh
(
scoreRule
.
getTitleZh
());
appMemberUserScoreLogRespVO
.
setDescEn
(
scoreRule
.
getDescEn
());
appMemberUserScoreLogRespVO
.
setDescZh
(
scoreRule
.
getDescZh
());
}
break
;
}
}
else
{
// 减少积分日志
switch
(
userScoreLogDO
.
getSourceType
())
{
// 人工操作
case
1
:
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"1"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"1"
).
getLabelEn
());
appMemberUserScoreLogRespVO
.
setDescZh
(
"人工积分"
);
appMemberUserScoreLogRespVO
.
setDescEn
(
"Manually reduce points"
);
break
;
// 兑换
case
2
:
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"2"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"2"
).
getLabelEn
());
// 查询兑换记录
Map
<
String
,
Long
>
extParam
=
JsonUtils
.
parseObject
(
userScoreLogDO
.
getExtParam
(),
HashMap
.
class
);
Long
redeemId
=
extParam
.
get
(
"redeemId"
);
if
(
redeemId
!=
null
)
{
RedeemDetailForUserDTO
redeemDetailForUser
=
redeemRewardApi
.
getRedeemDetailForUser
(
redeemId
);
if
(
redeemDetailForUser
!=
null
)
{
appMemberUserScoreLogRespVO
.
setRewardCount
(
redeemDetailForUser
.
getRewardCount
());
appMemberUserScoreLogRespVO
.
setDescZh
(
redeemDetailForUser
.
getRewardNameZh
());
appMemberUserScoreLogRespVO
.
setDescEn
(
redeemDetailForUser
.
getRewardNameEn
());
}
}
break
;
// 系统过期
case
3
:
appMemberUserScoreLogRespVO
.
setSourceTypeZh
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"3"
).
getLabel
());
appMemberUserScoreLogRespVO
.
setSourceTypeEn
(
DictFrameworkUtils
.
getDictDataFromCache
(
"member_score_source"
,
"3"
).
getLabelEn
());
appMemberUserScoreLogRespVO
.
setDescZh
(
"系统过期"
);
appMemberUserScoreLogRespVO
.
setDescEn
(
"System expiration"
);
}
}
appMemberUserScoreLogRespVOS
.
add
(
appMemberUserScoreLogRespVO
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleService.java
View file @
adba3fe8
...
...
@@ -7,6 +7,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import
cn.iocoder.yudao.framework.mybatis.core.service.IService
;
import
cn.iocoder.yudao.framework.mybatis.core.vo.PageVO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportTypeEnum
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.*
;
/**
...
...
@@ -18,6 +20,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 创建积分规则
*
* @param createReqVO 创建信息
* @return 编号
*/
...
...
@@ -25,12 +28,14 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 更新积分规则
*
* @param updateReqVO 更新信息
*/
void
updateScoreRule
(
@Valid
ScoreRuleUpdateReqVO
updateReqVO
);
/**
* 删除积分规则
*
* @param id 编号
*/
void
deleteScoreRule
(
Long
id
);
...
...
@@ -62,6 +67,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 获得积分规则列表, 用于 Excel 导出
*
* @param query 查询
* @return 积分规则列表
*/
...
...
@@ -69,6 +75,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 积分规则启用关闭
*
* @param scoreRuleStatusReqVO 积分规则状态
* @return
*/
...
...
@@ -76,6 +83,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 积分规则复制
*
* @param id
* @return
*/
...
...
@@ -83,6 +91,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 积分规则延期
*
* @param scoreDelayReqVO 积分规则延期
* @return
*/
...
...
@@ -90,8 +99,26 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 根据运输方式获取已启用订单V值规则
*
* @param transportType
* @return
*/
ScoreRuleDO
getEnabledOrderVScoreRuleByTransportType
(
Integer
transportType
);
/**
* 根据类型获取已启用积分规则
* @param scoreRuleType
* @return
*/
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
);
/**
* 根据类型获取已启用积分规则(带运输类型)
* @param scoreRuleType
* @param transportType
* @return
*/
ScoreRuleDO
getEnableScoreRuleByType
(
ScoreRuleTypeEnum
scoreRuleType
,
TransportTypeEnum
transportType
);
List
<
WarehouseTreeRegionSimpleVO
>
getWarehouseTreeRegionListSimple
();
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleServiceImpl.java
View file @
adba3fe8
This diff is collapsed.
Click to expand it.
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
View file @
adba3fe8
...
...
@@ -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 @
adba3fe8
...
...
@@ -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
()))
...
...
@@ -564,7 +565,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 @
adba3fe8
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
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/vo/scoreRule/ScoreDelayReqVO.java
View file @
adba3fe8
...
...
@@ -11,7 +11,7 @@ import java.util.Date;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Data
@ApiModel
(
"管理后台 - 积分规则延期 Re
sponse
VO"
)
@ApiModel
(
"管理后台 - 积分规则延期 Re
quest
VO"
)
public
class
ScoreDelayReqVO
{
@ApiModelProperty
(
value
=
"主键"
,
required
=
true
)
@NotNull
(
message
=
"主键不能为空"
)
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/vo/scoreRule/WarehouseTreeRegionSimpleVO.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
member
.
vo
.
scoreRule
;
import
cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseRespVO
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Objects
;
@Data
public
class
WarehouseTreeRegionSimpleVO
{
@ApiModelProperty
(
"国家id"
)
private
Long
countryId
;
@ApiModelProperty
(
"国家中文名"
)
private
String
labelZh
;
@ApiModelProperty
(
"国家英文名"
)
private
String
labelEn
;
@ApiModelProperty
(
"城市"
)
private
List
<
WarehouseCity
>
children
;
@Data
public
static
class
WarehouseCity
{
@ApiModelProperty
(
"城市id"
)
private
Long
cityId
;
@ApiModelProperty
(
"城市中文名"
)
private
String
labelZh
;
@ApiModelProperty
(
"城市英文名"
)
private
String
labelEn
;
@ApiModelProperty
(
"仓库"
)
private
List
<
Warehouse
>
children
;
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
WarehouseCity
that
=
(
WarehouseCity
)
o
;
return
Objects
.
equals
(
cityId
,
that
.
cityId
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hashCode
(
cityId
);
}
}
@Data
public
static
class
Warehouse
{
@ApiModelProperty
(
"仓库id"
)
private
Long
warehouseId
;
@ApiModelProperty
(
"仓库中文名"
)
private
String
labelZh
;
@ApiModelProperty
(
"仓库英文名"
)
private
String
labelEn
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/vo/scoreRule/extra/ScoreRuleOrderVExtraVO.java
View file @
adba3fe8
...
...
@@ -19,6 +19,8 @@ public class ScoreRuleOrderVExtraVO {
private
String
targetCity
;
@ApiModelProperty
(
value
=
"提货点,可多选,逗号拼接"
,
required
=
true
)
private
String
receiveAddr
;
@ApiModelProperty
(
value
=
"提货点列表(第一级提货点,第二级国家,城市,仓库id)"
,
required
=
true
)
private
List
<
List
<
Long
>>
receiveAddrList
;
@ApiModelProperty
(
value
=
"渠道,运输方式选择海运时,渠道隐藏,可多选,逗号拼接"
)
private
String
channel
;
@ApiModelProperty
(
value
=
"积分规则列表"
,
required
=
true
)
...
...
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApi.java
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
api
.
reward
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
...
...
@@ -13,4 +14,5 @@ public interface RedeemRewardApi {
RedeemRewardRespDTO
redeemReward
(
RedeemRewardReqVO
redeemRewardReqVO
);
List
<
RedeemRewardRespDTO
>
redeemRewards
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
);
RedeemDetailForUserDTO
getRedeemDetailForUser
(
Long
redeemId
);
}
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/dto/RedeemDetailForUserDTO.java
0 → 100644
View file @
adba3fe8
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
api
.
reward
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"用户 APP - 礼品兑换记录 DTO"
)
public
class
RedeemDetailForUserDTO
{
@ApiModelProperty
(
value
=
"礼品名称中文"
)
private
String
rewardNameZh
;
@ApiModelProperty
(
value
=
"礼品名称英文"
)
private
String
rewardNameEn
;
@ApiModelProperty
(
value
=
"兑换数量"
)
private
Integer
rewardCount
;
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
adba3fe8
...
...
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import
cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO
;
import
cn.iocoder.yudao.module.member.enums.PlatformTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO
;
...
...
@@ -188,6 +189,20 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
return
null
;
}
@Override
public
RedeemDetailForUserDTO
getRedeemDetailForUser
(
Long
redeemId
)
{
RewardRedeemDO
rewardRedeemDO
=
rewardRedeemMapper
.
selectById
(
redeemId
);
if
(
rewardRedeemDO
!=
null
)
{
RedeemDetailForUserDTO
redeemDetailForUserDTO
=
new
RedeemDetailForUserDTO
();
redeemDetailForUserDTO
.
setRewardCount
(
rewardRedeemDO
.
getRewardCount
());
RewardDO
rewardDO
=
rewardMapper
.
selectById
(
rewardRedeemDO
.
getRewardId
());
redeemDetailForUserDTO
.
setRewardNameEn
(
rewardDO
.
getTitleEn
());
redeemDetailForUserDTO
.
setRewardNameZh
(
rewardDO
.
getTitleZh
());
return
redeemDetailForUserDTO
;
}
return
null
;
}
private
void
verifyMemberUser
(
RedeemRewardReqVO
redeemRewardReqVO
,
RewardDO
rewardDO
)
{
// 查询会员积分
UserRespDTO
memberUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
...
...
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