feat: 完成营销中心优惠券页面与抽屉
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 53s
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 53s
This commit is contained in:
184
apps/web-antd/src/api/marketing/index.ts
Normal file
184
apps/web-antd/src/api/marketing/index.ts
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* 文件职责:营销中心 API 与 DTO 定义。
|
||||
* 1. 维护优惠券列表、详情、保存、状态切换与删除契约。
|
||||
*/
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 优惠券类型。 */
|
||||
export type MarketingCouponType = 'amount_off' | 'discount' | 'free_delivery';
|
||||
|
||||
/** 列表展示状态。 */
|
||||
export type MarketingCouponDisplayStatus =
|
||||
| 'disabled'
|
||||
| 'ended'
|
||||
| 'ongoing'
|
||||
| 'upcoming';
|
||||
|
||||
/** 编辑状态。 */
|
||||
export type MarketingCouponEditorStatus = 'disabled' | 'enabled';
|
||||
|
||||
/** 有效期类型。 */
|
||||
export type MarketingCouponValidityType = 'days' | 'fixed';
|
||||
|
||||
/** 适用渠道。 */
|
||||
export type MarketingCouponChannel = 'delivery' | 'dine_in' | 'pickup';
|
||||
|
||||
/** 门店范围模式。 */
|
||||
export type MarketingCouponStoreScopeMode = 'all' | 'stores';
|
||||
|
||||
/** 优惠券列表查询。 */
|
||||
export interface MarketingCouponListQuery {
|
||||
couponType?: '' | MarketingCouponType;
|
||||
keyword?: string;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
status?: '' | MarketingCouponDisplayStatus;
|
||||
storeId: string;
|
||||
}
|
||||
|
||||
/** 优惠券详情查询。 */
|
||||
export interface MarketingCouponDetailQuery {
|
||||
couponId: string;
|
||||
storeId: string;
|
||||
}
|
||||
|
||||
/** 保存优惠券请求。 */
|
||||
export interface SaveMarketingCouponDto {
|
||||
channels: MarketingCouponChannel[];
|
||||
couponType: MarketingCouponType;
|
||||
id?: string;
|
||||
minimumSpend: null | number;
|
||||
name: string;
|
||||
perUserLimit: null | number;
|
||||
relativeValidDays: null | number;
|
||||
status: MarketingCouponEditorStatus;
|
||||
storeId: string;
|
||||
storeIds?: string[];
|
||||
storeScopeMode: MarketingCouponStoreScopeMode;
|
||||
totalQuantity: number;
|
||||
validFrom: null | string;
|
||||
validTo: null | string;
|
||||
validityType: MarketingCouponValidityType;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** 修改状态请求。 */
|
||||
export interface ChangeMarketingCouponStatusDto {
|
||||
couponId: string;
|
||||
status: MarketingCouponEditorStatus;
|
||||
storeId: string;
|
||||
}
|
||||
|
||||
/** 删除请求。 */
|
||||
export interface DeleteMarketingCouponDto {
|
||||
couponId: string;
|
||||
storeId: string;
|
||||
}
|
||||
|
||||
/** 统计数据。 */
|
||||
export interface MarketingCouponStatsDto {
|
||||
claimedCount: number;
|
||||
ongoingCount: number;
|
||||
redeemRate: number;
|
||||
redeemedCount: number;
|
||||
totalCount: number;
|
||||
}
|
||||
|
||||
/** 列表项。 */
|
||||
export interface MarketingCouponListItemDto {
|
||||
channels: MarketingCouponChannel[];
|
||||
claimedQuantity: number;
|
||||
couponType: MarketingCouponType;
|
||||
displayStatus: MarketingCouponDisplayStatus;
|
||||
id: string;
|
||||
isDimmed: boolean;
|
||||
minimumSpend: null | number;
|
||||
name: string;
|
||||
perUserLimit: null | number;
|
||||
redeemedQuantity: number;
|
||||
relativeValidDays: null | number;
|
||||
storeIds: string[];
|
||||
storeScopeMode: MarketingCouponStoreScopeMode;
|
||||
totalQuantity: number;
|
||||
updatedAt: string;
|
||||
validFrom: null | string;
|
||||
validTo: null | string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** 列表结果。 */
|
||||
export interface MarketingCouponListResultDto {
|
||||
items: MarketingCouponListItemDto[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
stats: MarketingCouponStatsDto;
|
||||
total: number;
|
||||
}
|
||||
|
||||
/** 详情数据。 */
|
||||
export interface MarketingCouponDetailDto {
|
||||
channels: MarketingCouponChannel[];
|
||||
claimedQuantity: number;
|
||||
couponType: MarketingCouponType;
|
||||
id: string;
|
||||
minimumSpend: null | number;
|
||||
name: string;
|
||||
perUserLimit: null | number;
|
||||
relativeValidDays: null | number;
|
||||
status: MarketingCouponEditorStatus;
|
||||
storeIds: string[];
|
||||
storeScopeMode: MarketingCouponStoreScopeMode;
|
||||
totalQuantity: number;
|
||||
updatedAt: string;
|
||||
validFrom: null | string;
|
||||
validTo: null | string;
|
||||
validityType: MarketingCouponValidityType;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** 获取优惠券列表。 */
|
||||
export async function getMarketingCouponListApi(
|
||||
params: MarketingCouponListQuery,
|
||||
) {
|
||||
return requestClient.get<MarketingCouponListResultDto>(
|
||||
'/marketing/coupon/list',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取优惠券详情。 */
|
||||
export async function getMarketingCouponDetailApi(
|
||||
params: MarketingCouponDetailQuery,
|
||||
) {
|
||||
return requestClient.get<MarketingCouponDetailDto>(
|
||||
'/marketing/coupon/detail',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 保存优惠券。 */
|
||||
export async function saveMarketingCouponApi(data: SaveMarketingCouponDto) {
|
||||
return requestClient.post<MarketingCouponDetailDto>(
|
||||
'/marketing/coupon/save',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/** 修改优惠券状态。 */
|
||||
export async function changeMarketingCouponStatusApi(
|
||||
data: ChangeMarketingCouponStatusDto,
|
||||
) {
|
||||
return requestClient.post<MarketingCouponDetailDto>(
|
||||
'/marketing/coupon/status',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/** 删除优惠券。 */
|
||||
export async function deleteMarketingCouponApi(data: DeleteMarketingCouponDto) {
|
||||
return requestClient.post('/marketing/coupon/delete', data);
|
||||
}
|
||||
Reference in New Issue
Block a user