Skip to content

获取货道列表

此接口随时可能取消,建议使用 单台设备 + 产品查询 获取详情 。

TIP

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

text
请求方式(METHOD): POST
请求路径(URL): {url}/api/openapi/v1/floors
请求参数(Argsments): payload: base64code
注意: 默认查询条件: 已上架(产品),默认排序 sort_id desc,查询所有柜(含组合柜)

Payload

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

参数加密

对接示例

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

TIP

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

sh
package main

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

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

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

	// Create request
	req, err := http.NewRequest("POST", "{url}/api/openapi/v1/floors", 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/floors",
        [
            "Appid" => "ds*******************",
            "AppSecret" => "*******************",
        ],
        "{\"payload\":\"eyJjYWJpbmV0X25hbWUiOiJCIiwiY2F0******jJBMjU5Q0IwMDYxNzM5QiIsInRpbWVzdGFtcCI6IjE3MTMyNTE3MjYifQ==\"}");

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

请求结果(成功)

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

json
{
  "code": 0,
  "message": "ok",
  "data": [
    {
      "status": "1",
      "good": {
        "id": 121,
        "name": "可乐",
        "description": "可乐",
        "thumb": "http://127.0.0.1:8100/storage/BkAtNYSnD5/28e3ec39-65ee-43ff-bd26-30c38c599fef.png",
        "price": "1.00",
        "original_price": "1.00",
        "content": "<p>可乐</p>",
        "updated_at": "2024-04-25 09:26:52",
        "good_no": "412883701240",
        "slug": "412883701240"
      },
      "channel": {
        "id": 213,
        "name": "A1",
        "cabinet_name": "A",
        "code": "000",
        "x": "0",
        "y": "0",
        "addr": 1
      },
      "current_inventory": 1,
      "inventory": 2
    }
  ]
}

TIP

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

参数类型说明必传
floor_statusstring货道状态
channelobject货道内容
goodobject商品信息
current_inventoryint当前库存
inventoryint最大库存

floor_status 货道状态值 参考

json
'0' => '货道不存在',
'1' => '正常',
'2' => '卡货',
'3' => '电机故障',
'47' => '串口通讯超时',

查询结果为空时,data 默认返回空数组

json
{
  "code": 0,
  "message": "ok",
  "data": []
}

请求结果(失败)

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

json
{
  "code": 30002,
  "message": "设备已离线",
  "data": {}
}

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