Skip to content

创建订单

创建一笔新的业务订单,支持商品购买、会员卡办理、抵金券购买、分期还款等多种订单类型。

请求

POST /open-api/v1/orders

请求体

字段类型必填说明
merchantIdlong商户 ID
storeIdlong门店 ID
userIdlongApp 用户映射 ID(调用用户同步接口后获取)
orderTypeint订单类型:1-商品购买 2-会员卡办理 3-抵金券购买 4-分期还款
couponIdlong使用的优惠券 ID
voucherIdsstring使用的抵金券 ID 列表(JSON 数组格式)
remarkstring订单备注
itemsarray订单明细列表,不能为空
items[].itemTypeint商品类型:1-商品SPU 2-商品SKU 3-会员卡模板 4-抵金券
items[].itemIdlong关联 ID(对应商品ID、模板ID等)
items[].itemNamestring商品/服务名称
items[].itemCoverUrlstring商品封面图 URL
items[].specValuesstring规格信息(如颜色、尺寸)
items[].priceint单价(分),不能为负数
items[].quantityint数量,必须大于 0

请求示例

bash
curl -X POST 'https://openapi.example.com/open-api/v1/orders' \
  -H 'X-App-Key: ak_1234567890abcdef' \
  -H 'X-Timestamp: 1709280000' \
  -H 'X-Nonce: a1b2c3d4' \
  -H 'X-Sign: calculated_signature' \
  -H 'Content-Type: application/json' \
  -d '{
    "merchantId": 1001,
    "storeId": 2001,
    "userId": 10001,
    "orderType": 1,
    "remark": "下午3点到店",
    "items": [
      {
        "itemType": 1,
        "itemId": 4001,
        "itemName": "深层清洁护理",
        "price": 29900,
        "quantity": 1
      }
    ]
  }'

响应

响应参数

返回新创建的订单 ID(Long 类型)。

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": 9001
}

userId 说明

userId 是通过客户同步接口(POST /open-api/v1/customers/sync)将应用侧用户同步到平台后获取的 App 用户映射 ID,不是应用侧的原始用户 ID。

相关接口

接口路径说明
查询订单详情GET /open-api/v1/orders/{orderId}创建后可通过此接口查询订单状态
订单支付POST /open-api/v1/orders/{orderId}/pay对待支付订单发起支付
取消订单POST /open-api/v1/orders/{orderId}/cancel取消待支付的订单

商数通开放平台