'提交代码'

dev-discount
199901012 4 years ago
parent 1d4db5aa22
commit cda958fe6e
  1. 17
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  2. 8
      hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java
  3. 9
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  4. 2
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  5. 15
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java

@ -1,10 +1,15 @@
package com.hai.schedule; package com.hai.schedule;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighUserCoupon;
import com.hai.service.HighUserCouponService; import com.hai.service.HighUserCouponService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -14,6 +19,8 @@ import javax.annotation.Resource;
@Configuration @Configuration
public class HighCouponSchedule { public class HighCouponSchedule {
private static Logger log = LoggerFactory.getLogger(HighCouponSchedule.class);
@Resource @Resource
private HighUserCouponService highUserCouponService; private HighUserCouponService highUserCouponService;
@ -25,6 +32,14 @@ public class HighCouponSchedule {
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void expiredCoupon() { public void expiredCoupon() {
highUserCouponService.expiredCoupon(); // 查询过期的卡券
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon userCoupon : userCoupons) {
try {
highUserCouponService.expiredCoupon(userCoupon.getId());
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
} }
} }

@ -3,6 +3,8 @@ package com.hai.schedule;
import com.hai.entity.HighDiscountUserRel; import com.hai.entity.HighDiscountUserRel;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.service.HighDiscountUserRelService; import com.hai.service.HighDiscountUserRelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -17,6 +19,8 @@ import java.util.List;
@Configuration @Configuration
public class HighDiscountSchedule { public class HighDiscountSchedule {
private static Logger log = LoggerFactory.getLogger(HighDiscountSchedule.class);
@Resource @Resource
private HighDiscountUserRelService highDiscountUserRelService; private HighDiscountUserRelService highDiscountUserRelService;
@ -29,8 +33,12 @@ public class HighDiscountSchedule {
public void expiredDiscount() { public void expiredDiscount() {
List<HighDiscountUserRel> expiredDiscount = highDiscountUserRelService.getExpiredDiscount(); List<HighDiscountUserRel> expiredDiscount = highDiscountUserRelService.getExpiredDiscount();
for (HighDiscountUserRel rel : expiredDiscount) { for (HighDiscountUserRel rel : expiredDiscount) {
try {
rel.setStatus(0); rel.setStatus(0);
highDiscountUserRelService.updateDiscountUserRel(rel); highDiscountUserRelService.updateDiscountUserRel(rel);
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
} }
} }

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.service.HighOrderService; import com.hai.service.HighOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -21,6 +23,8 @@ import java.util.Map;
@Configuration @Configuration
public class HighOrderSchedule { public class HighOrderSchedule {
private static final Logger log = LoggerFactory.getLogger(HighOrderSchedule.class);
@Resource @Resource
private HighOrderService highOrderService; private HighOrderService highOrderService;
@ -31,11 +35,14 @@ public class HighOrderSchedule {
**/ **/
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void cancelOrder() { public void cancelOrder() {
List<HighOrder> orderList = highOrderService.getCloseOrder(); List<HighOrder> orderList = highOrderService.getCloseOrder();
if (orderList != null && orderList.size() > 0) { if (orderList != null && orderList.size() > 0) {
for (HighOrder order : orderList) { for (HighOrder order : orderList) {
try {
highOrderService.cancelOrder(order.getId()); highOrderService.cancelOrder(order.getId());
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
} }
} }
} }

@ -70,7 +70,7 @@ public interface HighUserCouponService {
* @Description 处理过期的卡券 * @Description 处理过期的卡券
* @Date 2021/4/5 12:26 * @Date 2021/4/5 12:26
**/ **/
void expiredCoupon(); void expiredCoupon(Long userCouponId);
} }

@ -172,10 +172,9 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
} }
@Override @Override
public void expiredCoupon() { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
// 查询过期的卡券 public void expiredCoupon(Long userCouponId) {
List<HighUserCoupon> userCoupons = getOverdueCoupon(); HighUserCoupon highUserCoupon = highUserCouponMapper.selectByPrimaryKey(userCouponId);
for (HighUserCoupon highUserCoupon : userCoupons) {
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用
highUserCoupon.setQrCodeImg(null); highUserCoupon.setQrCodeImg(null);
updateUserCoupon(highUserCoupon); updateUserCoupon(highUserCoupon);
@ -185,14 +184,14 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
couponCode.setChildOrderId(null); couponCode.setChildOrderId(null);
couponCode.setReceiveTime(null); couponCode.setReceiveTime(null);
HighUser highUser = highUserService.findByUserId(highUserCoupon.getUserId());
// 查询卡券信息 // 查询卡券信息
HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId()); HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId());
HighChildOrder childOrder = highOrderService.getChildOrderById(couponCode.getChildOrderId()); HighChildOrder childOrder = highOrderService.getChildOrderById(couponCode.getChildOrderId());
HighOrder order = highOrderService.getOrderById(childOrder.getId()); HighOrder order = highOrderService.getOrderById(childOrder.getId());
// 归库记录 // 归库记录
HighCouponRecycle highCouponRecycle = new HighCouponRecycle(); HighCouponRecycle highCouponRecycle = new HighCouponRecycle();
highCouponRecycle.setCouponId(coupon.getId()); highCouponRecycle.setCouponId(coupon.getId());
@ -206,10 +205,12 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
highCouponRecycle.setOrderNo(order.getOrderNo()); highCouponRecycle.setOrderNo(order.getOrderNo());
highCouponRecycle.setChildOrderId(childOrder.getId()); highCouponRecycle.setChildOrderId(childOrder.getId());
highCouponRecycle.setUserId(highUser.getId());
highCouponRecycle.setUserPhone(highUser.getPhone());
highCouponRecycle.setType(1); // 类型:1.过期 2.退款 highCouponRecycle.setType(1); // 类型:1.过期 2.退款
highCouponRecycle.setReceiveTime(highUserCoupon.getCreateTime()); // 领取时间 highCouponRecycle.setReceiveTime(highUserCoupon.getCreateTime()); // 领取时间
highCouponRecycle.setCreateTime(new Date()); highCouponRecycle.setCreateTime(new Date());
highCouponRecycleService.insertCouponRecycle(highCouponRecycle); highCouponRecycleService.insertCouponRecycle(highCouponRecycle);
} }
} }
}

Loading…
Cancel
Save