DuGuYang пре 3 година
родитељ
комит
dbef667bfb
1 измењених фајлова са 114 додато и 1 уклоњено
  1. 114 1
      Areas/Admin/Controllers/MainServer/UserRankWhiteController.cs

+ 114 - 1
Areas/Admin/Controllers/MainServer/UserRankWhiteController.cs

@@ -380,7 +380,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 导出Excel
         /// 导出Excel
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        public JsonResult ExportExcel(UserRankWhite data, string MakerCode, string RealName, string StatusSelect)
+        public JsonResult ExportExcel(UserRankWhite data, string MakerCode, string RealName, string StatusSelect, string TopMakerCode, string UpdateDateData)
         {
         {
             Dictionary<string, string> Fields = new Dictionary<string, string>();
             Dictionary<string, string> Fields = new Dictionary<string, string>();
 
 
@@ -400,6 +400,42 @@ namespace MySystem.Areas.Admin.Controllers
             {
             {
                 condition += " and Status=" + StatusSelect;
                 condition += " and Status=" + StatusSelect;
             }
             }
+            //顶级创客编号
+            if (!string.IsNullOrEmpty(TopMakerCode))
+            {
+                var topUser = db.Users.FirstOrDefault(m => m.MakerCode == TopMakerCode) ?? new Users();
+                var childIds = "";
+                // if (!string.IsNullOrEmpty(topUser.ParentNav))
+                // {
+                //     string[] ParentNavList = topUser.ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                //     var topUserId = "," + topUser.Id + ",";
+                //     if (ParentNavList.Length > 1)
+                //     {
+                //         var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                //         foreach (var item in childUser)
+                //         {
+                //             childIds = item.Id + ",";
+                //         }
+                //         childIds = childIds.TrimEnd(',');
+                //     }
+                // }
+                var topUserId = "," + topUser.Id + ",";
+                var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                foreach (var item in childUser)
+                {
+                    childIds += item.Id + ",";
+                }
+                childIds = childIds.TrimEnd(',');
+                condition += " and UserId in (" + childIds + ")";
+            }
+            //到期时间
+            if (!string.IsNullOrEmpty(UpdateDateData))
+            {
+                string[] datelist = UpdateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and UpdateDate>='" + start + " 00:00:00' and UpdateDate<='" + end + " 23:59:59'";
+            }
 
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserRankWhite", Fields, "Id desc", "0", 1, 20000, condition, "UserId,Rank,Status,CreateDate", false);
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserRankWhite", Fields, "Id desc", "0", 1, 20000, condition, "UserId,Rank,Status,CreateDate", false);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
@@ -448,5 +484,82 @@ namespace MySystem.Areas.Admin.Controllers
 
 
         #endregion
         #endregion
 
 
+
+
+        #region 快捷导出Excel
+        public IActionResult QuickExportExcel(string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            return View();
+        }
+
+        [HttpPost]
+        public string QuickExportExcelDo(string MakerCode, string RealName, string StatusSelect, string TopMakerCode, string UpdateDateData)
+        {
+
+            string SqlString = " and Status>-1";
+            string condition = " and Status>-1";
+            //创客编号
+            if (!string.IsNullOrEmpty(MakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
+            }
+            //创客名称
+            if (!string.IsNullOrEmpty(RealName))
+            {
+                condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
+            }
+            //状态
+            if (!string.IsNullOrEmpty(StatusSelect))
+            {
+                condition += " and Status=" + StatusSelect;
+            }
+            //顶级创客编号
+            if (!string.IsNullOrEmpty(TopMakerCode))
+            {
+                var topUser = db.Users.FirstOrDefault(m => m.MakerCode == TopMakerCode) ?? new Users();
+                var childIds = "";
+                // if (!string.IsNullOrEmpty(topUser.ParentNav))
+                // {
+                //     string[] ParentNavList = topUser.ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                //     var topUserId = "," + topUser.Id + ",";
+                //     if (ParentNavList.Length > 1)
+                //     {
+                //         var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                //         foreach (var item in childUser)
+                //         {
+                //             childIds = item.Id + ",";
+                //         }
+                //         childIds = childIds.TrimEnd(',');
+                //     }
+                // }
+                var topUserId = "," + topUser.Id + ",";
+                var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                foreach (var item in childUser)
+                {
+                    childIds += item.Id + ",";
+                }
+                childIds = childIds.TrimEnd(',');
+                condition += " and UserId in (" + childIds + ")";
+            }
+            //到期时间
+            if (!string.IsNullOrEmpty(UpdateDateData))
+            {
+                string[] datelist = UpdateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and UpdateDate>='" + start + " 00:00:00' and UpdateDate<='" + end + " 23:59:59'";
+            }
+            var Sql = "SELECT c.MakerCode '创客编号',c.RealName '创客姓名',DATE_FORMAT(c.CreateDate,'%Y-%m-%d %H:%i:%s') '创建时间',c.Remark '变动类型',c.Type1Num '电签兑换券张数',c.Type2Num '大POS兑换券张数',d.LeaderBalanceAmount '可提现余额',c.ChangeAmt '使用额度',c.BeforeAmt '使用前剩余额度',c.AfterAmt '使用后剩余额度' FROM(SELECT a.*,b.MakerCode,b.RealName FROM(SELECT Id,UserId,CreateDate,ChangeAmt,BeforeAmt,AfterAmt,Remark,REPLACE (JSON_EXTRACT (SeoTitle, '$[0].Num'),'\\\"','') AS 'Type1Num', REPLACE (JSON_EXTRACT (SeoTitle, '$[1].Num'),'\\\"','') AS 'Type2Num' FROM LeaderReserveRecord WHERE 1=1 " + SqlString + ") a LEFT JOIN Users b ON a.UserId=b.Id) c LEFT JOIN UserAccount d ON c.UserId=d.Id";
+            var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
+            var FileName = "创客预设职级记录" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            string SendData = "{\"Operater\":\"" + sysAdmin.Id + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
+            RedisDbconn.Instance.AddList("ExportQueue", SendData);
+            return "success";
+        }
+        #endregion
+
     }
     }
 }
 }