|
@@ -9,6 +9,8 @@ import com.qs.mp.common.enums.MqTopicType;
|
|
|
import com.qs.mp.common.enums.TicketBoxStatusEnum;
|
|
|
import com.qs.mp.common.pulsar.PulsarConsumer;
|
|
|
import com.qs.mp.common.utils.LogUtil;
|
|
|
+import com.qs.mp.user.domain.UserTicketOrder;
|
|
|
+import com.qs.mp.user.service.IUserTicketOrderService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,26 +31,37 @@ public class PulsarConsumerImpl implements PulsarConsumer {
|
|
|
@Autowired
|
|
|
private ITicketBoxService ticketBoxService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserTicketOrderService userTicketOrderService;
|
|
|
+
|
|
|
@Override
|
|
|
@Async("threadPoolTaskExecutor")
|
|
|
public void wsConsumer(String topicType, String mqData) {
|
|
|
logger.info(topicType + " >>>>>>>>>>>>>>>>>>>:" + mqData);
|
|
|
- //监听商户充值消息,后续业务处理
|
|
|
+ //监听盲票生成消息,后续业务处理
|
|
|
if (MqTopicType.ticket_generate.getValue().equals(topicType)) {
|
|
|
- String boxId = mqData;
|
|
|
- TicketBox ticketBox = ticketBoxService.getById(boxId);
|
|
|
- if (ticketBox.getStatus() != TicketBoxStatusEnum.WAIT ) {
|
|
|
- LogUtil.error(logger, "收到盲票生成消息,票组状态不是待出票,忽略消息。boxId=" + boxId);
|
|
|
- return;
|
|
|
- }
|
|
|
- // 先更新状态,防并发。如果最后生成失败了,暂时人工重新触发
|
|
|
- boolean rst = ticketBoxService.update(new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getStatus, TicketBoxStatusEnum.DOING)
|
|
|
- .eq(TicketBox::getBoxId, boxId).eq(TicketBox::getStatus, TicketBoxStatusEnum.WAIT));
|
|
|
- if (!rst) {
|
|
|
- LogUtil.error(logger, "收到盲票生成消息,更新票组状态为出票中失败。boxId=" + boxId);
|
|
|
- return;
|
|
|
- }
|
|
|
- ticketBoxService.generateTicket(boxId);
|
|
|
+ processTicketGenerateMsg(mqData);
|
|
|
+ } else if (MqTopicType.ticket_pay.getValue().equals(topicType)) {
|
|
|
+ String orderId = mqData;
|
|
|
+ UserTicketOrder ticketOrder = userTicketOrderService.getById(orderId);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void processTicketGenerateMsg(String mqData) {
|
|
|
+ String boxId = mqData;
|
|
|
+ TicketBox ticketBox = ticketBoxService.getById(boxId);
|
|
|
+ if (ticketBox.getStatus() != TicketBoxStatusEnum.WAIT ) {
|
|
|
+ LogUtil.error(logger, "收到盲票生成消息,票组状态不是待出票,忽略消息。boxId=" + boxId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 先更新状态,防并发。如果最后生成失败了,暂时人工重新触发
|
|
|
+ boolean rst = ticketBoxService.update(new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getStatus, TicketBoxStatusEnum.DOING)
|
|
|
+ .eq(TicketBox::getBoxId, boxId).eq(TicketBox::getStatus, TicketBoxStatusEnum.WAIT));
|
|
|
+ if (!rst) {
|
|
|
+ LogUtil.error(logger, "收到盲票生成消息,更新票组状态为出票中失败。boxId=" + boxId);
|
|
|
+ return;
|
|
|
}
|
|
|
+ ticketBoxService.generateTicket(boxId);
|
|
|
}
|
|
|
}
|