a
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -497,46 +495,3 @@ func DeletedTokenInfoWithoutParam(authInfo *AuthInfo) (err error) {
|
|||||||
}
|
}
|
||||||
return err
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay"
|
"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/jxutils/ddmsg"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
beego "github.com/astaxie/beego/server/web"
|
beego "github.com/astaxie/beego/server/web"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -1371,3 +1372,46 @@ func SendQywxPeopleCount(ctx *jxcontext.Context) (err error) {
|
|||||||
}
|
}
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -433,16 +433,3 @@ func (c *Auth2Controller) GetUserByMiniInfo() {
|
|||||||
return retVal, "", err
|
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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -608,3 +608,16 @@ func (c *User2Controller) GetUserStoreAuth() {
|
|||||||
return retVal, "", err
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -3708,6 +3708,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
||||||
web.ControllerComments{
|
web.ControllerComments{
|
||||||
Method: "UpdateUserWxNoAndPercent",
|
Method: "UpdateUserWxNoAndPercent",
|
||||||
|
|||||||
Reference in New Issue
Block a user