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
b7c806b3
Commit
b7c806b3
authored
Jul 26, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兑换礼品流程增加积分更新,兑换记录插入
parent
f6a68ca2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
12 deletions
+98
-12
DateUtils.java
...n/iocoder/yudao/framework/common/util/date/DateUtils.java
+9
-7
MemberCodeFlushTask.java
...dule/member/controller/admin/job/MemberCodeFlushTask.java
+1
-1
MemberUserScoreExpireTask.java
...ember/controller/admin/job/MemberUserScoreExpireTask.java
+75
-0
MemberUserScoreDetailDO.java
...object/memberUserScoreDetail/MemberUserScoreDetailDO.java
+11
-2
MemberUserScoreDetailServiceImpl.java
...mberUserScoreDetail/MemberUserScoreDetailServiceImpl.java
+2
-2
No files found.
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java
View file @
b7c806b3
...
@@ -3,8 +3,6 @@ package cn.iocoder.yudao.framework.common.util.date;
...
@@ -3,8 +3,6 @@ package cn.iocoder.yudao.framework.common.util.date;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -152,11 +150,15 @@ public class DateUtils {
...
@@ -152,11 +150,15 @@ public class DateUtils {
return
null
==
date
?
""
:
DateUtil
.
format
(
date
,
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
);
return
null
==
date
?
""
:
DateUtil
.
format
(
date
,
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
);
}
}
public
static
Date
getNextDayStart
(
Date
date
)
{
public
static
Date
getNextNDayStart
(
Date
date
,
int
days
)
{
LocalDateTime
localDateTime
=
LocalDateTime
.
ofInstant
(
date
.
toInstant
(),
ZoneId
.
systemDefault
());
Calendar
calendar
=
Calendar
.
getInstance
();
localDateTime
=
localDateTime
.
plusDays
(
1
).
withHour
(
0
).
withMinute
(
0
).
withSecond
(
0
);
calendar
.
setTime
(
date
);
java
.
time
.
LocalDate
localDate
=
localDateTime
.
toLocalDate
();
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
days
);
return
Date
.
from
(
localDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
calendar
.
getTime
();
}
}
public
static
Date
addDays
(
Date
date
,
int
days
)
{
public
static
Date
addDays
(
Date
date
,
int
days
)
{
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/job/MemberCodeFlushTask.java
View file @
b7c806b3
...
@@ -21,6 +21,6 @@ public class MemberCodeFlushTask implements JobHandler {
...
@@ -21,6 +21,6 @@ public class MemberCodeFlushTask implements JobHandler {
@Override
@Override
public
String
execute
(
String
param
)
throws
Exception
{
public
String
execute
(
String
param
)
throws
Exception
{
userService
.
historyCodeFlush
();
userService
.
historyCodeFlush
();
return
""
;
return
"
success
"
;
}
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/job/MemberUserScoreExpireTask.java
0 → 100644
View file @
b7c806b3
package
cn
.
iocoder
.
yudao
.
module
.
member
.
controller
.
admin
.
job
;
import
cn.iocoder.yudao.framework.common.util.date.DateUtils
;
import
cn.iocoder.yudao.framework.quartz.core.handler.JobHandler
;
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.memberUserScoreDetail.MemberUserScoreDetailDO
;
import
cn.iocoder.yudao.module.member.enums.MemberScoreStatueEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.service.memberUserScoreDetail.MemberUserScoreDetailService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 会员积分过期定时任务
*/
@Component
@Slf4j
public
class
MemberUserScoreExpireTask
implements
JobHandler
{
/**
* 会员积分的过期时间为每日的0点整
* 任务每天0点整运行,扫描当天0点过期的积分进行状态修改
* @param param 参数
* @return
* @throws Exception
*/
@Resource
private
MemberUserScoreDetailService
scoreDetailService
;
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
@Override
public
String
execute
(
String
param
)
throws
Exception
{
log
.
info
(
"member user score expire task running"
);
LambdaQueryWrapper
<
MemberUserScoreDetailDO
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
in
(
MemberUserScoreDetailDO:
:
getStatus
,
Lists
.
newArrayList
(
MemberScoreStatueEnum
.
AVAILABLE
.
getValue
(),
MemberScoreStatueEnum
.
PART_AVAILABLE
.
getValue
()));
wrapper
.
eq
(
MemberUserScoreDetailDO:
:
getExpireTime
,
DateUtils
.
getNextNDayStart
(
new
Date
(),
0
));
wrapper
.
orderByAsc
(
MemberUserScoreDetailDO:
:
getCreateTime
);
List
<
MemberUserScoreDetailDO
>
todoList
=
scoreDetailService
.
list
(
wrapper
);
log
.
info
(
"member user score expire task, to expire record count :{}"
,
todoList
.
size
());
if
(
CollectionUtils
.
isEmpty
(
todoList
))
{
return
"success"
;
}
for
(
MemberUserScoreDetailDO
memberUserScoreDetailDO
:
todoList
)
{
try
{
log
.
info
(
"score expire, score detail id :{}"
,
memberUserScoreDetailDO
.
getId
());
List
logIds
=
(
List
)
memberUserScoreDetailDO
.
getExtParamByKey
(
MemberUserScoreDetailDO
.
MemberUserScoreDetailExtKey
.
LOG_IDS
);
Map
<
String
,
Object
>
extParam
=
new
HashMap
<>();
extParam
.
put
(
"scoreLogIds"
,
logIds
);
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
memberUserScoreDetailDO
.
getMemberId
())
.
scoreCount
(
memberUserScoreDetailDO
.
getRemainCount
())
.
sourceType
(
ScoreSourceTypeEnum
.
SYSTEM_EXPIRED
)
.
extParam
(
extParam
)
.
build
());
}
catch
(
Exception
e
)
{
log
.
error
(
"member user score expire exception, data:{}"
,
memberUserScoreDetailDO
,
e
);
}
}
log
.
info
(
"member user score expire task finished"
);
return
"success"
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/memberUserScoreDetail/MemberUserScoreDetailDO.java
View file @
b7c806b3
package
cn
.
iocoder
.
yudao
.
module
.
member
.
dal
.
dataobject
.
memberUserScoreDetail
;
package
cn
.
iocoder
.
yudao
.
module
.
member
.
dal
.
dataobject
.
memberUserScoreDetail
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO
;
import
cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.vavr.collection.List
;
import
lombok.*
;
import
lombok.*
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Map
;
/**
/**
* 会员积分 DO
* 会员积分 DO
...
@@ -40,8 +45,7 @@ public class MemberUserScoreDetailDO extends BaseDO {
...
@@ -40,8 +45,7 @@ public class MemberUserScoreDetailDO extends BaseDO {
@Getter
@Getter
public
enum
MemberUserScoreDetailExtKey
{
public
enum
MemberUserScoreDetailExtKey
{
LOG_IDS
(
"logIds"
);
LOG_IDS
(
"scoreLogIds"
);
private
final
String
key
;
private
final
String
key
;
...
@@ -50,4 +54,9 @@ public class MemberUserScoreDetailDO extends BaseDO {
...
@@ -50,4 +54,9 @@ public class MemberUserScoreDetailDO extends BaseDO {
}
}
}
}
public
Object
getExtParamByKey
(
MemberUserScoreDetailExtKey
key
)
{
JSONObject
extParamJsonObject
=
JSONUtil
.
parseObj
(
extParam
);
return
extParamJsonObject
.
get
(
key
.
getKey
(),
List
.
class
);
}
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/memberUserScoreDetail/MemberUserScoreDetailServiceImpl.java
View file @
b7c806b3
...
@@ -19,7 +19,7 @@ import java.util.*;
...
@@ -19,7 +19,7 @@ import java.util.*;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
addDays
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
addDays
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
getNextDayStart
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
getNext
N
DayStart
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_ID_IS_NULL
;
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
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
MEMBER_SCORE_NOT_ENOUGH
;
...
@@ -90,7 +90,7 @@ public class MemberUserScoreDetailServiceImpl extends AbstractService<MemberUser
...
@@ -90,7 +90,7 @@ public class MemberUserScoreDetailServiceImpl extends AbstractService<MemberUser
memberUserScoreDetailDO
.
setRemainCount
(
reqDto
.
getScoreCount
());
memberUserScoreDetailDO
.
setRemainCount
(
reqDto
.
getScoreCount
());
memberUserScoreDetailDO
.
setCreateTime
(
new
Date
());
memberUserScoreDetailDO
.
setCreateTime
(
new
Date
());
if
(
reqDto
.
getExpireDays
()
!=
null
)
{
if
(
reqDto
.
getExpireDays
()
!=
null
)
{
memberUserScoreDetailDO
.
setExpireTime
(
addDays
(
getNext
DayStart
(
memberUserScoreDetailDO
.
getCreateTime
()
),
reqDto
.
getExpireDays
()));
memberUserScoreDetailDO
.
setExpireTime
(
addDays
(
getNext
NDayStart
(
memberUserScoreDetailDO
.
getCreateTime
(),
1
),
reqDto
.
getExpireDays
()));
}
}
Map
<
String
,
Object
>
extParma
=
new
HashMap
<>();
Map
<
String
,
Object
>
extParma
=
new
HashMap
<>();
extParma
.
put
(
MemberUserScoreDetailDO
.
MemberUserScoreDetailExtKey
.
LOG_IDS
.
getKey
(),
Lists
.
newArrayList
(
reqDto
.
getScoreLogId
()));
extParma
.
put
(
MemberUserScoreDetailDO
.
MemberUserScoreDetailExtKey
.
LOG_IDS
.
getKey
(),
Lists
.
newArrayList
(
reqDto
.
getScoreLogId
()));
...
...
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