淘宝信息
This commit is contained in:
@@ -7,6 +7,10 @@ using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
@@ -30,7 +34,7 @@ namespace Hncore.Pass.Sells.Service
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<string> ReceivedMsg(HttpRequest request, Func<string, Task<bool>> process)
|
||||
public async Task<string> ReceivedMsg(HttpRequest request, Func<string, Task<string>> process)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
long timestamp = long.Parse(request.Query["timestamp"]);
|
||||
@@ -61,7 +65,8 @@ namespace Hncore.Pass.Sells.Service
|
||||
*/
|
||||
if (process != null)
|
||||
{
|
||||
if (await process(json))
|
||||
var msg_info = await process(json);
|
||||
if (msg_info != "")
|
||||
{
|
||||
var returnJson = new
|
||||
{
|
||||
@@ -69,9 +74,9 @@ namespace Hncore.Pass.Sells.Service
|
||||
DoMemoUpdate = new
|
||||
{
|
||||
Flag = 1,
|
||||
Memo = "购买成功"
|
||||
Memo = msg_info
|
||||
},
|
||||
AliwwMsg = "购买成功"
|
||||
AliwwMsg = msg_info
|
||||
};
|
||||
return returnJson.ToJson();
|
||||
}
|
||||
@@ -79,6 +84,71 @@ namespace Hncore.Pass.Sells.Service
|
||||
return "";
|
||||
}
|
||||
|
||||
public async Task<string> SengMsg(string Tid,string msg)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
|
||||
|
||||
//阿奇所发送消息
|
||||
string accessToken = "TbAldsa2ph4sa7de69r5vvccm2767evg7k9rs4gsf4273upm8c";
|
||||
|
||||
WebRequest apiRequest = WebRequest.Create("http://gw.api.agiso.com/alds/WwMsg/Send");
|
||||
apiRequest.Method = "POST";
|
||||
apiRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
apiRequest.Headers.Add("Authorization", "Bearer " + accessToken);
|
||||
apiRequest.Headers.Add("ApiVersion", "1");
|
||||
|
||||
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
var args = new Dictionary<string,string>()
|
||||
{
|
||||
{"timestamp",Convert.ToInt64(ts.TotalSeconds).ToString()},
|
||||
{"tid",Tid},
|
||||
{"msg",msg},
|
||||
};
|
||||
args.Add("sign", Sign(args, appSecret));
|
||||
|
||||
string postData = "";
|
||||
foreach (var p in args)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(postData))
|
||||
{
|
||||
postData += "&";
|
||||
}
|
||||
string tmpStr = String.Format("{0}={1}", p.Key, HttpUtility.UrlEncode(p.Value));
|
||||
postData += tmpStr;
|
||||
}
|
||||
|
||||
using (var sw = new StreamWriter(apiRequest.GetRequestStream()))
|
||||
{
|
||||
sw.Write(postData);
|
||||
}
|
||||
WebResponse apiResponse = null;
|
||||
try
|
||||
{
|
||||
apiResponse = apiRequest.GetResponse();
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
if (we.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
apiResponse = (we.Response as HttpWebResponse);
|
||||
}
|
||||
else{
|
||||
//TODO:处理异常
|
||||
return "";
|
||||
}
|
||||
}
|
||||
using(Stream apiDataStream = apiResponse.GetResponseStream()){
|
||||
using(StreamReader apiReader = new StreamReader(apiDataStream, Encoding.UTF8)){
|
||||
string apiResult = apiReader.ReadToEnd();
|
||||
apiReader.Close();
|
||||
apiResponse.Close();
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> ReceivedRefundMsg(HttpRequest request, Func<string, Task<bool>> process)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
|
||||
Reference in New Issue
Block a user