mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-19 16:17:56 +00:00
Merge pull request #3364 from feitianbubu/fix/promo-clear-expiry
fix(promo): allow clearing promo code expiry on edit
This commit is contained in:
@@ -148,7 +148,7 @@ func (h *PromoHandler) Update(c *gin.Context) {
|
||||
if req.ExpiresAt != nil {
|
||||
if *req.ExpiresAt == 0 {
|
||||
// 0 表示清除过期时间
|
||||
input.ExpiresAt = nil
|
||||
input.ExpiresAt = &time.Time{}
|
||||
} else {
|
||||
t := time.Unix(*req.ExpiresAt, 0)
|
||||
input.ExpiresAt = &t
|
||||
|
||||
@@ -236,6 +236,9 @@ func (s *PromoService) Update(ctx context.Context, id int64, input *UpdatePromoC
|
||||
promoCode.Status = *input.Status
|
||||
}
|
||||
if input.ExpiresAt != nil {
|
||||
if input.ExpiresAt.IsZero() {
|
||||
input.ExpiresAt = nil
|
||||
}
|
||||
promoCode.ExpiresAt = input.ExpiresAt
|
||||
}
|
||||
if input.Notes != nil {
|
||||
|
||||
Reference in New Issue
Block a user