Esempio n. 1
0
        /// <summary>
        /// 计算连续单号
        /// </summary>
        /// <param name="shipTypeId"></param>
        /// <param name="expressNum"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public ActionResult GetFillExpressNum(string shipTypeId, string expressNum, int qty)
        {
            ShipTypeEntity shipTypeEntity = _shipTypeBLL.Repository().FindEntity("ShipTypeId", shipTypeId);
            ExpressService expressService = new ExpressService();
            List <string>  lstExpressNum  = new List <string>();

            string resultCode    = "1";
            string resultMessage = string.Empty;

            try
            {
                if (!string.IsNullOrWhiteSpace(expressNum))
                {
                    IExpressStrategy express = expressService.GetExpress(shipTypeEntity.ExpressNumStrategy);
                    bool             flag    = express.VerifyExpressNum(expressNum);
                    if (flag)
                    {
                        lstExpressNum = express.GetNextExpressNum(expressNum, qty);
                    }
                    else
                    {
                        resultCode    = "0";
                        resultMessage = "单号校验失败,请输入正确的单号";
                    }
                }
                else
                {
                    resultCode    = "0";
                    resultMessage = "单号不能为空";
                }
            }
            catch (Exception ex)
            {
                resultCode    = "0";
                resultMessage = ex.Message;
            }

            var jsonData = new
            {
                code    = resultCode,
                message = resultMessage,
                rows    = lstExpressNum
            };

            return(Content(jsonData.ToJson()));
        }
        public static List <IExpressStrategy> GetAllExpress()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();
            List <IExpressStrategy> processors = new List <IExpressStrategy>();

            foreach (var t in types)
            {
                bool flag = typeof(IExpressStrategy).IsAssignableFrom(t);
                if (flag)
                {
                    IExpressStrategy obj = CreateObject(t.FullName) as IExpressStrategy;
                    if (obj != null)
                    {
                        processors.Add(obj);
                    }
                }
            }
            return(processors.OrderBy(a => a.DisplayOrderId).ToList());
        }