| | |
| | | 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;
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | |
| | | if (discount_temp == null) {
|
| | | add = true;
|
| | | discount_temp = discount;
|
| | | } else if (discount_temp.compareTo(discount) > 0) { // 券面额大
|
| | | add = true;
|
| | | } else if (discount_temp.compareTo(discount) < 0 && discount.compareTo(price) <= 0) { |
| | | add = true; // 券面额大,且券能够使用
|
| | | }
|
| | |
|
| | | if (add) {
|
| | |
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | |
|
| | | String inOrderCount = json.optString("inOrderCount");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setInOrderCount30Days(Long.parseLong(inOrderCount));
|
| | | }
|
| | | |
| | | goods.setCouponInfo(null);
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | | imageList.add(json.optString("imgUrl"));
|
| | | goods.setPicUrl(json.optString("imgUrl"));
|
| | | goods.setImageList(imageList);
|
| | | goods.setInOrderCount30Days(0L);
|
| | | goods.setIsHot(null);
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | goods.setOwner(null);
|
| | |
| | |
|
| | | 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");
|
| | |
| | | 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);
|
| | | }
|