admin
2019-09-28 fe279c5bfcd5f3018f0f2aa7ac539a3b14afb550
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -1443,4 +1443,54 @@
         return false;
   }
   @Transactional(rollbackFor = Exception.class)
   public void invalidHongBaoV2AndGiveGodenCorn(Long hongBaoId, Long uid, String orderId, int sourceType,
         String beiZhu) throws Exception {
      HongBaoV2 v2 = new HongBaoV2(hongBaoId);
      v2.setState(HongBaoV2.STATE_SHIXIAO);
      v2.setBeizhu(beiZhu);
      v2.setUpdateTime(new Date());
      hongBaoV2Service.updateByPrimaryKeySelective(v2);
      List<HongBaoV2> children = hongBaoV2Service.listChildrenById(hongBaoId);
      if (children != null)
         for (HongBaoV2 child : children) {
            HongBaoV2 update = new HongBaoV2(child.getId());
            update.setState(HongBaoV2.STATE_SHIXIAO);
            update.setBeizhu(beiZhu);
            update.setUpdateTime(new Date());
            hongBaoV2Service.updateByPrimaryKeySelective(update);
         }
      userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId, sourceType, "因商家违约未能结算返利或商家已经关店");
   }
   @Transactional
   @Override
   public void doTaoBaoSellerNotPaid(TaoBaoOrder order) {
      // 根据交易ID查询
      if (!StringUtil.isNullOrEmpty(order.getTradeId())) {
         List<CommonOrder> commonOrderList = commonOrderService
               .listBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, order.getTradeId());
         if (commonOrderList != null)
            // 查询主订单
            for (CommonOrder commonOrder : commonOrderList) {
            // 查询主红包
            HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
            if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
            if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_BUKELINGQU) {
            // 订单失效,赠送金币
            try {
            invalidHongBaoV2AndGiveGodenCorn(hongBaoOrder.getHongBaoV2().getId(), hongBaoOrder.getHongBaoV2().getUserInfo().getId(), commonOrder.getOrderNo(), commonOrder.getSourceType(), "订单成功,商家未打款");
            } catch (Exception e) {
            e.printStackTrace();
            }
            }
            }
            }
      }
   }
}