Przeglądaj źródła

后台-客小爽-创客信息管理-新增创客系统批量查询完成,待测试

DuGuYang 3 lat temu
rodzic
commit
a1f9949757

+ 60 - 12
Areas/Admin/Controllers/MainServer/UsersController.cs

@@ -2525,6 +2525,11 @@ namespace MySystem.Areas.Admin.Controllers
                 Dictionary<string, object> objs = new Dictionary<string, object>();
                 return Json(objs);
             }
+            else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
+            {
+                Dictionary<string, object> objs = new Dictionary<string, object>();
+                return Json(objs);
+            }
             else
             {
                 if (!string.IsNullOrEmpty(PosSns))
@@ -2591,8 +2596,8 @@ namespace MySystem.Areas.Admin.Controllers
                             data["PosSn"] = pos.PosSn; //机具Sn
                             data["MerNo"] = mer.KqMerNo; //商户编号
                             data["PosFee"] = SeoKeyword; //服务费
-                            data["BindingTime"] = pos.BindingTime; //绑定时间
-                            data["ActivationTime"] = pos.ActivationTime; //激活时间
+                            data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
+                            data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
                             data["MakerCode"] = user.MakerCode; //创客编号
                             data["RealName"] = user.RealName; //创客姓名
                             data["TopMakerCode"] = TopMakerCode; //顶级创客编号
@@ -2669,8 +2674,8 @@ namespace MySystem.Areas.Admin.Controllers
                             data["PosSn"] = pos.PosSn; //机具Sn
                             data["MerNo"] = mer.KqMerNo; //商户编号
                             data["PosFee"] = SeoKeyword; //服务费
-                            data["BindingTime"] = pos.BindingTime; //绑定时间
-                            data["ActivationTime"] = pos.ActivationTime; //激活时间
+                            data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
+                            data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
                             data["MakerCode"] = user.MakerCode; //创客编号
                             data["RealName"] = user.RealName; //创客姓名
                             data["TopMakerCode"] = TopMakerCode; //顶级创客编号
@@ -2701,16 +2706,59 @@ namespace MySystem.Areas.Admin.Controllers
         #endregion
 
 
-        #region 上级创客导出Excel
-
-        /// <summary>
-        /// 上级创客导出Excel
-        /// </summary>
-        /// <returns></returns>
-        public JsonResult ExportBatchSeeUserInfoExcel(string PosSns, string MerNos)
+        #region 批量查询创客信息快捷导出Excel
+        public IActionResult ExportBatchSeeUserInfoExcel(string right)
         {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
 
-            return Json("111");
+            return View();
+        }
+
+        [HttpPost]
+        public string ExportBatchSeeUserInfoExcelDo(string PosSns, string MerNos)
+        {
+            var sql = "";
+            if (string.IsNullOrEmpty(PosSns) && string.IsNullOrEmpty(MerNos))
+            {
+                return "请输入查询内容";
+            }
+            else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
+            {
+                return "不能同时输入机具Sn和商户编号";
+            }
+            else
+            {
+                if (!string.IsNullOrEmpty(PosSns))
+                {
+                    var posIds = "";
+                    string[] PosSnsList = PosSns.Replace("\r", "").Replace("\n", ",").Split(',');
+                    foreach (string PosSn in PosSnsList)
+                    {
+                        var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
+                        posIds += pos.Id + ",";
+                    }
+                    posIds = posIds.TrimEnd(',');
+                    sql = "SELECT i.PosSn '机具SN',j.KqMerNo '商编',j.MerchantName '商户名称',(CASE WHEN i.BrandId not in(2,7,10,11) THEN ROUND(CAST(i.SeoKeyword AS DECIMAL)/100, 2) ELSE i.SeoKeyword end) '服务费',DATE_FORMAT(i.BindingTime,'%Y-%m-%d %H:%i:%s') '绑定时间',DATE_FORMAT(i.ActivationTime,'%Y-%m-%d %H:%i:%s') '激活时间',i.uMakerCode '推荐码',i.uRealName '创客姓名',i.topMakerCode '顶级推荐码',i.topRealname '顶级姓名',i.secondMakerCode '次顶级推荐码',i.secondRealname '次顶级姓名',i.thirdMakerCode '次次顶级推荐码',i.thirdRealname '次次顶级姓名'  FROM(SELECT g.*,h.MakerCode thirdMakerCode,h.Realname thirdRealname FROM (SELECT e.*,f.MakerCode secondMakerCode,f.Realname secondRealname FROM(SELECT c.*,d.MakerCode topMakerCode,d.Realname topRealname FROM(SELECT a.*,b.Id useId,b.MakerCode uMakerCode,b.RealName uRealName, SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',8),',',-1) thirdId FROM PosMachinesTwo a LEFT JOIN Users b ON a.BuyUserId=b.Id WHERE a.Id in(" + posIds + "))c LEFT JOIN Users d ON c.topId=d.Id) e LEFT JOIN Users f ON e.secondId=f.Id) g LEFT JOIN Users h ON g.thirdId=h.Id) i LEFT JOIN PosMerchantInfo j ON i.BindMerchantId=j.Id";
+                }
+                if (!string.IsNullOrEmpty(MerNos))
+                {
+                    var merIds = "";
+                    string[] MerNosList = MerNos.Replace("\r", "").Replace("\n", ",").Split(',');
+                    foreach (string MerNo in MerNosList)
+                    {
+                        var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
+                        merIds += mer.Id + ",";
+                    }
+                    merIds = merIds.TrimEnd(',');
+                    sql = "SELECT i.KqSnNo '机具SN',i.KqMerNo '商编',i.MerchantName '商户名称',i.SeoKeyword '服务费',i.BindingTime '绑定时间',i.ActivationTime '激活时间',i.uMakerCode '推荐码',i.uRealName '创客姓名',i.topMakerCode '顶级推荐码',i.topRealname '顶级姓名',i.secondMakerCode '次顶级推荐码',i.secondRealname '次顶级姓名',j.MakerCode '次次顶级推荐码',j.Realname '次次顶级姓名' FROM(SELECT g.*,h.MakerCode secondMakerCode,h.Realname secondRealname FROM(SELECT e.*,f.MakerCode topMakerCode,f.RealName topRealName FROM(SELECT c.*,d.MakerCode uMakerCode,d.RealName uRealName,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',8),',',-1) thirdId FROM(SELECT a.KqMerNo,a.KqSnNo,a.MerchantName,(CASE WHEN b.BrandId not in(2,7,10,11) THEN ROUND(CAST(b.SeoKeyword AS DECIMAL)/100, 2) ELSE b.SeoKeyword end) SeoKeyword,b.BindingTime,b.ActivationTime,b.BuyUserId,b.BrandId FROM PosMerchantInfo a LEFT JOIN PosMachinesTwo b ON a.KqSnNo=b.PosSn WHERE a.Id in(" + merIds + "))c LEFT JOIN Users d ON c.BuyUserId=d.Id) e LEFT JOIN Users f ON e.topId=f.Id) g LEFT JOIN Users h ON g.secondId=h.Id) i LEFT JOIN Users j ON i.thirdId=j.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
 

+ 13 - 2
Areas/Admin/Views/MainServer/Users/BatchSeeUserInfo.cshtml

@@ -49,6 +49,18 @@
                     <input class="layui-input" type="hidden" name="ShowFlag" autocomplete="off">
                     <div class="layui-form-item">
                         <div class="layui-inline">
+                            <label class="layui-form-label">机具Sn</label>
+                            <div class="layui-input-inline">
+                                <input class="layui-input" type="text" id="PosSns" name="PosSns" placeholder="多个机具Sn用逗号隔开" autocomplete="off">
+                            </div>
+                        </div>
+                        <div class="layui-inline">
+                            <label class="layui-form-label">商户编号</label>
+                            <div class="layui-input-inline">
+                                <input class="layui-input" type="text" id="MerNos" name="MerNos" placeholder="多个商户编号用逗号隔开" autocomplete="off">
+                            </div>
+                        </div>
+                        @* <div class="layui-inline">
                             <label class="layui-form-label">机具Sn</label>
                             <div class="layui-input-inline">
                                 <textarea class="layui-textarea" name="PosSn"
@@ -61,7 +73,7 @@
                                 <textarea class="layui-textarea" name="MerNos"
                                     id="MerNos" placeholder="请输入商户编号,多个商户编号用回车隔开"></textarea>
                             </div>
-                        </div>
+                        </div> *@
                         <div class="layui-inline ml50">
                             <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
                                 <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
@@ -87,7 +99,6 @@
     <script
         src="/layuiadmin/modules_main/BatchSeeUserInfo_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
     <script>
-        var UserId = '@UserId';
     </script>
 </body>
 

+ 23 - 267
wwwroot/layuiadmin/modules_main/BatchSeeUserInfo_Admin.js

@@ -1,21 +1,4 @@
 var ExcelData;
-function ConfirmImport() {
-    $.ajax({
-        type: "POST",
-        url: "/Admin/UserAccountRecord/Import?r=" + Math.random(1),
-        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
-        dataType: "text",
-        success: function (data) {
-            if (data == "success") {
-                layer.msg("导入成功", { time: 2000 }, function () {
-                    window.location.reload();
-                });
-            } else {
-                layer.msg(data);
-            }
-        }
-    });
-}
 
 var excel;
 layui.config({
@@ -68,22 +51,6 @@ layui.config({
         });
     });
 
-    //监听单元格编辑
-    table.on('edit(LAY-list-manage)', function (obj) {
-        var value = obj.value //得到修改后的值
-            , data = obj.data //得到所在行所有键值
-            , field = obj.field; //得到字段
-        if (field == "Sort") {
-            $.ajax({
-                type: "POST",
-                url: "/Admin/UserAccountRecord/Sort?r=" + Math.random(1),
-                data: "Id=" + data.Id + "&Sort=" + value,
-                dataType: "text",
-                success: function (data) {
-                }
-            });
-        }
-    });
 
     //列表数据
     table.render({
@@ -106,7 +73,6 @@ layui.config({
             , { field: 'ThirdRealName', width: 160, title: '次次顶级创客姓名', sort: true }
         ]]
         , where: {
-            UserId: UserId
         }
         , page: true
         , limit: 30
@@ -120,86 +86,7 @@ layui.config({
     //监听工具条
     table.on('tool(LAY-list-manage)', function (obj) {
         var data = obj.data;
-        if (obj.event === 'del') {
-            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
-                $.ajax({
-                    type: "POST",
-                    url: "/Admin/UserAccountRecord/Delete?r=" + Math.random(1),
-                    data: "Id=" + data.Id,
-                    dataType: "text",
-                    success: function (data) {
-                        if (data == "success") {
-                            obj.del();
-                            layer.close(index);
-                        } else {
-                            parent.layer.msg(data);
-                        }
-                    }
-                });
-            });
-        } else if (obj.event === 'edit') {
-            var tr = $(obj.tr);
-            var perContent = layer.open({
-                type: 2
-                , title: '创客账户变动记录-编辑'
-                , content: 'Edit?Id=' + data.Id + ''
-                , maxmin: true
-                , area: ['500px', '450px']
-                , btn: ['确定', '取消']
-                , yes: function (index, layero) {
-                    var iframeWindow = window['layui-layer-iframe' + index]
-                        , submitID = 'LAY-list-front-submit'
-                        , submit = layero.find('iframe').contents().find('#' + submitID);
 
-                    setTimeout(function () {
-                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
-                            var errObj = $(this).find('.layui-form-danger');
-                            if (errObj.length > 0) {
-                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
-                                submit.click();
-                            }
-                        });
-                    }, 300);
-
-
-
-
-
-
-                    //监听提交
-                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
-                        var field = data.field; //获取提交的字段
-                        var userdata = "";
-                        for (var prop in field) {
-                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
-                        }
-                        //提交 Ajax 成功后,静态更新表格中的数据
-                        //$.ajax({});
-
-                        $.ajax({
-                            type: "POST",
-                            url: "/Admin/UserAccountRecord/Edit?r=" + Math.random(1),
-                            data: userdata,
-                            dataType: "text",
-                            success: function (data) {
-                                layer.close(index); //关闭弹层
-                                if (data == "success") {
-                                    table.reload('LAY-list-manage'); //数据刷新
-                                } else {
-                                    layer.msg(data);
-                                }
-                            }
-                        });
-                    });
-
-                    submit.trigger('click');
-                }
-                , success: function (layero, index) {
-
-                }
-            });
-            layer.full(perContent);
-        }
     });
 
 
@@ -222,95 +109,7 @@ layui.config({
 
     //事件
     var active = {
-        batchdel: function () {
-            var checkStatus = table.checkStatus('LAY-list-manage')
-                , data = checkStatus.data; //得到选中的数据
-            if (data.length < 1) {
-                parent.layer.msg("请选择要删除的项");
-            } else {
-                var ids = "";
-                $.each(data, function (index, value) {
-                    ids += data[index].Id + ",";
-                });
-                ids = ids.substring(0, ids.length - 1);
-                var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
-                    $.ajax({
-                        type: "POST",
-                        url: "/Admin/UserAccountRecord/Delete?r=" + Math.random(1),
-                        data: "Id=" + ids,
-                        dataType: "text",
-                        success: function (data) {
-                            layer.close(index);
-                            if (data == "success") {
-                                table.reload('LAY-list-manage');
-                            } else {
-                                layer.msg(data);
-                            }
-                        }
-                    });
-                });
-            }
-        }
-        , add: function () {
-            var perContent = layer.open({
-                type: 2
-                , title: '创客账户变动记录-添加'
-                , content: 'Add'
-                , maxmin: true
-                , area: ['500px', '450px']
-                , btn: ['确定', '取消']
-                , yes: function (index, layero) {
-                    var iframeWindow = window['layui-layer-iframe' + index]
-                        , submitID = 'LAY-list-front-submit'
-                        , submit = layero.find('iframe').contents().find('#' + submitID);
-
-                    setTimeout(function () {
-                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
-                            var errObj = $(this).find('.layui-form-danger');
-                            if (errObj.length > 0) {
-                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
-                                submit.click();
-                            }
-                        });
-                    }, 300);
-
-
-
-
-
-
-                    //监听提交
-                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
-                        var field = data.field; //获取提交的字段
-                        var userdata = "";
-                        for (var prop in field) {
-                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
-                        }
-                        //提交 Ajax 成功后,静态更新表格中的数据
-                        //$.ajax({});
-
-                        $.ajax({
-                            type: "POST",
-                            url: "/Admin/UserAccountRecord/Add?r=" + Math.random(1),
-                            data: userdata,
-                            dataType: "text",
-                            success: function (data) {
-                                layer.close(index); //关闭弹层
-                                if (data == "success") {
-                                    table.reload('LAY-list-manage'); //数据刷新
-                                } else {
-                                    layer.msg(data);
-                                }
-                            }
-                        });
-                    });
-
-                    submit.trigger('click');
-                }
-            });
-            layer.full(perContent);
-        }
-        , ImportData: function () {
+        ImportData: function () {
             layer.open({
                 type: 1,
                 title: '导入',
@@ -329,74 +128,31 @@ 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');
-                }
-            });
-        }
-        , Open: function () {
-            var checkStatus = table.checkStatus('LAY-list-manage')
-                , data = checkStatus.data; //得到选中的数据
-            if (data.length < 1) {
-                parent.layer.msg("请选择要开启的项");
-            } else {
-                var ids = "";
-                $.each(data, function (index, value) {
-                    ids += data[index].Id + ",";
+            var index = layer.confirm('确定导出吗?', function (index) {
+                var indexs = layer.load(1, {
+                    shade: [0.5, '#000']
                 });
-                ids = ids.substring(0, ids.length - 1);
-                var index = layer.confirm('确定要开启吗?', function (index) {
-                    $.ajax({
-                        type: "POST",
-                        url: "/Admin/UserAccountRecord/Open?r=" + Math.random(1),
-                        data: "Id=" + ids,
-                        dataType: "text",
-                        success: function (data) {
-                            layer.close(index);
-                            if (data == "success") {
-                                table.reload('LAY-list-manage');
-                            } else {
-                                layer.msg(data);
-                            }
-                        }
-                    });
-                });
-            }
-        }
-        , Close: function () {
-            var checkStatus = table.checkStatus('LAY-list-manage')
-                , data = checkStatus.data; //得到选中的数据
-            if (data.length < 1) {
-                parent.layer.msg("请选择要关闭的项");
-            } else {
-                var ids = "";
-                $.each(data, function (index, value) {
-                    ids += data[index].Id + ",";
-                });
-                ids = ids.substring(0, ids.length - 1);
-                var index = layer.confirm('确定要关闭吗?', function (index) {
-                    $.ajax({
-                        type: "POST",
-                        url: "/Admin/UserAccountRecord/Close?r=" + Math.random(1),
-                        data: "Id=" + ids,
-                        dataType: "text",
-                        success: function (data) {
-                            layer.close(index);
-                            if (data == "success") {
-                                table.reload('LAY-list-manage');
-                            } else {
-                                layer.msg(data);
-                            }
+                $.ajax({
+                    type: "Post",
+                    url: "/Admin/Users/ExportBatchSeeUserInfoExcelDo?r=" + Math.random(1),
+                    data: userdata,
+                    dataType: "json",
+                    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);
                         }
-                    });
+                    }
                 });
-            }
+            });
         }
     };