This commit is contained in:
suyl
2021-06-03 14:34:23 +08:00
parent 86eb5f6951
commit 71da34111c
5 changed files with 111 additions and 20 deletions

View File

@@ -1236,6 +1236,7 @@ func CreateStoreByUser(ctx *jxcontext.Context, mobile string) (id int, err error
if store.StoreLevel == "" {
store.StoreLevel = "C"
}
store.MarketManPhone = "18048531223"
dao.WrapAddIDCULDEntity(store, ctx.GetUserName())
storeList, _ := dao.GetStoreList(db, nil, nil, nil, nil, []string{mobile}, "")
if len(storeList) > 0 {
@@ -4840,6 +4841,66 @@ func AddStoreMapAudit(ctx *jxcontext.Context, storeID, vendorID int, vendorOrgCo
storeMapAudit.VendorPasswaord = vendorPasswaord
}
dao.WrapAddIDCULDEntity(storeMapAudit, ctx.GetUserName())
dao.CreateEntity(db, storeMapAudit)
if err = dao.CreateEntity(db, storeMapAudit); err == nil {
//发消息
var (
userIDMap = make(map[string]string)
)
store, _ := dao.GetStoreDetail(db, storeID, vendorID, "")
operatorRoleList := []string{store.OperatorRole, store.OperatorRole2, store.OperatorRole3}
for _, vv := range operatorRoleList {
var (
roleList []*authz.RoleInfo
)
if vv != "" {
roleList = append(roleList, autils.NewRole(vv, 0))
if userIDMap2, err := GetRolesUserList(jxcontext.AdminCtx, roleList); err == nil {
for _, w := range userIDMap2 {
for _, ww := range w {
userIDMap[ww] = ww
}
}
}
}
noticeMsg := fmt.Sprintf("您有负责的商家申请授权请尽快审核门店ID :[%d],门店名:[%s],申请平台:[%v]", store.ID, store.Name, model.VendorChineseNames[vendorID])
user2, err := dao.GetUserByID(db, "mobile", store.MarketManPhone)
if err == nil {
userIDMap[user2.UserID] = user2.UserID
for _, v := range userIDMap {
if api.DingDingAPI.GetToken() != "" {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, v, "您有商家申请授权!", noticeMsg)
}
}
}
}
}
return err
}
func AuditStoreMap(ctx *jxcontext.Context, ID int, vendorOrgCode, vendorStoreID string, auditStatus int, comment string) (err error) {
var (
db = dao.GetDB()
storeMapAudit = &model.StoreMapAudit{}
)
storeMapAudit.ID = ID
err = dao.GetEntity(db, storeMapAudit)
if err != nil {
return err
}
if auditStatus == model.StoreMapAuditStatusPass {
if storeMapAudit.VendorOrgCode == "" && vendorOrgCode == "" {
return fmt.Errorf("请选择平台账号进行绑定!")
}
if vendorStoreID == "" {
return fmt.Errorf("请输入绑定的平台门店ID")
}
}
retVal, err := GetVendorStore(ctx, storeMapAudit.VendorID, vendorOrgCode, vendorStoreID)
if err != nil {
return err
}
if retVal == nil {
return fmt.Errorf("未在平台上查询到此门店请确认平台账号和平台门店ID")
}
return err
}

View File

@@ -1,9 +1,11 @@
package cms
import (
"encoding/base64"
"errors"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
beego "github.com/astaxie/beego/server/web"
"sort"
@@ -397,6 +399,21 @@ func CreateUser(user *model.User, creatorName string) (err error) {
if user.GetEmail() == "" {
user.Email = nil
}
if user.GetMobile() != "" && user.GetName() != "" && user.GetID2() != "" {
if user.LastLoginType != "" && user.LastLoginType == alipay.AuthType {
mobile := ""
data, _ := base64.StdEncoding.DecodeString(user.GetMobile())
key, _ := base64.StdEncoding.DecodeString(alipay.AuthKey)
iv := []byte{}
iv = append(iv, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
if result, err := utils.AESCBCDecpryt(data, key, iv); err == nil && result != nil {
mobile = string(result)
}
user.Mobile = &mobile
user.UserID2 = mobile
user.Name = mobile
}
}
dao.WrapAddIDCULDEntity(user, creatorName)
user.UserID = utils.GetUUID()
user.Status = model.UserStatusNormal