public List <ProductCateDto> GetProductCateList() { var topCateList = _dal.FindListBySql <ProductCateDto>($"SELECT id,name,parent_id,(SELECT count(0) from ivt_product WHERE cate_id=g.id AND delete_time=0) as productCnt FROM d_general as g WHERE general_table_id={(int)GeneralTableEnum.PRODUCT_CATE} and parent_id is null and delete_time=0 ORDER BY id ASC;"); List <ProductCateDto> dtoList = new List <ProductCateDto>(); if (topCateList != null && topCateList.Count > 0) { foreach (var cate in topCateList) { cate.nodes = AddSubNode(cate.id); dtoList.Add(cate); } } return(dtoList); }
/// <summary> /// //删除操作 /// </summary> /// <param name="id"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE Delete(long id, long user_id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } var data = _dal.FindById(id); if (data == null) { return(ERROR_CODE.ERROR); } var udf_data = _dal.FindById(Convert.ToInt64(data.ext1)); crm_installed_product_dal dal1 = new crm_installed_product_dal(); ivt_product_dal dal2 = new ivt_product_dal(); var installed_product = dal1.FindListBySql($"select * from crm_installed_product where cate_id={id} and delete_time=0"); var product = dal2.FindListBySql($"select * from ivt_product where installed_product_cate_id={id} and delete_time=0"); var product_cate = _dal.FindListBySql($"select * from d_general where ext1='{id.ToString()}' and delete_time=0"); if (installed_product.Count > 0) { foreach (var i in installed_product) { i.cate_id = 0; i.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); i.update_user_id = user_id; if (dal1.Update(i)) { var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONFIGURAITEM, // oper_object_id = i.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.AddValue(i), remark = "修改产品配置项" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 } } } if (product.Count > 0) { foreach (var i in product) { i.installed_product_cate_id = null; i.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); i.update_user_id = user_id; if (dal2.Update(i)) { var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT, // oper_object_id = i.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.AddValue(i), remark = "修改产品配置项" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 } } } if (product_cate.Count > 0) { foreach (var i in product_cate) { i.ext1 = null; i.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); i.update_user_id = user_id; if (_dal.Update(i)) { var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.General_Code, // oper_object_id = i.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.AddValue(i), remark = "修改配置项种类" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 } } } long time = data.delete_time = udf_data.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); data.delete_user_id = udf_data.delete_user_id = user.id; try { int n = new sys_udf_group_field_dal().ExecuteSQL($"update sys_udf_group_field set delete_time='{time}' and delete_user_id='{user.id}' where group_id={udf_data.id}"); } catch { return(ERROR_CODE.ERROR); } if (!_dal.Update(data)) { return(ERROR_CODE.ERROR); } if (!_dal.Update(udf_data)) { return(ERROR_CODE.ERROR); } return(ERROR_CODE.SUCCESS); }