/// <summary>
        /// 构造函数
        /// </summary>
        public BaseWcfService()
        {
            var httpContext = HttpContext.Current;

            if (httpContext != null)
            {
                var args = httpContext.Request.Url.Segments;
                for (var i = 0; i < args.Length; i++)
                {
                    args[i] = ValidateUtility.CheckNull(args[i].Trim(new char[] { '/', '\\', ' ' })).ToString();
                }
                if (args.Length >= 8)
                {
                    SystemType = MCvHelper.To <SystemType>(args[3]);
                    Token      = MCvHelper.To <string>(args[4]);
                    Guid       = MCvHelper.To <string>(args[5]);
                    UserId     = MCvHelper.To <int>(args[6]);
                    Uid        = MCvHelper.To <string>(args[7]);
                }
                else
                {
                    MLogManager.Error(MLogGroup.WcfService.构造函数, "", "wcf 服务基类 构造函数初始化 ,uri参数错误");
                }
            }
        }
        /// <summary>
        /// 获取缓存对象 自定义缓存类型
        /// </summary>
        /// <returns></returns>
        public static ICache GetCacheObj(MCaching.Provider provider)
        {
            if (_cacheObj == null)
            {
                if (IsEnable)
                {
                    switch (provider)
                    {
                    case MCaching.Provider.Redis:
                    {
                        _cacheObj = MRedisCache.GetInstance();
                    }
                    break;

                    case MCaching.Provider.Memcached:
                    {
                        _cacheObj = MMemcache.GetInstance();
                    }
                    break;

                    default:
                    {
                        MLogManager.Error(MLogGroup.Other.获取缓存对象, "",
                                          "缓存方式错误 没有指定 " + MCaching.Provider.Memcached + " 缓存的实现方法!");
                    }
                    break;
                    }
                }
                else
                {
                    _cacheObj = NotCache.GetInstance();
                }
            }
            return(_cacheObj);
        }
Esempio n. 3
0
        /// <summary>
        /// 移除缓存 来自 缓存分组
        /// </summary>
        /// <param name="cacheGroup"></param>
        /// <returns></returns>
        public int RemoveByKeyGroup(MCaching.CacheGroup cacheGroup)
        {
            var result = 0;
            var keys   = GetKeys();

            foreach (var key in keys)
            {
                try
                {
                    if (VerifyKeyInGroup(key, cacheGroup))
                    {
                        if (GetClient().Remove(key))
                        {
                            result++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取所有缓存Key 出错!", ex);
                }
            }

            return(result);
        }
Esempio n. 4
0
 /// <summary>
 /// 从连接池取连接对象
 /// </summary>
 /// <returns></returns>
 public static IRedisClient GetClient()
 {
     //if (_cacheClient != null)
     //{
     //    return _cacheClient;
     //}
     if (_cachePool != null)
     {
         try
         {
             if (_cacheClient == null)
             {
                 _cacheClient = _cachePool.GetClient();
             }
             return(_cacheClient);
         }
         catch (Exception)
         {
             MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取缓存连接对象失败!");
             throw new Exception("获取缓存连接对象失败!");
         }
     }
     else
     {
         MLogManager.Error(MLogGroup.Other.Redis缓存, null, "连接池初始化失败!");
         throw new Exception("连接池初始化失败!");
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 构造函数
        /// </summary>
        private MRedisCache()
        {
            try
            {
                var onlyReadServers = MConfigManager.GetAppSettingsValue <string>(
                    MConfigManager.FormatKey("RedisServers_readOnly", MConfigs.ConfigsCategory.Cache),
                    "").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                var readWriteServers = MConfigManager.GetAppSettingsValue <string>(
                    MConfigManager.FormatKey("RedisServers_readWrite", MConfigs.ConfigsCategory.Cache),
                    "").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                _cachePool = new PooledRedisClientManager(readWriteServers, onlyReadServers,
                                                          new RedisClientManagerConfig
                {
                    AutoStart        = true,
                    MaxReadPoolSize  = onlyReadServers.Length * 5,
                    MaxWritePoolSize = readWriteServers.Length * 5
                });

                //GetClient() = new RedisClient(host, port);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Redis缓存, null, "初始化 ReidaCache 失败!", ex);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 订单汇总信息
        /// </summary>
        /// <param name="norMalShoppingCart">购物车列表</param>
        /// <param name="channelId">区域ID</param>
        /// <param name="userId">用户id</param>
        /// <param name="payId">支付id</param>
        /// <param name="logisticsId">配送id</param>
        /// <param name="cityId">城市id</param>
        /// <returns></returns>
        public static OrderSumaryEntity SummaryOrderInfo(List <ShoppingCartEntity> norMalShoppingCart, int channelId, int userId, int payId, int logisticsId, int cityId)
        {
            var result = new OrderSumaryEntity();

            try
            {
                result.TotalScore    = norMalShoppingCart.Sum(c => c.intScore * c.intBuyCount);
                result.TotalGoodsFee = norMalShoppingCart.Sum(c => c.intBuyCount * c.numSalePrice);
                result.TotalWeight   = norMalShoppingCart.Sum(c => c.intBuyCount * c.intWeight ?? 0);
                result.TotalOriginal = norMalShoppingCart.Sum(c => c.intBuyCount * c.numOrgPrice);
                result.TotalFreight  =
                    BaseDataBLL.GetLogisticsInfo(
                        channelId,
                        userId,
                        MCvHelper.To <int>(cityId, 0),
                        payId, logisticsId,
                        result.TotalWeight, result.TotalGoodsFee).info;
                result.TotalDiscountFee = result.TotalGoodsFee -
                                          result.TotalOriginal;
                result.TotalOrderFee = result.TotalFreight +
                                       result.TotalGoodsFee -
                                       result.TotalDiscountFee;
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Order.订单汇总信息, null, "", ex);
            }
            return(result);
        }
Esempio n. 7
0
 /// <summary>
 /// 构造函数
 /// </summary>
 private MMemcache()
 {
     try
     {
         _cacheClient = new MemcachedClient();
         _cacheClient.FlushAll();
     }
     catch (Exception ex)
     {
         MLogManager.Error(MLogGroup.Other.Memcached缓存, null, "缓存初始化失败!", ex);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 移除缓存 来自 缓存Key
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool RemoveByKey(string key)
        {
            var result = false;

            try
            {
                result = GetClient().Remove(key);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取所有缓存Key 出错!", ex);
            }
            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// 获取所有缓存Key
        /// </summary>
        /// <returns></returns>
        public List <string> GetKeys()
        {
            var result = new List <string>();

            try
            {
                result = GetClient().GetAllKeys();
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取所有缓存Key 出错!", ex);
            }
            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="cacheGroup"> </param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool Add <T>(string key, MCaching.CacheGroup cacheGroup, T obj)
        {
            var result = false;

            try
            {
                var cacheKey = FormatKey(key, cacheGroup);
                result = GetClient().Add <T>(cacheKey, obj);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Redis缓存, null, "添加缓存 出错!", ex);
            }
            return(result);
        }
Esempio n. 11
0
        public T GetValByKey <T>(string key, Enums.MCaching.CacheGroup cacheGroup)
        {
            var result = default(T);

            try
            {
                var cacheKey = FormatKey(key, cacheGroup);
                result = _cacheClient.Get <T>(cacheKey);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Memcached缓存, null, "获取缓存值 出错!", ex);
            }
            return(result);
        }
Esempio n. 12
0
        public bool RemoveByKey(string key)
        {
            var result = false;

            try
            {
                result = _cacheClient.Remove(key);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Memcached缓存, null, "移除缓存出错!", ex);
            }

            return(result);
        }
Esempio n. 13
0
        public bool Add <T>(string key, Enums.MCaching.CacheGroup cacheGroup, T obj)
        {
            var result = false;

            try
            {
                var cacheKey = FormatKey(key, cacheGroup);
                result = _cacheClient.Store(StoreMode.Add, cacheKey, obj);
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Memcached缓存, null, "添加缓存 出错!", ex);
            }

            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// 添加 配置文件 AppSettings 节点
        /// </summary>
        /// <param name="key"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool AddAppSettings(string key, string val)
        {
            bool result = false;

            try
            {
                Config.AppSettings.Settings.Add(key, val);
                Config.Save();
                result = true;
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.配置文件操作, null, string.Format("添加 配置文件 AppSettings 节点 {0}={1}", key, val), ex);
            }
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="channelId"> </param>
        /// <param name="uid"></param>
        /// <param name="pwd"></param>
        /// <param name="guid"> </param>
        /// <returns></returns>
        public static MResult <int> LoginMember(string guid, int channelId, string uid, string pwd)
        {
            var result = new MResult <int>();

            try
            {
                var token      = CreateUserToKen();
                var memberObj  = Factory.DALFactory.Member();
                var passWord   = MEncryptUtility.MD5Encrypt(pwd, 16);
                var memberInfo = memberObj.GetMemberInfo(uid);
                if (memberInfo != null)
                {
                    if (memberInfo.passward.Equals(passWord, StringComparison.OrdinalIgnoreCase) && memberInfo.valid == 1)
                    {
                        result = UpdateUserCache(uid, token);
                        if (result.status == MResultStatus.Success)
                        {
                            result.msg = "成功登录 !";
                        }
                        else
                        {
                            result.data   = token;
                            result.status = MResultStatus.Success;
                            result.msg    = "成功登录,缓存失败" + result.msg;
                        }
                        ShoppingCartBll.MergeShoppingCartGoods(guid, channelId, uid, memberInfo.membNo);
                    }
                    else
                    {
                        result.status = MResultStatus.ExecutionError;
                        result.msg    = "用户名或密码错误!";
                    }
                    result.info = memberInfo.membNo;
                    result.data = token;
                }
                else
                {
                    result.status = MResultStatus.ExecutionError;
                    result.msg    = "用户不存在!";
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Member.登陆, channelId + "", "获取数据错误");
            }
            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// 重新登录
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static MResult ReLoginMember(string sid, string uid, string token)
        {
            var result = new MResult();

            try
            {
                var memberObj  = Factory.DALFactory.Member();
                var memberInfo = memberObj.GetMemberInfo(uid);
                var cache      = MCacheManager.GetCacheObj(MCaching.Provider.Redis);
                if (memberInfo != null && memberInfo.valid == 1)
                {
                    var uId = cache.GetValByKey <string>(token, MCaching.CacheGroup.Member);
                    if (uId != null && !string.IsNullOrEmpty(uId))
                    {
                        result = UpdateUserCache(uid, token);
                        if (result.status == MResultStatus.Success)
                        {
                            result.msg = "登录成功!";
                        }
                        else
                        {
                            result.data   = token;
                            result.status = MResultStatus.Success;
                            result.msg    = "用户名密码正确,缓存失败" + result.msg;
                        }
                    }
                    else
                    {
                        result.msg = "token 不存在,请重新登录";
                    }
                }
                else
                {
                    result.status = MResultStatus.ExecutionError;
                    result.msg    = "用户不存在!";
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Member.登陆, sid, "获取数据错误");
            }
            return(result);
        }
Esempio n. 17
0
        /// <summary>
        /// 移除 配置文件 AppSettings 节点
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool RemoveAppSettings(string key)
        {
            var result = false;

            try
            {
                if (Config.AppSettings.Settings.AllKeys.Contains(key))
                {
                    Config.AppSettings.Settings.Remove(key);
                    Config.Save();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.配置文件操作, null, string.Format("移除 配置文件 AppSettings 节点 {0}", key), ex);
            }
            return(result);
        }
Esempio n. 18
0
 /// <summary>
 /// 构造函数
 /// </summary>
 static MConfigManager()
 {
     try
     {
         var httpContext = HttpContext.Current;
         if (httpContext != null)
         {
             Config = WebConfigurationManager.OpenWebConfiguration("~");
         }
         else
         {
             Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         }
     }
     catch (Exception ex)
     {
         MLogManager.Error(MLogGroup.Other.配置文件操作, null, "初始化配置文件错误", ex);
     }
 }
Esempio n. 19
0
        public Dictionary <string, T> GetValByKeys <T>(List <string> keys, Enums.MCaching.CacheGroup cacheGroup)
        {
            var result = new Dictionary <string, T>();

            if (keys != null && keys.Count > 0)
            {
                foreach (var key in keys)
                {
                    try
                    {
                        result.Add(key, GetValByKey <T>(key, cacheGroup));
                    }
                    catch (Exception ex)
                    {
                        MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取缓存值 出错!", ex);
                    }
                }
            }
            return(result);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 private MMongoDbManager()
 {
     try
     {
         var host = MConfigManager.GetAppSettingsValue <string>(MConfigManager.FormatKey("MongoDbServer", MConfigs.ConfigsCategory.Cache));
         var port = MConfigManager.GetAppSettingsValue <int>(MConfigManager.FormatKey("MongoDbPort", MConfigs.ConfigsCategory.Cache));
         if (!string.IsNullOrEmpty(host) && port > 0)
         {
             var serverCon = string.Format("mongodb://{0}:{1}", host.Trim(), port);
             _server = MongoServer.Create(serverCon);
             if (_server == null)
             {
                 MLogManager.Error(MLogGroup.Other.MongoDb, null, "初始化 失败!");
             }
         }
     }
     catch (Exception ex)
     {
         MLogManager.Error(MLogGroup.Other.MongoDb, null, "初始化 失败!", ex);
     }
 }
Esempio n. 21
0
        /// <summary>
        /// 更新用户 Session
        /// </summary>
        /// <param name="uid">用户 字符串id(此处邮箱) 如果是更新用户状态可以为空,如果是登录则必填</param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static MResult <int> UpdateUserCache(string uid, string token)
        {
            var result = new MResult <int>();

            try
            {
                var cache = MCacheManager.GetCacheObj(MCaching.Provider.Redis);
                if (cache.Contains(token, MCaching.CacheGroup.Member))
                {
                    uid = cache.GetValByKey <string>(token, MCaching.CacheGroup.Member);
                    cache.RemoveByKey(token, MCaching.CacheGroup.Member);
                }

                if (!string.IsNullOrEmpty(uid))
                {
                    if (cache.Set <string>(token, MCaching.CacheGroup.Member, uid, DateTime.Now.AddMinutes(30)))
                    {
                        result.status = MResultStatus.Success;
                        result.data   = token;
                    }
                    else
                    {
                        result.status = MResultStatus.ExecutionError;
                        result.msg    = "[" + uid + "]缓存用户状态失败!";
                    }
                }
                else
                {
                    result.status = MResultStatus.ExecutionError;
                    result.msg    = "缓存用户状态 uid 不能为空!";
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Member.登陆, null, "更新用户状态缓存失败!", ex);
            }
            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// 注销
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static MResult LogOut(string sid, string uid, string token)
        {
            var result = new MResult();

            try
            {
                result = RemoveUserCache(uid, token);
                if (result.status == MResultStatus.Success)
                {
                    result.msg = "注销成功!";
                }
                else
                {
                    result.status = MResultStatus.Success;
                    result.msg    = "注销成功,清除缓存失败" + result.msg;
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Member.登陆, sid, "获取数据错误");
            }
            return(result);
        }
Esempio n. 23
0
 /// <summary>
 /// 使用缓存
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <param name="cacheGroup"></param>
 /// <param name="expired"> </param>
 /// <param name="cache"></param>
 /// <param name="func"></param>
 public static T UseCached <T>(string key, MCaching.CacheGroup cacheGroup, DateTime expired, ICache cache, Func <object> func) where T : class
 {
     try
     {
         T cacheResult;
         if (cache.Contains(key, cacheGroup))
         {
             cacheResult = (T)cache.GetValByKey <T>(key, cacheGroup);
             return(cacheResult);
         }
         else
         {
             cacheResult = func.Invoke() as T;
             cache.Set <T>(key, cacheGroup, cacheResult, expired);
             return(cacheResult);
         }
     }
     catch (Exception ex)
     {
         MLogManager.Error(MLogGroup.Other.Redis缓存, "", "使用缓存数据出错!", ex);
     }
     return(null);
 }
Esempio n. 24
0
        /// <summary>
        /// 检查商品销售区域
        /// </summary>
        /// <param name="shoppingList"> </param>
        /// <param name="userId"></param>
        /// <param name="cityId"></param>
        /// <param name="channelId"></param>
        /// <returns>无效的 商品ID</returns>
        public static List <int> CheckGoodsSaleArea(List <ShoppingCartEntity> shoppingList, int userId, int cityId, int channelId)
        {
            var result = new List <int>();

            try
            {
                var orderDal = DALFactory.Order();
                var norMalShoppingCartIdList = orderDal.CheckGoodsSaleArea(userId, cityId, channelId);
                shoppingList.ForEach(item =>
                {
                    if (!norMalShoppingCartIdList.Contains(item.intShopCartID))
                    {
                        result.Add(item.intProductID);
                    }
                });
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Order.检查商品销售区域, null, "", ex);
            }

            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// 获取所有缓存Key
        /// </summary>
        /// <param name="cacheGroup"></param>
        /// <returns></returns>
        public List <string> GetKeys(MCaching.CacheGroup cacheGroup)
        {
            var result = new List <string>();

            try
            {
                var keyList = GetKeys();
                if (keyList != null && keyList.Count > 0)
                {
                    foreach (var key in keyList)
                    {
                        if (VerifyKeyInGroup(key, cacheGroup))
                        {
                            result.Add(FormatKey(key, cacheGroup));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.Redis缓存, null, "获取缓存key", ex);
            }
            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// 获取 配置文件 AppSettings 节点的值
        /// </summary>
        /// <param name="key">配置文件的Key</param>
        /// <param name="def">如果不存在</param>
        /// <returns></returns>
        public static T GetAppSettingsValue <T>(string key, params T[] def)
        {
            object val = null;

            try
            {
                if (Config.AppSettings.Settings.AllKeys.Contains(key))
                {
                    val = Config.AppSettings.Settings[key].Value;
                }
                else if (def.Length > 0)
                {
                    if (AddAppSettings(key, def[0].ToString()))
                    {
                        val = def[0];
                    }
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.配置文件操作, null, string.Format("获取 配置文件 AppSettings 节点 {0}={1}", key, def[0]), ex);
            }
            return(MCvHelper.To <T>(val));
        }
Esempio n. 27
0
 /// <summary>
 /// 获取缓存对象 采用 配置文件配置
 /// </summary>
 /// <returns></returns>
 public static ICache GetCacheObj()
 {
     if (_cacheObj == null)
     {
         if (IsEnable)
         {
             var key       = MConfigManager.FormatKey("Default", MConfigs.ConfigsCategory.Cache);
             var cacheType = MConfigManager.GetAppSettingsValue(key, "");
             if (!string.IsNullOrEmpty(cacheType))
             {
                 if (cacheType.Equals(MCaching.Provider.Redis.ToString(), StringComparison.OrdinalIgnoreCase))
                 {
                     _cacheObj = MRedisCache.GetInstance();
                 }
                 else if (cacheType.Equals(MCaching.Provider.Memcached.ToString(),
                                           StringComparison.OrdinalIgnoreCase))
                 {
                     _cacheObj = MMemcache.GetInstance();
                 }
                 else
                 {
                     MLogManager.Error(MLogGroup.Other.获取缓存对象, "", "缓存方式配置无法识别,节点" + key);
                 }
             }
             else
             {
                 MLogManager.Error(MLogGroup.Other.获取缓存对象, "", "请配置缓存方式,节点" + key);
             }
         }
         else
         {
             _cacheObj = NotCache.GetInstance();
         }
     }
     return(_cacheObj);
 }
Esempio n. 28
0
        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="begimTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public static MResultList <ItemOrder> GetOrdersList(int sid, string uid, int userId, DateTime begimTime, DateTime endTime)
        {
            var result = new MResultList <ItemOrder>(true);

            #region 参数验证

            if (userId <= 0)
            {
                result.status = MResultStatus.ParamsError;
                result.msg    = "用户标识错误!";
            }

            #endregion

            try
            {
                var orderDal = DALFactory.Order();

                var orderList = orderDal.GetOrdersList(userId, begimTime, endTime);
                if (orderList.Any())
                {
                    orderList.ForEach(item =>
                    {
                        var payType = item.payMethod == 0 ? "货到付款" : "在线支付";

                        var payStatus = item.payStatus == 2 ? "已付款" : "未付款";
                        #region 订单状态
                        string orderStatus;
                        switch (item.flowStatus)
                        {
                        case 0: orderStatus = "付款未审核"; break;

                        case 1: orderStatus = "未确定"; break;

                        case 4: orderStatus = "客户已确认"; break;

                        case 5: orderStatus = "生成配货单"; break;

                        case 7: orderStatus = "已出库"; break;

                        case 20: orderStatus = "完成"; break;

                        default:
                            orderStatus = "未知"; break;
                        }
                        #endregion
                        var orderInfo = new ItemOrder
                        {
                            oid           = item.orderNo,
                            ocode         = item.orderCode,
                            created       = item.createDate,
                            statusid      = item.flowStatus,
                            paytype       = payType,
                            status        = orderStatus,
                            total_fee     = item.actuallyPay,
                            total_freight = item.carriage,
                            total_order   = item.shouldPay
                        };
                        result.list.Add(orderInfo);
                    });
                    result.status = MResultStatus.Success;
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单列表, null, "获取订单列表", ex);
            }

            return(result);
        }
Esempio n. 29
0
        /// <summary>
        /// 获取订单商品列表
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public static MResultList <ItemOrderGoods> GetOrderGoodsList(int sid, string uid, int userId, string orderCode)
        {
            var result = new MResultList <ItemOrderGoods>(true);

            try
            {
                #region 参数判断
                if (userId <= 0)
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "用户标识错误!";
                }
                if (string.IsNullOrEmpty(orderCode))
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "订单标识错误!";
                }
                #endregion

                var orderDal  = DALFactory.Order();
                var memberDal = DALFactory.Member();

                var memberInfo = memberDal.GetMemberInfo(userId);
                if (memberInfo == null || memberInfo.membNo <= 0)
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "用户不存在!";
                }
                var clusterId = MCvHelper.To(memberInfo.clusterId, 1);

                var orderGoodsList = orderDal.GetOrderGoodsList(userId, orderCode, clusterId);
                if (orderGoodsList.Any())
                {
                    orderGoodsList.ForEach(item =>
                    {
                        var goodsItem = new ItemOrderGoods()
                        {
                            gid         = item.intProductID,
                            title       = item.vchProductName,
                            price       = item.numSalePrice,
                            num         = item.intQty,
                            total       = item.numTotalAmount,
                            pic_url     = GoodsBLL.FormatProductPicUrl(item.PicUrl),
                            score       = item.intScores,
                            marketprice = MCvHelper.To <decimal>(item.numStandarPrice, item.numSalePrice),
                            productcode = item.vchProductPrinted
                        };
                        result.list.Add(goodsItem);
                    });
                    result.status = MResultStatus.Success;
                }
                else
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex);
            }

            return(result);
        }
Esempio n. 30
0
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public static MResult <ItemOrderDetails> GetOrderinfo(int sid, string uid, int userId, string orderCode)
        {
            var result = new MResult <ItemOrderDetails>();

            try
            {
                #region 参数判断
                if (userId <= 0)
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "用户标识错误!";
                }
                if (string.IsNullOrEmpty(orderCode))
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "订单标识错误!";
                }
                #endregion

                var orderDal    = DALFactory.Order();
                var baseDataDal = DALFactory.BaseData();

                var orderInfo = orderDal.GetOrderInfo(userId, orderCode);
                if (orderInfo != null && orderInfo.OrderNo > 0)
                {
                    orderInfo.PayType = orderInfo.PayId == 0 ? "货到付款" : "在线支付";

                    orderInfo.InvoiceType = (int)(string.IsNullOrEmpty(orderInfo.InvoiceTitle)
                                                 ? Invoice.TitleType.NoNeed
                                                 : orderInfo.InvoiceTitle.StartsWith("个人")
                                                       ? Invoice.TitleType.Personal
                                                       : Invoice.TitleType.Company);
                    orderInfo.PayStatus = orderInfo.PayStatusId == 2 ? "已付款" : "未付款";
                    #region 订单状态
                    string orderStatus;
                    switch (orderInfo.OrderStatusId)
                    {
                    case 0: orderStatus = "付款未审核"; break;

                    case 1: orderStatus = "未确定"; break;

                    case 4: orderStatus = "客户已确认"; break;

                    case 5: orderStatus = "生成配货单"; break;

                    case 7: orderStatus = "已出库"; break;

                    case 20: orderStatus = "完成"; break;

                    default:
                        orderStatus = "未知"; break;
                    }
                    #endregion
                    orderInfo.OrderStatus = orderStatus;

                    var invoiceCategory = MCvHelper.To <int>(orderInfo.InvoiceCategory, 0);

                    result.info = new ItemOrderDetails
                    {
                        oid             = orderInfo.OrderNo,
                        ocode           = orderInfo.OrderCode,
                        status          = orderInfo.OrderStatus,
                        addr            = orderInfo.AddressInfo,
                        province        = orderInfo.Provinces,
                        city            = orderInfo.City,
                        county          = orderInfo.County,
                        contact_name    = orderInfo.Consignee,
                        invoicecategory = invoiceCategory,
                        invoicetitle    = orderInfo.InvoiceTitle,
                        phone           = orderInfo.Phone,
                        titletype       = orderInfo.InvoiceType,
                        mobile          = orderInfo.Mobile,
                        paytype         = orderInfo.PayType,
                        paytypeid       = orderInfo.PayId,
                        statusid        = orderInfo.OrderStatusId,
                        zip             = orderInfo.Zip,
                        paystatus       = orderInfo.PayStatus,
                        paystatusid     = orderInfo.PayStatusId,
                        deliverytype    = orderInfo.DeliveryType
                    };
                    result.status = MResultStatus.Success;
                }
                else
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex);
            }

            return(result);
        }