> For the complete documentation index, see [llms.txt](https://developer.ghsv.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.ghsv.vn/api/don-hang.md).

# Đơn hàng

## Tạo đơn hàng.

<mark style="color:green;">`POST`</mark> `https://api.ghsv.vn/v1/order/create`

#### Headers

| Name                                           | Type   | Description                                                                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Token<mark style="color:red;">\*</mark>        | String | <p>token-cua-ban</p><p><a data-mention href="/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token">/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token</a></p> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                                                            |

#### Request Body

| Name                                           | Type    | Description                                                                                                                                                                                                          |
| ---------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| product<mark style="color:red;">\*</mark>      | String  | Tên đơn hàng                                                                                                                                                                                                         |
| to\_name<mark style="color:red;">\*</mark>     | String  | Tên người nhận                                                                                                                                                                                                       |
| to\_ward<mark style="color:red;">\*</mark>     | String  | <p>Xã người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-xa-phuong-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-xa-phuong-trong-csdl-cua-ghsv.</a></p>      |
| to\_district<mark style="color:red;">\*</mark> | String  | <p>Huyện người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-quan-huyen-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-quan-huyen-trong-csdl-cua-ghsv.</a></p> |
| to\_province<mark style="color:red;">\*</mark> | String  | <p>Tỉnh người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-tinh-thanh-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-tinh-thanh-trong-csdl-cua-ghsv.</a></p>  |
| to\_address<mark style="color:red;">\*</mark>  | String  | Địa chỉ chi tiết người nhận                                                                                                                                                                                          |
| weight<mark style="color:red;">\*</mark>       | Int     | Cân nặng kiện hàng (gram)                                                                                                                                                                                            |
| price<mark style="color:red;">\*</mark>        | Int     | Tiền hàng                                                                                                                                                                                                            |
| value                                          | Int     | Giá trị đơn hàng, dùng để tính tiền bảo hiểm                                                                                                                                                                         |
| client\_code                                   | String  | Mã đơn tùy chỉnh của bạn                                                                                                                                                                                             |
| note                                           | String  | Ghi chú giao hàng                                                                                                                                                                                                    |
| config\_delivery                               | Int     | <p><em>Cấu hình giao hàng gồm:</em></p><p></p><p><em>(1) Cho Xem Hàng Nhưng Không Cho Thử Hàng <strong>(mặc định)</strong></em><br><em>(2) Cho Thử Hàng</em></p><p><em>(3) Không Cho Xem Hàng</em></p>               |
| config\_collect                                | Int     | <p><em>Cấu hình thu hộ gồm:</em></p><p></p><p><em>(0) Thu hộ = Tiền hàng (price) + phí <strong>(mặc định )</strong></em></p><p><em>(1) Thu hộ = Tiền hàng (price)</em></p>                                           |
| is\_return                                     | Boolean | Hàng đổi trả **( mặc định: false )**                                                                                                                                                                                 |
| to\_phone<mark style="color:red;">\*</mark>    | String  | Số điện thoại người nhận                                                                                                                                                                                             |
| shop\_id<mark style="color:red;">\*</mark>     | Int     | <p>ID cửa hàng</p><p><a data-mention href="/pages/wUakPS41AlSFob5YtqwF#khoi-tao-cua-hang.">/pages/wUakPS41AlSFob5YtqwF#khoi-tao-cua-hang.</a></p>                                                                    |
| source                                         | String  | Nguồn lên đơn (TPOS, TRUSTSALES, HARAVAN, PANCAKE), liên hệ kỹ thuật để thêm nguồn.                                                                                                                                  |
| length                                         | Int     | Chiều dài kiện hàng (cm)                                                                                                                                                                                             |
| width                                          | Int     | Chiều rộng kiện hàng (cm)                                                                                                                                                                                            |
| height                                         | Int     | Chiều cao kiện hàng (cm)                                                                                                                                                                                             |

{% tabs %}
{% tab title="200: OK Tạo đơn hàng thất bại" %}

```javascript
{
    "success": false,
    "msg": "Tên người nhận không được bỏ trống."
}
```

{% endtab %}

{% tab title="200: OK Tạo đơn hàng thành công" %}

```javascript
{
    "success": true,
    "msg": "",
    "order": {
        "client_code": "TESTING7",
        "required_code": "YCCL.1400000010", // mã đơn hàng của GHSV
        "sorting_code" "BN280-00-00-02", // mã phân loại || null nếu chưa có
        "product": "Test",
        "weight": 100,
        "value": 0,
        "cod": 17000,
        "note": "Cho Xem Hàng Nhưng Không Cho Thử Hàng",
        "config_collect": 0,
        "is_return": false,
        "shop_id": 35,
        "fee": 16500,
        "to_name": "Thịnh",
        "to_phone": "0378872140",
        "to_address": "Test",
        "to_province": "Tỉnh Hải Dương",
        "to_district": "Thành phố Hải Dương",
        "to_ward": "Phường Tứ Minh"
    }
}
```

{% endtab %}
{% endtabs %}

## Tính phí đơn hàng.

<mark style="color:blue;">`GET`</mark> `https://api.ghsv.vn/v1/order/calcFee`

#### Headers

| Name                                           | Type   | Description                                                                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Token<mark style="color:red;">\*</mark>        | String | <p>token-cua-ban</p><p><a data-mention href="/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token">/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token</a></p> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                                                            |

#### Request Body

| Name                                           | Type   | Description                                                                                                                                                                                                          |
| ---------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| weight<mark style="color:red;">\*</mark>       | Int    | Cân nặng đơn hàng (g)                                                                                                                                                                                                |
| value                                          | Int    | Giá trị đơn hàng, dùng để tính tiền bảo hiểm                                                                                                                                                                         |
| to\_ward<mark style="color:red;">\*</mark>     | String | <p>Xã người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-xa-phuong-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-xa-phuong-trong-csdl-cua-ghsv.</a></p>      |
| to\_district<mark style="color:red;">\*</mark> | String | <p>Huyện người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-quan-huyen-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-quan-huyen-trong-csdl-cua-ghsv.</a></p> |
| to\_province<mark style="color:red;">\*</mark> | String | <p>Tỉnh người nhận</p><p><a data-mention href="/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-tinh-thanh-trong-csdl-cua-ghsv.">/pages/yagW9xG8TPo5DlsSRAeD#lay-danh-sach-cac-tinh-thanh-trong-csdl-cua-ghsv.</a></p>  |
| shop\_id<mark style="color:red;">\*</mark>     | Int    | <p>ID cửa hàng</p><p><a data-mention href="/pages/wUakPS41AlSFob5YtqwF#khoi-tao-cua-hang.">/pages/wUakPS41AlSFob5YtqwF#khoi-tao-cua-hang.</a></p>                                                                    |
| config\_collect                                | Int    | <p><em>Cấu hình thu hộ gồm:</em></p><p></p><p><em>(0) Thu hộ = Tiền hàng (price) + phí <strong>(mặc định )</strong></em></p><p><em>(1) Thu hộ = Tiền hàng (price)</em></p>                                           |

{% tabs %}
{% tab title="200: OK Tính phí thành công" %}

```javascript
{
    "success": true,
    "msg": false,
    "fee": 24000
}
```

{% endtab %}

{% tab title="200: OK Tính phí thất bại" %}

```javascript
{
    "success": false,
    "msg": "Trường shop_id không được bỏ trống."
}
```

{% endtab %}
{% endtabs %}

## Hủy đơn hàng.

<mark style="color:green;">`POST`</mark> `https://api.ghsv.vn/v1/order/cancel`

#### Headers

| Name                                           | Type   | Description                                                                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Token<mark style="color:red;">\*</mark>        | String | <p>token-cua-ban</p><p><a data-mention href="/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token">/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token</a></p> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                                                            |

#### Request Body

| Name           | Type   | Description                                                                                                  |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| required\_code | String | <p>Mã đơn hàng của GHSV</p><p><mark style="background-color:orange;">Bỏ trường client\_code</mark></p>       |
| client\_code   | String | <p>Mã đơn tùy chỉnh của bạn</p><p><mark style="background-color:orange;">Bỏ trường required\_code</mark></p> |

{% tabs %}
{% tab title="200: OK Hủy đơn hàng thành công" %}

```javascript
{
    "success": true,
    "msg": ""
}
```

{% endtab %}

{% tab title="200: OK Hủy đơn hàng thất bại" %}

```javascript
{
    "success": false,
    "msg": "Đơn hàng này không thể hủy."
}
```

{% endtab %}
{% endtabs %}

## Lấy thông tin đơn hàng.

<mark style="color:blue;">`GET`</mark> `https://api.ghsv.vn/v1/order/info`

#### Headers

| Name                                           | Type   | Description                                                                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Token<mark style="color:red;">\*</mark>        | String | <p>token-cua-ban</p><p><a data-mention href="/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token">/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token</a></p> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                                                            |

#### Request Body

| Name           | Type   | Description                                                                                                  |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| required\_code | String | <p>Mã đơn hàng của GHSV</p><p><mark style="background-color:orange;">Bỏ trường client\_code</mark></p>       |
| client\_code   | String | <p>Mã đơn tùy chỉnh của bạn</p><p><mark style="background-color:orange;">Bỏ trường required\_code</mark></p> |

{% tabs %}
{% tab title="200: OK Lấy thông tin đơn hàng thành công" %}

```javascript
{
    "success": true,
    "msg": "",
    "order": {
        "status": "Hoãn Giao Hàng",
        "audit_code": null, // mã đối soát GHSV
        "delivery_time": null,
        "client_code": "",
        "required_code": "YCCL.1400000004", // mã yêu cầu của GHSV
        "product": "test",
        "weight": 300,
        "value": 0,
        "cod": 65000,
        "note": "Cho Xem Hàng Nhưng Không Cho Thử Hàng",
        "config_collect": 0,
        "is_return": false,
        "shop_id": 0,
        "to_name": "test",
        "to_phone": "0378872140",
        "to_address": "test, test",
        "to_province": "Thành Phố Cần Thơ",
        "to_district": "Quận Ô Môn",
        "to_ward": "Phường Long Hưng",
        "fee": 35000
    }
}
```

{% endtab %}

{% tab title="200: OK Lấy thông tin đơn hàng thất bại" %}

```javascript
{
    "success": false,
    "msg": "Đơn hàng không tồn tại."
}
```

{% endtab %}
{% endtabs %}

## Lấy hành trình đơn hàng.

<mark style="color:blue;">`GET`</mark> `https://api.ghsv.vn/v1/order/tracking`

#### Headers

| Name                                           | Type   | Description                                                                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Token<mark style="color:red;">\*</mark>        | String | <p>token-cua-ban</p><p><a data-mention href="/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token">/pages/JzLKNPHdm2CKIOz2kSff#khoi-tao-token</a></p> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                                                            |

#### Request Body

| Name           | Type   | Description                                                                                                  |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| required\_code | String | <p>Mã đơn hàng của GHSV</p><p><mark style="background-color:orange;">Bỏ trường client\_code</mark></p>       |
| client\_code   | String | <p>Mã đơn tùy chỉnh của bạn</p><p><mark style="background-color:orange;">Bỏ trường required\_code</mark></p> |

{% tabs %}
{% tab title="200: OK Lấy hành trình đơn hàng thành công" %}

```javascript
{
    "success": true,
    "msg": "",
    "tracking": [
        {
            "time": "09-05-2022 12:01",
            "status": "Đã được đối soát",
            "address": "",
            "note": "Mã đối soát: 09052022_1"
        },    
        {
            "time": "06-05-2022 15:50",
            "status": "Đã Giao Hàng Toàn Bộ",
            "address": "",
            "note": "Nguyễn Đức Thịnh (0378872140) xác nhận Đã Giao Hàng Toàn Bộ lúc 15:50 06-05-2022"
        },
        {
            "time": "06-05-2022 15:42",
            "status": "Đang xử lý",
            "address": "",
            "note": ""
        },
        {
            "time": "06-05-2022 15:41",
            "status": "Đã nhập kho",
            "address": "",
            "note": ""
        },
        {
            "time": "05-05-2022 19:56",
            "status": "Đợi lấy hàng",
            "address": "",
            "note": ""
        }
    ],
    "response_code": 200,
    "status": "success"
}
```

{% endtab %}

{% tab title="200: OK Lấy hành trình đơn hàng thất bại" %}

```javascript
{
    "success": false,
    "msg": "Đơn hàng không tồn tại."
}
```

{% endtab %}
{% endtabs %}
