| | |
| | | package com.ruoyi.web.controller.yuncang.api.trade; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.web.controller.yuncang.utils.WdtClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | public class LogisticsSyncQuery { |
| | |
| | | String shop_no) { |
| | | WdtClient client = new WdtClient(sid, appkey, appsecret, url); |
| | | Map<String, String> params = new HashMap<String, String>(); |
| | | params.put("shop_no", shop_no); |
| | | if (StringUtils.isNotEmpty(shop_no)){ |
| | | params.put("shop_no", shop_no); |
| | | } |
| | | // params.put("is_part_sync_able", "0"); |
| | | params.put("limit", "100"); |
| | | try { |
| | |
| | | return null; |
| | | } |
| | | public static void main(String[] args) { |
| | | WdtClient client = new WdtClient("", "", "", ""); |
| | | WdtClient client = new WdtClient("apidevnew2", "hytycw02-test", "c7ae51196", "https://sandbox.wangdian.cn/openapi2/"); |
| | | Map<String, String> params = new HashMap<String, String>(); |
| | | params.put("shop_no", "mytest"); |
| | | // params.put("shop_no", "hytycw02-test"); |
| | | params.put("is_part_sync_able", "0"); |
| | | params.put("limit", "100"); |
| | | try { |
| | | String response = client.execute("logistics_sync_query.php", params); |
| | | System.out.println(response); |
| | | System.err.println(response); |
| | | JSONObject jsonObject = JSONObject.parseObject(response); |
| | | if(Objects.nonNull(jsonObject)){ |
| | | JSONArray trades = jsonObject.getJSONArray("trades"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | List<String> tidList = new ArrayList<>(); |
| | | List<Map<String, Object>> logistics_list = new ArrayList<>(); |
| | | for (int i = 0; i < trades.size(); i++) { |
| | | JSONObject trade_order = JSONObject.parseObject(JSONObject.toJSONString(trades.get(i))); |
| | | String rec_id = trade_order.getString("rec_id"); // 主键,用于logistics_sync_ack回写状态 |
| | | String tid = trade_order.getString("tid"); // 原始单号 |
| | | String logistics_no = trade_order.getString("logistics_no"); // 物流单号 |
| | | String logistics_name = trade_order.getString("logistics_name"); // 物流名称 |
| | | map.put(tid, logistics_no); |
| | | tidList.add(tid); |
| | | Map<String, Object> logistics_1 = new HashMap<>(); |
| | | logistics_1.put("rec_id", rec_id); |
| | | logistics_1.put("status", 0); |
| | | logistics_1.put("message", "同步成功"); |
| | | logistics_list.add(logistics_1); |
| | | } |
| | | |
| | | System.err.println(map); |
| | | |
| | | JSONObject logisticsSyncAck = LogisticsSyncAck.logisticsSyncAck("apidevnew2", "hytycw02-test", "c7ae51196", "https://sandbox.wangdian.cn/openapi2/", logistics_list); |
| | | System.err.println(logisticsSyncAck); |
| | | } |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |