admin
2020-11-09 2147d023563a7c9d05d97547c00d6b0162c0644c
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java
@@ -46,6 +46,7 @@
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService;
import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
import com.yeshi.fanli.service.manger.msg.RocketMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
@@ -74,8 +75,8 @@
   @Resource
   private RedPackBalanceService redPackBalanceService;
   @Resource(name = "producer")
   private Producer producer;
   @Resource
   private RocketMQManager rocketMQManager;
   @Resource
   private MQUnSendInfoService mqUnSendInfoService;
@@ -91,12 +92,11 @@
   @Resource
   private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
   @Resource
   private RedPackForbidService redPackForbidService;
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   @Override
   public void addOrder(BanLiShopOrder order) throws BanLiShopOrderException {
      // 查询必要的参数是否添加
@@ -181,7 +181,8 @@
      msg.setKey(orderId + "");
      long delayTime = System.currentTimeMillis() + (Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 10);// 10分钟后通知
      msg.setStartDeliverTime(delayTime);
      SendResult sendResult = producer.send(msg);
      SendResult sendResult =   rocketMQManager.sendNormalMsg(msg,  Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 10L, orderId + "");
      if (sendResult == null) {
         MQUnSendInfo info = new MQUnSendInfo();
         info.setBody(new String(msg.getBody()));
@@ -224,7 +225,7 @@
      banLiShopOrderMapper.updateByPrimaryKeySelective(order);
   }
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   @Override
   public void payOrderByHongBao(Long orderId) throws BanLiShopOrderException, RedPackBalanceException {
      BanLiShopOrder order = banLiShopOrderMapper.selectByPrimaryKeyForUpdate(orderId);
@@ -329,6 +330,7 @@
      return banLiShopOrderMapper.selectByPrimaryKeyForUpdate(id);
   }
   @Transactional(rollbackFor = Exception.class)
   @Override
   public void invalidOrderByOrderId(Long id, String desc) {
      // 判断订单是否存在
@@ -347,9 +349,9 @@
               if (isS)// 支付成功,重新发送支付成功消息
               {
                  BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid());
                  Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                        OrderTopicTagEnum.banLiShopOrderPaid,msg);
                  producer.send(message);
                  Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
                        OrderTopicTagEnum.banLiShopOrderPaid, msg);
                  rocketMQManager.sendNormalMsg(message, null);
                  return;
               }
@@ -379,8 +381,8 @@
      if (order.getState() != BanLiShopOrder.STATE_PAID)
         throw new BanLiShopOrderException(1, "订单未处于待审核状态");
      Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderRefund,
         new BanLiShopOrderMQMsg(order.getId(), order.getUid()));
      Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderRefund,
            new BanLiShopOrderMQMsg(order.getId(), order.getUid()));
      try {
         orderTransactionProducer.send(message, new LocalTransactionExecuter() {
            @Override
@@ -440,9 +442,9 @@
         throw new BanLiShopOrderException(22, "商品已下线");
      }
      if(redPackForbidService.verifyForbid(uid))
      if (redPackForbidService.verifyForbid(uid))
         throw new BanLiShopOrderException(25, "红包功能已被封禁");
      if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) {
         BigDecimal money = redPackBalanceService.getBalance(uid);
         if (money.compareTo(pay.getHongBaoPrice()) < 0) {