| | |
| | | import com.google.gson.FieldAttributes;
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.dataoke.DaTaoKeApiResult;
|
| | | import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopDTO;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | public static DaTaoKeApiResult goodsList(int page) {
|
| | | List<DaTaoKeDetail> list = new ArrayList<>();
|
| | | String url = String.format("http://api.dataoke.com/index.php?r=Port/index&type=total&appkey=%s&v=2&page=%s",
|
| | | Math.random() > 0.5 ? API_KEY : API_KEY_2, page + "");
|
| | | String result = request(url);
|
| | |
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | System.out.println(resultJson);
|
| | | JSONArray array = resultJson.optJSONArray("result");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | list.add(gson.fromJson(array.optJSONObject(i).toString(), DaTaoKeDetail.class));
|
| | | }
|
| | |
|
| | | for (DaTaoKeDetail dt : list)
|
| | | if (!dt.getPic().startsWith("http"))
|
| | | dt.setPic("https:" + dt.getPic());
|
| | |
|
| | | return new DaTaoKeApiResult(resultJson.optJSONObject("data").optInt("total_num"),
|
| | | resultJson.optJSONObject("data").optString("update_time"), list);
|
| | | }
|
| | |
|
| | | public static DaTaoKeDetail getGoodsDetailV1(Long id) {
|
| | | String url = String.format("http://api.dataoke.com/index.php?r=Port/index&type=total&appkey=%s&v=2&id=%s",
|
| | | Math.random() > 0.5 ? API_KEY : API_KEY_2, id + "");
|
| | | String result = request(url);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | return gson.fromJson(resultJson.optJSONArray("result").optJSONObject(0).toString(), DaTaoKeDetail.class);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | public static DaTaoKeDetailV2 getGoodsDetailByGoodsId(Long goodsId) {
|
| | | TaoKeAppInfo app = getRandomApp();
|
| | | Map<String, String> params = new TreeMap<>();
|
| | |
| | | cids = cids.substring(0, cids.length() - 1);
|
| | | if (!StringUtil.isNullOrEmpty(cids))
|
| | | params.put("cids", cids);
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(key))
|
| | | key = "";
|
| | | params.put("keyWords", key);
|
| | | |
| | |
|
| | | if (sort != null)
|
| | | params.put("sort", sort + "");
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | |
| | | }
|
| | | return daTaoKeGoodsResult;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static DaTaoKeGoodsResult search(String key, List<Integer> cidList, BigDecimal priceLowerLimit,
|
| | | BigDecimal priceUpperLimit, Integer couponPriceLowerLimit, int page, int pageSize, Integer sort) {
|
| | |
|
| | |
| | | params.put("priceLowerLimit", priceLowerLimit + "");
|
| | | if (priceUpperLimit != null)
|
| | | params.put("priceUpperLimit", priceUpperLimit + "");
|
| | | |
| | |
|
| | | if (couponPriceLowerLimit != null)
|
| | | params.put("couponPriceLowerLimit", couponPriceLowerLimit + "");
|
| | | |
| | |
|
| | | String cids = "";
|
| | | if (cidList != null && cidList.size() > 0)
|
| | | for (Integer cid : cidList) {
|
| | |
| | | cids = cids.substring(0, cids.length() - 1);
|
| | | if (!StringUtil.isNullOrEmpty(cids))
|
| | | params.put("cids", cids);
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(key))
|
| | | key = "%";
|
| | | params.put("keyWords", key);
|
| | | |
| | |
|
| | | if (sort != null)
|
| | | params.put("sort", sort + "");
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | |
| | |
|
| | | /**
|
| | | * 商品列表
|
| | | * |
| | | * @param key
|
| | | * @param cidList
|
| | | * @param priceLowerLimit
|
| | |
| | | params.put("appKey", app.getAppKey());
|
| | | params.put("pageSize", pageSize + "");
|
| | | params.put("pageId", pageId + "");
|
| | | |
| | |
|
| | | if (priceLowerLimit != null)
|
| | | params.put("priceLowerLimit", priceLowerLimit + "");
|
| | | if (priceUpperLimit != null)
|
| | | params.put("priceUpperLimit", priceUpperLimit + "");
|
| | | |
| | |
|
| | | if (couponPriceLowerLimit != null)
|
| | | params.put("couponPriceLowerLimit", couponPriceLowerLimit + "");
|
| | | |
| | |
|
| | | if (sort != null)
|
| | | params.put("sort", sort +"");
|
| | | |
| | | params.put("sort", sort + "");
|
| | |
|
| | | if (cidList != null && cidList.size() > 0) {
|
| | | String cids = "";
|
| | | for (int cid : cidList)
|
| | | cids += cid + ",";
|
| | | cids = cids.endsWith(",") ? cids.substring(0, cids.length() - 1) : cids;
|
| | |
|
| | | params.put("cids", cids + "");
|
| | | }
|
| | |
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | | String result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-goods-list", params, new HashMap<>());
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | |
| | | return hotWords;
|
| | | }
|
| | |
|
| | | class DaTaoKeResult {
|
| | | Date updateTime;
|
| | | List<DaTaoKeDetail> dataList;
|
| | | /**
|
| | | * 高效转链
|
| | | * @Title: convertLink
|
| | | * @Description: |
| | | * @param auctionId
|
| | | * @param pid |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String convertLink(Long auctionId, String pid) {
|
| | | TaoKeAppInfo app = APP_KEYS[1];
|
| | | Map<String, String> params = new TreeMap<>();
|
| | | params.put("version", "v1.1.1");
|
| | | params.put("goodsId", auctionId + "");
|
| | | params.put("pid", pid);
|
| | | params.put("appKey", app.getAppKey());
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | |
|
| | | public DaTaoKeResult(Date updateTime, List<DaTaoKeDetail> dataList) {
|
| | | this.updateTime = updateTime;
|
| | | this.dataList = dataList;
|
| | | String result = null;
|
| | | try {
|
| | | result = HttpUtil.get("https://openapi.dataoke.com/api/tb-service/get-privilege-link", params,
|
| | | new HashMap<>());
|
| | | } catch (Exception e) {
|
| | | result = HttpUtil.get("https://openapi.dataoke.com/api/tb-service/get-privilege-link", params,
|
| | | new HashMap<>());
|
| | | }
|
| | | |
| | | System.out.println(result);
|
| | |
|
| | | public DaTaoKeResult() {
|
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | if (json != null) {
|
| | | json = json.getJSONObject("data");
|
| | | if (json != null) {
|
| | | return json.optString("couponClickUrl");
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|