admin
2022-01-11 d1d0b4b9f4452fb6e9b6e39168f503d5b302c999
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -13,20 +13,13 @@
import java.util.List;
import java.util.Map;
import com.sun.istack.NotNull;
import com.yeshi.fanli.dto.jd.*;
import com.yeshi.fanli.entity.jd.JDBackUpOrder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.dto.jd.JDCategoryInfo;
import com.yeshi.fanli.dto.jd.JDCommissionInfo;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDOrderResult;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.jd.JDShopInfo;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.jd.JDOrder;
@@ -46,9 +39,9 @@
    public static String SECRET_KEY = "e22367fc866746d98b50d47b4c521781";
    private static String SERVER_URL = "https://router.jd.com/api";
    public static long POSITION_FANLI = 1869704794L;
    public static long POSITION_SHARE = 1869542990L;
    public static long POSITION_COUPON = 1869704796L;
//    public static long POSITION_FANLI = 1869704794L;
//    public static long POSITION_SHARE = 1869542990L;
//    public static long POSITION_COUPON = 1869704796L;
    // 订单查询类型
    public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
@@ -146,7 +139,7 @@
        return resultJson.optJSONObject("data").optString("clickURL");
    }
    public static String convertLinkWithSubUnionId(@NotNull String materialId, String couponUrl, String giftCouponKey, @NotNull String positionId,
    public static String convertLinkWithSubUnionId(String materialId, String couponUrl, String giftCouponKey, String positionId,
                                                   String subUnionId) {
        String log = "京东转链出错:";
        try {
@@ -684,10 +677,10 @@
            root = JSONObject.fromObject(root.optString("result"));
            if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
                String date = root.optJSONArray("data").toString();
                JSONArray data = root.optJSONArray("data");
                Type typeToken = new TypeToken<List<JDOrder>>() {
                }.getType();
                List<JDOrder> orderList = new Gson().fromJson(date, typeToken);
                List<JDOrder> orderList = new Gson().fromJson(data.toString(), typeToken);
                if (orderList != null)
                    for (JDOrder order : orderList) {
                        Map<Long, List<JDOrderItem>> map = new HashMap<>();
@@ -725,6 +718,41 @@
    }
    public static JDOrderForBackUpResult getOrderListForBackUp(int page, int pageSize, Date time, int type) {
        JSONObject json = new JSONObject();
        JSONObject orderReq = new JSONObject();
        orderReq.put("pageNo", page);
        orderReq.put("pageSize", pageSize);
        orderReq.put("type", type);
        orderReq.put("time", TimeUtil.getGernalTime(time.getTime(), "yyyyMMddHH"));
        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) {
                List<JDBackUpOrder> orderList = new ArrayList<>();
                JSONArray data = root.optJSONArray("data");
                for (int i = 0; i < data.size(); i++) {
                    JSONObject item = data.optJSONObject(i);
                    String orderId = item.optString("orderId");
                    Long orderTime = item.optLong("orderTime");
                    JDBackUpOrder order = new JDBackUpOrder();
                    order.setId(orderId);
                    order.setContent(item.toString());
                    order.setOrderTime(new Date(orderTime ));
                    orderList.add(order);
                }
                return new JDOrderForBackUpResult(hasMore, orderList);
            }
        }
        return null;
    }
    public static String createLiJin(String sku) {
        JSONObject json = new JSONObject();
        JSONObject couponReq = new JSONObject();