xuhy
2026-02-05 337d48dbcb60bacb9bad2d4a0c3f2c34b132ef73
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.ruoyi.web.controller.yuncang.api.trade;
 
 
import com.alibaba.fastjson.JSONObject;
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;
 
@Slf4j
public class TradeQuery {
 
    /**
     *
     * 订单查询
     * @param sid     卖家账号,接口请求的公共参数sid
     * @param appkey     接口账号,接口请求的公共参数appkey
     * @param appsecret     接口秘钥,接口请求的参数appsecret ,用于计算签名
     * @param url     接口地址,接口请求的公共参数url
     * @param src_tid     原始单号
     * @param start_time     开始时间
     * @param end_time     结束时间 时间跨度不能超过60分钟
     * @return
     */
    public static JSONObject tradeQuery(String sid, String appkey, String appsecret, String url,
                                        String src_tid,String start_time,String end_time) {
        WdtClient client = new WdtClient(sid, appkey, appsecret, url);
        
        Map<String, String> params = new HashMap<String, String>();
        params.put("start_time", start_time);
        params.put("end_time", end_time);
        params.put("src_tid", src_tid);
//        params.put("page_size", "40");
//        params.put("page_no", "0");
 
        try {
            String response = client.execute("trade_query.php", params);
            log.info("订单查询结果:{}", response);
            JSONObject jsonObject = JSONObject.parseObject(response);
            if(jsonObject.getInteger("code") == 0){
                return jsonObject;
            }else{
                log.info("订单查询失败");
                throw new RuntimeException(jsonObject.getString("message"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    public static void main(String[] args) {
        WdtClient client = new WdtClient("apidevnew2", "hytycw02-test", "c7ae51196", "https://sandbox.wangdian.cn/openapi2/");
        Map<String, String> params = new HashMap<String, String>();
        params.put("start_time", "2026-02-05 15:00:00");
        params.put("end_time", "2026-02-05 15:35:00");
        params.put("src_tid", "C2026011540514");
        params.put("page_size", "30");
        params.put("page_no", "0");
 
        try {
            String response = client.execute("trade_query.php", params);
            System.out.println(response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
}