feat 支持蹲库存和历史库存
All checks were successful
Build image / build (push) Successful in 2m26s

This commit is contained in:
timerzz 2024-12-02 19:25:39 +08:00
parent 66959d8a58
commit 1afeea4423
3 changed files with 27 additions and 23 deletions

View File

@ -118,16 +118,16 @@ func (c *Controller) traceRange() {
if c.doTrace(tracer) {
//如果蹲到了,需要通知
//resp, err := pusher.Push(c.ctx, &push.PushReq{
// Title: "coach 断货",
// Content: fmt.Sprintf("coach 商品 %s 断货了\n库存为0\n链接%s", tracer.pArticle.SkuID, tracer.pArticle.Link),
//})
//if err != nil {
// glog.Errorf("消息推送失败:%v", err)
//}
//if resp.Code != 0 {
// glog.Errorf("消息推送失败:%s", resp.Msg)
//}
resp, err := pusher.Push(c.ctx, &push.PushReq{
Title: "coach 断货",
Content: fmt.Sprintf("coach 商品 %s 断货了\n库存为0\n链接%s", tracer.pArticle.SkuID, tracer.pArticle.Link),
})
if err != nil {
glog.Errorf("消息推送失败:%v", err)
}
if resp.Code != 0 {
glog.Errorf("消息推送失败:%s", resp.Msg)
}
tracer.pArticle.SetTraceAts(false)
_ = c.storage.ProviderArticle().Update(*tracer.pArticle, "trace_ats")
c.tracers.Remove(tracer.pArticle.SkuID)

View File

@ -16,6 +16,8 @@ import (
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
"gitea.timerzz.com/kedaya_haitao/common/pkg/redis"
"gitea.timerzz.com/kedaya_haitao/common/pkg/web"
"gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher"
"github.com/cloudwego/kitex/client"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/gofiber/fiber/v3/middleware/recover"
@ -45,7 +47,7 @@ func main() {
glog.Fatalf("初始化redis失败%v", err)
}
//pusher.InitClient("pusher", client.WithHostPorts("pusher:8080"))
pusher.InitClient("pusher", client.WithHostPorts("pusher:8080"))
// 代理池
pool := proxy.NewProxyPool(cfg.Proxy.Subscribes)

View File

@ -10,6 +10,8 @@ import (
coach_client "gitea.timerzz.com/kedaya_haitao/common/pkg/coach-client"
"gitea.timerzz.com/kedaya_haitao/common/structs/storage"
v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2"
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
"gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher"
"github.com/golang/glog"
"gorm.io/gorm"
)
@ -114,17 +116,17 @@ func (c *Controller) watchRange() {
}()
if c.doWatch(watcher) {
//// 如果蹲到了,需要通知
//resp, err := pusher.Push(c.ctx, &push.PushReq{
// Title: "coach 补货",
// Content: fmt.Sprintf("coach 商品 %s 补货\n库存%d\n链接%s", watcher.pArticle.SkuID, watcher.pArticle.Ats, watcher.pArticle.Link),
//})
//if err != nil {
// glog.Errorf("消息推送失败:%v", err)
//}
//if resp.Code != 0 {
// glog.Errorf("消息推送失败:%s", resp.Msg)
//}
// 如果蹲到了,需要通知
resp, err := pusher.Push(c.ctx, &push.PushReq{
Title: "coach 补货",
Content: fmt.Sprintf("coach 商品 %s 补货\n库存%d\n链接%s", watcher.pArticle.SkuID, watcher.pArticle.Ats, watcher.pArticle.Link),
})
if err != nil {
glog.Errorf("消息推送失败:%v", err)
}
if resp.Code != 0 {
glog.Errorf("消息推送失败:%s", resp.Msg)
}
watcher.pArticle.SetWatch(false)
_ = c.storage.ProviderArticle().Update(*watcher.pArticle, "watch")
c.watchers.Remove(watcher.pArticle.SkuID)