feat(subscribe): add ShowOriginalPrice field and related database changes

This commit is contained in:
Tension 2025-12-28 17:08:26 +08:00
parent 31e634ba66
commit d332e760f8
9 changed files with 213 additions and 201 deletions

View File

@ -34,50 +34,52 @@ type (
Ids []int64 `json:"ids" validate:"required"` Ids []int64 `json:"ids" validate:"required"`
} }
CreateSubscribeRequest { CreateSubscribeRequest {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show *bool `json:"show"` Show *bool `json:"show"`
Sell *bool `json:"sell"` Sell *bool `json:"sell"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction *bool `json:"allow_deduction"` AllowDeduction *bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset *bool `json:"renewal_reset"` RenewalReset *bool `json:"renewal_reset"`
ShowOriginalPrice bool `json:"show_original_price"`
} }
UpdateSubscribeRequest { UpdateSubscribeRequest {
Id int64 `json:"id" validate:"required"` Id int64 `json:"id" validate:"required"`
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show *bool `json:"show"` Show *bool `json:"show"`
Sell *bool `json:"sell"` Sell *bool `json:"sell"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction *bool `json:"allow_deduction"` AllowDeduction *bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset *bool `json:"renewal_reset"` RenewalReset *bool `json:"renewal_reset"`
ShowOriginalPrice bool `json:"show_original_price"`
} }
SubscribeSortRequest { SubscribeSortRequest {
Sort []SortItem `json:"sort"` Sort []SortItem `json:"sort"`

View File

@ -66,7 +66,6 @@ type (
UnbindOAuthRequest { UnbindOAuthRequest {
Method string `json:"method"` Method string `json:"method"`
} }
GetLoginLogRequest { GetLoginLogRequest {
Page int `form:"page"` Page int `form:"page"`
Size int `form:"size"` Size int `form:"size"`

View File

@ -208,30 +208,31 @@ type (
Discount int64 `json:"discount"` Discount int64 `json:"discount"`
} }
Subscribe { Subscribe {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show bool `json:"show"` Show bool `json:"show"`
Sell bool `json:"sell"` Sell bool `json:"sell"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction bool `json:"allow_deduction"` AllowDeduction bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset bool `json:"renewal_reset"` RenewalReset bool `json:"renewal_reset"`
CreatedAt int64 `json:"created_at"` ShowOriginalPrice bool `json:"show_original_price"`
UpdatedAt int64 `json:"updated_at"` CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
} }
SubscribeGroup { SubscribeGroup {
Id int64 `json:"id"` Id int64 `json:"id"`

View File

@ -0,0 +1,2 @@
ALTER TABLE `subscribe`
DROP COLUMN `show_original_price`;

View File

@ -0,0 +1,2 @@
ALTER TABLE `subscribe`
ADD COLUMN `show_original_price` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'display the original price: 0 not display, 1 display' AFTER `created_at`;

View File

@ -35,28 +35,29 @@ func (l *CreateSubscribeLogic) CreateSubscribe(req *types.CreateSubscribeRequest
discount = string(val) discount = string(val)
} }
sub := &subscribe.Subscribe{ sub := &subscribe.Subscribe{
Id: 0, Id: 0,
Name: req.Name, Name: req.Name,
Language: req.Language, Language: req.Language,
Description: req.Description, Description: req.Description,
UnitPrice: req.UnitPrice, UnitPrice: req.UnitPrice,
UnitTime: req.UnitTime, UnitTime: req.UnitTime,
Discount: discount, Discount: discount,
Replacement: req.Replacement, Replacement: req.Replacement,
Inventory: req.Inventory, Inventory: req.Inventory,
Traffic: req.Traffic, Traffic: req.Traffic,
SpeedLimit: req.SpeedLimit, SpeedLimit: req.SpeedLimit,
DeviceLimit: req.DeviceLimit, DeviceLimit: req.DeviceLimit,
Quota: req.Quota, Quota: req.Quota,
Nodes: tool.Int64SliceToString(req.Nodes), Nodes: tool.Int64SliceToString(req.Nodes),
NodeTags: tool.StringSliceToString(req.NodeTags), NodeTags: tool.StringSliceToString(req.NodeTags),
Show: req.Show, Show: req.Show,
Sell: req.Sell, Sell: req.Sell,
Sort: 0, Sort: 0,
DeductionRatio: req.DeductionRatio, DeductionRatio: req.DeductionRatio,
AllowDeduction: req.AllowDeduction, AllowDeduction: req.AllowDeduction,
ResetCycle: req.ResetCycle, ResetCycle: req.ResetCycle,
RenewalReset: req.RenewalReset, RenewalReset: req.RenewalReset,
ShowOriginalPrice: req.ShowOriginalPrice,
} }
err := l.svcCtx.SubscribeModel.Insert(l.ctx, sub) err := l.svcCtx.SubscribeModel.Insert(l.ctx, sub)
if err != nil { if err != nil {

View File

@ -43,28 +43,29 @@ func (l *UpdateSubscribeLogic) UpdateSubscribe(req *types.UpdateSubscribeRequest
discount = string(val) discount = string(val)
} }
sub := &subscribe.Subscribe{ sub := &subscribe.Subscribe{
Id: req.Id, Id: req.Id,
Name: req.Name, Name: req.Name,
Language: req.Language, Language: req.Language,
Description: req.Description, Description: req.Description,
UnitPrice: req.UnitPrice, UnitPrice: req.UnitPrice,
UnitTime: req.UnitTime, UnitTime: req.UnitTime,
Discount: discount, Discount: discount,
Replacement: req.Replacement, Replacement: req.Replacement,
Inventory: req.Inventory, Inventory: req.Inventory,
Traffic: req.Traffic, Traffic: req.Traffic,
SpeedLimit: req.SpeedLimit, SpeedLimit: req.SpeedLimit,
DeviceLimit: req.DeviceLimit, DeviceLimit: req.DeviceLimit,
Quota: req.Quota, Quota: req.Quota,
Nodes: tool.Int64SliceToString(req.Nodes), Nodes: tool.Int64SliceToString(req.Nodes),
NodeTags: tool.StringSliceToString(req.NodeTags), NodeTags: tool.StringSliceToString(req.NodeTags),
Show: req.Show, Show: req.Show,
Sell: req.Sell, Sell: req.Sell,
Sort: req.Sort, Sort: req.Sort,
DeductionRatio: req.DeductionRatio, DeductionRatio: req.DeductionRatio,
AllowDeduction: req.AllowDeduction, AllowDeduction: req.AllowDeduction,
ResetCycle: req.ResetCycle, ResetCycle: req.ResetCycle,
RenewalReset: req.RenewalReset, RenewalReset: req.RenewalReset,
ShowOriginalPrice: req.ShowOriginalPrice,
} }
err = l.svcCtx.SubscribeModel.Update(l.ctx, sub) err = l.svcCtx.SubscribeModel.Update(l.ctx, sub)
if err != nil { if err != nil {

View File

@ -7,30 +7,31 @@ import (
) )
type Subscribe struct { type Subscribe struct {
Id int64 `gorm:"primaryKey"` Id int64 `gorm:"primaryKey"`
Name string `gorm:"type:varchar(255);not null;default:'';comment:Subscribe Name"` Name string `gorm:"type:varchar(255);not null;default:'';comment:Subscribe Name"`
Language string `gorm:"type:varchar(255);not null;default:'';comment:Language"` Language string `gorm:"type:varchar(255);not null;default:'';comment:Language"`
Description string `gorm:"type:text;comment:Subscribe Description"` Description string `gorm:"type:text;comment:Subscribe Description"`
UnitPrice int64 `gorm:"type:int;not null;default:0;comment:Unit Price"` UnitPrice int64 `gorm:"type:int;not null;default:0;comment:Unit Price"`
UnitTime string `gorm:"type:varchar(255);not null;default:'';comment:Unit Time"` UnitTime string `gorm:"type:varchar(255);not null;default:'';comment:Unit Time"`
Discount string `gorm:"type:text;comment:Discount"` Discount string `gorm:"type:text;comment:Discount"`
Replacement int64 `gorm:"type:int;not null;default:0;comment:Replacement"` Replacement int64 `gorm:"type:int;not null;default:0;comment:Replacement"`
Inventory int64 `gorm:"type:int;not null;default:0;comment:Inventory"` Inventory int64 `gorm:"type:int;not null;default:0;comment:Inventory"`
Traffic int64 `gorm:"type:int;not null;default:0;comment:Traffic"` Traffic int64 `gorm:"type:int;not null;default:0;comment:Traffic"`
SpeedLimit int64 `gorm:"type:int;not null;default:0;comment:Speed Limit"` SpeedLimit int64 `gorm:"type:int;not null;default:0;comment:Speed Limit"`
DeviceLimit int64 `gorm:"type:int;not null;default:0;comment:Device Limit"` DeviceLimit int64 `gorm:"type:int;not null;default:0;comment:Device Limit"`
Quota int64 `gorm:"type:int;not null;default:0;comment:Quota"` Quota int64 `gorm:"type:int;not null;default:0;comment:Quota"`
Nodes string `gorm:"type:varchar(255);comment:Node Ids"` Nodes string `gorm:"type:varchar(255);comment:Node Ids"`
NodeTags string `gorm:"type:varchar(255);comment:Node Tags"` NodeTags string `gorm:"type:varchar(255);comment:Node Tags"`
Show *bool `gorm:"type:tinyint(1);not null;default:0;comment:Show portal page"` Show *bool `gorm:"type:tinyint(1);not null;default:0;comment:Show portal page"`
Sell *bool `gorm:"type:tinyint(1);not null;default:0;comment:Sell"` Sell *bool `gorm:"type:tinyint(1);not null;default:0;comment:Sell"`
Sort int64 `gorm:"type:int;not null;default:0;comment:Sort"` Sort int64 `gorm:"type:int;not null;default:0;comment:Sort"`
DeductionRatio int64 `gorm:"type:int;default:0;comment:Deduction Ratio"` DeductionRatio int64 `gorm:"type:int;default:0;comment:Deduction Ratio"`
AllowDeduction *bool `gorm:"type:tinyint(1);default:1;comment:Allow deduction"` AllowDeduction *bool `gorm:"type:tinyint(1);default:1;comment:Allow deduction"`
ResetCycle int64 `gorm:"type:int;default:0;comment:Reset Cycle: 0: No Reset, 1: 1st, 2: Monthly, 3: Yearly"` ResetCycle int64 `gorm:"type:int;default:0;comment:Reset Cycle: 0: No Reset, 1: 1st, 2: Monthly, 3: Yearly"`
RenewalReset *bool `gorm:"type:tinyint(1);default:0;comment:Renew Reset"` RenewalReset *bool `gorm:"type:tinyint(1);default:0;comment:Renew Reset"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"` ShowOriginalPrice bool `gorm:"type:tinyint(1);not null;default:1;comment:Show Original Price"`
UpdatedAt time.Time `gorm:"comment:Update Time"` CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"`
} }
func (*Subscribe) TableName() string { func (*Subscribe) TableName() string {

View File

@ -388,26 +388,27 @@ type CreateSubscribeGroupRequest struct {
} }
type CreateSubscribeRequest struct { type CreateSubscribeRequest struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show *bool `json:"show"` Show *bool `json:"show"`
Sell *bool `json:"sell"` Sell *bool `json:"sell"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction *bool `json:"allow_deduction"` AllowDeduction *bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset *bool `json:"renewal_reset"` RenewalReset *bool `json:"renewal_reset"`
ShowOriginalPrice bool `json:"show_original_price"`
} }
type CreateTicketFollowRequest struct { type CreateTicketFollowRequest struct {
@ -2054,30 +2055,31 @@ type StripePayment struct {
} }
type Subscribe struct { type Subscribe struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show bool `json:"show"` Show bool `json:"show"`
Sell bool `json:"sell"` Sell bool `json:"sell"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction bool `json:"allow_deduction"` AllowDeduction bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset bool `json:"renewal_reset"` RenewalReset bool `json:"renewal_reset"`
CreatedAt int64 `json:"created_at"` ShowOriginalPrice bool `json:"show_original_price"`
UpdatedAt int64 `json:"updated_at"` CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
} }
type SubscribeApplication struct { type SubscribeApplication struct {
@ -2433,28 +2435,29 @@ type UpdateSubscribeGroupRequest struct {
} }
type UpdateSubscribeRequest struct { type UpdateSubscribeRequest struct {
Id int64 `json:"id" validate:"required"` Id int64 `json:"id" validate:"required"`
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Language string `json:"language"` Language string `json:"language"`
Description string `json:"description"` Description string `json:"description"`
UnitPrice int64 `json:"unit_price"` UnitPrice int64 `json:"unit_price"`
UnitTime string `json:"unit_time"` UnitTime string `json:"unit_time"`
Discount []SubscribeDiscount `json:"discount"` Discount []SubscribeDiscount `json:"discount"`
Replacement int64 `json:"replacement"` Replacement int64 `json:"replacement"`
Inventory int64 `json:"inventory"` Inventory int64 `json:"inventory"`
Traffic int64 `json:"traffic"` Traffic int64 `json:"traffic"`
SpeedLimit int64 `json:"speed_limit"` SpeedLimit int64 `json:"speed_limit"`
DeviceLimit int64 `json:"device_limit"` DeviceLimit int64 `json:"device_limit"`
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
Show *bool `json:"show"` Show *bool `json:"show"`
Sell *bool `json:"sell"` Sell *bool `json:"sell"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
DeductionRatio int64 `json:"deduction_ratio"` DeductionRatio int64 `json:"deduction_ratio"`
AllowDeduction *bool `json:"allow_deduction"` AllowDeduction *bool `json:"allow_deduction"`
ResetCycle int64 `json:"reset_cycle"` ResetCycle int64 `json:"reset_cycle"`
RenewalReset *bool `json:"renewal_reset"` RenewalReset *bool `json:"renewal_reset"`
ShowOriginalPrice bool `json:"show_original_price"`
} }
type UpdateTicketStatusRequest struct { type UpdateTicketStatusRequest struct {