admin
2019-03-13 69bee82b81626b82b7f39f0e459e4f56b1699b51
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -458,28 +458,47 @@
      if (tbPid == null) {
         throw new ShareGoodsException(3, "获取推广位失败");
      }
      String appId = tbPid.getPid().split("_")[2];
      String adzoneId = tbPid.getPid().split("_")[3];
      return getTaoBaoLink(uid, auctionId, tbPid.getPid());
   }
   @Override
   public TaoBaoLink getTaoBaoLink(Long uid, Long auctionId, String pid) throws ShareGoodsException {
      if (uid == null || uid <= 0) {
         throw new ShareGoodsException(1, "用户ID不能为空");
      }
      if (auctionId == null || auctionId <= 0) {
         throw new ShareGoodsException(2, "商品ID不能为空");
      }
      if (StringUtil.isNullOrEmpty(pid)) {
         throw new ShareGoodsException(3, "无推广位");
      }
      String appId = pid.split("_")[2];
      String adzoneId = pid.split("_")[3];
      TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
      TaoKeAppInfo info = new TaoKeAppInfo();
      info.setAdzoneId(adzoneId);
      info.setAppKey(taoBaoUnionConfig.getAppKey());
      info.setAppSecret(taoBaoUnionConfig.getAppSecret());
      info.setPid(tbPid.getPid());
      info.setPid(pid);
      TaoBaoGoodsBrief goods = null;
      try {
         goods = TaoKeApiUtil.searchGoodsDetailForConvert(auctionId, info);
      } catch (TaobaoGoodsDownException e) {
         throw new ShareGoodsException(4, "商品已下架");
      } finally {
      }
      if (goods == null) {
         throw new ShareGoodsException(5, "获取商品详情失败");
      }
      if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
         TaoBaoLink taoBaoLink = TaoBaoUtil.getTbLinkForShare(auctionId, tbPid.getPid(), taoBaoUnionConfig);
         TaoBaoLink taoBaoLink = TaoBaoUtil.getTbLinkForShare(auctionId, pid, taoBaoUnionConfig);
         if (taoBaoLink == null) {
            throw new ShareGoodsException(201, "商品转链失败");
         }
@@ -498,7 +517,30 @@
   @Override
   public TaoBaoLink getTaoBaoLinkForBuyWithSpecial(Long uid, String specialId, Long auctionId)
         throws ShareGoodsException {
      return null;
      if (uid == null || uid <= 0) {
         throw new ShareGoodsException(1, "用户ID不能为空");
      }
      if (auctionId == null || auctionId <= 0) {
         throw new ShareGoodsException(2, "商品ID不能为空");
      }
      TaoKeAppInfo app = new TaoKeAppInfo();
      app.setAppKey(Constant.TAOBAO_AUTH_APPKEY);
      app.setAppSecret(Constant.TAOBAO_AUTH_APPSECRET);
      app.setPid(Constant.TAOBAO_SPECIAL_PID_DEFAULT);
      TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
      if (goods == null) {
         throw new ShareGoodsException(1, "");
      }
      TaoBaoLink taoBaoLink = new TaoBaoLink();
      taoBaoLink.setAuctionId(auctionId);
      taoBaoLink.setClickUrl(goods.getAuctionUrl());
      taoBaoLink.setCouponLink(goods.getCouponLink());
      taoBaoLink.setGoods(goods);
      return taoBaoLink;
   }
}