记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
fdb270b9
Commit
fdb270b9
authored
Oct 20, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/pre' into pre
parents
ffd6d7df
83432373
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
8 deletions
+67
-8
CandyCouponDueTaskController.java
...m/controller/candy/task/CandyCouponDueTaskController.java
+67
-8
No files found.
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/candy/task/CandyCouponDueTaskController.java
View file @
fdb270b9
...
@@ -8,6 +8,7 @@ import com.liquidnet.service.base.ResponseDto;
...
@@ -8,6 +8,7 @@ import com.liquidnet.service.base.ResponseDto;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto
;
import
com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto
;
import
com.liquidnet.service.candy.dto.CandyCouponCodeDto
;
import
com.liquidnet.service.candy.dto.CandyCouponCodeDto
;
import
com.liquidnet.service.candy.dto.CandyUserCouponBasicDto
;
import
com.liquidnet.service.candy.entity.CandyCommonCoupon
;
import
com.liquidnet.service.candy.entity.CandyCommonCoupon
;
import
com.liquidnet.service.candy.entity.CandyCoupon
;
import
com.liquidnet.service.candy.entity.CandyCoupon
;
import
com.liquidnet.service.candy.entity.CandyCouponCode
;
import
com.liquidnet.service.candy.entity.CandyCouponCode
;
...
@@ -30,6 +31,7 @@ import java.util.List;
...
@@ -30,6 +31,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
/**
/**
* <p>
* <p>
...
@@ -59,6 +61,8 @@ public class CandyCouponDueTaskController {
...
@@ -59,6 +61,8 @@ public class CandyCouponDueTaskController {
@Autowired
@Autowired
private
PlatformCandyUserCouponService
platformCandyUserCouponService
;
private
PlatformCandyUserCouponService
platformCandyUserCouponService
;
private
static
final
String
OPERATOR_CHECK
=
"CHECK"
;
/**
/**
* <p>
* <p>
* 兑换类
* 兑换类
...
@@ -80,7 +84,7 @@ public class CandyCouponDueTaskController {
...
@@ -80,7 +84,7 @@ public class CandyCouponDueTaskController {
AtomicInteger
pl
=
new
AtomicInteger
();
AtomicInteger
pl
=
new
AtomicInteger
();
int
remainCount
=
totalCount
;
int
remainCount
=
totalCount
;
int
num
=
0
,
pSize
=
1000
;
int
num
=
0
,
pSize
=
1000
;
log
.
info
(
"券到期检查处理:兑换码[到期总记录数:{}] >>> BEGIN BEGIN BEGIN"
,
totalCount
);
log
.
info
(
"券
码
到期检查处理:兑换码[到期总记录数:{}] >>> BEGIN BEGIN BEGIN"
,
totalCount
);
ArrayList
<
CandyCouponCode
>
updateCouponCodeList
=
ObjectUtil
.
getCandyCouponCodeArrayList
();
ArrayList
<
CandyCouponCode
>
updateCouponCodeList
=
ObjectUtil
.
getCandyCouponCodeArrayList
();
couponCodeQueryWrapper
.
select
(
CandyCouponCode:
:
getMid
,
CandyCouponCode:
:
getCcode
);
couponCodeQueryWrapper
.
select
(
CandyCouponCode:
:
getMid
,
CandyCouponCode:
:
getCcode
);
...
@@ -89,7 +93,7 @@ public class CandyCouponDueTaskController {
...
@@ -89,7 +93,7 @@ public class CandyCouponDueTaskController {
updateCouponCodeList
.
clear
();
updateCouponCodeList
.
clear
();
LambdaQueryWrapper
<
CandyCouponCode
>
couponCodeLambdaQueryWrapper
=
couponCodeQueryWrapper
.
clone
();
LambdaQueryWrapper
<
CandyCouponCode
>
couponCodeLambdaQueryWrapper
=
couponCodeQueryWrapper
.
clone
();
String
lastLimitSql
=
"LIMIT "
+
(
num
*
pSize
)
+
","
+
pSize
;
String
lastLimitSql
=
"LIMIT "
+
0
+
","
+
pSize
;
couponCodeLambdaQueryWrapper
.
last
(
lastLimitSql
);
couponCodeLambdaQueryWrapper
.
last
(
lastLimitSql
);
List
<
CandyCouponCode
>
couponCodeList
=
platformCandyCouponCodeService
.
list
(
couponCodeLambdaQueryWrapper
);
List
<
CandyCouponCode
>
couponCodeList
=
platformCandyCouponCodeService
.
list
(
couponCodeLambdaQueryWrapper
);
...
@@ -98,12 +102,13 @@ public class CandyCouponDueTaskController {
...
@@ -98,12 +102,13 @@ public class CandyCouponDueTaskController {
CandyCouponCode
couponCode
=
couponCodeList
.
get
(
i
);
CandyCouponCode
couponCode
=
couponCodeList
.
get
(
i
);
couponCode
.
setState
(
3
);
couponCode
.
setState
(
3
);
couponCode
.
setOperator
(
OPERATOR_CHECK
);
couponCode
.
setUpdatedAt
(
now
);
couponCode
.
setUpdatedAt
(
now
);
updateCouponCodeList
.
add
(
couponCode
);
updateCouponCodeList
.
add
(
couponCode
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
c
ouponCodeList
))
{
if
(!
CollectionUtils
.
isEmpty
(
updateC
ouponCodeList
))
{
if
(
platformCandyCouponCodeService
.
updateBatchById
(
updateCouponCodeList
,
updateCouponCodeList
.
size
()))
{
if
(
platformCandyCouponCodeService
.
updateBatchById
(
updateCouponCodeList
,
updateCouponCodeList
.
size
()))
{
updateCouponCodeList
.
forEach
(
r
->
{
updateCouponCodeList
.
forEach
(
r
->
{
String
ccKey
=
CandyRedisConst
.
BASIC_COUPON_CODE
.
concat
(
r
.
getCcode
());
String
ccKey
=
CandyRedisConst
.
BASIC_COUPON_CODE
.
concat
(
r
.
getCcode
());
...
@@ -123,9 +128,9 @@ public class CandyCouponDueTaskController {
...
@@ -123,9 +128,9 @@ public class CandyCouponDueTaskController {
num
++;
num
++;
remainCount
-=
pSize
;
remainCount
-=
pSize
;
log
.
info
(
"券到期检查处理中:兑换码[到期总记录数:{},单次处理:{},剩余处理数:{}]"
,
totalCount
,
lastLimitSql
,
remainCount
);
log
.
info
(
"券
码
到期检查处理中:兑换码[到期总记录数:{},单次处理:{},剩余处理数:{}]"
,
totalCount
,
lastLimitSql
,
remainCount
);
}
}
log
.
info
(
"券到期检查处理:兑换码[到期总记录数:{},处理总数:{}] >>> END END END"
,
totalCount
,
pl
.
get
());
log
.
info
(
"券
码
到期检查处理:兑换码[到期总记录数:{},处理总数:{}] >>> END END END"
,
totalCount
,
pl
.
get
());
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
}
...
@@ -167,7 +172,7 @@ public class CandyCouponDueTaskController {
...
@@ -167,7 +172,7 @@ public class CandyCouponDueTaskController {
couponQueryWrapper
.
orderByAsc
(
CandyCoupon:
:
getMid
);
couponQueryWrapper
.
orderByAsc
(
CandyCoupon:
:
getMid
);
while
(
remainCount
>
0
)
{
while
(
remainCount
>
0
)
{
LambdaQueryWrapper
<
CandyCoupon
>
couponLambdaQueryWrapper
=
couponQueryWrapper
.
clone
();
LambdaQueryWrapper
<
CandyCoupon
>
couponLambdaQueryWrapper
=
couponQueryWrapper
.
clone
();
String
lastLimitSql
=
"LIMIT "
+
(
num
*
pSize
)
+
","
+
pSize
;
String
lastLimitSql
=
"LIMIT "
+
0
+
","
+
pSize
;
couponLambdaQueryWrapper
.
last
(
lastLimitSql
);
couponLambdaQueryWrapper
.
last
(
lastLimitSql
);
List
<
CandyCoupon
>
couponList
=
platformCandyCouponService
.
list
(
couponLambdaQueryWrapper
);
List
<
CandyCoupon
>
couponList
=
platformCandyCouponService
.
list
(
couponLambdaQueryWrapper
);
...
@@ -178,7 +183,7 @@ public class CandyCouponDueTaskController {
...
@@ -178,7 +183,7 @@ public class CandyCouponDueTaskController {
List
<
CandyCommonCoupon
>
inCommonCouponList
=
commonCouponIdToListMap
.
get
(
coupon
.
getCouponId
());
List
<
CandyCommonCoupon
>
inCommonCouponList
=
commonCouponIdToListMap
.
get
(
coupon
.
getCouponId
());
inCommonCouponList
.
forEach
(
r
->
{
inCommonCouponList
.
forEach
(
r
->
{
r
.
setState
(
3
);
r
.
setState
(
3
);
r
.
setOperator
(
"system"
);
r
.
setOperator
(
OPERATOR_CHECK
);
r
.
setUpdatedAt
(
now
);
r
.
setUpdatedAt
(
now
);
updateCommonCouponList
.
add
(
r
);
updateCommonCouponList
.
add
(
r
);
...
@@ -238,8 +243,62 @@ public class CandyCouponDueTaskController {
...
@@ -238,8 +243,62 @@ public class CandyCouponDueTaskController {
int
num
=
0
,
pSize
=
1000
;
int
num
=
0
,
pSize
=
1000
;
log
.
info
(
"券到期检查处理:私有券[到期总记录数:{}] >>> BEGIN BEGIN BEGIN"
,
totalCount
);
log
.
info
(
"券到期检查处理:私有券[到期总记录数:{}] >>> BEGIN BEGIN BEGIN"
,
totalCount
);
ArrayList
<
CandyUserCoupon
>
candyUserCouponArrayList
=
ObjectUtil
.
getCandyUserCouponArrayList
();
ArrayList
<
CandyUserCoupon
>
updateUserCouponList
=
ObjectUtil
.
getCandyUserCouponArrayList
();
userCouponQueryWrapper
.
select
(
CandyUserCoupon:
:
getMid
,
CandyUserCoupon:
:
getUcouponId
);
userCouponQueryWrapper
.
orderByAsc
(
CandyUserCoupon:
:
getMid
);
while
(
remainCount
>
0
)
{
updateUserCouponList
.
clear
();
LambdaQueryWrapper
<
CandyUserCoupon
>
userCouponLambdaQueryWrapper
=
userCouponQueryWrapper
.
clone
();
String
lastLimitSql
=
"LIMIT "
+
0
+
","
+
pSize
;
userCouponLambdaQueryWrapper
.
last
(
lastLimitSql
);
List
<
CandyUserCoupon
>
userCouponList
=
platformCandyUserCouponService
.
list
(
userCouponLambdaQueryWrapper
);
int
listSize
=
CollectionUtils
.
isEmpty
(
userCouponList
)
?
-
1
:
userCouponList
.
size
();
for
(
int
i
=
0
;
i
<
listSize
;
i
++)
{
CandyUserCoupon
userCoupon
=
userCouponList
.
get
(
i
);
userCoupon
.
setState
(
3
);
userCoupon
.
setOperator
(
OPERATOR_CHECK
);
userCoupon
.
setUpdatedAt
(
now
);
updateUserCouponList
.
add
(
userCoupon
);
}
if
(!
CollectionUtils
.
isEmpty
(
updateUserCouponList
))
{
if
(
platformCandyUserCouponService
.
updateBatchById
(
updateUserCouponList
,
updateUserCouponList
.
size
()))
{
// 需要更新的用户券记录按UID分组处理
Map
<
String
,
List
<
CandyUserCoupon
>>
userCouponListByUidMap
=
updateUserCouponList
.
stream
().
collect
(
Collectors
.
groupingBy
(
CandyUserCoupon:
:
getUid
));
userCouponListByUidMap
.
forEach
((
uid
,
updateUserCouponListByUid
)
->
{
String
uckey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
uid
);
List
<
CandyUserCouponBasicDto
>
vos
=
(
List
<
CandyUserCouponBasicDto
>)
redisUtil
.
get
(
uckey
);
if
(!
CollectionUtils
.
isEmpty
(
vos
))
{
updateUserCouponListByUid
.
forEach
(
r
->
{
int
idx
=
IntStream
.
range
(
0
,
vos
.
size
())
.
filter
(
i
->
vos
.
get
(
i
).
getUcouponId
().
equals
(
r
.
getUcouponId
()))
.
findFirst
().
orElse
(-
1
);
if
(
idx
!=
-
1
)
{
CandyUserCouponBasicDto
dto
=
vos
.
get
(
idx
);
dto
.
setState
(
3
);
vos
.
set
(
idx
,
dto
);
}
pl
.
getAndIncrement
();
});
redisUtil
.
set
(
uckey
,
vos
);
}
});
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券到期处理失败[updateUserCouponList.size=%s]"
,
updateUserCouponList
.
size
()));
}
}
num
++;
remainCount
-=
pSize
;
log
.
info
(
"券到期检查处理中:私有券[到期总记录数:{},单次处理:{},剩余处理数:{}]"
,
totalCount
,
lastLimitSql
,
remainCount
);
}
log
.
info
(
"券到期检查处理:私有券[到期总记录数:{},处理总数:{}] >>> END END END"
,
totalCount
,
pl
.
get
());
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
}
}
}
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