coupon.ts
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* @Author: Auto
* @Date: 2025-01-XX
* @LastEditors: 赵丽婷
* @LastEditTime: 2025-12-25 13:55:02
* @FilePath: \LinkMed\linkmed-vue3\src\api\coupon.ts
* @Description: 优惠券相关API
* Copyright (c) 2025 by 北京连心医疗科技有限公司, All Rights Reserved.
*/
import { service as http } from "@/utils/request";
// ==================== Types ====================
/** 优惠券使用记录行 */
export interface CouponWithUsageRow {
id?: number; // 优惠券ID
code?: string; // 优惠券编码
name?: string; // 优惠券名称
userId?: number; // 用户ID
couponUserName?: string; // 所有人名称
durationNames?: string; // 会员时长名称
durationMonths?: string; // 会员时长月数
deductAmount?: number; // 优惠券抵扣金额
validDays?: number; // 有效天数
effectiveStart?: string; // 生效开始时间(ISO 8601 日期时间)
effectiveEnd?: string; // 生效结束时间(ISO 8601 日期时间)
totalQuantity?: number; // 总数量
remainingQuantity?: number; // 剩余数量
status?: number; // 优惠券状态
remark?: string; // 备注
createdAt?: string; // 创建时间(ISO 8601 日期时间)
usageStatus?: number; // 用户使用状态
usedAt?: string; // 使用时间(ISO 8601 日期时间)
orderNo?: string; // 使用订单编号
usedUserName?: string; // 使用人名称
}
/** 分页查询优惠券请求参数 */
export interface GetCouponsPageParams {
page?: number; // 页码(从0开始),默认值: 0
size?: number; // 每页数量,1-100,默认 20
}
/** 分页查询优惠券响应 */
export interface CouponsPageResponse {
items?: CouponWithUsageRow[]; // 优惠券列表
total?: number; // 总记录数
page?: number; // 当前页码
size?: number; // 每页数量
}
/** 校验优惠券请求参数 */
export interface ValidateCouponParams {
code: string; // 优惠券 code(必需)
durationTypeId: number; // 会员时长类型ID(必需)
}
// ==================== APIs ====================
/** 按用户分页查询优惠券 */
export const getCouponsPage = (params?: GetCouponsPageParams) =>
http.get<CouponsPageResponse>("/pay/coupons/page", {
params,
});
/** 校验优惠券并返回可抵扣金额 */
export const validateCoupon = (params: ValidateCouponParams) =>
http.get<number>("/pay/coupons/validate", {
params,
});