Jelajahi Sumber

refactor(internal): 重构游戏盾续费日期查询逻辑

-移除了不必要的字符串替换操作
- 优化了数据库查询条件,直接使用 productID 查询
- 删除了多余的代码和导入
fusu 3 bulan lalu
induk
melakukan
5caca7e5bd
2 mengubah file dengan 2 tambahan dan 6 penghapusan
  1. 1 3
      internal/repository/gameshield.go
  2. 1 3
      internal/service/duedate.go

+ 1 - 3
internal/repository/gameshield.go

@@ -83,8 +83,7 @@ func (r *gameShieldRepository) GetGameShieldNextduedate(ctx context.Context, uid
 	var nextDueDate string
 	err := r.DB(ctx).Table("shd_host").
 		Select("nextduedate").
-		Where("domain = ?", productID).
-		Where("productid = ?", 67).
+		Where("id = ?", productID).
 		Where("uid = ?", uid).
 		Scan(&nextDueDate).Error
 
@@ -94,7 +93,6 @@ func (r *gameShieldRepository) GetGameShieldNextduedate(ctx context.Context, uid
 
 	return nextDueDate, nil
 }
-
 func (r *gameShieldRepository) GetGameShieldExistingIps(ctx context.Context, ip string) ([]string, error) {
 	var res []string
 	if err := r.DB(ctx).Model(&model.GameShield{}).

+ 1 - 3
internal/service/duedate.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"github.com/go-nunu/nunu-layout-advanced/internal/repository"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -29,8 +28,7 @@ type duedateService struct {
 	gameShieldRepository repository.GameShieldRepository
 }
 
-func (service *duedateService) NextDueDate(ctx context.Context, uid int, hostId string) (string, error) {
-	productID := strings.ReplaceAll(hostId, "(游戏盾入门版)", "")
+func (service *duedateService) NextDueDate(ctx context.Context, uid int, productID string) (string, error) {
 	timeStr, err := service.gameShieldRepository.GetGameShieldNextduedate(ctx, int64(uid), productID)
 	if timeStr == "0" || timeStr == "" {
 		return "", err