- GetAndStoreCitiesShops添加参数isShuffle

This commit is contained in:
gazebo
2019-09-11 16:49:56 +08:00
parent 37c9acc407
commit 3919aafe83
2 changed files with 11 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package netspider
import (
"fmt"
"math/rand"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
@@ -124,7 +125,7 @@ func getStoreListByCoordinates(ctx *jxcontext.Context, parentTask tasksch.ITask,
return storeList, err
}
func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeList []int, radius, gridWith int, isAsync bool) (hint string, err error) {
func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeList []int, radius, gridWith int, isShuffle, isAsync bool) (hint string, err error) {
db := dao.GetDB()
if len(cityCodeList) == 0 {
placeList, err2 := dao.GetPlacesByCond(db, dao.EnableCondAll)
@@ -134,7 +135,11 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
for _, v := range placeList {
cityCodeList = append(cityCodeList, v.Code)
}
// cityCodeList = []int{510100}
}
if isShuffle {
rand.Shuffle(len(cityCodeList), func(i, j int) {
cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i]
})
}
if len(vendorIDs) == 0 {
vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}