diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index 83875e419..705fa3332 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/base64" "errors" - "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - "git.rosy.net.cn/jx-callback/business/partner" "regexp" "strings" "time" @@ -497,46 +495,3 @@ func DeletedTokenInfoWithoutParam(authInfo *AuthInfo) (err error) { } return err } - -type UserInfo struct { - model.User - WxInfo string `json:"wxInfo"` - BrandMaps []*BrandMap `json:"brandMaps"` -} - -type BrandMap struct { - BrandID int `orm:"column(brand_id)" json:"brandID"` - Name string `json:"name"` - ManageCount int `json:"managerCount"` - Balance int `json:"balance"` -} - -func GetUserInfo(ctx *jxcontext.Context) (userInfo *UserInfo, err error) { - var ( - db = dao.GetDB() - ) - sql := ` - SELECT a.*, b.detail_data wx_info - FROM user a - LEFT JOIN auth_bind b ON a.user_id = b.user_id AND b.type_id = ? AND b.type = ? - WHERE a.user_id = ? - ` - sqlParams := []interface{}{"wx2bb99eb5d2c9b82c", "weixinsns", ctx.GetUserID()} - if err = dao.GetRow(db, &userInfo, sql, sqlParams); err == nil && userInfo != nil { - if brandUsers, _ := dao.GetBrandUser(db, 0, ctx.GetUserID()); len(brandUsers) > 0 { - for _, v := range brandUsers { - brands, _ := dao.GetBrands(db, "", v.BrandID) - balance, _ := partner.CurStoreAcctManager.GetBrandBalance(v.BrandID) - brandMap := &BrandMap{ - BrandID: v.BrandID, - Name: brands[0].Name, - Balance: balance, - } - stores, _ := dao.GetStoreList(db, nil, nil, nil, []int{v.BrandID}, nil, "") - brandMap.ManageCount = len(stores) - userInfo.BrandMaps = append(userInfo.BrandMaps, brandMap) - } - } - } - return userInfo, err -} diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index cd4551fa0..6e1cd21ef 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -9,6 +9,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/qywxapi" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay" "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" + "git.rosy.net.cn/jx-callback/business/partner" beego "github.com/astaxie/beego/server/web" "sort" "strings" @@ -1371,3 +1372,46 @@ func SendQywxPeopleCount(ctx *jxcontext.Context) (err error) { } return err } + +type UserInfo struct { + model.User + WxInfo string `json:"wxInfo"` + BrandMaps []*BrandMap `json:"brandMaps"` +} + +type BrandMap struct { + BrandID int `orm:"column(brand_id)" json:"brandID"` + Name string `json:"name"` + ManageCount int `json:"managerCount"` + Balance int `json:"balance"` +} + +func GetUserInfo(ctx *jxcontext.Context) (userInfo *UserInfo, err error) { + var ( + db = dao.GetDB() + ) + sql := ` + SELECT a.*, b.detail_data wx_info + FROM user a + LEFT JOIN auth_bind b ON a.user_id = b.user_id AND b.type_id = ? AND b.type = ? + WHERE a.user_id = ? + ` + sqlParams := []interface{}{"wx2bb99eb5d2c9b82c", "weixinsns", ctx.GetUserID()} + if err = dao.GetRow(db, &userInfo, sql, sqlParams); err == nil && userInfo != nil { + if brandUsers, _ := dao.GetBrandUser(db, 0, ctx.GetUserID()); len(brandUsers) > 0 { + for _, v := range brandUsers { + brands, _ := dao.GetBrands(db, "", v.BrandID) + balance, _ := partner.CurStoreAcctManager.GetBrandBalance(v.BrandID) + brandMap := &BrandMap{ + BrandID: v.BrandID, + Name: brands[0].Name, + Balance: balance, + } + stores, _ := dao.GetStoreList(db, nil, nil, nil, []int{v.BrandID}, nil, "") + brandMap.ManageCount = len(stores) + userInfo.BrandMaps = append(userInfo.BrandMaps, brandMap) + } + } + } + return userInfo, err +} diff --git a/controllers/auth2.go b/controllers/auth2.go index 2ea828f14..d195230d1 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -433,16 +433,3 @@ func (c *Auth2Controller) GetUserByMiniInfo() { return retVal, "", err }) } - -// @Title 得到自己登录的信息 -// @Description 得到自己登录的信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserInfo [get] -func (c *Auth2Controller) GetUserInfo() { - c.callGetUserInfo(func(params *tAuth2GetUserInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = auth2.GetUserInfo(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index bce3feeec..0ccd739f2 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -608,3 +608,16 @@ func (c *User2Controller) GetUserStoreAuth() { return retVal, "", err }) } + +// @Title 得到自己登录的信息 +// @Description 得到自己登录的信息 +// @Param token header string true "认证token" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetUserInfo [get] +func (c *Auth2Controller) GetUserInfo() { + c.callGetUserInfo(func(params *tAuth2GetUserInfoParams) (retVal interface{}, errCode string, err error) { + retVal, err = cms.GetUserInfo(params.Ctx) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 08daaed2b..a964834f8 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -3708,6 +3708,15 @@ func init() { Filters: nil, Params: nil}) + web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], + web.ControllerComments{ + Method: "GetUserInfo", + Router: `/GetUserInfo`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], web.ControllerComments{ Method: "UpdateUserWxNoAndPercent",