创建订单(API v1)
所有字段都以 form string 发送。删除 api_sig 后按 key 排序,使用 PHP
默认 flags 的 json_encode 编码全部参数,再计算 HMAC-SHA256。
query/body 同名字段和空值处理保持 v1 兼容行为。
POST
/orders/createdeprecatedRequest body
requiredapplication/x-www-form-urlencodedapi_keystringrequiredDarkroom 签发的 v1 API key。
min length 3
api_tsstringUnix seconds;v1 不验证新鲜度。
tsstring`api_ts` 的历史别名。
api_sigstringrequiredmatches ^[a-f0-9]{64}$
order_idstring优先于 `order_code`。
min length 3 · max length 40
order_codestringmin length 3 · max length 40
order_datestringrequiredmatches ^\d{4}-\d{2}-\d{2}$
order_hourstringrequiredmatches ^\d{2}:\d{2}:\d{2}$
store_idstring门店 numeric ID 或 store slug;空值触发 v1 默认门店规则。
order_planstring单服务项目 code。
order_plansstringJSON string,例如
`[{"id":"family-basic","price":"699.00","num":"1"}]`。
order_couponstringorder_secretstring少于 4 位时由 Darkroom 自动生成。
created_atstring有效 datetime 时覆盖订单与新顾客的建立时间。
customer_namestringcustomer_area_codestringdefault: "+86"
customer_mobilestringrequiredcustomer_emailstringcustomer_genderstringv1 只保存首字符。
customer_passstringcustomer_zonestringcustomer_provstringcustomer_citystringcustomer_addrstringcustomer_babynamestringcustomer_babygenderstringcustomer_babybirthstringkid_namestringkid_genderstringkid_birthdaystringkid_agestringwx_openidstringwx_avatarstringprepay_amountstring数字必须以 string 发送。
prepay_methodstring可用值由当前商家配置决定。
prepay_remarkstringcustomer_remarkstringorder_remarkstringteam_remarkstringResponses
200成功或 v1 业务错误;必须检查 `error_code`。
error_codeintegerrequiredAllowed:
01251525354565758596162717281121151152153error_msgstringrequiredorderOrderShow propertiesHide properties
idstringrequireddatestringrequiredhourstringrequiredstatusstringrequiredstore_idstringrequiredplansOrderService[]requiredShow propertiesHide properties
Array of
OrderServiceidstringrequirednamestringrequiredpricestring | numberrequiredShow propertiesHide properties
One of:
string
stringnumber
numbernumberintegerrequiredcreated_atstringrequiredcoupon_codestringrequiredtotal_pricestring | numberrequiredShow propertiesHide properties
One of:
string
stringnumber
numberprepayPrepaymentrequiredShow propertiesHide properties
amountstringrequiredmethodstringrequiredremarkstringrequiredcontactCustomerContactrequiredShow propertiesHide properties
namestringrequiredemailstringrequiredarea_codestringrequiredmobilestringrequiredkidChildShow propertiesHide properties
namestringrequiredgenderstringrequiredbirthdaystringrequiredagestringrequiredcustomer_remarkstringteam_remarkstringauto_login_urlstring<uri>长期有效的顾客免登录链接,属于敏感凭据。不得记录到日志、转发给无关系统或用于新功能。
customerCustomerShow propertiesHide properties
idstringrequiredstore_idstringrequirednamestringrequiredarea_codestringrequiredmobilestringrequiredemailstringrequiredgenderstringrequiredorder_idsstring[]required429已超过 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"
}'const response = await fetch("https://api.darkroom.net/v1/orders/create", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: JSON.stringify({
"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"
})
});import requests
response = requests.post(
"https://api.darkroom.net/v1/orders/create",
headers={
"Content-Type": "application/x-www-form-urlencoded"
},
json={
"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"
]
}
}已超过 v1 的 20 requests/min/key 配额;服务端返回标准 HTTP 429。
