yujian
2019-07-29 a1175313094799efcdbbecf2840a90350d3159a7
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -75,6 +75,7 @@
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
import com.yeshi.fanli.vo.goods.CouponInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.MoneyInfoVO;
@@ -396,9 +397,8 @@
         extraVO.setIsNative(true);
      } 
      // 商品链接
      String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), id + "");
      String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + "");
      try {
         extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
      } catch (Exception e) {
@@ -519,9 +519,7 @@
      }
      
      // 分享路径
      String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
      ShareVO shareInfoVO = new ShareVO();
      shareInfoVO.setUrl(shareUrl);
      shareInfoVO.setHelpLink(helpLink);
      extraVO.setShare(shareInfoVO);
@@ -585,8 +583,16 @@
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, fanLiRate, shareRate);
      CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
      if (couponInfo != null) {
         // 券链接处理
         String materialId = "https://item.jd.com/" + id + ".html";
         String url = JDApiUtil.convertShortLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON+"", null);
         couponInfo.setLink(url);
      }
      ShopInfoVO shopInfo = goodsDetail.getShopInfo();
      if (shopInfo != null) {
         if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
@@ -649,8 +655,8 @@
      }
      // 商品链接
      String h5Url = String.format("http://%s%s?id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), jdGoods.getSkuId() + "", Constant.SOURCE_TYPE_JD);
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
      try {
         extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
      } catch (Exception e) {
@@ -664,11 +670,7 @@
         helpLink = configService.get("no_rebate_help_link");
      }
      // 分享路径
      String shareUrl = String.format("%s?id=" + jdGoods.getSkuId(),
            Constant.systemCommonConfig.getAppShareInfoUrl());
      ShareVO shareInfoVO = new ShareVO();
      shareInfoVO.setUrl(shareUrl);
      shareInfoVO.setHelpLink(helpLink);
      extraVO.setShare(shareInfoVO);
@@ -717,8 +719,13 @@
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
      CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
      if (couponInfo != null) {
         String url = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
         couponInfo.setLink(url);
      }
      ShopInfoVO shopInfo = goodsDetail.getShopInfo();
      if (shopInfo != null) {
         if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
@@ -738,24 +745,34 @@
      // 图文详情
      extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id="+ id);
      
      Long inOrderCount30Days = pddGoods.getSoldQuantity();
      List<ShamUser> listShareUser = new ArrayList<ShamUser>();
      MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
      if (moneyInfo != null) {
         String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
         if (Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
            listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
      String salesTip = pddGoods.getSalesTip();
      if (!StringUtil.isNullOrEmpty(salesTip)) {
         int totalSales = 0;
         if (salesTip.contains("万")) {
            salesTip = salesTip.substring(0, salesTip.indexOf("万"));
            totalSales= (int) (Float.parseFloat(salesTip) * 10000);
         } else {
            totalSales = Integer.parseInt(salesTip);
         }
      }
      extraVO.setListShareUser(listShareUser);
         List<ShamUser> listShareUser = new ArrayList<ShamUser>();
         MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
         if (moneyInfo != null) {
            String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
            if (totalSales >= 50000) {
               listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
            }
         }
         extraVO.setListShareUser(listShareUser);
      // 领券人列表
      List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
      if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
         listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
         // 领券人列表
         List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
         if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
            listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
         }
         extraVO.setListCouponUser(listCouponUser);
      }
      extraVO.setListCouponUser(listCouponUser);
      if (uid != null) {
         // 是否加入收藏
         CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
@@ -772,9 +789,9 @@
         extraVO.setIsNative(true);
      }
      // 商品链接
      String h5Url = String.format("http://%s%s?id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), id + "", Constant.SOURCE_TYPE_PDD);
      // 分享路径
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "",   id + "");
      try {
         extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
      } catch (Exception e) {
@@ -788,10 +805,8 @@
      if (StringUtil.isNullOrEmpty(helpLink)) {
         helpLink = configService.get("no_rebate_help_link");
      }
      // 分享路径
      String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
      ShareVO shareInfoVO = new ShareVO();
      shareInfoVO.setUrl(shareUrl);
      shareInfoVO.setHelpLink(helpLink);
      extraVO.setShare(shareInfoVO);
@@ -829,7 +844,7 @@
      // 京东
      if (goodsType == Constant.SOURCE_TYPE_JD) {
         JSONObject data = new JSONObject();
         data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
         data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
      
         List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
         if (list == null) {
@@ -843,7 +858,7 @@
         List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
         
         for (JDGoods goods: list) {
            listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate));
            listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate));
         }
         
         // 取偶数个数据
@@ -851,7 +866,7 @@
            listDetailVO.remove(listDetailVO.size() - 1);
         }
                  
         data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
         data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
         out.print(JsonUtil.loadTrueResult(data));
         return;
      }
@@ -859,7 +874,7 @@
      // 拼多多
      if (goodsType == Constant.SOURCE_TYPE_PDD) {
         JSONObject data = new JSONObject();
         data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
         data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
         
         List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
         
@@ -883,7 +898,7 @@
                  BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                  BigDecimal shareRate = hongBaoManageService.getShareRate();
                  for (PDDGoodsDetail goods : goodsList) {
                     listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate));
                     listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate));
                  }
               }
            }
@@ -894,7 +909,7 @@
            listDetailVO.remove(listDetailVO.size() - 1);
         }
         
         data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
         data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
         out.print(JsonUtil.loadTrueResult(data));
         return;
      }
@@ -1014,7 +1029,7 @@
      if (couponInfo != null) {
         couponUrl = couponInfo.getLink();
      }
      String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", id + "");
      String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", uid + "");
      
      JSONObject data = new JSONObject();
      data.put("native", true);