admin
2019-01-23 e179d8660bf4837455a38c24e74320143e0d2e17
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -7,6 +7,8 @@
import java.util.List;
import java.util.Map;
import org.yeshi.utils.taobao.TbImgUtil;
import com.taobao.api.ApiException;
import com.yeshi.fanli.entity.taobao.RelateGoods;
import com.yeshi.fanli.entity.taobao.SearchFilter;
@@ -24,9 +26,6 @@
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import org.fanli.TaoKeTest;
import org.yeshi.utils.taobao.TbImgUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -159,7 +158,7 @@
      map.put("method", "taobao.tbk.item.info.get");
      map.put("num_iids", id + "");
      String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
//      System.out.println(resultStr);
      // System.out.println(resultStr);
      JSONObject data = JSONObject.fromObject(resultStr);
      // 商品下架
      if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15
@@ -221,7 +220,7 @@
         if (item.optBoolean("free_shipment"))
            goods.setFreeShipment(1);
         System.out.println(item.optString("material_lib_type"));
         return goods;
@@ -326,9 +325,9 @@
            if (item.optBoolean("free_shipment"))
               goods.setFreeShipment(1);
            if("1".equalsIgnoreCase(item.optString("material_lib_type")))
               TaoKeTest.count++;
            if ("1".equalsIgnoreCase(item.optString("material_lib_type")))
               ;
            goodsList.add(goods);
         }
      }
@@ -1464,25 +1463,41 @@
   }
   public static String getAccessToken(String code, String appKey, String appSecret) {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.top.auth.token.create");
      map.put("code", code);
      TaoKeAppInfo app = new TaoKeAppInfo();
      app.setAppKey(appKey);
      app.setAppSecret(appSecret);
      try {
         JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
         if (json != null)
            return json.toString();
      } catch (TaoKeApiException e) {
         e.printStackTrace();
      }
      return null;
   }
   /**
    * 渠道邀请码
    * 
    * @param relationId
    * @return
    */
   public static String getInviteCode(Long relationId, String accessToken) {
   public static String getInviteCode(Long relationId, String accessToken, String appKey, String appSecret) {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.sc.invitecode.get");
      map.put("session", accessToken);
      map.put("relation_id", relationId + "");
      map.put("code_type", "2");
      map.put("relation_app", "返利券");
      map.put("code_type", "1");
      map.put("relation_app", "common");
      JSONObject resultJSON = null;
      try {
         TaoKeAppInfo app=new TaoKeAppInfo();
         app.setAppKey("24567001");
         app.setAppSecret("e26a8d0f8726883d44bf04742829b533");
         app.setAdzoneId("123123");
         TaoKeAppInfo app = new TaoKeAppInfo();
         app.setAppKey(appKey);
         app.setAppSecret(appSecret);
         resultJSON = TaoKeBaseUtil.baseRequest(map, app);
      } catch (TaoKeApiException e) {
         e.printStackTrace();
@@ -1491,7 +1506,27 @@
         return null;
      return null;
   }
   public static String beiAnQuDao(Long relationId, String accessToken, String appKey, String appSecret) {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.sc.publisher.info.save");
      map.put("session", accessToken);
      map.put("inviter_code", "A2QnGL");
      map.put("info_type", "1");
      JSONObject resultJSON = null;
      try {
         TaoKeAppInfo app = new TaoKeAppInfo();
         app.setAppKey(appKey);
         app.setAppSecret(appSecret);
         resultJSON = TaoKeBaseUtil.baseRequest(map, app);
      } catch (TaoKeApiException e) {
         e.printStackTrace();
      }
      if (resultJSON == null)
         return null;
      return null;
   }
   private static TaoBaoGoodsBrief parseWuLiaoItemFromMaterialId(JSONObject item) {