public static bool PaySuccess(decimal orderId, string serialNumber, DateTime payTime, string payAccount = "") { bool result = false; lock (order_lock) { try { IOnlineOrder factory = OnlineOrderFactory.GetFactory(); OnlineOrder order = factory.QueryByOrderId(orderId); if (order == null) { throw new MyException("订单编号不存在"); } if (order.Status != OnlineOrderStatus.WaitPay && order.Status != OnlineOrderStatus.Paying) { string message = string.Format("【{0}】,订单编号:{1},状态:{2}", order.PaymentChannel.GetDescription(), order.OrderID, order.Status.GetDescription()); TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【更改订单状态为已支付失败】订单不是有效状态,备注:{0},支付账号:{1}", message, order.PayAccount); return(false); } if (!string.IsNullOrWhiteSpace(payAccount)) { result = factory.PaySuccess(order.OrderID, serialNumber, payAccount, payTime); } else { result = factory.PaySuccess(order.OrderID, serialNumber, payTime); } if (result) { order.Status = OnlineOrderStatus.PaySuccess; order.SerialNumber = serialNumber; order.RealPayTime = payTime; TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "方法名:{0},操作类型:{1},订单编号:{2},备注:{3}", "PaySuccess", "更改订单状态为已支付", orderId, "更改订单状态为已支付成功"); bool noticeResult = NoticePaymentResult(order); string remark = noticeResult ? "通知支付结果成功" : "通知支付结果失败"; TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "方法名:{0},操作类型:{1},订单编号:{2},备注:{3}", "PaySuccess", "更改订单状态为已支付", orderId, remark); } else { TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【更改订单状态为已支付失败】【{0}】,订单编号:{1},状态:{2}", order.PaymentChannel.GetDescription(), order.OrderID, order.Status.GetDescription()); } } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【更改订单状态为已支付失败】订单编号:{0},Message:{1},StackTrace:{2}", orderId, ex.Message, ex.StackTrace); } return(result); } }