记得上下班打卡 | 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
d6aa8e96
Commit
d6aa8e96
authored
Sep 02, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兑换码+兑换有效时间段;
parent
8fe8790b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
194 additions
and
45 deletions
+194
-45
CandyCouponCodeDto.java
...a/com/liquidnet/service/candy/dto/CandyCouponCodeDto.java
+11
-6
CandyCouponCode.java
...a/com/liquidnet/service/candy/entity/CandyCouponCode.java
+10
-0
db_ln_candy_initialdata.sql
...idnet-service-candy-impl/docu/db_ln_candy_initialdata.sql
+3
-1
CandyCouponDueTaskController.java
...m/controller/candy/task/CandyCouponDueTaskController.java
+168
-0
CandyCouponTaskController.java
...form/controller/candy/task/CandyCouponTaskController.java
+0
-38
PlatformCandyCouponService.java
...atform/service/impl/candy/PlatformCandyCouponService.java
+2
-0
No files found.
liquidnet-bus-do/liquidnet-service-candy-do/src/main/java/com/liquidnet/service/candy/dto/CandyCouponCodeDto.java
View file @
d6aa8e96
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.service.candy.entity.CandyCouponCode;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
@Data
public
class
CandyCouponCodeDto
implements
Serializable
,
Cloneable
{
...
...
@@ -11,12 +12,14 @@ public class CandyCouponCodeDto implements Serializable, Cloneable {
private
String
ccode
;
private
String
couponId
;
private
Integer
state
;
// private String redeemUid;
// private String redeemMobile;
// private LocalDateTime redeemAt;
// private LocalDateTime createdAt;
// private LocalDateTime updatedAt;
// private String comment;
//private String redeemUid;
//private String redeemMobile;
//private LocalDateTime redeemAt;
private
LocalDateTime
redeemStart
;
private
LocalDateTime
redeemStop
;
//private LocalDateTime createdAt;
//private LocalDateTime updatedAt;
//private String comment;
private
static
final
CandyCouponCodeDto
obj
=
new
CandyCouponCodeDto
();
...
...
@@ -33,6 +36,8 @@ public class CandyCouponCodeDto implements Serializable, Cloneable {
this
.
setCcode
(
source
.
getCcode
());
this
.
setCouponId
(
source
.
getCouponId
());
this
.
setState
(
source
.
getState
());
this
.
setRedeemStart
(
source
.
getRedeemStart
());
this
.
setRedeemStop
(
source
.
getRedeemStop
());
return
this
;
}
}
liquidnet-bus-do/liquidnet-service-candy-do/src/main/java/com/liquidnet/service/candy/entity/CandyCouponCode.java
View file @
d6aa8e96
...
...
@@ -53,6 +53,16 @@ public class CandyCouponCode implements Serializable {
*/
private
LocalDateTime
redeemAt
;
/**
* 兑换开放时间
*/
private
LocalDateTime
redeemStart
;
/**
* 兑换停止时间
*/
private
LocalDateTime
redeemStop
;
private
LocalDateTime
createdAt
;
private
LocalDateTime
updatedAt
;
...
...
liquidnet-bus-service/liquidnet-service-candy/liquidnet-service-candy-impl/docu/db_ln_candy_initialdata.sql
View file @
d6aa8e96
...
...
@@ -92,8 +92,10 @@ create table candy_coupon_code
redeem_uid
varchar
(
64
)
comment
'兑换用户UID'
,
redeem_mobile
varchar
(
64
)
comment
'兑换用户手机号'
,
redeem_at
datetime
(
3
)
comment
'兑换时间'
,
redeem_start
datetime
(
3
)
comment
'兑换开放时间'
,
redeem_stop
datetime
(
3
)
comment
'兑换停止时间'
,
created_at
datetime
(
3
)
not
null
,
updated_at
datetime
(
3
),
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/candy/task/CandyCouponDueTaskController.java
0 → 100644
View file @
d6aa8e96
package
com
.
liquidnet
.
service
.
platform
.
controller
.
candy
.
task
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto
;
import
com.liquidnet.service.candy.entity.CandyCommonCoupon
;
import
com.liquidnet.service.candy.entity.CandyCoupon
;
import
com.liquidnet.service.platform.service.impl.candy.PlatformCandyCommonCouponService
;
import
com.liquidnet.service.platform.service.impl.candy.PlatformCandyCouponService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* <p>
* 券到期检查任务
* </p>
* - 兑换类
* --- 检查[coupon.redeem_stop]
* - 发放类
* --- 公有券:检查[coupon.expire_at]
* --- 私有券:检查[user_coupon.dued_at]
*
* @author zhanggb
* Created by IntelliJ IDEA at 2021/9/1
*/
@Slf4j
@RestController
@RequestMapping
(
"ccoupon/task/due"
)
public
class
CandyCouponDueTaskController
{
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
PlatformCandyCouponService
platformCandyCouponService
;
@Autowired
private
PlatformCandyCommonCouponService
platformCandyCommonCouponService
;
/**
* <p>
* 兑换类
* </p>
* - 更新兑换码状态
* - 同步REDIS.DTO
*
* @return ResponseDto<String>
*/
@PutMapping
(
"redeem"
)
public
ResponseDto
<
String
>
processForRedeem
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
return
ResponseDto
.
success
();
}
/**
* <p>
* 发放类-公有券
* </p>
* - 更新公有券状态
* - 同步REDIS.DTO
*
* @return ResponseDto<String>
*/
@PutMapping
(
"common"
)
public
ResponseDto
<
String
>
processForCommon
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
// 查取状态可用的公有券
LambdaQueryWrapper
<
CandyCommonCoupon
>
commonCouponQueryWrapper
=
Wrappers
.
lambdaQuery
(
CandyCommonCoupon
.
class
);
commonCouponQueryWrapper
.
eq
(
CandyCommonCoupon:
:
getState
,
1
);
commonCouponQueryWrapper
.
select
(
CandyCommonCoupon:
:
getMid
,
CandyCommonCoupon:
:
getCcouponId
,
CandyCommonCoupon:
:
getCouponId
);
List
<
CandyCommonCoupon
>
commonCouponList
=
platformCandyCommonCouponService
.
list
(
commonCouponQueryWrapper
);
log
.
info
(
"券到期检查:公有券[可用券总数:{}] >>> BEGIN BEGIN BEGIN"
,
commonCouponList
.
size
());
if
(!
CollectionUtils
.
isEmpty
(
commonCouponList
))
{
List
<
CandyCommonCoupon
>
updateCommonCouponList
=
new
ArrayList
<>();
// 查取状态可用的公有券 - 券ID集
Object
[]
commonCouponIdArr
=
commonCouponList
.
stream
().
map
(
CandyCommonCoupon:
:
getCouponId
).
toArray
();
Map
<
String
,
List
<
CandyCommonCoupon
>>
commonCouponIdToListMap
=
commonCouponList
.
stream
().
collect
(
Collectors
.
groupingBy
(
CandyCommonCoupon:
:
getCouponId
));
// 查取状态可用的公有券 - 对应的过期券列表
LambdaQueryWrapper
<
CandyCoupon
>
couponQueryWrapper
=
Wrappers
.
lambdaQuery
(
CandyCoupon
.
class
);
couponQueryWrapper
.
in
(
CandyCoupon:
:
getCouponId
,
commonCouponIdArr
);
couponQueryWrapper
.
le
(
CandyCoupon:
:
getExpireAt
,
now
);
int
totalCount
=
platformCandyCouponService
.
count
(
couponQueryWrapper
),
remainCount
=
totalCount
,
num
=
0
,
pSize
=
1000
;
log
.
info
(
"券到期检查:公有券[可用券总数:{},其中到期券ID数:{}]"
,
commonCouponList
.
size
(),
totalCount
);
couponQueryWrapper
.
orderByAsc
(
CandyCoupon:
:
getMid
);
while
(
remainCount
>
0
)
{
String
lastLimitSql
=
"LIMIT "
+
(
num
*
pSize
)
+
","
+
pSize
;
couponQueryWrapper
.
last
(
lastLimitSql
);
couponQueryWrapper
.
select
(
CandyCoupon:
:
getMid
,
CandyCoupon:
:
getCouponId
);
List
<
CandyCoupon
>
couponList
=
platformCandyCouponService
.
list
(
couponQueryWrapper
);
int
couponListSize
=
CollectionUtils
.
isEmpty
(
couponList
)
?
-
1
:
couponList
.
size
();
for
(
int
i
=
0
;
i
<
couponListSize
;
i
++)
{
CandyCoupon
coupon
=
couponList
.
get
(
i
);
List
<
CandyCommonCoupon
>
inCommonCouponList
=
commonCouponIdToListMap
.
get
(
coupon
.
getCouponId
());
inCommonCouponList
.
forEach
(
r
->
{
r
.
setState
(
3
);
r
.
setOperator
(
"system"
);
r
.
setUpdatedAt
(
now
);
updateCommonCouponList
.
add
(
r
);
});
}
num
++;
remainCount
-=
pSize
;
}
if
(!
CollectionUtils
.
isEmpty
(
updateCommonCouponList
))
{
if
(
platformCandyCommonCouponService
.
updateBatchById
(
updateCommonCouponList
,
updateCommonCouponList
.
size
()))
{
String
ccKey
=
CandyRedisConst
.
BASIC_COMMON_COUPON
;
List
<
CandyCommonCouponBasicDto
>
vos
=
(
List
<
CandyCommonCouponBasicDto
>)
redisUtil
.
get
(
ccKey
);
if
(!
CollectionUtils
.
isEmpty
(
vos
))
{
Map
<
String
,
CandyCommonCouponBasicDto
>
vosMap
=
vos
.
stream
().
collect
(
Collectors
.
toMap
(
CandyCommonCouponBasicDto:
:
getCcouponId
,
t
->
t
));
updateCommonCouponList
.
forEach
(
r
->
{
vos
.
removeIf
(
v
->
v
.
getCcouponId
().
equals
(
r
.
getCcouponId
()));
CandyCommonCouponBasicDto
commonCouponBasicDto
=
vosMap
.
get
(
r
.
getCcouponId
());
commonCouponBasicDto
.
setState
(
3
);
vos
.
add
(
commonCouponBasicDto
);
});
redisUtil
.
set
(
ccKey
,
vos
);
}
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券到期处理失败[updateCommonCouponList.size=%s]"
,
updateCommonCouponList
.
size
()));
}
}
log
.
info
(
"券到期检查:公有券[可用券总数:{},到期券ID数:{},到期券处理数:{}] >>> END END END"
,
commonCouponList
.
size
(),
totalCount
,
updateCommonCouponList
.
size
());
}
return
ResponseDto
.
success
();
}
/**
* <p>
* 发放类-私有券
* </p>
* - 更新用户券状态
* - 同步REDIS.DTO
*
* @return ResponseDto<String>
*/
@PutMapping
(
"user"
)
public
ResponseDto
<
String
>
processForUser
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
return
ResponseDto
.
success
();
}
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/candy/task/CandyCouponTaskController.java
deleted
100644 → 0
View file @
8fe8790b
package
com
.
liquidnet
.
service
.
platform
.
controller
.
candy
.
task
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.candy.entity.CandyCoupon
;
import
com.liquidnet.service.platform.service.impl.candy.PlatformCandyCouponService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
@Slf4j
@RestController
@RequestMapping
(
"ccoupon/task"
)
public
class
CandyCouponTaskController
{
@Autowired
private
PlatformCandyCouponService
platformCandyCouponService
;
@PutMapping
(
"due/validity_check"
)
public
ResponseDto
<
String
>
dueCheck
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
LambdaQueryWrapper
<
CandyCoupon
>
queryWrapper
=
Wrappers
.
lambdaQuery
(
CandyCoupon
.
class
);
queryWrapper
.
eq
(
CandyCoupon:
:
getState
,
1
);
queryWrapper
.
eq
(
CandyCoupon:
:
getExclusive
,
0
);
queryWrapper
.
le
(
CandyCoupon:
:
getExpireAt
,
now
);
int
totalCount
=
platformCandyCouponService
.
count
(
queryWrapper
);
log
.
info
(
"券到期检查总记录数:{} >>> BEGIN BEGIN BEGIN"
,
totalCount
);
return
ResponseDto
.
success
();
}
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/candy/PlatformCandyCouponService.java
View file @
d6aa8e96
...
...
@@ -95,6 +95,8 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
couponCode
.
setCouponId
(
coupon
.
getCouponId
());
couponCode
.
setState
(
0
);
couponCode
.
setCreatedAt
(
now
);
couponCode
.
setRedeemStart
(
coupon
.
getRedeemStart
());
couponCode
.
setRedeemStop
(
coupon
.
getRedeemStop
());
initCouponCodeList
.
add
(
couponCode
);
}
...
...
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