From e5faf31965fef7235ade5dc39b03384c3830d088 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 21 八月 2019 14:39:09 +0800 Subject: [PATCH] 券退回 券失效 --- fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 45 insertions(+), 14 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java index 0aab34a..f1dbced 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java @@ -7,8 +7,11 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord; +import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService; +import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; @Component @@ -16,29 +19,57 @@ @Resource private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService; - + + @Resource + private UserSystemCouponService userSystemCouponService; /** - * 姣忓ぉ00:10 璧犻�侀��鍥炲凡杩囨湡娣樼ぜ閲� + * 姣忓ぉ00:10 鏇存柊鍒� */ @Scheduled(cron = "0 10 0 * * ? ") - public void giveSendBack() { + public void updateCouponInfo() { if (!Constant.IS_TASK) return; + // 1銆佽禒閫侀��鍥炲埜 + giveSendBack(); - for (int i = 0; i < 100; i++) { - List<UserSystemCouponGiveRecord> overdueList = userSystemCouponGiveRecordService.overdueList(500); - if (overdueList == null || overdueList.size() == 0) { - break; + // 2銆佸埜澶辨晥 + updateInvalid(); + + + } + + /** + * 璧犻�侀��鍥炲埜 + */ + public void giveSendBack() { + try { + for (int i = 0; i < 100; i++) { + List<UserSystemCouponGiveRecord> overdueList = userSystemCouponGiveRecordService.overdueList(500); + if (overdueList == null || overdueList.size() == 0) { + break; + } + userSystemCouponService.sendBackGiveCoupon(overdueList); } - - for (UserSystemCouponGiveRecord record: overdueList) { - - UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord(); - updateRecord.setId(record.getId()); - updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE); - userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + /** + * 鏇存柊鍒稿け鏁� + */ + public void updateInvalid() { + try { + for (int i = 0; i < 100; i++) { + List<UserSystemCoupon> list = userSystemCouponService.getCounponNowInvalid(500); + if (list == null || list.size() == 0) { + break; + } + userSystemCouponService.updateCounponInvalid(list); } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); } } } -- Gitblit v1.8.0