1
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/common"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||||
@@ -9,6 +11,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
)
|
||||
@@ -574,8 +577,56 @@ func (c *StoreController) SyncStoresCourierInfo() {
|
||||
// @router /GetStoreListByLocation [get]
|
||||
func (c *StoreController) GetStoreListByLocation() {
|
||||
c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID)
|
||||
return retVal, "", err
|
||||
locationList, err := common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID)
|
||||
|
||||
// 获取用户权限,如果是普通用户不展示b2b相关目录,如果是门店老板或者管理则展示全部
|
||||
userAuth, err := auth2.GetTokenInfo(params.Token)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if total != model.YES {
|
||||
return nil, "", errors.New("未注册用户")
|
||||
}
|
||||
if user[0].Type != model.YES {
|
||||
return locationList, "", nil
|
||||
}
|
||||
|
||||
// 获取位置附近门店列表
|
||||
storeIDs := make([]int, 0, len(locationList))
|
||||
for _, v := range locationList {
|
||||
storeIDs = append(storeIDs, v.ID)
|
||||
}
|
||||
// 判断门店是不是b2b门店,如果是,用户必须为系统管理员(门店老板和运营人员)
|
||||
store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "")
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
isMatterStore := false
|
||||
for _, v := range storeIDs {
|
||||
if v == model.MatterStoreID {
|
||||
isMatterStore = true
|
||||
}
|
||||
}
|
||||
|
||||
result := make([]*common.Store4User, 0, 0)
|
||||
for _, v := range store {
|
||||
for _, s := range locationList {
|
||||
if v.ID == s.ID {
|
||||
if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店
|
||||
continue
|
||||
} else {
|
||||
result = append(result, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result, "", err
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user