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
e8a403ca
Commit
e8a403ca
authored
Jul 23, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增会员编码字段,刷新历史数据
parent
31cd04db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
RedisHelper.java
.../cn/iocoder/yudao/framework/redis/helper/RedisHelper.java
+4
-0
MemberUserController.java
...le/member/controller/admin/user/MemberUserController.java
+7
-0
MemberUserServiceImpl.java
...dao/module/member/service/user/MemberUserServiceImpl.java
+17
-6
No files found.
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/redis/helper/RedisHelper.java
View file @
e8a403ca
...
...
@@ -1409,4 +1409,8 @@ public class RedisHelper {
public
boolean
execute
(
DefaultRedisScript
<
Boolean
>
defaultRedisScript
,
List
<
String
>
keys
,
Object
...
args
)
{
return
operations
.
execute
(
defaultRedisScript
,
keys
,
args
);
}
public
Long
execute4Long
(
DefaultRedisScript
<
Long
>
defaultRedisScript
,
List
<
String
>
keys
,
Object
...
args
)
{
return
operations
.
execute
(
defaultRedisScript
,
keys
,
args
);
}
}
\ No newline at end of file
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java
View file @
e8a403ca
...
...
@@ -459,4 +459,11 @@ public class MemberUserController {
}
return
success
(
null
);
}
@PutMapping
(
"/memberCode/flush"
)
@ApiOperation
(
"刷新历史会员编码"
)
public
CommonResult
<
String
>
memberCodeFlush
()
{
userService
.
historyCodeFlush
();
return
success
(
null
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
View file @
e8a403ca
...
...
@@ -49,6 +49,7 @@ import com.google.common.annotations.VisibleForTesting;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.data.redis.core.script.DefaultRedisScript
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -215,6 +216,7 @@ public class MemberUserServiceImpl implements MemberUserService {
}
user
.
setEnglishName
(
englishName
);
user
.
setNickname
(
englishName
);
user
.
setCode
(
getNextMemberCode
());
memberUserMapper
.
insert
(
user
);
//站内信
InternalMessageCreateDto
dto
=
InternalMessageCreateDto
.
builder
().
toIdList
(
Arrays
.
asList
(
user
.
getId
()))
...
...
@@ -565,14 +567,23 @@ public class MemberUserServiceImpl implements MemberUserService {
private
String
getNextMemberCode
()
{
String
key
=
"memberCode:max:number"
;
Boolean
hasMemberCodeMaxNumber
=
redisHelper
.
hasKey
(
key
);
if
(
hasMemberCodeMaxNumber
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
redisHelper
.
incrBy
(
key
,
1
));
String
incrIfExistScript
=
"if redis.call(\"exists\", KEYS[1]) == 1 then\n"
+
" return redis.call(\"incr\", KEYS[1])\n"
+
"else\n"
+
" return nil\n"
+
"end"
;
DefaultRedisScript
<
Long
>
redisScript
=
new
DefaultRedisScript
<>();
redisScript
.
setScriptText
(
incrIfExistScript
);
redisScript
.
setResultType
(
Long
.
class
);
Long
nextMemberCodeNumber
=
redisHelper
.
execute4Long
(
redisScript
,
Collections
.
singletonList
(
key
));
if
(
nextMemberCodeNumber
!=
null
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
nextMemberCodeNumber
);
}
synchronized
(
this
)
{
hasMemberCodeMaxNumber
=
redisHelper
.
hasKey
(
key
);
if
(
hasMemberCodeMaxNumber
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
redisHelper
.
incrBy
(
key
,
1
)
);
nextMemberCodeNumber
=
redisHelper
.
execute4Long
(
redisScript
,
Collections
.
singletonList
(
key
)
);
if
(
nextMemberCodeNumber
!=
null
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
nextMemberCodeNumber
);
}
String
currentMaxMemberCode
=
memberUserMapper
.
getCurrentMaxMemberCode
();
Long
memberCodeMaxNumber
=
MemberUserCodeUtils
.
getMemberCodeNumber
(
currentMaxMemberCode
);
...
...
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