From 16f8ca25d93103df480e5181db74b13edbd0f046 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Sun, 4 Apr 2021 23:15:08 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=AE=8C=E6=88=90=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E8=BF=87=E6=9C=9F'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hai/schedule/HighCouponSchedule.java | 5 +++ .../hai/schedule/HighDiscountSchedule.java | 38 +++++++++++++++++++ .../com/hai/schedule/HighOrderSchedule.java | 7 +++- .../service/HighDiscountUserRelService.java | 8 ++++ .../impl/HighDiscountUserRelServiceImpl.java | 7 ++++ .../service/impl/HighOrderServiceImpl.java | 8 ++-- 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 921ae58f..77d4d9ab 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -19,6 +19,11 @@ public class HighCouponSchedule { @Resource private HighUserCouponService highUserCouponService; + /** + * @Author 胡锐 + * @Description 处理过期的卡券 + * @Date 2021/4/4 22:44 + **/ // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 public void expiredCoupon() { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java new file mode 100644 index 00000000..66dd437d --- /dev/null +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -0,0 +1,38 @@ +package com.hai.schedule; + +import com.hai.entity.HighDiscountUserRel; +import com.hai.entity.HighOrder; +import com.hai.service.HighDiscountUserRelService; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Auther: 胡锐 + * @Description: 优惠券定时任务 + * @Date: 2021/4/4 22:43 + */ +@Configuration +public class HighDiscountSchedule { + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + /** + * @Author 胡锐 + * @Description 处理过期的优惠券 + * @Date 2021/4/4 22:44 + **/ + @Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次 + public void expiredDiscount() { + List expiredDiscount = highDiscountUserRelService.getExpiredDiscount(); + for (HighDiscountUserRel rel : expiredDiscount) { + rel.setStatus(0); + highDiscountUserRelService.updateDiscountUserRel(rel); + } + + } + +} diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 18fd3aef..c6869d83 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -24,8 +24,13 @@ public class HighOrderSchedule { @Resource private HighOrderService highOrderService; + /** + * @Author 胡锐 + * @Description 取消订单 15分钟 + * @Date 2021/4/4 22:45 + **/ @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 - public void certification() { + public void cancelOrder() { List orderList = highOrderService.getCloseOrder(); if (orderList != null && orderList.size() > 0) { diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java b/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java index db043025..546267ab 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java @@ -48,4 +48,12 @@ public interface HighDiscountUserRelService { **/ List getDiscountList(Map map); + /** + * @Author 胡锐 + * @Description 查询过期优惠券 + * @Date 2021/4/4 22:48 + **/ + List getExpiredDiscount(); + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index eddc1555..a7c4e060 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -137,4 +137,11 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic } return list; } + + @Override + public List getExpiredDiscount() { + HighDiscountUserRelExample example = new HighDiscountUserRelExample(); + example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date()); + return highDiscountUserRelMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 75dd0856..f7a5a237 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -359,9 +359,11 @@ public class HighOrderServiceImpl implements HighOrderService { if (order.getMemDiscountId() != null) { HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); - rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - rel.setUseTime(new Date()); - highDiscountUserRelService.updateDiscountUserRel(rel); + if (rel != null) { + rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + rel.setUseTime(new Date()); + highDiscountUserRelService.updateDiscountUserRel(rel); + } } updateOrder(order); }