添加优惠券功能 & 更新折扣管理的接口
This commit is contained in:
34
src/actions/coupon.ts
Normal file
34
src/actions/coupon.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { PageRecord } from "@/lib/api"
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
import { callByUser } from "./base"
|
||||
|
||||
export async function getPagCoupon(params: { page: number; size: number }) {
|
||||
return callByUser<PageRecord<Coupon>>("/api/admin/coupon/page", params)
|
||||
}
|
||||
|
||||
export async function createCoupon(data: {
|
||||
code: string
|
||||
amount: number
|
||||
remark?: string
|
||||
min_amount?: number
|
||||
expire_at?: Date
|
||||
}) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/create", data)
|
||||
}
|
||||
|
||||
export async function updateCoupon(data: {
|
||||
code: string
|
||||
amount: number
|
||||
remark?: string
|
||||
min_amount?: number
|
||||
expire_at?: Date
|
||||
status?: number
|
||||
}) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/update", data)
|
||||
}
|
||||
|
||||
export async function deleteCoupon(id: number) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/remove", {
|
||||
id,
|
||||
})
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import type { ProductDiscount } from "@/models/product_discount"
|
||||
import { callByUser } from "./base"
|
||||
|
||||
export async function getAllProductDiscount() {
|
||||
return callByUser<ProductDiscount[]>("/api/admin/product/discount/all")
|
||||
return callByUser<ProductDiscount[]>("/api/admin/discount/all")
|
||||
}
|
||||
|
||||
export async function getPageProductDiscount(params: {
|
||||
@@ -13,7 +13,7 @@ export async function getPageProductDiscount(params: {
|
||||
size: number
|
||||
}) {
|
||||
return callByUser<PageRecord<ProductDiscount>>(
|
||||
"/api/admin/product/discount/page",
|
||||
"/api/admin/discount/page",
|
||||
params,
|
||||
)
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export async function createProductDiscount(data: {
|
||||
name: string
|
||||
discount: string
|
||||
}) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/create", {
|
||||
return callByUser<ProductDiscount>("/api/admin/discount/create", {
|
||||
name: data.name,
|
||||
discount: Number(data.discount),
|
||||
})
|
||||
@@ -33,7 +33,7 @@ export async function updateProductDiscount(data: {
|
||||
name?: string
|
||||
discount?: string
|
||||
}) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/update", {
|
||||
return callByUser<ProductDiscount>("/api/admin/discount/update", {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
discount: data.discount ? Number(data.discount) : undefined,
|
||||
@@ -41,7 +41,7 @@ export async function updateProductDiscount(data: {
|
||||
}
|
||||
|
||||
export async function deleteProductDiscount(id: number) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/remove", {
|
||||
return callByUser<ProductDiscount>("/api/admin/discount/remove", {
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function getPageUsers(params: { page: number; size: number }) {
|
||||
|
||||
export async function bindAdmin(params: {
|
||||
id: number
|
||||
phone?: string
|
||||
account?: string
|
||||
name?: string
|
||||
identified?: boolean
|
||||
enabled?: boolean
|
||||
|
||||
Reference in New Issue
Block a user