예제 #1
0
        /// <summary>
        /// 作废订单,调用ECCservice进行作废
        /// </summary>
        /// <param name="orderSysNo">订单编号</param>
        /// <param name="message"></param>
        /// <param name="userSysNo"></param>
        /// <returns>如果返回的空字符串则作废成功,否则显示返回的字符串</returns>
        public static string VoidedOrder(int orderSysNo, string message, int userSysNo)
        {
            var orderInfo = CustomerFacade.GetCenterSODetailInfo(userSysNo, orderSysNo);

            if (orderInfo == null)
            {
                throw new BusinessException("订单不存在");
            }
            if (orderInfo.HoldMark)
            {
                throw new BusinessException("订单已被锁定不能作废。如有疑问,请联系客服人员。");
            }
            var client     = new Common.RestClient.RestClient(ConstValue.ECCServiceBaseUrl, ConstValue.LanguageCode);
            var serviceUrl = "/SOService/SO/Abandon";
            RestServiceError error;

            client.Update(serviceUrl, new
            {
                IsCreateAO = false,
                ImmediatelyReturnInventory = false,
                SOSysNoList = new List <int> {
                    orderSysNo
                }
            }, out error);
            if (error != null)
            {
                var sb = new StringBuilder();
                error.Faults.ForEach(e => sb.AppendLine(e.ErrorDescription));

                if (error.Faults.All(e => e.IsBusinessException))
                {
                    return(sb.ToString());
                }
                throw new ApplicationException(sb.ToString());
            }
            CustomerDA.InsertSOLog(userSysNo, CommonFacade.GetIP(), orderSysNo, message, 201);

            //将作废的订单的SOSysNo保存到Cookies中
            var values = CookieHelper.GetCookie <List <int> >(ConstValue.Cookie_Name_VoidedOrder);

            if (values != null)
            {
                values.Add(orderSysNo);
            }
            else
            {
                values = new List <int>();
                values.Add(orderSysNo);
            }
            CookieHelper.SaveCookie <List <int> >(ConstValue.Cookie_Name_VoidedOrder, values);

            return("");
        }