| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- // src/lib/services/orderService.ts
- import api from '@/lib/api';
- export interface OrderListParams {
- page?: number;
- page_size?: number;
- size?: number;
- keyword?: string;
- status?: string;
- channel_type?: 'direct' | 'agency' | 'website' | string;
- handler_id?: string;
- settlement_status?: 'unsettled' | 'risk_period' | 'eligible' | 'settled' | string;
- [key: string]: any;
- }
- export const orderService = {
- /**
- * 分页查询订单列表
- */
- async listAll(params?: OrderListParams) {
- const res = await api.get('/api/vas/order/list_all', { params });
- return res.data;
- },
- /**
- * 分页查询当前用户的订单列表 (前台用户)
- */
- async listByUser(params?: OrderListParams) {
- const res = await api.get('/api/vas/order/list_by_user', { params });
- return res.data;
- },
- /**
- * 获取订单详情
- */
- async getDetail(orderId: string | number) {
- const res = await api.get('/api/vas/order/detail', {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 前台用户创建订单
- */
- async create(payload: Record<string, any>) {
- const res = await api.post('/api/vas/order/create', payload);
- return res.data;
- },
- /**
- * 管理员后台直接创建订单 (支持渠道/中介/对接人/自定义价格)
- */
- async createByAdmin(payload: {
- product_id: number;
- user_inputs: Record<string, any>;
- channel_type?: 'direct' | 'agency' | 'website' | string;
- agency_id?: string | null;
- handler_id?: string | null;
- final_amount?: number | null;
- }) {
- const res = await api.post('/api/vas/order/create_by_admin', payload);
- return res.data;
- },
- /**
- * 标记订单履约出签完成,开启退款风险期(如T+7)
- */
- async markCompleted(orderId: string | number, riskDays: number = 7) {
- const res = await api.post('/api/vas/order/mark_completed', null, {
- params: { order_id: orderId, risk_days: riskDays },
- });
- return res.data;
- },
- /**
- * 取消订单
- */
- async cancel(orderId: string | number) {
- const res = await api.post('/api/vas/order/cancel', null, {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 管理员更新订单状态
- */
- async updateStatus(orderId: string | number, payload: { status: string; [key: string]: any }) {
- const res = await api.post('/api/vas/order/admin_update_status', payload, {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 修改订单用户输入数据 (JSON Patch)
- */
- async patchUserInputs(orderId: string | number, payload: Record<string, any>) {
- const res = await api.post('/api/vas/order/patch_user_inputs', payload, {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 管理员配置与更新订单属性 (渠道/对接人/中介/申报参数/状态)
- */
- async updateOrder(
- orderId: string | number,
- payload: {
- channel_type?: 'direct' | 'agency' | 'website';
- agency_id?: string | null;
- handler_id?: string | null;
- status?: string;
- user_inputs?: Record<string, any>;
- }
- ) {
- const res = await api.post('/api/vas/order/update', payload, {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 后台调整订单价格 (优惠 / 减免 / 附加费)
- */
- async adjustPrice(orderId: string | number, payload: Record<string, any>) {
- const res = await api.post('/api/vas/order/adjust-price', payload, {
- params: { order_id: orderId },
- });
- return res.data;
- },
- /**
- * 获取订单生命周期事件日志
- */
- async getEvents(orderId: string | number) {
- try {
- const res = await api.get('/api/vas/order-event/list', {
- params: { order_id: orderId },
- });
- return res.data;
- } catch {
- const res = await api.get('/api/order/events', {
- params: { order_id: orderId },
- });
- return res.data;
- }
- },
- /**
- * AI 智能解析表单数据 (LLM Data Parsing)
- */
- async parseDataWithLlm(payload: { raw_text?: string; input_raw_str?: string; schema_id?: string | number;[key: string]: any }) {
- const res = await api.post('/api/vas/llm/data_parsing', payload);
- return res.data;
- },
- };
|