/// <summary>
        /// 通过oid查询后台类目
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="oid"></param>
        /// <returns></returns>
        public IEnumerable <VW_ProductCategoriesModel> SelectProductCategoriesForOid(IEnumerable <int> oids)
        {
            Func <SqlConnection, IEnumerable <VW_ProductCategoriesModel> > action = (connection) => OperationCategoryDAL.SelectProductCategoriesForOid(connection, oids);

            return(dbManager.Execute(action));
        }
Example #2
0
        public static List <CommentItemWithProductName> GetAllCommentListByExportExcel(int type, int pageDim, string keyWord, int wordCount, string InstallShop, string CommentProductId, string CommentTousuType,
                                                                                       DateTime?commentstartDate, DateTime?commentendDate, DateTime?auditstartDate, DateTime?auditendDate, ref List <KeyValuePair <LambdaExpression, OrderType> > order, List <int> otherfilter, string orderId)
        {
            GungnirDataContext            dc           = new GungnirDataContext(ConfigurationManager.ConnectionStrings["Gungnir_AlwaysOnRead"].ConnectionString);
            IQueryable <tbl_CommentTousu> commentTousu = dc.tbl_CommentTousu;

            var result = GetAllCommentListWithProductName(type, pageDim, keyWord, wordCount, InstallShop, CommentProductId, CommentTousuType,
                                                          commentstartDate, commentendDate, auditstartDate, auditendDate, ref order, otherfilter, orderId);

            if (result != null && result.Any())
            {
                var pids = result.Select(cl => "'" + cl.CommentProductId + "'").ToList();

                var productModels = OperationCategoryDAL.FetchPrProductsModelByProductIds(pids);
                if (productModels != null && productModels.Any())
                {
                    result.ForEach(cl => cl.CommentProductName = productModels.Where(pm => pm.PID == cl.CommentProductId).FirstOrDefault() == null ? null : productModels.Where(pm => pm.PID == cl.CommentProductId).FirstOrDefault().DisplayName);
                }
            }
            var tousuTypeItems = dc.TousuType.Select(view => new TousuTypeItem()
            {
                DicType   = view.DicType,
                DicText   = view.DicText,
                DicValue  = view.DicValue,
                TypeLevel = view.TypeLevel
            }).ToList();

            foreach (var item in result)
            {
                if (!string.IsNullOrEmpty(item.CommentExtAttr))
                {
                    item.CommentExtAttr = Regex.Match(item.CommentExtAttr, @"InstallShop[^ID][\s|\S]*[-]*.*testUserInfo").ToString()
                                          .Replace("InstallShop", "").Replace("testUserInfo", "").Replace(":", "")
                                          .Replace(",", "").Replace("\"", "");
                }
                if (!string.IsNullOrEmpty(item.CommentSource))
                {
                    if (item.CommentSource == "0")
                    {
                        item.CommentSource = "PC端";
                    }
                    else if (item.CommentSource == "1")
                    {
                        item.CommentSource = "手机端";
                    }
                }
                if (!string.IsNullOrEmpty(item.CommentStatusName))
                {
                    if (item.CommentStatusName == "0")
                    {
                        item.CommentStatusName = "审核不通过";
                    }
                    else if (item.CommentStatusName == "1")
                    {
                        item.CommentStatusName = "未审核";
                    }
                    else if (item.CommentStatusName == "2")
                    {
                        item.CommentStatusName = "审核通过";
                    }
                    else if (item.CommentStatusName == "3")
                    {
                        item.CommentStatusName = "仅打分";
                    }
                }
            }

            for (var i = 0; i < result.Count(); i++)
            {
                var complaint = result[i].Complaint;
                if (!string.IsNullOrEmpty(complaint))
                {
                    result[i].ComplaintItem = JsonConvert.DeserializeObject <List <Complaint> >(complaint);
                    var complaintItems = result[i].ComplaintItem;
                    foreach (var item in complaintItems)
                    {
                        var           typeText      = string.Empty;
                        TousuTypeItem tousuTypeItem = null;
                        string        key           = item.key;
                        int           level         = 0;
                        bool          flag          = true;
                        while (flag)
                        {
                            if (level == 0)
                            {
                                tousuTypeItem = tousuTypeItems.Where(fd => fd.DicValue.Equals(key)).FirstOrDefault();
                            }
                            else
                            {
                                tousuTypeItem = tousuTypeItems.Where(fd => fd.DicValue.Equals(key) &&
                                                                     fd.TypeLevel.Equals(level - 1)).FirstOrDefault();
                            }
                            if (tousuTypeItem != null)
                            {
                                typeText = tousuTypeItem.DicText + "-" + typeText;
                                key      = tousuTypeItem.DicType;
                                level    = tousuTypeItem.TypeLevel;
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                        if (!string.IsNullOrEmpty(typeText))
                        {
                            typeText = typeText.TrimEnd('-');
                            result[i].ComplaintItems += typeText + "|";
                        }
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// 更新关联产品关系
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="oid"></param>
        /// <param name="type"></param>
        /// <param name="lists"></param>
        /// <returns></returns>
        public bool UpdateOperationCategoryProducts(int oid, int type, List <OperationCategoryProductsModel> lists)
        {
            Func <SqlConnection, bool> action = (connection) => OperationCategoryDAL.UpdateOperationCategoryProducts(connection, oid, type, lists);

            return(dbManager.Execute(action));
        }
        /// <summary>
        /// 获取后台类目集合
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ZTreeModel> SelectProductCategories()
        {
            Func <SqlConnection, IEnumerable <ZTreeModel> > action = (connection) => OperationCategoryDAL.SelectProductCategories(connection);

            return(dbManager.Execute(action));
        }
        /// <summary>
        /// 获取关联产品
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="oid"></param>
        /// <returns></returns>
        public IEnumerable <OperationCategoryProductsModel> SelectOperationCategoryProducts(int oid)
        {
            Func <SqlConnection, IEnumerable <OperationCategoryProductsModel> > action = (connection) => OperationCategoryDAL.SelectOperationCategoryProducts(connection, oid);

            return(dbManager.Execute(action));
        }
        public bool Delete(int id)
        {
            Func <SqlConnection, bool> action = (connection) => OperationCategoryDAL.Delete(connection, id);

            return(dbManager.Execute(action));
        }
        public bool Update(OperationCategoryModel model)
        {
            Func <SqlConnection, bool> action = (connection) => OperationCategoryDAL.Update(connection, model);

            return(dbManager.Execute(action));
        }
        public IEnumerable <OperationCategoryModel> Select(int?id, int?parentId, int?type)
        {
            Func <SqlConnection, IEnumerable <OperationCategoryModel> > action = (connection) => OperationCategoryDAL.Select(connection, id, parentId, type);

            return(dbManager.Execute(action));
        }
        /// <summary>
        /// 查询产品信息
        /// </summary>
        /// <returns></returns>
        public IEnumerable <VW_ProductsModel> SelectProductCategories(IEnumerable <string> tags, bool isOid = false)
        {
            Func <SqlConnection, IEnumerable <VW_ProductsModel> > action = (connection) => OperationCategoryDAL.SelectProductCategories(connection, tags, isOid);

            return(dbManager.Execute(action));
        }