/** * 网卡相关 API */ import { BaseService } from '../BaseService' import type { Card, SimCardProduct, CardQueryParams, CardImportBatch, CardOperationParams, CardAssignParams, BatchRechargeRecord, CardChangeApplication, ProcessCardChangeParams, FlowDetail, SuspendResumeRecord, CardOrder, BaseResponse, PaginationResponse, ListResponse } from '@/types/api' export class CardService extends BaseService { // ========== 号卡商品管理 ========== /** * 获取号卡商品列表 * @param params 查询参数 */ static getSimCardProducts(params?: any): Promise> { return this.getPage('/api/simcard-products', params) } /** * 创建号卡商品 * @param data 商品数据 */ static createSimCardProduct(data: Partial): Promise { return this.create('/api/simcard-products', data) } /** * 更新号卡商品 * @param id 商品ID * @param data 商品数据 */ static updateSimCardProduct( id: string | number, data: Partial ): Promise { return this.update(`/api/simcard-products/${id}`, data) } /** * 删除号卡商品 * @param id 商品ID */ static deleteSimCardProduct(id: string | number): Promise { return this.remove(`/api/simcard-products/${id}`) } /** * 号卡分配 * @param params 分配参数 */ static assignCard(params: CardAssignParams): Promise { return this.post('/api/simcard-products/assign', params) } // ========== 网卡管理 ========== /** * 获取网卡列表 * @param params 查询参数 */ static getCards(params?: CardQueryParams): Promise> { return this.getPage('/api/cards', params) } /** * 根据ICCID获取单卡信息 * @param iccid ICCID */ static getCardByIccid(iccid: string): Promise> { return this.getOne(`/api/cards/iccid/${iccid}`) } /** * 网卡操作(充值、停复机、增减流量等) * @param params 操作参数 */ static cardOperation(params: CardOperationParams): Promise { return this.post('/api/cards/operation', params) } /** * 套餐充值 * @param iccid ICCID * @param packageId 套餐ID */ static rechargePackage(iccid: string, packageId: string | number): Promise { return this.post(`/api/cards/${iccid}/recharge`, { packageId }) } /** * 停机 * @param iccid ICCID * @param remark 备注 */ static suspend(iccid: string, remark?: string): Promise { return this.post(`/api/cards/${iccid}/suspend`, { remark }) } /** * 复机 * @param iccid ICCID * @param remark 备注 */ static resume(iccid: string, remark?: string): Promise { return this.post(`/api/cards/${iccid}/resume`, { remark }) } /** * 获取流量详情 * @param iccid ICCID * @param startDate 开始日期 * @param endDate 结束日期 */ static getFlowDetails( iccid: string, startDate?: string, endDate?: string ): Promise> { return this.getList(`/api/cards/${iccid}/flow-details`, { startDate, endDate }) } /** * 获取停复机记录 * @param iccid ICCID */ static getSuspendResumeRecords(iccid: string): Promise> { return this.getList(`/api/cards/${iccid}/suspend-resume-records`) } /** * 获取往期订单 * @param iccid ICCID */ static getCardOrders(iccid: string): Promise> { return this.getList(`/api/cards/${iccid}/orders`) } /** * 更改过期时间 * @param iccid ICCID * @param expireTime 过期时间 */ static changeExpireTime(iccid: string, expireTime: string): Promise { return this.put(`/api/cards/${iccid}/expire-time`, { expireTime }) } /** * 增加流量 * @param iccid ICCID * @param flow 流量(MB) */ static addFlow(iccid: string, flow: number): Promise { return this.post(`/api/cards/${iccid}/add-flow`, { flow }) } /** * 减少流量 * @param iccid ICCID * @param flow 流量(MB) */ static reduceFlow(iccid: string, flow: number): Promise { return this.post(`/api/cards/${iccid}/reduce-flow`, { flow }) } /** * 变更钱包余额 * @param iccid ICCID * @param amount 金额 */ static changeWalletBalance(iccid: string, amount: number): Promise { return this.put(`/api/cards/${iccid}/wallet`, { amount }) } // ========== 批量操作 ========== /** * 获取导入批次列表 * @param params 查询参数 */ static getImportBatches(params?: any): Promise> { return this.getPage('/api/cards/import-batches', params) } /** * 批量导入网卡 * @param file Excel文件 * @param params 额外参数 */ static importCards(file: File, params?: Record): Promise { return this.upload('/api/cards/import', file, params) } /** * 获取导入失败记录 * @param batchId 批次ID */ static getImportFailures(batchId: string | number): Promise> { return this.getList(`/api/cards/import-batches/${batchId}/failures`) } /** * 批量充值记录列表 * @param params 查询参数 */ static getBatchRechargeRecords( params?: any ): Promise> { return this.getPage('/api/cards/batch-recharge-records', params) } /** * 批量充值导入 * @param file Excel文件 */ static batchRecharge(file: File): Promise { return this.upload('/api/cards/batch-recharge', file) } // ========== 换卡管理 ========== /** * 获取换卡申请列表 * @param params 查询参数 */ static getCardChangeApplications( params?: any ): Promise> { return this.getPage('/api/card-change-applications', params) } /** * 处理换卡申请 * @param params 处理参数 */ static processCardChange(params: ProcessCardChangeParams): Promise { return this.post('/api/card-change-applications/process', params) } /** * 创建换卡通知 * @param iccids ICCID列表 * @param reason 换卡原因 */ static createCardChangeNotice(iccids: string[], reason: string): Promise { return this.post('/api/card-change-notices', { iccids, reason }) } /** * 获取换卡通知记录 * @param params 查询参数 */ static getCardChangeNotices(params?: any): Promise> { return this.getPage('/api/card-change-notices', params) } }