Exemple #1
0
        /// <summary>
        /// 订单挂起
        /// </summary>
        /// <param name="orderNos"></param>
        /// <returns></returns>
        public ActionResult SuspendOrder(string orderNos)
        {
            try
            {
                var      sb         = new StringBuilder();
                string[] aryOrderNo = orderNos.Split(',');
                foreach (var orderNo in aryOrderNo)
                {
                    var entity = Repositoryfactory.Repository().FindEntity("OrderNo", orderNo);
                    if (entity == null || entity.Status == (int)OrderStatus.Canceled)
                    {
                        sb.AppendFormat("订单{0}已作废,不能挂起<br>", orderNo);
                        continue;
                    }

                    if (entity.Status == (int)OrderStatus.OutStock)
                    {
                        sb.AppendFormat("订单{0}已出库,不能挂起<br>", orderNo);
                        continue;
                    }

                    if (entity.IsSuspended)
                    {
                        sb.AppendFormat("订单{0}已挂起,不能重复操作<br>", orderNo);
                        continue;
                    }

                    entity.Modify(entity.OrderId);
                    entity.IsSuspended = true;
                    bool flag = _orderBll.SuspendOrder(entity);
                    if (flag)
                    {
                        sb.AppendFormat("订单{0}挂起成功<br>", orderNo);
                    }
                    else
                    {
                        sb.AppendFormat("订单{0}更新失败<br>", orderNo);
                    }
                }

                WriteLog(1, orderNos, sb.ToString());
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = sb.ToString()
                }.ToString()));
            }
            catch (Exception ex)
            {
                WriteLog(-1, orderNos, "操作失败:" + ex.Message);
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }