From 9345f127382f04d08a7f2a7ede8b87f1cd7a3b90 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 11 Sep 2019 21:44:06 +0800 Subject: [PATCH] =?UTF-8?q?-=20beta=E5=90=AF=E5=8A=A8=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BF=90=E8=A1=8Cnetspider.GetAndStoreCitiesShops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/misc/misc.go | 6 ++++++ business/netspider/netspider.go | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 44dbd2029..f1e4c563e 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -15,8 +15,10 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/business/netspider" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" + "github.com/astaxie/beego" ) const ( @@ -106,6 +108,10 @@ func Init() { ScheduleTimerFunc("AutoSaleStoreSku", func() { cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) }, autoSaleStoreSkuTimeList) + + if beego.BConfig.RunMode == "beta" { + netspider.GetAndStoreCitiesShops(jxcontext.AdminCtx, nil, nil, 0, 0, false, true) + } } func doDailyWork() { diff --git a/business/netspider/netspider.go b/business/netspider/netspider.go index 3cf4d7e57..5a661aa1c 100644 --- a/business/netspider/netspider.go +++ b/business/netspider/netspider.go @@ -192,9 +192,11 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis } }() for _, v := range shopList { - tmpShop := *v - dao.DeleteEntity(db, &tmpShop, model.FieldVendorStoreID, model.FieldVendorID) - if err = dao.CreateEntity(db, v); err != nil { + if v.DistrictCode > 0 { + tmpShop := *v + dao.DeleteEntity(db, &tmpShop, model.FieldVendorStoreID, model.FieldVendorID) + } + if err = dao.CreateEntity(db, v); err != nil && !dao.IsDuplicateError(err) { break } }