add package
This commit is contained in:
+2
-2
@@ -62,9 +62,9 @@ async function list(req: Page<EventItem>, options?: ListOptions): Promise<PageRe
|
||||
return await axios.post(`${BASE_URI}/list`, withCurrentStorePage(orderedPage));
|
||||
}
|
||||
|
||||
async function listValid(): Promise<EventItem[]> {
|
||||
async function listValid(storeId?: string): Promise<EventItem[]> {
|
||||
const list = await axios.post(`${BASE_URI}/list/valid`, undefined, {
|
||||
params: { storeId: getCurrentStoreId() }
|
||||
params: { storeId: storeId || getCurrentStoreId() }
|
||||
}) as unknown as EventItem[];
|
||||
return sortEventList(list);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
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";
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
async function configListValid(storeId?: string): Promise<GaoPackageConfig[]> {
|
||||
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));
|
||||
}
|
||||
|
||||
async function configUpdate(config: GaoPackageConfig): Promise<void> {
|
||||
await axios.post(`${CONFIG_URI}/update`, withStore(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));
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user