| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | 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.tlj.UserTaoLiJinGiveRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
|
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Component
|
| | | public class UserSystemCouponJob {
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | /**
|
| | | * 每天00:10 赠送退回已过期淘礼金
|
| | | * 每天一个小时更新券
|
| | | */
|
| | | @Scheduled(cron = "0 10 0 * * ? ")
|
| | | public void giveSendBack() {
|
| | | @Scheduled(cron = "0 0 0/1 * * ? ")
|
| | | public void updateCouponInfo() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | |
|
| | | for (int i = 0; i < 100; i++) {
|
| | | List<UserSystemCouponGiveRecord> overdueList = userSystemCouponGiveRecordService.overdueList(500);
|
| | | if (overdueList == null || overdueList.size() == 0) {
|
| | | break;
|
| | | // 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);
|
| | | }
|
| | | |
| | | for (UserSystemCouponGiveRecord record: overdueList) {
|
| | | // try {
|
| | | // userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record.getAmount());
|
| | | // // 更新记录
|
| | | // UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord();
|
| | | // updateRecord.setId(record.getId());
|
| | | // updateRecord.setState(UserTaoLiJinGiveRecord.STATE_OVERDUE);
|
| | | // userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
|
| | | // } catch (Exception e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | } 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);
|
| | | }
|
| | | }
|
| | | }
|