| | |
| | |
|
| | | import java.io.IOException;
|
| | | import java.lang.reflect.Type;
|
| | | import java.net.URLDecoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfoRecommend;
|
| | | import com.yeshi.fanli.dto.suning.SuningOrderQueryResultDTO;
|
| | | import com.yeshi.fanli.dto.suning.SuningQueryModel;
|
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo;
|
| | |
| | | model.setPicHeight(320);
|
| | | String key = "querySearchcommoditynew";
|
| | | String json = new Gson().toJson(model);
|
| | | // String result =
|
| | | // baseRequest("suning.netalliance.searchcommoditynew.query", key,
|
| | | // JSONObject.fromObject(json));
|
| | | String result = baseRequest("suning.netalliance.searchcommoditynew.query", key, JSONObject.fromObject(json));
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询商品
|
| | | * @Title: searchGoods
|
| | | * @Description: |
| | | * @param model
|
| | | * @return |
| | | * List<SuningGoodsInfo> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static List<SuningGoodsInfo> searchGoodsOld(SuningQueryModel model) {
|
| | | model.setPicWidth(320);
|
| | | model.setPicHeight(320);
|
| | | String key = "querySearchcommodity";
|
| | | String json = new Gson().toJson(model);
|
| | | String result = baseRequest("suning.netalliance.searchcommodity.query", key, JSONObject.fromObject(json));
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONObject responseContent = resultJSON.optJSONObject("sn_responseContent");
|
| | | if (responseContent != null) {
|
| | | JSONObject snBody = responseContent.optJSONObject("sn_body");
|
| | | if (snBody != null) {
|
| | | JSONArray array = snBody.optJSONArray(key);
|
| | | if (array != null) {
|
| | | Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
|
| | | }.getType();
|
| | | List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | return goodsList;
|
| | | }
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static SuningGoodsInfo getGoodsDetail(String goodsCode, String supplierCode) {
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("commodityStr", goodsCode + "-" + supplierCode);
|
| | | model.put("commodityStr", goodsCode + "-" +SuningUtil.getFullSupplierCode( supplierCode));
|
| | | model.put("picWidth", 600);
|
| | | model.put("picHeight", 600);
|
| | | model.put("couponMark", 1);
|
| | |
|
| | | String key = "queryCommoditydetail";
|
| | | String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
|
| | |
| | | return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询关联商品
|
| | | * @Title: searchGoods
|
| | | * @Description: |
| | | * @param model
|
| | | * @return |
| | | * List<SuningGoodsInfo> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static List<SuningGoodsInfoRecommend> getRecommendGoods(String goodsCode, String supplierCode) {
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("commodityCode", goodsCode);
|
| | | model.put("supplierCode", supplierCode);
|
| | | model.put("picWidth", 320);
|
| | | model.put("picHeight", 320);
|
| | |
|
| | | String key = "getMorerecommend";
|
| | | String json = new Gson().toJson(model);
|
| | | String result = baseRequest("suning.netalliance.morerecommend.get", key, JSONObject.fromObject(json));
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
|
| | | .optJSONArray("commodityList");
|
| | | if (array != null) {
|
| | | Type type = new TypeToken<ArrayList<SuningGoodsInfoRecommend>>() {
|
| | | }.getType();
|
| | | List<SuningGoodsInfoRecommend> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | return goodsList;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
|
| | | String sts = "";
|
| | | for (String st : list) {
|
| | | sts += st + "_";
|
| | | }
|
| | |
|
| | | if (sts.endsWith("_"))
|
| | | sts = sts.substring(0, sts.length() - 1);
|
| | |
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("commodityStr", sts);
|
| | | model.put("picWidth", 300);
|
| | | model.put("picHeight", 300);
|
| | | model.put("couponMark", 1);
|
| | | List<SuningGoodsInfo> goodsList = new ArrayList<>();
|
| | |
|
| | | String key = "queryCommoditydetail";
|
| | | String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
|
| | | System.out.println(result);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
|
| | | if (array != null && array.size() > 0) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | goodsList.add(new Gson().fromJson(array.optJSONObject(i).toString(), SuningGoodsInfo.class));
|
| | | }
|
| | | }
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | public static String convertLink(String productUrl, String quanUrl, String pid, String subUser) {
|
| | |
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param page
|
| | | * @param orderLineStatus
|
| | | * @param orderLineStatus (0:全部状态;1:等待付款;2:支付完成;3:退款;4:订单已取消;5:确认收货)
|
| | | * @return
|
| | | * SuningOrderQueryResultDTO 返回类型
|
| | | * @throws
|
| | |
| | | String result = baseRequest("suning.netalliance.order.query", key, model);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | resultJSON = resultJSON.optJSONObject("sn_responseContent");
|
| | | JSONArray array = resultJSON.optJSONObject("sn_body").optJSONArray(key);
|
| | | JSONObject snBody = resultJSON.optJSONObject("sn_body");
|
| | | if (snBody == null)
|
| | | return null;
|
| | |
|
| | | JSONArray array = snBody.optJSONArray(key);
|
| | |
|
| | | if (array == null)
|
| | | return null;
|
| | |
|
| | | Gson gson = new Gson();
|
| | |
|
| | | Type type = new TypeToken<ArrayList<SuningOrderInfo>>() {
|
| | |
| | | JSONObject data = array.optJSONObject(i);
|
| | | JSONArray itemArray = data.optJSONArray("orderDetail");
|
| | | List<SuningOrderInfo> tempList = gson.fromJson(itemArray.toString(), type);
|
| | | for(SuningOrderInfo info:tempList){
|
| | | for (SuningOrderInfo info : tempList) {
|
| | | info.setOrderCode(data.optString("orderCode"));
|
| | | orderList.add(info);
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 常规转链
|
| | | * @Title: convertCommonLink
|
| | | * @Description: |
| | | * @param url
|
| | | * @param pid
|
| | | * @param subUser
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String convertCommonLink(String url, String pid, String subUser) {
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("adBookId", pid);
|
| | | model.put("visitUrl", url);
|
| | | model.put("subUser", subUser);
|
| | |
|
| | | String key = "queryCustompromotionurl";
|
| | | String result = baseRequest("suning.netalliance.custompromotionurl.query", key, model);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | resultJSON = resultJSON.optJSONObject("sn_responseContent");
|
| | | String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl")
|
| | | .optString("shortUrl");
|
| | | return URLDecoder.decode(shortUrl);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品精选接口
|
| | | * @Title: getSelectRecommendGoods
|
| | | * @Description: |
| | | * @param eliteId
|
| | | * @param page
|
| | | * @return |
| | | * List<SuningGoodsInfo> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static List<SuningGoodsInfo> getSelectRecommendGoods(int eliteId, int page) {
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("eliteId", eliteId);
|
| | | model.put("pageIndex", page);
|
| | | // model.put("picWidth", 320);
|
| | | // model.put("picHeight", 320);
|
| | | model.put("size", 10);
|
| | | model.put("couponMark", 1);
|
| | |
|
| | | String key = "querySelectrecommendcommodity";
|
| | | String result = baseRequest("suning.netalliance.selectrecommendcommodity.query", key, model);
|
| | | System.out.println(result);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | resultJSON = resultJSON.optJSONObject("sn_responseContent");
|
| | | JSONArray array = resultJSON.optJSONObject("sn_body").optJSONObject(key).optJSONArray("commodityList");
|
| | | if (array != null) {
|
| | | Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
|
| | | }.getType();
|
| | | List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | return goodsList;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|