- the information format of store map and courier map in GetStores changed to list
- nameIDs and skuIDs form GetSkuNames.
This commit is contained in:
@@ -174,6 +174,16 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
|||||||
sql += " AND t1.id = ?"
|
sql += " AND t1.id = ?"
|
||||||
sqlParams = append(sqlParams, params["nameID"].(int))
|
sqlParams = append(sqlParams, params["nameID"].(int))
|
||||||
}
|
}
|
||||||
|
if params["nameIDs"] != nil {
|
||||||
|
var nameIDs []int
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params["nameIDs"].(string)), &nameIDs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nameIDs) > 0 {
|
||||||
|
sql += " AND t1.id IN (" + dao.GenQuestionMarks(len(nameIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, nameIDs)
|
||||||
|
}
|
||||||
|
}
|
||||||
if params["categoryID"] != nil {
|
if params["categoryID"] != nil {
|
||||||
cat := &model.SkuCategory{}
|
cat := &model.SkuCategory{}
|
||||||
cat.ID = params["categoryID"].(int)
|
cat.ID = params["categoryID"].(int)
|
||||||
@@ -229,6 +239,16 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
|||||||
sql += " AND t2.id = ?"
|
sql += " AND t2.id = ?"
|
||||||
sqlParams = append(sqlParams, params["skuID"].(int))
|
sqlParams = append(sqlParams, params["skuID"].(int))
|
||||||
}
|
}
|
||||||
|
if params["skuIDs"] != nil {
|
||||||
|
var skuIDs []int
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params["skuIDs"].(string)), &skuIDs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(skuIDs) > 0 {
|
||||||
|
sql += " AND t2.id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
|
}
|
||||||
|
}
|
||||||
if params["fromStatus"] != nil {
|
if params["fromStatus"] != nil {
|
||||||
fromStatus := params["fromStatus"].(int)
|
fromStatus := params["fromStatus"].(int)
|
||||||
toStatus := fromStatus
|
toStatus := fromStatus
|
||||||
|
|||||||
@@ -22,13 +22,14 @@ const (
|
|||||||
|
|
||||||
type StoreExt struct {
|
type StoreExt struct {
|
||||||
model.Store
|
model.Store
|
||||||
FloatLng float64 `json:"lng"`
|
FloatLng float64 `json:"lng"`
|
||||||
FloatLat float64 `json:"lat"`
|
FloatLat float64 `json:"lat"`
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
DistrictName string `json:"districtName"`
|
DistrictName string `json:"districtName"`
|
||||||
JdID string `orm:"column(jd_id)" json:"jdID"`
|
StoreMapStr string `json:"-"`
|
||||||
ElmID string `orm:"column(elm_id)" json:"elmID"`
|
CourierMapStr string `json:"-"`
|
||||||
EbaiID string `orm:"column(ebai_id)" json:"ebaiID"`
|
StoreMaps []interface{} `orm:"-"`
|
||||||
|
CourierMaps []interface{} `orm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoresInfo struct {
|
type StoresInfo struct {
|
||||||
@@ -47,16 +48,14 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
FROM store t1
|
FROM store t1
|
||||||
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
|
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
|
||||||
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
|
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
|
||||||
LEFT JOIN store_map jdm ON t1.id = jdm.store_id AND jdm.vendor_id = 0 AND jdm.deleted_at = ?
|
LEFT JOIN store_map m1 ON t1.id = m1.store_id AND m1.deleted_at = ?
|
||||||
LEFT JOIN store_map elmm ON t1.id = elmm.store_id AND elmm.vendor_id = 2 AND elmm.deleted_at = ?
|
LEFT JOIN store_courier_map m2 ON t1.id = m2.store_id AND m2.deleted_at = ?
|
||||||
LEFT JOIN store_map ebaim ON t1.id = ebaim.store_id AND ebaim.vendor_id = 3 AND ebaim.deleted_at = ?
|
|
||||||
WHERE t1.deleted_at = ?
|
WHERE t1.deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
}
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
keywordLike := "%" + keyword + "%"
|
keywordLike := "%" + keyword + "%"
|
||||||
@@ -136,10 +135,33 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng,CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat,
|
SELECT SQL_CALC_FOUND_ROWS
|
||||||
t1.*, city.name city_name, district.name district_name,
|
CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng,
|
||||||
jdm.vendor_store_id jd_id, elmm.vendor_store_id elm_id, ebaim.vendor_store_id ebai_id
|
CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat,
|
||||||
|
t1.id,
|
||||||
|
t1.created_at,
|
||||||
|
t1.updated_at,
|
||||||
|
t1.last_operator,
|
||||||
|
t1.deleted_at,
|
||||||
|
t1.name,
|
||||||
|
t1.city_code,
|
||||||
|
t1.district_code,
|
||||||
|
t1.address,
|
||||||
|
t1.tel1,
|
||||||
|
t1.tel2,
|
||||||
|
t1.open_time1,
|
||||||
|
t1.close_time1,
|
||||||
|
t1.open_time2,
|
||||||
|
t1.close_time2,
|
||||||
|
t1.delivery_range_type,
|
||||||
|
t1.delivery_range,
|
||||||
|
t1.status,
|
||||||
|
city.name city_name,
|
||||||
|
district.name district_name,
|
||||||
|
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"vendorStoreID":"', m1.vendor_store_id, '", "vendorID":', m1.vendor_id, ', "status":', m1.status, "}")), "]") store_map_str,
|
||||||
|
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"vendorStoreID":"', m2.vendor_store_id, '", "vendorID":', m2.vendor_id, ', "status":', m2.status, "}")), "]") courier_map_str
|
||||||
` + sqlWhere + `
|
` + sqlWhere + `
|
||||||
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
|
||||||
ORDER BY t1.id
|
ORDER BY t1.id
|
||||||
LIMIT ? OFFSET ?`
|
LIMIT ? OFFSET ?`
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
@@ -156,11 +178,24 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
globals.SugarLogger.Debug(sql)
|
||||||
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
|
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
|
||||||
countInfo := &struct{ Ct int }{}
|
countInfo := &struct{ Ct int }{}
|
||||||
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
|
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
|
||||||
retVal.TotalCount = countInfo.Ct
|
retVal.TotalCount = countInfo.Ct
|
||||||
}
|
}
|
||||||
|
for _, v := range retVal.Stores {
|
||||||
|
if v.StoreMapStr != "" {
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(v.StoreMapStr), &v.StoreMaps); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v.CourierMapStr != "" {
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(v.CourierMapStr), &v.CourierMaps); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
return retVal, err
|
return retVal, err
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ type Store struct {
|
|||||||
Lng int `json:"-"` // 乘了10的6次方
|
Lng int `json:"-"` // 乘了10的6次方
|
||||||
Lat int `json:"-"` // 乘了10的6次方
|
Lat int `json:"-"` // 乘了10的6次方
|
||||||
DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义
|
DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义
|
||||||
DeliveryRange string `orm:"size(2048)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米
|
DeliveryRange string `orm:"type(text)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
|
|
||||||
DeliveryType int8 `orm:"-" json:"-"`
|
DeliveryType int8 `orm:"-" json:"-"`
|
||||||
|
|||||||
@@ -131,8 +131,10 @@ func (c *SkuController) SyncCategory() {
|
|||||||
// @Description 得到商品信息,如下条件之间是与的关系
|
// @Description 得到商品信息,如下条件之间是与的关系
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||||||
// @Param nameID query int false "SkuName ID"
|
// @Param nameID query int false "SkuName ID,废弃,请使用nameIDs"
|
||||||
// @Param skuID query int false "Sku ID"
|
// @Param nameIDs query string false "SkuName IDs列表"
|
||||||
|
// @Param skuID query int false "Sku ID,废弃,请使用skuDs"
|
||||||
|
// @Param skuIDs query string false "Sku ID列表"
|
||||||
// @Param name query string false "商品名称(不要求完全一致)"
|
// @Param name query string false "商品名称(不要求完全一致)"
|
||||||
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
||||||
// @Param placeCond query string false "查询地点的条件(如果此字段没有设置,placeCode与isGlobal无效),and:与,or:或,指的是placeCode,isGlobal这两个条件间的关系,这组条件与其它条件都是与的关系"
|
// @Param placeCond query string false "查询地点的条件(如果此字段没有设置,placeCode与isGlobal无效),and:与,or:或,指的是placeCode,isGlobal这两个条件间的关系,这组条件与其它条件都是与的关系"
|
||||||
|
|||||||
Reference in New Issue
Block a user