| | |
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Component
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
| | | @Override
|
| | | public TransactionStatus check(Message msg) {
|
| | |
|
| | | String tag = msg.getTag();
|
| | | if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_ORDER.name())) {
|
| | | if (msg.getTag().startsWith(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX)) {// 订单加入红包标识
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_FANLI.name())) {
|
| | | if (msg.getTag().equalsIgnoreCase("actual")) {// 查询key值是否在
|
| | | if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
|
| | | if (hongBaoV2SettleTempService.countByKey(msg.getKey()) > 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | } else if (msg.getTag().equalsIgnoreCase("delay")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.teamRewardPreRecieved.name())) {
|
| | | if (hongBaoV2SettleTempService.countByKey(msg.getKey()) > 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiDelay.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | OrderMoneyRecievedMQMsg.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {
|
| | | // TODO 尚未处理一个订单部分到账的状况
|
| | | // 返利是否到账
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(dto.getSourceType(),
|
| | |
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | |
|
| | | // 其他未知条件暂时处理为回滚
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name())) {
|
| | | return mqLocalUserCouponUsedTransactionChecker.check(msg);
|
| | |
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_USER.name())) {
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.useSystemCoupon.name()))// 系统券使用
|
| | | return mqLocalUserCouponUsedTransactionChecker.check(msg);
|
| | | }
|
| | |
|
| | | return TransactionStatus.Unknow;
|