| | |
| | | import com.yeshi.fanli.dto.jd.JDShopInfo;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.jd.JDOrderItem;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | | public static int ORDER_TYPE_FINISHTIME = 2;// 完成时间
|
| | | public static int ORDER_TYPE_UPDATETIME = 3;// 更新时间
|
| | |
|
| | |
|
| | |
|
| | | private static String post2(String url, Map<String, String> params) {
|
| | | String baseUrl = url;
|
| | |
| | |
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
|
| | | System.out.println(result);
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | |
| | | return list.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过商品搜索接口批量获取详情
|
| | | * |
| | | * @param skuIds
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> listGoodsDetail(List<Long> skuIds) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setListId(skuIds);
|
| | | JDSearchResult result = queryByKey(filter);
|
| | | return result.getGoodsList();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | json.put("orderReq", orderReq);
|
| | | String result = baseRequest2("jd.union.open.order.query", null, json);
|
| | | System.out.println(result);
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | | root = JSONObject.fromObject(root.optString("result"));
|
| | | if (root.optInt("code") == 200&&root.optJSONArray("data")!=null) {
|
| | | |
| | | if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
|
| | |
|
| | | String date = root.optJSONArray("data").toString();
|
| | | Type typeToken = new TypeToken<List<JDOrder>>() {
|
| | | }.getType();
|
| | | List<JDOrder> orderList = new Gson().fromJson(date, typeToken);
|
| | | if (orderList != null)
|
| | | for (JDOrder order : orderList) {
|
| | | Map<Long, List<JDOrderItem>> map = new HashMap<>();
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (map.get(orderItem.getSkuId()) == null)
|
| | | map.put(orderItem.getSkuId(), new ArrayList<>());
|
| | | map.get(orderItem.getSkuId()).add(orderItem);
|
| | |
|
| | | order.getOrderItemList().get(i)
|
| | | .setTradeId(order.getOrderId() + "-" + order.getOrderItemList().get(i).getSkuId());
|
| | | order.getOrderItemList().get(i).setOrderId(order.getOrderId());
|
| | | order.getOrderItemList().get(i).setOrderBy(i + 1);
|
| | | }
|
| | | // 查询商品ID相同的子订单
|
| | | for (Iterator<Long> its = map.keySet().iterator(); its.hasNext();) {
|
| | | Long skuId = its.next();
|
| | | if (map.get(skuId).size() > 1) {
|
| | | int skuOrderBy = 1;
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (orderItem.getSkuId().longValue() == skuId) {
|
| | | order.getOrderItemList().get(i).setTradeId(order.getOrderId() + "-"
|
| | | + order.getOrderItemList().get(i).getSkuId() + "-" + skuOrderBy++);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | return new JDOrderResult(hasMore, orderList);
|
| | | }
|