- 实现 RechargeHandler 处理充值订单创建、预检、查询等接口 - 添加充值相关 DTO(CreateRechargeRequest、RechargeCheckRequest 等) - 支持充值预检(强充检查、金额限制等) - 支持充值订单列表和详情查询
113 lines
4.8 KiB
Go
113 lines
4.8 KiB
Go
package dto
|
||
|
||
import "time"
|
||
|
||
// CreateRechargeRequest 创建充值订单请求
|
||
type CreateRechargeRequest struct {
|
||
// 资源类型: iot_card-物联网卡 device-设备
|
||
ResourceType string `json:"resource_type" validate:"required,oneof=iot_card device" description:"资源类型"`
|
||
// 资源ID(卡ID或设备ID)
|
||
ResourceID uint `json:"resource_id" validate:"required,min=1" description:"资源ID"`
|
||
// 充值金额(分)
|
||
Amount int64 `json:"amount" validate:"required,min=100,max=10000000" description:"充值金额(分)"`
|
||
// 支付方式: wechat-微信 alipay-支付宝
|
||
PaymentMethod string `json:"payment_method" validate:"required,oneof=wechat alipay" description:"支付方式"`
|
||
}
|
||
|
||
// RechargeResponse 充值订单响应
|
||
type RechargeResponse struct {
|
||
// 充值订单ID
|
||
ID uint `json:"id" description:"充值订单ID"`
|
||
// 充值订单号
|
||
RechargeNo string `json:"recharge_no" description:"充值订单号"`
|
||
// 用户ID
|
||
UserID uint `json:"user_id" description:"用户ID"`
|
||
// 钱包ID
|
||
WalletID uint `json:"wallet_id" description:"钱包ID"`
|
||
// 充值金额(分)
|
||
Amount int64 `json:"amount" description:"充值金额(分)"`
|
||
// 支付方式
|
||
PaymentMethod string `json:"payment_method" description:"支付方式"`
|
||
// 支付渠道
|
||
PaymentChannel *string `json:"payment_channel,omitempty" description:"支付渠道"`
|
||
// 第三方支付交易号
|
||
PaymentTransactionID *string `json:"payment_transaction_id,omitempty" description:"第三方支付交易号"`
|
||
// 充值状态: 1-待支付 2-已支付 3-已完成 4-已关闭 5-已退款
|
||
Status int `json:"status" description:"充值状态"`
|
||
// 状态文本
|
||
StatusText string `json:"status_text" description:"状态文本"`
|
||
// 支付时间
|
||
PaidAt *time.Time `json:"paid_at,omitempty" description:"支付时间"`
|
||
// 完成时间
|
||
CompletedAt *time.Time `json:"completed_at,omitempty" description:"完成时间"`
|
||
// 创建时间
|
||
CreatedAt time.Time `json:"created_at" description:"创建时间"`
|
||
// 更新时间
|
||
UpdatedAt time.Time `json:"updated_at" description:"更新时间"`
|
||
}
|
||
|
||
// RechargeListRequest 充值订单列表请求
|
||
type RechargeListRequest struct {
|
||
// 页码(从1开始)
|
||
Page int `json:"page" form:"page" description:"页码"`
|
||
// 每页数量
|
||
PageSize int `json:"page_size" form:"page_size" description:"每页数量"`
|
||
// 钱包ID筛选
|
||
WalletID *uint `json:"wallet_id" form:"wallet_id" description:"钱包ID"`
|
||
// 状态筛选
|
||
Status *int `json:"status" form:"status" description:"状态"`
|
||
// 开始时间
|
||
StartTime *time.Time `json:"start_time" form:"start_time" description:"开始时间"`
|
||
// 结束时间
|
||
EndTime *time.Time `json:"end_time" form:"end_time" description:"结束时间"`
|
||
}
|
||
|
||
// RechargeListResponse 充值订单列表响应
|
||
type RechargeListResponse struct {
|
||
// 列表数据
|
||
List []*RechargeResponse `json:"list" description:"列表数据"`
|
||
// 总记录数
|
||
Total int64 `json:"total" description:"总记录数"`
|
||
// 当前页码
|
||
Page int `json:"page" description:"当前页码"`
|
||
// 每页数量
|
||
PageSize int `json:"page_size" description:"每页数量"`
|
||
// 总页数
|
||
TotalPages int `json:"total_pages" description:"总页数"`
|
||
}
|
||
|
||
// RechargeCheckRequest 充值预检请求
|
||
type RechargeCheckRequest struct {
|
||
// 资源类型: iot_card-物联网卡 device-设备
|
||
ResourceType string `json:"resource_type" query:"resource_type" validate:"required,oneof=iot_card device" description:"资源类型"`
|
||
// 资源ID(卡ID或设备ID)
|
||
ResourceID uint `json:"resource_id" query:"resource_id" validate:"required,min=1" description:"资源ID"`
|
||
}
|
||
|
||
// RechargeCheckResponse 充值预检响应
|
||
type RechargeCheckResponse struct {
|
||
// 是否需要强充
|
||
NeedForceRecharge bool `json:"need_force_recharge" description:"是否需要强充"`
|
||
// 强充金额(分)
|
||
ForceRechargeAmount int64 `json:"force_recharge_amount" description:"强充金额(分)"`
|
||
// 触发类型: single_recharge-单次充值 accumulated_recharge-累计充值
|
||
TriggerType string `json:"trigger_type" description:"触发类型"`
|
||
// 最小充值金额(分)
|
||
MinAmount int64 `json:"min_amount" description:"最小充值金额(分)"`
|
||
// 最大充值金额(分)
|
||
MaxAmount int64 `json:"max_amount" description:"最大充值金额(分)"`
|
||
// 当前累计充值金额(分)
|
||
CurrentAccumulated int64 `json:"current_accumulated" description:"当前累计充值金额(分)"`
|
||
// 佣金触发阈值(分)
|
||
Threshold int64 `json:"threshold" description:"佣金触发阈值(分)"`
|
||
// 提示信息
|
||
Message string `json:"message" description:"提示信息"`
|
||
// 一次性佣金是否已发放
|
||
FirstCommissionPaid bool `json:"first_commission_paid" description:"一次性佣金是否已发放"`
|
||
}
|
||
|
||
// GetRechargeRequest 获取充值订单详情请求
|
||
type GetRechargeRequest struct {
|
||
ID uint `path:"id" description:"充值订单ID" required:"true"`
|
||
}
|