修改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

277
src/types/api/asset.ts Normal file
View File

@@ -0,0 +1,277 @@
/**
* 资产管理相关类型定义
* 对应文档asset-detail-refactor-api-changes.md
*/
// ========== 资产类型枚举 ==========
// 资产类型
export type AssetType = 'card' | 'device'
// 网络状态
export enum NetworkStatus {
OFFLINE = 0, // 停机
ONLINE = 1 // 开机
}
// 实名状态
export enum RealNameStatus {
NOT_VERIFIED = 0, // 未实名
VERIFYING = 1, // 实名中
VERIFIED = 2 // 已实名
}
// 保护期状态
export type DeviceProtectStatus = 'none' | 'stop' | 'start'
// 套餐使用状态
export enum PackageUsageStatus {
PENDING = 0, // 待生效
ACTIVE = 1, // 生效中
USED_UP = 2, // 已用完
EXPIRED = 3, // 已过期
INVALID = 4 // 已失效
}
// 套餐类型
export type PackageType = 'formal' | 'addon'
// 套餐使用类型
export type UsageType = 'single_card' | 'device'
// ========== 资产详情响应 ==========
/**
* 资产解析/详情响应
* 对应接口GET /api/admin/assets/resolve/:identifier
*/
export interface AssetResolveResponse {
asset_type: AssetType // 资产类型card 或 device
asset_id: number // 数据库 ID
virtual_no: string // 虚拟号
status: number // 资产状态
batch_no: string // 批次号
shop_id: number // 所属店铺 ID
shop_name: string // 所属店铺名称
series_id: number // 套餐系列 ID
series_name: string // 套餐系列名称
real_name_status: RealNameStatus // 实名状态0 未实名 / 1 实名中 / 2 已实名
network_status?: NetworkStatus // 网络状态0 停机 / 1 开机(仅 card
current_package: string // 当前套餐名称(无则空)
package_total_mb: number // 当前套餐总虚流量 MB
package_used_mb: number // 已用虚流量 MB
package_remain_mb: number // 剩余虚流量 MB
device_protect_status?: DeviceProtectStatus // 保护期状态none / stop / start仅 device
activated_at: string // 激活时间
created_at: string // 创建时间
updated_at: string // 更新时间
accumulated_recharge?: number // 累计充值金额(分)
first_commission_paid?: boolean // 一次性佣金是否已发放
// ===== 卡专属字段 (asset_type === 'card' 时) =====
iccid?: string // 卡 ICCID
bound_device_id?: number // 绑定设备 ID
bound_device_no?: string // 绑定设备虚拟号
bound_device_name?: string // 绑定设备名称
carrier_id?: number // 运营商ID
carrier_type?: string // 运营商类型
carrier_name?: string // 运营商名称
msisdn?: string // 手机号
imsi?: string // IMSI
card_category?: string // 卡业务类型
supplier?: string // 供应商
activation_status?: number // 激活状态
enable_polling?: boolean // 是否参与轮询
// ===== 设备专属字段 (asset_type === 'device' 时) =====
bound_card_count?: number // 绑定卡数量
cards?: AssetBoundCard[] // 绑定卡列表
device_name?: string // 设备名称
imei?: string // IMEI
sn?: string // 序列号
device_model?: string // 设备型号
device_type?: string // 设备类型
max_sim_slots?: number // 最大插槽数
manufacturer?: string // 制造商
}
/**
* 设备绑定的卡信息
*/
export interface AssetBoundCard {
card_id: number // 卡 ID
iccid: string // ICCID
msisdn: string // 手机号
network_status: NetworkStatus // 网络状态
real_name_status: RealNameStatus // 实名状态
slot_position: number // 插槽位置
}
// ========== 资产实时状态响应 ==========
/**
* 资产实时状态响应
* 对应接口GET /api/admin/assets/:asset_type/:id/realtime-status
*/
export interface AssetRealtimeStatusResponse {
asset_type: AssetType // 资产类型
asset_id: number // 资产 ID
// ===== 卡专属字段 =====
network_status?: NetworkStatus // 网络状态(仅 card
real_name_status?: RealNameStatus // 实名状态(仅 card
current_month_usage_mb?: number // 本月已用流量 MB仅 card
last_sync_time?: string // 最后同步时间(仅 card
// ===== 设备专属字段 =====
device_protect_status?: DeviceProtectStatus // 保护期(仅 device
cards?: AssetBoundCard[] // 所有绑定卡的状态(仅 device
}
/**
* 资产刷新响应(结构与 realtime-status 完全相同)
* 对应接口POST /api/admin/assets/:asset_type/:id/refresh
*/
export type AssetRefreshResponse = AssetRealtimeStatusResponse
// ========== 资产套餐查询响应 ==========
/**
* 资产套餐使用记录
* 对应接口GET /api/admin/assets/:asset_type/:id/packages
*/
export interface AssetPackageUsageRecord {
package_usage_id?: number // 套餐使用记录 ID
package_id?: number // 套餐 ID
package_name?: string // 套餐名称
package_type?: PackageType // formal正式套餐/ addon加油包
usage_type?: UsageType // 使用类型single_card/device
status?: PackageUsageStatus // 0 待生效 / 1 生效中 / 2 已用完 / 3 已过期 / 4 已失效
status_name?: string // 状态中文名
data_limit_mb?: number // 真流量总量 MB
virtual_limit_mb?: number // 虚流量总量 MB已按 virtual_ratio 换算)
data_usage_mb?: number // 已用真流量 MB
virtual_used_mb?: number // 已用虚流量 MB
virtual_remain_mb?: number // 剩余虚流量 MB
virtual_ratio?: number // 虚流量比例real/virtual
activated_at?: string // 激活时间
expires_at?: string // 到期时间
master_usage_id?: number | null // 主套餐 ID加油包时有值
priority?: number // 优先级
created_at?: string // 创建时间
}
/**
* 当前套餐响应(结构同套餐使用记录单项)
* 对应接口GET /api/admin/assets/:asset_type/:id/current-package
*/
export type AssetCurrentPackageResponse = AssetPackageUsageRecord
// ========== 设备停复机响应 ==========
/**
* 设备批量停机响应
* 对应接口POST /api/admin/assets/device/:device_id/stop
*/
export interface DeviceStopResponse {
message: string // 操作结果描述
success_count: number // 成功停机的卡数量
failed_cards: DeviceStopFailedCard[] // 停机失败列表
}
/**
* 停机失败的卡信息
*/
export interface DeviceStopFailedCard {
iccid: string // ICCID
reason: string // 失败原因
}
/**
* 设备批量复机响应HTTP 200 即成功,无 body
* 对应接口POST /api/admin/assets/device/:device_id/start
*/
export type DeviceStartResponse = void
/**
* 单卡停机响应HTTP 200 即成功,无 body
* 对应接口POST /api/admin/assets/card/:iccid/stop
*/
export type CardStopResponse = void
/**
* 单卡复机响应HTTP 200 即成功,无 body
* 对应接口POST /api/admin/assets/card/:iccid/start
*/
export type CardStartResponse = void
// ========== 钱包流水响应 ==========
/**
* 交易类型
*/
export type TransactionType = 'recharge' | 'deduct' | 'refund'
/**
* 关联业务类型
*/
export type ReferenceType = 'recharge' | 'order'
/**
* 钱包流水单项
*/
export interface AssetWalletTransactionItem {
id?: number // 流水记录ID
transaction_type?: TransactionType // 交易类型recharge/deduct/refund
transaction_type_text?: string // 交易类型文本:充值/扣款/退款
amount?: number // 变动金额(分),充值为正数,扣款/退款为负数
balance_before?: number // 变动前余额(分)
balance_after?: number // 变动后余额(分)
reference_type?: ReferenceType | null // 关联业务类型recharge 或 order可空
reference_no?: string | null // 关联业务编号充值单号CRCH…或订单号ORD…可空
remark?: string | null // 备注(可空)
created_at?: string // 流水创建时间RFC3339
}
/**
* 钱包流水列表响应
* 对应接口GET /api/admin/assets/:asset_type/:id/wallet/transactions
*/
export interface AssetWalletTransactionListResponse {
list?: AssetWalletTransactionItem[] | null // 流水列表
page?: number // 当前页码
page_size?: number // 每页数量
total?: number // 总记录数
total_pages?: number // 总页数
}
/**
* 钱包流水查询参数
*/
export interface AssetWalletTransactionParams {
page?: number // 页码默认1
page_size?: number // 每页数量默认20最大100
transaction_type?: TransactionType | null // 交易类型过滤recharge/deduct/refund
start_time?: string | null // 开始时间RFC3339
end_time?: string | null // 结束时间RFC3339
}
// ========== 钱包概况响应 ==========
/**
* 资产钱包概况响应
* 对应接口GET /api/admin/assets/:asset_type/:id/wallet
*/
export interface AssetWalletResponse {
wallet_id?: number // 钱包数据库ID
resource_id?: number // 对应卡或设备的数据库ID
resource_type?: string // 资源类型iot_card 或 device
balance?: number // 总余额(分)
frozen_balance?: number // 冻结余额(分)
available_balance?: number // 可用余额 = balance - frozen_balance
currency?: string // 币种,目前固定 CNY
status?: number // 钱包状态1-正常 2-冻结 3-关闭
status_text?: string // 状态文本
created_at?: string // 创建时间RFC3339
updated_at?: string // 更新时间RFC3339
}

View File

@@ -312,6 +312,7 @@ export interface StandaloneCardQueryParams extends PaginationParams {
shop_id?: number // 分销商ID
iccid?: string // ICCID(模糊查询)
msisdn?: string // 卡接入号(模糊查询)
virtual_no?: string // 虚拟号(模糊查询)
batch_no?: string // 批次号
package_id?: number // 套餐ID
is_distributed?: boolean // 是否已分销
@@ -327,6 +328,7 @@ export interface StandaloneIotCard {
iccid: string // ICCID
imsi?: string // IMSI (可选)
msisdn?: string // 卡接入号 (可选)
virtual_no?: string // 虚拟号(可空)
carrier_id: number // 运营商ID
carrier_type: string // 运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)
carrier_name: string // 运营商名称
@@ -465,6 +467,7 @@ export interface IotCardDetailResponse {
iccid: string // ICCID
imsi: string // IMSI
msisdn: string // 卡接入号
virtual_no?: string // 虚拟号(可空)
carrier_id: number // 运营商ID
carrier_name: string // 运营商名称
carrier_type: string // 运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)

View File

@@ -184,7 +184,7 @@ export interface ShopCommissionRecordItem {
order_no?: string // 订单号
order_created_at?: string // 订单创建时间
iccid?: string // ICCID
device_no?: string // 设备号
virtual_no?: string // 虚拟号(原 device_no
created_at: string // 佣金入账时间
}

View File

@@ -19,7 +19,7 @@ export enum DeviceStatus {
// 设备信息
export interface Device {
id: number // 设备ID
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
device_name: string // 设备名称
device_model: string // 设备型号
device_type: string // 设备类型
@@ -39,7 +39,7 @@ export interface Device {
// 设备查询参数
export interface DeviceQueryParams extends PaginationParams {
device_no?: string // 设备号(模糊查询)
virtual_no?: string // 虚拟号(模糊查询,原 device_no)
device_name?: string // 设备名称(模糊查询)
status?: DeviceStatus // 状态
shop_id?: number | null // 店铺ID (NULL表示平台库存)
@@ -107,7 +107,7 @@ export interface AllocateDevicesRequest {
// 分配失败项
export interface AllocationDeviceFailedItem {
device_id: number // 设备ID
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
reason: string // 失败原因
}
@@ -194,7 +194,7 @@ export interface DeviceImportTaskListResponse {
// 导入结果详细项
export interface DeviceImportResultItem {
line: number // 行号
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
reason: string // 原因
}
@@ -215,7 +215,7 @@ export interface BatchSetDeviceSeriesBindingRequest {
// 设备套餐系列绑定失败项
export interface DeviceSeriesBindingFailedItem {
device_id: number // 设备ID
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
reason: string // 失败原因
}

View File

@@ -18,8 +18,8 @@ export interface FailedItem {
export interface AllocatedDevice {
/** 设备ID */
device_id: number
/** 设备号 */
device_no: string
/** 虚拟号(原 device_no */
virtual_no: string
/** 卡数量 */
card_count: number
/** 卡ICCID列表 */
@@ -92,8 +92,8 @@ export interface DeviceBundleCard {
export interface DeviceBundle {
/** 设备ID */
device_id: number
/** 设备号 */
device_no: string
/** 虚拟号(原 device_no */
virtual_no: string
/** 触发卡(用户选择的卡) */
trigger_card: DeviceBundleCard
/** 连带卡(同设备的其他卡) */
@@ -158,8 +158,8 @@ export interface EnterpriseCardItem {
package_name?: string
/** 设备ID */
device_id?: number | null
/** 设备号 */
device_no?: string
/** 虚拟号(原 device_no */
virtual_no?: string
}
/**
@@ -176,8 +176,8 @@ export interface EnterpriseCardListParams {
carrier_id?: number
/** ICCID模糊查询 */
iccid?: string
/** 设备号(模糊查询) */
device_no?: string
/** 虚拟号(模糊查询,原 device_no */
virtual_no?: string
}
/**
@@ -200,8 +200,8 @@ export interface EnterpriseCardPageResult {
export interface RecalledDevice {
/** 设备ID */
device_id: number
/** 设备号 */
device_no: string
/** 虚拟号(原 device_no */
virtual_no: string
/** 卡数量 */
card_count: number
/** 卡ICCID列表 */

View File

@@ -11,7 +11,7 @@ import { PaginationParams } from '@/types'
*/
export interface EnterpriseDeviceItem {
device_id: number // 设备ID
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
device_name: string // 设备名称
device_model: string // 设备型号
card_count: number // 绑定卡数量
@@ -22,7 +22,7 @@ export interface EnterpriseDeviceItem {
* 企业设备列表查询参数
*/
export interface EnterpriseDeviceListParams extends PaginationParams {
device_no?: string // 设备号(模糊搜索)
virtual_no?: string // 虚拟号(模糊搜索,原 device_no
}
/**
@@ -39,7 +39,7 @@ export interface EnterpriseDevicePageResult {
* 授权设备请求参数
*/
export interface AllocateDevicesRequest {
device_nos: string[] | null // 设备号列表最多100个
virtual_nos: string[] | null // 虚拟号列表最多100个,原 device_nos
remark?: string // 授权备注
}
@@ -48,7 +48,7 @@ export interface AllocateDevicesRequest {
*/
export interface AuthorizedDeviceItem {
device_id: number // 设备ID
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
card_count: number // 绑定卡数量
}
@@ -56,7 +56,7 @@ export interface AuthorizedDeviceItem {
* 失败设备项
*/
export interface FailedDeviceItem {
device_no: string // 设备号
virtual_no: string // 虚拟号(原 device_no
reason: string // 失败原因
}
@@ -76,7 +76,7 @@ export interface AllocateDevicesResponse {
* 撤销设备授权请求参数
*/
export interface RecallDevicesRequest {
device_nos: string[] | null // 设备号列表最多100个
virtual_nos: string[] | null // 虚拟号列表最多100个,原 device_nos
}
/**

View File

@@ -76,3 +76,6 @@ export * from './carrier'
// 订单相关
export * from './order'
// 资产管理相关
export * from './asset'

View File

@@ -112,6 +112,7 @@ export interface PackageResponse {
data_reset_cycle?: string // 流量重置周期 (daily:每日, monthly:每月, yearly:每年, none:不重置)
real_data_mb?: number // 真流量额度MB
virtual_data_mb?: number // 虚流量额度MB
virtual_ratio?: number // 虚流量比例real_data_mb / virtual_data_mb。启用虚流量时计算否则为 1.0
enable_virtual_data?: boolean // 是否启用虚流量
enable_realname_activation?: boolean // 是否启用实名激活 (true:需实名后激活, false:立即激活)
cost_price?: number // 成本价(分)