| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.dto.vip.VIPConvertResultDTO;
|
| | | import com.yeshi.fanli.dto.vip.VIPSearchFilter;
|
| | | import com.yeshi.fanli.dto.vip.VIPSearchResult;
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | |
| | | if (resultJson.optInt("returnCode") == 0) {
|
| | | resultJson = resultJson.optJSONObject("result");
|
| | | int count = resultJson.optInt("total");
|
| | | |
| | | JSONArray array = resultJson.optJSONArray("goodsInfoList");
|
| | | if (array != null && array.size() > 0) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject optJSONObject = array.optJSONObject(i);
|
| | | if (optJSONObject == null) {
|
| | | continue;
|
| | | }
|
| | | VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
|
| | | if (info != null)
|
| | | goodsList.add(info);
|
| | | }
|
| | | }
|
| | | |
| | | return new VIPSearchResult(goodsList, count);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | |
| | | public static VIPSearchResult getGoodsList(int channelType,int page) {
|
| | | Map<String, String> taskParams = new HashMap<>();
|
| | | taskParams.put("channelType",channelType+"");
|
| | | taskParams.put("page", page+ "");
|
| | | taskParams.put("pageSize", 20 + "");
|
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
|
| | | |
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("request", JSONObject.fromObject(taskParams));
|
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "goodsList", root);
|
| | | System.out.println(result);
|
| | | List<VIPGoodsInfo> goodsList = new ArrayList<>();
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | Gson gson = new Gson();
|
| | | if (resultJson.optInt("returnCode") == 0) {
|
| | | resultJson = resultJson.optJSONObject("result");
|
| | | int count = resultJson.optInt("total");
|
| | | JSONArray array = resultJson.optJSONArray("goodsInfoList");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
|
| | |
| | | *
|
| | | * @param goodsId
|
| | | */
|
| | | public static String convertLink(String goodsId, String tag) {
|
| | | public static VIPConvertResultDTO convertLink(String goodsId, String tag) {
|
| | | JSONObject taskParams = new JSONObject();
|
| | | JSONArray goodsIdArray = new JSONArray();
|
| | | goodsIdArray.add(goodsId);
|
| | |
| | | System.out.println(result);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | if (resultJSON.optInt("returnCode") == 0) {
|
| | | return resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).optString("url");
|
| | | String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString();
|
| | | return new Gson().fromJson(re, VIPConvertResultDTO.class);
|
| | | }
|
| | | return null;
|
| | | }
|