admin
2019-12-24 4d0c5d771b04d7ba32471df58c91c37dabe96bbf
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java
@@ -470,6 +470,24 @@
         }
      }
      // 获取维权资金
      if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
         try {
            Map<Long, BigDecimal> userSubMoneyMap = taoBaoWeiQuanDrawBackService.doWeiQuanFanli(orderId, false);
            if (userSubMoneyMap != null) {
               for (Iterator<Long> its = userMoney.keySet().iterator(); its.hasNext();) {
                  Long uid = its.next();
                  if (userSubMoneyMap.get(uid) != null) {
                     // 减去维权资金
                     userMoney.put(uid, userMoney.get(uid).subtract(userSubMoneyMap.get(uid)));
                  }
               }
            }
         } catch (Exception e) {
            throw new OrderMoneySettleException(2, "维权订单出错");
         }
      }
      // if (userMoney.isEmpty()) {
      // throw new OrderMoneySettleException(1, "没有需要结算的订单");
      // }
@@ -521,31 +539,6 @@
         userSystemCouponService.updateStateByArrivalAccount(orderId);
      } catch (Exception e) {
         e.printStackTrace();
      }
      // 维权扣款(2018-08-05后开始实行)
      try {
         if (sourceType == Constant.SOURCE_TYPE_TAOBAO)
            taoBaoWeiQuanDrawBackService.doWeiQuanFanli(orderId);
      } catch (TaoBaoWeiQuanException e) {
         if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
            List<TaoBaoOrder> olist = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
            if (olist != null && olist.size() > 0) {
               long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
               olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
               if (olist != null && olist.size() > 0) {
                  for (int i = 0; i < olist.size(); i++) {
                     if (!olist.get(i).getOrderId().equalsIgnoreCase(orderId)) {// 删除无关订单
                        olist.remove(i);
                        i--;
                     }
                  }
                  taoBaoOrderService.addTaoBaoOrderList(olist);
               }
            }
         } else
            throw new OrderMoneySettleException(e.getCode(), "维权处理出错:" + e.getMsg());
      }
      // 添加结算映射