| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
| | | private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userinfoMapper;
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
| | | // 生成二维码信息
|
| | | // 包含用户ID与商品ID
|
| | | // 新版商品分享
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | |
|
| | | SystemEnum system= userInfoService.getUserSystem(uid);
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(system),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goods.getAuctionId() + "");
|
| | |
|
| | |
| | | // throw new ShareGoodsException(4, "生成二维码失败");
|
| | | // }
|
| | | // 获取到用户的头像
|
| | | UserInfo user = userinfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | InputStream portrait = null;
|
| | | if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
|
| | | try {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLinkForShare(Long uid, Long auctionId, String relationId) throws ShareGoodsException {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (auctionId == null || auctionId <= 0) {
|
| | | throw new ShareGoodsException(2, "商品ID不能为空");
|
| | | }
|
| | |
|
| | | TaoKeAppInfo info = new TaoKeAppInfo();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | String pid = TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT;
|
| | | String appId = pid.split("_")[2];
|
| | | String adzoneId = pid.split("_")[3];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(pid);
|
| | | } else {
|
| | | TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
|
| | | if (tbPid == null) {
|
| | | throw new ShareGoodsException(3, "获取推广位失败");
|
| | | }
|
| | | String appId = tbPid.getPid().split("_")[2];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | String adzoneId = tbPid.getPid().split("_")[3];
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(tbPid.getPid());
|
| | | }
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(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")) {
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | |
|
| | | String link = taoBaoGoodsCacheUtil.getBaseConvertLink(auctionId, info.getPid());
|
| | | if (link != null) {
|
| | | goods.setCouponLink(link);
|
| | | } else {// 缓存
|
| | | DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
|
| | | if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
|
| | | || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, info.getPid());
|
| | | } else if (goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {// 有券
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, info.getPid());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | goods.setCouponLink(link);
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, info.getPid(), link);
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(link)) {
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl()))
|
| | | goods.setAuctionUrl(goods.getAuctionUrl() + "&relationId=" + relationId);
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | goods.setCouponLink(goods.getCouponLink() + "&relationId=" + relationId);
|
| | | }
|
| | |
|
| | | // 保存商品详情
|
| | |
|
| | | // 创建淘口令
|
| | | TaoBaoLink tbLink = new TaoBaoLink();
|
| | | tbLink.setAuctionId(goods.getAuctionId());
|
| | | tbLink.setClickUrl(goods.getAuctionUrl());
|
| | | tbLink.setCouponLink(goods.getCouponLink());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
|
| | | tbLink.getCouponLink());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | | } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
|
| | | tbLink.getClickUrl());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | |
|
| | | tbLink.setGoods(goods);
|
| | |
|
| | | // 存储分享商品的信息,用于加快分享网页接口请求速度
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.saveTaoBaoGoodsBriefTemp(goods);
|
| | |
|
| | | LogManager.getLogger(LogType.taobaoTrade)
|
| | | .info(String.format("淘宝商品分享\n UID:%s \n 商品ID:%s \n 券链接%s \n商品链接:%s \n 口令:%s ", uid, auctionId,
|
| | | tbLink.getCouponLink(), tbLink.getClickUrl(), tbLink.getTaoToken()));
|
| | |
|
| | | return tbLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods) {
|
| | | String quanToken = "";
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | |
| | | goods.getAuctionUrl());
|
| | | }
|
| | | return quanToken;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLinkForBuy(Long uid, Long auctionId, int pidType) throws ShareGoodsException {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (auctionId == null || auctionId <= 0) {
|
| | | throw new ShareGoodsException(2, "商品ID不能为空");
|
| | | }
|
| | |
|
| | | TBPid tbPid = tbPidService.getTBPid(uid, pidType);
|
| | | if (tbPid == null) {
|
| | | throw new ShareGoodsException(3, "获取推广位失败");
|
| | | }
|
| | | return getTaoBaoLink(uid, auctionId, tbPid.getPid());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLinkForBuyWithSpecial(Long uid, String specialId, Long auctionId)
|
| | | throws ShareGoodsException {
|
| | | 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(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | |
|
| | | TaoBaoLink taoBaoLink = new TaoBaoLink();
|
| | | taoBaoLink.setAuctionId(auctionId);
|
| | |
|
| | | String baseUrl = taoBaoGoodsCacheUtil.getBaseConvertLink(auctionId, app.getPid());
|
| | | if (!StringUtil.isNullOrEmpty(baseUrl)) {
|
| | | taoBaoLink.setClickUrl(baseUrl);
|
| | | taoBaoLink.setCouponLink(baseUrl);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | | // 查询是否为大淘客商品
|
| | |
|
| | | String link = null;
|
| | | try {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, app.getPid());
|
| | | } catch (Exception e) {
|
| | | }
|
| | | DaTaoKeDetailV2 v2 = daTaoKeGoodsDetailV2Service.selectByAuctionId(auctionId);
|
| | | if (v2 != null) {
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | if (goods != null) {
|
| | | if (DaTaoKeUtil.canFilterCouponInfo(goods, v2)) {
|
| | | // link = DaTaoKeApiUtil.convertLink(auctionId,
|
| | | // app.getPid());
|
| | | |
| | | }
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(4, "商品ID不能为空");
|
| | | }
|
| | | }
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, app.getPid(), link);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | taoBaoLink.setCouponLink(link);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
|
| | | if (goods == null) {
|
| | | throw new ShareGoodsException(1, "");
|
| | | }
|
| | |
|
| | | taoBaoLink.setClickUrl(goods.getAuctionUrl());
|
| | | taoBaoLink.setCouponLink(goods.getCouponLink());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(goods.getYsylClickUrl()))
|
| | | taoBaoLink.setCouponLink(goods.getYsylClickUrl());
|
| | | taoBaoLink.setGoods(goods);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsHistory getShareGoodsHistory(Long uid, Long auctionId) {
|
| | | return userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, auctionId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLinkForShare(Long uid, Long auctionId, String relationId, String pid)
|
| | | throws ShareGoodsException {
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (auctionId == null || auctionId <= 0) {
|
| | | throw new ShareGoodsException(2, "商品ID不能为空");
|
| | | }
|
| | |
|
| | | TaoKeAppInfo info = new TaoKeAppInfo();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | String appId = pid.split("_")[2];
|
| | | String adzoneId = pid.split("_")[3];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(pid);
|
| | | } else {
|
| | | TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
|
| | | if (tbPid == null) {
|
| | | throw new ShareGoodsException(3, "获取推广位失败");
|
| | | }
|
| | | String appId = tbPid.getPid().split("_")[2];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | String adzoneId = tbPid.getPid().split("_")[3];
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(tbPid.getPid());
|
| | | }
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(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")) {
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | |
|
| | | String link = taoBaoGoodsCacheUtil.getBaseConvertLink(auctionId, info.getPid());
|
| | | if (link != null) {
|
| | | goods.setCouponLink(link);
|
| | | } else {// 缓存
|
| | | DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
|
| | | if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
|
| | | || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, info.getPid());
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | goods.setCouponLink(link);
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, info.getPid(), link);
|
| | | }
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(link)) {
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl()))
|
| | | goods.setAuctionUrl(goods.getAuctionUrl() + "&relationId=" + relationId);
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | goods.setCouponLink(goods.getCouponLink() + "&relationId=" + relationId);
|
| | | }
|
| | |
|
| | | // 保存商品详情
|
| | |
|
| | | // 创建淘口令
|
| | | TaoBaoLink tbLink = new TaoBaoLink();
|
| | | tbLink.setAuctionId(goods.getAuctionId());
|
| | | tbLink.setClickUrl(goods.getAuctionUrl());
|
| | | tbLink.setCouponLink(goods.getCouponLink());
|
| | | if (!StringUtil.isNullOrEmpty(goods.getYsylClickUrl()))
|
| | | tbLink.setCouponLink(goods.getYsylClickUrl());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | | } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | |
|
| | | tbLink.setGoods(goods);
|
| | |
|
| | | // 存储分享商品的信息,用于加快分享网页接口请求速度
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.saveTaoBaoGoodsBriefTemp(goods);
|
| | |
|
| | | return tbLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId, String pid)
|
| | | throws ShareGoodsException {
|
| | | if (uid == null || uid <= 0)
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | |
|
| | | if (auctionId == null || auctionId <= 0)
|
| | | throw new ShareGoodsException(1, "商品ID不能为空");
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(1, "该商品已下架");
|
| | | }
|
| | |
|
| | | if (goods == null)
|
| | | throw new ShareGoodsException(1, "该商品已下架");
|
| | |
|
| | | String taoLiJinLink = null;
|
| | | try {
|
| | | goods.setAuctionId(auctionId);
|
| | | taoLiJinLink = userTaoLiJinNewbiesService.createTaoLiJinForBuy(goods, uid);
|
| | | } catch (UserTaoLiJinNewbiesException e1) {
|
| | | throw new ShareGoodsException(e1.getCode(), e1.getMsg());
|
| | | }
|
| | |
|
| | | TaoBaoLink taoBaoLink = new TaoBaoLink();
|
| | | taoBaoLink.setAuctionId(auctionId);
|
| | | taoBaoLink.setClickUrl(goods.getAuctionUrl());
|
| | | taoBaoLink.setCouponLink(taoLiJinLink);
|
| | | taoBaoLink.setGoods(goods);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoLiJinLinkForShare(Long uid, Long auctionId, String relationId) throws ShareGoodsException {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (auctionId == null || auctionId <= 0) {
|
| | | throw new ShareGoodsException(2, "商品ID不能为空");
|
| | | }
|
| | |
|
| | | TaoKeAppInfo info = new TaoKeAppInfo();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | String pid = TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT;
|
| | | String appId = pid.split("_")[2];
|
| | | String adzoneId = pid.split("_")[3];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(pid);
|
| | | } else {
|
| | | TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
|
| | | if (tbPid == null) {
|
| | | throw new ShareGoodsException(3, "获取推广位失败");
|
| | | }
|
| | | String appId = tbPid.getPid().split("_")[2];
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | String adzoneId = tbPid.getPid().split("_")[3];
|
| | | info.setAdzoneId(adzoneId);
|
| | | info.setAppKey(taoBaoUnionConfig.getAppKey());
|
| | | info.setAppSecret(taoBaoUnionConfig.getAppSecret());
|
| | | info.setPid(tbPid.getPid());
|
| | | }
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(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")) {
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService
|
| | | .getConfigByAppIdCache(info.getPid().split("_")[2]);
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | | }
|
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl()))
|
| | | goods.setAuctionUrl(goods.getAuctionUrl() + "&relationId=" + relationId);
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | goods.setCouponLink(goods.getCouponLink() + "&relationId=" + relationId);
|
| | | }
|
| | |
|
| | | // 创建淘口令
|
| | | TaoBaoLink tbLink = new TaoBaoLink();
|
| | | tbLink.setAuctionId(goods.getAuctionId());
|
| | | tbLink.setClickUrl(goods.getAuctionUrl());
|
| | | tbLink.setCouponLink(goods.getCouponLink());
|
| | | tbLink.setGoods(goods);
|
| | |
|
| | | // 存储分享商品的信息,用于加快分享网页接口请求速度
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.saveTaoBaoGoodsBriefTemp(goods);
|
| | |
|
| | | return tbLink;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | if (!canBuy) {
|
| | | throw new ShareGoodsException(3, "立减红包已抢光,请稍后再试");
|
| | | }
|
| | |
|
| | | SystemEnum system= userInfoService.getUserSystem(uid);
|
| | |
|
| | | long currentTime = System.currentTimeMillis();
|
| | | Date sendEndTime = new Date(TimeUtil.convertToTimeTemp(
|
| | |
| | | } catch (TaoLiJinCreateException e1) {
|
| | | if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {// 资金不足
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(app.getAppKey());
|
| | | businessEmergent110Service.tljNoMoney(config.getAccount());
|
| | | businessEmergent110Service.tljNoMoney(config.getAccount(),system);
|
| | | } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {// 商品不允许创建淘礼金
|
| | | tljBuyGoodsService.removeGoods(auctionId);
|
| | | }
|