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
53a6a1a1
Commit
53a6a1a1
authored
Jul 22, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增会员编码字段,刷新历史数据
parent
6f32cb16
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
116 additions
and
3 deletions
+116
-3
SecurityConfiguration.java
...nfra/framework/security/config/SecurityConfiguration.java
+1
-0
MemberUserController.java
...le/member/controller/admin/user/MemberUserController.java
+8
-0
MemberUserDO.java
...yudao/module/member/dal/dataobject/user/MemberUserDO.java
+1
-1
MemberUserMapper.java
.../yudao/module/member/dal/mysql/user/MemberUserMapper.java
+4
-2
MemberUserService.java
...r/yudao/module/member/service/user/MemberUserService.java
+3
-0
MemberUserServiceImpl.java
...dao/module/member/service/user/MemberUserServiceImpl.java
+55
-0
MemberUserCodeUtils.java
...iocoder/yudao/module/member/util/MemberUserCodeUtils.java
+36
-0
MemberUserMapper.xml
...-impl/src/main/resources/mapper/user/MemberUserMapper.xml
+8
-0
No files found.
yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
View file @
53a6a1a1
...
@@ -26,6 +26,7 @@ public class SecurityConfiguration {
...
@@ -26,6 +26,7 @@ public class SecurityConfiguration {
registry
.
antMatchers
(
"/swagger-ui.html"
).
anonymous
()
registry
.
antMatchers
(
"/swagger-ui.html"
).
anonymous
()
.
antMatchers
(
"/swagger-resources/**"
).
anonymous
()
.
antMatchers
(
"/swagger-resources/**"
).
anonymous
()
.
antMatchers
(
"/webjars/**"
).
anonymous
()
.
antMatchers
(
"/webjars/**"
).
anonymous
()
.
antMatchers
(
"/doc.html#/**"
).
anonymous
()
.
antMatchers
(
"/*/api-docs"
).
anonymous
();
.
antMatchers
(
"/*/api-docs"
).
anonymous
();
// Spring Boot Actuator 的安全配置
// Spring Boot Actuator 的安全配置
registry
.
antMatchers
(
"/actuator"
).
anonymous
()
registry
.
antMatchers
(
"/actuator"
).
anonymous
()
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java
View file @
53a6a1a1
...
@@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.member.vo.userCardAuth.UserCardAuthCreateReqVO;
...
@@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.member.vo.userCardAuth.UserCardAuthCreateReqVO;
import
cn.iocoder.yudao.module.member.vo.userEnterpriseAuth.UserEnterpriseAuthBackVO
;
import
cn.iocoder.yudao.module.member.vo.userEnterpriseAuth.UserEnterpriseAuthBackVO
;
import
cn.iocoder.yudao.module.member.vo.userEnterpriseAuth.UserEnterpriseAuthCreateReqVO
;
import
cn.iocoder.yudao.module.member.vo.userEnterpriseAuth.UserEnterpriseAuthCreateReqVO
;
import
cn.iocoder.yudao.module.member.vo.userOperationLog.UserOperationLogBackVO
;
import
cn.iocoder.yudao.module.member.vo.userOperationLog.UserOperationLogBackVO
;
import
com.alibaba.excel.util.CollectionUtils
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
...
@@ -459,5 +460,12 @@ public class MemberUserController {
...
@@ -459,5 +460,12 @@ public class MemberUserController {
return
success
(
null
);
return
success
(
null
);
}
}
@PutMapping
(
"/history/code/flush"
)
@ApiOperation
(
"历史会员编码刷新"
)
@PreAuthorize
(
"@ss.hasPermission('member:user:info')"
)
public
CommonResult
<
Boolean
>
historyCodeFlush
()
{
userService
.
historyCodeFlush
();
return
success
(
true
);
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
View file @
53a6a1a1
...
@@ -234,6 +234,6 @@ public class MemberUserDO extends TenantBaseDO {
...
@@ -234,6 +234,6 @@ public class MemberUserDO extends TenantBaseDO {
*/
*/
private
Boolean
isDeal
;
private
Boolean
isDeal
;
private
String
code
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java
View file @
53a6a1a1
...
@@ -171,8 +171,10 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
...
@@ -171,8 +171,10 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
"</script>"
"</script>"
})
})
MemberUserDO
info
(
@Param
(
"id"
)
Long
id
);
MemberUserDO
info
(
@Param
(
"id"
)
Long
id
);
@Update
(
"update ecw_customer_contacts set userid = null where userid = #{userId}"
)
@Update
(
"update ecw_customer_contacts set userid = null where userid = #{userId}"
)
void
unbindingCustomer
(
@Param
(
"userId"
)
Long
userId
);
void
unbindingCustomer
(
@Param
(
"userId"
)
Long
userId
);
String
getCurrentMaxMemberCode
();
void
updateMemberCodeById
(
@Param
(
"code"
)
String
memberCode
,
@Param
(
"id"
)
Long
id
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
View file @
53a6a1a1
...
@@ -218,4 +218,7 @@ public interface MemberUserService {
...
@@ -218,4 +218,7 @@ public interface MemberUserService {
void
memberCancellation
(
Long
userId
);
void
memberCancellation
(
Long
userId
);
List
<
MemberUserDO
>
getByCursor
(
Long
startUserId
,
long
limit
);
void
historyCodeFlush
();
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
View file @
53a6a1a1
...
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
...
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils
;
import
cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils
;
import
cn.iocoder.yudao.framework.mybatis.core.vo.PageVO
;
import
cn.iocoder.yudao.framework.mybatis.core.vo.PageVO
;
import
cn.iocoder.yudao.framework.redis.helper.RedisHelper
;
import
cn.iocoder.yudao.module.ecw.api.customer.CustomerApi
;
import
cn.iocoder.yudao.module.ecw.api.customer.CustomerApi
;
import
cn.iocoder.yudao.module.ecw.api.internalMessage.ClientInternalMessageApi
;
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.internalMessage.dto.InternalMessageCreateDto
;
...
@@ -32,15 +33,18 @@ import cn.iocoder.yudao.module.member.dal.mysql.userEnterpriseAuth.UserEnterpris
...
@@ -32,15 +33,18 @@ import cn.iocoder.yudao.module.member.dal.mysql.userEnterpriseAuth.UserEnterpris
import
cn.iocoder.yudao.module.member.enums.UserOperationLogTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.UserOperationLogTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.UserQueryAuthTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.UserQueryAuthTypeEnum
;
import
cn.iocoder.yudao.module.member.service.userOperationLog.UserOperationLogService
;
import
cn.iocoder.yudao.module.member.service.userOperationLog.UserOperationLogService
;
import
cn.iocoder.yudao.module.member.util.MemberUserCodeUtils
;
import
cn.iocoder.yudao.module.member.vo.member.MemberUpdateReqVO
;
import
cn.iocoder.yudao.module.member.vo.member.MemberUpdateReqVO
;
import
cn.iocoder.yudao.module.member.vo.userOperationLog.UserOperationLogCreateReqVO
;
import
cn.iocoder.yudao.module.member.vo.userOperationLog.UserOperationLogCreateReqVO
;
import
cn.iocoder.yudao.module.product.service.coupon.CouponService
;
import
cn.iocoder.yudao.module.product.service.coupon.CouponService
;
import
cn.iocoder.yudao.module.system.api.sms.SmsCodeApi
;
import
cn.iocoder.yudao.module.system.api.sms.SmsCodeApi
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO
;
import
cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum
;
import
cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum
;
import
com.alibaba.excel.util.CollectionUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.annotations.VisibleForTesting
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -53,6 +57,7 @@ import javax.annotation.Resource;
...
@@ -53,6 +57,7 @@ import javax.annotation.Resource;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
...
@@ -102,6 +107,9 @@ public class MemberUserServiceImpl implements MemberUserService {
...
@@ -102,6 +107,9 @@ public class MemberUserServiceImpl implements MemberUserService {
@Resource
@Resource
private
ParamValidatorApi
paramValidatorApi
;
private
ParamValidatorApi
paramValidatorApi
;
@Resource
private
RedisHelper
redisHelper
;
@Override
@Override
public
MemberUserDO
getUserByMobile
(
String
mobile
)
{
public
MemberUserDO
getUserByMobile
(
String
mobile
)
{
...
@@ -524,4 +532,51 @@ public class MemberUserServiceImpl implements MemberUserService {
...
@@ -524,4 +532,51 @@ public class MemberUserServiceImpl implements MemberUserService {
memberUserMapper
.
unbindingCustomer
(
userId
);
memberUserMapper
.
unbindingCustomer
(
userId
);
}
}
@Override
public
List
<
MemberUserDO
>
getByCursor
(
Long
startUserId
,
long
limit
)
{
if
(
startUserId
==
null
)
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
MemberUserDO
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
gt
(
MemberUserDO:
:
getId
,
startUserId
);
wrapper
.
orderByAsc
(
MemberUserDO:
:
getId
);
wrapper
.
last
(
"limit "
+
limit
);
return
memberUserMapper
.
getList
(
wrapper
);
}
@Override
public
void
historyCodeFlush
()
{
Long
startUserId
=
0L
;
long
limit
=
500
;
while
(
true
)
{
List
<
MemberUserDO
>
result
=
this
.
getByCursor
(
startUserId
,
limit
);
if
(
CollectionUtils
.
isEmpty
(
result
))
{
break
;
}
result
.
forEach
(
memberUserDO
->
{
String
memberCode
=
getNextMemberCode
();
memberUserMapper
.
updateMemberCodeById
(
memberCode
,
memberUserDO
.
getId
());
});
startUserId
=
result
.
stream
().
mapToLong
(
MemberUserDO:
:
getId
).
max
().
orElse
(
Long
.
MAX_VALUE
);
}
}
private
String
getNextMemberCode
()
{
String
key
=
"memberCode:max:number"
;
Boolean
hasMemberCodeMaxNumber
=
redisHelper
.
hasKey
(
key
);
if
(
hasMemberCodeMaxNumber
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
redisHelper
.
incrBy
(
key
,
1
));
}
synchronized
(
this
)
{
hasMemberCodeMaxNumber
=
redisHelper
.
hasKey
(
key
);
if
(
hasMemberCodeMaxNumber
)
{
return
MemberUserCodeUtils
.
generateMemberCode
(
redisHelper
.
incrBy
(
key
,
1
));
}
String
currentMaxMemberCode
=
memberUserMapper
.
getCurrentMaxMemberCode
();
Long
memberCodeMaxNumber
=
MemberUserCodeUtils
.
getMemberCodeNumber
(
currentMaxMemberCode
);
redisHelper
.
set
(
key
,
String
.
valueOf
(
memberCodeMaxNumber
),
5
,
TimeUnit
.
MINUTES
);
return
MemberUserCodeUtils
.
generateMemberCode
(
redisHelper
.
incrBy
(
key
,
1
));
}
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/util/MemberUserCodeUtils.java
0 → 100644
View file @
53a6a1a1
package
cn
.
iocoder
.
yudao
.
module
.
member
.
util
;
import
org.apache.commons.lang.StringUtils
;
import
org.json.JSONObject
;
/**
* @author zhaobiyan
*/
public
class
MemberUserCodeUtils
{
private
static
final
String
MEMBER_CODE_PREFIX
=
"EC"
;
private
static
final
int
DEFAULT_LENGTH
=
6
;
public
static
String
generateMemberCode
(
Long
codeNumber
)
{
StringBuilder
codeNumberStr
=
new
StringBuilder
(
String
.
valueOf
(
codeNumber
));
if
(
codeNumberStr
.
length
()
>=
DEFAULT_LENGTH
)
{
return
MEMBER_CODE_PREFIX
+
codeNumberStr
;
}
int
supplyCount
=
DEFAULT_LENGTH
-
codeNumberStr
.
length
();
for
(
int
i
=
0
;
i
<
supplyCount
;
i
++)
{
codeNumberStr
.
insert
(
0
,
"0"
);
}
return
MEMBER_CODE_PREFIX
+
codeNumberStr
;
}
public
static
Long
getMemberCodeNumber
(
String
currentMaxMemberCode
)
{
if
(
StringUtils
.
isBlank
(
currentMaxMemberCode
))
{
return
0L
;
}
String
[]
split
=
currentMaxMemberCode
.
split
(
MEMBER_CODE_PREFIX
);
return
Long
.
parseLong
(
split
[
1
]);
}
}
yudao-module-member/yudao-module-member-impl/src/main/resources/mapper/user/MemberUserMapper.xml
View file @
53a6a1a1
...
@@ -83,4 +83,12 @@
...
@@ -83,4 +83,12 @@
) as t
) as t
${ew.customSqlSegment}
${ew.customSqlSegment}
</select>
</select>
<select
id=
"getCurrentMaxMemberCode"
resultType=
"String"
>
select code from member_user order by code desc limit 1
</select>
<update
id=
"updateMemberCodeById"
>
update member_user set code = #{code} where id = #{id}
</update>
</mapper>
</mapper>
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