Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
pseer
gxpt_ht
Commits
36fc5af2
Commit
36fc5af2
authored
Jan 22, 2024
by
hayden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除核销补偿逻辑
parent
78f5a43c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
57 deletions
+0
-57
CouponRetryTask.java
...artz/src/main/java/share/quartz/task/CouponRetryTask.java
+0
-57
No files found.
share-quartz/src/main/java/share/quartz/task/CouponRetryTask.java
View file @
36fc5af2
package
share
.
quartz
.
task
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
share.common.enums.ConsumerCouponStatusEnum
;
import
share.common.enums.UserStatusEnum
;
import
share.common.enums.YesNoEnum
;
import
share.system.domain.CouponLog
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SStore
;
import
share.system.service.CouponLogService
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISStoreService
;
import
share.system.service.QPService
;
import
share.system.service.impl.QPServiceImpl
;
import
java.util.*
;
...
...
@@ -25,17 +17,9 @@ import java.util.stream.Collectors;
@Component
(
"couponRetryTask"
)
public
class
CouponRetryTask
{
@Autowired
private
CouponLogService
couponLogService
;
@Autowired
private
QPService
qpService
;
@Autowired
private
ISStoreService
sStoreService
;
@Autowired
private
ISConsumerCouponService
sConsumerCouponService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QPServiceImpl
.
class
);
private
static
final
Integer
TRY_NUMBER
=
3
;
public
void
AuToRetryCoupon
()
{
LambdaQueryWrapper
<
SConsumerCoupon
>
consumerCouponWrapper
=
new
LambdaQueryWrapper
<>();
consumerCouponWrapper
.
eq
(
SConsumerCoupon:
:
getUseStatus
,
UserStatusEnum
.
UNUSED
.
getCode
());
...
...
@@ -50,46 +34,5 @@ public class CouponRetryTask {
if
(!
CollectionUtils
.
isEmpty
(
expiredSConsumerCounpons
))
{
sConsumerCouponService
.
updateBatchById
(
expiredSConsumerCounpons
);
}
LambdaQueryWrapper
<
CouponLog
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
CouponLog:
:
getStatus
,
YesNoEnum
.
no
.
getDisplay_3
());
queryWrapper
.
eq
(
CouponLog:
:
getNumber
,
TRY_NUMBER
);
List
<
CouponLog
>
list
=
couponLogService
.
list
(
queryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
;
}
//根据code分组
Map
<
String
,
List
<
CouponLog
>>
collect
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
CouponLog:
:
getCode
));
//门店id集合
List
<
Long
>
storeIds
=
list
.
stream
().
map
(
CouponLog:
:
getStoreId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
SStore
>
sStoreList
=
sStoreService
.
listByIds
(
storeIds
);
//遍历Map
collect
.
forEach
((
k
,
v
)
->
{
CouponLog
couponLog
=
v
.
get
(
0
);
SStore
sStore
=
sStoreList
.
stream
().
filter
(
s
->
s
.
getId
().
equals
(
couponLog
.
getStoreId
())).
findFirst
().
get
();
if
(
couponLog
.
getNumber
().
equals
(
TRY_NUMBER
))
{
for
(
int
i
=
0
;
i
<
TRY_NUMBER
;
i
++)
{
try
{
qpService
.
consume
(
couponLog
.
getCode
(),
1
,
sStore
.
getOpenShopUuid
(),
ConsumerCouponStatusEnum
.
TASK
.
getCode
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"验卷失败:{}"
,
e
.
getMessage
());
}
finally
{
couponLog
.
setNumber
(
couponLog
.
getNumber
()
-
1
);
couponLogService
.
updateById
(
couponLog
);
}
}
//根据code批量更新状态
LambdaUpdateWrapper
<
CouponLog
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
updateWrapper
.
eq
(
CouponLog:
:
getCode
,
k
);
//设置number为0
updateWrapper
.
set
(
CouponLog:
:
getNumber
,
0
);
couponLogService
.
update
(
updateWrapper
);
//更新优惠卷领取状态
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
sConsumerCoupon
.
setId
(
couponLog
.
getCouponId
());
sConsumerCoupon
.
setUseStatus
(
UserStatusEnum
.
EXPIRED
.
getCode
());
sConsumerCouponService
.
updateById
(
sConsumerCoupon
);
}
});
}
}
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