Coupon
Mô tả
Các API hỗ trợ:
-
GET /coupons: Lấy danh sách các coupon.
-
GET /coupons/{id}: Lấy chi tiết 1 coupon.
-
POST /coupons: Tạo mới coupon.
-
PUT /coupons/{id}: Cập nhật coupon.
API
GET /api/coupons
Lấy danh sách các coupon, hỗ trợ các tham số filter sau:
| Tên trường | Kiểu dữ liệu | Mô tả |
|---|---|---|
| code | string | Mã coupon |
| name | string | Tên coupon |
| status | string | Trạng thái |
| created_from | string | Từ ngày |
| created_to | string | Đến ngày |
| sort | integer | Tên trường sắp xếp |
| order | integer | Thứ tự sắp xếp |
| page | integer | Trang |
| size | integer | Số bản ghi trên trang |
Trạng thái bao gồm: 0 (Hết hạn) | 1 (Hiệu lực)
GET /api/coupons?page=1&size=10&sort=code&order=asc&code=2&name=2&status=0&created_from=2024-01-01T10%3A00%3A00Z&created_to=2025-01-01T10%3A00%3A00Z
{
"code": 200,
"message": "Success",
"result": [
{
"id": "6c626754-f44e-414b-8029-26b8fb6137eb",
"code": "20240311",
"name": "20240311",
"description": null,
"value": 10.0,
"type": "percent",
"started_at": "2024-08-15T05:00:00.000Z",
"ended_at": "2024-08-15T05:00:00.000Z",
"status": 0,
"total_quantity": 2,
"total_used_quantity": 0,
"created_at": "2024-03-11T02:29:38.000Z"
}
],
"page": 1,
"page_size": 10,
"total": 1
}
GET /api/coupons/{id}
Lấy chi tiết 1 coupon.
GET /api/coupons/6c626754-f44e-414b-8029-26b8fb6137eb
{
"code": 200,
"message": "Thành công",
"result": {
"id": "6c626754-f44e-414b-8029-26b8fb6137eb",
"code": "20240311",
"name": "20240311",
"description": null,
"value": 10.0,
"type": "percent",
"started_at": "2024-08-15T05:00:00.000Z",
"ended_at": "2024-08-15T05:00:00.000Z",
"status": 0,
"total_quantity": 2,
"total_used_quantity": 0,
"merchant_id": "00000000-0000-0000-0000-000000000004",
"deleted": 0,
"created_at": "2024-03-11T02:29:38.000Z",
"created_by": "admin",
"updated_at": "2024-08-15T06:42:15.000Z",
"updated_by": "admin"
}
}
POST /api/coupons
Tạo mới coupon.
Request Body
-
code: (string) Mã coupon. -
name: (string) Tên coupon. -
description: (string) Mô tả. -
ended_at: (string) Ngày hết hạn. -
started_at: (string) Ngày bắt đầu có hiệu lực. -
status: (string) Trạng thái. -
total_quantity: (int) Số lượng coupon. -
type: (string) Loại giảm giá. Bao gồmpercent|money -
value: (double) Giá trị giảm.
{
"code": "CP001",
"name": "Coupon 1",
"type": "money",
"description": "abc",
"value": 10000000.0,
"total_quantity": 1,
"started_at": "2024-08-06T12:00:00",
"ended_at": "2024-08-15T12:00:00",
"status": 1
}
POST /api/coupons
PUT /api/coupons/{id}
Cập nhật coupon.
Request Body
-
name: (string) Tên coupon. -
description: (string) Mô tả. -
ended_at: (string) Ngày hết hạn. -
started_at: (string) Ngày bắt đầu có hiệu lực. -
status: (string) Trạng thái. -
total_quantity: (int) Số lượng coupon. -
type: (string) Loại giảm giá. Bao gồmpercent|money -
value: (double) Giá trị giảm.
{
"name": "Coupon 1",
"type": "money",
"description": "abc",
"value": 10000000.0,
"total_quantity": 1,
"started_at": "2024-08-06T12:00:00",
"ended_at": "2024-08-15T12:00:00",
"status": 1
}
PUT /api/coupons/d529573a-f87c-4233-a917-13ad74349f35