'完成优惠券定时任务过期'

dev-discount
199901012 4 years ago
parent e04766d22d
commit 16f8ca25d9
  1. 5
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  2. 38
      hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java
  3. 7
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  4. 8
      hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java
  5. 7
      hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java
  6. 8
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.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() {

@ -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<HighDiscountUserRel> expiredDiscount = highDiscountUserRelService.getExpiredDiscount();
for (HighDiscountUserRel rel : expiredDiscount) {
rel.setStatus(0);
highDiscountUserRelService.updateDiscountUserRel(rel);
}
}
}

@ -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<HighOrder> orderList = highOrderService.getCloseOrder();
if (orderList != null && orderList.size() > 0) {

@ -48,4 +48,12 @@ public interface HighDiscountUserRelService {
**/
List<HighDiscountUserRel> getDiscountList(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 查询过期优惠券
* @Date 2021/4/4 22:48
**/
List<HighDiscountUserRel> getExpiredDiscount();
}

@ -137,4 +137,11 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
}
return list;
}
@Override
public List<HighDiscountUserRel> getExpiredDiscount() {
HighDiscountUserRelExample example = new HighDiscountUserRelExample();
example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date());
return highDiscountUserRelMapper.selectByExample(example);
}
}

@ -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);
}

Loading…
Cancel
Save