aa
This commit is contained in:
@@ -4360,9 +4360,10 @@ type QueryPageSkusResult struct {
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Address string `json:"address"`
|
||||
CityName string `json:"cityName"`
|
||||
CityCode int `json:"cityCode"`
|
||||
}
|
||||
|
||||
func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string, keyword string, lng, lat float64, radius, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string, keyword string, cityCode int, lng, lat float64, radius, sortType, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
results []*QueryPageSkusResult
|
||||
@@ -4383,7 +4384,7 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string
|
||||
`
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
t1.*
|
||||
t1.*, t2.code city_code
|
||||
FROM (
|
||||
`
|
||||
if vendorID == -1 {
|
||||
@@ -4402,6 +4403,7 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string
|
||||
}
|
||||
sql += `
|
||||
)t1
|
||||
LEFT JOIN place t2 ON t2.name = t1.city_name
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
@@ -4414,6 +4416,20 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string
|
||||
sql += " AND t1.store_id IN (" + dao.GenQuestionMarks(len(vendorStoreIDs)) + ")"
|
||||
sqlParams = append(sqlParams, vendorStoreIDs)
|
||||
}
|
||||
if cityCode > 0 {
|
||||
sql += " AND t2.code = ?"
|
||||
sqlParams = append(sqlParams, cityCode)
|
||||
}
|
||||
if sortType != 0 {
|
||||
switch math.Abs(float64(sortType)) {
|
||||
case 1:
|
||||
if sortType < 0 {
|
||||
sql += " ORDER BY t1.month_sales DESC"
|
||||
} else {
|
||||
sql += " ORDER BY t1.month_sales"
|
||||
}
|
||||
}
|
||||
}
|
||||
sql += `
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
@@ -4427,8 +4443,6 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string
|
||||
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),
|
||||
|
||||
@@ -170,7 +170,7 @@ func (c *NetSpiderController) QueryPageSkus() {
|
||||
c.callQueryPageSkus(func(params *tNetspiderQueryPageSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorStoreIDs []string
|
||||
jxutils.Strings2Objs(params.VendorStoreIDs, &vendorStoreIDs)
|
||||
retVal, err = cms.QueryPageSkus(params.Ctx, params.VendorID, vendorStoreIDs, params.Keyword, utils.Str2Float64WithDefault(params.Lng, 0), utils.Str2Float64WithDefault(params.Lat, 0), params.Radius, params.Offset, params.PageSize)
|
||||
retVal, err = cms.QueryPageSkus(params.Ctx, params.VendorID, vendorStoreIDs, params.Keyword, params.CityCode, utils.Str2Float64WithDefault(params.Lng, 0), utils.Str2Float64WithDefault(params.Lat, 0), params.Radius, params.SortType, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user