+ Store添加MarketManRole与OperatorRole
- GetStoreListByMobileOrStoreIDs支持按Store.MarketManRole与OperatorRole来得到门店列表
This commit is contained in:
@@ -162,17 +162,32 @@ func GetUsers(ctx *jxcontext.Context, userType int, keyword string, userIDs []st
|
||||
return dao.GetUsers(dao.GetDB(), userType, keyword, userIDs, userID2, mobile)
|
||||
}
|
||||
|
||||
func GetStoreList4User(ctx *jxcontext.Context, mobileNum, userID string) (storeList []*dao.StoreWithCityName, err error) {
|
||||
roleList, err := api2.RoleMan.GetUserRoleList(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
storeIDs []int
|
||||
shortRoleNameList []string
|
||||
)
|
||||
for _, v := range roleList {
|
||||
if v.StoreID == 0 {
|
||||
shortRoleNameList = append(shortRoleNameList, v.Name)
|
||||
} else {
|
||||
storeIDs = append(storeIDs, v.StoreID)
|
||||
}
|
||||
}
|
||||
storeList, err = dao.GetStoreListByMobileOrStoreIDs(dao.GetDB(), mobileNum, shortRoleNameList, storeIDs)
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) {
|
||||
mobileNum, userID := ctx.GetMobileAndUserID()
|
||||
if mobileNum == "" {
|
||||
return nil, fmt.Errorf("不能得到用户手机号")
|
||||
}
|
||||
roleList, err := api2.RoleMan.GetUserRoleList(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
storeList, err = dao.GetStoreListByMobileOrStoreIDs(dao.GetDB(), mobileNum, authz.RoleList2StoreIDList(roleList))
|
||||
return storeList, err
|
||||
return GetStoreList4User(ctx, mobileNum, userID)
|
||||
}
|
||||
|
||||
func GetStoreRoleList(ctx *jxcontext.Context) (roleList []*authz.RoleInfo, err error) {
|
||||
|
||||
@@ -154,7 +154,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityN
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
|
||||
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
|
||||
sql := `
|
||||
SELECT t1.*, t2.name city_name
|
||||
FROM store t1
|
||||
@@ -167,6 +167,10 @@ func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, storeIDs []int) (s
|
||||
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?"
|
||||
sqlParams = append(sqlParams, mobile, mobile)
|
||||
}
|
||||
if len(shortRoleNameList) > 0 {
|
||||
sql += " OR t1.market_man_role IN (" + GenQuestionMarks(len(shortRoleNameList)) + ") OR t1.operator_role IN (" + GenQuestionMarks(len(shortRoleNameList)) + ")"
|
||||
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList)
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
|
||||
@@ -286,6 +286,8 @@ type Store struct {
|
||||
|
||||
MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名
|
||||
MarketManPhone string `orm:"size(16)" json:"marketManPhone"` // 市场负责人电话
|
||||
MarketManRole string `orm:"size(32)" json:"marketManRole"` // 市场负责人组(角色)
|
||||
|
||||
JxBrandFeeFactor int `json:"jxBrandFeeFactor"` // 京西品牌费因子
|
||||
MarketAddFeeFactor int `json:"marketAddFeeFactor"` // 市场附加费因子
|
||||
|
||||
@@ -297,6 +299,7 @@ type Store struct {
|
||||
|
||||
OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
|
||||
OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 运营人电话
|
||||
OperatorRole string `orm:"size(32)" json:"operatorRole"` // 运营人组(角色)
|
||||
}
|
||||
|
||||
func (*Store) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user