修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m33s

This commit is contained in:
sexygoat
2026-03-17 09:31:37 +08:00
parent 8f31526499
commit f4ccf9ed24
28 changed files with 3383 additions and 1247 deletions

179
src/api/modules/asset.ts Normal file
View File

@@ -0,0 +1,179 @@
/**
* 资产管理 API 服务
* 对应文档asset-detail-refactor-api-changes.md
*/
import { BaseService } from '../BaseService'
import type {
BaseResponse,
AssetType,
AssetResolveResponse,
AssetRealtimeStatusResponse,
AssetRefreshResponse,
AssetPackageUsageRecord,
AssetCurrentPackageResponse,
DeviceStopResponse,
DeviceStartResponse,
CardStopResponse,
CardStartResponse,
AssetWalletTransactionListResponse,
AssetWalletTransactionParams,
AssetWalletResponse
} from '@/types/api'
export class AssetService extends BaseService {
/**
* 通过任意标识符查询设备或卡的完整详情
* 支持虚拟号、ICCID、IMEI、SN、MSISDN
* GET /api/admin/assets/resolve/:identifier
* @param identifier 资产标识符虚拟号、ICCID、IMEI、SN、MSISDN
*/
static resolveAsset(identifier: string): Promise<BaseResponse<AssetResolveResponse>> {
return this.getOne<AssetResolveResponse>(`/api/admin/assets/resolve/${identifier}`)
}
/**
* 读取资产实时状态(直接读 DB/Redis不调网关
* GET /api/admin/assets/:asset_type/:id/realtime-status
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
*/
static getRealtimeStatus(
assetType: AssetType,
id: number
): Promise<BaseResponse<AssetRealtimeStatusResponse>> {
return this.getOne<AssetRealtimeStatusResponse>(
`/api/admin/assets/${assetType}/${id}/realtime-status`
)
}
/**
* 主动调网关拉取最新数据后返回
* POST /api/admin/assets/:asset_type/:id/refresh
* 注意:设备有 30 秒冷却期,冷却中调用返回 429
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
*/
static refreshAsset(
assetType: AssetType,
id: number
): Promise<BaseResponse<AssetRefreshResponse>> {
return this.post<BaseResponse<AssetRefreshResponse>>(
`/api/admin/assets/${assetType}/${id}/refresh`,
{}
)
}
/**
* 查询该资产所有套餐记录,含虚流量换算字段
* GET /api/admin/assets/:asset_type/:id/packages
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
*/
static getAssetPackages(
assetType: AssetType,
id: number
): Promise<BaseResponse<AssetPackageUsageRecord[]>> {
return this.get<BaseResponse<AssetPackageUsageRecord[]>>(
`/api/admin/assets/${assetType}/${id}/packages`
)
}
/**
* 查询当前生效中的主套餐
* GET /api/admin/assets/:asset_type/:id/current-package
* 无生效套餐时返回 404
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
*/
static getCurrentPackage(
assetType: AssetType,
id: number
): Promise<BaseResponse<AssetCurrentPackageResponse>> {
return this.getOne<AssetCurrentPackageResponse>(
`/api/admin/assets/${assetType}/${id}/current-package`
)
}
// ========== 设备停复机操作 ==========
/**
* 批量停机设备下所有已实名卡
* POST /api/admin/assets/device/:device_id/stop
* 停机成功后设置 1 小时停机保护期(保护期内禁止复机)
* @param deviceId 设备ID
*/
static stopDevice(deviceId: number): Promise<BaseResponse<DeviceStopResponse>> {
return this.post<BaseResponse<DeviceStopResponse>>(
`/api/admin/assets/device/${deviceId}/stop`,
{}
)
}
/**
* 批量复机设备下所有已实名卡
* POST /api/admin/assets/device/:device_id/start
* 复机成功后设置 1 小时复机保护期(保护期内禁止停机)
* @param deviceId 设备ID
*/
static startDevice(deviceId: number): Promise<BaseResponse<void>> {
return this.post<BaseResponse<void>>(`/api/admin/assets/device/${deviceId}/start`, {})
}
// ========== 单卡停复机操作 ==========
/**
* 手动停机单张卡(通过 ICCID
* POST /api/admin/assets/card/:iccid/stop
* 若卡绑定的设备在复机保护期内,返回 403
* @param iccid ICCID
*/
static stopCard(iccid: string): Promise<BaseResponse<void>> {
return this.post<BaseResponse<void>>(`/api/admin/assets/card/${iccid}/stop`, {})
}
/**
* 手动复机单张卡(通过 ICCID
* POST /api/admin/assets/card/:iccid/start
* 若卡绑定的设备在停机保护期内,返回 403
* @param iccid ICCID
*/
static startCard(iccid: string): Promise<BaseResponse<void>> {
return this.post<BaseResponse<void>>(`/api/admin/assets/card/${iccid}/start`, {})
}
// ========== 钱包查询 ==========
/**
* 查询指定卡或设备的钱包余额概况
* GET /api/admin/assets/:asset_type/:id/wallet
* 企业账号禁止调用
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
*/
static getAssetWallet(
assetType: AssetType,
id: number
): Promise<BaseResponse<AssetWalletResponse>> {
return this.getOne<AssetWalletResponse>(`/api/admin/assets/${assetType}/${id}/wallet`)
}
/**
* 分页查询指定资产的钱包收支流水
* GET /api/admin/assets/:asset_type/:id/wallet/transactions
* 企业账号禁止调用
* @param assetType 资产类型 (card 或 device)
* @param id 资产ID
* @param params 查询参数
*/
static getWalletTransactions(
assetType: AssetType,
id: number,
params?: AssetWalletTransactionParams
): Promise<BaseResponse<AssetWalletTransactionListResponse>> {
return this.get<BaseResponse<AssetWalletTransactionListResponse>>(
`/api/admin/assets/${assetType}/${id}/wallet/transactions`,
params
)
}
}

View File

@@ -19,9 +19,6 @@ import type {
BaseResponse,
PaginationResponse,
ListResponse,
GatewayFlowUsageResponse,
GatewayRealnameStatusResponse,
GatewayCardStatusResponse,
GatewayRealnameLinkResponse
} from '@/types/api'
@@ -91,7 +88,8 @@ export class CardService extends BaseService {
}
/**
* 通过ICCID查询单卡详情接口,用于单卡查询页面
* 通过ICCID查询单卡详情接口,已废弃
* @deprecated 使用 AssetService.resolveAsset 替代
* @param iccid ICCID
*/
static getIotCardDetailByIccid(iccid: string): Promise<BaseResponse<any>> {
@@ -374,36 +372,6 @@ export class CardService extends BaseService {
// ========== IoT卡网关操作相关 ==========
/**
* 查询流量使用
* @param iccid ICCID
*/
static getGatewayFlow(iccid: string): Promise<BaseResponse<GatewayFlowUsageResponse>> {
return this.get<BaseResponse<GatewayFlowUsageResponse>>(
`/api/admin/iot-cards/${iccid}/gateway-flow`
)
}
/**
* 查询实名认证状态
* @param iccid ICCID
*/
static getGatewayRealname(iccid: string): Promise<BaseResponse<GatewayRealnameStatusResponse>> {
return this.get<BaseResponse<GatewayRealnameStatusResponse>>(
`/api/admin/iot-cards/${iccid}/gateway-realname`
)
}
/**
* 查询卡实时状态
* @param iccid ICCID
*/
static getGatewayStatus(iccid: string): Promise<BaseResponse<GatewayCardStatusResponse>> {
return this.get<BaseResponse<GatewayCardStatusResponse>>(
`/api/admin/iot-cards/${iccid}/gateway-status`
)
}
/**
* 获取实名认证链接
* @param iccid ICCID
@@ -413,20 +381,4 @@ export class CardService extends BaseService {
`/api/admin/iot-cards/${iccid}/realname-link`
)
}
/**
* 启用物联网卡(复机)
* @param iccid ICCID
*/
static startCard(iccid: string): Promise<BaseResponse> {
return this.post<BaseResponse>(`/api/admin/iot-cards/${iccid}/start`, {})
}
/**
* 停用物联网卡(停机)
* @param iccid ICCID
*/
static stopCard(iccid: string): Promise<BaseResponse> {
return this.post<BaseResponse>(`/api/admin/iot-cards/${iccid}/stop`, {})
}
}

View File

@@ -46,14 +46,6 @@ export class DeviceService extends BaseService {
return this.getOne<Device>(`/api/admin/devices/${id}`)
}
/**
* 通过设备号查询设备详情
* @param imei 设备号(IMEI)
*/
static getDeviceByImei(imei: string): Promise<BaseResponse<Device>> {
return this.getOne<Device>(`/api/admin/devices/by-imei/${imei}`)
}
/**
* 通过ICCID查询设备详情
* @param iccid ICCID

View File

@@ -25,6 +25,7 @@ export { PackageSeriesService } from './packageSeries'
export { PackageManageService } from './packageManage'
export { ShopSeriesGrantService } from './shopSeriesGrant'
export { OrderService } from './order'
export { AssetService } from './asset'
// TODO: 按需添加其他业务模块
// export { SettingService } from './setting'