From 60f3ec9c3bc01ffed22d9fa5a9e77737f8404fd6 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 8 Aug 2019 15:46:32 +0800 Subject: [PATCH] =?UTF-8?q?+=20Store=E6=B7=BB=E5=8A=A0MarketManRole?= =?UTF-8?q?=E4=B8=8EOperatorRole=20-=20GetStoreListByMobileOrStoreIDs?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89Store.MarketManRole=E4=B8=8EOperator?= =?UTF-8?q?Role=E6=9D=A5=E5=BE=97=E5=88=B0=E9=97=A8=E5=BA=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/user2.go | 27 +++++++++++++++++++++------ business/model/dao/dao_user.go | 6 +++++- business/model/store.go | 11 +++++++---- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index fffbfeae7..00d3decbb 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -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) { diff --git a/business/model/dao/dao_user.go b/business/model/dao/dao_user.go index a64fd82da..40b66bbc3 100644 --- a/business/model/dao/dao_user.go +++ b/business/model/dao/dao_user.go @@ -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) diff --git a/business/model/store.go b/business/model/store.go index 87e8bcc1e..d5cce5e2d 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -284,10 +284,12 @@ type Store struct { Licence2Valid string `orm:"size(32)" json:"licence2Valid"` // 有效期开始 Licence2Expire string `orm:"size(32)" json:"licence2Expire"` // 有效期结束 - MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名 - MarketManPhone string `orm:"size(16)" json:"marketManPhone"` // 市场负责人电话 - JxBrandFeeFactor int `json:"jxBrandFeeFactor"` // 京西品牌费因子 - MarketAddFeeFactor int `json:"marketAddFeeFactor"` // 市场附加费因子 + 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"` // 市场附加费因子 PayeeName string `orm:"size(8)" json:"payeeName"` // 收款人姓名 PayeeAccountNo string `orm:"size(255)" json:"payeeAccountNo"` // 收款账号 @@ -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 {