直接换货流程
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m28s

This commit is contained in:
Break
2026-06-03 16:55:32 +08:00
parent 46ede81aef
commit 5f57429fb0
13 changed files with 718 additions and 167 deletions

View File

@@ -22,7 +22,7 @@ type AssetWalletTransactionListRequest struct {
Identifier string `path:"identifier" description:"资产标识符ICCID 或 VirtualNo" required:"true"`
Page int `json:"page" query:"page" description:"页码默认1"`
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" description:"每页数量默认20最大100"`
TransactionType *string `json:"transaction_type" query:"transaction_type" validate:"omitempty,oneof=recharge deduct refund" description:"交易类型过滤recharge/deduct/refund"`
TransactionType *string `json:"transaction_type" query:"transaction_type" validate:"omitempty,oneof=recharge deduct refund exchange" description:"交易类型过滤recharge/deduct/refund/exchange"`
StartTime *time.Time `json:"start_time" query:"start_time" description:"开始时间RFC3339"`
EndTime *time.Time `json:"end_time" query:"end_time" description:"结束时间RFC3339"`
}
@@ -30,12 +30,12 @@ type AssetWalletTransactionListRequest struct {
// AssetWalletTransactionItem 单条流水记录
type AssetWalletTransactionItem struct {
ID uint `json:"id" description:"流水记录ID"`
TransactionType string `json:"transaction_type" description:"交易类型recharge/deduct/refund"`
TransactionTypeText string `json:"transaction_type_text" description:"交易类型文本:充值/扣款/退款"`
TransactionType string `json:"transaction_type" description:"交易类型recharge/deduct/refund/exchange"`
TransactionTypeText string `json:"transaction_type_text" description:"交易类型文本:充值/扣款/退款/换货迁移"`
Amount int64 `json:"amount" description:"变动金额(分),充值为正数,扣款/退款为负数"`
BalanceBefore int64 `json:"balance_before" description:"变动前余额(分)"`
BalanceAfter int64 `json:"balance_after" description:"变动后余额(分)"`
ReferenceType *string `json:"reference_type,omitempty" description:"关联业务类型rechargeorder可空"`
ReferenceType *string `json:"reference_type,omitempty" description:"关联业务类型rechargeorder 或 exchange(可空)"`
ReferenceNo *string `json:"reference_no,omitempty" description:"关联业务编号充值单号CRCH…或订单号ORD…可空"`
Remark *string `json:"remark,omitempty" description:"备注(可空)"`
CreatedAt time.Time `json:"created_at" description:"流水创建时间RFC3339"`

View File

@@ -5,6 +5,9 @@ import "time"
type CreateExchangeRequest struct {
OldAssetType string `json:"old_asset_type" validate:"required,oneof=iot_card device" required:"true" description:"旧资产类型 (iot_card:物联网卡, device:设备)"`
OldIdentifier string `json:"old_identifier" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"旧资产标识符(ICCID/虚拟号/IMEI/SN)"`
FlowType string `json:"flow_type" validate:"omitempty,oneof=shipping direct" enum:"shipping,direct" description:"换货流程类型 (shipping:物流换货, direct:直接换货)"`
NewIdentifier string `json:"new_identifier" validate:"omitempty,min=1,max=100" minLength:"1" maxLength:"100" description:"新资产标识符direct 流程必填(ICCID/虚拟号/IMEI/SN)"`
MigrateData *bool `json:"migrate_data" description:"是否执行全量迁移direct 流程未传按 false 处理"`
ExchangeReason string `json:"exchange_reason" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"换货原因"`
Remark *string `json:"remark" validate:"omitempty,max=500" maxLength:"500" description:"备注"`
}
@@ -13,6 +16,7 @@ type ExchangeListRequest struct {
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量"`
Status *int `json:"status" query:"status" validate:"omitempty,min=1,max=5" minimum:"1" maximum:"5" description:"换货状态 (1:待填写信息, 2:待发货, 3:已发货待确认, 4:已完成, 5:已取消)"`
FlowType string `json:"flow_type" query:"flow_type" validate:"omitempty,oneof=shipping direct" enum:"shipping,direct" description:"换货流程类型 (shipping:物流换货, direct:直接换货)"`
Identifier string `json:"identifier" query:"identifier" validate:"omitempty,max=100" maxLength:"100" description:"资产标识符搜索(旧资产/新资产标识符模糊匹配)"`
CreatedAtStart *time.Time `json:"created_at_start" query:"created_at_start" description:"创建时间起始"`
CreatedAtEnd *time.Time `json:"created_at_end" query:"created_at_end" description:"创建时间结束"`
@@ -61,6 +65,8 @@ type ClientShippingInfoParams struct {
type ExchangeOrderResponse struct {
ID uint `json:"id" description:"换货单ID"`
ExchangeNo string `json:"exchange_no" description:"换货单号"`
FlowType string `json:"flow_type" description:"换货流程类型 (shipping:物流换货, direct:直接换货)"`
FlowTypeName string `json:"flow_type_name" description:"换货流程类型名称"`
OldAssetType string `json:"old_asset_type" description:"旧资产类型 (iot_card:物联网卡, device:设备)"`
OldAssetID uint `json:"old_asset_id" description:"旧资产ID"`
OldAssetIdentifier string `json:"old_asset_identifier" description:"旧资产标识符"`
@@ -75,9 +81,12 @@ type ExchangeOrderResponse struct {
MigrateData bool `json:"migrate_data" description:"是否执行全量迁移"`
MigrationCompleted bool `json:"migration_completed" description:"迁移是否已完成"`
MigrationBalance int64 `json:"migration_balance" description:"迁移转移金额(分)"`
ShippedAt *time.Time `json:"shipped_at,omitempty" description:"发货时间"`
CompletedAt *time.Time `json:"completed_at,omitempty" description:"换货完成时间"`
ExchangeReason string `json:"exchange_reason" description:"换货原因"`
Remark *string `json:"remark,omitempty" description:"备注"`
Status int `json:"status" description:"换货状态 (1:待填写信息, 2:待发货, 3:已发货待确认, 4:已完成, 5:已取消)"`
StatusName string `json:"status_name" description:"换货状态名称(中文)"`
StatusText string `json:"status_text" description:"换货状态文本"`
ShopID *uint `json:"shop_id,omitempty" description:"所属店铺ID"`
CreatedAt time.Time `json:"created_at" description:"创建时间"`
@@ -97,7 +106,9 @@ type ExchangeListResponse struct {
type ClientExchangePendingResponse struct {
ID uint `json:"id" description:"换货单ID"`
ExchangeNo string `json:"exchange_no" description:"换货单号"`
FlowType string `json:"flow_type" description:"换货流程类型 (shipping:物流换货, direct:直接换货)"`
Status int `json:"status" description:"换货状态 (1:待填写信息, 2:待发货, 3:已发货待确认, 4:已完成, 5:已取消)"`
StatusName string `json:"status_name" description:"换货状态名称(中文)"`
StatusText string `json:"status_text" description:"换货状态文本"`
ExchangeReason string `json:"exchange_reason" description:"换货原因"`
CreatedAt time.Time `json:"created_at" description:"创建时间"`

View File

@@ -9,8 +9,8 @@ import (
)
// ExchangeOrder 换货单模型
// 承载客户端换货的完整生命周期:后台发起 → 客户填写收货信息 → 后台发货 → 确认完成(含可选全量迁移) → 旧资产可转新
// 状态机1-待填写信息 → 2-待发货 → 3-已发货待确认 → 4-已完成1/2 时可取消 → 5-已取消
// 承载物流换货与直接换货的完整生命周期:后台发起 → 可选客户填写收货信息 → 可选后台发货 → 确认完成(含可选全量迁移) → 旧资产可转新
// 状态机:shipping 为 1-待填写信息 → 2-待发货 → 3-已发货待确认 → 4-已完成1/2 时可取消 → 5-已取消direct 创建即完成为 4
type ExchangeOrder struct {
gorm.Model
BaseModel `gorm:"embedded"`
@@ -18,6 +18,9 @@ type ExchangeOrder struct {
// 单号
ExchangeNo string `gorm:"column:exchange_no;type:varchar(50);not null;uniqueIndex:idx_exchange_order_no,where:deleted_at IS NULL;comment:换货单号(EXC+日期+随机数)" json:"exchange_no"`
// 流程类型
FlowType string `gorm:"column:flow_type;type:varchar(20);not null;default:'shipping';index:idx_exchange_order_flow_status;comment:换货流程类型 shipping-物流换货 direct-直接换货" json:"flow_type"`
// 旧资产快照
OldAssetType string `gorm:"column:old_asset_type;type:varchar(20);not null;comment:旧资产类型(iot_card/device)" json:"old_asset_type"`
OldAssetID uint `gorm:"column:old_asset_id;not null;index:idx_exchange_order_old_asset;comment:旧资产ID" json:"old_asset_id"`
@@ -42,6 +45,10 @@ type ExchangeOrder struct {
MigrationCompleted bool `gorm:"column:migration_completed;type:boolean;default:false;comment:迁移是否已完成" json:"migration_completed"`
MigrationBalance int64 `gorm:"column:migration_balance;type:bigint;default:0;comment:迁移转移金额(分)" json:"migration_balance"`
// 业务时间
ShippedAt *time.Time `gorm:"column:shipped_at;comment:发货时间,仅物流换货发货成功后写入" json:"shipped_at,omitempty"`
CompletedAt *time.Time `gorm:"column:completed_at;comment:换货完成时间,物流换货和直接换货完成后写入" json:"completed_at,omitempty"`
// 业务信息
ExchangeReason string `gorm:"column:exchange_reason;type:varchar(100);not null;comment:换货原因" json:"exchange_reason"`
Remark *string `gorm:"column:remark;type:text;comment:备注" json:"remark,omitempty"`