淘宝信息
This commit is contained in:
@@ -570,33 +570,47 @@ namespace Home.Controllers
|
||||
[HttpPost, AllowAnonymous]
|
||||
public async Task<IActionResult> TaoBao()
|
||||
{
|
||||
Func<string, Task<bool>> process = async (data) =>
|
||||
Func<string, Task<string>> process = async (data) =>
|
||||
{
|
||||
var notifyOrder = data.FromJsonTo<TaoBaoNotifyModel>();
|
||||
LogHelper.Info("TaoBao process");
|
||||
if (notifyOrder == null || notifyOrder.Tid.NotHas())
|
||||
return false;
|
||||
return "";
|
||||
|
||||
if (m_ScoreService.ExistTaoBaoScore(notifyOrder.Tid))
|
||||
return true;
|
||||
return "";
|
||||
// var phone = notifyOrder.ReceiverMobile.NotHas() ? notifyOrder.ReceiverPhone : notifyOrder.ReceiverMobile;
|
||||
// if (phone.NotHas()) return false;
|
||||
var userEntity = await m_UserService.Query(m => m.TaoBao == notifyOrder.BuyerNick).FirstOrDefaultAsync();
|
||||
var phone = notifyOrder.BuyerNick;
|
||||
|
||||
string pas_result = "";
|
||||
Random rd = new Random(Guid.NewGuid().GetHashCode());
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int rnd = rd.Next(0, 9);
|
||||
pas_result += rnd.ToString();
|
||||
}
|
||||
|
||||
Console.WriteLine("==================================================================");
|
||||
|
||||
string msg = "";
|
||||
|
||||
if (userEntity == null)
|
||||
{
|
||||
userEntity = new User()
|
||||
{
|
||||
CreateType = UserCreateType.TaoBaoRegist,
|
||||
LoginCode = phone,
|
||||
Password = "1234",
|
||||
Password = pas_result,
|
||||
Phone = phone,
|
||||
TaoBao= notifyOrder.BuyerNick,
|
||||
id_code=""
|
||||
};
|
||||
var ret = await m_UserService.Regist(userEntity);
|
||||
if (ret.Code != ResultCode.C_SUCCESS) return false;
|
||||
msg = "您好,打开网址:juip.com,登录会员名:"+phone+"("+notifyOrder.Payment+"元已充值到此账户),密码:"+pas_result+"。登录后点击网站上方的-产品购买,即可完成开通或续费。淘宝付款将随机赠送优惠券,欢迎您多来淘宝下单";
|
||||
if (ret.Code != ResultCode.C_SUCCESS) return msg;
|
||||
|
||||
} else {
|
||||
phone = userEntity.Phone;
|
||||
|
||||
@@ -604,6 +618,8 @@ namespace Home.Controllers
|
||||
userEntity.TaoBao= notifyOrder.BuyerNick;
|
||||
await m_UserService.Update(userEntity);
|
||||
}
|
||||
msg = "您好,"+notifyOrder.Payment+"元已充值到充值到您的会员中,会员号为:"+userEntity.LoginCode+",打开网址:juip.com,登录后点击网站上方的-产品购买,即可完成开通或续费。淘宝付款将随机赠送优惠券,欢迎您多来淘宝下单";
|
||||
|
||||
}
|
||||
|
||||
var amountInfo = new UpdateAmountRequest()
|
||||
@@ -624,7 +640,15 @@ namespace Home.Controllers
|
||||
|
||||
await m_TaoBaoService.Add(taobaoEntity);
|
||||
|
||||
return retAmount.Code == ResultCode.C_SUCCESS;
|
||||
|
||||
// await Task.Delay(3000);
|
||||
// Console.WriteLine("===================================================================");
|
||||
// var send_msg_info = await m_TaoBaoService.SengMsg(notifyOrder.Tid,msg);
|
||||
// Console.WriteLine("===================================================================");
|
||||
// Console.WriteLine(send_msg_info);
|
||||
// Console.WriteLine("===================================================================");
|
||||
|
||||
return msg;
|
||||
};
|
||||
Func<string, Task<bool>> refunds = async (data) =>
|
||||
{
|
||||
@@ -649,7 +673,7 @@ namespace Home.Controllers
|
||||
var info = "";
|
||||
if (aopic == 2){
|
||||
info = await m_TaoBaoService.ReceivedMsg(this.Request, process);
|
||||
} else if(aopic == 256){
|
||||
} else if(aopic == 256){//退款
|
||||
var his_order= m_TaoBaoRefundService.Query(m => m.Tid == refundInfos.Tid).FirstOrDefault();
|
||||
if (his_order == null){
|
||||
info = await m_TaoBaoRefundService.ReceivedRefundMsg(this.Request, refunds);
|
||||
|
||||
@@ -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