调整依赖结构,jxutils不依赖于dao,dao依赖于jxutils
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/authz"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -201,7 +202,7 @@ func HandleOrder4Consignee(order *model.GoodsOrder) (err error) {
|
||||
if mobileNumber == "" && order.VendorUserID == "" {
|
||||
return fmt.Errorf("订单:%s手机号与平台用户标识都是空", order.VendorOrderID)
|
||||
}
|
||||
authType := jxutils.GetAuthType4Vendor(order.VendorID)
|
||||
authType := dao.GetAuthType4Vendor(order.VendorID)
|
||||
if authType == "" {
|
||||
msg := fmt.Sprintf("平台ID:%d当前不被支持,请联系开发", order.VendorID)
|
||||
globals.SugarLogger.Warn(msg)
|
||||
@@ -470,7 +471,7 @@ func AddRoles4User(ctx *jxcontext.Context, userID string, rList []*authz.RoleInf
|
||||
if err = api2.RoleMan.AddRole4User(userID, v); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if v.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
}
|
||||
} else {
|
||||
errList.AddErr(err)
|
||||
@@ -485,7 +486,7 @@ func DeleteRoles4User(ctx *jxcontext.Context, userID string, rList []*authz.Role
|
||||
if err = api2.RoleMan.DeleteRole4User(userID, v); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if v.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -504,7 +505,7 @@ func AddUsers4Role(ctx *jxcontext.Context, r *authz.RoleInfo, userIDList []strin
|
||||
if err = api2.RoleMan.AddRole4User(v, r); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if r.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -516,7 +517,7 @@ func DeleteUsers4Role(ctx *jxcontext.Context, r *authz.RoleInfo, userIDList []st
|
||||
if err = api2.RoleMan.DeleteRole4User(v, r); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if r.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -713,3 +714,66 @@ func GetSelfInfo(ctx *jxcontext.Context) (user *model.User, err error) {
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
openIDs := []string{}
|
||||
storeID := 0
|
||||
remark := ""
|
||||
|
||||
// if !globals.DisableWXAuth1 {
|
||||
// wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
|
||||
// if err == nil {
|
||||
// openIDs = []string{wxinfo.OpenID}
|
||||
// storeID = wxinfo.JxStoreID
|
||||
// }
|
||||
// }
|
||||
if globals.EnableWXAuth2 {
|
||||
userID := ""
|
||||
if mobileIsUerID {
|
||||
userID = mobile
|
||||
} else {
|
||||
userList, _, err2 := dao.GetUsers(db, model.UserTypeStoreBoss, "", nil, "", mobile, 0, -1)
|
||||
if err = err2; len(userList) > 0 {
|
||||
userID = userList[0].GetID()
|
||||
}
|
||||
}
|
||||
if userID != "" {
|
||||
authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "")
|
||||
if err = err2; err == nil {
|
||||
for _, v := range authBindList {
|
||||
openIDs = append(openIDs, v.AuthID)
|
||||
}
|
||||
}
|
||||
roleList, err2 := api2.RoleMan.GetUserRoleList(userID)
|
||||
if err = err2; err == nil && len(roleList) > 0 {
|
||||
storeID = roleList[0].StoreID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(openIDs) > 0 {
|
||||
if storeID > 0 {
|
||||
store := &model.Store{}
|
||||
store.ID = storeID
|
||||
if err = dao.GetEntity(db, store); err == nil {
|
||||
city := &model.Place{
|
||||
Code: store.CityCode,
|
||||
}
|
||||
if err = dao.GetEntity(db, city, "Code"); err == nil {
|
||||
remark = city.Name + "-" + store.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
if globals.EnableStoreWrite {
|
||||
for _, openID := range openIDs {
|
||||
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user