Get the list of coupons that the current user can use in the current situation, supporting filtering by order amount and product ID.
Precautions
- This interface is used to get the list of coupons available to the current user.
- Coupons that apply to orders of a specified amount can be filtered through the 'amount' parameter.
- Coupons applicable to the specified product can be filtered by the 'archive_id' parameter
- You need to log in as a user to get the coupon list
- Ensure that the domain address is correctly configured.
- Returns a valid and unused coupon based on the current time
- The validity of the coupon includes time range, usage conditions, and other restrictions
Request address
{域名地址}/api/coupon/valid
Description:{域名地址}Need to replace it with your domain address, such ashttps://en.anqicms.com/api/coupon/valid
Request syntax
GET /api/coupon/valid
Request header
This interface only involves public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request Parameters
| Field Name | Type | Required | Description |
|---|---|---|---|
| amount | integer | No | Order amount, used to filter coupons that meet the amount conditions |
| archive_id | integer | No | Product ID, used for filtering coupons available for a specific product |
Response Headers
This interface only involves public response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field Name | Type | Description |
|---|---|---|
| code | integer | Error code |
| message | string | Error Description |
| data | object[] | Result Content |
| total | integer | Total Count |
data result item parameter
| Field Name | Type | Description |
|---|---|---|
| id | integer | Voucher code ID |
| Title | string | Coupon Name |
| coupon_id | integer | Coupon ID |
| start_time | integer | Start Time |
| End Time | integer | End Time |
| user_id | integer | User ID |
| money | Float | Discount amount |
| max_money | Float | Maximum discount amount |
| get_time | integer | Claim time |
| use_time | integer | Use time |
| order_id | integer | Order ID |
| Money type | integer | Discount amount type 0 = Fixed amount, 1 = Random amount, 2 = Percentage discount |
| Description | string | Description |
Example Usage
Request Example
GET /api/coupon/valid?amount=100&archive_id=5 HTTP/1.1
Host: www.anqicms.com
Response Example
{
"code": 0,
"data": [
{
"id": 1,
"title": "满减优惠券",
"coupon_id": 1,
"start_time": 1624494644,
"end_time": 1627173044,
"user_id": 1,
"money": 10.00,
"max_money": 0.00,
"get_time": 1624494644,
"use_time": 0,
"order_id": 0,
"money_type": 0,
"description": "满100可用"
},
{
"id": 2,
"title": "新用户优惠券",
"coupon_id": 2,
"start_time": 1624494644,
"end_time": 1627173044,
"user_id": 1,
"money": 20.00,
"max_money": 0.00,
"get_time": 1624494650,
"use_time": 0,
"order_id": 0,
"money_type": 0,
"description": "新用户专享优惠券"
}
],
"msg": "",
"total": 2
}
Error code
| Error code | Description |
|---|---|
| 0 | OK |
| -1 | Error, the reason is indicated in msg |
| 1001 | Not logged in |
| 1002 | Unauthorized |
| 200 | API request OK |