+ QueryPageStores
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi"
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -275,12 +276,7 @@ func IsEmptyID(id int64) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FormalizePageSize(pageSize int) int {
|
func FormalizePageSize(pageSize int) int {
|
||||||
if pageSize == 0 {
|
return dao.FormalizePageSize(pageSize)
|
||||||
return model.DefPageSize
|
|
||||||
} else if pageSize < 0 {
|
|
||||||
return model.UnlimitedPageSize
|
|
||||||
}
|
|
||||||
return pageSize
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormalizeName(name string) string {
|
func FormalizeName(name string) string {
|
||||||
|
|||||||
@@ -172,3 +172,12 @@ func value2Value(srcValue, dstValue reflect.Value, copyType int) {
|
|||||||
func IsVendorThingIDEmpty(vendorThingID string) bool {
|
func IsVendorThingIDEmpty(vendorThingID string) bool {
|
||||||
return vendorThingID == "" || vendorThingID == "0"
|
return vendorThingID == "" || vendorThingID == "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormalizePageSize(pageSize int) int {
|
||||||
|
if pageSize == 0 {
|
||||||
|
return model.DefPageSize
|
||||||
|
} else if pageSize < 0 {
|
||||||
|
return model.UnlimitedPageSize
|
||||||
|
}
|
||||||
|
return pageSize
|
||||||
|
}
|
||||||
|
|||||||
90
business/model/dao/page_store.go
Normal file
90
business/model/dao/page_store.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PageShopWithPlaceName struct {
|
||||||
|
model.PageShop
|
||||||
|
|
||||||
|
CityName string `json:"cityName"`
|
||||||
|
DistrictName string `json:"districtName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func QueryPageStores(db *DaoDB, pageSize, offset int, keyword string, vendorStoreID string, vendorID int, cityCode, districtCode int, tel string, minShopScore float32, minRecentOrderNum, minSkuCount int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS
|
||||||
|
t1.*,
|
||||||
|
t2.name city_name, t3.name district_name
|
||||||
|
FROM page_shop t1
|
||||||
|
LEFT JOIN place t2 ON t2.code = t1.city_code
|
||||||
|
LEFT JOIN place t3 ON t3.code = t1.district_code
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
|
||||||
|
if vendorStoreID != "" {
|
||||||
|
sql += " AND t1.vendor_store_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorStoreID)
|
||||||
|
}
|
||||||
|
if vendorID != -1 {
|
||||||
|
sql += " AND t1.vendor_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorID)
|
||||||
|
}
|
||||||
|
if cityCode != 0 {
|
||||||
|
sql += " AND t1.city_code = ?"
|
||||||
|
sqlParams = append(sqlParams, cityCode)
|
||||||
|
}
|
||||||
|
if districtCode != 0 {
|
||||||
|
sql += " AND t1.district_code = ?"
|
||||||
|
sqlParams = append(sqlParams, districtCode)
|
||||||
|
}
|
||||||
|
if tel != "" {
|
||||||
|
sql += " AND t1.tel1 = ?"
|
||||||
|
sqlParams = append(sqlParams, tel)
|
||||||
|
}
|
||||||
|
if minShopScore > 0 {
|
||||||
|
sql += " AND t1.shop_score >= ?"
|
||||||
|
sqlParams = append(sqlParams, minShopScore)
|
||||||
|
}
|
||||||
|
if minRecentOrderNum > 0 {
|
||||||
|
sql += " AND t1.recent_order_num >= ?"
|
||||||
|
sqlParams = append(sqlParams, minRecentOrderNum)
|
||||||
|
}
|
||||||
|
if minSkuCount > 0 {
|
||||||
|
sql += " AND t1.sku_count >= ?"
|
||||||
|
sqlParams = append(sqlParams, minSkuCount)
|
||||||
|
}
|
||||||
|
if keyword != "" {
|
||||||
|
keywordLike := "%" + keyword + "%"
|
||||||
|
sql += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.org_code LIKE ? OR t1.address LIKE ? OR t2.name LIKE ? OR t3.name LIKE ?"
|
||||||
|
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||||
|
sql += ")"
|
||||||
|
}
|
||||||
|
sql += `
|
||||||
|
LIMIT ? OFFSET ?
|
||||||
|
`
|
||||||
|
pageSize = FormalizePageSize(pageSize)
|
||||||
|
if offset < 0 {
|
||||||
|
offset = 0
|
||||||
|
}
|
||||||
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
var shopList []*PageShopWithPlaceName
|
||||||
|
Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err = GetRows(db, &shopList, sql, sqlParams...); err == nil {
|
||||||
|
pagedInfo = &model.PagedInfo{
|
||||||
|
TotalCount: GetLastTotalRowCount(db),
|
||||||
|
Data: shopList,
|
||||||
|
}
|
||||||
|
Commit(db)
|
||||||
|
} else {
|
||||||
|
Rollback(db)
|
||||||
|
}
|
||||||
|
return pagedInfo, err
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/netspider"
|
"git.rosy.net.cn/jx-callback/business/netspider"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
@@ -30,3 +31,30 @@ func (c *NetSpiderController) GetAndStoreCitiesShops() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 同步商家商品信息
|
||||||
|
// @Description 同步商家商品信息
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param offset query int false "列表起始序号(以0开始,缺省为0)"
|
||||||
|
// @Param pageSize query int false "列表页大小(缺省为50,-1表示全部)"
|
||||||
|
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||||||
|
// @Param vendorStoreID query string false "门店号"
|
||||||
|
// @Param vendorID query int false "平台ID"
|
||||||
|
// @Param cityCode query int false "城市代码"
|
||||||
|
// @Param districtCode query int false "行政区代码"
|
||||||
|
// @Param tel query string false "手机号"
|
||||||
|
// @Param minShopScore query float64 false "门店分值最小值"
|
||||||
|
// @Param minRecentOrderNum query int false "最近单量最小值"
|
||||||
|
// @Param minSkuCount query int false "SKU数量最小值"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /QueryPageStores [get]
|
||||||
|
func (c *NetSpiderController) QueryPageStores() {
|
||||||
|
c.callQueryPageStores(func(params *tNetspiderQueryPageStoresParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if params.MapData["vendorID"] == nil {
|
||||||
|
params.VendorID = -1
|
||||||
|
}
|
||||||
|
retVal, err = dao.QueryPageStores(dao.GetDB(), params.PageSize, params.Offset, params.Keyword, params.VendorStoreID, params.VendorID, params.CityCode, params.DistrictCode, params.Tel, float32(params.MinShopScore), params.MinRecentOrderNum, params.MinSkuCount)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -520,6 +520,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:NetSpiderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:NetSpiderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "QueryPageStores",
|
||||||
|
Router: `/QueryPageStores`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AcceptOrRefuseFailedGetOrder",
|
Method: "AcceptOrRefuseFailedGetOrder",
|
||||||
|
|||||||
Reference in New Issue
Block a user