- GetAndStoreCitiesShops会从上一次的地方继续

This commit is contained in:
gazebo
2019-09-11 21:21:13 +08:00
parent 11e30ffb24
commit 8e49f41227

View File

@@ -54,7 +54,9 @@ func getStorePageInfo(ctx *jxcontext.Context, handler partner.IPurchasePlatformN
if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) { if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) {
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode)) storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode))
if storePageInfo.DistrictCode == 0 && cityCode != 0 { 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 { } else if storePageInfo.DistrictCode == 0 {
storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat) 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) { rand.Shuffle(len(cityCodeList), func(i, j int) {
cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i] 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 { if len(vendorIDs) == 0 {
vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI} vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}