|
|
|
@@ -2,17 +2,18 @@ package com.iformall.schedule; |
|
|
|
|
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.domain.po.WxOrder; |
|
|
|
import com.iformall.enums.EnumAppType; |
|
|
|
import com.iformall.enums.EnumOrderStatus; |
|
|
|
import com.iformall.enums.EnumOrderType; |
|
|
|
import com.iformall.enums.EnumRefundStatus; |
|
|
|
import com.iformall.domain.po.msg.*; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.mapper.WxAppinfoMapper; |
|
|
|
import com.iformall.mapper.WxCouponMapper; |
|
|
|
import com.iformall.mapper.WxOrderGroupMapper; |
|
|
|
import com.iformall.mapper.WxOrderMapper; |
|
|
|
import com.iformall.mq.MqBaseProducer; |
|
|
|
import com.iformall.service.WxMsgRecordService; |
|
|
|
import com.iformall.service.WxOrderGroupService; |
|
|
|
import com.iformall.service.WxOrderService; |
|
|
|
import com.iformall.service.WxRefundOrderService; |
|
|
|
import com.iformall.utils.JsonUtil; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -54,6 +55,12 @@ public class OrderExpiringSchedule { |
|
|
|
@Autowired |
|
|
|
WxCouponMapper wxCouponMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMsgRecordService wxMsgRecordService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
MqBaseProducer mqBaseProducer; |
|
|
|
|
|
|
|
@Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 |
|
|
|
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 |
|
|
|
public void orderExpireSchedule() { |
|
|
|
@@ -143,7 +150,49 @@ public class OrderExpiringSchedule { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//消息重发 |
|
|
|
WxMsgRecord msgRecord = new WxMsgRecord(); |
|
|
|
msgRecord.setMsgStatus(EnumMsgRecordStatus.SEND_FAIL.getCode()); |
|
|
|
List<WxMsgRecord> recordList = wxMsgRecordService.findList(msgRecord); |
|
|
|
for (WxMsgRecord wxMsgRecord:recordList) { |
|
|
|
logger.info("消息重发:{}",wxMsgRecord.getMsgJson()); |
|
|
|
try { |
|
|
|
if(EnumMsgRecordType.INSIDE_ORDER_SUCCESS.getCode().equals(wxMsgRecord.getMsgType())){ |
|
|
|
//内部消息 - 下订单成功 |
|
|
|
FmInsideOrderSuccessMsg msg = (FmInsideOrderSuccessMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),FmInsideOrderSuccessMsg.class); |
|
|
|
msg.setMsgType(wxMsgRecord.getMsgType()); |
|
|
|
msg.setReceiver(wxMsgRecord.getReceiver()); |
|
|
|
msg.setTenantId(wxMsgRecord.getTenantId()); |
|
|
|
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
}else if(EnumMsgRecordType.INSIDE_COUPON_VERIFY.getCode().equals(wxMsgRecord.getMsgType())){ |
|
|
|
FmInsideCouponVerifyMsg msg = (FmInsideCouponVerifyMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),FmInsideCouponVerifyMsg.class); |
|
|
|
msg.setMsgType(wxMsgRecord.getMsgType()); |
|
|
|
msg.setReceiver(wxMsgRecord.getReceiver()); |
|
|
|
msg.setTenantId(wxMsgRecord.getTenantId()); |
|
|
|
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
}else if(EnumMsgRecordType.INSIDE_C_LOGIN.getCode().equals(wxMsgRecord.getMsgType())){ |
|
|
|
FmInsideCLoginMsg msg = (FmInsideCLoginMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),FmInsideCLoginMsg.class); |
|
|
|
msg.setMsgType(wxMsgRecord.getMsgType()); |
|
|
|
msg.setReceiver(wxMsgRecord.getReceiver()); |
|
|
|
msg.setTenantId(wxMsgRecord.getTenantId()); |
|
|
|
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
}else if(EnumMsgRecordType.INSIDE_NOTIFY_PAY_SUCCESS.getCode().equals(wxMsgRecord.getMsgType())){ |
|
|
|
FmInsideNotifyPaySuccessMsg msg = (FmInsideNotifyPaySuccessMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),FmInsideNotifyPaySuccessMsg.class); |
|
|
|
msg.setMsgType(wxMsgRecord.getMsgType()); |
|
|
|
msg.setReceiver(wxMsgRecord.getReceiver()); |
|
|
|
msg.setTenantId(wxMsgRecord.getTenantId()); |
|
|
|
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
}else if(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode().equals(wxMsgRecord.getMsgType())){ |
|
|
|
FmInsideNotifyRefundSuccessMsg msg = (FmInsideNotifyRefundSuccessMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),FmInsideNotifyRefundSuccessMsg.class); |
|
|
|
msg.setMsgType(wxMsgRecord.getMsgType()); |
|
|
|
msg.setReceiver(wxMsgRecord.getReceiver()); |
|
|
|
msg.setTenantId(wxMsgRecord.getTenantId()); |
|
|
|
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("消息重发错误:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
|