Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
16fc4a6c
Commit
16fc4a6c
authored
Dec 16, 2024
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
2804b713
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
161 additions
and
77 deletions
+161
-77
WechatMessage.cs
Mall.Common/Pay/WeChatPat/Model/WechatMessage.cs
+20
-10
WXBizMsgCrypt.cs
Mall.Common/Pay/WeChatPat/Msg/WXBizMsgCrypt.cs
+22
-38
PointModule.cs
Mall.Module.Education/PointModule.cs
+6
-0
WeChatNotifyController.cs
...WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
+113
-29
No files found.
Mall.Common/Pay/WeChatPat/Model/WechatMessage.cs
View file @
16fc4a6c
...
@@ -11,16 +11,13 @@ namespace Mall.WeChat.Common
...
@@ -11,16 +11,13 @@ namespace Mall.WeChat.Common
/// </summary>
/// </summary>
public
class
WechatMessage
public
class
WechatMessage
{
{
/// <summary>
/// 本公众帐号
/// </summary>
public
string
ToUserName
{
get
;
set
;
}
/// <summary>
/// <summary>
/// appid
/// appid
/// </summary>
/// </summary>
public
string
App
i
d
{
get
;
set
;
}
public
string
App
I
d
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Token
/// Token
...
@@ -31,6 +28,11 @@ namespace Mall.WeChat.Common
...
@@ -31,6 +28,11 @@ namespace Mall.WeChat.Common
/// EncodingAESKey
/// EncodingAESKey
/// </summary>
/// </summary>
public
string
EncodingAESKey
{
get
;
set
;
}
public
string
EncodingAESKey
{
get
;
set
;
}
/// <summary>
/// 本公众帐号
/// </summary>
public
string
ToUserName
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 用户帐号
/// 用户帐号
/// </summary>
/// </summary>
...
@@ -52,16 +54,24 @@ namespace Mall.WeChat.Common
...
@@ -52,16 +54,24 @@ namespace Mall.WeChat.Common
/// </summary>
/// </summary>
public
string
EventName
{
get
;
set
;
}
public
string
EventName
{
get
;
set
;
}
/// <summary>
/// <summary>
///
这两个属性会在后面的讲解中提到
///
消息id
/// </summary>
/// </summary>
public
string
Ticket
{
get
;
set
;
}
public
string
MsgId
{
get
;
set
;
}
/// <summary>
/// <summary>
///
事件KEY值,qrscene_为前缀,后面为二维码的参数值
///
消息标题
/// </summary>
/// </summary>
public
string
EventKey
{
get
;
set
;
}
public
string
Title
{
get
;
set
;
}
/// <summary>
/// 消息url地址
/// </summary>
public
string
PagePath
{
get
;
set
;
}
}
}
}
}
Mall.Common/Pay/WeChatPat/Msg/WXBizMsgCrypt.cs
View file @
16fc4a6c
...
@@ -21,7 +21,7 @@ using Org.BouncyCastle.Crypto.Generators;
...
@@ -21,7 +21,7 @@ using Org.BouncyCastle.Crypto.Generators;
//-40010 : base64解密异常
//-40010 : base64解密异常
namespace
Mall.Common.Pay.WeChatPat
namespace
Mall.Common.Pay.WeChatPat
{
{
public
class
WXBizMsgCrypt
public
class
WXBizMsgCrypt
{
{
string
m_sToken
;
string
m_sToken
;
string
m_sEncodingAESKey
;
string
m_sEncodingAESKey
;
...
@@ -42,9 +42,9 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -42,9 +42,9 @@ namespace Mall.Common.Pay.WeChatPat
};
};
//构造函数
//构造函数
// @param sToken: 公众平台上,开发者设置的Token
// @param sToken: 公众平台上,开发者设置的Token
// @param sEncodingAESKey: 公众平台上,开发者设置的EncodingAESKey
// @param sEncodingAESKey: 公众平台上,开发者设置的EncodingAESKey
// @param sAppID: 公众帐号的appid
// @param sAppID: 公众帐号的appid
public
WXBizMsgCrypt
(
string
sToken
,
string
sEncodingAESKey
,
string
sAppID
)
public
WXBizMsgCrypt
(
string
sToken
,
string
sEncodingAESKey
,
string
sAppID
)
{
{
m_sToken
=
sToken
;
m_sToken
=
sToken
;
...
@@ -62,10 +62,10 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -62,10 +62,10 @@ namespace Mall.Common.Pay.WeChatPat
// @return: 成功0,失败返回对应的错误码
// @return: 成功0,失败返回对应的错误码
public
int
DecryptMsg
(
string
sMsgSignature
,
string
sTimeStamp
,
string
sNonce
,
string
sPostData
,
ref
string
sMsg
)
public
int
DecryptMsg
(
string
sMsgSignature
,
string
sTimeStamp
,
string
sNonce
,
string
sPostData
,
ref
string
sMsg
)
{
{
if
(
m_sEncodingAESKey
.
Length
!=
43
)
if
(
m_sEncodingAESKey
.
Length
!=
43
)
{
{
return
(
int
)
WXBizMsgCryptErrorCode
.
WXBizMsgCrypt_IllegalAesKey
;
return
(
int
)
WXBizMsgCryptErrorCode
.
WXBizMsgCrypt_IllegalAesKey
;
}
}
XmlDocument
doc
=
new
XmlDocument
();
XmlDocument
doc
=
new
XmlDocument
();
XmlNode
root
;
XmlNode
root
;
string
sEncryptMsg
;
string
sEncryptMsg
;
...
@@ -112,10 +112,10 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -112,10 +112,10 @@ namespace Mall.Common.Pay.WeChatPat
// return:成功0,失败返回对应的错误码
// return:成功0,失败返回对应的错误码
public
int
EncryptMsg
(
string
sReplyMsg
,
string
sTimeStamp
,
string
sNonce
,
ref
string
sEncryptMsg
)
public
int
EncryptMsg
(
string
sReplyMsg
,
string
sTimeStamp
,
string
sNonce
,
ref
string
sEncryptMsg
)
{
{
if
(
m_sEncodingAESKey
.
Length
!=
43
)
if
(
m_sEncodingAESKey
.
Length
!=
43
)
{
{
return
(
int
)
WXBizMsgCryptErrorCode
.
WXBizMsgCrypt_IllegalAesKey
;
return
(
int
)
WXBizMsgCryptErrorCode
.
WXBizMsgCrypt_IllegalAesKey
;
}
}
string
raw
=
""
;
string
raw
=
""
;
try
try
{
{
...
@@ -187,7 +187,7 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -187,7 +187,7 @@ namespace Mall.Common.Pay.WeChatPat
}
}
}
}
public
static
int
GenarateSinature
(
string
sToken
,
string
sTimeStamp
,
string
sNonce
,
string
sMsgEncrypt
,
ref
string
sMsgSignature
)
public
static
int
GenarateSinature
(
string
sToken
,
string
sTimeStamp
,
string
sNonce
,
string
sMsgEncrypt
,
ref
string
sMsgSignature
)
{
{
ArrayList
AL
=
new
ArrayList
();
ArrayList
AL
=
new
ArrayList
();
AL
.
Add
(
sToken
);
AL
.
Add
(
sToken
);
...
@@ -245,7 +245,7 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -245,7 +245,7 @@ namespace Mall.Common.Pay.WeChatPat
int
r
=
ret
.
DecryptMsg
(
msg_signature
,
timestamp
,
nonce
,
postStr
,
ref
postStr
);
int
r
=
ret
.
DecryptMsg
(
msg_signature
,
timestamp
,
nonce
,
postStr
,
ref
postStr
);
if
(
r
!=
0
)
if
(
r
!=
0
)
{
{
Plugin
.
LogHelper
.
WriteInfo
(
"GetWxMessage_消息解密失败:"
);
Plugin
.
LogHelper
.
WriteInfo
(
"GetWxMessage_消息解密失败
111
:"
);
return
wx
;
return
wx
;
}
}
}
}
...
@@ -255,39 +255,23 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -255,39 +255,23 @@ namespace Mall.Common.Pay.WeChatPat
wx
.
ToUserName
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"ToUserName"
).
InnerText
;
wx
.
ToUserName
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"ToUserName"
).
InnerText
;
wx
.
FromUserName
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"FromUserName"
).
InnerText
;
wx
.
FromUserName
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"FromUserName"
).
InnerText
;
wx
.
MsgType
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"MsgType"
).
InnerText
;
wx
.
MsgType
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"MsgType"
).
InnerText
;
if
(
wx
.
MsgType
.
Trim
()
==
"text"
)
if
(
wx
.
MsgType
.
Trim
()
==
"text"
)
{
{
wx
.
Content
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"Content"
).
InnerText
;
wx
.
Content
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"Content"
).
InnerText
;
}
}
if
(
wx
.
MsgType
.
Trim
()
==
"event
"
)
else
if
(
wx
.
MsgType
.
Trim
()
==
"miniprogrampage
"
)
{
{
wx
.
EventName
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"Event"
).
InnerText
;
wx
.
MsgId
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"MsgId"
).
InnerText
;
try
//wx.Title = xml.SelectSingleNode("xml").SelectSingleNode("Title").InnerText;
{
wx
.
AppId
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"AppId"
).
InnerText
;
wx
.
EventKey
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"EventKey"
).
InnerText
;
wx
.
PagePath
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"PagePath"
).
InnerText
;
Plugin
.
LogHelper
.
Write
(
"wx.EventKey:"
+
wx
.
EventKey
.
Trim
());
}
catch
(
Exception
ex
)
{
Plugin
.
LogHelper
.
Write
(
ex
);
wx
.
EventKey
=
""
;
}
try
{
wx
.
Ticket
=
xml
.
SelectSingleNode
(
"xml"
).
SelectSingleNode
(
"Ticket"
)?.
InnerText
??
""
;
Plugin
.
LogHelper
.
Write
(
"wx.Ticket:"
+
wx
.
Ticket
.
Trim
());
}
catch
(
Exception
ex
)
{
Plugin
.
LogHelper
.
Write
(
ex
);
wx
.
Ticket
=
""
;
}
}
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
Plugin
.
LogHelper
.
Write
(
ex
);
Plugin
.
LogHelper
.
Write
(
ex
,
"我是解析方法GetWxMessage:"
);
}
}
return
wx
;
return
wx
;
}
}
...
@@ -307,7 +291,7 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -307,7 +291,7 @@ namespace Mall.Common.Pay.WeChatPat
[
Obsolete
]
[
Obsolete
]
public
static
bool
CheckSignature
(
string
signature
,
string
timestamp
,
string
nonce
,
string
_token
)
public
static
bool
CheckSignature
(
string
signature
,
string
timestamp
,
string
nonce
,
string
_token
)
{
{
return
false
;
return
false
;
//var vs = new[] { timestamp, nonce, _token }.OrderBy(s => s);
//var vs = new[] { timestamp, nonce, _token }.OrderBy(s => s);
//var str = string.Join("", vs);
//var str = string.Join("", vs);
//var tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
//var tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
...
...
Mall.Module.Education/PointModule.cs
View file @
16fc4a6c
...
@@ -11,6 +11,7 @@ using Mall.Common;
...
@@ -11,6 +11,7 @@ using Mall.Common;
using
Mall.Common.API
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Common.Plugin
;
using
Mall.Module.User
;
using
Mall.Module.User
;
using
Mall.Repository.TradePavilion
;
namespace
Mall.Module.Education
namespace
Mall.Module.Education
{
{
...
@@ -35,6 +36,8 @@ namespace Mall.Module.Education
...
@@ -35,6 +36,8 @@ namespace Mall.Module.Education
private
readonly
RB_Education_TeacherRepository
education_TeacherRepository
=
new
RB_Education_TeacherRepository
();
private
readonly
RB_Education_TeacherRepository
education_TeacherRepository
=
new
RB_Education_TeacherRepository
();
#
region
用户基本信息
#
region
用户基本信息
public
Model
.
Entity
.
User
.
RB_Member_User
GetUserEntity
(
int
UserId
)
public
Model
.
Entity
.
User
.
RB_Member_User
GetUserEntity
(
int
UserId
)
...
@@ -1120,5 +1123,8 @@ namespace Mall.Module.Education
...
@@ -1120,5 +1123,8 @@ namespace Mall.Module.Education
}
}
#
endregion
#
endregion
}
}
}
}
Mall.WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
View file @
16fc4a6c
...
@@ -2,22 +2,28 @@
...
@@ -2,22 +2,28 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Web
;
using
System.Web
;
using
System.Xml
;
using
System.Xml
;
using
Google.Protobuf.WellKnownTypes
;
using
Google.Protobuf.WellKnownTypes
;
using
Mall.CacheManager.AppletWeChat
;
using
Mall.Common
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.API
;
using
Mall.Common.Pay.WeChatPat
;
using
Mall.Common.Pay.WeChatPat
;
using
Mall.Common.Plugin
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.User
;
using
Mall.Module.User
;
using
Mall.Module.User
;
using
Mall.WebApi.Filter
;
using
Mall.WebApi.Filter
;
using
Mall.WeChat.Common
;
using
Mall.WeChat.Common
;
using
Microsoft.AspNetCore.Components.Routing
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
MongoDB.Libmongocrypt
;
using
Newtonsoft.Json.Linq
;
using
Newtonsoft.Json.Linq
;
using
Org.BouncyCastle.Crypto.Generators
;
using
Org.BouncyCastle.Crypto.Generators
;
using
RabbitMQ.Client.Framing.Impl
;
namespace
Mall.WebApi.Controllers.AppletWeChat
namespace
Mall.WebApi.Controllers.AppletWeChat
{
{
...
@@ -34,6 +40,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -34,6 +40,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
private
readonly
Module
.
MarketingCenter
.
RechargeModule
rechargeModule
=
new
Module
.
MarketingCenter
.
RechargeModule
();
private
readonly
Module
.
MarketingCenter
.
RechargeModule
rechargeModule
=
new
Module
.
MarketingCenter
.
RechargeModule
();
private
readonly
Module
.
MarketingCenter
.
CouponModule
couponModule
=
new
Module
.
MarketingCenter
.
CouponModule
();
private
readonly
Module
.
MarketingCenter
.
CouponModule
couponModule
=
new
Module
.
MarketingCenter
.
CouponModule
();
private
readonly
Module
.
Education
.
PointModule
pointModule
=
new
Module
.
Education
.
PointModule
();
private
readonly
Module
.
Education
.
PointModule
pointModule
=
new
Module
.
Education
.
PointModule
();
private
readonly
Module
.
TradePavilion
.
BuildingCarrierModule
buildingCarrierModule
=
new
Module
.
TradePavilion
.
BuildingCarrierModule
();
private
readonly
Module
.
Education
.
ActivityModule
activityModule
=
new
Module
.
Education
.
ActivityModule
();
private
readonly
Module
.
Education
.
ActivityModule
activityModule
=
new
Module
.
Education
.
ActivityModule
();
private
readonly
IHttpContextAccessor
_accessor
;
private
readonly
IHttpContextAccessor
_accessor
;
...
@@ -539,9 +546,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -539,9 +546,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat
/// <returns></returns>
/// <returns></returns>
[
HttpPost
]
[
HttpPost
]
[
HttpGet
]
[
HttpGet
]
public
string
EventMessageCall
(
int
MallBaseId
,
int
TenantId
)
public
string
EventMessageCall
(
int
MallBaseId
,
int
TenantId
)
{
{
LogHelper
.
WriteInfo
(
"EventMessageCall_进入方法...."
);
string
timestamp
=
""
;
string
timestamp
=
""
;
string
nonce
=
""
;
string
nonce
=
""
;
string
echostr
=
""
;
string
echostr
=
""
;
...
@@ -604,21 +610,12 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -604,21 +610,12 @@ namespace Mall.WebApi.Controllers.AppletWeChat
LogHelper
.
WriteInfo
(
"openid:"
+
ex
.
Message
);
LogHelper
.
WriteInfo
(
"openid:"
+
ex
.
Message
);
}
}
LogHelper
.
WriteInfo
(
$"我进来了参数如下[MallBaseId:"
+
MallBaseId
+
","
+
LogHelper
.
WriteInfo
(
$"我进来了参数如下[MallBaseId:"
+
MallBaseId
+
","
+
"TenantId:"
+
TenantId
+
",signature:"
+
signature
+
",echostr:"
+
echostr
+
",timestamp:"
+
timestamp
+
",nonce:"
+
nonce
+
",openid:"
+
openid
+
",encrypt_type:"
+
encrypt_type
+
",msg_signature:"
+
msg_signature
);
"TenantId:"
+
TenantId
+
",signature:"
+
signature
+
",echostr:"
+
echostr
+
",timestamp:"
+
timestamp
+
",nonce:"
+
nonce
+
",openid:"
+
openid
+
",encrypt_type:"
+
encrypt_type
+
",msg_signature:"
+
msg_signature
);
var
req
=
new
RequestHandler
();
var
req
=
new
RequestHandler
();
try
try
{
{
int
qrCodeType
=
0
;
int
userId
=
0
;
string
textpl
=
""
;
string
content
=
"你好!"
;
string
sToken
=
"f87f2b2a8c474c06908b5c937068b506"
;
string
sAppID
=
"wxaeb077c07ed6f30d"
;
string
sEncodingAESKey
=
"9FgR0wMXxe6wXBB5hwgpn2mZM6sQMi3E3Vk5sxrXEAL"
;
var
request
=
_accessor
.
HttpContext
.
Request
;
var
request
=
_accessor
.
HttpContext
.
Request
;
LogHelper
.
WriteInfo
(
"我是回调方法:EventMessageCall"
+
"请求方式:"
+
request
.
Method
);
if
(
request
.
Method
==
"GET"
)
if
(
request
.
Method
==
"GET"
)
{
{
try
try
...
@@ -628,30 +625,110 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -628,30 +625,110 @@ namespace Mall.WebApi.Controllers.AppletWeChat
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
echostr
=
""
;
echostr
=
""
;
LogHelper
.
WriteInfo
(
"echostr:::"
+
ex
.
Message
);
LogHelper
.
WriteInfo
(
"echostr:::"
+
ex
.
Message
);
}
}
return
echostr
??
"echostr is null"
;
return
echostr
??
"echostr is null"
;
}
}
// var str = new StreamReader(HttpContext.Request.);
else
var
str
=
new
StreamReader
(
request
.
Body
);
string
postStr
=
str
.
ReadToEnd
();
LogHelper
.
WriteInfo
(
"我是返回信息:"
+
postStr
);
lock
(
_lock
)
{
{
if
(!
string
.
IsNullOrWhiteSpace
(
postStr
))
var
str
=
new
StreamReader
(
request
.
Body
);
string
postStr
=
str
.
ReadToEnd
();
lock
(
_lock
)
{
{
WechatMessage
wx
=
WXBizMsgCrypt
.
GetWxMessage
(
postStr
,
timestamp
,
nonce
,
signature
,
encrypt_type
,
msg_signature
,
openid
);
if
(!
string
.
IsNullOrWhiteSpace
(
postStr
))
if
(!
string
.
IsNullOrWhiteSpace
(
wx
.
MsgType
))
// 用户未关注时,进行关注后的事件推送;事件KEY值,qrscene_为前缀,后面为二维码的参数值
{
{
textpl
=
ReceivedText
(
wx
.
FromUserName
,
wx
.
ToUserName
,
content
);
WechatMessage
wx
=
WXBizMsgCrypt
.
GetWxMessage
(
postStr
,
timestamp
,
nonce
,
signature
,
encrypt_type
,
msg_signature
,
openid
);
if
(
encrypt_type
.
ToLower
()
==
"aes"
.
ToLower
())
//加密模式需要先解密
if
(
!
string
.
IsNullOrWhiteSpace
(
wx
.
PagePath
)
&&
wx
.
MsgType
==
"miniprogrampage"
)
// 卡片消息发送联系人信息
{
{
var
ret
=
new
WXBizMsgCrypt
(
sToken
,
sEncodingAESKey
,
sAppID
);
var
parameters
=
GetQueryParameters
(
wx
.
PagePath
);
int
r
=
ret
.
EncryptMsg
(
textpl
,
timestamp
,
nonce
,
ref
textpl
);
if
(
r
!=
0
)
int
id
=
0
;
if
(
parameters
!=
null
&&
parameters
.
Any
())
{
foreach
(
System
.
Text
.
RegularExpressions
.
Match
m
in
parameters
)
{
if
(
m
.
Result
(
"$2"
).
Equals
(
"id"
))
{
try
{
id
=
Convert
.
ToInt32
(
m
.
Result
(
"$3"
));
}
catch
(
Exception
ex
)
{
id
=
0
;
}
}
}
}
if
(
id
>
0
)
{
{
LogHelper
.
WriteInfo
(
"GetWxMessage_消息加密失败:"
);
bool
sendMsg
=
false
;
textpl
=
""
;
string
contactName
=
""
;
string
contactPhone
=
""
;
if
(
wx
.
PagePath
.
Contains
(
"pages/kotra/carrier/detail_building"
))
//楼宇
{
var
model
=
buildingCarrierModule
.
GetBuildingInfoModule
(
id
);
contactName
=
model
?.
ContactName
??
""
;
contactPhone
=
model
?.
ContactPhone
??
""
;
sendMsg
=
true
;
}
else
if
(
wx
.
PagePath
.
Contains
(
"pages/kotra/carrier/detail_carrier"
))
//载体
{
var
model
=
buildingCarrierModule
.
GetBuildingCarrierModule
(
id
);
contactName
=
model
?.
ContactName
??
""
;
contactPhone
=
model
?.
ContactPhone
??
""
;
sendMsg
=
true
;
}
else
if
(
wx
.
PagePath
.
Contains
(
"pages/kotra/brand/detail_brand"
))
//品牌
{
var
model
=
buildingCarrierModule
.
GetBrandEnterpriseModule
(
id
);
contactName
=
model
?.
ContactName
??
""
;
contactPhone
=
model
?.
ContactPhone
??
""
;
sendMsg
=
true
;
}
else
if
(
wx
.
PagePath
.
Contains
(
"pages/kotra/brand/detail_company"
))
//企业
{
var
model
=
buildingCarrierModule
.
GetEnterpriseServicesInfoModule
(
id
);
contactName
=
model
?.
ContactName
??
""
;
contactPhone
=
model
?.
ContactPhone
??
""
;
sendMsg
=
true
;
}
if
(
sendMsg
)
{
RB_MiniProgram_Extend
modelMiniProgram
=
new
RB_MiniProgram_Extend
();
modelMiniProgram
=
activityModule
.
GetMiniProgramExtend
(
MallBaseId
);
string
token
=
WeiXinReidsCache
.
Get
(
modelMiniProgram
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetLXYToken
(
token
,
modelMiniProgram
.
MiniAppId
,
modelMiniProgram
.
MiniAppSecret
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
WeiXinReidsCache
.
Set
(
modelMiniProgram
.
MiniAppId
,
token
));
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
return
""
;
}
string
url
=
"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token="
+
token
;
string
contetnStr
=
""
;
if
(
string
.
IsNullOrWhiteSpace
(
contactName
)
&&
String
.
IsNullOrWhiteSpace
(
contactPhone
))
{
contetnStr
=
"暂无相关主体联系人信息"
;
}
else
{
contetnStr
=
"联系人:"
+
contactName
+
"\n"
+
"联系电话:"
+
contactPhone
;
}
var
obj
=
new
{
touser
=
wx
.
FromUserName
,
msgtype
=
"text"
,
text
=
new
{
content
=
contetnStr
},
};
string
result
=
Common
.
Plugin
.
HttpHelper
.
HttpPostStr
(
url
,
JsonHelper
.
Serialize
(
obj
));
// LogHelper.WriteInfo("发送消息返回信息:" + result);
}
}
}
}
}
}
}
...
@@ -665,6 +742,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -665,6 +742,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat
return
echostr
??
"echostr is null"
;
return
echostr
??
"echostr is null"
;
}
}
private
static
MatchCollection
GetQueryParameters
(
string
url
)
{
System
.
Text
.
RegularExpressions
.
Regex
re
=
new
System
.
Text
.
RegularExpressions
.
Regex
(
@"(^|&)?(\w+)=([^&]+)(&|$)?"
,
System
.
Text
.
RegularExpressions
.
RegexOptions
.
Compiled
);
System
.
Text
.
RegularExpressions
.
MatchCollection
mc
=
re
.
Matches
(
url
);
return
mc
;
}
/// <summary>
/// <summary>
/// 接收消息
/// 接收消息
/// </summary>
/// </summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment