Пример #1
0
 /// <summary>
 /// 更新商品属性
 /// </summary>
 public static bool UpdateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     if (productAttributeInfo.Pid < 1 || productAttributeInfo.AttrId < 1 || productAttributeInfo.AttrValueId < 0 || (productAttributeInfo.AttrValueId == 0 && string.IsNullOrWhiteSpace(productAttributeInfo.InputValue)))
     {
         return(false);
     }
     return(BrnShop.Data.Products.UpdateProductAttribute(productAttributeInfo));
 }
Пример #2
0
        /// <summary>
        /// 更新商品属性
        /// </summary>
        public static bool UpdateProductAttribute(ProductAttributeInfo productAttributeInfo)
        {
            bool result = BrnShop.Core.BSPData.RDBS.UpdateProductAttribute(productAttributeInfo);

            if (_productnosql != null)
            {
                _productnosql.ClearProductAttribute(productAttributeInfo.Pid);
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 更新商品属性
        /// </summary>
        /// <param name="pid">商品id</param>
        /// <param name="attrId">属性id</param>
        /// <param name="attrValueId">属性值id</param>
        /// <param name="inputValue">输入值</param>
        /// <param name="type">更新类型</param>
        /// <returns></returns>
        public ActionResult UpdateProductAttribute(int pid = -1, int attrId = -1, int attrValueId = -1, string inputValue = "", int type = -1)
        {
            PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(pid);

            if (partProductInfo == null || partProductInfo.StoreId != WorkContext.StoreId)
            {
                return(Content("0"));
            }

            bool result = false;
            ProductAttributeInfo productAttributeInfo = AdminProducts.GetProductAttributeByPidAndAttrId(pid, attrId);

            if (productAttributeInfo == null)
            {
                productAttributeInfo = new ProductAttributeInfo();

                productAttributeInfo.Pid         = pid;
                productAttributeInfo.AttrId      = attrId;
                productAttributeInfo.AttrValueId = attrValueId;
                if (AdminCategories.GetAttributeValueById(attrValueId).IsInput == 0 || string.IsNullOrWhiteSpace(inputValue))
                {
                    productAttributeInfo.InputValue = "";
                }
                else
                {
                    productAttributeInfo.InputValue = inputValue;
                }

                result = AdminProducts.CreateProductAttribute(productAttributeInfo);
            }
            else
            {
                if (type == 1)
                {
                    productAttributeInfo.AttrValueId = attrValueId;
                    productAttributeInfo.InputValue  = inputValue;
                    result = AdminProducts.UpdateProductAttribute(productAttributeInfo);
                }
                else if (type == 0)
                {
                    productAttributeInfo.AttrValueId = attrValueId;
                    productAttributeInfo.InputValue  = "";
                    result = AdminProducts.UpdateProductAttribute(productAttributeInfo);
                }
            }
            if (result)
            {
                AddStoreAdminLog("修改商品属性", "修改商品属性,商品属性ID:" + pid + "_" + attrId);
                return(Content("1"));
            }
            else
            {
                return(Content("0"));
            }
        }
Пример #4
0
        /// <summary>
        /// 从IDataReader创建ProductAttributeInfo
        /// </summary>
        public static ProductAttributeInfo BuildProductAttributeFromReader(IDataReader reader)
        {
            ProductAttributeInfo productAttributeInfo = new ProductAttributeInfo();

            productAttributeInfo.RecordId    = TypeHelper.ObjectToInt(reader["recordid"]);
            productAttributeInfo.Pid         = TypeHelper.ObjectToInt(reader["pid"]);
            productAttributeInfo.AttrId      = TypeHelper.ObjectToInt(reader["attrid"]);
            productAttributeInfo.AttrValueId = TypeHelper.ObjectToInt(reader["attrvalueid"]);
            productAttributeInfo.InputValue  = reader["inputvalue"].ToString();

            return(productAttributeInfo);
        }
Пример #5
0
        /// <summary>
        /// 获得商品属性
        /// </summary>
        /// <param name="pid">商品id</param>
        /// <param name="attrId">属性id</param>
        /// <returns></returns>
        public static ProductAttributeInfo GetProductAttributeByPidAndAttrId(int pid, int attrId)
        {
            ProductAttributeInfo productAttributeInfo = null;
            IDataReader          reader = BrnShop.Core.BSPData.RDBS.GetProductAttributeByPidAndAttrId(pid, attrId);

            if (reader.Read())
            {
                productAttributeInfo = BuildProductAttributeFromReader(reader);
            }
            reader.Close();
            return(productAttributeInfo);
        }
Пример #6
0
        /// <summary>
        /// 获得商品属性列表
        /// </summary>
        /// <param name="pid">商品id</param>
        /// <returns></returns>
        public static List <ProductAttributeInfo> GetProductAttributeList(int pid)
        {
            List <ProductAttributeInfo> productAttributeList = new List <ProductAttributeInfo>();
            IDataReader reader = BrnShop.Core.BSPData.RDBS.GetProductAttributeList(pid);

            while (reader.Read())
            {
                ProductAttributeInfo productAttributeInfo = BuildProductAttributeFromReader(reader);
                productAttributeList.Add(productAttributeInfo);
            }
            reader.Close();
            return(productAttributeList);
        }
Пример #7
0
        public List <ProductAttributeInfo> SearchByproductid(string id)
        {
            List <ProductAttributeInfo> list = new List <ProductAttributeInfo>();
            DataTable      dt         = new DataTable();
            MySqlParameter pidpartmer = new MySqlParameter("pid", MySqlDbType.Int64);

            pidpartmer.Value = id;
            dt = IndexService.Common.MySqlHelper.Search("SELECT * FROM himall_productattributes WHERE ProductId=@pid", new MySqlParameter[] { pidpartmer });
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ProductAttributeInfo info = new ProductAttributeInfo();
                    info.Id          = long.Parse(dt.Rows[i]["Id"].ToString());
                    info.ProductId   = long.Parse(dt.Rows[i]["ProductId"].ToString());
                    info.AttributeId = long.Parse(dt.Rows[i]["AttributeId"].ToString());
                    info.ValueId     = long.Parse(dt.Rows[i]["ValueId"].ToString());
                    info.ValueName   = dt.Rows[i]["ValueName"].ToString();
                    list.Add(info);
                }
            }
            return(list);
        }
Пример #8
0
        public int Update2(ProductAttributeInfo oParam)
        {
            string     sql = @"UPDATE product_attribute SET 
                            A1_AttributeOptionSysNo=@A1, A2_AttributeOptionSysNo=@A2, 
                            A3_AttributeOptionSysNo=@A3, A4_AttributeOptionSysNo=@A4, 
                            A5_AttributeOptionSysNo=@A5, A6_AttributeOptionSysNo=@A6, 
                            A7_AttributeOptionSysNo=@A7, A8_AttributeOptionSysNo=@A8, 
                            A9_AttributeOptionSysNo=@A9, A10_AttributeOptionSysNo=@A10, 
                            A11_AttributeOptionSysNo=@A11, A12_AttributeOptionSysNo=@A12, 
                            A13_AttributeOptionSysNo=@A13, A14_AttributeOptionSysNo=@A14, 
                            A15_AttributeOptionSysNo=@A15, A16_AttributeOptionSysNo=@A16, 
                            A17_AttributeOptionSysNo=@A17, A18_AttributeOptionSysNo=@A18, 
                            A19_AttributeOptionSysNo=@A19, A20_AttributeOptionSysNo=@A20, 
                            A21_AttributeOptionSysNo=@A21, A22_AttributeOptionSysNo=@A22, 
                            A23_AttributeOptionSysNo=@A23, A24_AttributeOptionSysNo=@A24, 
                            A25_AttributeOptionSysNo=@A25, A26_AttributeOptionSysNo=@A26, 
                            A27_AttributeOptionSysNo=@A27, A28_AttributeOptionSysNo=@A28, 
                            A29_AttributeOptionSysNo=@A29, A30_AttributeOptionSysNo=@A30
                            WHERE SysNo=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramA1    = new SqlParameter("@A1", SqlDbType.NVarChar, 200);
            SqlParameter paramA2    = new SqlParameter("@A2", SqlDbType.NVarChar, 200);
            SqlParameter paramA3    = new SqlParameter("@A3", SqlDbType.NVarChar, 200);
            SqlParameter paramA4    = new SqlParameter("@A4", SqlDbType.NVarChar, 200);
            SqlParameter paramA5    = new SqlParameter("@A5", SqlDbType.NVarChar, 200);
            SqlParameter paramA6    = new SqlParameter("@A6", SqlDbType.NVarChar, 200);
            SqlParameter paramA7    = new SqlParameter("@A7", SqlDbType.NVarChar, 200);
            SqlParameter paramA8    = new SqlParameter("@A8", SqlDbType.NVarChar, 200);
            SqlParameter paramA9    = new SqlParameter("@A9", SqlDbType.NVarChar, 200);
            SqlParameter paramA10   = new SqlParameter("@A10", SqlDbType.NVarChar, 200);
            SqlParameter paramA11   = new SqlParameter("@A11", SqlDbType.NVarChar, 200);
            SqlParameter paramA12   = new SqlParameter("@A12", SqlDbType.NVarChar, 200);
            SqlParameter paramA13   = new SqlParameter("@A13", SqlDbType.NVarChar, 200);
            SqlParameter paramA14   = new SqlParameter("@A14", SqlDbType.NVarChar, 200);
            SqlParameter paramA15   = new SqlParameter("@A15", SqlDbType.NVarChar, 200);
            SqlParameter paramA16   = new SqlParameter("@A16", SqlDbType.NVarChar, 200);
            SqlParameter paramA17   = new SqlParameter("@A17", SqlDbType.NVarChar, 200);
            SqlParameter paramA18   = new SqlParameter("@A18", SqlDbType.NVarChar, 200);
            SqlParameter paramA19   = new SqlParameter("@A19", SqlDbType.NVarChar, 200);
            SqlParameter paramA20   = new SqlParameter("@A20", SqlDbType.NVarChar, 200);
            SqlParameter paramA21   = new SqlParameter("@A21", SqlDbType.NVarChar, 200);
            SqlParameter paramA22   = new SqlParameter("@A22", SqlDbType.NVarChar, 200);
            SqlParameter paramA23   = new SqlParameter("@A23", SqlDbType.NVarChar, 200);
            SqlParameter paramA24   = new SqlParameter("@A24", SqlDbType.NVarChar, 200);
            SqlParameter paramA25   = new SqlParameter("@A25", SqlDbType.NVarChar, 200);
            SqlParameter paramA26   = new SqlParameter("@A26", SqlDbType.NVarChar, 200);
            SqlParameter paramA27   = new SqlParameter("@A27", SqlDbType.NVarChar, 200);
            SqlParameter paramA28   = new SqlParameter("@A28", SqlDbType.NVarChar, 200);
            SqlParameter paramA29   = new SqlParameter("@A29", SqlDbType.NVarChar, 200);
            SqlParameter paramA30   = new SqlParameter("@A30", SqlDbType.NVarChar, 200);

            if (oParam.SysNo != AppConst.IntNull)
            {
                paramSysNo.Value = oParam.SysNo;
            }
            else
            {
                paramSysNo.Value = System.DBNull.Value;
            }
            if (oParam.A1 != AppConst.StringNull)
            {
                paramA1.Value = oParam.A1;
            }
            else
            {
                paramA1.Value = System.DBNull.Value;
            }
            if (oParam.A2 != AppConst.StringNull)
            {
                paramA2.Value = oParam.A2;
            }
            else
            {
                paramA2.Value = System.DBNull.Value;
            }
            if (oParam.A3 != AppConst.StringNull)
            {
                paramA3.Value = oParam.A3;
            }
            else
            {
                paramA3.Value = System.DBNull.Value;
            }
            if (oParam.A4 != AppConst.StringNull)
            {
                paramA4.Value = oParam.A4;
            }
            else
            {
                paramA4.Value = System.DBNull.Value;
            }
            if (oParam.A5 != AppConst.StringNull)
            {
                paramA5.Value = oParam.A5;
            }
            else
            {
                paramA5.Value = System.DBNull.Value;
            }
            if (oParam.A6 != AppConst.StringNull)
            {
                paramA6.Value = oParam.A6;
            }
            else
            {
                paramA6.Value = System.DBNull.Value;
            }
            if (oParam.A7 != AppConst.StringNull)
            {
                paramA7.Value = oParam.A7;
            }
            else
            {
                paramA7.Value = System.DBNull.Value;
            }
            if (oParam.A8 != AppConst.StringNull)
            {
                paramA8.Value = oParam.A8;
            }
            else
            {
                paramA8.Value = System.DBNull.Value;
            }
            if (oParam.A9 != AppConst.StringNull)
            {
                paramA9.Value = oParam.A9;
            }
            else
            {
                paramA9.Value = System.DBNull.Value;
            }
            if (oParam.A10 != AppConst.StringNull)
            {
                paramA10.Value = oParam.A10;
            }
            else
            {
                paramA10.Value = System.DBNull.Value;
            }
            if (oParam.A11 != AppConst.StringNull)
            {
                paramA11.Value = oParam.A11;
            }
            else
            {
                paramA11.Value = System.DBNull.Value;
            }
            if (oParam.A12 != AppConst.StringNull)
            {
                paramA12.Value = oParam.A12;
            }
            else
            {
                paramA12.Value = System.DBNull.Value;
            }
            if (oParam.A13 != AppConst.StringNull)
            {
                paramA13.Value = oParam.A13;
            }
            else
            {
                paramA13.Value = System.DBNull.Value;
            }
            if (oParam.A14 != AppConst.StringNull)
            {
                paramA14.Value = oParam.A14;
            }
            else
            {
                paramA14.Value = System.DBNull.Value;
            }
            if (oParam.A15 != AppConst.StringNull)
            {
                paramA15.Value = oParam.A15;
            }
            else
            {
                paramA15.Value = System.DBNull.Value;
            }
            if (oParam.A16 != AppConst.StringNull)
            {
                paramA16.Value = oParam.A16;
            }
            else
            {
                paramA16.Value = System.DBNull.Value;
            }
            if (oParam.A17 != AppConst.StringNull)
            {
                paramA17.Value = oParam.A17;
            }
            else
            {
                paramA17.Value = System.DBNull.Value;
            }
            if (oParam.A18 != AppConst.StringNull)
            {
                paramA18.Value = oParam.A18;
            }
            else
            {
                paramA18.Value = System.DBNull.Value;
            }
            if (oParam.A19 != AppConst.StringNull)
            {
                paramA19.Value = oParam.A19;
            }
            else
            {
                paramA19.Value = System.DBNull.Value;
            }
            if (oParam.A20 != AppConst.StringNull)
            {
                paramA20.Value = oParam.A20;
            }
            else
            {
                paramA20.Value = System.DBNull.Value;
            }
            if (oParam.A21 != AppConst.StringNull)
            {
                paramA21.Value = oParam.A21;
            }
            else
            {
                paramA21.Value = System.DBNull.Value;
            }
            if (oParam.A22 != AppConst.StringNull)
            {
                paramA22.Value = oParam.A22;
            }
            else
            {
                paramA22.Value = System.DBNull.Value;
            }
            if (oParam.A23 != AppConst.StringNull)
            {
                paramA23.Value = oParam.A23;
            }
            else
            {
                paramA23.Value = System.DBNull.Value;
            }
            if (oParam.A24 != AppConst.StringNull)
            {
                paramA24.Value = oParam.A24;
            }
            else
            {
                paramA24.Value = System.DBNull.Value;
            }
            if (oParam.A25 != AppConst.StringNull)
            {
                paramA25.Value = oParam.A25;
            }
            else
            {
                paramA25.Value = System.DBNull.Value;
            }
            if (oParam.A26 != AppConst.StringNull)
            {
                paramA26.Value = oParam.A26;
            }
            else
            {
                paramA26.Value = System.DBNull.Value;
            }
            if (oParam.A27 != AppConst.StringNull)
            {
                paramA27.Value = oParam.A27;
            }
            else
            {
                paramA27.Value = System.DBNull.Value;
            }
            if (oParam.A28 != AppConst.StringNull)
            {
                paramA28.Value = oParam.A28;
            }
            else
            {
                paramA28.Value = System.DBNull.Value;
            }
            if (oParam.A29 != AppConst.StringNull)
            {
                paramA29.Value = oParam.A29;
            }
            else
            {
                paramA29.Value = System.DBNull.Value;
            }
            if (oParam.A30 != AppConst.StringNull)
            {
                paramA30.Value = oParam.A30;
            }
            else
            {
                paramA30.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramA1);
            cmd.Parameters.Add(paramA2);
            cmd.Parameters.Add(paramA3);
            cmd.Parameters.Add(paramA4);
            cmd.Parameters.Add(paramA5);
            cmd.Parameters.Add(paramA6);
            cmd.Parameters.Add(paramA7);
            cmd.Parameters.Add(paramA8);
            cmd.Parameters.Add(paramA9);
            cmd.Parameters.Add(paramA10);
            cmd.Parameters.Add(paramA11);
            cmd.Parameters.Add(paramA12);
            cmd.Parameters.Add(paramA13);
            cmd.Parameters.Add(paramA14);
            cmd.Parameters.Add(paramA15);
            cmd.Parameters.Add(paramA16);
            cmd.Parameters.Add(paramA17);
            cmd.Parameters.Add(paramA18);
            cmd.Parameters.Add(paramA19);
            cmd.Parameters.Add(paramA20);
            cmd.Parameters.Add(paramA21);
            cmd.Parameters.Add(paramA22);
            cmd.Parameters.Add(paramA23);
            cmd.Parameters.Add(paramA24);
            cmd.Parameters.Add(paramA25);
            cmd.Parameters.Add(paramA26);
            cmd.Parameters.Add(paramA27);
            cmd.Parameters.Add(paramA28);
            cmd.Parameters.Add(paramA29);
            cmd.Parameters.Add(paramA30);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
Пример #9
0
        public ActionResult Search(string keywords = "", string exp_keywords = "", long cid = 0L, long b_id = 0L, string a_id = "", int orderKey = 1, int orderType = 1, int pageNo = 1, int pageSize = 60)
        {
            int           i;
            long          valueId;
            long          num;
            string        str;
            ProductSearch productSearch = new ProductSearch()
            {
                shopId     = 0,
                BrandId    = b_id,
                CategoryId = cid,
                Ex_Keyword = exp_keywords,
                Keyword    = keywords,
                OrderKey   = orderKey,
                OrderType  = orderType == 1,
                AttrIds    = new List <string>(),
                PageNumber = pageNo,
                PageSize   = pageSize
            };
            ProductSearch productSearch1 = productSearch;
            string        str1           = a_id.Replace("%40", "@");

            char[]   chrArray  = new char[] { '@' };
            string[] strArrays = str1.Split(chrArray);
            for (i = 0; i < strArrays.Length; i++)
            {
                string str2 = strArrays[i];
                if (!string.IsNullOrWhiteSpace(str2))
                {
                    productSearch1.AttrIds.Add(str2);
                }
            }
            IProductService         productService = ServiceHelper.Create <IProductService>();
            PageModel <ProductInfo> pageModel      = productService.SearchProduct(productSearch1);
            int total = pageModel.Total;

            ViewBag.Total = total;
            ProductInfo[] array   = pageModel.Models.ToArray();
            dynamic       viewBag = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            viewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, num);
            CategoryInfo category = ServiceHelper.Create <ICategoryService>().GetCategory(productSearch1.CategoryId);
            string       str3     = (category == null ? string.Empty : category.Name);
            BrandInfo    brand    = ServiceHelper.Create <IBrandService>().GetBrand(b_id) ?? new BrandInfo();
            string       str4     = (brand == null ? "" : brand.Name);
            string       str5     = (string.IsNullOrEmpty(keywords) ? str3 : keywords);

            base.ViewBag.keywords = (string.IsNullOrEmpty(str5) ? str4 : str5);
            ViewBag.exp_keywords  = exp_keywords;
            if (pageModel.Total == 0)
            {
                return(View());
            }
            var categoryId =
                from prod in array
                orderby prod.CategoryId
                group prod by prod.CategoryId into G
                select new { Key = G.Key, Path = G.FirstOrDefault().CategoryPath };
            List <CategoryJsonModel> categoryJsonModels = new List <CategoryJsonModel>();

            foreach (var variable in categoryId)
            {
                string path      = variable.Path;
                char[] chrArray1 = new char[] { '|' };
                if (path.Split(chrArray1).Length != 2)
                {
                    string path1 = variable.Path;
                    chrArray = new char[] { '|' };
                    if (path1.Split(chrArray).Length != 3)
                    {
                        continue;
                    }
                    string path2 = variable.Path;
                    chrArray = new char[] { '|' };
                    long   num1  = long.Parse(path2.Split(chrArray)[1]);
                    string path3 = variable.Path;
                    chrArray = new char[] { '|' };
                    InitialCategory(categoryJsonModels, num1, long.Parse(path3.Split(chrArray)[2]));
                }
                else
                {
                    string path4 = variable.Path;
                    chrArray = new char[] { '|' };
                    long   num2  = long.Parse(path4.Split(chrArray)[0]);
                    string path5 = variable.Path;
                    chrArray = new char[] { '|' };
                    InitialCategory(categoryJsonModels, num2, long.Parse(path5.Split(chrArray)[1]));
                }
            }
            List <BrandInfo>   brandInfos = new List <BrandInfo>();
            IEnumerable <long> nums       = (
                from a in array
                where a.BrandId != 0
                select a.BrandId).Distinct <long>();
            IQueryable <BrandInfo> brands =
                from a in ServiceHelper.Create <IBrandService>().GetBrands("")
                where nums.Contains(a.Id)
                select a;

            brandInfos = brands.ToList();
            List <TypeAttributesModel> typeAttributesModels = new List <TypeAttributesModel>();
            var collection =
                from p in array
                group p by p.CategoryId into G
                select new { Key = G.Key, Count = G.Count() } into pp
            orderby pp.Count descending
            select pp;
            long   key = collection.ToList()[0].Key;

            array = (
                from p in array
                orderby p.CategoryId.Equals(key) descending
                select p).ToArray();
            if (collection.Count() <= 20)
            {
                IEnumerable <ProductInfo> productInfos =
                    from p in array
                    where p.CategoryId.Equals(key)
                    select p;
                foreach (ProductInfo productInfo in productInfos)
                {
                    if (System.IO.File.Exists(Server.MapPath(productInfo.ImagePath + string.Format("/{0}.png", 1))))
                    {
                        if (!System.IO.File.Exists(Server.MapPath(productInfo.ImagePath + string.Format("/{0}_{1}.png", 1, base.CurrentSiteSetting.CategoryProductPictureSize))))
                        {
                            string str8 = Server.MapPath(productInfo.ImagePath + string.Format("/{0}_{1}.png", 1, base.CurrentSiteSetting.CategoryProductPictureSize));
                            ImageHelper.CreateThumbnail(Server.MapPath(productInfo.ImagePath + string.Format("/{0}.png", 1)), str8, int.Parse(base.CurrentSiteSetting.CategoryProductPictureSize), int.Parse(base.CurrentSiteSetting.CategoryProductPictureSize));
                        }
                    }
                    ProductAttributeInfo[] productAttributeInfoArray  = productService.GetProductAttribute(productInfo.Id).ToArray();
                    ProductAttributeInfo[] productAttributeInfoArray1 = productAttributeInfoArray;
                    for (i = 0; i < productAttributeInfoArray1.Length; i++)
                    {
                        ProductAttributeInfo productAttributeInfo = productAttributeInfoArray1[i];
                        if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId))
                        {
                            TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId);
                            if (!typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString()))
                            {
                                if (productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId) != null)
                                {
                                    List <TypeAttrValue> attrValues    = typeAttributesModel.AttrValues;
                                    TypeAttrValue        typeAttrValue = new TypeAttrValue();
                                    valueId            = productAttributeInfo.ValueId;
                                    typeAttrValue.Id   = valueId.ToString();
                                    typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value;
                                    attrValues.Add(typeAttrValue);
                                }
                            }
                        }
                        else
                        {
                            TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel()
                            {
                                AttrId     = productAttributeInfo.AttributeId,
                                AttrValues = new List <TypeAttrValue>(),
                                Name       = productAttributeInfo.AttributesInfo.Name
                            };
                            TypeAttributesModel typeAttributesModel2 = typeAttributesModel1;
                            foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo)
                            {
                                if (!((IEnumerable <ProductAttributeInfo>)productAttributeInfoArray).Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id))
                                {
                                    continue;
                                }
                                List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues;
                                TypeAttrValue        value          = new TypeAttrValue();
                                valueId    = attributeValueInfo.Id;
                                value.Id   = valueId.ToString();
                                value.Name = attributeValueInfo.Value;
                                typeAttrValues.Add(value);
                            }
                            typeAttributesModels.Add(typeAttributesModel2);
                        }
                    }
                }
            }
            Dictionary <string, string> strs = new Dictionary <string, string>();

            foreach (string attrId in productSearch1.AttrIds)
            {
                long num3 = 0;
                chrArray = new char[] { '\u005F' };
                long.TryParse(attrId.Split(chrArray)[0], out num3);
                long num4 = 0;
                chrArray = new char[] { '\u005F' };
                long.TryParse(attrId.Split(chrArray)[1], out num4);
                AttributeInfo      attributeInfo       = ServiceHelper.Create <IProductService>().GetAttributeInfo(num3);
                AttributeValueInfo attributeValueInfo1 = attributeInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo v) => v.Id == num4);
                string             str6 = string.Concat(attributeInfo.Name, ':', attributeValueInfo1.Value);
                string             str7 = "";
                foreach (string attrId1 in productSearch1.AttrIds)
                {
                    if (attrId1.Equals(attrId))
                    {
                        if (productSearch1.AttrIds.Count() != 1)
                        {
                            continue;
                        }
                        str7 = attrId1;
                    }
                    else
                    {
                        str7 = string.Concat(str7, attrId1, '@');
                    }
                }
                chrArray = new char[] { '@' };
                strs.Add(str6, str7.TrimEnd(chrArray));
            }
            ViewBag.Attrs     = typeAttributesModels;
            ViewBag.Brands    = brandInfos;
            ViewBag.Category  = categoryJsonModels;
            ViewBag.cid       = cid;
            ViewBag.b_id      = b_id;
            ViewBag.a_id      = a_id;
            ViewBag.orderKey  = orderKey;
            ViewBag.orderType = orderType;
            dynamic obj = base.ViewBag;

            str                  = (b_id == 0 ? "" : brandInfos.FirstOrDefault((BrandInfo b) => b.Id.Equals(b_id)).Name);
            obj.BrandName        = str;
            ViewBag.AttrDic      = strs;
            base.ViewBag.Logined = (base.CurrentUser != null ? 1 : 0);
            switch (orderKey)
            {
            case 2:
            {
                ProductInfo[] productInfoArray = array;
                for (i = 0; i < productInfoArray.Length; i++)
                {
                    ProductInfo      productInfo1     = productInfoArray[i];
                    ProductVistiInfo productVistiInfo = productInfo1.Himall_ProductVistis.FirstOrDefault();
                    productInfo1.OrderCounts = (productVistiInfo == null || !productVistiInfo.OrderCounts.HasValue ? 0 : productVistiInfo.OrderCounts.Value);
                }
                array = (
                    from p in array
                    orderby p.OrderCounts descending
                    select p).ToArray();
                break;
            }

            case 3:
            {
                if (orderType != 2)
                {
                    array = (
                        from p in array
                        orderby p.MinSalePrice
                        select p).ToArray();
                    break;
                }
                else
                {
                    array = (
                        from p in array
                        orderby p.MinSalePrice descending
                        select p).ToArray();
                    break;
                }
            }

            case 4:
            {
                array = (
                    from p in array
                    orderby p.ProductConsultationInfo.Count() descending
                    select p).ToArray();
                break;
            }

            case 5:
            {
                array = (
                    from p in array
                    orderby p.AddedDate descending
                    select p).ToArray();
                break;
            }
            }
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = productSearch1.PageNumber,
                ItemsPerPage = pageSize,
                TotalItems   = total
            };

            ViewBag.pageInfo = pagingInfo;
            CategoryInfo categoryInfo = ServiceHelper.Create <ICategoryService>().GetCategory(cid);

            if (categoryInfo != null && categoryInfo.Depth == 3)
            {
                array = (
                    from p in array
                    where p.CategoryId == cid
                    select p).ToArray();
            }
            return(View(array ?? new ProductInfo[0]));
        }
Пример #10
0
 /// <summary>
 /// 创建商品属性
 /// </summary>
 public static bool CreateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     return(BrnShop.Data.Products.CreateProductAttribute(productAttributeInfo));
 }
Пример #11
0
        public static ProductInfo GetProductInfo(ProductDetailModel m, long productId)
        {
            CategoryInfo category = ServiceHelper.Create <ICategoryService>().GetCategory(m.categoryId);
            decimal      num      = new decimal(0);

            if (m.specificationsValue.Count <= 0)
            {
                num = decimal.Parse(m.mallPrce);
            }
            else
            {
                List <decimal> list = (
                    from p in m.specificationsValue
                    select decimal.Parse(p.mallPrice)).ToList();
                num = list.Min();
            }
            ProductInfo productInfo = new ProductInfo()
            {
                Id                           = productId,
                TypeId                       = category.TypeId,
                AddedDate                    = DateTime.Now,
                BrandId                      = m.brandId,
                CategoryId                   = m.categoryId,
                CategoryPath                 = category.Path,
                MarketPrice                  = decimal.Parse(m.marketPrice),
                ShortDescription             = m.adWord,
                ProductCode                  = m.productCode,
                ImagePath                    = "",
                DisplaySequence              = 1,
                ProductName                  = m.goodsName,
                MinSalePrice                 = num,
                ShopId                       = 1,
                HasSKU                       = true,
                DisableBuy                   = m.DisableBuy,
                Quantity                     = Convert.ToInt32(m.stock),//¿â´æ
                ProductAttributeInfo         = new List <ProductAttributeInfo>(),
                Himall_ProductShopCategories = new List <ProductShopCategoryInfo>()
            };
            ProductDescriptionInfo productDescriptionInfo = new ProductDescriptionInfo()
            {
                AuditReason          = "",
                Description          = m.des,
                MobileDescription    = m.mdes,
                DescriptionPrefixId  = m.styleTemplateId[0],
                DescriptiondSuffixId = m.styleTemplateId[1],
                Meta_Description     = m.seoDes,
                Meta_Keywords        = m.seoKey,
                Meta_Title           = m.seoTitle,
                ProductId            = productId
            };

            productInfo.ProductDescriptionInfo = productDescriptionInfo;
            productInfo.SKUInfo           = new List <SKUInfo>();
            productInfo.SaleStatus        = (ProductInfo.ProductSaleStatus)m.saleStatus;
            productInfo.AuditStatus       = ProductInfo.ProductAuditStatus.WaitForAuditing;
            productInfo.FreightTemplateId = m.FreightTemplateId;
            productInfo.MeasureUnit       = m.MeasureUnit;
            productInfo.Volume            = new decimal?(m.Volume);
            productInfo.Weight            = new decimal?(m.Weight);
            ProductInfo productInfo1 = productInfo;

            foreach (AttrSelectData attrSelectDatum in m.attrSelectData)
            {
                string[] strArrays = attrSelectDatum.valueId.Split(new char[] { ',' });
                for (int i = 0; i < strArrays.Length; i++)
                {
                    string str = strArrays[i];
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        ICollection <ProductAttributeInfo> productAttributeInfo = productInfo1.ProductAttributeInfo;
                        ProductAttributeInfo productAttributeInfo1 = new ProductAttributeInfo()
                        {
                            AttributeId = attrSelectDatum.attrId,
                            ProductId   = productId,
                            ValueId     = long.Parse(str)
                        };
                        productAttributeInfo.Add(productAttributeInfo1);
                    }
                }
            }
            foreach (long num1 in m.goodsCategory)
            {
                if (num1.Equals(0))
                {
                    continue;
                }
                ICollection <ProductShopCategoryInfo> himallProductShopCategories = productInfo1.Himall_ProductShopCategories;
                ProductShopCategoryInfo productShopCategoryInfo = new ProductShopCategoryInfo()
                {
                    ProductId      = productId,
                    ShopCategoryId = num1
                };
                himallProductShopCategories.Add(productShopCategoryInfo);
            }
            return(productInfo1);
        }
Пример #12
0
        public ActionResult Detail(string id)
        {
            ProductDescriptionTemplateInfo template;
            long                        num15;
            TimeSpan                    span;
            TimeSpan                    span2;
            TimeSpan                    span3;
            ParameterExpression         expression;
            LimitTimeBuyDetailModel     model  = new LimitTimeBuyDetailModel();
            string                      str    = "";
            LimitTimeProductDetailModel model2 = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };
            FlashSaleModel model3    = null;
            ShopInfo       shop      = null;
            long           productId = 0L;
            long           result    = 0L;

            if (long.TryParse(id, out result))
            {
            }
            if (result == 0L)
            {
                return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            model3 = this._iLimitTimeBuyService.Get(result);
            switch (model3.Status)
            {
            case FlashSaleInfo.FlashSaleStatus.Ended:
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));

            case FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
            }
            model2.FlashSale = model3;
            if ((model3 == null) || (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing))
            {
                model3 = (model3 == null) ? this._iLimitTimeBuyService.GetFlaseSaleByProductId(result) : model3;
                if (model3 == null)
                {
                    return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
                }
            }
            if ((model3 != null) && ((model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) || (DateTime.Parse(model3.EndDate) < DateTime.Now)))
            {
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
            }
            model2.MaxSaleCount = model3.LimitCountOfThePeople;
            model2.Title        = model3.Title;
            shop = this._iShopService.GetShop(model3.ShopId, false);
            if ((model3 == null) || (model3.Id == 0L))
            {
                return(base.RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ProductInfo product = this._iProductService.GetProduct(model3.ProductId);

            productId                 = model3.ProductId;
            model2.Product            = product;
            model2.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0L)
            {
                template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                model2.DescriptionPrefix = (template == null) ? "" : template.Content;
            }
            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0L)
            {
                template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                model2.DescriptiondSuffix = (template == null) ? "" : template.Content;
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            model2.Shop.PackMark          = shopComprehensiveMark.PackMark;
            model2.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            model2.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            IQueryable <ProductCommentInfo> commentsByProductId = this._iCommentService.GetCommentsByProductId(productId);

            model2.Shop.Name = shop.ShopName;
            Decimal num1;

            if (commentsByProductId != null && Queryable.Count <ProductCommentInfo>(commentsByProductId) != 0)
            {
                num1 = Queryable.Average <ProductCommentInfo>(commentsByProductId, (Expression <Func <ProductCommentInfo, Decimal> >)(p => (Decimal)p.ReviewMark));
            }
            else
            {
                num1 = new Decimal(0);
            }
            model2.Shop.ProductMark = num1;
            model2.Shop.Id          = product.ShopId;
            model2.Shop.FreeFreight = shop.FreeFreight;
            model.ProductNum        = this._iProductService.GetShopOnsaleProducts(product.ShopId);
            model.FavoriteShopCount = this._iShopService.GetShopFavoritesCount(product.ShopId);
            if (base.CurrentUser == null)
            {
                model.IsFavorite     = false;
                model.IsFavoriteShop = false;
            }
            else
            {
                model.IsFavorite     = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id);
                model.IsFavoriteShop = (from item in this._iShopService.GetFavoriteShopInfos(base.CurrentUser.Id) select item.ShopId).ToArray <long>().Contains <long>(product.ShopId);
            }
            List <ShopCategoryInfo> source = this._iShopCategoryService.GetShopCategory(product.ShopId).ToList <ShopCategoryInfo>();

            using (IEnumerator <ShopCategoryInfo> enumerator = (from s in source
                                                                where s.ParentCategoryId == 0L
                                                                select s).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Func <ShopCategoryInfo, bool> predicate = null;
                    ShopCategoryInfo  main   = enumerator.Current;
                    CategoryJsonModel model5 = new CategoryJsonModel
                    {
                        Name        = main.Name,
                        Id          = main.Id.ToString(),
                        SubCategory = new List <SecondLevelCategory>()
                    };
                    if (predicate == null)
                    {
                        predicate = s => s.ParentCategoryId == main.Id;
                    }
                    foreach (ShopCategoryInfo info4 in source.Where <ShopCategoryInfo>(predicate))
                    {
                        SecondLevelCategory category = new SecondLevelCategory
                        {
                            Name = info4.Name,
                            Id   = info4.Id.ToString()
                        };
                        model5.SubCategory.Add(category);
                    }
                    model2.ShopCategory.Add(model5);
                }
            }
            IQueryable <ProductInfo> hotSaleProduct = this._iProductService.GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                foreach (ProductInfo info5 in hotSaleProduct.ToArray <ProductInfo>())
                {
                    HotProductInfo info6 = new HotProductInfo
                    {
                        ImgPath   = info5.ImagePath,
                        Name      = info5.ProductName,
                        Price     = info5.MinSalePrice,
                        Id        = info5.Id,
                        SaleCount = (int)info5.SaleCounts
                    };
                    model2.HotSaleProducts.Add(info6);
                }
            }
            IQueryable <ProductInfo> hotConcernedProduct = this._iProductService.GetHotConcernedProduct(shop.Id, 5);

            if (hotConcernedProduct != null)
            {
                foreach (ProductInfo info5 in hotConcernedProduct.ToArray <ProductInfo>())
                {
                    HotProductInfo info7 = new HotProductInfo
                    {
                        ImgPath   = info5.ImagePath,
                        Name      = info5.ProductName,
                        Price     = info5.MinSalePrice,
                        Id        = info5.Id,
                        SaleCount = info5.ConcernedCount
                    };
                    model2.HotAttentionProducts.Add(info7);
                }
            }
            ProductTypeInfo type = this._iTypeService.GetType(product.TypeId);
            string          str2 = ((type == null) || string.IsNullOrEmpty(type.ColorAlias)) ? SpecificationType.Color.ToDescription() : type.ColorAlias;
            string          str3 = ((type == null) || string.IsNullOrEmpty(type.SizeAlias)) ? SpecificationType.Size.ToDescription() : type.SizeAlias;
            string          str4 = ((type == null) || string.IsNullOrEmpty(type.VersionAlias)) ? SpecificationType.Version.ToDescription() : type.VersionAlias;

            model2.ColorAlias   = str2;
            model2.SizeAlias    = str3;
            model2.VersionAlias = str4;
            if ((product.SKUInfo != null) && (product.SKUInfo.Count <SKUInfo>() > 0))
            {
                long num3 = 0L;
                long num4 = 0L;
                long num5 = 0L;
                using (IEnumerator <SKUInfo> enumerator3 = product.SKUInfo.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        Func <ProductSKU, bool> func2 = null;
                        Func <SKUInfo, bool>    func3 = null;
                        Func <ProductSKU, bool> func4 = null;
                        Func <SKUInfo, bool>    func5 = null;
                        Func <ProductSKU, bool> func6 = null;
                        Func <SKUInfo, bool>    func7 = null;
                        SKUInfo  sku      = enumerator3.Current;
                        string[] strArray = sku.Id.Split(new char[] { '_' });
                        if (strArray.Count <string>() > 0)
                        {
                            if (long.TryParse(strArray[1], out num3))
                            {
                            }
                            if (num3 != 0L)
                            {
                                if (func2 == null)
                                {
                                    func2 = v => v.Value.Equals(sku.Color);
                                }
                                if (!model2.Color.Any <ProductSKU>(func2))
                                {
                                    if (func3 == null)
                                    {
                                        func3 = s => s.Color.Equals(sku.Color);
                                    }
                                    long       num6 = product.SKUInfo.Where <SKUInfo>(func3).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock));
                                    ProductSKU tsku = new ProductSKU
                                    {
                                        Name          = "选择" + str2,
                                        EnabledClass  = (num6 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num3,
                                        Value         = sku.Color,
                                        Img           = sku.ShowPic
                                    };
                                    model2.Color.Add(tsku);
                                }
                            }
                        }
                        if (strArray.Count <string>() > 1)
                        {
                            if (long.TryParse(strArray[2], out num4))
                            {
                            }
                            if (num4 != 0L)
                            {
                                if (func4 == null)
                                {
                                    func4 = v => v.Value.Equals(sku.Size);
                                }
                                if (!model2.Size.Any <ProductSKU>(func4))
                                {
                                    if (func5 == null)
                                    {
                                        func5 = s => s.Size.Equals(sku.Size);
                                    }
                                    long       num7  = product.SKUInfo.Where <SKUInfo>(func5).Sum <SKUInfo>((Func <SKUInfo, long>)(s1 => s1.Stock));
                                    ProductSKU tsku2 = new ProductSKU
                                    {
                                        Name          = "选择" + str3,
                                        EnabledClass  = (num7 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num4,
                                        Value         = sku.Size
                                    };
                                    model2.Size.Add(tsku2);
                                }
                            }
                        }
                        if (strArray.Count <string>() > 2)
                        {
                            if (long.TryParse(strArray[3], out num5))
                            {
                            }
                            if (num5 != 0L)
                            {
                                if (func6 == null)
                                {
                                    func6 = v => v.Value.Equals(sku.Version);
                                }
                                if (!model2.Version.Any <ProductSKU>(func6))
                                {
                                    if (func7 == null)
                                    {
                                        func7 = s => s.Version.Equals(sku.Version);
                                    }
                                    long       num8  = product.SKUInfo.Where <SKUInfo>(func7).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock));
                                    ProductSKU tsku3 = new ProductSKU
                                    {
                                        Name          = "选择" + str4,
                                        EnabledClass  = (num8 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num5,
                                        Value         = sku.Version
                                    };
                                    model2.Version.Add(tsku3);
                                }
                            }
                        }
                    }
                }
                decimal num9  = 0M;
                decimal num10 = 0M;
                num9 = (from s in product.SKUInfo
                        where s.Stock >= 0L
                        select s).Min <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice));
                num10 = (from s in product.SKUInfo
                         where s.Stock >= 0L
                         select s).Max <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice));
                if ((num9 == 0M) && (num10 == 0M))
                {
                    str = product.MinSalePrice.ToString("f2");
                }
                else if (num10 > num9)
                {
                    str = string.Format("{0}-{1}", num9.ToString("f2"), num10.ToString("f2"));
                }
                else
                {
                    str = string.Format("{0}", num9.ToString("f2"));
                }
            }
            model.Price = string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str;
            List <TypeAttributesModel>  list2 = new List <TypeAttributesModel>();
            List <ProductAttributeInfo> list3 = this._iProductService.GetProductAttribute(product.Id).ToList <ProductAttributeInfo>();

            using (List <ProductAttributeInfo> .Enumerator enumerator4 = list3.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    Func <TypeAttributesModel, bool> func9  = null;
                    Func <TypeAttributesModel, bool> func10 = null;
                    Func <TypeAttrValue, bool>       func11 = null;
                    Func <AttributeValueInfo, bool>  func12 = null;
                    ProductAttributeInfo             attr   = enumerator4.Current;
                    if (func9 == null)
                    {
                        func9 = p => p.AttrId == attr.AttributeId;
                    }
                    if (!list2.Any <TypeAttributesModel>(func9))
                    {
                        TypeAttributesModel model7 = new TypeAttributesModel
                        {
                            AttrId     = attr.AttributeId,
                            AttrValues = new List <TypeAttrValue>(),
                            Name       = attr.AttributesInfo.Name
                        };
                        using (IEnumerator <AttributeValueInfo> enumerator5 = attr.AttributesInfo.AttributeValueInfo.GetEnumerator())
                        {
                            while (enumerator5.MoveNext())
                            {
                                Func <ProductAttributeInfo, bool> func8 = null;
                                AttributeValueInfo attrV = enumerator5.Current;
                                if (func8 == null)
                                {
                                    func8 = p => p.ValueId == attrV.Id;
                                }
                                if (list3.Any <ProductAttributeInfo>(func8))
                                {
                                    TypeAttrValue value2 = new TypeAttrValue
                                    {
                                        Id   = attrV.Id.ToString(),
                                        Name = attrV.Value
                                    };
                                    model7.AttrValues.Add(value2);
                                }
                            }
                        }
                        list2.Add(model7);
                    }
                    else
                    {
                        if (func10 == null)
                        {
                            func10 = p => p.AttrId == attr.AttributeId;
                        }
                        TypeAttributesModel model9 = list2.FirstOrDefault <TypeAttributesModel>(func10);
                        if (func11 == null)
                        {
                            func11 = p => p.Id == attr.ValueId.ToString();
                        }
                        if (!model9.AttrValues.Any <TypeAttrValue>(func11))
                        {
                            TypeAttrValue value3 = new TypeAttrValue
                            {
                                Id = attr.ValueId.ToString()
                            };
                            if (func12 == null)
                            {
                                func12 = a => a.Id == attr.ValueId;
                            }
                            value3.Name = attr.AttributesInfo.AttributeValueInfo.FirstOrDefault <AttributeValueInfo>(func12).Value;
                            model9.AttrValues.Add(value3);
                        }
                    }
                }
            }
            model.ProductAttrs = list2;
            IEnumerable <ProductCommentInfo> enumerable = Enumerable.Where <ProductCommentInfo>((IEnumerable <ProductCommentInfo>)product.Himall_ProductComments, (Func <ProductCommentInfo, bool>)(item => !item.IsHidden.HasValue || !item.IsHidden.Value));
            int num11 = enumerable.Count <ProductCommentInfo>();

            model.CommentCount = num11;
            IQueryable <ProductConsultationInfo> consultations = this._iConsultationService.GetConsultations(productId);

            model.Consultations = consultations.Count <ProductConsultationInfo>();
            double num12 = num11;
            double num13 = enumerable.Count <ProductCommentInfo>(item => item.ReviewMark >= 4);

            model.NicePercent   = (int)((num13 / num12) * 100.0);
            model.Consultations = consultations.Count <ProductConsultationInfo>();
            if (this._iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                model.VShopId = -1L;
            }
            else
            {
                model.VShopId = this._iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = this._iShopService.GetShopStatisticOrderComments(product.ShopId);
            StatisticOrderCommentsInfo info9 = (from c in shopStatisticOrderComments
                                                where ((int)c.CommentKey) == 1
                                                select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info10 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 9
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info11 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 5
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info12 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 2
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info13 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 10
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info14 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 6
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info15 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 3
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info16 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 4
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info17 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 11
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info18 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 12
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info19 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 7
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info20 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 8
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            decimal num14 = 5M;

            if (!(((info9 == null) || (info12 == null)) || shop.IsSelf))
            {
                model.ProductAndDescription     = info9.CommentValue;
                model.ProductAndDescriptionPeer = info12.CommentValue;
                model.ProductAndDescriptionMin  = info16.CommentValue;
                model.ProductAndDescriptionMax  = info15.CommentValue;
            }
            else
            {
                model.ProductAndDescription     = num14;
                model.ProductAndDescriptionPeer = num14;
                model.ProductAndDescriptionMin  = num14;
                model.ProductAndDescriptionMax  = num14;
            }
            if (!(((info10 == null) || (info13 == null)) || shop.IsSelf))
            {
                model.SellerServiceAttitude     = info10.CommentValue;
                model.SellerServiceAttitudePeer = info13.CommentValue;
                model.SellerServiceAttitudeMax  = info17.CommentValue;
                model.SellerServiceAttitudeMin  = info18.CommentValue;
            }
            else
            {
                model.SellerServiceAttitude     = num14;
                model.SellerServiceAttitudePeer = num14;
                model.SellerServiceAttitudeMax  = num14;
                model.SellerServiceAttitudeMin  = num14;
            }
            if (!(((info14 == null) || (info11 == null)) || shop.IsSelf))
            {
                model.SellerDeliverySpeed     = info11.CommentValue;
                model.SellerDeliverySpeedPeer = info14.CommentValue;
                model.SellerDeliverySpeedMax  = (info19 != null) ? info19.CommentValue : 0M;
                model.sellerDeliverySpeedMin  = (info20 != null) ? info20.CommentValue : 0M;
            }
            else
            {
                model.SellerDeliverySpeed     = num14;
                model.SellerDeliverySpeedPeer = num14;
                model.SellerDeliverySpeedMax  = num14;
                model.sellerDeliverySpeedMin  = num14;
            }
            if ((base.CurrentUser != null) && (base.CurrentUser.Id > 0L))
            {
                model2.IsFavorite = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id);
            }
            else
            {
                model2.IsFavorite = false;
            }
            VShopInfo vShopByShopId = this._iVShopService.GetVShopByShopId(shop.Id);

            if (vShopByShopId == null)
            {
                num15 = -1L;
            }
            else
            {
                num15 = vShopByShopId.Id;
            }
            model.VShopId       = num15;
            model2.Shop.VShopId = num15;
            model2.VShopLog     = this._iVShopService.GetVShopLog(model2.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model2.VShopLog))
            {
                model2.VShopLog = base.CurrentSiteSetting.WXLogo;
            }
            model.Logined     = (base.CurrentUser != null) ? 1 : 0;
            model2.EnabledBuy = (((product.AuditStatus == ProductInfo.ProductAuditStatus.Audited) && (DateTime.Parse(model3.BeginDate) <= DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now)) && (product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale);
            if (((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) < DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now))
            {
                span         = new TimeSpan(DateTime.Parse(model3.EndDate).Ticks);
                span2        = new TimeSpan(DateTime.Now.Ticks);
                span3        = span.Subtract(span2);
                model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds;
            }
            else if ((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) > DateTime.Now))
            {
                span         = new TimeSpan(DateTime.Parse(model3.BeginDate).Ticks);
                span2        = new TimeSpan(DateTime.Now.Ticks);
                span3        = span.Subtract(span2);
                model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds;
            }
            ((dynamic)base.ViewBag).DetailModel = model;
            List <Himall.DTO.CustomerService> mobileCustomerService = CustomerServiceApplication.GetMobileCustomerService(model3.ShopId);

            Himall.DTO.CustomerService service = Enumerable.FirstOrDefault <Himall.DTO.CustomerService>((IEnumerable <Himall.DTO.CustomerService>)CustomerServiceApplication.GetPreSaleByShopId(model3.ShopId), (Func <Himall.DTO.CustomerService, bool>)(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia));
            if (service != null)
            {
                mobileCustomerService.Insert(0, service);
            }
            ((dynamic)base.ViewBag).CustomerServices = mobileCustomerService;
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            return(base.View(model2));
        }