aa
This commit is contained in:
@@ -512,6 +512,37 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn
|
|||||||
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
|
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
|
||||||
func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int, orderTimeFrom, orderTimeTo time.Time, orderCountFrom, orderCountTo int) (retVal *StoresInfo, err error) {
|
func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int, orderTimeFrom, orderTimeTo time.Time, orderCountFrom, orderCountTo int) (retVal *StoresInfo, err error) {
|
||||||
briefLevel := int(utils.ForceInterface2Int64(params["briefLevel"]))
|
briefLevel := int(utils.ForceInterface2Int64(params["briefLevel"]))
|
||||||
|
//权限
|
||||||
|
//权限
|
||||||
|
if permission.IsRoled(ctx) {
|
||||||
|
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||||
|
var storeIDs2 []int
|
||||||
|
if params["storeIDs"] != nil {
|
||||||
|
var storeIDs []int
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err == nil {
|
||||||
|
for _, v := range storeIDs {
|
||||||
|
if storeIDsMap[v] != 0 {
|
||||||
|
storeIDs2 = append(storeIDs2, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(storeIDs2) == 0 {
|
||||||
|
storeIDs2 = append(storeIDs2, -1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if len(storeIDsMap) > 0 {
|
||||||
|
for k, _ := range storeIDsMap {
|
||||||
|
storeIDs2 = append(storeIDs2, k)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
storeIDs2 = append(storeIDs2, -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if data, err := json.Marshal(storeIDs2); err == nil {
|
||||||
|
params["storeIDs"] = string(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
sql, sqlParams, _, _, err := getStoresSql(ctx, keyword, params, orderTimeFrom, orderTimeTo)
|
sql, sqlParams, _, _, err := getStoresSql(ctx, keyword, params, orderTimeFrom, orderTimeTo)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -536,6 +567,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
(SELECT COUNT(*) FROM store t11 WHERE t11.link_store_id = t1.id) link_store_count
|
(SELECT COUNT(*) FROM store t11 WHERE t11.link_store_id = t1.id) link_store_count
|
||||||
` + sql + `
|
` + sql + `
|
||||||
ORDER BY t1.id DESC
|
ORDER BY t1.id DESC
|
||||||
|
LIMIT ? OFFSET ?
|
||||||
`
|
`
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
retVal = &StoresInfo{}
|
retVal = &StoresInfo{}
|
||||||
@@ -544,12 +576,12 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
var storeList []*StoreExt
|
var storeList []*StoreExt
|
||||||
offset = jxutils.FormalizePageOffset(offset)
|
offset = jxutils.FormalizePageOffset(offset)
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
//mapLimit := false
|
//mapLimit := false
|
||||||
//globals.SugarLogger.Debug(sql)
|
//globals.SugarLogger.Debug(sql)
|
||||||
//globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
//globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||||
|
|
||||||
if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil {
|
if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil {
|
||||||
fmt.Println("111111111111111111111111111111", utils.Format4Output(storeList, true))
|
|
||||||
// 地图区域限制过滤
|
// 地图区域限制过滤
|
||||||
//if mapLongitude2, ok := params["mapLongitude"].(string); ok {
|
//if mapLongitude2, ok := params["mapLongitude"].(string); ok {
|
||||||
// var (
|
// var (
|
||||||
@@ -572,35 +604,22 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
//} else {
|
//} else {
|
||||||
// retVal.Stores = storeList
|
// retVal.Stores = storeList
|
||||||
//}
|
//}
|
||||||
//权限
|
|
||||||
if permission.IsRoled(ctx) {
|
|
||||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
|
||||||
var storeList2 []*StoreExt
|
|
||||||
for _, v := range retVal.Stores {
|
|
||||||
if storeIDsMap[v.ID] != 0 {
|
|
||||||
storeList2 = append(storeList2, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
retVal.Stores = nil
|
|
||||||
retVal.Stores = storeList2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 订单情况过滤
|
// 订单情况过滤
|
||||||
storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo)
|
//storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 分页
|
// 分页
|
||||||
retVal.TotalCount = len(storeList)
|
//retVal.TotalCount = len(storeList)
|
||||||
retVal.Stores = nil
|
//retVal.Stores = nil
|
||||||
for i := offset; i < offset+pageSize && i < len(storeList); i++ {
|
//for i := offset; i < offset+pageSize && i < len(storeList); i++ {
|
||||||
storeIDs = append(storeIDs, storeList[i].ID)
|
// storeIDs = append(storeIDs, storeList[i].ID)
|
||||||
retVal.Stores = append(retVal.Stores, storeList[i])
|
// retVal.Stores = append(retVal.Stores, storeList[i])
|
||||||
}
|
//}
|
||||||
if len(storeIDs) == 0 {
|
//if len(storeIDs) == 0 {
|
||||||
return retVal, nil
|
// return retVal, nil
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 导出门店地图标信息时,可能会需要转换门店坐标
|
// 导出门店地图标信息时,可能会需要转换门店坐标
|
||||||
needConver2Baidu := int(utils.Interface2Int64WithDefault(params["coordinateType"], 0)) == model.CoordinateTypeBaiDu
|
needConver2Baidu := int(utils.Interface2Int64WithDefault(params["coordinateType"], 0)) == model.CoordinateTypeBaiDu
|
||||||
|
|||||||
Reference in New Issue
Block a user