From 8e49f412273a89457dbb96554635e7adfbefd683 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 11 Sep 2019 21:21:13 +0800 Subject: [PATCH] =?UTF-8?q?-=20GetAndStoreCitiesShops=E4=BC=9A=E4=BB=8E?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AC=A1=E7=9A=84=E5=9C=B0=E6=96=B9=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/netspider/netspider.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/business/netspider/netspider.go b/business/netspider/netspider.go index 860239f88..3cf4d7e57 100644 --- a/business/netspider/netspider.go +++ b/business/netspider/netspider.go @@ -54,7 +54,9 @@ func getStorePageInfo(ctx *jxcontext.Context, handler partner.IPurchasePlatformN if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) { storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode)) if storePageInfo.DistrictCode == 0 && cityCode != 0 { - storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, "") + if place, err := dao.GetPlaceByCode(dao.GetDB(), cityCode); err == nil { + storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(place.ParentCode)) + } } } else if storePageInfo.DistrictCode == 0 { storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat) @@ -140,6 +142,31 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis rand.Shuffle(len(cityCodeList), func(i, j int) { cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i] }) + } else { + sql := ` + SELECT * + FROM page_shop t1 + ORDER BY t1.id DESC + LIMIT 1` + var lastShop *model.PageShop + if dao.GetRow(db, &lastShop, sql) != nil { + index := -1 + for k, v := range cityCodeList { + if v == lastShop.CityCode { + index = k + 1 + if index >= len(cityCodeList) { + index = -1 + } + break + } + } + if index > 0 { + var cityCodeList2 []int + cityCodeList2 = append(cityCodeList2, cityCodeList[index:]...) + cityCodeList2 = append(cityCodeList2, cityCodeList[:index]...) + cityCodeList = cityCodeList2 + } + } } if len(vendorIDs) == 0 { vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}