+ EnableWXAuth2

This commit is contained in:
gazebo
2019-08-12 17:54:00 +08:00
parent c5a5f4777b
commit 339b60c374
6 changed files with 119 additions and 40 deletions

View File

@@ -4,21 +4,23 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"math"
"math/rand"
"regexp"
"sort"
"strings"
"time"
"io/ioutil"
"git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/baseapi/utils/routinepool"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/jx-callback/globals/api2"
"github.com/qiniu/api.v7/storage"
)
@@ -425,13 +427,36 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string) (err error) {
if db == nil {
db = dao.GetDB()
}
wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
openID := ""
storeID := 0
remark := ""
if !globals.EnableWXAuth2 {
wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
if err == nil {
openID = wxinfo.OpenID
storeID = wxinfo.JxStoreID
}
} else {
userList, err2 := dao.GetUsers(db, model.UserTypeStoreBoss, "", nil, "", mobile)
if err = err2; len(userList) > 0 {
userID := userList[0].GetID()
authBind, err2 := dao.GetAuthBind(db, userID, weixin.AuthTypeMP, "")
if err = err2; err == nil {
openID = authBind.AuthID
}
roleList, err2 := api2.RoleMan.GetUserRoleList(userID)
if err = err2; err == nil && len(roleList) > 0 {
storeID = roleList[0].StoreID
}
}
}
if err == nil {
if wxinfo.OpenID != "" {
remark := ""
if wxinfo.JxStoreID > 0 {
if openID != "" {
if storeID > 0 {
store := &model.Store{}
store.ID = wxinfo.JxStoreID
store.ID = storeID
if err = dao.GetEntity(db, store); err == nil {
city := &model.Place{
Code: store.CityCode,
@@ -442,7 +467,7 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string) (err error) {
}
}
if err == nil {
err = api.WeixinAPI.CBUpdateRemark(wxinfo.OpenID, remark)
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
}
}
}
@@ -624,4 +649,4 @@ func GetEbaiOrderGetCode(order *model.GoodsOrder) (getCode string) {
func WriteFile(fileName string, binData []byte) error {
err := ioutil.WriteFile(fileName, binData, 0666)
return err
}
}