Beispiel #1
0
        /// <summary>
        /// 订单支付中
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static bool OrderPaying(decimal orderId)
        {
            lock (order_lock)
            {
                try
                {
                    IOnlineOrder factory = OnlineOrderFactory.GetFactory();

                    OnlineOrder order = factory.QueryByOrderId(orderId);
                    if (order.Status == OnlineOrderStatus.WaitPay)
                    {
                        return(factory.UpdateOrderStatusByOrderId(orderId, OnlineOrderStatus.Paying));
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", "更改订单支付中失败", ex, LogFrom.WeiXin);
                    return(false);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 取消待支付订单
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public static bool CancelOrder(decimal orderId)
 {
     lock (order_lock)
     {
         try
         {
             IOnlineOrder factory = OnlineOrderFactory.GetFactory();
             OnlineOrder  order   = factory.QueryByOrderId(orderId);
             if (order.Status == OnlineOrderStatus.WaitPay)
             {
                 bool result = factory.UpdateOrderStatusByOrderId(orderId, OnlineOrderStatus.Cancel);
                 if (result && order.PaymentChannel == PaymentChannel.WeiXinPay)
                 {
                     PaymentServices.CloseOrderPay(order.CompanyID, orderId.ToString());
                 }
                 return(result);
             }
         }
         catch (Exception ex) {
             ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", "取消订单失败", ex, LogFrom.WeiXin);
         }
     }
     return(false);
 }