Browse Source

创客账户变动记录导出功能完成,待测试

DuGuYang 3 years ago
parent
commit
0694360920

+ 30 - 39
Areas/Admin/Controllers/MainServer/UserAccountRecordController.cs

@@ -131,22 +131,10 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 if (int.Parse(ChangeType) > 0)
                 {
-                    // if (ChangeType == 0)
-                    // {
-                    //     condition += " and ChangeType in(0,12)";
-                    // }
                     if (int.Parse(ChangeType) == 1)
                     {
                         condition += " and (ChangeType=" + int.Parse(ChangeType) + " or (ChangeType in(112,1) and ProductType=101))";
                     }
-                    else if (int.Parse(ChangeType) == 30)
-                    {
-                        condition += " and ChangeType=31 and Remark='开机抢红包活动'";
-                    }
-                    else if (int.Parse(ChangeType) == 31)
-                    {
-                        condition += " and (ChangeType=" + int.Parse(ChangeType) + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
-                    }
                     else if (int.Parse(ChangeType) == 112)
                     {
                         condition += " and ChangeType=112 and ProductType=0";
@@ -514,7 +502,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 导出Excel
         /// </summary>
         /// <returns></returns>
-        public JsonResult ExportExcel(UserAccountRecord data, int ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, string CreateDateData, int TopUserId, int UserId)
+        public JsonResult ExportExcel(UserAccountRecord data, string ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, string CreateDateData, int TopUserId, int UserId)
         {
             Dictionary<string, string> Fields = new Dictionary<string, string>();
             // Fields.Add("ChangeType", "1"); //交易类型
@@ -541,23 +529,26 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and UserId=" + UserId;
             }
-            if (ChangeType > 0)
+            if (!string.IsNullOrEmpty(ChangeType))
             {
-                if (ChangeType == 1)
-                {
-                    condition += " and (ChangeType=" + ChangeType + " or (ChangeType in(112,1) and ProductType=101))";
-                }
-                else if (ChangeType == 30)
-                {
-                    condition += " and ChangeType=31 and Remark='开机抢红包活动'";
-                }
-                else if (ChangeType == 31)
+                if (int.Parse(ChangeType) > 0)
                 {
-                    condition += " and (ChangeType=" + ChangeType + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
+                    if (int.Parse(ChangeType) == 1)
+                    {
+                        condition += " and (ChangeType=" + int.Parse(ChangeType) + " or (ChangeType in(112,1) and ProductType=101))";
+                    }
+                    else if (int.Parse(ChangeType) == 112)
+                    {
+                        condition += " and ChangeType=112 and ProductType=0";
+                    }
+                    else
+                    {
+                        condition += " and ChangeType=" + int.Parse(ChangeType);
+                    }
                 }
-                else
+                if (int.Parse(ChangeType) == 0)
                 {
-                    condition += " and ChangeType=" + ChangeType;
+                    condition += " and ChangeType in(0,12)";
                 }
             }
             if (ProductType > 0)
@@ -663,43 +654,43 @@ namespace MySystem.Areas.Admin.Controllers
         public string QuickExportExcelDo(int ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, string CreateDateData)
         {
 
-            string SqlString = " and Status>-1";
+            string SqlString = " and a.Status>-1";
             //创客编号
             if (!string.IsNullOrEmpty(MakerCode))
             {
-                SqlString += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
+                SqlString += " and a.UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
             }
             //创客名称
             if (!string.IsNullOrEmpty(RealName))
             {
-                SqlString += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
+                SqlString += " and a.UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
             }
             if (ChangeType > 0)
             {
                 if (ChangeType == 1)
                 {
-                    SqlString += " and (ChangeType=" + ChangeType + " or (ChangeType in(112,1) and ProductType=101))";
+                    SqlString += " and (a.ChangeType=" + ChangeType + " or (a.ChangeType in(112,1) and a.ProductType=101))";
                 }
                 else if (ChangeType == 30)
                 {
-                    SqlString += " and ChangeType=31 and Remark='开机抢红包活动'";
+                    SqlString += " and a.ChangeType=31 and a.Remark='开机抢红包活动'";
                 }
                 else if (ChangeType == 31)
                 {
-                    SqlString += " and (ChangeType=" + ChangeType + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
+                    SqlString += " and (a.ChangeType=" + ChangeType + " and (a.Remark!='开机抢红包活动' or a.Remark IS NULL))";
                 }
                 else
                 {
-                    SqlString += " and ChangeType=" + ChangeType;
+                    SqlString += " and a.ChangeType=" + ChangeType;
                 }
             }
             if (ProductType > 0)
             {
-                SqlString += " and ProductType=" + ProductType;
+                SqlString += " and a.ProductType=" + ProductType;
             }
             if (!string.IsNullOrEmpty(TransRecordNo))
             {
-                SqlString += " and TransRecordNo='" + TransRecordNo + "'";
+                SqlString += " and a.TransRecordNo='" + TransRecordNo + "'";
             }
             if (!string.IsNullOrEmpty(CreateDateData))
             {
@@ -711,17 +702,17 @@ namespace MySystem.Areas.Admin.Controllers
                 if (check)
                 {
                     var sId = db.UserAccountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
-                    SqlString += "  and Id >=" + sId;
+                    SqlString += "  and a.Id >=" + sId;
                 }
                 if (checks)
                 {
                     var eId = db.UserAccountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
-                    SqlString += " and Id <=" + eId;
+                    SqlString += " and a.Id <=" + eId;
                 }
             }
-            var Sql = "SELECT e.MakerCode,e.RealName,f.MakerCode,f.RealName,e.`Name`,e.TransRecordNo,e.ChangeTypeName,e.ChangeAmount,e.Remark,e.BeforeTotalAmount,e.AfterTotalAmount,e.BeforeFreezeAmount,e.AfterFreezeAmount,e.BeforeBalanceAmount,e.AfterBalanceAmount,e.CreateDate FROM (SELECT b.MakerCode,b.RealName,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',4),',',-1) topId,c.`Name`,a.TransRecordNo,d.`Name` ChangeTypeName,a.ChangeAmount,a.Remark,a.BeforeTotalAmount,a.AfterTotalAmount,a.BeforeFreezeAmount,a.AfterFreezeAmount,a.BeforeBalanceAmount,a.AfterBalanceAmount,a.CreateDate FROM UserAccountRecord a LEFT JOIN Users b ON a.UserId=b.Id LEFT JOIN KqProducts c ON a.ProductType=c.Id LEFT JOIN ChangeTypes d ON a.ChangeType=d.Id WHERE a.UserId=598 LIMIT 1) e LEFT JOIN Users f ON e.topId=f.Id";
+            var Sql = "SELECT e.MakerCode '创客编号',e.RealName '创客姓名',f.MakerCode '顶级创客编号',f.RealName '顶级创客名称',e.`Name` '产品类型',e.TransRecordNo '交易流水编号',e.ChangeTypeName '交易类型',e.ChangeAmount '交易金额',e.Remark '备注',e.BeforeTotalAmount '交易前总金额',e.AfterTotalAmount '交易后总金额',e.BeforeFreezeAmount '交易前冻结金额',e.AfterFreezeAmount '交易后冻结金额',e.BeforeBalanceAmount '交易前余额',e.AfterBalanceAmount '交易后余额',e.CreateDate '交易时间' FROM (SELECT b.MakerCode,b.RealName,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',4),',',-1) topId,c.`Name`,a.TransRecordNo,d.`Name` ChangeTypeName,a.ChangeAmount,a.Remark,a.BeforeTotalAmount,a.AfterTotalAmount,a.BeforeFreezeAmount,a.AfterFreezeAmount,a.BeforeBalanceAmount,a.AfterBalanceAmount,a.CreateDate FROM UserAccountRecord a LEFT JOIN Users b ON a.UserId=b.Id LEFT JOIN KqProducts c ON a.ProductType=c.Id LEFT JOIN ChangeTypes d ON a.ChangeType=d.Id WHERE 1=1 " + SqlString + ") e LEFT JOIN Users f ON e.topId=f.Id";
             var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
-            var FileName = "盟主储蓄金变动记录" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            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";

+ 34 - 9
wwwroot/layuiadmin/modules_main/UserAccountRecord_Admin.js

@@ -385,15 +385,40 @@ layui.config({
             $(".layuiadmin-card-header-auto select").each(function (i) {
                 userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
             });
-            $.ajax({
-                type: "GET",
-                url: "/Admin/UserAccountRecord/ExportExcel?r=" + Math.random(1),
-                data: userdata,
-                dataType: "json",
-                success: function (data) {
-                    data.Obj.unshift(data.Fields);
-                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
-                }
+            // $.ajax({
+            //     type: "GET",
+            //     url: "/Admin/UserAccountRecord/ExportExcel?r=" + Math.random(1),
+            //     data: userdata,
+            //     dataType: "json",
+            //     success: function (data) {
+            //         data.Obj.unshift(data.Fields);
+            //         excel.exportExcel(data.Obj, data.Info, 'xlsx');
+            //     }
+            // });
+            var index = layer.confirm('确定导出吗?', function (index) {
+                var indexs = layer.load(1, {
+                    shade: [0.5, '#000']
+                });
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/UserAccountRecord/QuickExportExcelDo?r=" + Math.random(1),
+                    data: userdata,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(index); //关闭弹层
+                        if (data == "success") {
+                            layer.close(indexs); //关闭弹层
+                            layer.msg('导出成功,请到我的下载中点击下载文件', {
+                                time: 1000
+                            }, function () {
+                                window.location.reload();
+                            });
+                        } else {
+                            layer.close(indexs); //关闭弹层
+                            layer.msg(data);
+                        }
+                    }
+                });
             });
         }
         , Open: function () {