# Base URL 正式站: [https://www.diageocrm.com.tw/api](https://www.diageocrm.com.tw/api) 測試站: https://diageocrm-com.diageoplatform.com/api # Endpoints ## `POST /external-orders` **Requires certain server IP** > 同步 order 資料 API > 當 order 有任何資料變更時 call (新增/修改/刪除) ### Request #### Header ``` Content-Type: application/json ``` #### Body - `line_id`: required | string - `order_id`: required | string | unique - `time`: required | string | datetime format: yyyy-MM-dd HH:mm:ss - `store`: string - `storeType`: tinyint (1: 連鎖通路、2: 菸酒專) - `items`: array (刪除時 (取消訂單) 傳空 array 即可) - `coupon_code`: string 優惠券碼 - `price`: string 訂單總金額 ### Response **Status 非 200 請 retry** #### Example **Request:** ```json POST https://diageocrm-com.diageoplatform.com/api/external-orders Content-Type: application/json { "line_id": "lineididid", "order_id": "xxx", "store": "xxx", "time": "1990-01-01 00:00:00", "coupon_code": "ABC123", "price": "2000", "items": [ { "item_name": "test", "item_num": 1 }, { "item_name": "test2", "item_num": 5 } ] } ``` **Response:** ```json { "error": false, "message": "成功" } ``` ## `GET /coupon/{line_id}/{coupon_code}` **Requires certain server IP** ### Request #### Header ``` Content-Type: application/json ``` #### Path - `line_id`: string - `coupon_code`: string (優惠券碼) ### Response - **200**: 成功 (包含兩個欄位:滿多少金額 (null 則無限制)、折多少金額) - **400**: 無此優惠券 / 優惠券已使用 #### Example **Request:** ``` GET https://diageocrm-com.diageoplatform.com/api/coupon/ABC123 Content-Type: application/json ``` #### Success Response (200) ```json { "error": false, "message": "成功", "status": 0, "min_amount": 1000, "discount_amount": 100 } ``` #### Error Response (400) - Invalid Coupon ```json { "error": true, "status": 1, "message": "無此優惠券" } ``` #### Error Response (400) - Not Owner's Coupon ```json { "error": true, "status": 4, "message": "非本人優惠券" } ``` #### Error Response (400) - Coupon Already Used ```json { "error": true, "status": 2, "message": "優惠券已使用", "store": "店家A" } ``` #### Error Response (400) - Coupon Expired ```json { "error": true, "status": 3, "message": "優惠券已過期" } ```