admin
2020-04-15 ee5c8055b1c0dd7c67a9025a76b10bd287c93d9a
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -19,10 +19,8 @@
import org.yeshi.utils.exception.HttpException;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper;
import com.yeshi.fanli.dao.mybatis.share.PidUserMapper;
import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -39,20 +37,19 @@
import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinNewbiesException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.LogManager;
import com.yeshi.fanli.log.LogType;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
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.tlj.UserTaoLiJinRecordService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FilePathEnum;
@@ -68,8 +65,7 @@
@Service
public class ShareGoodsServiceImpl implements ShareGoodsService {
   @Resource
   private PidUserMapper pidUserMapper;
   @Resource
   private TBPidService tbPidService;
@@ -77,8 +73,6 @@
   @Resource
   private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
   @Resource
   private HongBaoManageMapper hongBaoManageMapper;
   @Resource
   private UserInfoMapper userinfoMapper;
@@ -98,17 +92,6 @@
   @Resource
   private HongBaoManageService hongBaoManageService;
   @Resource
   private UserShareGoodsRecordService userShareGoodsRecordService;
   @Resource
   private CommonGoodsService commonGoodsService;
   @Resource
   private UserMoneyExtraService userMoneyExtraService;
   @Resource
   private UserTaoLiJinRecordService userTaoLiJinRecordService;
   @Resource
   private UserTLJBuyHistoryService userTLJBuyHistoryService;
@@ -122,6 +105,9 @@
   @Resource
   private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
   
   @Resource
   private ConvertLinkManager convertLinkManager;
   @Override
   public void addShareGoodsHistory(UserShareGoodsHistory history) {
      UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper
@@ -305,7 +291,8 @@
         }
         FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
               FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_" + System.currentTimeMillis() + ".png");
               FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_"
                     + System.currentTimeMillis() + ".png");
         if (shareImgResult == null || StringUtil.isNullOrEmpty(shareImgResult.getUrl())) {
            throw new ShareGoodsException(6, "分享图片保存失败");
@@ -421,8 +408,6 @@
      }
      TaoBaoGoodsBrief goods = null;
      try {
         // 测试
         // info.setAdzoneId("123");
         goods = TaoKeApiUtil.searchGoodsDetail(auctionId, info);
      } catch (TaobaoGoodsDownException e) {
         throw new ShareGoodsException(4, "商品已下架");
@@ -433,8 +418,6 @@
      }
      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, "商品转链失败");
@@ -459,12 +442,12 @@
      tbLink.setCouponLink(goods.getCouponLink());
      if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
         String quanToken = TaoKeApiUtil.getTKToken(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 = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
         String quanToken = convertLinkManager.createTaoBaoToken(uid,goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
         if (!StringUtil.isNullOrEmpty(quanToken)) {
            tbLink.setTaoToken(quanToken);
         }
@@ -476,9 +459,24 @@
      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())) {// 通过立即推广方式获取淘口令成功
         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());
      }
      return quanToken;
   }
   @Override
   public TaoBaoLink getTaoBaoLinkForBuy(Long uid, Long auctionId, int pidType) throws ShareGoodsException {
@@ -680,22 +678,22 @@
   @Override
   public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId, String pid)
         throws ShareGoodsException {
      if (uid == null || uid <= 0)
      if (uid == null || uid <= 0)
         throw new ShareGoodsException(1, "用户ID不能为空");
      if (auctionId == null || auctionId <= 0)
      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)
      if (goods == null)
         throw new ShareGoodsException(1, "该商品已下架");
      String taoLiJinLink = null;
      try {
         goods.setAuctionId(auctionId);