admin
2019-11-12 ca3e865a9e3c22fc24c7ca4b67ad8c25d3f2ef18
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.yeshi.utils.exception.WXOrderException;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer;
@@ -45,6 +46,7 @@
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil;
@Service
public class BanLiShopOrderServiceImpl implements BanLiShopOrderService {
@@ -138,6 +140,10 @@
      order.setOrderNo(orderNo);
      banLiShopOrderMapper.updateByPrimaryKeySelective(update);
      // 增加销量
      banLiShopGoodsSetService.addSalesCount(order.getGoodsSet().getId(), 1);
      banLiShopGoodsService.addSalesCount(order.getGoods().getId(), 1);
      // 订单添加成功 ,延时通知后续
      sendPlaceOrderMsg(order.getId(), order.getUid());
   }
@@ -151,6 +157,7 @@
      orderGoods.setSetName(set.getName());
      orderGoods.setState(set.getState());
      orderGoods.setZkPrice(set.getZkPrice());
      orderGoods.setPicture(goods.getSquarePicture());
      banLiShopOrderGoodsMapper.insertSelective(orderGoods);
      return orderGoods;
   }
@@ -183,12 +190,12 @@
   @Override
   public List<BanLiShopOrder> listByUid(Long uid, int page, int pageSize) {
      return banLiShopOrderMapper.listByUid(null, uid, (page - 1) * pageSize, pageSize);
      return banLiShopOrderMapper.listByUidAndState(null, uid, (page - 1) * pageSize, pageSize);
   }
   @Override
   public long countByUid(Long uid) {
      return banLiShopOrderMapper.countByUid(null, uid);
      return banLiShopOrderMapper.countByUidAndState(null, uid);
   }
   @Override
@@ -319,6 +326,28 @@
      // 判断是否处于未付款
      if (order.getState() == BanLiShopOrder.STATE_NO_PAY) {
         /**
          * 查询是否已经微信支付
          */
         if (order.getMoneyPayment() != null) {
            try {
               boolean isS = BanLiShopWXPayUtil.isPaySuccess(order.getOrderNo());
               if (isS)// 支付成功,重新发送支付成功消息
               {
                  BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid());
                  Message message = new Message(MQTopicName.TOPIC_ORDER.name(),
                        OrderTopicTagEnum.banLiShopOrderPaid.name(), new Gson().toJson(msg).getBytes());
                  producer.send(message);
                  return;
               }
            } catch (WXOrderException e) {
               e.printStackTrace();
            } catch (Exception e) {
            }
         }
         BanLiShopOrder update = new BanLiShopOrder();
         update.setId(id);
         update.setStateDesc(desc);
@@ -364,6 +393,7 @@
         update.setState(BanLiShopOrder.STATE_REJECT);
         update.setStateDesc(msg);
         update.setUpdateTime(new Date());
         update.setRejectTime(new Date());
         banLiShopOrderMapper.updateByPrimaryKeySelective(update);
         transactionManager.commit(transactionStatus);
      } catch (Exception e) {
@@ -390,7 +420,12 @@
      }
      if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) {
         BigDecimal money = redPackBalanceService.getBalance(uid);
         BigDecimal money = null;
         try {
            money = redPackBalanceService.getBalance(uid);
         } catch (RedPackBalanceException e) {
            throw new BanLiShopOrderException(25, "红包功能异常");
         }
         if (money.compareTo(pay.getHongBaoPrice()) < 0) {
            throw new BanLiShopOrderException(24, "红包余额不足");
         }
@@ -422,4 +457,19 @@
      return order;
   }
   @Override
   public BanLiShopOrder selectByOrderNo(String orderNo) {
      return banLiShopOrderMapper.selectByOrderNo(orderNo);
   }
   @Override
   public List<BanLiShopOrder> listByUidAndState(Long uid, List<Integer> stateList, int page, int pageSize) {
      return banLiShopOrderMapper.listByUidAndState(stateList, uid, (page - 1) * pageSize, pageSize);
   }
   @Override
   public long countByUidAndState(Long uid, List<Integer> stateList) {
      return banLiShopOrderMapper.countByUidAndState(stateList, uid);
   }
}