/// <summary> /// 从IDataReader创建ExtGiftInfo /// </summary> public static ExtGiftInfo BuildExtGiftFromReader(IDataReader reader) { ExtGiftInfo extGiftInfo = new ExtGiftInfo(); extGiftInfo.RecordId = TypeHelper.ObjectToInt(reader["recordid"]); extGiftInfo.PmId = TypeHelper.ObjectToInt(reader["pmid"]); extGiftInfo.Number = TypeHelper.ObjectToInt(reader["number"]); extGiftInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]); extGiftInfo.PSN = reader["psn"].ToString(); extGiftInfo.CateId = TypeHelper.ObjectToInt(reader["cateid"]); extGiftInfo.BrandId = TypeHelper.ObjectToInt(reader["brandid"]); extGiftInfo.StoreId = TypeHelper.ObjectToInt(reader["storeid"]); extGiftInfo.StoreCid = TypeHelper.ObjectToInt(reader["storecid"]); extGiftInfo.StoreSTid = TypeHelper.ObjectToInt(reader["storestid"]); extGiftInfo.SKUGid = TypeHelper.ObjectToInt(reader["skugid"]); extGiftInfo.Name = reader["name"].ToString(); extGiftInfo.ShopPrice = TypeHelper.ObjectToDecimal(reader["shopprice"]); extGiftInfo.MarketPrice = TypeHelper.ObjectToDecimal(reader["marketprice"]); extGiftInfo.CostPrice = TypeHelper.ObjectToDecimal(reader["costprice"]); extGiftInfo.State = TypeHelper.ObjectToInt(reader["state"]); extGiftInfo.IsBest = TypeHelper.ObjectToInt(reader["isbest"]); extGiftInfo.IsHot = TypeHelper.ObjectToInt(reader["ishot"]); extGiftInfo.IsNew = TypeHelper.ObjectToInt(reader["isnew"]); extGiftInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]); extGiftInfo.Weight = TypeHelper.ObjectToInt(reader["weight"]); extGiftInfo.ShowImg = reader["showimg"].ToString(); return extGiftInfo; }
/// <summary> /// 创建OrderProductInfo /// </summary> public static OrderProductInfo BuildOrderProduct(ExtGiftInfo extGiftInfo) { OrderProductInfo orderProductInfo = new OrderProductInfo(); orderProductInfo.Pid = extGiftInfo.Pid; orderProductInfo.PSN = extGiftInfo.PSN; orderProductInfo.CateId = extGiftInfo.CateId; orderProductInfo.BrandId = extGiftInfo.BrandId; orderProductInfo.StoreId = extGiftInfo.StoreId; orderProductInfo.StoreCid = extGiftInfo.StoreCid; orderProductInfo.StoreSTid = extGiftInfo.StoreSTid; orderProductInfo.Name = extGiftInfo.Name; orderProductInfo.DiscountPrice = extGiftInfo.ShopPrice; orderProductInfo.ShopPrice = extGiftInfo.ShopPrice; orderProductInfo.MarketPrice = extGiftInfo.MarketPrice; orderProductInfo.CostPrice = extGiftInfo.CostPrice; orderProductInfo.Weight = extGiftInfo.Weight; orderProductInfo.ShowImg = extGiftInfo.ShowImg; return orderProductInfo; }
/// <summary> /// 获得扩展赠品列表 /// </summary> /// <param name="pmId">促销活动id</param> /// <returns></returns> public static List<ExtGiftInfo> GetExtGiftList(int pmId) { List<ExtGiftInfo> extGiftList = null; if (_promotionnosql != null) { extGiftList = _promotionnosql.GetExtGiftList(pmId); if (extGiftList == null) { extGiftList = new List<ExtGiftInfo>(); foreach (ExtGiftInfo item in AdminGetExtGiftList(pmId)) { ExtGiftInfo extGiftInfo = new ExtGiftInfo(); extGiftInfo.RecordId = item.RecordId; extGiftInfo.PmId = item.PmId; extGiftInfo.Number = item.Number; extGiftInfo.Pid = item.Pid; extGiftList.Add(extGiftInfo); } _promotionnosql.CreateExtGiftList(pmId, extGiftList); } List<string> pidList = new List<string>(); foreach (ExtGiftInfo extGiftInfo in extGiftList) { pidList.Add(extGiftInfo.Pid.ToString()); } List<PartProductInfo> partProductList = _productnosql.GetPartProductList(pidList); List<ExtGiftInfo> filterExtGiftList = new List<ExtGiftInfo>(); foreach (ExtGiftInfo extGiftInfo in extGiftList) { PartProductInfo partProductInfo = partProductList.Find(x => x.Pid == extGiftInfo.Pid); if (partProductInfo != null) { extGiftInfo.PSN = partProductInfo.PSN; extGiftInfo.CateId = partProductInfo.CateId; extGiftInfo.BrandId = partProductInfo.BrandId; extGiftInfo.StoreId = partProductInfo.StoreId; extGiftInfo.StoreCid = partProductInfo.StoreCid; extGiftInfo.StoreSTid = partProductInfo.StoreSTid; extGiftInfo.SKUGid = partProductInfo.SKUGid; extGiftInfo.Name = partProductInfo.Name; extGiftInfo.ShopPrice = partProductInfo.ShopPrice; extGiftInfo.MarketPrice = partProductInfo.MarketPrice; extGiftInfo.CostPrice = partProductInfo.CostPrice; extGiftInfo.State = partProductInfo.State; extGiftInfo.IsBest = partProductInfo.IsBest; extGiftInfo.IsHot = partProductInfo.IsHot; extGiftInfo.IsNew = partProductInfo.IsNew; extGiftInfo.DisplayOrder = partProductInfo.DisplayOrder; extGiftInfo.Weight = partProductInfo.Weight; extGiftInfo.ShowImg = partProductInfo.ShowImg; filterExtGiftList.Add(extGiftInfo); } } extGiftList = filterExtGiftList; } else { extGiftList = new List<ExtGiftInfo>(); IDataReader reader = BrnMall.Core.BMAData.RDBS.GetExtGiftList(pmId); while (reader.Read()) { ExtGiftInfo extGiftInfo = BuildExtGiftFromReader(reader); extGiftList.Add(extGiftInfo); } reader.Close(); } return extGiftList; }