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
c5a80e61
Commit
c5a80e61
authored
Nov 07, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
548fc4d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
2 deletions
+60
-2
MessageController.cs
Mall.WebApi/Controllers/Adapay/MessageController.cs
+60
-2
No files found.
Mall.WebApi/Controllers/Adapay/MessageController.cs
View file @
c5a80e61
...
...
@@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Mvc;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.WebApi.Controllers.Adapay
...
...
@@ -16,11 +19,66 @@ namespace Mall.WebApi.Controllers.Adapay
[
EnableCors
(
"AllowCors"
)]
public
class
MessageController
:
ControllerBase
{
/// <summary>
/// 接口认证
/// </summary>
/// <param name="echostr"></param>
/// <param name="signature"></param>
/// <param name="timestamp"></param>
/// <param name="nonce"></param>
/// <returns></returns>
[
HttpGet
]
[
HttpPost
]
public
bool
GetWeChatMessage
()
public
bool
CheckSignature
(
string
echostr
,
string
signature
,
string
timestamp
,
string
nonce
)
{
string
token
=
"jjsw"
;
string
queryStr
=
string
.
Format
(
"echostr:{0} signature:{1} timestamp:{2} nonce:{3}"
,
echostr
,
signature
,
timestamp
,
nonce
);
Common
.
Plugin
.
LogHelper
.
WriteInfo
(
queryStr
);
if
(!
CheckSignatureModule
(
token
,
signature
,
timestamp
,
nonce
))
{
return
false
;
}
return
true
;
}
/// <summary>
/// 接收客服消息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
HttpResponseMessage
>
wx
()
{
//var content = await Request.Content.ReadAsStringAsync();
HttpResponseMessage
responseMessage
=
new
HttpResponseMessage
();
return
responseMessage
;
}
/// <summary>
/// 验证微信签名
/// </summary>
private
bool
CheckSignatureModule
(
string
token
,
string
signature
,
string
timestamp
,
string
nonce
)
{
string
[]
ArrTmp
=
{
token
,
timestamp
,
nonce
};
Array
.
Sort
(
ArrTmp
);
string
tmpStr
=
string
.
Join
(
""
,
ArrTmp
);
var
data
=
SHA1
.
Create
().
ComputeHash
(
Encoding
.
UTF8
.
GetBytes
(
tmpStr
));
Common
.
Plugin
.
LogHelper
.
Write
(
"data:"
+
data
);
var
sb
=
new
StringBuilder
();
foreach
(
var
t
in
data
)
{
sb
.
Append
(
t
.
ToString
(
"X2"
));
}
tmpStr
=
sb
.
ToString
();
tmpStr
=
tmpStr
.
ToLower
();
if
(
tmpStr
==
signature
)
{
return
true
;
}
else
{
return
false
;
}
}
}
}
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