admin
2020-06-10 271ae63c20fcbe28d29c47f1881138ff6551a2a1
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -22,11 +22,14 @@
import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -42,12 +45,17 @@
import com.yeshi.fanli.entity.order.ESOrder;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
import com.yeshi.fanli.entity.order.SourceTypeEnum;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.entity.suning.SuningOrderInfo;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrderGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.entity.vipshop.VipShopOrder;
import com.yeshi.fanli.entity.vipshop.VipShopOrderDetail;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
@@ -80,9 +88,12 @@
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
import com.yeshi.fanli.util.suning.SuningApiUtil;
import com.yeshi.fanli.util.suning.SuningUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.user.UserLevelUtil;
import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -145,6 +156,9 @@
   @Resource
   private UserLevelManager userLevelManager;
   @Resource
   private TaoBaoOrderGoodsMapper taoBaoOrderGoodsMapper;
   @Resource(name = "producer")
   private Producer orderProducer;
@@ -213,6 +227,7 @@
         List<Integer> listSource) throws CommonOrderException, Exception {
      int pageSize = Constant.PAGE_SIZE;
      List<CommonOrderVO> listOrder = commonOrderMapper.listUserOrder((page - 1) * pageSize, pageSize, uid, state,
            type, orderState, orderNo, startTime, endTime, dateType, listSource);
@@ -315,7 +330,7 @@
      // 当前用户是否VIP
      boolean vip = userInviteService.verifyVIP(uid);
      // 是否存在奖励券
      boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid);
      for (CommonOrderVO order : listOrder) {
@@ -585,23 +600,24 @@
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType) {
            // 奖励订单、免单 使用记录
            if (sourceType == null) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData,
                     hongBao);
            } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip,
                     acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, acceptData,
                     hongBao);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip,
                     acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, acceptData,
                     hongBao);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip,
                     acceptData);
                     acceptData, hongBao);
            }
         }
         // 分享、邀请 隐藏订单号
         if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType
               || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
         // 邀请 隐藏订单号
         if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
            order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
         }
      }
@@ -617,7 +633,8 @@
    * @param signList
    */
   private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
         List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception {
         List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao)
         throws Exception {
      // 是否免单商品
      boolean freeOrder = false;
@@ -713,6 +730,11 @@
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 使用奖励券 金额额限制
      if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0) {
         return;
      }
      // 是否可使用奖励券
@@ -869,7 +891,6 @@
      return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
   }
   @Override
   public BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
      BigDecimal weiQuanMoney = new BigDecimal(0);
@@ -931,8 +952,14 @@
         if ("饿了么".equalsIgnoreCase(taoBaoOrder.getOrderType())) {
            cog.setGoodsId(taoBaoOrder.getTradeId() + "");
            cog.setGoodsType(Constant.SOURCE_TYPE_ELME);
            cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
            cog.setTitle(taoBaoOrder.getTitle());
            TaoBaoOrderGoods goods = taoBaoOrderGoodsMapper.selectByTradeId(taoBaoOrder.getTradeId());
            if (goods == null) {
               cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
               cog.setTitle(taoBaoOrder.getTitle());
            } else {
               cog.setPicture(goods.getImg());
               cog.setTitle(goods.getTitle());
            }
            newCommonOrder.setCommonOrderGoods(cog);
         } else {
            cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
@@ -1135,6 +1162,123 @@
            commonOrderGoodsMapper.insertSelective(cog);
         } else {
         }
         newCommonOrder.setUserInfo(new UserInfo(uid));
         commonOrderList.add(addCommonOrder(newCommonOrder));
      }
      addConfirmMQMsg(commonOrderList);
      return commonOrderList;
   }
   @Transactional(rollbackFor = Exception.class)
   @Override
   public List<CommonOrderAddResultDTO> addVipShopOrder(VipShopOrder vipShopOrder, Long uid)
         throws CommonOrderException {
      List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
      // 判断所有的订单状态
      int invalidCount = 0;
      for (VipShopOrderDetail detail : vipShopOrder.getDetailList()) {
         if (detail.getStatus() == VipShopOrderDetail.STATUS_INVALID) {
            invalidCount++;
         }
      }
      // 获取整体订单的状态
      int wholeOrderState = 0;
      if (vipShopOrder.getDetailList().size() == invalidCount)
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_SHIXIAO;
      else if (invalidCount == 0)
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_YOUXIAO;
      else
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO;
      List<VipShopOrderDetail> orderItemList = vipShopOrder.getDetailList();
      vipShopOrder.setDetailList(null);
      for (VipShopOrderDetail itemOrder : orderItemList) {
         itemOrder.setOrder(vipShopOrder);
         CommonOrder newCommonOrder = CommonOrderFactory.create(itemOrder);
         CommonOrderGoods cog = new CommonOrderGoods();
         cog.setGoodsId(itemOrder.getGoodsId());
         cog.setGoodsType(Constant.SOURCE_TYPE_VIP);
         newCommonOrder.setCommonOrderGoods(cog);
         newCommonOrder.setStateWholeOrder(wholeOrderState);
         // 订单商品插入
         List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(),
               cog.getGoodsType());
         if (commonGoodsList.size() <= 0)// 不存在就插入商品
         {
            VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(itemOrder.getGoodsId());
            if (goods == null) {
               goods = new VIPGoodsInfo();
               goods.setGoodsName(itemOrder.getGoodsName());
               goods.setVipPrice("");
               goods.setGoodsId(itemOrder.getGoodsId());
               goods.setGoodsThumbUrl(itemOrder.getGoodsThumb());
            }
            if (goods != null) {
               cog = CommonOrderGoodsFactory.create(goods);
            }
            cog.setCreateTime(new Date());
            cog.setUpdateTime(new Date());
            commonOrderGoodsMapper.insertSelective(cog);
         } else {
         }
         newCommonOrder.setUserInfo(new UserInfo(uid));
         commonOrderList.add(addCommonOrder(newCommonOrder));
      }
      addConfirmMQMsg(commonOrderList);
      return commonOrderList;
   }
   @Transactional(rollbackFor = Exception.class)
   @Override
   public List<CommonOrderAddResultDTO> addSuningOrder(List<SuningOrderInfo> suningOrderList, Long uid)
         throws CommonOrderException {
      List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
      // 判断所有的订单状态
      int invalidCount = 0;
      for (SuningOrderInfo order : suningOrderList) {
         if ("退款".equalsIgnoreCase(order.getOrderLineStatusDesc())
               || "订单已取消".equalsIgnoreCase(order.getOrderLineStatusDesc())) {
            invalidCount++;
         }
      }
      // 获取整体订单的状态
      int wholeOrderState = 0;
      if (suningOrderList.size() == invalidCount)
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_SHIXIAO;
      else if (invalidCount == 0)
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_YOUXIAO;
      else
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO;
      for (SuningOrderInfo suningOrderInfo : suningOrderList) {
         CommonOrder newCommonOrder = CommonOrderFactory.create(suningOrderInfo);
         CommonOrderGoods cog = new CommonOrderGoods();
         cog.setGoodsId(suningOrderInfo.getGoodsNum() + "");
         cog.setGoodsType(Constant.SOURCE_TYPE_SUNING);
         newCommonOrder.setCommonOrderGoods(cog);
         newCommonOrder.setStateWholeOrder(wholeOrderState);
         // 订单商品插入
         List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(),
               cog.getGoodsType());
         if (commonGoodsList.size() <= 0)// 不存在就插入商品
         {
            SuningGoodsInfo pddGoods = null;
            // TODO 需要获取
            pddGoods = SuningApiUtil.getGoodsDetail(suningOrderInfo.getGoodsNum(), suningOrderInfo.getSellerCode());
            if (pddGoods != null) {
               cog = CommonOrderGoodsFactory.create(pddGoods);
            }
            cog.setCreateTime(new Date());
            cog.setUpdateTime(new Date());
            commonOrderGoodsMapper.insertSelective(cog);
            newCommonOrder.setCommonOrderGoods(cog);
         } else {
         }
         newCommonOrder.setUserInfo(new UserInfo(uid));
         commonOrderList.add(addCommonOrder(newCommonOrder));
@@ -1789,505 +1933,6 @@
      return listVO;
   }
   /**
    * 订单信息加工
    *
    * @param acceptData
    * @param listOrder
    * @param listGoods
    * @param uid
    */
   private void orderVOFactoryNew(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
         Long uid) throws Exception {
      List<String> listTB = new ArrayList<String>();
      List<String> listJD = new ArrayList<String>();
      List<String> listPDD = new ArrayList<String>();
      for (CommonOrderVO commonOrderVO : listOrder) {
         Integer sourceType = commonOrderVO.getSourceType();
         if (sourceType == null) {
            continue;
         } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            listTB.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_JD) {
            listJD.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            listPDD.add(commonOrderVO.getOrderNo());
         }
      }
      List<UserSystemCouponRecord> listRecordTB = null;
      if (listTB.size() > 0) {
         listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
      }
      List<UserSystemCouponRecord> listRecordJD = null;
      if (listJD.size() > 0) {
         listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
      }
      List<UserSystemCouponRecord> listRecordPDD = null;
      if (listPDD.size() > 0) {
         listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
      }
      // 需要查询是否为VIP的用户ID,只有邀请订单才需要查询
      List<Long> needSelectVIPUidList = new ArrayList<>();
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI)
            needSelectVIPUidList.add(Long.parseLong(order.getUserId()));
      }
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) {
            Integer urank = order.getUrank();
            if (urank != null) {
               String levelName = UserLevelUtil.getLevelName(urank);
               if (!StringUtil.isNullOrEmpty(levelName)) {
                  order.setOrderDesc("订单来源:" + levelName);
               }
            }
         }
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
      SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
      // 2019.8.1开始返回维权信息
      Date august = TimeUtil.parse("2019-08-01");
      // 当前用户是否可以使用奖励券
      boolean isvip = userInviteService.verifyVIP(uid);
      // 是否存在奖励券
      boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid);
      for (CommonOrderVO order : listOrder) {
         String orderNo = order.getOrderNo();
         Integer sourceType = order.getSourceType();
         Integer hongBaoType = order.getHongBaoType();
         // 商品信息组合
         for (CommonOrderVO commonOrder : listGoods) {
            CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
            if (goods == null) {
               continue;
            }
            if (sourceType.equals(commonOrder.getSourceType()) && orderNo.equals(commonOrder.getOrderNo())) {
               CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO();
               PropertyUtils.copyProperties(commonGoodsVO, goods);
               if (commonGoodsVO.getGoodsType() == null) {
                  commonGoodsVO.setGoodsType(sourceType);
               }
               // 淘宝商品图片处理
               String picture = commonGoodsVO.getPicture();
               if (sourceType == Constant.SOURCE_TYPE_TAOBAO && !StringUtil.isNullOrEmpty(picture)
                     && !picture.contains("320x320")) {
                  commonGoodsVO.setPicture(TbImgUtil.getTBSize320Img(picture));
               }
               // 购买数量
               commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "件");
               // 实付款
               BigDecimal totalSettlement = commonOrder.getTotalSettlement();
               if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                  totalSettlement = commonOrder.getTotalPayment();
               }
               commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
               // 邀请订单信息保护
               if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                     || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
                     || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
                  Map<String, String> titleMap = new HashMap<String, String>();
                  titleMap.put("content", "为保障用户隐私,商品信息已隐藏!");
                  titleMap.put("fontColor", "#888888");
                  titleMap.put("bottomColor", "#E9E9E9");
                  commonGoodsVO.setTitle(null);
                  commonGoodsVO.setGoodsTitle(titleMap);
               }
               // 订单类型为空时 已商品类为准
               String shopType = commonGoodsVO.getShopType();
               if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) {
                  order.setOrderType(1);
               } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                  order.setOrderType(2);
               }
               Integer goodsType = commonGoodsVO.getGoodsType();
               if (goodsType != null & goodsType == Constant.SOURCE_TYPE_ELME) {
                  order.setOrderType(Constant.SOURCE_TYPE_ELME); // 饿了么订单
               }
               order.getListOrderGoods().add(commonGoodsVO);
            }
         }
         // 订单类型
         if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            Integer orderType = order.getOrderType();
            if (orderType == null) {
               order.setOrderType(1);
            }
         } else if (sourceType == Constant.SOURCE_TYPE_JD) {
            order.setOrderType(3);
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            order.setOrderType(4);
         }
         Date thirdCreateTime = order.getThirdCreateTime();
         if (thirdCreateTime != null) {
            order.setDownTime("下单时间:" + format.format(thirdCreateTime));
            order.setObtainTime(thirdCreateTime.getTime());
         }
         Date settleTime = order.getSettleTime();
         if (settleTime != null) {
            order.setReceiveTime("收货时间:" + format.format(settleTime));
         }
         /* 订单状态 转换处理 */
         String orderStateContent = "";
         Map<String, String> orderStateMap = new HashMap<String, String>();
         // 订单状态
         Integer orderState = order.getState();
         // 红包状态
         Integer hongBaoState = order.getHongBaoState();
         Integer stateWholeOrder = order.getStateWholeOrder();
         if (CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO == stateWholeOrder) {
            // 整个订单部分失效:判断真实状态 订单、红包
            CommonOrderVO buFenOrder = commonOrderMapper.getBuFenOrderState(uid, order.getOrderNo());
            if (buFenOrder != null) {
               // 有效的订单状态
               orderState = buFenOrder.getState();
               // 有效的红包状态
               hongBaoState = buFenOrder.getHongBaoState();
            }
         }
         // 2.1显示返利说明连接> 未失效-自购-分享
         if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
            if (CommonOrder.STATE_SX != orderState
                  && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)
                  && ((HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType)
                        || HongBaoV2.TYPE_SHARE_GOODS == hongBaoType)) {
               String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
               order.setRebateLink(rebateLink + "?orderNo=" + orderNo + "&sourceType=" + sourceType);
            }
         }
         BigDecimal hongBao = order.getHongBao();
         if (hongBao == null) {
            hongBao = new BigDecimal(0);
         }
         if (CommonOrder.STATE_FK == orderState) {
            orderStateContent = "已付款";
         } else if (CommonOrder.STATE_JS == orderState) {
            orderStateContent = "已收货";
         } else if (CommonOrder.STATE_SX == orderState) {
            orderStateContent = "未付款/已退款";
         } else if (CommonOrder.STATE_WQ == orderState) {
            orderStateContent = "已售后";
            if (sourceType != null && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               /* 订单维权 判断是否全部维权 */
               List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                     .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
               BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
               if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) {
                  orderStateContent = "售后成功";
                  WeiQuanInfo weiQuanInfo = new WeiQuanInfo();
                  weiQuanInfo.setOldHongBao("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
                  weiQuanInfo.setWqHongBao("售后:-¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
                  hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
                  order.setWeiQuanInfo(weiQuanInfo);
               }
            }
         }
         orderStateMap.put("content", orderStateContent);
         orderStateMap.put("fontColor", "#666666");
         order.setOrderState(orderStateMap);
         String hongbaoInfo = "";
         // 订单标识
         List<String> signList = new ArrayList<String>();
         /* 订单返利类型 转换 */
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            // 自购
            hongbaoInfo = "返利";
            order.setOrderOrigin("1");
            order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
            signList.add(CommonOrder.TYPE_FANLI);
         } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
            // 分享
            hongbaoInfo = "奖金";
            order.setOrderOrigin("2");
            order.setHongBaoTypePic(CommonOrder.TYPE_SHARE);
            signList.add(CommonOrder.TYPE_SHARE);
         } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
            // 下级的分享订单: 显示邀请
            hongbaoInfo = "奖金";
            order.setOrderOrigin("3");
            order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            signList.add(CommonOrder.TYPE_INVITE);
         } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType) {
            // 邀请订单
            hongbaoInfo = "奖金";
            order.setOrderOrigin("3");
            order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            signList.add(CommonOrder.TYPE_INVITE);
            // 超级会员补贴信息
            InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, order.getOrderNo(),
                  sourceType);
            if (orderSubsidy != null) {
               ClientTextStyleVO subsidyInfo = new ClientTextStyleVO();
               subsidyInfo.setContent("(补贴¥" + orderSubsidy.getMoney() + ")");
               if (orderSubsidy.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED) {
                  subsidyInfo.setColor("#E5005C");
               } else {
                  subsidyInfo.setColor("#888888");
               }
               order.setSubsidy(subsidyInfo);
               // 解释信息(问号)
               List<String> subsidyList = new ArrayList<String>();
               subsidyList.add("额外补贴能否获得由系统算法自动判断,人为无法干涉;");
               subsidyList.add("额外补贴到账时间以及金额请以实际到账为准;");
               subsidyList.add("额外补贴产生后将会在消息-资金消息中提醒你。");
               order.setSubsidyList(subsidyList);
            }
         }
         order.setSignList(signList);
         String hongBaoDate = null;
         String hongBaoState_Str = "";
         String hongbaoInfoFontColor = "#E5005C";
         /* 红包状态 转换 */
         String stateContent = "";
         String stateFontColor = "#E5005C";
         Integer orderHongBaoState = null;
         if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
            orderHongBaoState = 1;
            stateContent = "未到账";
            hongBaoState_Str = "预估";
            Date preAccountTime = order.getPreAccountTime();
            if (preAccountTime != null) {
               hongBaoDate = "预计到账时间:" + formatday.format(preAccountTime);
            }
         } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
            orderHongBaoState = 3;
            stateContent = "已到账";
            Date accountTime = order.getAccountTime();
            if (accountTime != null) {
               hongBaoDate = "到账时间:" + formatday.format(accountTime);
            }
         } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) {
            stateContent = "部分失效";
            orderHongBaoState = 3;
            Date accountTime = order.getAccountTime();
            if (accountTime != null) {
               hongBaoDate = "到账时间:" + formatday.format(accountTime);
            }
         } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
            orderHongBaoState = 4;
            stateContent = "已失效";
            hongbaoInfoFontColor = "#888888";
         }
         order.setHongBaoState(orderHongBaoState);
         order.setHongBaoDate(hongBaoDate);
         if (!StringUtil.isNullOrEmpty(order.getStateDesc())) {
            stateContent = stateContent + "-" + order.getStateDesc();
         }
         Map<String, String> stateMap = new HashMap<String, String>();
         stateMap.put("content", stateContent);
         stateMap.put("fontColor", stateFontColor);
         order.setAccountState(stateMap);
         hongbaoInfo = hongBaoState_Str + hongbaoInfo;
         Map<String, String> hongBaoMap = new HashMap<String, String>();
         hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
         hongBaoMap.put("fontColor", hongbaoInfoFontColor);
         order.setHongBaoInfo(hongBaoMap);
         // 显示返利、免单详情
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType) {
            // 奖励订单、免单 使用记录
            if (sourceType == null) {
               couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, isvip);
            } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, isvip);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, isvip);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
               couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, isvip);
            }
         }
         // 分享、邀请 隐藏订单号
         if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType
               || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
            order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
         }
      }
   }
   /**
    * 订单: 免单标识 奖励标识
    *
    * @param order
    * @param hasRewardCoupon
    * @param hongBaoState
    * @param list
    * @param signList
    */
   private void couponFactoryNew(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState,
         Integer hongBaoType, List<UserSystemCouponRecord> list, Long uid, boolean vip) throws Exception {
      // 是否免单商品
      boolean freeOrder = false;
      // 是否奖励成功
      boolean rewardSuccess = false;
      if (list != null && list.size() > 0) {
         for (UserSystemCouponRecord couponRecord : list) {
            int goodSource = couponRecord.getGoodSource();
            if (goodSource == 0)
               goodSource = 1;
            if (order.getOrderNo().equals(couponRecord.getOrderNo()) && goodSource == order.getSourceType()) {
               Integer state = couponRecord.getState();
               String systemCouponType = couponRecord.getCouponType();
               if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
                     && UserSystemCouponRecord.STATE_SUCCESS == state) {
                  rewardSuccess = true;
               } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
                     || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
                     || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
                  if (UserSystemCouponRecord.STATE_FREE_ON == state) {
                     // 免单中
                     freeOrder = true;
                     order.getSignList().add(PIC_FREE_ON);
                  } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
                     // 免单成功
                     freeOrder = true;
                     order.getSignList().add(PIC_FREE_SUCCEED);
                  } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
                        || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
                     // 规则不匹配、退款
                     freeOrder = true;
                     order.getSignList().add(PIC_FREE_FAIL);
                  }
               }
               break;
            }
         }
      }
      // 免单详情
      if (freeOrder) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
         rewardStyleVO.setContent("免单详情 >");
         rewardStyleVO.setColor("#E5005C");
         rewardStyleVO.setBottomColor("#FFDCEA");
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         jumpLink.put("goodsType", order.getSourceType() + "");
         Map<String, Object> jump = new HashMap<String, Object>();
         jump.put("type", 1); // 页面跳转
         jump.put("params", jumpLink);
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
         Map<String, Object> rewardMap = new HashMap<String, Object>();
         rewardMap.put("text", rewardStyleVO);
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 已使用奖励券
      if (rewardSuccess) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
         rewardStyleVO.setColor("#E5005C");
         rewardStyleVO.setBottomColor("#FFDCEA");
         rewardStyleVO.setContent("已使用奖励券 >");
         Map<String, Object> rewardMap = new HashMap<String, Object>();
         rewardMap.put("text", rewardStyleVO);
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         jumpLink.put("goodsType", order.getSourceType() + "");
         Map<String, Object> jump = new HashMap<String, Object>();
         jump.put("type", 1); // 1 常规跳转页面
         jump.put("params", jumpLink);
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 是否可使用奖励券
      if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
            && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) {
         // 下单时间
         Date thirdCreateTime = order.getThirdCreateTime();
         // 到账时间
         Date accountTime = order.getAccountTime();
         if (thirdCreateTime == null || accountTime == null)
            return;
         // 下单日期是否是符合上线日期
         long downOrderTime = thirdCreateTime.getTime();
         long limitDate = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
         if (downOrderTime > limitDate) {
            // 2.1 开始新版
            rewardCounponLimitTime(order, accountTime);
         } else if (hasRewardCoupon) {
            // 在2.1新版上线之前订单-存在则显示奖励券可使用
            ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
            rewardStyleVO.setColor("#E5005C");
            rewardStyleVO.setBottomColor("#FFDCEA");
            rewardStyleVO.setContent("使用奖励券");
            Map<String, Object> jumpLink = new HashMap<String, Object>();
            jumpLink.put("orderNo", order.getOrderNo());
            jumpLink.put("goodsType", order.getSourceType() + "");
            Map<String, Object> jump = new HashMap<String, Object>();
            jump.put("type", 2); // 弹框
            jump.put("params", jumpLink);
            jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
            Map<String, Object> rewardMap = new HashMap<String, Object>();
            rewardMap.put("text", rewardStyleVO);
            rewardMap.put("jump", jump);
            order.setRewardDetail(rewardMap);
         }
      }
   }
   @Override
   public Date getThirdCreateTime(String orderId, int sourceType) {
      List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId);
@@ -2296,15 +1941,13 @@
      return list.get(0).getThirdCreateTime();
   }
   @Override
   public List<CommonOrderVO> getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
         Integer orderState, String orderNo, String startTime, String endTime, Integer dateType,
         List<Integer> listSource) throws CommonOrderException, Exception {
      int pageSize = Constant.PAGE_SIZE;
      List<CommonOrderVO> listOrder = commonOrderMapper.getOrderList((page - 1) * pageSize, pageSize, uid, state,
            type, orderState, orderNo, startTime, endTime, dateType, listSource);
@@ -2328,13 +1971,11 @@
   @Override
   public long countOrderList(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
         String startTime, String endTime, Integer dateType, List<Integer> listSource) throws CommonOrderException {
         String startTime, String endTime, Integer dateType, List<Integer> listSource) {
      return commonOrderMapper.countOrderList(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
            listSource);
   }
   /**
    * 订单信息加工
    * 
@@ -2348,19 +1989,22 @@
      List<String> listTB = new ArrayList<String>();
      List<String> listJD = new ArrayList<String>();
      List<String> listPDD = new ArrayList<String>();
      List<String> listVIP = new ArrayList<String>();
      List<String> listSuNing = new ArrayList<String>();
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_YIJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) {
            Integer urank = order.getUrank();
            if (urank != null) {
               String levelName = UserLevelUtil.getLevelName(urank);
               if (!StringUtil.isNullOrEmpty(levelName)) {
                  order.setOrderDesc("订单来源:" + levelName);
               UserLevelEnum levelEnum = UserLevelUtil.getByOrderRank(urank);
               if (levelEnum != null) {
                  levelEnum = UserLevelUtil.getShowLevel(levelEnum);
                  order.setOrderDesc("订单来源:" + levelEnum.getName());
               }
            }
         }
         Integer sourceType = order.getSourceType();
         if (sourceType == null) {
            continue;
@@ -2370,6 +2014,10 @@
            listJD.add(order.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            listPDD.add(order.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_VIP) {
            listVIP.add(order.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_SUNING) {
            listSuNing.add(order.getOrderNo());
         }
      }
@@ -2388,7 +2036,17 @@
         listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
      }
      List<UserSystemCouponRecord> listRecordVIP = null;
      if (listVIP.size() > 0) {
         listRecordVIP = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_VIP, listVIP);
      }
      List<UserSystemCouponRecord> listRecordSuNing = null;
      if (listSuNing.size() > 0) {
         listRecordSuNing = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_SUNING, listSuNing);
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
      SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
      // 是否存在奖励券
@@ -2452,6 +2110,10 @@
               if (goodsType != null & goodsType == Constant.SOURCE_TYPE_ELME) {
                  order.setOrderType(Constant.SOURCE_TYPE_ELME); // 饿了么订单
               }
               if (goodsType == Constant.SOURCE_TYPE_SUNING) {
                  commonGoodsVO.setGoodsId(SuningUtil.getConcatGoodsIId(commonGoodsVO.getShopId() +"", commonGoodsVO.getGoodsId()));
               }
               order.getListOrderGoods().add(commonGoodsVO);
            }
         }
@@ -2467,6 +2129,21 @@
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            order.setOrderType(4);
         }
         // 子来源类型
         ClientTextStyleVO shopStyleVO = new ClientTextStyleVO();
         SourceTypeEnum typeEnum = SourceTypeEnum.getByDesc(order.getChildSourceType());
         if (typeEnum == null) {
            shopStyleVO.setContent("其他");
            shopStyleVO.setColor("#FF5000");
            shopStyleVO.setBorderColor("#FF5000");
         } else {
            shopStyleVO.setContent(typeEnum.getDescShow());
            shopStyleVO.setColor(typeEnum.getFontColor());
            shopStyleVO.setBorderColor(typeEnum.getBorderColor());
         }
         order.setShopType(shopStyleVO);
         Date thirdCreateTime = order.getThirdCreateTime();
         if (thirdCreateTime != null) {
@@ -2479,7 +2156,6 @@
            order.setReceiveTime("收货时间:" + format.format(settleTime));
         }
         Map<String, String> orderStateMap = new HashMap<String, String>();
         // 订单状态
         Integer orderState = order.getState();
@@ -2492,21 +2168,21 @@
               orderState = buFenOrder.getState();
            }
         }
         // 显示返利说明连接> 未失效
         if (CommonOrder.STATE_SX != orderState
               && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) {
            String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
            order.setRebateLink(rebateLink + "?orderNo=" + orderNo + "&sourceType=" + sourceType);
         }
         // 红包信息
         List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, uid);
         List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo,
               sourceType, uid);
         HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hongBaoOrderList);
         BigDecimal hongBao = hongBaoCountVO.getValidMoney();
         Integer hongBaoState = hongBaoCountVO.getCurrentState();
         /* 订单状态 转换处理 */
         String orderStateContent = "";
         if (CommonOrder.STATE_FK == orderState) {
@@ -2519,8 +2195,17 @@
            orderStateContent = "已售后";
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               /* 订单维权 判断是否全部维权 */
               List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
               List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                     .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
               BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
               if (settleTime != null) {
                  orderStateContent = "售后成功";
                  WeiQuanInfo weiQuanInfo = new WeiQuanInfo();
                  weiQuanInfo.setOldHongBao("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
                  weiQuanInfo.setWqHongBao("售后:-¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
                  order.setWeiQuanInfo(weiQuanInfo);
               }
               hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
            }
         }
@@ -2528,28 +2213,29 @@
         orderStateMap.put("fontColor", "#666666");
         order.setOrderState(orderStateMap);
         String hongbaoInfo = "";
         // 订单标识
         List<String> signList = new ArrayList<String>();
         /* 订单返利类型 转换 */
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            // 自购
            hongbaoInfo = "返利";
            order.setOrderOrigin("1");
            order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
            signList.add(CommonOrder.TYPE_FANLI);
            // 是否已使用奖励券、免单券情况
             if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               couponUseFactory(order, listRecordTB);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               couponUseFactory(order, listRecordJD);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
               couponUseFactory(order, listRecordPDD);
            } else if (sourceType == Constant.SOURCE_TYPE_VIP) {
               couponUseFactory(order, listRecordVIP);
            } else if (sourceType == Constant.SOURCE_TYPE_SUNING) {
               couponUseFactory(order, listRecordSuNing);
            }
         } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
            // 分享
            hongbaoInfo = "奖金";
            order.setOrderOrigin("2");
            order.setHongBaoTypePic(CommonOrder.TYPE_SHARE);
            signList.add(CommonOrder.TYPE_SHARE);
@@ -2558,11 +2244,10 @@
               || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType) {
            // 邀请订单
            hongbaoInfo = "收益";
            order.setOrderOrigin("3");
            order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            signList.add(CommonOrder.TYPE_INVITE);
         }
         }
         order.setSignList(signList);
         String hongBaoDate = null;
@@ -2605,16 +2290,16 @@
         stateMap.put("fontColor", stateFontColor);
         order.setAccountState(stateMap);
         hongbaoInfo = hongBaoState_Str + hongbaoInfo;
         Map<String, String> hongBaoMap = new HashMap<String, String>();
         hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
         hongBaoMap.put("content",
               hongBaoState_Str + "收益 ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
         hongBaoMap.put("fontColor", hongbaoInfoFontColor);
         order.setHongBaoInfo(hongBaoMap);
         // 分享、邀请 隐藏订单号
         if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
         if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
            order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
         }
      }
@@ -2624,20 +2309,14 @@
    * 订单: 免单标识 奖励标识
    * 
    * @param order
    * @param hasRewardCoupon
    * @param hongBaoState
    * @param list
    * @param signList
    */
   private void couponUseFactory(CommonOrderVO order, List<UserSystemCouponRecord> list) throws Exception {
      if (list == null || list.size() == 0) {
         return;
      }
      // 是否免单商品
      boolean freeOrder = false;
      // 是否奖励成功
      boolean rewardSuccess = false;
      String text = null;
      for (UserSystemCouponRecord couponRecord : list) {
         int goodSource = couponRecord.getGoodSource();
         if (goodSource == 0)
@@ -2649,71 +2328,49 @@
            String systemCouponType = couponRecord.getCouponType();
            if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
                  && UserSystemCouponRecord.STATE_SUCCESS == state) {
               // 已使用奖励券
               rewardSuccess = true;
               text = "已奖励";
            } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
                  || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
                  || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
               if (UserSystemCouponRecord.STATE_FREE_ON == state) {
                  // 免单中
                  freeOrder = true;
                  order.getSignList().add(PIC_FREE_ON);
                  text = "免单中";
               } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
                  // 免单成功
                  freeOrder = true;
                  order.getSignList().add(PIC_FREE_SUCCEED);
               } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
                     || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
                  // 规则不匹配、退款
                  freeOrder = true;
                  order.getSignList().add(PIC_FREE_FAIL);
                  text = "已免单";
               }
            }
            break;
         }
      }
      // 免单详情
      if (freeOrder) {
      if (!StringUtil.isNullOrEmpty(text)) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
         rewardStyleVO.setContent("免单详情 >");
         rewardStyleVO.setContent(text);
         rewardStyleVO.setColor("#E5005C");
         rewardStyleVO.setBottomColor("#FFDCEA");
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         jumpLink.put("goodsType", order.getSourceType() + "");
         Map<String, Object> jump = new HashMap<String, Object>();
         jump.put("type", 1); // 页面跳转
         jump.put("params", jumpLink);
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
         Map<String, Object> rewardMap = new HashMap<String, Object>();
         rewardMap.put("text", rewardStyleVO);
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 已使用奖励券
      if (rewardSuccess) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
         rewardStyleVO.setColor("#E5005C");
         rewardStyleVO.setBottomColor("#FFDCEA");
         rewardStyleVO.setContent("已使用奖励券 >");
         Map<String, Object> rewardMap = new HashMap<String, Object>();
         rewardMap.put("text", rewardStyleVO);
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         jumpLink.put("goodsType", order.getSourceType() + "");
         Map<String, Object> jump = new HashMap<String, Object>();
         jump.put("type", 1); // 1 常规跳转页面
         jump.put("params", jumpLink);
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
   }
   @Override
   public long countOrderByUidAndSettled(Long uid, BigDecimal payment) {
      Long count = commonOrderMapper.countOrderByUidAndSettled(uid, payment);
      if (count == null) {
         count = 0L;
      }
      return count;
   }
   @Override
   public String getNewestOrderNoByTaoBao() {
      return commonOrderMapper.getNewestOrderNoByTaoBao();
   }
   @Override
   public List<CommonOrder> listByOrderNo(String orderNo) {
      return commonOrderMapper.listByOrderNo(orderNo);
   }
}