yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -25,7 +25,9 @@
import com.yeshi.fanli.exception.taobao.TaoBaoAuthException;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.TLJLogHelper;
import com.yeshi.fanli.log.TaoKeLogHelper;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@@ -38,8 +40,6 @@
//淘宝客API接口
public class TaoKeApiUtil {
   // 解析券的内容
   private static TaoBaoSearchResult parseCoupleContent(String content) {
@@ -339,22 +339,6 @@
            System.out.println(goods.getAuctionId() + ":" + g.getAuctionId());
            if (goods.getAuctionId().longValue() == g.getAuctionId()) {
               g.setId(goods.getAuctionId());
               // 判断是否有优惠券
               if (!StringUtil.isNullOrEmpty(g.getCouponActivityId())) {
                  // 获取优惠券详情
                  QuanInfo quanInfo = getQuanInfo(g.getAuctionId(), g.getCouponActivityId());
                  if (quanInfo != null) {
                     g.setCouponAmount(quanInfo.coupon_amount);
                     g.setCouponEffectiveEndTime(quanInfo.coupon_end_time);
                     g.setCouponEffectiveStartTime(quanInfo.coupon_start_time);
                     g.setCouponLeftCount(quanInfo.coupon_remain_count);
                     g.setCouponStartFee(quanInfo.coupon_start_fee);
                     g.setCouponTotalCount(quanInfo.coupon_total_count);
                  }
               } else {
                  g.setCouponAmount(new BigDecimal(0));
                  g.setCouponStartFee(new BigDecimal(0));
               }
               g.setCreatetime(new Date());
               g.setMaterialLibType(goods.getMaterialLibType());
               return g;
@@ -892,10 +876,9 @@
      if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
         List<BigDecimal> quanInfo = TaoBaoCouponUtil.getCouponInfo(goods.getCouponInfo());
         goods.setCouponAmount(quanInfo.get(1));
         goods.setCouponEffectiveEndTime(
               TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24, "yyyy-MM-dd"));
         goods.setCouponEffectiveStartTime(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
         goods.setCouponStartFee(quanInfo.get(0));
         goods.setCouponEffectiveEndTime(item.optString("coupon_end_time"));
         goods.setCouponEffectiveStartTime(item.optString("coupon_start_time"));
         goods.setCouponStartFee(new BigDecimal(item.optString("coupon_start_fee")));
         goods.setCouponLeftCount(item.optInt("coupon_remain_count"));
         goods.setCouponLink("https:" + item.optString("coupon_share_url"));
         goods.setCouponTotalCount(item.optInt("coupon_total_count"));
@@ -1708,7 +1691,7 @@
   public static void taoKeContent() {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.content.get");
      map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
      map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
      map.put("type", "1");
      map.put("count", "100");
@@ -1922,7 +1905,7 @@
   // 淘礼金创建
   public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
         Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app)
         throws TaoKeApiException {
         throws TaoKeApiException, TaoLiJinCreateException {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.dg.vegas.tlj.create");
      map.put("adzone_id", app.getPid().split("_")[3]);
@@ -1964,14 +1947,15 @@
            // 接口返回异常
            String msgCode = root.optJSONObject("result").optString("msg_code");
            if (!StringUtil.isNullOrEmpty(msgCode)) {
               TLJLogHelper.info(auctionId, root.toString());// 淘礼金异常信息记录
               switch (msgCode) {
               case "FAIL_BIZ_ITEM_FORBIDDEN":
                  throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_FORBIDDEN, "该商品不支持创建淘礼金红包");
                  throw new TaoLiJinCreateException(TaoLiJinCreateException.CODE_TLJ_FORBIDDEN, "该商品不支持创建淘礼金红包");
               case "FAIL_BIZ_ACCOUNT_UN_PAID":
               case "PRE_FREEZE_ASSET_ACCOUNT_ERROR":
                  throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足");
                  throw new TaoLiJinCreateException(TaoLiJinCreateException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足");
               default:
                  return null;
                  throw new TaoKeApiException(Integer.parseInt(msgCode), root.toString());
               }
            }
         }