Commit 17a4853e authored by 吴春's avatar 吴春

提交

parent 1d3c4937
......@@ -197,6 +197,94 @@ namespace Mall.WebApi.App_Code
}
/// <summary>
/// 支付
/// </summary>
/// <returns></returns>
public BaseResult NotifyZhouTian(IHttpContextAccessor accessor)
{
try
{
var res = new ResponseHandler(accessor);
var tradeType = res.GetParameter("trade_type");
LogHelper.WriteInfo("Notify支付回调:res-" + res.ToString());
RB_MiniProgram_Extend model = new RB_MiniProgram_Extend();
model = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 6, TenantId = 16 });
res.SetKey(model.WeChatApiSecret);
//判断签名
if (res.IsWXsign(out string error))
{
#region 参数
var returnCode = res.GetParameter("return_code");
//返回信息,如非空,为错误原因签名失败参数格式校验错误
var returnMsg = res.GetParameter("return_msg");
var appid = res.GetParameter("appid");
//以下字段在 return_code 为 SUCCESS 的时候有返回--------------------------------
var mchId = res.GetParameter("mch_id");
var deviceInfo = res.GetParameter("device_info");
var nonceStr = res.GetParameter("nonce_str");
var resultCode = res.GetParameter("result_code");
var errCode = res.GetParameter("err_code");
var errCodeDes = res.GetParameter("err_code_des");
//以下字段在 return_code 和 result_code 都为 SUCCESS 的时候有返回---------------
var openid = res.GetParameter("openid");
//Y-关注,N-未关注,仅在公众账号类型支付有效
var isSubscribe = res.GetParameter("is_subscribe");
//银行类型,采用字符串类型的银行标识
var bankType = res.GetParameter("bank_type");
var totalFee = res.GetParameter("total_fee");
//货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
var feeType = res.GetParameter("fee_type");
//微信支付订单号
var transactionId = res.GetParameter("transaction_id");
//商户系统的订单号,与请求一致。
var outTradeNo = res.GetParameter("out_trade_no");
var attach = res.GetParameter("attach");
//格 式 为yyyyMMddhhmmss
var timeEnd = res.GetParameter("time_end");
#endregion
//支付成功
if (!outTradeNo.Equals("") && returnCode.Equals("SUCCESS") && resultCode.Equals("SUCCESS"))
{
return new BaseResult()
{
IsSuccess = true,
Data = new Dictionary<string, string>
{
{"sOrderNo", outTradeNo},
{"sTradeNo", transactionId},
{"dPrice", totalFee},
{"sPayerOpenID", openid},
{"bIsRecharge", attach},
{"OrderPayType", tradeType},
{"PayDate",timeEnd }
}
};
}
else
{
LogHelper.WriteInfo("Notify支付回调:returnMsg-" + returnMsg);
}
}
else
{
LogHelper.Write(null, "Notify签名验证失败:");
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "Notify支付错误:");
}
return new BaseResult() { IsSuccess = false };
}
/// <summary>
/// 退款 传入订单号OrderNumber,RefundNumber,总金额total_fee(分),RefundFee退款金额(分),
/// </summary>
......
......@@ -93,7 +93,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
switch ((int)demodel.OrderPayType)
{
case 1://微信支付 _accessor.HttpContext.Connection.RemoteIpAddress.ToString()
sPayInfo = App_Code.PayUtil.GetMinUnifiedOrder(sOrderNo, demodel.GoodsName, model.Income.Value, model.UserId.ToString(), demodel.OpenId, Config.sTenpayNotify, miniProgram, _accessor, System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault(address => address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)?.ToString());
sPayInfo = App_Code.PayUtil.GetMinUnifiedOrder(sOrderNo, demodel.GoodsName, model.Income.Value, model.UserId.ToString(), demodel.OpenId, (model.MallBaseId==6&&model.TenantId==16)? "http://mallapi.oytour.com/api/WeChatNotify/NotifyZhouTian" : Config.sTenpayNotify, miniProgram, _accessor, System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault(address => address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)?.ToString());
break;
default:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment