修复Senparc组件引入后支付bug;调整在线支付单号和订单单号一致;增加支付流水号,方便对账

This commit is contained in:
2019-09-14 23:51:39 +08:00
parent fcca7f76fd
commit 0e679e2d62
9 changed files with 237 additions and 149 deletions
+22 -17
View File
@@ -59,21 +59,26 @@ namespace COMCMS.Web.Controllers.api
return new ReJson(40000, "用户状态错误,无法使用本功能!");
}
//开始生成支付订单
OnlinePayOrder model = new OnlinePayOrder();
model.OrderId = entity.Id;
model.OrderNum = entity.OrderNum;
model.PayId = 1;
model.PaymentNotes = "微信支付";
model.PaymentStatus = Utils.PaymentState[0];
model.PayOrderNum = Utils.GetOrderNum();//在线支付订单的订单号
model.PayType = "微信支付";
model.TotalPrice = entity.TotalPay;
model.TotalQty = entity.TotalQty;
model.UId = entity.UId;
model.IP = Utils.GetIP();
model.IsOK = 0;
model.AddTime = DateTime.Now;
model.Insert();
OnlinePayOrder model = OnlinePayOrder.Find(OnlinePayOrder._.OrderNum == entity.OrderNum);
if(model == null)
{
model = new OnlinePayOrder();
model.OrderId = entity.Id;
model.OrderNum = entity.OrderNum;
model.PayId = 1;
model.PaymentNotes = "微信支付";
model.PaymentStatus = Utils.PaymentState[0];
model.PayOrderNum = Utils.GetOrderNum();//在线支付订单的订单号
model.PayType = "微信支付";
model.TotalPrice = entity.TotalPay;
model.TotalQty = entity.TotalQty;
model.UId = entity.UId;
model.Ip = Utils.GetIP();
model.IsOK = 0;
model.AddTime = DateTime.Now;
model.Insert();
}
//写入日志
OrderLog log = new OrderLog();
@@ -92,7 +97,7 @@ namespace COMCMS.Web.Controllers.api
TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify");
TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey,"","", Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify");
TenPayV3Info.TenPayV3Notify = Utils.GetServerUrl() + "/wxpayment/notify";
XTrace.WriteLine("微信支付异步通知地址:" + TenPayV3Info.TenPayV3Notify);
//创建支付应答对象
@@ -102,7 +107,7 @@ namespace COMCMS.Web.Controllers.api
string rtimeStamp = Utils.GetTimeStamp();
//创建请求统一订单接口参数
var xmlDataInfo = new TenPayV3UnifiedorderRequestData(TenPayV3Info.AppId, TenPayV3Info.MchId, entity.Title, model.PayOrderNum, (int)(entity.TotalPay * 100), Utils.GetIP(), TenPayV3Info.TenPayV3Notify, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, my.WeixinAppOpenId, TenPayV3Info.Key, nonceStr);
var xmlDataInfo = new TenPayV3UnifiedorderRequestData(TenPayV3Info.AppId, TenPayV3Info.MchId, entity.Title, model.OrderNum, (int)(entity.TotalPay * 100), Utils.GetIP(), TenPayV3Info.TenPayV3Notify, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, my.WeixinAppOpenId, TenPayV3Info.Key, nonceStr);
//返回给微信的请求
RequestHandler res = new RequestHandler(null);
@@ -42,7 +42,7 @@ namespace COMCMS.Web.Controllers
string wxmchId = cfg.MCHId;// ConfigurationManager.AppSettings["WeixinMCHId"];
string wxmchKey = cfg.MCHKey;// ConfigurationManager.AppSettings["WeixinMCHKey"];
TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify");
TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey,"","", Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify");
string res = null;
resHandler.SetKey(TenPayV3Info.Key);
@@ -54,7 +54,7 @@ namespace COMCMS.Web.Controllers
string out_trade_no = resHandler.GetParameter("out_trade_no");//商户订单号
XTrace.WriteLine("微信异步通知订单号:" + out_trade_no + ";" + JsonConvert.SerializeObject(resHandler));
OnlinePayOrder payOrder = OnlinePayOrder.Find(OnlinePayOrder._.PayOrderNum == out_trade_no);
OnlinePayOrder payOrder = OnlinePayOrder.Find(OnlinePayOrder._.OrderNum == out_trade_no);
if (payOrder == null)
{
XTrace.WriteLine($"支付成功,但是支付订单不存在:{out_trade_no}");
@@ -67,6 +67,7 @@ namespace COMCMS.Web.Controllers
//更新支付订单
payOrder.PaymentStatus = Utils.PaymentState[1];
payOrder.ReceiveTime = DateTime.Now;
payOrder.OutTradeNo = out_trade_no;
payOrder.IsOK = 1;
payOrder.Update();
@@ -76,6 +77,8 @@ namespace COMCMS.Web.Controllers
{
order.PaymentStatus = Utils.PaymentState[1];
order.PayType = "微信支付";
order.OutTradeNo = out_trade_no;
if (order.MyType == (int)Utils.MyType.分销商认证)
{
order.OrderStatus = Utils.OrdersState[2];