修复订单取消/退款之后优惠券没有返还问题 (#397)

This commit is contained in:
Tyson
2020-06-08 22:09:41 +08:00
committed by GitHub
parent acb459a74b
commit a2f77152d8
4 changed files with 45 additions and 4 deletions

View File

@@ -534,6 +534,9 @@ public class WxOrderService {
}
}
// 返还优惠券
releaseCoupon(orderId);
return ResponseUtil.ok();
}
@@ -1013,4 +1016,21 @@ public class WxOrderService {
return ResponseUtil.ok();
}
/**
* 取消订单/退款返还优惠券
* <br/>
* @param orderId
* @return void
* @author Tyson
* @date 2020/6/8/0008 1:41
*/
public void releaseCoupon(Integer orderId) {
List<LitemallCouponUser> couponUsers = couponUserService.findByOid(orderId);
for (LitemallCouponUser couponUser: couponUsers) {
// 优惠券状态设置为可使用
couponUser.setStatus(CouponUserConstant.STATUS_USABLE);
couponUser.setUpdateTime(LocalDateTime.now());
couponUserService.update(couponUser);
}
}
}

View File

@@ -11,6 +11,7 @@ import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import org.linlinjava.litemall.db.service.LitemallOrderGoodsService;
import org.linlinjava.litemall.db.service.LitemallOrderService;
import org.linlinjava.litemall.db.util.OrderUtil;
import org.linlinjava.litemall.wx.service.WxOrderService;
import java.time.LocalDateTime;
import java.util.List;
@@ -36,6 +37,7 @@ public class OrderUnpaidTask extends Task {
LitemallOrderService orderService = BeanUtil.getBean(LitemallOrderService.class);
LitemallOrderGoodsService orderGoodsService = BeanUtil.getBean(LitemallOrderGoodsService.class);
LitemallGoodsProductService productService = BeanUtil.getBean(LitemallGoodsProductService.class);
WxOrderService wxOrderService = BeanUtil.getBean(WxOrderService.class);
LitemallOrder order = orderService.findById(this.orderId);
if(order == null){
@@ -62,6 +64,10 @@ public class OrderUnpaidTask extends Task {
throw new RuntimeException("商品货品库存增加失败");
}
}
//返还优惠券
wxOrderService.releaseCoupon(orderId);
logger.info("系统结束处理延时任务---订单超时未付款---" + this.orderId);
}
}