add product

This commit is contained in:
Timi
2026-09-03 14:27:40 +08:00
parent 7f669621fb
commit 333999fe21
63 changed files with 5662 additions and 2210 deletions
+31
View File
@@ -0,0 +1,31 @@
import { axios } from "timi-web-api";
import { withCurrentStoreId } from "@/utils/store";
import type { FulfillmentActionRequest, FulfillmentPage, FulfillmentPageResult, FulfillmentPrepareStockRequest, FulfillmentRevokeRequest, OrderFulfillment, OrderFulfillmentCreateRequest } from "@/types/Fulfillment";
const URI = "/gao/order/fulfillment";
async function list(page: FulfillmentPage): Promise<FulfillmentPageResult<OrderFulfillment>> {
return await axios.post(`${URI}/list`, withCurrentStoreId(page));
}
async function detail(id: string): Promise<OrderFulfillment> {
return await axios.post(`${URI}/detail`, undefined, { params: { id } });
}
async function create(request: OrderFulfillmentCreateRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/create`, request);
}
async function prepareStock(request: FulfillmentPrepareStockRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/prepare-stock`, request);
}
async function verify(request: FulfillmentActionRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/verify`, request);
}
async function reject(request: FulfillmentActionRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/reject`, request);
}
async function cancel(request: FulfillmentActionRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/cancel`, request);
}
async function revoke(request: FulfillmentRevokeRequest): Promise<OrderFulfillment> {
return await axios.post(`${URI}/revoke`, request);
}
export default { list, detail, create, prepareStock, verify, reject, cancel, revoke };
+8 -159
View File
@@ -1,190 +1,39 @@
import { axios } from "timi-web-api";
import { getCurrentStoreId } from "@/utils/store";
import type {
CustomerPackagePage,
DeliveryPage,
FundRecordPage,
GaoCustomerPackage,
GaoFundRecord,
GaoPackageConfig,
GaoPackageDelivery,
PackageConfigPage,
PackagePageResult,
PackagePaymentReceiveRequest,
PackagePurchaseRequest,
PackageDeliveryCreateRequest,
PackageAttachment
} from "@/types/Package";
import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store";
import type { CustomerPackagePage, GaoCustomerPackage, GaoPackageConfig, PackageConfigPage, PackagePageResult, PackagePurchaseRequest } from "@/types/Package";
const CONFIG_URI = "/gao/package/config";
const CUSTOMER_PACKAGE_URI = "/gao/customer/package";
const DELIVERY_URI = "/gao/package/delivery";
const FUND_URI = "/gao/fund/record";
function withStore<T extends { storeId?: string }>(request: T): T {
const storeId = request.storeId || getCurrentStoreId();
return storeId ? { ...request, storeId } : request;
}
async function configList(page: PackageConfigPage): Promise<PackagePageResult<GaoPackageConfig>> {
return await axios.post(`${CONFIG_URI}/list`, withStore(page));
return await axios.post(`${CONFIG_URI}/list`, withCurrentStoreId(page));
}
async function configListValid(storeId?: string): Promise<GaoPackageConfig[]> {
return await axios.post(`${CONFIG_URI}/list/valid`, undefined, {
params: { storeId: storeId || getCurrentStoreId() }
});
return await axios.post(`${CONFIG_URI}/list/valid`, undefined, { params: { storeId: storeId || getCurrentStoreId() } });
}
async function configDetail(id: string): Promise<GaoPackageConfig> {
return await axios.post(`${CONFIG_URI}/detail`, undefined, { params: { id } });
}
async function configCreate(config: GaoPackageConfig): Promise<string> {
return await axios.post(`${CONFIG_URI}/create`, withStore(config));
return await axios.post(`${CONFIG_URI}/create`, withCurrentStoreId(config));
}
async function configUpdate(config: GaoPackageConfig): Promise<void> {
await axios.post(`${CONFIG_URI}/update`, withStore(config));
await axios.post(`${CONFIG_URI}/update`, withCurrentStoreId(config));
}
async function configRemove(id: string): Promise<void> {
await axios.post(`${CONFIG_URI}/delete`, undefined, { params: { id } });
}
async function customerPackageList(page: CustomerPackagePage): Promise<PackagePageResult<GaoCustomerPackage>> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/list`, withStore(page));
return await axios.post(`${CUSTOMER_PACKAGE_URI}/list`, withCurrentStoreId(page));
}
async function customerPackageDetail(id: string): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/detail`, undefined, { params: { id } });
}
async function purchase(request: PackagePurchaseRequest): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/purchase`, request);
}
async function cancel(customerPackageId: string, reason: string): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/cancel`, { customerPackageId, reason });
}
async function receivePayment(request: PackagePaymentReceiveRequest): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/payment/receive`, request);
}
async function verifyPayment(fundRecordId: string): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/payment/verify`, undefined, { params: { id: fundRecordId } });
}
async function rejectPayment(fundRecordId: string, reason: string): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/payment/reject`, { fundRecordId, reason });
}
async function cancelPayment(fundRecordId: string, reason: string): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/payment/cancel`, { fundRecordId, reason });
}
async function refund(request: {
requestNo: string;
customerPackageId: string;
amount: number;
occurredAt?: number;
reason: string;
attachmentList: PackageAttachment[];
remark?: string | null;
}): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/refund`, request);
}
async function confirmNoRefund(request: {
requestNo: string;
customerPackageId: string;
occurredAt?: number;
reason: string;
remark?: string | null;
}): Promise<GaoCustomerPackage> {
return await axios.post(`${CUSTOMER_PACKAGE_URI}/refund/confirm-none`, request);
}
async function deliveryList(page: DeliveryPage): Promise<PackagePageResult<GaoPackageDelivery>> {
return await axios.post(`${DELIVERY_URI}/list`, withStore(page));
}
async function deliveryDetail(id: string): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/detail`, undefined, { params: { id } });
}
async function createDelivery(request: PackageDeliveryCreateRequest): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/create`, request);
}
async function verifyDelivery(id: string): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/verify`, undefined, { params: { id } });
}
async function rejectDelivery(deliveryId: string, reason: string): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/reject`, { deliveryId, reason });
}
async function cancelDelivery(deliveryId: string, reason: string): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/cancel`, { deliveryId, reason });
}
async function revokeDelivery(request: {
requestNo: string;
deliveryId: string;
deliveredAt?: number;
reason: string;
attachmentList: PackageAttachment[];
remark?: string | null;
}): Promise<GaoPackageDelivery> {
return await axios.post(`${DELIVERY_URI}/revoke`, request);
}
async function fundRecordList(page: FundRecordPage): Promise<PackagePageResult<GaoFundRecord>> {
return await axios.post(`${FUND_URI}/list`, withStore(page));
}
async function fundRecordDetail(id: string): Promise<GaoFundRecord> {
return await axios.post(`${FUND_URI}/detail`, undefined, { params: { id } });
}
async function revokeFundRecord(request: {
requestNo: string;
fundRecordId: string;
occurredAt?: number;
reason: string;
attachmentList: PackageAttachment[];
remark?: string | null;
}): Promise<GaoFundRecord> {
return await axios.post(`${FUND_URI}/revoke`, request);
}
export default {
configList,
configListValid,
configDetail,
configCreate,
configUpdate,
configRemove,
customerPackageList,
customerPackageDetail,
purchase,
cancel,
receivePayment,
verifyPayment,
rejectPayment,
cancelPayment,
refund,
confirmNoRefund,
deliveryList,
deliveryDetail,
createDelivery,
verifyDelivery,
rejectDelivery,
cancelDelivery,
revokeDelivery,
fundRecordList,
fundRecordDetail,
revokeFundRecord
};
export default { configList, configListValid, configDetail, configCreate, configUpdate, configRemove, customerPackageList, customerPackageDetail, purchase, cancel };
+106
View File
@@ -0,0 +1,106 @@
import { axios } from "timi-web-api";
import type { Product, ProductCategory, ProductCategoryPage, ProductPage, ProductPageResult, ProductStock, ProductStockChangeRequest, ProductStockPage, StockRecord, StockRecordPage } from "@/types/Product";
import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store";
const PRODUCT_URI = "/gao/product";
const STOCK_URI = "/gao/product/stock";
async function categoryList(page: ProductCategoryPage): Promise<ProductPageResult<ProductCategory>> {
return await axios.post(`${PRODUCT_URI}/category/list`, withCurrentStoreId(page));
}
async function categoryCreate(category: ProductCategory): Promise<string> {
return await axios.post(`${PRODUCT_URI}/category/create`, withCurrentStoreId(category));
}
async function categoryUpdate(category: ProductCategory): Promise<void> {
await axios.post(`${PRODUCT_URI}/category/update`, withCurrentStoreId(category));
}
async function categorySort(idList: string[]): Promise<void> {
return await axios.post(`${PRODUCT_URI}/category/sort`, idList);
}
async function categoryDisable(id: string): Promise<void> {
await axios.post(`${PRODUCT_URI}/category/disable`, undefined, { params: { id } });
}
async function list(page: ProductPage): Promise<ProductPageResult<Product>> {
return await axios.post(`${PRODUCT_URI}/list`, withCurrentStoreId(page));
}
async function detail(id: string): Promise<Product> {
return await axios.post(`${PRODUCT_URI}/detail`, undefined, { params: { id } });
}
async function create(product: Product): Promise<string> {
return await axios.post(`${PRODUCT_URI}/create`, withCurrentStoreId(product));
}
async function update(product: Product): Promise<void> {
await axios.post(`${PRODUCT_URI}/update`, withCurrentStoreId(product));
}
async function disable(id: string): Promise<void> {
await axios.post(`${PRODUCT_URI}/disable`, undefined, { params: { id } });
}
async function sellableList(page: ProductPage): Promise<Product[]> {
return await axios.post(`${PRODUCT_URI}/sellable/list`, withCurrentStoreId(page));
}
async function stockList(page: ProductStockPage): Promise<ProductPageResult<ProductStock>> {
return await axios.post(`${STOCK_URI}/list`, withCurrentStoreId(page));
}
async function stockDetail(productId: string, storeId?: string): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/detail`, undefined, {
params: { productId, storeId: storeId || getCurrentStoreId() }
});
}
async function initialIn(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/initial-in`, withCurrentStoreId(request));
}
async function manualIn(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/manual-in`, withCurrentStoreId(request));
}
async function manualOut(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/manual-out`, withCurrentStoreId(request));
}
async function stocktakeGain(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/stocktake-gain`, withCurrentStoreId(request));
}
async function stocktakeLoss(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/stocktake-loss`, withCurrentStoreId(request));
}
async function recordList(page: StockRecordPage): Promise<ProductPageResult<StockRecord>> {
return await axios.post(`${STOCK_URI}/record/list`, withCurrentStoreId(page));
}
export default {
categoryList,
categoryCreate,
categoryUpdate,
categorySort,
categoryDisable,
list,
detail,
create,
update,
disable,
sellableList,
stockList,
stockDetail,
initialIn,
manualIn,
manualOut,
stocktakeGain,
stocktakeLoss,
recordList
};
+64
View File
@@ -0,0 +1,64 @@
import { axios } from "timi-web-api";
import { withCurrentStoreId } from "@/utils/store";
import type {
DirectProductOrderCreateRequest,
FundRecord,
FundRecordPage,
OrderPaymentActionRequest,
OrderPaymentNoRefundRequest,
OrderPaymentReceiveRequest,
OrderPaymentRefundRequest,
OrderPaymentRevokeRequest,
SalesOrder,
SalesOrderCancelRequest,
SalesOrderPage,
SalesOrderPageResult
} from "@/types/SalesOrder";
const ORDER_URI = "/gao/sales/order";
const FUND_URI = "/gao/fund/record";
async function list(page: SalesOrderPage): Promise<SalesOrderPageResult<SalesOrder>> {
return await axios.post(`${ORDER_URI}/list`, withCurrentStoreId(page));
}
async function detail(id: string): Promise<SalesOrder> {
return await axios.post(`${ORDER_URI}/detail`, undefined, { params: { id } });
}
async function createDirectProduct(request: DirectProductOrderCreateRequest): Promise<SalesOrder> {
return await axios.post(`${ORDER_URI}/direct-product/create`, request);
}
async function cancel(request: SalesOrderCancelRequest): Promise<SalesOrder> {
return await axios.post(`${ORDER_URI}/cancel`, request);
}
async function receivePayment(request: OrderPaymentReceiveRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/payment/receive`, request);
}
async function verifyPayment(id: string): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/payment/verify`, undefined, { params: { id } });
}
async function rejectPayment(request: OrderPaymentActionRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/payment/reject`, request);
}
async function cancelPayment(request: OrderPaymentActionRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/payment/cancel`, request);
}
async function refund(request: OrderPaymentRefundRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/refund`, request);
}
async function confirmNoRefund(request: OrderPaymentNoRefundRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/refund/confirm-none`, request);
}
async function revokeFund(request: OrderPaymentRevokeRequest): Promise<FundRecord> {
return await axios.post(`${ORDER_URI}/fund/revoke`, request);
}
async function fundRecordList(page: FundRecordPage): Promise<SalesOrderPageResult<FundRecord>> {
return await axios.post(`${FUND_URI}/list`, withCurrentStoreId(page));
}
async function fundRecordDetail(id: string): Promise<FundRecord> {
return await axios.post(`${FUND_URI}/detail`, undefined, { params: { id } });
}
async function fundRecordRevoke(request: OrderPaymentRevokeRequest): Promise<FundRecord> {
return await axios.post(`${FUND_URI}/revoke`, request);
}
export default { list, detail, createDirectProduct, cancel, receivePayment, verifyPayment, rejectPayment, cancelPayment, refund, confirmNoRefund, revokeFund, fundRecordList, fundRecordDetail, fundRecordRevoke };
+8
View File
@@ -1,5 +1,6 @@
import { axios } from "timi-web-api";
import type { Page, PageResult } from "timi-web-api";
import type { EventItem } from "@/types/EventItem";
import type { Store, StoreBusinessDay } from "@/types/Store";
const STORE_BASE_URI = "/gao/store";
@@ -15,6 +16,12 @@ async function detail(id: string): Promise<Store> {
});
}
async function directProductSaleEventList(storeId: string): Promise<EventItem[]> {
return await axios.post(`${STORE_BASE_URI}/direct-product-sale-event/list`, undefined, {
params: { storeId }
});
}
async function loginStore(): Promise<Store | undefined> {
return await axios.post(`${STORE_BASE_URI}/user`);
}
@@ -80,6 +87,7 @@ async function removeBusinessDay(id: string): Promise<void> {
export default {
list,
detail,
directProductSaleEventList,
loginStore,
create,
update,