Esempio n. 1
0
 private static void UpdateSyncResultTimes(decimal orderId, string payDetailId)
 {
     try
     {
         IOnlineOrder factory = OnlineOrderFactory.GetFactory();
         factory.UpdateSyncResultTimes(orderId, payDetailId);
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", "修改同步次数失败", ex, LogFrom.WeiXin);
     }
 }
Esempio n. 2
0
        private static bool NoticePaymentResult(OnlineOrder order)
        {
            if (order.Status != OnlineOrderStatus.PaySuccess)
            {
                TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【通知支付结果】订单不是已支付状态,订单编号:{0},支付账号:{1}", order.OrderID, order.PayAccount);
                return(false);
            }

            bool         noticePayResult = false;
            IOnlineOrder factory         = OnlineOrderFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = factory.SyncPayResultSuccess(order.OrderID, dbOperator);
                    if (!result)
                    {
                        throw new MyException("更改同步成功状态失败");
                    }

                    string payDetailId = string.Empty;
                    noticePayResult = SyncNoticePayResult(order.OrderID, order.RealPayTime, order, out payDetailId);
                    if (!noticePayResult)
                    {
                        throw new MyException("同步支付结果失败");
                    }
                    dbOperator.CommitTransaction();

                    factory.UpdateSyncResultTimes(order.OrderID, payDetailId);
                    SendSyncResultMessage(order);
                    return(true);
                }
                catch (MyException ex)
                {
                    dbOperator.RollbackTransaction();
                    factory.SyncPayResultFail(order.OrderID, ex.Message);
                    return(false);
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTransaction();
                    factory.SyncPayResultFail(order.OrderID, "同步支付结果异常");
                    TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【{0}】支付账号{3},订单编号:{1},描述:{2}", order.PaymentChannel.GetDescription(), order.OrderID, ex.Message, order.PayAccount);
                    return(false);
                }
            }
        }