Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
向汉
/
uc-engine
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
07430150
...
074301509e9165f2eef10f24782ec0159e47ea89
authored
2022-04-20 02:38:01 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.优化
1 parent
79d9e9c5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
40 deletions
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/domain/PointsDetail.java
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/service/dto/PointsDetailDTO.java
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/service/dto/PointsDetailQueryCriteria.java
member-service-impl/src/main/java/com/topdraw/business/process/domian/TempRights.java
member-service-impl/src/main/java/com/topdraw/business/process/rest/PointsOperationController.java
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/PointsOperationServiceImpl.java
member-service-impl/src/test/java/com/topdraw/test/business/process/rest/PointsOperationControllerTest.java
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/domain/PointsDetail.java
View file @
0743015
...
...
@@ -84,6 +84,10 @@ public class PointsDetail implements Serializable {
@Column
(
name
=
"description"
,
nullable
=
false
)
private
String
description
;
// 商品id
@Column
(
name
=
"item_id"
)
private
Long
itemId
;
// 创建时间
@CreatedDate
@Column
(
name
=
"create_time"
)
...
...
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/service/dto/PointsDetailDTO.java
View file @
0743015
...
...
@@ -54,6 +54,9 @@ public class PointsDetailDTO implements Serializable {
// 积分变化描述,用于管理侧显示
private
String
description
;
// 商品id
private
Long
itemId
;
// 创建时间
private
Timestamp
createTime
;
...
...
member-service-impl/src/main/java/com/topdraw/business/module/points/detail/service/dto/PointsDetailQueryCriteria.java
deleted
100644 → 0
View file @
79d9e9c
package
com
.
topdraw
.
business
.
module
.
points
.
detail
.
service
.
dto
;
import
com.topdraw.annotation.Query
;
import
lombok.Data
;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Data
public
class
PointsDetailQueryCriteria
{
@Query
(
type
=
Query
.
Type
.
EQUAL
)
private
Long
memberId
;
@Query
(
type
=
Query
.
Type
.
EQUAL
)
private
Long
accountId
;
}
member-service-impl/src/main/java/com/topdraw/business/process/domian/TempRights.java
View file @
0743015
...
...
@@ -56,7 +56,6 @@ public class TempRights {
/** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */
@Transient
@NotNull
(
message
=
"设备类型不得为空"
)
protected
Integer
deviceType
;
/** 应用code(表示当前用户对应应用的标识) */
...
...
member-service-impl/src/main/java/com/topdraw/business/process/rest/PointsOperationController.java
View file @
0743015
package
com
.
topdraw
.
business
.
process
.
rest
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.aop.log.Log
;
import
com.topdraw.business.module.member.service.MemberService
;
import
com.topdraw.business.module.member.service.dto.MemberDTO
;
import
com.topdraw.business.module.points.detail.service.PointsDetailService
;
import
com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria
;
import
com.topdraw.business.module.user.iptv.service.UserTvService
;
import
com.topdraw.business.module.user.iptv.service.dto.UserTvDTO
;
import
com.topdraw.business.module.user.weixin.service.UserWeixinService
;
...
...
@@ -15,10 +14,12 @@ import com.topdraw.business.process.service.dto.CustomPointsResult;
import
com.topdraw.business.process.service.PointsOperationService
;
import
com.topdraw.common.ResultInfo
;
import
com.topdraw.config.LocalConstants
;
import
com.topdraw.exception.BadRequestException
;
import
com.topdraw.exception.GlobeExceptionMsg
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -33,6 +34,7 @@ import java.util.Objects;
@Api
(
tags
=
"PointsOperation管理"
)
@RestController
@RequestMapping
(
"/uce/pointsOperation"
)
@Slf4j
public
class
PointsOperationController
{
@Autowired
...
...
@@ -42,10 +44,9 @@ public class PointsOperationController {
@Autowired
private
UserWeixinService
userWeixinService
;
@Autowired
private
PointsDetailService
pointsDetailService
;
@Autowired
private
PointsOperationService
pointsOperationService
;
@Log
(
"清除过期积分并计算总积分,供客户端会员查询积分时调用"
)
@GetMapping
(
value
=
"/cleanInvalidPointsAndCalculateCurrentPoints/{id}"
)
@ApiOperation
(
"清除过期积分并计算总积分,供客户端会员查询积分时调用"
)
@AnonymousAccess
...
...
@@ -54,10 +55,11 @@ public class PointsOperationController {
return
ResultInfo
.
success
(
Objects
.
isNull
(
aLong
)
?
0L
:
aLong
);
}
@PostMapping
(
value
=
"/grantPointsByManual"
)
@Log
(
"手动发放积分"
)
@PostMapping
(
value
=
"/addPoints"
)
@ApiOperation
(
"手动发放积分"
)
@AnonymousAccess
public
ResultInfo
grantPointsByManual
(
@Validated
@RequestBody
TempPoints
tempPoints
)
{
public
ResultInfo
addPoints
(
@Validated
@RequestBody
TempPoints
tempPoints
)
{
Long
memberId
=
tempPoints
.
getMemberId
();
Long
points
=
tempPoints
.
getPoints
();
Assert
.
notNull
(
memberId
,
"memberId can't be null!"
);
...
...
@@ -172,6 +174,33 @@ public class PointsOperationController {
return
ResultInfo
.
success
(
Arrays
.
asList
(
b
),
description
);
}
@Log
(
"积分兑换商品"
)
@PostMapping
(
value
=
"/consumeItemPoints"
)
@ApiOperation
(
"积分兑换商品"
)
@AnonymousAccess
public
ResultInfo
consumeItemPoints
(
@Validated
@RequestBody
TempPoints
tempPoints
)
{
log
.
info
(
"pointsOperation ==>> consumeItemPoints ==>> param ==>> {}"
,
tempPoints
);
Long
memberId
=
tempPoints
.
getMemberId
();
Assert
.
notNull
(
memberId
,
GlobeExceptionMsg
.
MEMBER_ID_IS_NULL
);
Long
points
=
tempPoints
.
getPoints
();
if
(
Objects
.
isNull
(
points
)
||
points
<=
0
)
{
log
.
info
(
"points ==>> {}"
,
points
);
throw
new
BadRequestException
(
"points error"
);
}
Long
itemId
=
tempPoints
.
getItemId
();
Assert
.
notNull
(
itemId
,
"itemId can't be null"
);
// 积分兑换商品
tempPoints
.
setEvtType
(
30
);
tempPoints
.
setPointsType
(
0
);
CustomPointsResult
b
=
this
.
pointsOperationService
.
customPoints
(
tempPoints
);
String
description
=
"操作成功"
;
if
(!
b
.
isResult
())
{
description
=
"操作失败,积分不足"
;
}
return
ResultInfo
.
success
(
Arrays
.
asList
(
b
),
description
);
}
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/PointsOperationServiceImpl.java
View file @
0743015
...
...
@@ -74,6 +74,8 @@ public class PointsOperationServiceImpl implements PointsOperationService {
@AsyncMqSend
public
void
asyncPointsAvailable
(
PointsAvailable
pointsAvailable
)
{}
@AsyncMqSend
public
void
asyncDeletePointsAvailable
(
PointsAvailable
pointsAvailable
)
{}
@AsyncMqSend
public
void
asyncPointsDetail
(
PointsDetail
pointsDetail
)
{}
@Override
...
...
@@ -111,6 +113,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
this
.
redisUtils
.
doLock
(
"member::id::"
+
memberId
.
toString
());
//1.删除过期的积分
this
.
cleanInvalidAvailablePointsByMemberId
(
memberId
);
log
.
info
(
"删除过期的积分 ==>> cleanInvalidAvailablePointsByMemberId ==>> "
);
// 1.判断可用积分是否够用
boolean
b
=
this
.
checkAvailablePoints
(
tempPoints
);
// 3.当前可用总积分
...
...
@@ -123,6 +126,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
this
.
customAvailablePoints
(
tempPoints
,
pointsAvailableDTOS
);
// 3.添加积分明细
this
.
doInsertTrPointsDetailByAvailablePointsMap
(
tempPoints
,
customAvailablePointsMap
,
currentPoints
);
log
.
info
(
"添加积分明细 ==>> doInsertTrPointsDetailByAvailablePointsMap ==>> "
);
// 4.更新可用积分表,超过的删除,剩余的新增
long
totalPoints
=
this
.
doFreshTrPointsAvailableByAvailablePointsMap
(
customAvailablePointsMap
,
currentPoints
);
// 5.即将过期的积分
...
...
@@ -164,6 +168,10 @@ public class PointsOperationServiceImpl implements PointsOperationService {
for
(
PointsAvailableDTO
pointsAvailableDTO
:
pointsAvailableDTOS1
)
{
totalCustomAvailablePoints
=
(
totalCustomAvailablePoints
+
pointsAvailableDTO
.
getPoints
());
this
.
pointsAvailableService
.
delete4Custom
(
pointsAvailableDTO
.
getId
());
PointsAvailable
pointsAvailable
=
new
PointsAvailable
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailable
);
((
PointsOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncDeletePointsAvailable
(
pointsAvailable
);
}
}
...
...
@@ -172,10 +180,12 @@ public class PointsOperationServiceImpl implements PointsOperationService {
if
(!
CollectionUtils
.
isEmpty
(
pointsAvailableDTOS2
))
{
PointsAvailableDTO
pointsAvailableDTO
=
pointsAvailableDTOS2
.
get
(
0
);
PointsAvailable
pointsAvailable
=
new
PointsAvailable
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailable
);
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailable
);
pointsAvailable
.
setId
(
null
);
pointsAvailable
.
setCode
(
String
.
valueOf
(
IdWorker
.
generator
()));
this
.
pointsAvailableService
.
create4Custom
(
pointsAvailable
);
((
PointsOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncPointsAvailable
(
pointsAvailable
);
}
}
...
...
@@ -198,12 +208,13 @@ public class PointsOperationServiceImpl implements PointsOperationService {
PointsAvailableDTO
pointsAvailableDTO
=
pointsAvailableDTOS
.
get
(
0
);
Long
memberId
=
pointsAvailableDTO
.
getMemberId
();
TempPoints
tempPoints1
=
new
TempPoints
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
tempPoints1
);
BeanUtils
.
copyProperties
(
tempPoints
,
tempPoints1
);
tempPoints1
.
setPoints
(-(
Math
.
abs
(
points
)));
Long
totalPoints
=
this
.
calculateTotalPoints
(
tempPoints1
,
currentPoints
);
this
.
doInsertTrPointsDetail
(
memberId
,
tempPoints1
,
currentPoints
,
totalPoints
);
TempPoints
_tempPoints
=
new
TempPoints
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
_tempPoints
);
BeanUtils
.
copyProperties
(
tempPoints
,
_tempPoints
);
_tempPoints
.
setPoints
(-(
Math
.
abs
(
points
)));
Long
totalPoints
=
this
.
calculateTotalPoints
(
_tempPoints
,
currentPoints
);
this
.
doInsertTrPointsDetail
(
memberId
,
_tempPoints
,
currentPoints
,
totalPoints
);
}
}
...
...
@@ -244,7 +255,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
long
beyond
=
points1_
-
points
;
// 新增
PointsAvailableDTO
pointsAvailableDTO2
=
new
PointsAvailableDTO
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailableDTO2
);
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailableDTO2
);
pointsAvailableDTO2
.
setPoints
(
beyond
);
pointsAvailableDTOS2
.
add
(
pointsAvailableDTO2
);
...
...
@@ -252,7 +263,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
long
suit
=
points1
-
beyond
;
// 扣除
PointsAvailableDTO
pointsAvailableDTO1
=
new
PointsAvailableDTO
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailableDTO1
);
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailableDTO1
);
pointsAvailableDTO1
.
setPoints
(
suit
);
pointsAvailableDTOS1
.
add
(
pointsAvailableDTO1
);
...
...
@@ -371,7 +382,12 @@ public class PointsOperationServiceImpl implements PointsOperationService {
* @param pointsAvailableDTO
*/
private
void
doDeleteInvalidAvailablePoints
(
PointsAvailableDTO
pointsAvailableDTO
)
{
this
.
pointsAvailableService
.
delete4Custom
(
pointsAvailableDTO
.
getId
());
PointsAvailable
pointsAvailable
=
new
PointsAvailable
();
BeanUtils
.
copyProperties
(
pointsAvailableDTO
,
pointsAvailable
);
((
PointsOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncDeletePointsAvailable
(
pointsAvailable
);
}
/**
...
...
@@ -381,7 +397,8 @@ public class PointsOperationServiceImpl implements PointsOperationService {
private
void
doCreatePointsDetail
(
PointsAvailableDTO
pointsAvailableDTO
)
{
Long
memberId
=
pointsAvailableDTO
.
getMemberId
();
// 原始积分
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
memberId
);
// 原始积分
long
availablePoints
=
this
.
pointsAvailableService
.
findTotalPointsByMemberId
(
memberId
);
//this.findAvailablePointsByMemberId(memberId);
// 过期积分
long
l
=
pointsAvailableDTO
.
getPoints
();
...
...
@@ -399,7 +416,11 @@ public class PointsOperationServiceImpl implements PointsOperationService {
pointsDetail
.
setEvtType
(
99
);
pointsDetail
.
setCreateTime
(
TimestampUtil
.
now
());
pointsDetail
.
setUpdateTime
(
TimestampUtil
.
now
());
pointsDetail
.
setMemberCode
(
memberDTO
.
getCode
());
this
.
pointsDetailService
.
create4Custom
(
pointsDetail
);
log
.
info
(
"asyncPointsDetail ==>> pointsDetail ==>> {}"
,
pointsDetail
);
((
PointsOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncPointsDetail
(
pointsDetail
);
}
/**
...
...
@@ -544,11 +565,13 @@ public class PointsOperationServiceImpl implements PointsOperationService {
*/
private
void
doInsertTrPointsDetail
(
Long
memberId
,
TempPoints
tempPoints
,
Long
currentPoints
,
Long
totalPoints
){
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
memberId
);
PointsDetail
pointsDetail
=
new
PointsDetail
();
BeanUtils
.
copyProperties
(
tempPoints
,
pointsDetail
);
BeanUtils
.
copyProperties
(
tempPoints
,
pointsDetail
);
pointsDetail
.
setId
(
null
);
pointsDetail
.
setMemberId
(
memberId
);
pointsDetail
.
setMemberCode
(
tempPoints
.
getMember
Code
());
pointsDetail
.
setMemberCode
(
memberDTO
.
get
Code
());
pointsDetail
.
setCode
(
String
.
valueOf
(
IdWorker
.
generator
()));
pointsDetail
.
setPoints
(
tempPoints
.
getPoints
());
pointsDetail
.
setOriginalPoints
(
currentPoints
);
...
...
member-service-impl/src/test/java/com/topdraw/test/business/process/rest/PointsOperationControllerTest.java
View file @
0743015
...
...
@@ -50,7 +50,7 @@ public class PointsOperationControllerTest extends BaseTest {
tempPoints
.
setEvtType
(
1
);
tempPoints
.
setActivityId
(
1L
);
String
s
=
JSON
.
toJSONString
(
tempPoints
);
ResultInfo
byId
=
this
.
pointsOperationController
.
grantPointsByManual
(
tempPoints
);
ResultInfo
byId
=
this
.
pointsOperationController
.
addPoints
(
tempPoints
);
LOG
.
info
(
"===>>>"
+
byId
);
}
...
...
Please
register
or
sign in
to post a comment