Пример #1
0
        /// <summary>
        /// 从IDataReader创建ExtSuitProductInfo
        /// </summary>
        public static ExtSuitProductInfo BuildExtSuitProductFromReader(IDataReader reader)
        {
            ExtSuitProductInfo extSuitProductInfo = new ExtSuitProductInfo();

            extSuitProductInfo.RecordId = TypeHelper.ObjectToInt(reader["recordid"]);
            extSuitProductInfo.PmId = TypeHelper.ObjectToInt(reader["pmid"]);
            extSuitProductInfo.Discount = TypeHelper.ObjectToInt(reader["discount"]);
            extSuitProductInfo.Number = TypeHelper.ObjectToInt(reader["number"]);
            extSuitProductInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]);
            extSuitProductInfo.PSN = reader["psn"].ToString();
            extSuitProductInfo.CateId = TypeHelper.ObjectToInt(reader["cateid"]);
            extSuitProductInfo.BrandId = TypeHelper.ObjectToInt(reader["brandid"]);
            extSuitProductInfo.SKUGid = TypeHelper.ObjectToInt(reader["skugid"]);
            extSuitProductInfo.Name = reader["name"].ToString();
            extSuitProductInfo.ShopPrice = TypeHelper.ObjectToDecimal(reader["shopprice"]);
            extSuitProductInfo.MarketPrice = TypeHelper.ObjectToDecimal(reader["marketprice"]);
            extSuitProductInfo.CostPrice = TypeHelper.ObjectToDecimal(reader["costprice"]);
            extSuitProductInfo.State = TypeHelper.ObjectToInt(reader["state"]);
            extSuitProductInfo.IsBest = TypeHelper.ObjectToInt(reader["isbest"]);
            extSuitProductInfo.IsHot = TypeHelper.ObjectToInt(reader["ishot"]);
            extSuitProductInfo.IsNew = TypeHelper.ObjectToInt(reader["isnew"]);
            extSuitProductInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]);
            extSuitProductInfo.Weight = TypeHelper.ObjectToInt(reader["weight"]);
            extSuitProductInfo.ShowImg = reader["showimg"].ToString();

            return extSuitProductInfo;
        }
Пример #2
0
        /// <summary>
        /// 获得扩展套装商品列表
        /// </summary>
        /// <param name="pmId">促销活动id</param>
        /// <returns></returns>
        public static List<ExtSuitProductInfo> GetExtSuitProductList(int pmId)
        {
            List<ExtSuitProductInfo> extSuitProductList = null;

            if (_promotionnosql != null)
            {
                extSuitProductList = _promotionnosql.GetSuitProductList(pmId);
                if (extSuitProductList == null)
                {
                    extSuitProductList = new List<ExtSuitProductInfo>();
                    foreach (ExtSuitProductInfo item in AdminGetExtSuitProductList(pmId))
                    {
                        ExtSuitProductInfo extSuitProductInfo = new ExtSuitProductInfo();
                        extSuitProductInfo.RecordId = item.RecordId;
                        extSuitProductInfo.PmId = item.PmId;
                        extSuitProductInfo.Discount = item.Discount;
                        extSuitProductInfo.Number = item.Number;
                        extSuitProductInfo.Pid = item.Pid;
                        extSuitProductList.Add(extSuitProductInfo);
                    }
                    _promotionnosql.CreateSuitProductList(pmId, extSuitProductList);
                }

                List<string> pidList = new List<string>();
                foreach (ExtSuitProductInfo extSuitProductInfo in extSuitProductList)
                {
                    pidList.Add(extSuitProductInfo.Pid.ToString());
                }
                List<PartProductInfo> partProductList = _productnosql.GetPartProductList(pidList);

                List<ExtSuitProductInfo> filterExtSuitProductList = new List<ExtSuitProductInfo>();
                foreach (ExtSuitProductInfo extSuitProductInfo in extSuitProductList)
                {
                    PartProductInfo partProductInfo = partProductList.Find(x => x.Pid == extSuitProductInfo.Pid);
                    if (partProductInfo != null)
                    {
                        extSuitProductInfo.PSN = partProductInfo.PSN;
                        extSuitProductInfo.CateId = partProductInfo.CateId;
                        extSuitProductInfo.BrandId = partProductInfo.BrandId;
                        extSuitProductInfo.SKUGid = partProductInfo.SKUGid;
                        extSuitProductInfo.Name = partProductInfo.Name;
                        extSuitProductInfo.ShopPrice = partProductInfo.ShopPrice;
                        extSuitProductInfo.MarketPrice = partProductInfo.MarketPrice;
                        extSuitProductInfo.CostPrice = partProductInfo.CostPrice;
                        extSuitProductInfo.State = partProductInfo.State;
                        extSuitProductInfo.IsBest = partProductInfo.IsBest;
                        extSuitProductInfo.IsHot = partProductInfo.IsHot;
                        extSuitProductInfo.IsNew = partProductInfo.IsNew;
                        extSuitProductInfo.DisplayOrder = partProductInfo.DisplayOrder;
                        extSuitProductInfo.Weight = partProductInfo.Weight;
                        extSuitProductInfo.ShowImg = partProductInfo.ShowImg;
                        filterExtSuitProductList.Add(extSuitProductInfo);
                    }
                }

                extSuitProductList = filterExtSuitProductList;
            }
            else
            {
                extSuitProductList = new List<ExtSuitProductInfo>();
                IDataReader reader = BrnShop.Core.BSPData.RDBS.GetExtSuitProductList(pmId);
                while (reader.Read())
                {
                    ExtSuitProductInfo extSuitProductInfo = BuildExtSuitProductFromReader(reader);
                    extSuitProductList.Add(extSuitProductInfo);
                }
                reader.Close();
            }

            return extSuitProductList;
        }