update console
This commit is contained in:
1 parent
29fd2dd801
commit
18ec9d181c
34 files changed
+1713
-112
No files matched your search
@@ -5,3 +5,4 @@ export * from './chat';
|
||||
export * from './midjourney';
|
||||
export * from './usage';
|
||||
export * from './api';
|
||||
export * from './order';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -0,0 +1,33 @@
|
||||
import { IApplication } from '../application';
|
||||
|
||||
export enum OrderState {
|
||||
PENDING = 'Pending',
|
||||
PAID = 'Paid',
|
||||
EXPIRED = 'Expired',
|
||||
FAILED = 'Failed'
|
||||
}
|
||||
|
||||
export interface IOrder {
|
||||
id?: string;
|
||||
description?: string;
|
||||
state?: OrderState;
|
||||
price?: number;
|
||||
amount?: number;
|
||||
user_id?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
application?: IApplication;
|
||||
application_id?: string;
|
||||
wechatpay_url?: string;
|
||||
pay_id?: string;
|
||||
pay_url?: string;
|
||||
alipay_url?: string;
|
||||
pay_way?: string;
|
||||
}
|
||||
|
||||
export interface IOrderListResponse {
|
||||
count: number;
|
||||
items: IOrder[];
|
||||
}
|
||||
|
||||
export type IOrderDetailResponse = IOrder;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IOrder, IOrderDetailResponse, IOrderListResponse } from './models';
|
||||
|
||||
export interface IOrderQuery {
|
||||
user_id?: string;
|
||||
package_id?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
ordering: string;
|
||||
}
|
||||
|
||||
class OrderService {
|
||||
key = 'orders';
|
||||
|
||||
async getAll(query: IOrderQuery): Promise<AxiosResponse<IOrderListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async refresh(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/refresh/`);
|
||||
}
|
||||
|
||||
async pay(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/pay/`, data);
|
||||
}
|
||||
|
||||
async updatePrice(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/update-price/`, data);
|
||||
}
|
||||
|
||||
async finish(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/finish/`);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const orderOperator = new OrderService();
|
||||
Reference in new issue
Block a user