diff --git a/business/jxstore/cms/user.go b/business/jxstore/cms/user.go index de4e57985..c7e10d889 100644 --- a/business/jxstore/cms/user.go +++ b/business/jxstore/cms/user.go @@ -84,7 +84,7 @@ func getMobileFromCtx(ctx *jxcontext.Context) (mobile string) { return mobile } -func GetMyStoreList(ctx *jxcontext.Context) (storeList []*model.Store, err error) { +func GetMyStoreList(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) { mobileNum := getMobileFromCtx(ctx) if mobileNum == "" { return nil, fmt.Errorf("不能得到用户手机号") diff --git a/business/model/dao/dao_user.go b/business/model/dao/dao_user.go index 73e10f91f..81a91a3b2 100644 --- a/business/model/dao/dao_user.go +++ b/business/model/dao/dao_user.go @@ -15,6 +15,11 @@ type StoreUserInfo struct { MembersStr string `json:"-"` } +type StoreWithCityName struct { + model.Store + CityName string `json:"cityName"` +} + func CreateWeiXins(db *DaoDB, user *legacymodel.WeiXins) (err error) { Begin(db) if err = CreateEntity(db, user); err != nil { @@ -118,10 +123,11 @@ func GetUserStoreInfo(db *DaoDB, fieldName, fieldValue string) (storeUserInfo *S return storeUserInfo, err } -func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*model.Store, err error) { +func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) { if mobile != "" { sql := ` - SELECT DISTINCT * + SELECT + DISTINCT t1.*, t2.name city_name FROM ( SELECT * FROM store t1 @@ -133,6 +139,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*model.Store, e LEFT JOIN weixins t3 ON t3.parentid = t2.id WHERE (t2.tel = ? OR t3.tel = ?) ) t1 + LEFT JOIN place t2 ON t2.code = t1.city_code WHERE t1.deleted_at = ? ORDER BY t1.name` sqlParams := []interface{}{