跳到内容
API 文档
Esc
切换打开⌘J预览

创建订单(API v1)

所有字段都以 form string 发送。删除 api_sig 后按 key 排序,使用 PHP 默认 flags 的 json_encode 编码全部参数,再计算 HMAC-SHA256。 query/body 同名字段和空值处理保持 v1 兼容行为。

POST/orders/createdeprecated
Request body
requiredapplication/x-www-form-urlencoded
api_keystringrequired
Darkroom 签发的 v1 API key。
min length 3
api_tsstring
Unix seconds;v1 不验证新鲜度。
tsstring
`api_ts` 的历史别名。
api_sigstringrequired
matches ^[a-f0-9]{64}$
order_idstring
优先于 `order_code`。
min length 3 · max length 40
order_codestring
min length 3 · max length 40
order_datestringrequired
matches ^\d{4}-\d{2}-\d{2}$
order_hourstringrequired
matches ^\d{2}:\d{2}:\d{2}$
store_idstring
门店 numeric ID 或 store slug;空值触发 v1 默认门店规则。
order_planstring
单服务项目 code。
order_plansstring
JSON string,例如 `[{"id":"family-basic","price":"699.00","num":"1"}]`。
order_couponstring
order_secretstring
少于 4 位时由 Darkroom 自动生成。
created_atstring
有效 datetime 时覆盖订单与新顾客的建立时间。
customer_namestring
customer_area_codestring
default: "+86"
customer_mobilestringrequired
customer_emailstring
customer_genderstring
v1 只保存首字符。
customer_passstring
customer_zonestring
customer_provstring
customer_citystring
customer_addrstring
customer_babynamestring
customer_babygenderstring
customer_babybirthstring
kid_namestring
kid_genderstring
kid_birthdaystring
kid_agestring
wx_openidstring
wx_avatarstring
prepay_amountstring
数字必须以 string 发送。
prepay_methodstring
可用值由当前商家配置决定。
prepay_remarkstring
customer_remarkstring
order_remarkstring
team_remarkstring
Responses
200成功或 v1 业务错误;必须检查 `error_code`。
error_codeintegerrequired
Allowed:01251525354565758596162717281121151152153
error_msgstringrequired
orderOrder
Show properties
idstringrequired
datestringrequired
hourstringrequired
statusstringrequired
store_idstringrequired
plansOrderService[]required
Show properties
Array of OrderService
idstringrequired
namestringrequired
pricestring | numberrequired
Show properties
One of:
string
string
number
number
numberintegerrequired
created_atstringrequired
coupon_codestringrequired
total_pricestring | numberrequired
Show properties
One of:
string
string
number
number
prepayPrepaymentrequired
Show properties
amountstringrequired
methodstringrequired
remarkstringrequired
contactCustomerContactrequired
Show properties
namestringrequired
emailstringrequired
area_codestringrequired
mobilestringrequired
kidChild
Show properties
namestringrequired
genderstringrequired
birthdaystringrequired
agestringrequired
customer_remarkstring
team_remarkstring
auto_login_urlstring<uri>
长期有效的顾客免登录链接,属于敏感凭据。不得记录到日志、转发给无关系统或用于新功能。
customerCustomer
Show properties
idstringrequired
store_idstringrequired
namestringrequired
area_codestringrequired
mobilestringrequired
emailstringrequired
genderstringrequired
order_idsstring[]required
429已超过 v1 的 20 requests/min/key 配额;服务端返回标准 HTTP 429。
Request
curl -X POST "https://api.darkroom.net/v1/orders/create" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d '{
  "api_key": "string",
  "api_ts": "string",
  "ts": "string",
  "api_sig": "string",
  "order_id": "string",
  "order_code": "string",
  "order_date": "string",
  "order_hour": "string",
  "store_id": "string",
  "order_plan": "string",
  "order_plans": "string",
  "order_coupon": "string",
  "order_secret": "string",
  "created_at": "string",
  "customer_name": "string",
  "customer_area_code": "+86",
  "customer_mobile": "string",
  "customer_email": "string",
  "customer_gender": "string",
  "customer_pass": "string",
  "customer_zone": "string",
  "customer_prov": "string",
  "customer_city": "string",
  "customer_addr": "string",
  "customer_babyname": "string",
  "customer_babygender": "string",
  "customer_babybirth": "string",
  "kid_name": "string",
  "kid_gender": "string",
  "kid_birthday": "string",
  "kid_age": "string",
  "wx_openid": "string",
  "wx_avatar": "string",
  "prepay_amount": "string",
  "prepay_method": "string",
  "prepay_remark": "string",
  "customer_remark": "string",
  "order_remark": "string",
  "team_remark": "string"
}'
Response
{
  "error_code": 0,
  "error_msg": "string",
  "order": {
    "id": "string",
    "date": "string",
    "hour": "string",
    "status": "string",
    "store_id": "string",
    "plans": [
      {
        "id": "string",
        "name": "string",
        "price": "string",
        "number": 0
      }
    ],
    "created_at": "string",
    "coupon_code": "string",
    "total_price": "string",
    "prepay": {
      "amount": "string",
      "method": "string",
      "remark": "string"
    },
    "contact": {
      "name": "string",
      "email": "string",
      "area_code": "string",
      "mobile": "string"
    },
    "kid": {
      "name": "string",
      "gender": "string",
      "birthday": "string",
      "age": "string"
    },
    "customer_remark": "string",
    "team_remark": "string",
    "auto_login_url": "<uri>"
  },
  "customer": {
    "id": "string",
    "store_id": "string",
    "name": "string",
    "area_code": "string",
    "mobile": "string",
    "email": "string",
    "gender": "string",
    "order_ids": [
      "string"
    ]
  }
}