| | |
| | | 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")); |
| | |
| | | |
| | | 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) { |
| | |
| | | /** |
| | | * 获取商品详情,简版 |
| | | * |
| | | * @param id |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException { |
| | |
| | | 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)); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | goods.getUserType(), app); |
| | | 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)); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | goods.getUserType(), app); |
| | | 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()); |
| | | 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()); |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | System.out.println(data); |
| | | System.out.println(data.toString()); |
| | | |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | |
| | | /** |
| | | * 商品物料搜索 |
| | | * |
| | | * @param filter |
| | | * @return |
| | | */ |
| | | public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity, |
| | |
| | | /** |
| | | * 商品物料搜索 |
| | | * |
| | | * @param filter |
| | | * @return |
| | | */ |
| | | public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity, |
| | |
| | | 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 TaoKeApiUtil.QuanInfo getQuanInfo(Long auctionId, String activityId) { |
| | | public static TaoKeApiUtil.QuanInfo getQuanInfo(String auctionId, String activityId) { |
| | | TaoKeApiUtil.QuanInfo info = new TaoKeApiUtil.QuanInfo(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.coupon.get"); |
| | |
| | | /** |
| | | * 店铺搜索 |
| | | * |
| | | * @param key -店铺名称 |
| | | * @param page -页码 |
| | | * @return |
| | | */ |
| | | public static List<TaoBaoShopInfo> searchShop(SearchShopFilter filter) { |
| | |
| | | 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) { |
| | | public static TaoBaoGoodsBrief specialConvertCoupon(String auctionId, TaoKeAppInfo app) { |
| | | String pid = app.getPid(); |
| | | String[] sts = pid.split("_"); |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | |
| | | } |
| | | |
| | | 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 |
| | | * |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | // 淘礼金创建 |
| | | 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<>(); |
| | |
| | | } |
| | | |
| | | // 淘礼金报告 |
| | | public static UserTaoLiJinReport getTaoLiJinEffective(String 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 |
| | | */ |
| | |
| | | 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) { |