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
00d72aad
Commit
00d72aad
authored
Jul 25, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员操作积分接口
parent
9c6f9ba4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
50 deletions
+39
-50
MemberUserScoreApiImpl.java
...yudao/module/member/api/score/MemberUserScoreApiImpl.java
+12
-0
MemberUserScoreController.java
...ller/admin/memberUserScore/MemberUserScoreController.java
+22
-1
MemberUserScoreService.java
...ember/service/memberUserScore/MemberUserScoreService.java
+0
-2
MemberUserScoreServiceImpl.java
...r/service/memberUserScore/MemberUserScoreServiceImpl.java
+5
-47
No files found.
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/api/score/MemberUserScoreApiImpl.java
View file @
00d72aad
...
...
@@ -10,11 +10,17 @@ import cn.iocoder.yudao.module.member.service.memberUserScore.MemberUserScoreSer
import
cn.iocoder.yudao.module.member.service.memberUserScoreDetail.MemberUserScoreDetailService
;
import
cn.iocoder.yudao.module.member.service.memberUserScoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq
;
import
com.alibaba.excel.util.CollectionUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_ID_IS_NULL
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
SCORE_COUNT_ERROR
;
@Slf4j
@Service
public
class
MemberUserScoreApiImpl
implements
MemberUserScoreApi
{
...
...
@@ -30,6 +36,12 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
MemberUserScoreOperateRespDTO
operateScore
(
MemberUserScoreOperateReqDTO
req
)
{
if
(
req
.
getMemberId
()
==
null
)
{
throw
exception
(
MEMBER_ID_IS_NULL
);
}
if
(
req
.
getScoreCount
()
<=
0
)
{
throw
exception
(
SCORE_COUNT_ERROR
);
}
//todo 校验
String
lockKey
=
"member:operate:socre:"
+
req
.
getMemberId
();
boolean
lock
=
redisDistributedLock
.
lock
(
lockKey
,
5000
,
3
,
100
);
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/memberUserScore/MemberUserScoreController.java
View file @
00d72aad
...
...
@@ -2,6 +2,11 @@ package cn.iocoder.yudao.module.member.controller.admin.memberUserScore;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApiImpl
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateRespDTO
;
import
cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.service.memberUserScore.MemberUserScoreService
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreOperateQueryVO
;
...
...
@@ -18,6 +23,9 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
@Validated
...
...
@@ -28,6 +36,9 @@ public class MemberUserScoreController {
@Resource
private
MemberUserScoreService
userScoreService
;
@Resource
private
MemberUserScoreApiImpl
scoreApi
;
@PostMapping
(
"/page"
)
@ApiOperation
(
"获得会员积分分页"
)
...
...
@@ -41,7 +52,17 @@ public class MemberUserScoreController {
@ApiOperation
(
"操作积分"
)
@PreAuthorize
(
"@ss.hasPermission('member:user-score:operate')"
)
public
CommonResult
<
Boolean
>
operate
(
@Valid
@RequestBody
MemberUserScoreOperateQueryVO
query
)
{
userScoreService
.
operate
(
query
);
query
.
getMemberIds
().
forEach
(
memberId
->
{
Map
<
String
,
Object
>
extParam
=
new
HashMap
<>();
extParam
.
put
(
"comment"
,
query
.
getComment
());
MemberUserScoreOperateRespDTO
memberUserScoreOperateRespDTO
=
scoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
memberId
)
.
scoreCount
(
query
.
getScoreCount
())
.
operateType
(
ScoreOperateTypeEnum
.
parseByValue
(
query
.
getOperateType
()))
.
sourceType
(
ScoreSourceTypeEnum
.
MANUAL_OPERATE
)
.
extParam
(
extParam
)
.
build
());
});
return
success
(
null
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/memberUserScore/MemberUserScoreService.java
View file @
00d72aad
...
...
@@ -49,7 +49,5 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> {
*/
List
<
MemberUserScoreDO
>
getUserScoreList
(
MemberUserScoreQueryVO
query
);
void
operate
(
MemberUserScoreOperateQueryVO
query
);
void
updateUserScore
(
MemberUserScoreUpdateReqDTO
query
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/memberUserScore/MemberUserScoreServiceImpl.java
View file @
00d72aad
...
...
@@ -2,32 +2,25 @@ package cn.iocoder.yudao.module.member.service.memberUserScore;
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.MemberUserScoreApi
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApiImpl
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateRespDTO
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.memberUserScore.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.vo.memberUserScore.MemberUserScoreBackVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreOperateQueryVO
;
import
cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO
;
import
com.alibaba.excel.util.CollectionUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_ID_IS_NULL
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_SCORE_NOT_ENOUGH
;
/**
* 会员积分 Service 实现类
...
...
@@ -42,9 +35,6 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
@Resource
private
MemberUserScoreMapper
userScoreMapper
;
@Resource
private
MemberUserScoreApiImpl
scoreApi
;
@Override
public
void
deleteUserScore
(
Long
id
)
{
// 删除
...
...
@@ -74,38 +64,6 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
public
List
<
MemberUserScoreDO
>
getUserScoreList
(
MemberUserScoreQueryVO
query
)
{
return
userScoreMapper
.
selectList
(
query
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
operate
(
MemberUserScoreOperateQueryVO
query
)
{
if
(
CollectionUtils
.
isEmpty
(
query
.
getMemberIds
()))
{
throw
exception
(
MEMBER_ID_IS_NULL
);
}
if
(
query
.
getScoreCount
()
<=
0
)
{
throw
exception
(
SCORE_COUNT_ERROR
);
}
// 校验用户当前积分是否满足扣减要求
if
(
query
.
getOperateType
()
==
2
)
{
LambdaQueryWrapper
<
MemberUserScoreDO
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
in
(
MemberUserScoreDO:
:
getMemberId
,
query
.
getMemberIds
());
List
<
MemberUserScoreDO
>
userScoreDOList
=
this
.
list
(
wrapper
);
List
<
MemberUserScoreDO
>
notEnoughScoreList
=
userScoreDOList
.
stream
()
.
filter
(
item
->
item
.
getHoldScore
()
<
query
.
getScoreCount
()).
collect
(
Collectors
.
toList
());
if
(!
notEnoughScoreList
.
isEmpty
())
{
throw
exception
(
MEMBER_SCORE_NOT_ENOUGH
);
}
}
query
.
getMemberIds
().
forEach
(
memberId
->
{
Map
<
String
,
Object
>
extParam
=
new
HashMap
<>();
extParam
.
put
(
"comment"
,
query
.
getComment
());
MemberUserScoreOperateRespDTO
memberUserScoreOperateRespDTO
=
scoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
memberId
)
.
scoreCount
(
query
.
getScoreCount
())
.
operateType
(
ScoreOperateTypeEnum
.
parseByValue
(
query
.
getOperateType
()))
.
sourceType
(
ScoreSourceTypeEnum
.
MANUAL_OPERATE
)
.
extParam
(
extParam
)
.
build
());
});
}
@Override
public
void
updateUserScore
(
MemberUserScoreUpdateReqDTO
query
)
{
...
...
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