Compare commits

..

No commits in common. "b977fbca79f74f1a79c9ef4599189bd752c9d214" and "4b02235be4de05742a8b50186368d3cfd9ca54ac" have entirely different histories.

3 changed files with 13 additions and 17 deletions

View File

@ -2,15 +2,6 @@ package main
import ( import (
"context" "context"
"haitao_watcher/pkg/options"
"haitao_watcher/pkg/watcher"
"haitao_watcher/server"
"log"
"log/slog"
"os"
"os/signal"
"time"
"gitea.timerzz.com/kedaya_haitao/common/pkg/database" "gitea.timerzz.com/kedaya_haitao/common/pkg/database"
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy" "gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
"gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher" "gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher"
@ -19,6 +10,14 @@ import (
"github.com/gofiber/fiber/v3/middleware/cors" "github.com/gofiber/fiber/v3/middleware/cors"
"github.com/golang/glog" "github.com/golang/glog"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
"haitao_watcher/pkg/options"
"haitao_watcher/pkg/watcher"
"haitao_watcher/server"
"log"
"log/slog"
"os"
"os/signal"
"time"
) )
func main() { func main() {
@ -60,6 +59,6 @@ func main() {
server.NewProxySvc(pool).RegistryRouter(api) server.NewProxySvc(pool).RegistryRouter(api)
if err = r.Listen(":8080"); err != nil { if err = r.Listen(":8080"); err != nil {
glog.Warningf("service over: %v", err) glog.Warningf("server over: %v", err)
} }
} }

View File

@ -21,8 +21,6 @@ type CoachOutlet struct {
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
client *coach_client.US client *coach_client.US
// 库存
ats int
} }
func NewCoachWatcher(ctx context.Context, client *coach_client.US, cfg *model.WatchInfo, db *gorm.DB) *CoachOutlet { func NewCoachWatcher(ctx context.Context, client *coach_client.US, cfg *model.WatchInfo, db *gorm.DB) *CoachOutlet {
@ -123,11 +121,10 @@ func (c *CoachOutlet) doWatch() bool {
glog.Warningf("获取coach %s 库存失败:%v", c.cfg.Pid, err) glog.Warningf("获取coach %s 库存失败:%v", c.cfg.Pid, err)
return false return false
} }
c.cfg.Orderable = inventory.Orderable && inventory.Ats > 0 c.cfg.Orderable = inventory.Orderable
if !inventory.AllocationResetDate.IsZero() { if !inventory.AllocationResetDate.IsZero() {
c.cfg.AllocationResetDate = inventory.AllocationResetDate c.cfg.AllocationResetDate = inventory.AllocationResetDate
} }
c.ats = inventory.Ats
if c.cfg.Orderable { if c.cfg.Orderable {
c.cfg.Watch = false c.cfg.Watch = false
} }
@ -149,7 +146,7 @@ func (c *CoachOutlet) Push() {
resp, err := pusher.Push(c.ctx, &push.PushReq{ resp, err := pusher.Push(c.ctx, &push.PushReq{
Ids: c.cfg.ToPusherIds(), Ids: c.cfg.ToPusherIds(),
Title: "coach 补货", Title: "coach 补货",
Content: fmt.Sprintf("coach 商品 %s 补货\n商品名%s\n库存:%d\n链接:%s", c.cfg.Pid, c.cfg.Name, c.ats, c.cfg.Link), Content: fmt.Sprintf("coach 商品 %s 补货\n商品名%s\n链接:%s", c.cfg.Pid, c.cfg.Name, c.cfg.Link),
}) })
if err != nil { if err != nil {
glog.Errorf("消息推送失败:%v", err) glog.Errorf("消息推送失败:%v", err)

View File

@ -101,7 +101,7 @@ type ListWatcherInfoRequest struct {
func (c *Controller) List(req ListWatcherInfoRequest) (resp web.ListResponse[model.WatchInfo], err error) { func (c *Controller) List(req ListWatcherInfoRequest) (resp web.ListResponse[model.WatchInfo], err error) {
tx := c.db tx := c.db
if req.Keyword != "" { if req.Keyword != "" {
tx = tx.Where("name ilike ? or remark ilike ? or pid ilike ?", fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword)) tx = tx.Where("name LIKE ? or remark LIKE ?", fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword))
} }
if !req.Website.IsZero() { if !req.Website.IsZero() {
tx = tx.Where("website = ?", req.Website) tx = tx.Where("website = ?", req.Website)