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

@ -54,6 +54,7 @@ type (
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"`
@ -78,6 +79,7 @@ type (
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

@ -230,6 +230,7 @@ type (
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"`
CreatedAt int64 `json:"created_at"` CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"` UpdatedAt int64 `json:"updated_at"`
} }

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

@ -57,6 +57,7 @@ func (l *CreateSubscribeLogic) CreateSubscribe(req *types.CreateSubscribeRequest
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

@ -65,6 +65,7 @@ func (l *UpdateSubscribeLogic) UpdateSubscribe(req *types.UpdateSubscribeRequest
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

@ -29,6 +29,7 @@ type Subscribe struct {
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"`
ShowOriginalPrice bool `gorm:"type:tinyint(1);not null;default:1;comment:Show Original Price"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"` CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"` UpdatedAt time.Time `gorm:"comment:Update Time"`
} }

View File

@ -408,6 +408,7 @@ type CreateSubscribeRequest struct {
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 {
@ -2076,6 +2077,7 @@ type Subscribe struct {
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"`
CreatedAt int64 `json:"created_at"` CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"` UpdatedAt int64 `json:"updated_at"`
} }
@ -2455,6 +2457,7 @@ type UpdateSubscribeRequest struct {
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 {