151 lines
9.6 KiB
Go
151 lines
9.6 KiB
Go
package bus_models
|
||
|
||
import "go-admin/app/admin/models"
|
||
|
||
type BusCooperative struct {
|
||
models.Model
|
||
|
||
CooperativeNumber string `gorm:"type:varchar(32);not null" json:"cooperative_number"` // 合作商编号
|
||
CooperativeName string `gorm:"type:varchar(64);not null" json:"cooperative_name"` // 合作商名称
|
||
Contact string `gorm:"type:varchar(32);not null" json:"contact"` // 联系人
|
||
Tel string `gorm:"type:varchar(20);not null" json:"tel"` // 手机号
|
||
Status uint8 `gorm:"type:tinyint(1);not null;default:1" json:"status"` // 账户状态(1启用 2禁用)
|
||
Account string `gorm:"type:varchar(32);not null;unique" json:"account"` // 账户
|
||
Password string `gorm:"type:varchar(64);not null" json:"password"` // 密码(建议存储加密哈希值)
|
||
Balance float64 `gorm:"type:decimal(10,3);not null;default:0.000" json:"balance"` // 账户余额
|
||
Free float64 `gorm:"type:decimal(10,2);not null;default:0.00" json:"free"` // 赠送余额
|
||
Bond float64 `gorm:"type:decimal(10,2);not null;default:0.00" json:"bond"` // 保证金
|
||
CardHolder string `gorm:"type:varchar(32)" json:"card_holder,omitempty"` // 开户人
|
||
Bank string `gorm:"type:varchar(64)" json:"bank,omitempty"` // 开户行
|
||
CardID string `gorm:"type:varchar(32)" json:"card_id,omitempty"` // 银行帐号
|
||
TaxID string `gorm:"type:varchar(32)" json:"tax_id,omitempty"` // 税号
|
||
UserId int `gorm:"type:int;not null" json:"userId"` // 用户ID(重置密码时需要)
|
||
Products []ProductDetail `json:"products" gorm:"-"` // 产品信息
|
||
}
|
||
|
||
// BusCooperativeProduct 合作商与产品关联表
|
||
type BusCooperativeProduct struct {
|
||
models.Model
|
||
|
||
CooperativeID uint64 `gorm:"not null" json:"cooperative_id"` // 合作商编号
|
||
ProductID uint64 `gorm:"not null" json:"product_id"` // 产品ID
|
||
Discount float64 `gorm:"type:decimal(5,2);not null;default:0.00" json:"discount"` // 折扣(0-1)
|
||
}
|
||
|
||
// CooperativeListReq 查询合作商列表请求
|
||
type CooperativeListReq struct {
|
||
CooperativeNumber string `json:"cooperative_number,omitempty"` // 合作商编号(可选)
|
||
CooperativeName string `json:"cooperative_name,omitempty"` // 合作商名称(支持模糊查询)
|
||
Status uint8 `json:"status,omitempty"` // 账户状态(1启用 2禁用)
|
||
Page int `json:"page" binding:"required,min=1"` // 页码
|
||
PageSize int `json:"page_size" binding:"required,min=1,max=100"` // 每页条数
|
||
}
|
||
|
||
// CooperativeListResp 查询合作商列表响应
|
||
type CooperativeListResp struct {
|
||
List []BusCooperative `json:"list"` // 合作商列表
|
||
Total int `json:"total"` // 总记录数
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页大小
|
||
}
|
||
|
||
// CreateCooperativeReq 创建合作商请求
|
||
type CreateCooperativeReq struct {
|
||
CooperativeName string `json:"cooperative_name" binding:"required"` // 合作商名称
|
||
Contact string `json:"contact" binding:"required"` // 联系人
|
||
Tel string `json:"tel" binding:"required"` // 手机号
|
||
Account string `json:"account" binding:"required"` // 账户
|
||
Password string `json:"password" binding:"required"` // 密码(前端传输时应加密)
|
||
Balance float64 `json:"balance,omitempty"` // 账户余额(可选)
|
||
Free float64 `json:"free,omitempty"` // 赠送余额(可选)
|
||
Bond float64 `json:"bond,omitempty"` // 保证金(可选)
|
||
CardHolder string `json:"card_holder,omitempty"` // 开户人(可选)
|
||
Bank string `json:"bank,omitempty"` // 开户行(可选)
|
||
CardID string `json:"card_id,omitempty"` // 银行帐号(可选)
|
||
TaxID string `json:"tax_id,omitempty"` // 税号(可选)
|
||
Products []ProductDetail `json:"products"` // 关联产品及折扣信息
|
||
}
|
||
|
||
// ProductDiscount 结构体用于存储产品ID及对应折扣
|
||
type ProductDiscount struct {
|
||
ProductID uint64 `json:"product_id" binding:"required"` // 产品ID
|
||
Discount float64 `json:"discount" binding:"required"` // 折扣(0-1之间)
|
||
}
|
||
|
||
// CreateCooperativeResp 创建合作商响应
|
||
type CreateCooperativeResp struct {
|
||
CooperativeNumber string `form:"cooperative_number"` // 合作商编号
|
||
}
|
||
|
||
// EditCooperativeReq 编辑合作商请求
|
||
type EditCooperativeReq struct {
|
||
CooperativeNumber string `json:"cooperative_number,required"` // 合作商编号
|
||
CooperativeName string `json:"cooperative_name,omitempty"` // 合作商名称(可选)
|
||
Contact string `json:"contact,omitempty"` // 联系人(可选)
|
||
Tel string `json:"tel,omitempty"` // 手机号(可选)
|
||
Status uint8 `json:"status,omitempty"` // 账户状态(可选)
|
||
Account string `json:"account,omitempty"` // 账户(可选)
|
||
Password string `json:"password,omitempty"` // 密码(可选,前端加密传输)
|
||
Balance float64 `json:"balance,omitempty"` // 账户余额(可选)
|
||
Free float64 `json:"free,omitempty"` // 赠送余额(可选)
|
||
Bond float64 `json:"bond,omitempty"` // 保证金(可选)
|
||
CardHolder string `json:"card_holder,omitempty"` // 开户人(可选)
|
||
Bank string `json:"bank,omitempty"` // 开户行(可选)
|
||
CardID string `json:"card_id,omitempty"` // 银行帐号(可选)
|
||
TaxID string `json:"tax_id,omitempty"` // 税号(可选)
|
||
Products []ProductDetail `json:"products"` // 关联产品及折扣信息
|
||
}
|
||
|
||
// DeleteCooperativeReq 删除合作商请求
|
||
type DeleteCooperativeReq struct {
|
||
CooperativeNumber string `json:"cooperative_number,required"` // 合作商编号
|
||
}
|
||
|
||
// CooperativeDetailReq 查询合作商详情请求参数
|
||
type CooperativeDetailReq struct {
|
||
CooperativeNumber string `json:"cooperative_number" binding:"required"` // 合作商编号
|
||
}
|
||
|
||
// CooperativeDetailResp 查询合作商详情响应参数
|
||
type CooperativeDetailResp struct {
|
||
CooperativeNumber string `json:"cooperative_number"` // 合作商编号
|
||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||
Contact string `json:"contact"` // 联系人
|
||
Tel string `json:"tel"` // 手机号
|
||
Status uint8 `json:"status"` // 账户状态(1启用 2禁用)
|
||
Account string `json:"account"` // 账户
|
||
Password string `json:"password"` // 密码(建议存储加密哈希值)
|
||
Balance float64 `json:"balance"` // 账户余额
|
||
Free float64 `json:"free"` // 赠送余额
|
||
Bond float64 `json:"bond"` // 保证金
|
||
CardHolder string `json:"card_holder"` // 开户人
|
||
Bank string `json:"bank"` // 开户行
|
||
CardID string `json:"card_id"` // 银行帐号
|
||
TaxID string `json:"tax_id"` // 税号
|
||
Products []ProductDetail `json:"products"` // 产品信息
|
||
}
|
||
|
||
// ProductDetail 产品信息
|
||
type ProductDetail struct {
|
||
ProductID uint64 `json:"product_id"` // 产品ID
|
||
ProductCode string `json:"product_code"` // 产品编码
|
||
ProductName string `json:"product_name"` // 产品名称
|
||
Discount float64 `json:"discount"` // 折扣(0-1):给到合作商的折扣,不是产品本身的折扣
|
||
}
|
||
|
||
// AdjustAccountReq 账户调整入参
|
||
type AdjustAccountReq struct {
|
||
TransactionType uint8 `json:"transaction_type" binding:"required"` // 交易类型(1-加款, 2-减款)
|
||
CooperativeNumber string `json:"cooperative_number" binding:"required"` // 合作商编号
|
||
Amount float64 `json:"amount" binding:"required"` // 调整金额
|
||
GiftAmount float64 `json:"gift_amount,omitempty"` // 赠送金额(仅加款时有效)
|
||
SourceFundingType uint8 `json:"source_funding_type"` // 资金来源,例如 "对公转账"、"支付宝"、"微信"、"现金"等(查询字典值)
|
||
Remark string `json:"remark,omitempty"` // 备注信息,例如交易编号、支付凭证等
|
||
}
|
||
|
||
// SetCooperativeStatusReq 设置合作商状态
|
||
type SetCooperativeStatusReq struct {
|
||
CooperativeNumber string `json:"cooperative_number" binding:"required"` // 合作商编号
|
||
Status uint8 `json:"status" binding:"required,oneof=1 2"` // 状态 (1 启用, 2 禁用)
|
||
}
|