Skip to content

查询订单

根据 主动下单 得到的 order_id 进行查询。

TIP

请求接口(Header)必须携带参数,AppidAppSecret

请求方式(METHOD): POST
请求路径(URL): {url}/api/openapi/v1/orders/{order_id}
请求参数(Argsments): payload: base64code

Payload

参数类型说明必传
machine_nostring设备编号(定长8位数字字符串)
timestampstring当前时间戳

参数加密

对接示例

我们为您提供了2种语言 GO,PHP 的对接示例,如果您需要其他语言示例,请 联系我们

TIP

{url}默认为提供服务的地址

sh
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	json := []byte(`{"payload": "eyJtYWNoaW5lX25vIjoiMTYzMjcxMjkiLCJz********xNjUyRTE1MEEiLCJzdGF0dXMiOjIsInRpbWVzdGFtcCI6IjE3MTQxMTU3NDIifQ=="}`)
	body := bytes.NewBuffer(json)

	
	// Create client
	client := &http.Client{}

	// Create request
	req, err := http.NewRequest("POST", "{url}/api/openapi/v1/orders/{order_id}", body)

	// Headers
	req.Header.Add("Appid", "ds*******")
	req.Header.Add("AppSecret", "********")

	parseFormErr := req.ParseForm()
	if parseFormErr != nil {
	  fmt.Println(parseFormErr)    
	}

	// Fetch Request
	resp, err := client.Do(req)
	
	if err != nil {
		fmt.Println("Failure : ", err)
	}

	// Read Response Body
	respBody, _ := io.ReadAll(resp.Body)

	// Display Results
	fmt.Println("response Status : ", resp.Status)
	fmt.Println("response Headers : ", resp.Header)
	fmt.Println("response Body : ", string(respBody))
}
php
<?php

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();

$request = new Request(
        "POST",
        "{url}/api/openapi/v1/orders/{order_id}",
        [
            "Appid" => "ds*******************",
            "AppSecret" => "*******************",
        ],
        "{\"payload\":\"eyJtYWNoaW5lX25vIjoiMTYzMjcxMjki****6IjE3MTQxMTU3NDIifQ==\"}");

$response = $client->send($request);
echo "Response HTTP : " . $response->getStatusCode();

请求结果(成功)

将以上 AppidAppSecret 进行修改成您商户的内容,运行结果:

json
{
  "code": 0,
  "message": "ok",
  "data": {
    "order_id": 54,
    "trade_id": "3f2a58ad69b74e86b8a1a3da6fd75cc1",
    "date": "2024-04-26",
    "amount": "3.00",
    "status": "SUCCESS",
    "notify_send_count": 1,
    "records": [
      {
        "id": 70,
        "product_id": 121,
        "quantity": 1,
        "price": "1.00",
        "status": "IS_DELIVERING",
        "notify_sent": "1"
      },
      {
        "id": 71,
        "product_id": 122,
        "quantity": 1,
        "price": "1.00",
        "status": "WAITING_PICKED_UP",
        "notify_sent": "0"
      },
      {
        "id": 72,
        "product_id": 131,
        "quantity": 1,
        "price": "1.00",
        "status": "WAITING_PICKED_UP",
        "notify_sent": "0"
      }
    ]
  }
}

TIP

注意: 因接口返回的字段使用 protobuf, 部分字段值为空 或 false 时,默认不传

参数说明

参数类型说明必传
order_idint订单id
trade_idstring自定义订单号
datestring下单日期
amountstring订单总额
statusstring状态(参考下表)
notify_send_countint出货通知记录数-
recordsobject订单详细记录
pickup_code_idint取货码id-
SUCCESS: 支付成功
REFUND: 转入退款
CLOSED: 已关闭
REVOKED: 已撤销(付款码支付)
USERPAYING: 用户支付中(付款码支付)
PAYERROR: 支付失败(其他原因,如银行返回失败)
PICKUPCODE: 取货码订单
NOTPAY: 未支付
TESTPAY: 测试订单

订单详细记录

参数类型说明必传
idint记录id
product_idint产品id
quantityint数量
pricestring商品总金额
statusstring状态(订单已支付时显示)-
notify_sentstring是否推送了出货状态-

status 取值说明

WAITING_PICKED_UP: 等待出货
IS_PICKED_UP: 已取货
IS_REFUND: 订单取消,退回
IS_DELIVERING: 出货中
IS_SUCCESS: 出货完成
IS_FAILED: 出货失败
IS_TIMEOUT: 出货超时

请求结果(失败)

根据返回的 错误代码 进行排查:

json
{
  "code": 40005,
  "message": "订单已过期",
  "data": {}
}

© All rights reserved. 广州鼎商金属制品有限公司