aa
This commit is contained in:
@@ -4357,18 +4357,19 @@ type QueryPageSkusResult struct {
|
||||
RealTimePrice string `json:"realTimePrice"` //促销价
|
||||
BasicPrice string `json:"basicPrice"` // 原价
|
||||
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Address string `json:"address"`
|
||||
CityName string `json:"cityName"`
|
||||
}
|
||||
|
||||
func QueryPageSkus(ctx *jxcontext.Context, vendorID int, keyword string, lng, lat float64, radius, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreID, keyword string, lng, lat float64, radius, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
results []*QueryPageSkusResult
|
||||
)
|
||||
//db.Db = orm.NewOrmUsingDB("c4beta")
|
||||
db.Db = orm.NewOrmUsingDB("c4beta")
|
||||
sqlJD := `
|
||||
SELECT b.orgcode org_code, a.wmpoiid store_id, b.name store_name, a.Base sku_id, a.name sku_name, a.month_saled month_sales, a.basic_price, b.address, b.bak_info city_name
|
||||
SELECT 0 vendor_id, b.orgcode org_code, a.wmpoiid store_id, b.name store_name, a.Base sku_id, a.name sku_name, a.month_saled month_sales, a.basic_price, b.address, b.bak_info city_name
|
||||
FROM jingdong_foodlist a
|
||||
LEFT JOIN jingdong_showd b ON a.wmpoiid = b.wmpoiid
|
||||
`
|
||||
@@ -4376,7 +4377,7 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, keyword string, lng, la
|
||||
|
||||
`
|
||||
sqlMT := `
|
||||
SELECT a.wmpoiid store_id, b.name store_name, a.name sku_name, a.month_saled month_sales, a.min_price basic_price, b.address, a.unit parameter
|
||||
SELECT 1 vendor_id, a.wmpoiid store_id, b.name store_name, a.name sku_name, a.month_saled month_sales, a.min_price basic_price, b.address, a.unit parameter
|
||||
FROM meituan_foodlist a
|
||||
LEFT JOIN meituan_showd b ON a.wmpoiid = b.wmpoiid
|
||||
`
|
||||
@@ -4409,6 +4410,10 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, keyword string, lng, la
|
||||
sql += " AND t1.sku_name LIKE ?"
|
||||
sqlParams = append(sqlParams, keywordLike)
|
||||
}
|
||||
if vendorStoreID != "" {
|
||||
sql += " AND t1.store_id LIKE ?"
|
||||
sqlParams = append(sqlParams, "%"+vendorStoreID+"%")
|
||||
}
|
||||
sql += `
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
@@ -4422,33 +4427,39 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, keyword string, lng, la
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
fmt.Println(sql)
|
||||
fmt.Println(sqlParams)
|
||||
if err = dao.GetRowsTx(txDB, &results, sql, sqlParams...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||
//Data: shopList,
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
var newShopList []*QueryPageSkusResult
|
||||
task := tasksch.NewParallelTask("", tasksch.NewParallelConfig().SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*QueryPageSkusResult)
|
||||
if radius > 0 {
|
||||
result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.CityName)
|
||||
distance := jxutils.EarthDistance(lng, lat, result.Lng, result.Lat)
|
||||
if utils.Float64TwoInt(math.Round(distance*1000)) < radius {
|
||||
if radius > 0 {
|
||||
var newShopList []*QueryPageSkusResult
|
||||
task := tasksch.NewParallelTask("", tasksch.NewParallelConfig().SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*QueryPageSkusResult)
|
||||
if radius > 0 {
|
||||
result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.CityName)
|
||||
distance := jxutils.EarthDistance(lng, lat, result.Lng, result.Lat)
|
||||
if utils.Float64TwoInt(math.Round(distance*1000)) < radius {
|
||||
retVal = []*QueryPageSkusResult{v}
|
||||
}
|
||||
} else {
|
||||
retVal = []*QueryPageSkusResult{v}
|
||||
}
|
||||
} else {
|
||||
retVal = []*QueryPageSkusResult{v}
|
||||
}
|
||||
return retVal, err
|
||||
}, results)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
result, _ := task.GetResult(0)
|
||||
for _, v := range result {
|
||||
newShopList = append(newShopList, v.(*QueryPageSkusResult))
|
||||
return retVal, err
|
||||
}, results)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
result, _ := task.GetResult(0)
|
||||
for _, v := range result {
|
||||
newShopList = append(newShopList, v.(*QueryPageSkusResult))
|
||||
}
|
||||
pagedInfo.Data = newShopList
|
||||
} else {
|
||||
pagedInfo.Data = results
|
||||
}
|
||||
pagedInfo.Data = newShopList
|
||||
} else {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user