aa
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package alipay
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/baseapi/platformapi/alipayapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthType = "alipaycode"
|
||||
|
||||
AuthKey = "GHp3ojlVYRRu2XID4FX2ew=="
|
||||
)
|
||||
|
||||
type Auther struct {
|
||||
@@ -33,24 +33,10 @@ func (a *Auther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx,
|
||||
if err == nil {
|
||||
//userInfo, err2 := api.AliPayAPI.UserInfoShare(tokenInfo.AccessToken)
|
||||
//if err = err2; err == nil {
|
||||
//if authBindEx, err = a.UnionFindAuthBind(AuthType, api.AliPayAPI.GetAppID(), nil, userInfo.UserID, "", userInfo); err == nil {
|
||||
// authBindEx.UserHint = &auth2.UserBasic{
|
||||
// Name: userInfo.NickName,
|
||||
// Avatar: userInfo.Avatar,
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
authBindEx = &auth2.AuthBindEx{}
|
||||
authBindEx.Type = AuthType
|
||||
authBindEx.TypeID = globals.AliKey
|
||||
authBindEx.AuthID = tokenInfo.UserID
|
||||
authBindEx.AuthID2 = tokenInfo.AlipayUserID
|
||||
authBindEx.Status = model.YES
|
||||
if data, err2 := json.Marshal(tokenInfo); err2 == nil {
|
||||
authBindEx.DetailData = string(data)
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthType, api.AliPayAPI.GetAppID(), nil, tokenInfo.UserID, tokenInfo.AlipayUserID, tokenInfo); err == nil {
|
||||
authBindEx.AuthSecret = tokenInfo.AccessToken
|
||||
authBindEx.AuthSecret2 = tokenInfo.RefreshToken
|
||||
}
|
||||
authBindEx.AuthSecret = tokenInfo.AccessToken
|
||||
authBindEx.AuthSecret2 = tokenInfo.RefreshToken
|
||||
}
|
||||
return authBindEx, err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1118,3 +1118,21 @@ func (c *StoreController) AddStoreMapAudit() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 审核商户申请授权
|
||||
// @Description 审核商户申请授权
|
||||
// @Param token header string true "认证token"
|
||||
// @Param ID formData int true "申请记录的ID"
|
||||
// @Param vendorOrgCode formData string false "厂商内组织代码"
|
||||
// @Param vendorStoreID formData string false "平台门店ID"
|
||||
// @Param auditStatus formData int false "审核标志,1为通过,-1为不通过"
|
||||
// @Param comment formData string false "不通过原因"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /AuditStoreMap [post]
|
||||
func (c *StoreController) AuditStoreMap() {
|
||||
c.callAuditStoreMap(func(params *tStoreAuditStoreMapParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.AuditStoreMap(params.Ctx, params.ID, params.VendorOrgCode, params.VendorStoreID, params.AuditStatus, params.Comment)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2106,6 +2106,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "AuditStoreMap",
|
||||
Router: `/AuditStoreMap`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "AddStoreCategoryMap",
|
||||
|
||||
Reference in New Issue
Block a user