| | |
| | | package com.yeshi.fanli.util.taobao; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.common.entity.PageEntity; |
| | | import com.yeshi.common.entity.taobao.TaoBaoShopInfo; |
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo; |
| | |
| | | import com.yeshi.goods.facade.dto.taobao.TaoBaoShopInfoDTO; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoHead; |
| | | import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.yeshi.utils.JsonUtil; |
| | |
| | | JSONObject item = array.optJSONObject(i); |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setPictUrl(item.optString("pict_url")); |
| | | goods.setAuctionId(item.optLong("num_iid")); |
| | | goods.setAuctionId(item.optString("num_iid")); |
| | | goods.setAuctionUrl(item.optString("item_url")); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | goods.setCouponInfo(item.optString("coupon_info")); |
| | |
| | | * @param id -商品AuctionId |
| | | * @return |
| | | */ |
| | | public static TaoBaoGoodsBrief getSimpleGoodsInfo(Long id) throws TaobaoGoodsDownException { |
| | | public static TaoBaoGoodsBrief getSimpleGoodsInfo(String id) throws TaobaoGoodsDownException { |
| | | Map<String, String> map = new HashMap<>(); |
| | | //TODO 临时接口 taobao.tbk.item.info.get |
| | | map.put("method", "taobao.tbk.item.info.get"); |
| | | // map.put("biz_scene_id", 2 + ""); |
| | | map.put("num_iids", id + ""); |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | |
| | | throw new TaobaoGoodsDownException(data.optJSONObject("error_response").optInt("code"), "商品下架"); |
| | | } |
| | | |
| | | //TODO 修改临时接口 tbk_item_info_get_response |
| | | if (data.optJSONObject("tbk_item_info_get_response") == null) |
| | | return null; |
| | | JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results") |
| | | .optJSONArray("n_tbk_item"); |
| | | if (array != null && array.size() > 0) { |
| | | JSONObject item = array.optJSONObject(0); |
| | | return parseSimpleGoodsInfo(item); |
| | | TaoBaoGoodsBrief goods = parseSimpleGoodsInfo(item); |
| | | if(goods!=null){ |
| | | goods.setAuctionId(id); |
| | | } |
| | | return goods; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static TaoBaoGoodsBrief parseSimpleGoodsInfo(JSONObject item) { |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setAuctionId(item.optLong("num_iid")); |
| | | goods.setAuctionId(item.optString("num_iid")); |
| | | goods.setAuctionUrl(item.optString("item_url")); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | if (item.optJSONObject("small_images") != null) { |
| | |
| | | return goods; |
| | | } |
| | | |
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<Long> listId) |
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<String> listId) |
| | | throws TaoKeApiException, TaobaoGoodsDownException { |
| | | if (listId == null || listId.size() == 0) { |
| | | throw new TaobaoGoodsDownException(1, "淘宝商品ID不能为空"); |
| | |
| | | } |
| | | |
| | | StringBuffer ids = new StringBuffer(); |
| | | for (Long id : listId) { |
| | | for (String id : listId) { |
| | | ids.append(id + ","); |
| | | } |
| | | |
| | |
| | | * @return |
| | | * @throws TaobaoGoodsDownException |
| | | */ |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(Long id, String specialId, String relationId) throws TaobaoGoodsDownException { |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(String id, String specialId, String relationId) throws TaobaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id); |
| | | if (goods == null) |
| | | return null; |
| | |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | System.out.println(goods.getAuctionId() + ":" + g.getAuctionId()); |
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) { |
| | | g.setId(goods.getAuctionId()); |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | g.setMaterialLibType(goods.getMaterialLibType()); |
| | | g.setProvcity(goods.getProvcity()); |
| | |
| | | // 从转链搜索 |
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(), |
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT), specialId, relationId); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT), specialId, relationId); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | |
| | | } |
| | | |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(Long id) throws TaobaoGoodsDownException { |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(String id) throws TaobaoGoodsDownException { |
| | | return searchGoodsDetail(id, null, null); |
| | | } |
| | | |
| | |
| | | * @return |
| | | * @throws TaobaoGoodsDownException |
| | | */ |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(Long id, TaoKeAppInfo app) throws TaobaoGoodsDownException { |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(String id, TaoKeAppInfo app) throws TaobaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id); |
| | | if (goods == null) |
| | | return null; |
| | |
| | | goods.getUserType(), app, null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) { |
| | | g.setId(goods.getAuctionId()); |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | // 判断是否有优惠券 |
| | | if (!StringUtil.isNullOrEmpty(g.getCouponActivityId())) { |
| | | // 获取优惠券详情 |
| | |
| | | // 从转链搜索 |
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(), |
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT), null, null); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT), null, null); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | * @return |
| | | * @throws TaobaoGoodsDownException |
| | | */ |
| | | public static TaoBaoGoodsBrief searchGoodsDetailForConvert(Long id, TaoKeAppInfo app, String specialId, String relationId) |
| | | public static TaoBaoGoodsBrief searchGoodsDetailForConvert(String id, TaoKeAppInfo app, String specialId, String relationId) |
| | | throws TaobaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id); |
| | | if (goods == null) |
| | |
| | | goods.getUserType(), app, specialId, relationId); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) { |
| | | g.setId(goods.getAuctionId()); |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | return g; |
| | | } |
| | |
| | | goods.getUserType(), null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) { |
| | | g.setId(goods.getAuctionId()); |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setAuctionUrl(goods.getAuctionUrl()); |
| | | g.setShopTitle(goods.getShopTitle()); |
| | | |
| | |
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null |
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) { |
| | | for (TaoBaoGoodsBrief g : searchResult.getTaoBaoGoodsBriefs()) { |
| | | if (g.getAuctionId().longValue() == goods.getAuctionId()) { |
| | | if (TaoBaoUtil.isEqual(g.getAuctionId(), goods.getAuctionId())) { |
| | | g.setImgList(goods.getImgList()); |
| | | g.setId(goods.getAuctionId()); |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setAuctionUrl(goods.getAuctionUrl()); |
| | | g.setShopTitle(goods.getShopTitle()); |
| | | |
| | |
| | | if (filter.getKey() != null && filter.getKey().trim().equalsIgnoreCase("")) |
| | | return null; |
| | | |
| | | if (filter.getKey() != null && filter.getKey().length() > 100) |
| | | return null; |
| | | // if (filter.getKey() != null && filter.getKey().length() > 100) |
| | | // return null; |
| | | |
| | | PageEntity pageEntity = new PageEntity(); |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | //TODO 临时接口taobao.tbk.dg.material.optional |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | map.put("page_size", filter.getPageSize() == 0 ? "20" : filter.getPageSize() + ""); |
| | | map.put("page_no", (filter.getPage() <= 0 ? 1 : filter.getPage()) + ""); |
| | | //1-动态ID转链场景,2-消费者比价场景(不填默认为1) |
| | | // map.put("biz_scene_id","2"); |
| | | // map.put("promotion_type","1"); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) { |
| | | map.put("special_id", specialId); |
| | | } else if (!StringUtil.isNullOrEmpty(specialId)) { |
| | |
| | | } |
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | // System.out.println("resultStr"+ resultStr); |
| | | System.out.println("resultStr" + resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | //TODO 临时接口tbk_dg_material_optional_response |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") |
| | |
| | | provcity = provcity.split(" ")[provcity.split(" ").length - 1]; |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | //TODO 临时接口 taobao.tbk.dg.material.optional |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | map.put("page_size", 50 + ""); |
| | | map.put("page_no", 1 + ""); |
| | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | //TODO 临时接口 tbk_dg_material_optional_response |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") |
| | |
| | | } |
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, app); |
| | | System.out.println(resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | |
| | | } |
| | | |
| | | // 解析物料 |
| | | private static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { |
| | | public static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setPictUrl(item.optString("pict_url")); |
| | | |
| | |
| | | goods.setPictUrlWhite(item.optString("white_image")); |
| | | } |
| | | |
| | | goods.setAuctionId(item.optLong("num_iid")); |
| | | goods.setAuctionId(item.optString("num_iid")); |
| | | goods.setAuctionUrl("https:" + item.optString("url")); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | goods.setCouponInfo(item.optString("coupon_info")); |
| | |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static QuanInfo getQuanInfo(Long auctionId, String activityId) { |
| | | public static QuanInfo getQuanInfo(String auctionId, String activityId) { |
| | | QuanInfo info = new TaoKeApiUtil.QuanInfo(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.coupon.get"); |
| | |
| | | if (url.contains("s.click.taobao.com/t?e=m")) { |
| | | TaoBaoGoodsBrief goods; |
| | | try { |
| | | goods = searchGoodsDetail(item.optLong("num_iid")); |
| | | goods = searchGoodsDetail(item.optString("num_iid")); |
| | | if (goods != null) |
| | | goodsList.add(goods); |
| | | } catch (TaobaoGoodsDownException e) { |
| | |
| | | System.out.println(resultStr); |
| | | } |
| | | |
| | | public static void getTAEGoodsDetail(Long auctionId) { |
| | | public static void getTAEGoodsDetail(String auctionId) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tae.items.list"); |
| | | map.put("fields", "title,nick,pic_url,location,cid,price,post_fee,promoted_service,ju,shop_name"); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 从淘宝链接中解析商品ID(高级接口) |
| | | * |
| | | * @param link |
| | | * @return |
| | | */ |
| | | public static String parseAuctionIdFromLink(String link) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.item.click.extract"); |
| | | map.put("click_url", link + ""); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | JSONObject resultJSON = null; |
| | | try { |
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(resultJSON); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (resultJSON == null) |
| | | return null; |
| | | |
| | | return null; |
| | | |
| | | } |
| | | |
| | | public static String getAccessToken(String code, String appKey, String appSecret) { |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static void specialConvertItem(Long auctionId, TaoKeAppInfo app) { |
| | | public static void specialConvertItem(String auctionId, TaoKeAppInfo app) { |
| | | String pid = app.getPid(); |
| | | String[] sts = pid.split("_"); |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | public static TaoBaoGoodsBrief specialConvertCoupon(Long auctionId, TaoKeAppInfo app, String specialId, String relationId) { |
| | | public static TaoBaoGoodsBrief specialConvertCoupon(String auctionId, TaoKeAppInfo app, String specialId, String relationId) { |
| | | String pid = app.getPid(); |
| | | String[] sts = pid.split("_"); |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static void juHuaSuan() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.ju.items.search"); |
| | | map.put("current_page", 1 + ""); |
| | | map.put("page_size", 100 + ""); |
| | | map.put("pid", "mm_124933865_43788020_381938426"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey("24838852"); |
| | | app.setAppSecret("bc8265e2bf8d8115329d652f9d3d4cd8"); |
| | | |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static void taoKeContent() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.content.get"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]); |
| | | map.put("type", "1"); |
| | | map.put("count", "100"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public static void taoKeContentSource(String contentId, String source) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.optimus.material"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); |
| | | map.put("page_size", "10"); |
| | | map.put("page_no", "1"); |
| | | map.put("content_id", contentId); |
| | | map.put("content_source", source); |
| | | map.put("material_id", "1"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // AA5ISJ |
| | | |
| | |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | // 设置成320*320的图片尺寸 |
| | | goods.setPictUrl(TbImgUtil.getTBSize320Img("https:" + item.optString("pict_url"))); |
| | | goods.setAuctionId(item.optLong("item_id")); |
| | | goods.setAuctionId(item.optString("item_id")); |
| | | goods.setAuctionUrl("https://item.taobao.com/item.htm?id=" + goods.getAuctionId()); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | if (!StringUtil.isNullOrEmpty(item.optString("coupon_amount"))) { |
| | |
| | | } |
| | | } |
| | | |
| | | public static void getTaoKeContentEffective() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.optimus.material"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]); |
| | | map.put("page_no", "1"); |
| | | map.put("page_size", "20"); |
| | | map.put("content_id", "8872035"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static void getTaoKeContent() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.content.get"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]); |
| | | map.put("type", "1"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 淘口令转商品ID |
| | | * |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public static Long tokenConvertAuctionId(String token) throws TaoBaoTokenParseException { |
| | | public static TokenConvertResult tokenConvert(String token) throws TaoBaoTokenParseException { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.tpwd.convert"); |
| | | map.put("password_content", token); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_PID_DEFAULT.split("_")[3]); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | |
| | | System.out.println(json.toString()); |
| | | |
| | | try { |
| | | return json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data").optLong("num_iid"); |
| | | JSONObject data = json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data"); |
| | | Gson gson = new Gson(); |
| | | |
| | | return gson.fromJson(data.toString(), TokenConvertResult.class); |
| | | } catch (Exception e) { |
| | | |
| | | return null; |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // 淘礼金创建 |
| | | //{"result":{"msg_code":"FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR","msg_info":"今日该商品淘礼金创建数已超上限,请您明日再试","success":false},"request_id":"10p30v02qadkq"} |
| | | //{"result":{"msg_code":"ASSET_ACCOUNT_BALANCE_NOT_ENOUGH","msg_info":"账户预算不足","success":false},"request_id":"5caz9izr7jqp"} |
| | | public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, |
| | | public static TaoLiJinDTO createTaoLiJin(String auctionId, String name, BigDecimal perface, int totalNum, |
| | | Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) |
| | | throws TaoLiJinCreateException, TaoKeApiException { |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | // 淘礼金报告 |
| | | public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId) { |
| | | /** |
| | | * @return com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport |
| | | * @author hxh |
| | | * @description 淘礼金报告 接口文档:https://open.taobao.com/api.htm?source=search&docId=58736&docType=2 |
| | | * @date 10:57 2022/1/11 |
| | | * @param: rightsId |
| | | **/ |
| | | public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId, String pid) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.vegas.tlj.instance.report"); |
| | | map.put("method", "taobao.tbk.dg.vegas.tlj.report"); |
| | | map.put("rights_id", rightsId); |
| | | map.put("adzone_id", pid.split("_")[3]); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | |
| | | JSONObject json = JSONObject.fromObject(result); |
| | | System.out.println(json); |
| | | |
| | | JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_instance_report_response"); |
| | | JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_report_response"); |
| | | |
| | | if (root != null && root.optJSONObject("result") != null) { |
| | | if (root.optJSONObject("result").optBoolean("success")) { |
| | | JSONObject modelJson = root.optJSONObject("result").optJSONObject("model"); |
| | | |
| | | if (modelJson != null && modelJson.size() > 0) { |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport(); |
| | | report.setId(rightsId); |
| | | report.setUnfreezeAmount(new BigDecimal(modelJson.optString("unfreeze_amount"))); |
| | | report.setUnfreezeNum(modelJson.optInt("unfreeze_num")); |
| | | report.setRefundAmount(new BigDecimal(modelJson.optString("refund_amount"))); |
| | | report.setRefundNum(modelJson.optInt("refund_num")); |
| | | report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amount"))); |
| | | report.setUseAmount(new BigDecimal(modelJson.optString("use_amount"))); |
| | | report.setUseNum(modelJson.optInt("use_num")); |
| | | report.setWinAmount(new BigDecimal(modelJson.optString("win_amount"))); |
| | | report.setWinNum(modelJson.optInt("win_num")); |
| | | report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_commission_amount"))); |
| | | return report; |
| | | } |
| | | if (root != null && root.optBoolean("result_success")) { |
| | | JSONObject modelJson = root.optJSONObject("model").optJSONObject("extra"); |
| | | if (modelJson != null && modelJson.size() > 0) { |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport(); |
| | | report.setId(rightsId); |
| | | report.setWinAmount(new BigDecimal(modelJson.optString("win_sum_amt"))); |
| | | report.setWinNum(modelJson.optInt("win_pv")); |
| | | report.setRefundAmount(new BigDecimal(modelJson.optString("refund_sum_amt"))); |
| | | report.setRefundNum(modelJson.optInt("refund_num")); |
| | | report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amt"))); |
| | | report.setUseAmount(new BigDecimal(modelJson.optString("use_sum_amt"))); |
| | | report.setUseNum(modelJson.optInt("use_num")); |
| | | report.setUnfreezeAmount(new BigDecimal(modelJson.optString("remaining_amt"))); |
| | | report.setUnfreezeNum(modelJson.optInt("remaining_num")); |
| | | report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp"))); |
| | | return report; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static void getCouponByAuctionId(Long auctionId) { |
| | | public static void getCouponByAuctionId(String auctionId) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.itemid.coupon.get"); |
| | | map.put("platform", 2 + ""); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT); |
| | | map.put("num_iids", auctionId + ""); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取淘宝系统时间 |
| | | * 获取淘宝系统时间(收费API,谨慎调用) |
| | | * |
| | | * @return |
| | | */ |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId, int count) { |
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(String auctionId, int count) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.optimus.material"); |
| | | map.put("item_id", auctionId + ""); |
| | |
| | | return goodsList; |
| | | } |
| | | |
| | | public static List<TaoBaoGoodsBrief> getCouponListByItemId(Long auctionId) { |
| | | public static List<TaoBaoGoodsBrief> getCouponListByItemId(String auctionId) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.itemid.coupon.get"); |
| | | map.put("platform", auctionId + ""); |
| | | map.put("num_iids", auctionId + ""); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT); |
| | | |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | JSONObject resultJSON = null; |
| | | try { |
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response"); |
| | | if (response != null && response.optJSONObject("result_list") != null) { |
| | |
| | | public BigDecimal coupon_start_fee;// 券起始金额 |
| | | } |
| | | |
| | | public static class TokenConvertResult { |
| | | private String num_iid;// 商品Id |
| | | private String click_url;//商品淘客转链 |
| | | private String seller_id;//店铺卖家ID |
| | | private String origin_url;//入参淘口令对应原始链接 |
| | | private String origin_pid;//入参淘口令推广链接中的pid,如果不属于当前调用的推广者则展示“0” |
| | | |
| | | public String getNum_iid() { |
| | | return num_iid; |
| | | } |
| | | |
| | | public void setNum_iid(String num_iid) { |
| | | this.num_iid = num_iid; |
| | | } |
| | | |
| | | public String getClick_url() { |
| | | return click_url; |
| | | } |
| | | |
| | | public void setClick_url(String click_url) { |
| | | this.click_url = click_url; |
| | | } |
| | | |
| | | public String getSeller_id() { |
| | | return seller_id; |
| | | } |
| | | |
| | | public void setSeller_id(String seller_id) { |
| | | this.seller_id = seller_id; |
| | | } |
| | | |
| | | public String getOrigin_url() { |
| | | return origin_url; |
| | | } |
| | | |
| | | public void setOrigin_url(String origin_url) { |
| | | this.origin_url = origin_url; |
| | | } |
| | | |
| | | public String getOrigin_pid() { |
| | | return origin_pid; |
| | | } |
| | | |
| | | public void setOrigin_pid(String origin_pid) { |
| | | this.origin_pid = origin_pid; |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) throws TaoBaoTokenParseException, TaobaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo("qYtrU8tgk7CWt0-GmgDAKHqqGm3XDwHZj"); |
| | | System.out.println(goods.getAuctionId()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |