This commit is contained in:
129
src/api/modules/exchange.ts
Normal file
129
src/api/modules/exchange.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* 换货管理 API 服务
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type { BaseResponse, PaginationResponse } from '@/types/api'
|
||||
|
||||
// 换货单查询参数
|
||||
export interface ExchangeQueryParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
status?: number // 换货状态
|
||||
identifier?: string // 资产标识符(模糊匹配)
|
||||
created_at_start?: string // 创建时间起始
|
||||
created_at_end?: string // 创建时间结束
|
||||
}
|
||||
|
||||
// 创建换货单请求
|
||||
export interface CreateExchangeRequest {
|
||||
exchange_reason: string // 换货原因
|
||||
old_asset_type: string // 旧资产类型 (iot_card 或 device)
|
||||
old_identifier: string // 旧资产标识符(ICCID/虚拟号/IMEI/SN)
|
||||
remark?: string // 备注(可选)
|
||||
}
|
||||
|
||||
// 换货单响应
|
||||
export interface ExchangeResponse {
|
||||
id: number
|
||||
exchange_no: string
|
||||
exchange_reason: string
|
||||
old_asset_type: string
|
||||
old_asset_identifier: string
|
||||
new_asset_type: string
|
||||
new_asset_identifier: string
|
||||
status: number // 换货状态(1:待填写信息, 2:待发货, 3:已发货待确认, 4:已完成, 5:已取消)
|
||||
status_text: string
|
||||
recipient_name?: string
|
||||
recipient_phone?: string
|
||||
recipient_address?: string
|
||||
express_company?: string
|
||||
express_no?: string
|
||||
remark?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
// 换货发货请求
|
||||
export interface ShipExchangeRequest {
|
||||
express_company: string // 快递公司
|
||||
express_no: string // 快递单号
|
||||
migrate_data: boolean // 是否迁移数据
|
||||
new_identifier: string // 新资产标识符(ICCID/虚拟号/IMEI/SN)
|
||||
}
|
||||
|
||||
// 取消换货请求
|
||||
export interface CancelExchangeRequest {
|
||||
remark?: string // 取消备注(可选)
|
||||
}
|
||||
|
||||
export class ExchangeService extends BaseService {
|
||||
/**
|
||||
* 获取换货单列表
|
||||
* GET /api/admin/exchanges
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getExchanges(
|
||||
params?: ExchangeQueryParams
|
||||
): Promise<BaseResponse<{ list: ExchangeResponse[]; page: number; page_size: number; total: number }>> {
|
||||
return this.get<
|
||||
BaseResponse<{ list: ExchangeResponse[]; page: number; page_size: number; total: number }>
|
||||
>('/api/admin/exchanges', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建换货单
|
||||
* POST /api/admin/exchanges
|
||||
* @param data 创建参数
|
||||
*/
|
||||
static createExchange(data: CreateExchangeRequest): Promise<BaseResponse<ExchangeResponse>> {
|
||||
return this.create<ExchangeResponse>('/api/admin/exchanges', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取换货单详情
|
||||
* GET /api/admin/exchanges/{id}
|
||||
* @param id 换货单ID
|
||||
*/
|
||||
static getExchangeDetail(id: number): Promise<BaseResponse<ExchangeResponse>> {
|
||||
return this.getOne<ExchangeResponse>(`/api/admin/exchanges/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消换货
|
||||
* POST /api/admin/exchanges/{id}/cancel
|
||||
* @param id 换货单ID
|
||||
* @param data 取消参数
|
||||
*/
|
||||
static cancelExchange(id: number, data?: CancelExchangeRequest): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/exchanges/${id}/cancel`, data || {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认换货完成
|
||||
* POST /api/admin/exchanges/{id}/complete
|
||||
* @param id 换货单ID
|
||||
*/
|
||||
static completeExchange(id: number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/exchanges/${id}/complete`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 旧资产转新
|
||||
* POST /api/admin/exchanges/{id}/renew
|
||||
* @param id 换货单ID
|
||||
*/
|
||||
static renewExchange(id: number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/exchanges/${id}/renew`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 换货发货
|
||||
* POST /api/admin/exchanges/{id}/ship
|
||||
* @param id 换货单ID
|
||||
* @param data 发货参数
|
||||
*/
|
||||
static shipExchange(id: number, data: ShipExchangeRequest): Promise<BaseResponse<ExchangeResponse>> {
|
||||
return this.post<BaseResponse<ExchangeResponse>>(`/api/admin/exchanges/${id}/ship`, data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user