| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | 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
|
| | | public class UserSystemCouponJob {
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
|
| | | |
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | | /**
|
| | | * 每天一个小时更新券
|
| | | */
|
| | | @Scheduled(cron = "0 0 0/1 * * ? ")
|
| | | public void updateCouponInfo() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | |
| | | // 1、赠送退回券
|
| | | giveSendBack();
|
| | | |
| | | // 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);
|
| | | }
|
| | | } 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);
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.job; |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | 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 |
| | | public class UserSystemCouponJob { |
| | | |
| | | @Resource |
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService; |
| | | |
| | | @Resource |
| | | private UserSystemCouponService userSystemCouponService; |
| | | |
| | | /** |
| | | * 每天一个小时更新券 |
| | | */ |
| | | @Scheduled(cron = "0 0 0/1 * * ? ") |
| | | public void updateCouponInfo() { |
| | | if (!Constant.IS_TASK) |
| | | return; |
| | | |
| | | // 1、赠送退回券 |
| | | giveSendBack(); |
| | | |
| | | // 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); |
| | | } |
| | | } 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); |
| | | } |
| | | } |
| | | } |