diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java index 8d569777e..b41e80742 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java @@ -1,9 +1,12 @@ package com.iformall.schedule; import com.iformall.domain.po.WxOrder; +import com.iformall.domain.po.WxOrderGroup; import com.iformall.enums.EnumOrderStatus; import com.iformall.enums.EnumOrderType; +import com.iformall.mapper.WxOrderGroupMapper; import com.iformall.mapper.WxOrderMapper; +import com.iformall.service.WxOrderGroupService; import com.iformall.service.WxOrderService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,6 +33,12 @@ public class OrderExpiringSchedule { @Autowired WxOrderService wxOrderService; + @Autowired + WxOrderGroupMapper wxOrderGroupMapper; + + @Autowired + WxOrderGroupService wxOrderGroupService; + @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 @@ -54,6 +63,12 @@ public class OrderExpiringSchedule { orderPresss.parallelStream().forEach( o -> { orderPressExpired(o); }); + + //拼团 + List orderGroups = wxOrderGroupService.findList(null); + orderGroups.parallelStream().forEach(g -> { + wxOrderGroupService.updateGroupStatus(g); + }); } @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @@ -84,4 +99,5 @@ public class OrderExpiringSchedule { logger.info("\n砍价订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); } + } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/service/WxOrderGroupService.java b/mallinkService/src/main/java/com/iformall/service/WxOrderGroupService.java index f1ea20186..377f724fe 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxOrderGroupService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxOrderGroupService.java @@ -6,6 +6,7 @@ import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxOrder; import com.iformall.domain.po.WxOrderGroup; +import java.util.List; import java.util.Map; /** @@ -25,4 +26,8 @@ public interface WxOrderGroupService { ResultData queryAttendStatus(WxOrderGroup wxOrderGroup); + void updateGroupStatus(WxOrderGroup wxOrderGroup); + + List findList(WxOrderGroup group); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java index 011276580..2c7c47bf5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java @@ -239,6 +239,8 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { return new ResultData(result); } + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) + @Override public void updateGroupStatus(WxOrderGroup wxOrderGroup) { Long id = wxOrderGroup.getId(); WxOrderGroup group = wxOrderGroupMapper.selectByPrimaryKey(id); @@ -258,6 +260,11 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { } } + @Override + public List findList(WxOrderGroup group) { + return wxOrderGroupMapper.select(group); + } + public void returnMoney(WxOrderGroup group) { //券失效或拼团超时 修改 拼团的状态 wxOrderGroupMapper.updateByPrimaryKeySelective(group); @@ -277,9 +284,12 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { wxOrder.setOrderGroupId(group.getId()); List list = wxOrderMapper.findList(wxOrder); for (WxOrder temp : list) { - if (!temp.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode())) { + if (temp.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_OVERTIME.getCode()) + || temp.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode())) { ResultData resultData = WxRefundOrderService.returnMoney(appinfo, temp.getId()); + logger.info("拼团不成功时的退款返回信息:" + resultData + "resultData.code == ResultData.SUCCESS" + (resultData.code == ResultData.SUCCESS)); if (resultData.code == ResultData.SUCCESS) { + logger.info("修改订单的状态为已退款"); temp.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); wxOrderMapper.updateByPrimaryKeySelective(order); }