From c35542f91106a833abbd0725c0aa3df25c56eae5 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 14 Apr 2026 11:19:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=A8=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E8=AE=A2=E5=8D=95=E5=92=8C=E8=B5=84=E4=BA=A7=20DTO=20?= =?UTF-8?q?=5Fname=20=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/admin-openapi.yaml | 83 ++++++++++++++++++------ internal/handler/app/client_asset.go | 74 +++++++++++---------- internal/model/dto/client_order_dto.go | 44 +++++++------ internal/service/client_order/service.go | 58 +++++++++++------ pkg/openapi/generator.go | 1 - pkg/utils/excel.go | 1 - 6 files changed, 164 insertions(+), 97 deletions(-) diff --git a/docs/admin-openapi.yaml b/docs/admin-openapi.yaml index 23e86fc..b707bfb 100644 --- a/docs/admin-openapi.yaml +++ b/docs/admin-openapi.yaml @@ -76,6 +76,9 @@ components: status: description: 状态 (0:禁用, 1:启用) type: integer + status_name: + description: 状态名称(中文) + type: string updated_at: description: 更新时间 type: string @@ -604,6 +607,9 @@ components: activation_status: description: 激活状态(0:未激活, 1:已激活) type: integer + activation_status_name: + description: 激活状态名称(中文) + type: string asset_id: description: 资产ID minimum: 0 @@ -625,6 +631,9 @@ components: bound_device_no: description: 绑定的设备虚拟号 type: string + bound_phone: + description: 当前登录用户绑定的手机号 + type: string card_category: description: 卡业务类型(normal:普通卡, industry:行业卡) type: string @@ -684,6 +693,9 @@ components: network_status: description: 网络状态(0:停机, 1:开机) type: integer + network_status_name: + description: 网络状态名称(中文) + type: string package_remain_mb: description: 当前剩余虚流量(MB),已按虚流量比例换算 type: number @@ -696,12 +708,18 @@ components: real_name_status: description: 实名状态(0:未实名, 1:已实名) type: integer + real_name_status_name: + description: 实名状态名称(中文) + type: string sn: description: 设备序列号 type: string status: description: 状态(1:在库, 2:已分销, 3:已激活, 4:已停用) type: integer + status_name: + description: 状态名称(中文) + type: string virtual_no: description: 虚拟号 type: string @@ -948,9 +966,6 @@ components: type: object DtoAssetResolveResponse: properties: - accumulated_recharge: - description: 累计充值金额(分) - type: integer activated_at: description: 激活时间 format: date-time @@ -1023,9 +1038,6 @@ components: enable_polling: description: 是否参与轮询 type: boolean - first_commission_paid: - description: 一次性佣金是否已发放 - type: boolean iccid: description: 卡ICCID(asset_type=card时有效) type: string @@ -1103,8 +1115,11 @@ components: description: 固件版本号(设备类型时有效) type: string status: - description: 资产状态 + description: 资产状态 (1:在库, 2:已分销, 3:已激活, 4:已停用) type: integer + status_name: + description: 资产状态名称(中文) + type: string supplier: description: 供应商 type: string @@ -1807,6 +1822,9 @@ components: payment_status: description: 支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款) type: integer + payment_status_name: + description: 支付状态名称(中文) + type: string total_amount: description: 订单总金额(分) type: integer @@ -1826,6 +1844,9 @@ components: payment_status: description: 支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款) type: integer + payment_status_name: + description: 支付状态名称(中文) + type: string total_amount: description: 订单总金额(分) type: integer @@ -1851,6 +1872,9 @@ components: payment_status: description: 支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款) type: integer + payment_status_name: + description: 支付状态名称(中文) + type: string total_amount: description: 订单总金额(分) type: integer @@ -2005,6 +2029,9 @@ components: status: description: 状态 (0:待支付, 1:已支付, 2:已关闭) type: integer + status_name: + description: 状态名称(中文) + type: string type: object DtoClientRechargeListItem: properties: @@ -3160,6 +3187,9 @@ components: status: description: 卡状态 (1:在库, 2:已分销, 3:已激活, 4:已停用) type: integer + status_name: + description: 卡状态名称(中文) + type: string type: object DtoDeviceCardItem: properties: @@ -3656,9 +3686,6 @@ components: type: object DtoDeviceResponse: properties: - accumulated_recharge: - description: 累计充值金额(分) - type: integer activated_at: description: 激活时间 format: date-time @@ -3683,9 +3710,6 @@ components: device_type: description: 设备类型 type: string - first_commission_paid: - description: 一次性佣金是否已发放 - type: boolean id: description: 设备ID minimum: 0 @@ -4911,6 +4935,9 @@ components: commission_status: description: 佣金状态 (1:待计算, 2:已计算) type: integer + commission_status_name: + description: 佣金状态名称(中文) + type: string created_at: description: 创建时间 format: date-time @@ -5085,9 +5112,15 @@ components: shelf_status: description: 上架状态 (1:上架, 2:下架) type: integer + shelf_status_name: + description: 上架状态名称(中文) + type: string status: description: 状态 (0:禁用, 1:启用) type: integer + status_name: + description: 状态名称(中文) + type: string suggested_retail_price: description: 建议售价(分) type: integer @@ -5965,6 +5998,9 @@ components: status: description: 状态 (1:待审批, 2:已通过, 3:已拒绝, 4:已退回) type: integer + status_name: + description: 状态名称(中文) + type: string updated_at: description: 更新时间 type: string @@ -6349,6 +6385,9 @@ components: status: description: 状态 (0:禁用, 1:启用) type: integer + status_name: + description: 状态名称(中文) + type: string updated_at: description: 更新时间 type: string @@ -6648,9 +6687,6 @@ components: type: object DtoStandaloneIotCardResponse: properties: - accumulated_recharge: - description: 累计充值金额(分) - type: integer activated_at: description: 激活时间 format: date-time @@ -6659,6 +6695,9 @@ components: activation_status: description: 激活状态 (0:未激活, 1:已激活) type: integer + activation_status_name: + description: 激活状态名称(中文) + type: string batch_no: description: 批次号 type: string @@ -6696,9 +6735,6 @@ components: enable_polling: description: 是否参与轮询 type: boolean - first_commission_paid: - description: 一次性佣金是否已发放 - type: boolean iccid: description: ICCID type: string @@ -6728,9 +6764,15 @@ components: network_status: description: 网络状态 (0:停机, 1:开机) type: integer + network_status_name: + description: 网络状态名称(中文) + type: string real_name_status: description: 实名状态 (0:未实名, 1:已实名) type: integer + real_name_status_name: + description: 实名状态名称(中文) + type: string series_id: description: 套餐系列ID minimum: 0 @@ -6750,6 +6792,9 @@ components: status: description: 状态 (1:在库, 2:已分销, 3:已激活, 4:已停用) type: integer + status_name: + description: 状态名称(中文) + type: string supplier: description: 供应商 type: string diff --git a/internal/handler/app/client_asset.go b/internal/handler/app/client_asset.go index c0a88a7..232c577 100644 --- a/internal/handler/app/client_asset.go +++ b/internal/handler/app/client_asset.go @@ -151,41 +151,45 @@ func (h *ClientAssetHandler) GetAssetInfo(c *fiber.Ctx) error { phone, _ := middleware.GetCustomerPhone(c) resp := &dto.AssetInfoResponse{ - BoundPhone: phone, - AssetType: resolved.Asset.AssetType, - AssetID: resolved.Asset.AssetID, - Identifier: resolved.Identifier, - VirtualNo: resolved.Asset.VirtualNo, - Status: resolved.Asset.Status, - RealNameStatus: resolved.Asset.RealNameStatus, - CarrierName: resolved.Asset.CarrierName, - Generation: strconv.Itoa(resolved.Generation), - WalletBalance: resolved.WalletBalance, - ActivatedAt: resolved.Asset.ActivatedAt, - CurrentPackage: resolved.Asset.CurrentPackage, - PackageTotalMB: resolved.Asset.PackageTotalMB, - PackageUsedMB: resolved.Asset.PackageUsedMB, - PackageRemainMB: resolved.Asset.PackageRemainMB, - DeviceName: resolved.Asset.DeviceName, - IMEI: resolved.Asset.IMEI, - SN: resolved.Asset.SN, - DeviceModel: resolved.Asset.DeviceModel, - DeviceType: resolved.Asset.DeviceType, - Manufacturer: resolved.Asset.Manufacturer, - MaxSimSlots: resolved.Asset.MaxSimSlots, - BoundCardCount: resolved.Asset.BoundCardCount, - Cards: resolved.Asset.Cards, - DeviceProtectStatus: resolved.Asset.DeviceProtectStatus, - ICCID: resolved.Asset.ICCID, - MSISDN: resolved.Asset.MSISDN, - CarrierID: resolved.Asset.CarrierID, - CarrierType: resolved.Asset.CarrierType, - NetworkStatus: resolved.Asset.NetworkStatus, - ActivationStatus: resolved.Asset.ActivationStatus, - CardCategory: resolved.Asset.CardCategory, - BoundDeviceID: resolved.Asset.BoundDeviceID, - BoundDeviceNo: resolved.Asset.BoundDeviceNo, - BoundDeviceName: resolved.Asset.BoundDeviceName, + BoundPhone: phone, + AssetType: resolved.Asset.AssetType, + AssetID: resolved.Asset.AssetID, + Identifier: resolved.Identifier, + VirtualNo: resolved.Asset.VirtualNo, + Status: resolved.Asset.Status, + StatusName: resolved.Asset.StatusName, + RealNameStatus: resolved.Asset.RealNameStatus, + RealNameStatusName: constants.GetRealNameStatusName(resolved.Asset.RealNameStatus), + CarrierName: resolved.Asset.CarrierName, + Generation: strconv.Itoa(resolved.Generation), + WalletBalance: resolved.WalletBalance, + ActivatedAt: resolved.Asset.ActivatedAt, + CurrentPackage: resolved.Asset.CurrentPackage, + PackageTotalMB: resolved.Asset.PackageTotalMB, + PackageUsedMB: resolved.Asset.PackageUsedMB, + PackageRemainMB: resolved.Asset.PackageRemainMB, + DeviceName: resolved.Asset.DeviceName, + IMEI: resolved.Asset.IMEI, + SN: resolved.Asset.SN, + DeviceModel: resolved.Asset.DeviceModel, + DeviceType: resolved.Asset.DeviceType, + Manufacturer: resolved.Asset.Manufacturer, + MaxSimSlots: resolved.Asset.MaxSimSlots, + BoundCardCount: resolved.Asset.BoundCardCount, + Cards: resolved.Asset.Cards, + DeviceProtectStatus: resolved.Asset.DeviceProtectStatus, + ICCID: resolved.Asset.ICCID, + MSISDN: resolved.Asset.MSISDN, + CarrierID: resolved.Asset.CarrierID, + CarrierType: resolved.Asset.CarrierType, + NetworkStatus: resolved.Asset.NetworkStatus, + NetworkStatusName: constants.GetNetworkStatusName(resolved.Asset.NetworkStatus), + ActivationStatus: resolved.Asset.ActivationStatus, + ActivationStatusName: constants.GetActivationStatusName(resolved.Asset.ActivationStatus), + CardCategory: resolved.Asset.CardCategory, + BoundDeviceID: resolved.Asset.BoundDeviceID, + BoundDeviceNo: resolved.Asset.BoundDeviceNo, + BoundDeviceName: resolved.Asset.BoundDeviceName, } // 调用服务层获取设备实时 Gateway 数据(per D-11) diff --git a/internal/model/dto/client_order_dto.go b/internal/model/dto/client_order_dto.go index f0c4585..c8e2123 100644 --- a/internal/model/dto/client_order_dto.go +++ b/internal/model/dto/client_order_dto.go @@ -23,11 +23,12 @@ type ClientCreateOrderResponse struct { // ClientOrderInfo D1 套餐订单信息 type ClientOrderInfo struct { - OrderID uint `json:"order_id" description:"订单ID"` - OrderNo string `json:"order_no" description:"订单号"` - TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` - PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` - CreatedAt string `json:"created_at" description:"创建时间"` + OrderID uint `json:"order_id" description:"订单ID"` + OrderNo string `json:"order_no" description:"订单号"` + TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` + PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` + PaymentStatusName string `json:"payment_status_name" description:"支付状态名称(中文)"` + CreatedAt string `json:"created_at" description:"创建时间"` } // ClientRechargeInfo D1 充值订单信息 @@ -36,6 +37,7 @@ type ClientRechargeInfo struct { RechargeNo string `json:"recharge_no" description:"充值单号"` Amount int64 `json:"amount" description:"充值金额(分)"` Status int `json:"status" description:"状态 (0:待支付, 1:已支付, 2:已关闭)"` + StatusName string `json:"status_name" description:"状态名称(中文)"` AutoPurchaseStatus string `json:"auto_purchase_status" description:"自动购包状态"` } @@ -71,12 +73,13 @@ type ClientOrderListRequest struct { // ClientOrderListItem D2 客户端订单列表项 type ClientOrderListItem struct { - OrderID uint `json:"order_id" description:"订单ID"` - OrderNo string `json:"order_no" description:"订单号"` - TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` - PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` - CreatedAt string `json:"created_at" description:"创建时间"` - PackageNames []string `json:"package_names" description:"套餐名称列表"` + OrderID uint `json:"order_id" description:"订单ID"` + OrderNo string `json:"order_no" description:"订单号"` + TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` + PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` + PaymentStatusName string `json:"payment_status_name" description:"支付状态名称(中文)"` + CreatedAt string `json:"created_at" description:"创建时间"` + PackageNames []string `json:"package_names" description:"套餐名称列表"` } // ClientOrderListResponse D2 客户端订单列表响应 @@ -93,15 +96,16 @@ type ClientOrderListResponse struct { // ClientOrderDetailResponse D3 客户端订单详情响应 type ClientOrderDetailResponse struct { - OrderID uint `json:"order_id" description:"订单ID"` - OrderNo string `json:"order_no" description:"订单号"` - TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` - PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` - PaymentMethod string `json:"payment_method" description:"支付方式"` - CreatedAt string `json:"created_at" description:"创建时间"` - PaidAt *string `json:"paid_at,omitempty" description:"支付时间"` - CompletedAt *string `json:"completed_at,omitempty" description:"完成时间"` - Packages []ClientOrderPackageItem `json:"packages" description:"订单套餐列表"` + OrderID uint `json:"order_id" description:"订单ID"` + OrderNo string `json:"order_no" description:"订单号"` + TotalAmount int64 `json:"total_amount" description:"订单总金额(分)"` + PaymentStatus int `json:"payment_status" description:"支付状态 (1:待支付, 2:已支付, 3:已取消, 4:已退款)"` + PaymentStatusName string `json:"payment_status_name" description:"支付状态名称(中文)"` + PaymentMethod string `json:"payment_method" description:"支付方式"` + CreatedAt string `json:"created_at" description:"创建时间"` + PaidAt *string `json:"paid_at,omitempty" description:"支付时间"` + CompletedAt *string `json:"completed_at,omitempty" description:"完成时间"` + Packages []ClientOrderPackageItem `json:"packages" description:"订单套餐列表"` } // ClientOrderPackageItem D3 订单套餐项 diff --git a/internal/service/client_order/service.go b/internal/service/client_order/service.go index aa7a22d..0e5ebe9 100644 --- a/internal/service/client_order/service.go +++ b/internal/service/client_order/service.go @@ -323,11 +323,12 @@ func (s *Service) createPackageOrder( return &dto.ClientCreateOrderResponse{ OrderType: "package", Order: &dto.ClientOrderInfo{ - OrderID: order.ID, - OrderNo: order.OrderNo, - TotalAmount: order.TotalAmount, - PaymentStatus: order.PaymentStatus, - CreatedAt: formatClientServiceTime(order.CreatedAt), + OrderID: order.ID, + OrderNo: order.OrderNo, + TotalAmount: order.TotalAmount, + PaymentStatus: order.PaymentStatus, + PaymentStatusName: constants.GetOrderPaymentStatusName(order.PaymentStatus), + CreatedAt: formatClientServiceTime(order.CreatedAt), }, }, nil } @@ -394,13 +395,15 @@ func (s *Service) createForceRechargeOrder( s.markClientPurchaseCreated(ctx, redisKey, recharge.RechargeNo) *created = true + clientStatus := rechargeStatusToClientStatus(recharge.Status) return &dto.ClientCreateOrderResponse{ OrderType: "recharge", Recharge: &dto.ClientRechargeInfo{ RechargeID: recharge.ID, RechargeNo: recharge.RechargeNo, Amount: recharge.Amount, - Status: rechargeStatusToClientStatus(recharge.Status), + Status: clientStatus, + StatusName: clientRechargeStatusName(clientStatus), AutoPurchaseStatus: recharge.AutoPurchaseStatus, }, PayConfig: buildClientPayConfigFromResult(paymentResult), @@ -709,6 +712,17 @@ func rechargeStatusToClientStatus(status int) int { } } +func clientRechargeStatusName(clientStatus int) string { + switch clientStatus { + case 0: + return "待支付" + case 1: + return "已支付" + default: + return "已关闭" + } +} + func formatClientServiceTime(t time.Time) string { if t.IsZero() { return "" @@ -789,12 +803,13 @@ func (s *Service) ListOrders(ctx context.Context, customerID uint, req *dto.Clie } list = append(list, dto.ClientOrderListItem{ - OrderID: order.ID, - OrderNo: order.OrderNo, - TotalAmount: order.TotalAmount, - PaymentStatus: order.PaymentStatus, - CreatedAt: formatClientServiceTime(order.CreatedAt), - PackageNames: packageNames, + OrderID: order.ID, + OrderNo: order.OrderNo, + TotalAmount: order.TotalAmount, + PaymentStatus: order.PaymentStatus, + PaymentStatusName: constants.GetOrderPaymentStatusName(order.PaymentStatus), + CreatedAt: formatClientServiceTime(order.CreatedAt), + PackageNames: packageNames, }) } @@ -835,15 +850,16 @@ func (s *Service) GetOrderDetail(ctx context.Context, customerID uint, orderID u } return &dto.ClientOrderDetailResponse{ - OrderID: order.ID, - OrderNo: order.OrderNo, - TotalAmount: order.TotalAmount, - PaymentStatus: order.PaymentStatus, - PaymentMethod: order.PaymentMethod, - CreatedAt: formatClientServiceTime(order.CreatedAt), - PaidAt: formatClientServiceTimePtr(order.PaidAt), - CompletedAt: nil, - Packages: packages, + OrderID: order.ID, + OrderNo: order.OrderNo, + TotalAmount: order.TotalAmount, + PaymentStatus: order.PaymentStatus, + PaymentStatusName: constants.GetOrderPaymentStatusName(order.PaymentStatus), + PaymentMethod: order.PaymentMethod, + CreatedAt: formatClientServiceTime(order.CreatedAt), + PaidAt: formatClientServiceTimePtr(order.PaidAt), + CompletedAt: nil, + Packages: packages, }, nil } diff --git a/pkg/openapi/generator.go b/pkg/openapi/generator.go index b787e26..f3ea5f8 100644 --- a/pkg/openapi/generator.go +++ b/pkg/openapi/generator.go @@ -138,7 +138,6 @@ func (g *Generator) AddOperation(method, path, summary, description string, inpu } } - // u663eu5f0fu4f20u5165u7684 JSON bodyuff0cu7528u4e8e DELETE u7b49u65b9u6cd5u4e0du81eau52a8u751fu6210 requestBody u7684u573au666f if body != nil { tempOp := openapi3.Operation{} diff --git a/pkg/utils/excel.go b/pkg/utils/excel.go index 7a6a323..3c0c720 100644 --- a/pkg/utils/excel.go +++ b/pkg/utils/excel.go @@ -278,4 +278,3 @@ func parseCardRows(rows [][]string) (*CSVParseResult, error) { return result, nil } -