feat: 添加更新价格的任务

master
howell 3 years ago
parent 3b30e326cc
commit 99c7abfd08

@ -239,6 +239,11 @@ func (g *Goods) ShaMaSync(c *gin.Context) {
c.String(200, "suc")
}
func (g *Goods) ShaMaPrice(c *gin.Context) {
go ShaMaPriceSync()
c.String(200, "suc")
}
func (g *Goods) Sync(c *gin.Context) {
b := c.Query("brand")
go SyncAllSku(b)

@ -69,6 +69,24 @@ func AttrSync() {
}
}
func ShaMaPriceSync() {
client := shama.GetClient()
var sl []goods.RecookGoodsSkuModel
mysql2.Db.Find(&sl, "third_party_type = 4")
//fmt.Println(len(sl))
for _, v := range sl {
id, _ := strconv.Atoi(v.ThirdPartySkuId)
r := shama.SkuDetailReq{SkuIDSet: []uint{uint(id)}}
var resp []shama.SkuDetailResp
if err := client.Exec(r, &resp); err != nil {
fmt.Println(err.Error())
continue
} else {
mysql2.Db.Model(v).Update("purchase_price", resp[0].SkuDetailBase.SupplyPrice)
}
}
}
func ShaMaSyncAllSku() {
defer func() {
if err := recover(); err != nil {

@ -22,4 +22,6 @@ func routerTask(taskRouter *gin.RouterGroup) {
taskRouter.POST("zip/sync", goodsController.ZipSync)
taskRouter.GET("shaMaSync", goodsController.ShaMaSync)
taskRouter.GET("shaMaPriceSync", goodsController.ShaMaPrice)
}

Loading…
Cancel
Save