实现价格折扣动态调整
This commit is contained in:
@@ -19,3 +19,49 @@ export async function getPageProductSku(params: {
|
||||
params,
|
||||
)
|
||||
}
|
||||
|
||||
export async function createProductSku(data: {
|
||||
product_id: number
|
||||
code: string
|
||||
name: string
|
||||
price: string
|
||||
discount_id?: number
|
||||
}) {
|
||||
return callByUser<ProductSku>("/api/admin/product/sku/create", {
|
||||
product_id: data.product_id,
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
price: data.price,
|
||||
discount_id: data.discount_id,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateProductSku(data: {
|
||||
id: number
|
||||
code?: string
|
||||
name?: string
|
||||
price?: string
|
||||
discount_id?: number | null
|
||||
}) {
|
||||
return callByUser<ProductSku>("/api/admin/product/sku/update", {
|
||||
id: data.id,
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
price: data.price,
|
||||
discount_id: data.discount_id,
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteProductSku(id: number) {
|
||||
return callByUser<ProductSku>("/api/admin/product/sku/remove", { id })
|
||||
}
|
||||
|
||||
export async function batchUpdateProductSkuDiscount(data: {
|
||||
product_id: number
|
||||
discount_id: number | null
|
||||
}) {
|
||||
return callByUser<void>("/api/admin/product/sku/update/discount/batch", {
|
||||
product_id: data.product_id,
|
||||
discount_id: data.discount_id,
|
||||
})
|
||||
}
|
||||
|
||||
47
src/actions/product_discount.ts
Normal file
47
src/actions/product_discount.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
"use server"
|
||||
|
||||
import type { PageRecord } from "@/lib/api"
|
||||
import type { ProductDiscount } from "@/models/product_discount"
|
||||
import { callByUser } from "./base"
|
||||
|
||||
export async function getAllProductDiscount() {
|
||||
return callByUser<ProductDiscount[]>("/api/admin/product/discount/all")
|
||||
}
|
||||
|
||||
export async function getPageProductDiscount(params: {
|
||||
page: number
|
||||
size: number
|
||||
}) {
|
||||
return callByUser<PageRecord<ProductDiscount>>(
|
||||
"/api/admin/product/discount/page",
|
||||
params,
|
||||
)
|
||||
}
|
||||
|
||||
export async function createProductDiscount(data: {
|
||||
name: string
|
||||
discount: string
|
||||
}) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/create", {
|
||||
name: data.name,
|
||||
discount: Number(data.discount),
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateProductDiscount(data: {
|
||||
id: number
|
||||
name?: string
|
||||
discount?: string
|
||||
}) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/update", {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
discount: data.discount ? Number(data.discount) : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteProductDiscount(id: number) {
|
||||
return callByUser<ProductDiscount>("/api/admin/product/discount/remove", {
|
||||
id,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user