| | |
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | |
|
| | | // 没有获取到转过链的商品详情
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
|
| | | TaoBaoLink taoBaoLink = TaoBaoUtil.getTbLinkForShare(auctionId, tbPid.getPid(), taoBaoUnionConfig);
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info); // TaoBaoUtil.getTbLinkForShare(auctionId,
|
| | | // tbPid.getPid(),
|
| | | // taoBaoUnionConfig);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getClickUrl());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | | return addShareGoodsHistory(uid, goods);
|
| | | }
|
| | |
| | | TaoKeAppInfo info = new TaoKeAppInfo();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | String pid = Constant.TAOBAO_RELATION_PID_DEFAULT;
|
| | | String pid = TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT;
|
| | | String appId = pid.split("_")[2];
|
| | | String adzoneId = pid.split("_")[3];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService
|
| | | .getConfigByAppIdCache(info.getPid().split("_")[2]);
|
| | | TaoBaoLink taoBaoLink = TaoBaoUtil.getTbLinkForShare(auctionId, info.getPid(), taoBaoUnionConfig);
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getClickUrl());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | |
| | | return getTaoBaoLink(uid, auctionId, tbPid.getPid());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLink(Long uid, Long auctionId, String pid) throws ShareGoodsException {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | |
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
|
| | | TaoBaoLink taoBaoLink = TaoBaoUtil.getTbLinkForShare(auctionId, pid, taoBaoUnionConfig);
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getClickUrl());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | |
|
| | | // 创建淘口令
|
| | |
| | | }
|
| | |
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(Constant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(Constant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setPid(Constant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
|
| | | if (goods == null) {
|
| | | throw new ShareGoodsException(1, "");
|
| | |
| | | taoBaoLink.setCouponLink(goods.getCouponLink());
|
| | | taoBaoLink.setGoods(goods);
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoods = null;
|
| | | try {
|
| | | taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(2, "商品为空");
|
| | | }
|
| | |
|
| | | String url = goods.getAuctionUrl();
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | url = goods.getCouponLink();
|
| | | String token = TaoKeApiUtil.getTKToken(taoBaoGoods.getPictUrl(), taoBaoGoods.getTitle(), url);
|
| | | taoBaoLink.setTaoToken(token);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsHistory getShareGoodsHistory(Long uid, Long auctionId) {
|
| | | return userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, auctionId);
|
| | | }
|
| | |
|
| | | }
|