| @@ -1,9 +1,11 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.enums.EnumRefundStatus; | |||
| import com.iformall.mapper.WxAppinfoMapper; | |||
| import com.iformall.mapper.WxCouponMapper; | |||
| import com.iformall.mapper.WxOrderGroupMapper; | |||
| @@ -98,8 +100,19 @@ public class OrderExpiringSchedule { | |||
| }); | |||
| //拼团过期 | |||
| // 拼团取消 | |||
| WxOrder order = new WxOrder(); | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | |||
| wxOrderMapper.select(order).parallelStream().forEach(o -> { | |||
| try { | |||
| orderGroupExpired(o); | |||
| } catch (Exception e) { | |||
| logger.error("拼团取消失败" + e.getMessage()); | |||
| } | |||
| }); | |||
| //拼团过期 | |||
| order = new WxOrder(); | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_OVERTIME.getCode()); | |||
| wxOrderMapper.select(order).parallelStream().forEach(o -> { | |||
| try { | |||
| @@ -135,15 +148,11 @@ public class OrderExpiringSchedule { | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void orderExpired(WxOrder order) { | |||
| Integer status = EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode(); | |||
| WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(order.getProductId()); | |||
| if (wxCoupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode())) { | |||
| status = EnumOrderStatus.ORDER_STATUS_COOPERATING_BREAK.getCode(); | |||
| } | |||
| WxOrder updateOrder = new WxOrder(); | |||
| updateOrder.setId(order.getId()); | |||
| updateOrder.setUpdateDate(new Date()); | |||
| updateOrder.setOrderStatus(status); | |||
| updateOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| wxOrderMapper.updateByPrimaryKeySelective(updateOrder); | |||
| // 库存退回 | |||
| @@ -170,6 +179,24 @@ public class OrderExpiringSchedule { | |||
| logger.info("砍价订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void orderGroupExpired(WxOrder order) { | |||
| Date curDate = new Date(); | |||
| WxOrder updateOrder = new WxOrder(); | |||
| updateOrder.setId(order.getId()); | |||
| updateOrder.setTenantId(order.getTenantId()); | |||
| updateOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_BREAK.getCode()); | |||
| updateOrder.setUpdateDate(curDate); | |||
| wxOrderMapper.updateByPrimaryKeySelective(updateOrder); | |||
| // 库存退回 | |||
| wxOrderService.stockBack(order); | |||
| // 微信 关单 | |||
| wxOrderService.orderClose(updateOrder); | |||
| logger.info("拼团订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void returnMoney(WxOrder order) { | |||