Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -33,12 +33,13 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
AuthTypeNone = ""
|
||||
AuthTypePassword = "localpass"
|
||||
AuthTypeEmail = "email"
|
||||
AuthTypeMobile = "mobile"
|
||||
AuthTypeWXApp = "weixinapp" //微信小程序
|
||||
AuthTypeWXMini = "weixinmini" //微信小程序
|
||||
AuthTypeNone = ""
|
||||
AuthTypePassword = "localpass"
|
||||
AuthTypeEmail = "email"
|
||||
AuthTypeMobile = "mobile"
|
||||
AuthTypeWXApp = "weixinapp" //微信小程序(商家版)
|
||||
AuthTypeWXAppCaishi = "weixinappcs" //微信小程序(用户)
|
||||
AuthTypeWXMini = "weixinmini" //微信小程序
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -305,7 +306,7 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
}
|
||||
}
|
||||
//微信APP端登录
|
||||
if authType == AuthTypeWXApp {
|
||||
if authType == AuthTypeWXApp || authType == AuthTypeWXAppCaishi {
|
||||
appID := strings.Split(authSecret, ",")[0]
|
||||
if appID == model.JXC4ClientAppID && authInfo.AuthBindInfo.UserID != "" {
|
||||
binds, err := dao.GetUserBindAuthInfo(dao.GetDB(), authInfo.AuthBindInfo.UserID, 0, nil, "", "", []string{model.JXC4ClientAppID})
|
||||
@@ -335,7 +336,7 @@ func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authI
|
||||
return LoginInternal(ctx, authType, authID, authIDType, authSecret)
|
||||
}
|
||||
|
||||
// 抖音用户信息解密
|
||||
// TikTokDecryptInfo 抖音用户信息解密
|
||||
type TikTokDecryptInfo struct {
|
||||
CountryCode string `json:"countryCode"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
@@ -346,7 +347,13 @@ type TikTokDecryptInfo struct {
|
||||
} `json:"watermark"`
|
||||
}
|
||||
|
||||
func DecryptUserMsg(sessionKey, iv, msg string) (string, error) {
|
||||
// KuaiShouInfo 抖音用户信息解密
|
||||
type KuaiShouInfo struct {
|
||||
CountryCode string `json:"countryCode"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
}
|
||||
|
||||
func DecryptUserMsg(sessionKey, iv, msg, loginType string) (string, error) {
|
||||
decodeMsg, err := base64.StdEncoding.DecodeString(msg)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -364,11 +371,22 @@ func DecryptUserMsg(sessionKey, iv, msg string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
result := &TikTokDecryptInfo{}
|
||||
if err := json.Unmarshal(userInfo, result); err != nil {
|
||||
return "", err
|
||||
|
||||
switch loginType {
|
||||
case "tiktokmini":
|
||||
result := &TikTokDecryptInfo{}
|
||||
if err := json.Unmarshal(userInfo, result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return result.PhoneNumber, nil
|
||||
case "kuaishoumini":
|
||||
result := &KuaiShouInfo{}
|
||||
if err := json.Unmarshal(userInfo, result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return result.PhoneNumber, nil
|
||||
}
|
||||
return result.PhoneNumber, nil
|
||||
return "", ErrIllegalAuthType
|
||||
}
|
||||
|
||||
// 通过临时TOKEN绑定新创建的用户
|
||||
|
||||
@@ -16,20 +16,20 @@ const (
|
||||
AuthTypeTiktokMini = "tiktokmini" // 抖音小程序
|
||||
)
|
||||
|
||||
type TiktopMiniAuther struct {
|
||||
type TiktokMiniAuther struct {
|
||||
authprovider.DefAuther
|
||||
}
|
||||
|
||||
var (
|
||||
AutherObjMini *TiktopMiniAuther
|
||||
AutherObjMini *TiktokMiniAuther
|
||||
)
|
||||
|
||||
func init() {
|
||||
AutherObjMini = new(TiktopMiniAuther)
|
||||
AutherObjMini = new(TiktokMiniAuther)
|
||||
auth2.RegisterAuther(AuthTypeTiktokMini, AutherObjMini)
|
||||
}
|
||||
|
||||
func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
func (a *TiktokMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
//appID, realCode := splitCode(code)
|
||||
//sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
|
||||
sessionInfo, err := api.TiktokApi.GetTiktokOauth(code)
|
||||
@@ -44,7 +44,7 @@ func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.A
|
||||
}
|
||||
|
||||
// 特殊接口
|
||||
func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
func (a *TiktokMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
var sessionKey string
|
||||
appID, jsCode := weixin.SplitJsCode(jsCode)
|
||||
if jsCode != "" {
|
||||
@@ -74,7 +74,7 @@ func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encrypt
|
||||
return string(decryptedData), nil
|
||||
}
|
||||
|
||||
func (a *TiktopMiniAuther) GetUserType() (userType int8) {
|
||||
func (a *TiktokMiniAuther) GetUserType() (userType int8) {
|
||||
return model.UserTypeStoreBoss
|
||||
}
|
||||
|
||||
100
business/auth2/authprovider/kuaishou/kuaishou_mini.go
Normal file
100
business/auth2/authprovider/kuaishou/kuaishou_mini.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package kuaishou
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthTypeKuaiShouMini = "kuaishoumini" // 快手小程序
|
||||
)
|
||||
|
||||
type KuaiShouMiniAuther struct {
|
||||
authprovider.DefAuther
|
||||
}
|
||||
|
||||
var (
|
||||
AutherObjMini *KuaiShouMiniAuther
|
||||
)
|
||||
|
||||
func init() {
|
||||
AutherObjMini = new(KuaiShouMiniAuther)
|
||||
auth2.RegisterAuther(AuthTypeKuaiShouMini, AutherObjMini)
|
||||
}
|
||||
|
||||
func (a *KuaiShouMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
//appID, realCode := splitCode(code)
|
||||
//sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
|
||||
sessionInfo, openId, err := api.KuaiShouApi.AuthLoginKuaiShou(code)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeKuaiShouMini, api.KuaiShouApi.GetAppID(), []string{AuthTypeKuaiShouMini}, openId, "", sessionInfo); err == nil {
|
||||
authBindEx.UserData = sessionInfo
|
||||
}
|
||||
return authBindEx, err
|
||||
}
|
||||
|
||||
//func (a *KuaiShouMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
// var sessionKey string
|
||||
// appID, jsCode := weixin.SplitJsCode(jsCode)
|
||||
// if jsCode != "" {
|
||||
// sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
|
||||
// if err == nil {
|
||||
// // if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
|
||||
// // if authBindEx.UserID != authInfo.GetID() {
|
||||
// // return "", fmt.Errorf("jsCode与token不匹配")
|
||||
// // }
|
||||
// // } else {
|
||||
// // return "", err
|
||||
// // }
|
||||
// sessionKey = sessionInfo.SessionKey
|
||||
// } else {
|
||||
// return "", err
|
||||
// }
|
||||
// } else {
|
||||
// if authInfo.AuthBindInfo.Type != AuthTypeKuaiShouMini {
|
||||
// // return "", ErrAuthTypeShouldBeMini
|
||||
// }
|
||||
// sessionKey = authInfo.AuthBindInfo.UserData.(string)
|
||||
// }
|
||||
// decryptedData, err := weixinapi.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// return string(decryptedData), nil
|
||||
//}
|
||||
//
|
||||
//func (a *KuaiShouMiniAuther) GetUserType() (userType int8) {
|
||||
// return model.UserTypeStoreBoss
|
||||
//}
|
||||
//
|
||||
//func getWxApp(appID string) (miniApi *weixinapi.API) {
|
||||
// miniApi = api.WeixinMiniAPI
|
||||
// if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
|
||||
// miniApi = api.WeixinMiniAPI2
|
||||
// }
|
||||
// if len(appID) > 0 && appID == api.WeixinMiniAppIDsc {
|
||||
// miniApi = api.WeixinMiniAPIsc
|
||||
// }
|
||||
// return miniApi
|
||||
//}
|
||||
//
|
||||
//func getTikTokApp(appID string) (TikTokMini *tiktok.API) {
|
||||
// TikTokMini = api.TiktokApi
|
||||
// if len(appID) > 0 && appID == api.TiktokJXDJApiID {
|
||||
// TikTokMini = api.TiktokJXDJApi
|
||||
// }
|
||||
// return TikTokMini
|
||||
//}
|
||||
//func splitCode(code string) (appID, realCode string) {
|
||||
// str := strings.Split(code, "&")
|
||||
// if len(str) == 2 {
|
||||
// appID = str[1]
|
||||
// realCode = str[0]
|
||||
// } else {
|
||||
// globals.SugarLogger.Warnf("splitCode abnormal code:%s", code)
|
||||
// }
|
||||
// return appID, realCode
|
||||
//}
|
||||
@@ -2,7 +2,6 @@ package weixin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
@@ -11,10 +10,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AuthTypeWeixin = "wxqrcode" // 微信扫码
|
||||
AuthTypeMP = "weixinsns" // 公众号
|
||||
AuthTypeWXNative = "wxnative" // 微信APP
|
||||
AuthTypeWxApp = "weixinapp" //app微信登录
|
||||
AuthTypeWeixin = "wxqrcode" // 微信扫码
|
||||
AuthTypeMP = "weixinsns" // 公众号
|
||||
AuthTypeWXNative = "wxnative" // 微信APP
|
||||
AuthTypeWxApp = "weixinapp" //app微信登录(商家版)
|
||||
AuthTypeWxAppCaishi = "weixinappcs" //app微信登录(用户版)
|
||||
)
|
||||
|
||||
type Auther struct {
|
||||
@@ -23,10 +23,11 @@ type Auther struct {
|
||||
}
|
||||
|
||||
var (
|
||||
AutherObjWX *Auther
|
||||
AutherObjMP *Auther
|
||||
AutherObjNative *Auther
|
||||
AutherObjApp *Auther
|
||||
AutherObjWX *Auther
|
||||
AutherObjMP *Auther
|
||||
AutherObjNative *Auther
|
||||
AutherObjApp *Auther
|
||||
AutherObjCaiShiApp *Auther
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -53,6 +54,11 @@ func init() {
|
||||
authType: AuthTypeWxApp,
|
||||
}
|
||||
auth2.RegisterAuther(AuthTypeWxApp, AutherObjApp)
|
||||
|
||||
AutherObjCaiShiApp = &Auther{
|
||||
authType: AuthTypeWxAppCaishi,
|
||||
}
|
||||
auth2.RegisterAuther(AuthTypeWxAppCaishi, AutherObjCaiShiApp)
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(id, secret string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
@@ -89,7 +95,7 @@ func (a *Auther) VerifySecret(id, secret string) (authBindEx *auth2.AuthBindEx,
|
||||
if err == nil {
|
||||
wxUserinfo, err2 := a.getAPI().SNSGetUserInfo(accessToken, openID)
|
||||
if err = err2; err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(a.authType, a.getAPI().GetAppID(), []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini, AuthTypeWXNative, AuthTypeWxApp}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(a.authType, a.getAPI().GetAppID(), []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini, AuthTypeWXNative, AuthTypeWxApp, AuthTypeWxAppCaishi}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
Name: wxUserinfo.NickName,
|
||||
Avatar: wxUserinfo.HeadImgURL,
|
||||
@@ -107,6 +113,9 @@ func (a *Auther) getAPI() *weixinapi.API {
|
||||
if a.authType == AuthTypeWxApp {
|
||||
return api.WeixinApp
|
||||
}
|
||||
if a.authType == AuthTypeWxAppCaishi {
|
||||
return api.WeixinApp2
|
||||
}
|
||||
return api.WeixinAPI
|
||||
}
|
||||
|
||||
|
||||
@@ -3526,7 +3526,7 @@ func GetStoreCategoryMap(ctx *jxcontext.Context, parentID, level int, storeID in
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != weixin.AuthTypeWxAppCaishi && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
return storeCatMaps, err
|
||||
}
|
||||
//表示没有门店分类
|
||||
@@ -3542,7 +3542,7 @@ func GetStoreCategoryMapNoDefault(ctx *jxcontext.Context, parentID, level int, s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != weixin.AuthTypeWxAppCaishi && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
return storeCatMaps, err
|
||||
}
|
||||
return storeCatMaps, err
|
||||
@@ -5512,7 +5512,7 @@ func GetBrandCategoryMap(ctx *jxcontext.Context, parentID, level int, brandID in
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != weixin.AuthTypeWxAppCaishi && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
return brandCatMaps, err
|
||||
}
|
||||
return brandCatMaps, err
|
||||
|
||||
@@ -5896,7 +5896,7 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
return false, err
|
||||
}
|
||||
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != weixin.AuthTypeWxAppCaishi && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
authInfo, err := ctx.GetV2AuthInfo()
|
||||
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
|
||||
if len(storeAudits) > 0 {
|
||||
@@ -5974,7 +5974,7 @@ func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos [
|
||||
return false, err
|
||||
}
|
||||
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != weixin.AuthTypeWxAppCaishi && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
authInfo, err := ctx.GetV2AuthInfo()
|
||||
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
|
||||
if len(storeAudits) > 0 {
|
||||
|
||||
@@ -504,7 +504,7 @@ func GetMyStoreListNew(ctx *jxcontext.Context, version string) (storesInfo inter
|
||||
if !auth2.IsV2Token(ctx.GetToken()) {
|
||||
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
|
||||
}
|
||||
if ctx.GetLoginType() == weixin.AuthTypeWxApp {
|
||||
if ctx.GetLoginType() == weixin.AuthTypeWxApp || ctx.GetLoginType() == weixin.AuthTypeWxAppCaishi {
|
||||
if configs, _ := dao.QueryConfigs(dao.GetDB(), "checkversion", model.ConfigTypeSys, ""); len(configs) > 0 {
|
||||
if version == "" || configs[0].Value != version {
|
||||
return nil, "", fmt.Errorf("当前APP版本过旧,数据显示有错误,请到'京西菜市'公众号下载最新版本APP!")
|
||||
|
||||
@@ -2,6 +2,8 @@ package ddmsg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/enterprise_msg"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
@@ -32,7 +34,14 @@ func SendUserMessage(msgType, userID, title, content string) (err error) {
|
||||
if len(content) > dingdingapi.MaxWorkContentLen {
|
||||
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
||||
}
|
||||
err = SendDDUserMessage(msgType, auth.AuthID, title, content)
|
||||
if err := SendDDUserMessage(msgType, auth.AuthID, title, content); err != nil {
|
||||
userInfo, err := dao.GetUserByID(dao.GetDB(), "user_id", auth.UserID)
|
||||
if err != nil || userInfo == nil {
|
||||
globals.SugarLogger.Errorf("get user err %v", err)
|
||||
continue
|
||||
}
|
||||
enterprise_msg.SendUserMessage(*userInfo.Mobile, title, content, content)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -43,6 +52,7 @@ func SendUserMessage(msgType, userID, title, content string) (err error) {
|
||||
if err != nil {
|
||||
globals.SugarLogger.Infof("SendUserMessage userID:%s, title:%s, content:%s failed with error:%v", userID, title, content, err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
110
business/jxutils/enterprise_msg/enterprise_send_msg.go
Normal file
110
business/jxutils/enterprise_msg/enterprise_send_msg.go
Normal file
@@ -0,0 +1,110 @@
|
||||
package enterprise_msg
|
||||
|
||||
import (
|
||||
enterprise "git.rosy.net.cn/baseapi/platformapi/enterprise_wechat"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var enterpriseUserIdMap = map[string]string{
|
||||
"15881105234": "WenShiQi",
|
||||
"15928865396": "HeJiaMeng2",
|
||||
"18981810340": "LiuLei",
|
||||
"18048531223": "ShiFeng2",
|
||||
"18080188338": "ShiFeng",
|
||||
"18744776542": "WuTingQi",
|
||||
"15729837802": "ZhangShuWei",
|
||||
"17358644830": "ShengTianBanZi1376",
|
||||
"18982250714": "LaoZhaoTongXue",
|
||||
"15680070110": "LiRongWei",
|
||||
"18780171617": "TianQinXin",
|
||||
"17381914617": "TianQinXin2",
|
||||
"18583684218": "JingXiCaiShi-YanXiaoKang18583684218",
|
||||
"17381580510": "YouRan",
|
||||
}
|
||||
|
||||
// SendUserMessage 发送文本卡片
|
||||
func SendUserMessage(phone, title, description, url string) error {
|
||||
// 根据电话号码获取用户touserId
|
||||
var enterpriseUserId = ""
|
||||
var err error = nil
|
||||
if id, ok := enterpriseUserIdMap[phone]; ok {
|
||||
enterpriseUserId = id
|
||||
} else {
|
||||
enterpriseUserId, err = api.EnterpriseChatMin.GetUserIdByMobile(phone)
|
||||
if err != nil {
|
||||
enterpriseUserId = enterpriseUserIdMap["18981810340"]
|
||||
}
|
||||
enterpriseUserIdMap[phone] = enterpriseUserId
|
||||
}
|
||||
|
||||
err = api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{
|
||||
Touser: enterpriseUserId,
|
||||
Msgtype: enterprise.MsgTypeText,
|
||||
Agentid: enterprise.EnterpriseAgentid,
|
||||
Text: struct {
|
||||
Content string `json:"content"`
|
||||
}{Content: title + ":" + description},
|
||||
Safe: 0,
|
||||
EnableIdTrans: 0,
|
||||
EnableDuplicateCheck: 0,
|
||||
DuplicateCheckInterval: 0,
|
||||
})
|
||||
return err
|
||||
//
|
||||
//msg := &enterprise.EnterpriseSendMsgReq{
|
||||
// Touser: enterpriseUserId,
|
||||
// Msgtype: enterprise.MsgTypeTextCard,
|
||||
// Agentid: enterprise.EnterpriseAgentid,
|
||||
// Textcard: enterprise.TextCardObject{
|
||||
// Title: title,
|
||||
// Description: description,
|
||||
// Url: url,
|
||||
// Btntxt: "详情",
|
||||
// },
|
||||
//}
|
||||
//return api.EnterpriseChatMin.SendMsgToUser(msg)
|
||||
}
|
||||
|
||||
// SendUserMessageText 发送文本消息
|
||||
func SendUserMessageText() {
|
||||
|
||||
}
|
||||
|
||||
func SendEnterpriseUserMessage(msgType, phone, title, content string) (err error) {
|
||||
// 根据电话号码获取用户touserId
|
||||
enterpriseUserId, err := api.EnterpriseChatMin.GetUserIdByMobile(phone)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("SendEnterpriseUserMessage err1 %v", err)
|
||||
return err
|
||||
}
|
||||
if msgType == enterprise.MsgTypeText {
|
||||
err = api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{
|
||||
Touser: enterpriseUserId,
|
||||
Msgtype: enterprise.MsgTypeText,
|
||||
Agentid: enterprise.EnterpriseAgentid,
|
||||
Text: struct {
|
||||
Content string `json:"content"`
|
||||
}{Content: title + ":" + content},
|
||||
Safe: 0,
|
||||
EnableIdTrans: 0,
|
||||
EnableDuplicateCheck: 0,
|
||||
DuplicateCheckInterval: 0,
|
||||
})
|
||||
} else if msgType == enterprise.MsgTypeMarkdown {
|
||||
err = api.EnterpriseChatMin.SendMsgToUserMarkdown(&enterprise.SendMarkdownMsgReq{
|
||||
Touser: enterpriseUserId,
|
||||
Msgtype: enterprise.MsgTypeMarkdown,
|
||||
Agentid: enterprise.EnterpriseAgentid,
|
||||
Markdown: struct {
|
||||
Content string `json:"content"`
|
||||
}{Content: title + ":" + content},
|
||||
Safe: 0,
|
||||
EnableIdTrans: 0,
|
||||
EnableDuplicateCheck: 0,
|
||||
DuplicateCheckInterval: 0,
|
||||
})
|
||||
}
|
||||
globals.SugarLogger.Errorf("SendEnterpriseUserMessage err2 %v", err)
|
||||
return err
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package msg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/enterprise_msg"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||
@@ -30,7 +31,12 @@ func SendUserMessage(msgType string, user *model.User, title, content string) (e
|
||||
if title != "" {
|
||||
content = title + "\n" + content
|
||||
}
|
||||
err = ddmsg.SendDDUserMessage(msgType, auth.AuthID, title, content)
|
||||
if err2 := ddmsg.SendDDUserMessage(msgType, auth.AuthID, title, content); err2 != nil {
|
||||
if msgType == "txt" {
|
||||
msgType = "text"
|
||||
}
|
||||
err = enterprise_msg.SendEnterpriseUserMessage(msgType, auth.AuthID, title, content)
|
||||
}
|
||||
} else if auth.Type == weixin.AuthTypeMP && msgType != dingdingapi.MsgTypeMarkdown {
|
||||
err = weixinmsg.NotifyStoreStatusChanged(auth.AuthID, title, content)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/enterprise_msg"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -508,7 +509,12 @@ func SendMessage(t *BaseTask) {
|
||||
} else {
|
||||
content += ",\n" + t.Error()
|
||||
}
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
|
||||
|
||||
if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content); err != nil {
|
||||
globals.SugarLogger.Errorf("==============errr ddd %v", err)
|
||||
err2 := enterprise_msg.SendUserMessage(authInfo.Mobile, "异步任务完成", "", content)
|
||||
globals.SugarLogger.Errorf("==============errr ddd %v", err2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,10 @@ fnCode = "uDEyAmTbrfS2qjYbgi20Jm"
|
||||
fnMerchantId= "51658"
|
||||
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
|
||||
|
||||
# 快手授权地址
|
||||
kuaiShouAppId = "ks680887971696897880"
|
||||
kuaiShouAppSecret = "1wShCPqUzhg8W1vcb8OdvA"
|
||||
|
||||
#uu跑腿
|
||||
uuAppID="55c4542ae60e4d348edcfc93b06dd302"
|
||||
uuAppKey="76b362c06b1b4baa9e47bab6387a5356"
|
||||
@@ -343,6 +347,10 @@ fnCode = "uDEyAmTbrfS2qjYbgi20Jm"
|
||||
fnMerchantId= "51658"
|
||||
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
|
||||
|
||||
# 快手授权地址
|
||||
kuaiShouAppId = "ks680887971696897880"
|
||||
kuaiShouAppSecret = "1wShCPqUzhg8W1vcb8OdvA"
|
||||
|
||||
#uu跑腿
|
||||
uuAppID="55c4542ae60e4d348edcfc93b06dd302"
|
||||
uuAppKey="76b362c06b1b4baa9e47bab6387a5356"
|
||||
@@ -456,6 +464,11 @@ fnAppSecret = "a8248088-a742-4c33-a0db-03aeae00ca7d"
|
||||
fnMerchantId = "51658"
|
||||
fnCode = "uDEyAmTbrfS2qjYbgi20Jm"
|
||||
fnCallbackURL = "http://callback-jxgy.jxc4.com/fn/msg"
|
||||
|
||||
# 快手授权地址
|
||||
kuaiShouAppId = "ks680887971696897880"
|
||||
kuaiShouAppSecret = "1wShCPqUzhg8W1vcb8OdvA"
|
||||
|
||||
#uu跑腿
|
||||
uuAppID="55c4542ae60e4d348edcfc93b06dd302"
|
||||
uuAppKey="76b362c06b1b4baa9e47bab6387a5356"
|
||||
@@ -654,6 +667,11 @@ fnAppSecret = "c1e6c280-e618-4103-9d0a-673bc54fb22e"
|
||||
fnCode = "uDEyAmTbrfS2qjYbgi20Jm"
|
||||
fnMerchantId= "51658"
|
||||
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
|
||||
|
||||
# 快手授权地址
|
||||
kuaiShouAppId = "ks680887971696897880"
|
||||
kuaiShouAppSecret = "1wShCPqUzhg8W1vcb8OdvA"
|
||||
|
||||
#uu跑腿
|
||||
uuAppID="55c4542ae60e4d348edcfc93b06dd302"
|
||||
uuAppKey="76b362c06b1b4baa9e47bab6387a5356"
|
||||
|
||||
@@ -92,19 +92,20 @@ func (c *Auth2Controller) SendVerifyCode() {
|
||||
// @Param iv formData string true "加密字符偏移量"
|
||||
// @Param sessionKey formData string true "加密key"
|
||||
// @Param msg formData string true "加密消息"
|
||||
// @Param loginType formData string true "登录类型兼容抖音登录/快手[tiktokmini/kuaishoumini]"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /TiktokDecrypt [post]
|
||||
func (c *Auth2Controller) TiktokDecrypt() {
|
||||
c.callTiktokDecrypt(func(params *tAuth2TiktokDecryptParams) (interface{}, string, error) {
|
||||
phone, err := auth2.DecryptUserMsg(params.SessionKey, params.Iv, params.Msg)
|
||||
phone, err := auth2.DecryptUserMsg(params.SessionKey, params.Iv, params.Msg, params.LoginType)
|
||||
return phone, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 登录接口
|
||||
// @Description 登录接口(微信与公众号登录不能直接调用此接口)
|
||||
// @Param authType formData string true "登录类型,当前支持[localpass:本地账号密码,mobile:手机短信,wxqrcode:微信登录,weixinsns:微信公众号,weixinmini;小程序,wxnative:微信APP,ddstaff:钉钉企业,ddqrcode:钉钉扫码,alipaycode:支付宝小程序]"
|
||||
// @Param authType formData string true "登录类型,当前支持[kuaishou:快手授权登录,localpass:本地账号密码,mobile:手机短信,wxqrcode:微信登录,weixinsns:微信公众号,weixinmini;小程序,wxnative:微信APP,ddstaff:钉钉企业,ddqrcode:钉钉扫码,alipaycode:支付宝小程序]"
|
||||
// @Param authSecret formData string true "不同登录类型的登录秘密,如果是localpass登录类型,是md5后的值(空串不要md5)"
|
||||
// @Param authID formData string false "登录ID,登录类型为localpass时依赖于authIDType,其它为相应登录类型的id"
|
||||
// @Param authIDType formData string false "只有在登录类型为localpass时,才有意义,分别为:userid2:用户名,email,mobile"
|
||||
@@ -121,7 +122,7 @@ func (c *Auth2Controller) Login() {
|
||||
if params.AuthType == weixin.AuthTypeMini {
|
||||
params.AuthSecret = GetComposedCode(&c.Controller, params.AuthSecret)
|
||||
}
|
||||
if params.AuthType == weixin.AuthTypeWxApp {
|
||||
if params.AuthType == weixin.AuthTypeWxApp || params.AuthType == weixin.AuthTypeWxAppCaishi {
|
||||
//if configs, _ := dao.QueryConfigs(dao.GetDB(), "checkversion", model.ConfigTypeSys, ""); len(configs) > 0 {
|
||||
// if params.Version == "" || configs[0].Value != params.Version {
|
||||
// return nil, "", fmt.Errorf("当前APP版本过旧,数据显示有错误,请到'京西菜市'公众号下载最新版本APP!")
|
||||
|
||||
@@ -39,7 +39,7 @@ func (c *User2Controller) RegisterUser() {
|
||||
)
|
||||
if params.AuthToken != "" {
|
||||
inAuthInfo, err = auth2.GetTokenInfo(params.AuthToken)
|
||||
if inAuthInfo.AuthBindInfo.Type == weixin.AuthTypeWxApp {
|
||||
if inAuthInfo.AuthBindInfo.Type == weixin.AuthTypeWxApp || inAuthInfo.AuthBindInfo.Type == weixin.AuthTypeWxAppCaishi {
|
||||
if configs, _ := dao.QueryConfigs(dao.GetDB(), "checkversion", model.ConfigTypeSys, ""); len(configs) > 0 {
|
||||
if params.Version == "" || configs[0].Value != params.Version {
|
||||
return nil, "", fmt.Errorf("当前APP版本过旧,数据显示有错误,请到'京西菜市'公众号下载最新版本APP!")
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/ali_logistics_query"
|
||||
enterprise "git.rosy.net.cn/baseapi/platformapi/enterprise_wechat"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/kuaishou_mini"
|
||||
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok"
|
||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
@@ -79,7 +80,8 @@ var (
|
||||
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
||||
WeixinMiniAPIsc *weixinapi.API //小程序商超
|
||||
WeixinMiniAPIPrint *weixinapi.API //小程序打印机
|
||||
WeixinApp *weixinapi.API // app微信登录
|
||||
WeixinApp *weixinapi.API // app微信登录(商家端App微信授权)
|
||||
WeixinApp2 *weixinapi.API // app微信登录(菜市端App微信授权)
|
||||
WeixinMiniAppID2 string
|
||||
WeixinMiniAppID3 string
|
||||
WeixinMiniAppIDsc string
|
||||
@@ -125,6 +127,7 @@ var (
|
||||
EnterpriseChatMin *enterprise.API // 企业微信小程序api
|
||||
|
||||
LogisticsApi *ali_logistics_query.API // 阿里云提供获取物流订单的配送信息
|
||||
KuaiShouApi *kuaishou_mini.API // 快手平台
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -265,6 +268,8 @@ func Init() {
|
||||
if WeixinMiniAppID3 = beego.AppConfig.DefaultString("weixinMiniAppID3", ""); WeixinMiniAppID3 != "" {
|
||||
WeixinApp = weixinapi.New(WeixinMiniAppID3, beego.AppConfig.DefaultString("weixinMiniSecret3", ""))
|
||||
}
|
||||
WeixinApp2 = weixinapi.New("wxf3657c94aa01a3f0", "ce2b9c4cf991d72a09f67bab4d359015") // 暂时写死的
|
||||
|
||||
if WeixinMiniAppIDsc = beego.AppConfig.DefaultString("weixinMiniAppIDsc", ""); WeixinMiniAppIDsc != "" {
|
||||
WeixinMiniAPIsc = weixinapi.New(WeixinMiniAppIDsc, beego.AppConfig.DefaultString("weixinMiniSecretsc", ""))
|
||||
}
|
||||
@@ -320,4 +325,5 @@ func Init() {
|
||||
TiktokStore = tiktokShop.New(beego.AppConfig.DefaultString("tiktokShopAppId", ""), beego.AppConfig.DefaultString("tiktokShopAppSecret", ""), "")
|
||||
EnterpriseChatHeadApi = enterprise.New("ww9a156bfa070e1857", "0jBdCjSmoFiOoHIXyeCK9VbGQ82fVNJZ8uMl6JNN7X4") // 通讯录
|
||||
EnterpriseChatMin = enterprise.NewMin("ww9a156bfa070e1857", "JQsEmSTltHhNgdPIT320YJFphiYmRs-YZa-rCBwplss") // 小程序
|
||||
KuaiShouApi = kuaishou_mini.New(beego.AppConfig.DefaultString("kuaiShouAppSecret", ""), beego.AppConfig.DefaultString("kuaiShouAppId", ""))
|
||||
}
|
||||
|
||||
8
main.go
8
main.go
@@ -41,6 +41,10 @@ import (
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/douyin"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/kuaishou"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
_ "git.rosy.net.cn/jx-callback/business/enterprise"
|
||||
_ "git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
@@ -48,10 +52,6 @@ import (
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jx"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/weimob/wsc"
|
||||
//_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/douyin"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/act"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user