forked from gxwebsoft/mp-10550
feat(礼品卡): 优化颜色主题并添加核销功能
- 修改礼品卡颜色主题,使用渐变色提升视觉效果 - 添加礼品卡核销功能,包括生成和验证核销码 -优化礼品卡组件,增加状态显示和使用说明 - 新增礼品卡颜色测试页面,用于验证颜色
This commit is contained in:
@@ -113,6 +113,22 @@ export async function getShopGift(id: number) {
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code查询礼品卡
|
||||
* @param code
|
||||
*/
|
||||
export async function getShopGiftByCode(code: string) {
|
||||
const res = await request.get<ApiResult<ShopGift>>(
|
||||
'/shop/shop-gift/by-code/' + code
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 兑换礼品卡
|
||||
*/
|
||||
@@ -178,3 +194,52 @@ export async function exportShopGift(ids?: number[]) {
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成礼品卡核销码
|
||||
*/
|
||||
export async function generateVerificationCode(giftId: number) {
|
||||
const res = await request.post<ApiResult<{ verificationCode: string; expireTime: string }>>(
|
||||
'/shop/shop-gift/generate-verification-code',
|
||||
{ giftId }
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证核销码
|
||||
*/
|
||||
export async function verifyGiftCard(params: { verificationCode?: string; giftCode?: string }) {
|
||||
const res = await request.post<ApiResult<ShopGift>>(
|
||||
'/shop/shop-gift/verify',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成礼品卡核销
|
||||
*/
|
||||
export async function completeVerification(params: {
|
||||
giftId: number;
|
||||
verificationCode: string;
|
||||
storeId?: number;
|
||||
storeName?: string;
|
||||
operatorId?: number;
|
||||
operatorName?: string;
|
||||
}) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-gift/complete-verification',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ export interface ShopGift {
|
||||
isShow?: string;
|
||||
// 状态 (0未使用 1已使用 2已过期 3已失效)
|
||||
status?: number;
|
||||
// 使用状态 (0可用 1已使用 2已过期)
|
||||
useStatus?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 使用说明
|
||||
@@ -74,12 +72,11 @@ export interface ShopGift {
|
||||
export interface ShopGiftParam extends PageParam {
|
||||
id?: number;
|
||||
keywords?: string;
|
||||
code?: string;
|
||||
// 礼品卡类型筛选
|
||||
type?: number;
|
||||
// 状态筛选
|
||||
// 状态筛选 (0未使用 1已使用 2失效)
|
||||
status?: number;
|
||||
// 使用状态筛选
|
||||
useStatus?: number;
|
||||
// 用户ID筛选
|
||||
userId?: number;
|
||||
// 商品ID筛选
|
||||
|
||||
Reference in New Issue
Block a user