| | |
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper;
|
| | | import com.yeshi.fanli.dto.taobao.DaTaoKeFilterResult;
|
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.UserTLJBuyHistory;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.UserTLJBuyHistoryService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | | public class ShareGoodsServiceImpl implements ShareGoodsService {
|
| | |
|
| | |
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userinfoMapper;
|
| | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private UserTLJBuyHistoryService userTLJBuyHistoryService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ConvertLinkManager convertLinkManager;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Override
|
| | | public void addShareGoodsHistory(UserShareGoodsHistory history) {
|
| | |
| | | }
|
| | |
|
| | | 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)) {
|
| | |
| | | tbLink.setCouponLink(goods.getCouponLink());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(), 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());
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
|
| | | tbLink.getClickUrl());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | |
| | | public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods) {
|
| | | String quanToken = "";
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | | quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(), goods.getCouponLink());
|
| | | quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
|
| | | goods.getCouponLink());
|
| | | } else if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
|
| | | quanToken = convertLinkManager.createTaoBaoToken(uid,goods.getPictUrl(), goods.getTitle(), goods.getAuctionUrl());
|
| | | quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(),
|
| | | goods.getAuctionUrl());
|
| | | }
|
| | | return quanToken;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoBaoLinkForBuy(Long uid, Long auctionId, int pidType) throws ShareGoodsException {
|
| | |
|
| | |
| | | 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 taoBaoLink = new TaoBaoLink();
|
| | | taoBaoLink.setAuctionId(auctionId);
|
| | | taoBaoLink.setClickUrl(goods.getAuctionUrl());
|
| | | taoBaoLink.setCouponLink(goods.getCouponLink());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(goods.getYsylClickUrl()))
|
| | | taoBaoLink.setCouponLink(goods.getYsylClickUrl());
|
| | | taoBaoLink.setGoods(goods);
|
| | |
| | | }
|
| | | 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)) {
|
| | |
| | | throw new ShareGoodsException(4, "商品已下架");
|
| | | }
|
| | |
|
| | | BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70));
|
| | | BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false);
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1,
|