public OrderPayResultNotifyByMinShunLog PayQuery(int operater, Order pms) { MinShunPayOrderInfo orderInfo = new MinShunPayOrderInfo(); orderInfo.Price = 0.01m; orderInfo.Remark = pms.Remarks; orderInfo.SubmitTime = pms.SubmitTime; orderInfo.TermId = pms.TermId; orderInfo.SpbillIp = pms.SpbillIp; if (pms.PayWay == Enumeration.OrderPayWay.Wechat) { orderInfo.TranType = "180020"; orderInfo.OrderId = pms.TradeSnByWechat; } else if (pms.PayWay == Enumeration.OrderPayWay.Alipay) { orderInfo.TranType = "280020"; orderInfo.OrderId = pms.TradeSnByAlipay; } OrderPayResultNotifyByMinShunLog receiveNotifyLog = null; var payQuery_result = MinShunPayUtil.PayQuery(orderInfo); if (payQuery_result == null) { } else { receiveNotifyLog = new OrderPayResultNotifyByMinShunLog(); receiveNotifyLog.OrderId = payQuery_result.ORDERID; receiveNotifyLog.Mercid = payQuery_result.MERCID; receiveNotifyLog.Termid = payQuery_result.TERMID; receiveNotifyLog.Txnamt = payQuery_result.TXNAMT; receiveNotifyLog.ResultCode = payQuery_result.RESULT_CODE; receiveNotifyLog.ResultCodeName = GetResultCodeName(payQuery_result.RESULT_CODE); receiveNotifyLog.ResultMsg = payQuery_result.RESULT_MSG; receiveNotifyLog.Sign = payQuery_result.SIGN; receiveNotifyLog.MwebUrl = payQuery_result.MWEB_URL; receiveNotifyLog.NotifyParty = Enumeration.PayResultNotifyParty.MinShunOrderQueryApi; receiveNotifyLog.NotifyPartyName = Enumeration.PayResultNotifyParty.MinShunOrderQueryApi.GetCnName(); receiveNotifyLog.Creator = 0; receiveNotifyLog.CreateTime = DateTime.Now; } return(receiveNotifyLog); }
private CustomJsonResult MinShun_ResultNotify(int operater, OrderPayResultNotifyByMinShunLog receiveNotifyLog) { CustomJsonResult result = new CustomJsonResult(); try { using (TransactionScope ts = new TransactionScope()) { string orderId = receiveNotifyLog.OrderId.Substring(0, receiveNotifyLog.OrderId.Length - 1); var order = CurrentDb.Order.Where(m => m.Sn == orderId).FirstOrDefault(); if (order == null) { CurrentDb.OrderPayResultNotifyByMinShunLog.Add(receiveNotifyLog); CurrentDb.SaveChanges(); ts.Complete(); return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "找不到对应的订单号")); } if (receiveNotifyLog.ResultCode == "00" || receiveNotifyLog.ResultCode == "T5") { switch (order.Type) { case Enumeration.OrderType.PosMachineServiceFee: result = PayServiceFeeCompleted(operater, order.Sn); break; } } CurrentDb.OrderPayResultNotifyByMinShunLog.Add(receiveNotifyLog); CurrentDb.SaveChanges(); ts.Complete(); } } catch (Exception ex) { Log.ErrorFormat("订单号({0})结果反馈发生异常,原因:{1}", receiveNotifyLog.OrderId, ex.StackTrace); result = new CustomJsonResult(ResultType.Exception, ResultCode.Exception, "支付失败"); } return(result); }
public APIResponse ReceiveNotify(ReceiveNotifyModel model) { Stream stream = HttpContext.Current.Request.InputStream; stream.Seek(0, SeekOrigin.Begin); string postData = new StreamReader(stream).ReadToEnd(); Log.Info("ReceiveNotify:" + postData); OrderPayResultNotifyByMinShunLog receiveNotifyLog = new OrderPayResultNotifyByMinShunLog(); receiveNotifyLog.OrderId = model.orderId; receiveNotifyLog.Mercid = model.mercid; receiveNotifyLog.Termid = model.termid; receiveNotifyLog.Txnamt = model.txnamt; receiveNotifyLog.ResultCode = model.result_code; receiveNotifyLog.ResultCodeName = SdkFactory.MinShunPay.GetResultCodeName(model.result_code); receiveNotifyLog.ResultMsg = model.result_msg; receiveNotifyLog.Sign = model.sign; receiveNotifyLog.MwebUrl = null; receiveNotifyLog.NotifyParty = Enumeration.PayResultNotifyParty.MinShunNotifyUrl; receiveNotifyLog.NotifyPartyName = Enumeration.PayResultNotifyParty.MinShunNotifyUrl.GetCnName(); receiveNotifyLog.Creator = 0; receiveNotifyLog.CreateTime = DateTime.Now; IResult result = null; Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("orderId", model.orderId); dic.Add("mercid", model.mercid); dic.Add("termid", model.termid); dic.Add("txnamt", model.txnamt); dic.Add("result_code", model.result_code); dic.Add("result_msg", model.result_msg); if (SdkFactory.MinShunPay.CheckSign(dic, model.sign)) { result = BizFactory.Pay.ResultNotify(0, Enumeration.PayResultNotifyParty.MinShunNotifyUrl, receiveNotifyLog); if (result.Result == ResultType.Success) { Log.Info("ReceiveNotify->success,通知成功"); result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "success"); } else { Log.Warn("ReceiveNotify->fail, 通知失败"); result = new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "fail,通知失败"); } } else { Log.Error("ReceiveNotify->fail,验证签名失败"); result = new CustomJsonResult(ResultType.Failure, ResultCode.Failure, " fail,验证签名失败"); } return(new APIResponse(result)); }