aa
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -500,9 +501,42 @@ func DeletedTokenInfoWithoutParam(authInfo *AuthInfo) (err error) {
|
|||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
model.User
|
model.User
|
||||||
WxInfo string `json:"wxInfo"`
|
WxInfo string `json:"wxInfo"`
|
||||||
BrandMaps string `json:"brandMaps"`
|
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) {
|
func GetUserInfo(ctx *jxcontext.Context) (userInfo *UserInfo, err error) {
|
||||||
return nil, err
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user