Esempio n. 1
0
        public static OrderPipelineProcessResult CreateSO(OrderInfo orderInfo)
        {
            OrderPipelineProcessResult order = BuildCheckOut(orderInfo);

            if (order.HasSucceed)
            {
                OrderPipeline pipeline            = OrderPipeline.Create("CreateSO");
                OrderPipelineProcessResult result = null;
                try
                {
                    result = pipeline.Process(order.ReturnData);
                }
                catch (BusinessException bizEx)
                {
                    if (result == null)
                    {
                        result = new OrderPipelineProcessResult();
                    }
                    result.HasSucceed = false;
                    result.ErrorMessages.Add(bizEx.Message.ToString());
                }
                catch (Exception ex)
                {
                    if (result == null)
                    {
                        result = new OrderPipelineProcessResult();
                    }
                    ECommerce.Utility.Logger.WriteLog(ex.ToString(), "SOPipeline");
                    result.HasSucceed = false;
                    result.ErrorMessages.Add("系统繁忙,请稍后再试");
                }
                return(result);
            }
            return(order);
        }
Esempio n. 2
0
        internal static OrderPipelineProcessResult Failed(List <string> errorMsgs, OrderInfo orderInfo)
        {
            OrderPipelineProcessResult rst = new OrderPipelineProcessResult();

            rst.HasSucceed      = false;
            rst.m_ErrorMessages = errorMsgs;
            rst.ReturnData      = orderInfo;
            return(rst);
        }
Esempio n. 3
0
        public OrderPipelineProcessResult Process(OrderInfo order)
        {
            OnInitializing(order);
            Initialize(order);
            OnInitialized(order);

            // 1. do pre checking
            OnPreValidating(order);
            List <string> errorList1;
            bool          r1 = PreValidate(order, out errorList1);

            OnPreValidated(order, ref r1, ref errorList1);
            if (r1 == false)
            {
                return(OrderPipelineProcessResult.Failed(errorList1, order));
            }

            // 2. do calculation
            OnCalculating(order);
            Calculate(order);
            OnCalculated(order);

            // 3. do post checking
            OnPostValidating(order);
            List <string> errorList2;
            bool          r2 = PostValidate(order, out errorList2);

            OnPostValidated(order, ref r2, ref errorList2);
            if (r2 == false)
            {
                return(OrderPipelineProcessResult.Failed(errorList2, order));
            }

            // 4. do persisting
            OnPersisting(order);
            using (TransactionScope tran = _CreateTransactionScope())
            {
                try
                {
                    Persist(order);
                    tran.Complete();
                }
                catch (Exception ex)
                {
                    ECommerce.Utility.Logger.WriteLog(ex.ToString(), "SOPipeline");
                    //当创建多个订单时,是否允许部分订单创建成功由调用端来决定 poseidon.y.tong
                    throw ex;
                    //return OrderPipelineProcessResult.Failed(new List<string>() { "Persist error" }, order);
                }
            }
            OnPersisted(order);

            // 5. return the result
            return(OrderPipelineProcessResult.Succeed(order));
        }
Esempio n. 4
0
        public static OrderPipelineProcessResult BuildShoppingCart(ShoppingCart shoppingCart)
        {
            #region 1.Check
            OrderPipelineProcessResult checkResult = _BuildShoppingCartBaseCheck(shoppingCart);
            if (!checkResult.HasSucceed)
            {
                return(checkResult);
            }
            #endregion

            #region 2.转换为orderinfo
            OrderInfo orderInfo = Convert2OrderInfo(shoppingCart);
            #endregion

            #region 3.订单和促销计算
            OrderPipeline pipeline            = OrderPipeline.Create("BuildShoppingCart");
            OrderPipelineProcessResult result = pipeline.Process(orderInfo);
            #endregion

            return(result);
        }
Esempio n. 5
0
        private static OrderPipelineProcessResult _BuildShoppingCartBaseCheck(ShoppingCart shoppingCart)
        {
            OrderPipelineProcessResult result = new OrderPipelineProcessResult();

            if (shoppingCart == null)
            {
                result.HasSucceed = false;
                return(result);
            }

            if (string.IsNullOrEmpty(shoppingCart.ChannelID) ||
                shoppingCart.ShoppingItemGroupList == null ||
                shoppingCart.ShoppingItemGroupList.Count == 0 ||
                shoppingCart.ShoppingItemGroupList[0].ShoppingItemList == null ||
                shoppingCart.ShoppingItemGroupList[0].ShoppingItemList.Count == 0)
            {
                result.HasSucceed = false;
            }
            else
            {
                result.HasSucceed = true;
            }
            return(result);
        }