This commit is contained in:
suyl
2021-08-31 17:11:11 +08:00
parent dd46bff315
commit 894ecf2277
5 changed files with 66 additions and 58 deletions

View File

@@ -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
}