Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
337b0996
Commit
337b0996
authored
Dec 23, 2018
by
Junling Bu
Browse files
feat[litemall-admin-api]: 优惠券定时任务,检查是否过期
parent
a831c948
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/job/CouponJob.java
0 → 100644
View file @
337b0996
package
org.linlinjava.litemall.admin.job
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.db.domain.LitemallCoupon
;
import
org.linlinjava.litemall.db.domain.LitemallCouponUser
;
import
org.linlinjava.litemall.db.service.LitemallCouponService
;
import
org.linlinjava.litemall.db.service.LitemallCouponUserService
;
import
org.linlinjava.litemall.db.util.CouponConstant
;
import
org.linlinjava.litemall.db.util.CouponUserConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* 检测优惠券过期情况
*/
@Component
public
class
CouponJob
{
private
final
Log
logger
=
LogFactory
.
getLog
(
CouponJob
.
class
);
@Autowired
private
LitemallCouponService
couponService
;
@Autowired
private
LitemallCouponUserService
couponUserService
;
/**
* 每隔一个小时检查
*/
@Scheduled
(
fixedDelay
=
60
*
60
*
1000
)
public
void
checkCouponExpired
()
{
logger
.
info
(
"系统开启任务检查优惠券是否已经过期"
);
List
<
LitemallCoupon
>
couponList
=
couponService
.
queryExpired
();
for
(
LitemallCoupon
coupon
:
couponList
){
coupon
.
setStatus
(
CouponConstant
.
STATUS_EXPIRED
);
couponService
.
updateById
(
coupon
);
}
List
<
LitemallCouponUser
>
couponUserList
=
couponUserService
.
queryExpired
();
for
(
LitemallCouponUser
couponUser
:
couponUserList
){
couponUser
.
setStatus
(
CouponUserConstant
.
STATUS_EXPIRED
);
couponUserService
.
update
(
couponUser
);
}
}
}
Write
Preview
Supports
Markdown
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