pengchanglu 2 سال پیش
والد
کامیت
46d5caf125

+ 43 - 33
application/admin/controller/lottery/Lottery.php

@@ -53,45 +53,55 @@ class Lottery extends Backend
 
         $tickets = new \app\admin\model\lottery\Tickets;
 
-        $whereAll = [
-                't1' =>$arr[0],
-                't2' =>$arr[1],
-                't3' =>$arr[2],
-                't4' =>$arr[3],
-                't5' =>$arr[4],
-            ];
+        // 构建五个字段数组
+        $fieldsAll = array("t1", "t2", "t3", "t4", "t5");
+        $where5 = array_combine($fieldsAll,$arr);
+
         //先去掉 5个的
-        $tickets->where($whereAll)->update(['deletetime'=>time()]);
+        $tickets->where($where5)->update(['deletetime'=>time()]);
+        //echo $tickets->getLastsql()."</br>";
 
+        //print_r($where);exit;
         //去掉 4个 的 5 种
-        foreach ($arr as $k => $v) {
-            $where5= $whereAll;
-            $key = "t" . ($k+1);
-            unset($where5[$key]);
-            $where4 = $where5;
-            $tickets->where($where4)->update(['deletetime'=>time()]);
-            echo $tickets->getLastsql()."</br>";
+        foreach ($fieldsAll as $k1 => $v1) {
+            $fields = $fieldsAll;
+            unset($fields[$k1]);   
+            foreach ($arr as $k2 => $v2) {
+                $temp = $arr;
+                unset($temp[$k2]);
+                $where4 = array_combine($fields,$temp);
+                $tickets->where($where4)->update(['deletetime'=>time()]);
+                //echo $tickets->getLastsql()."</br>";
+                $where4 = [];
+            }
         }
-
-
-        //去掉 3个的  c5 3  10 种情况
-        $count = count($arr);
-        for ($i=1; $i<=$count; $i++) { 
-            
-            for ($j=$i+1; $j <=$count ; $j++) {
-                $where5= $whereAll;
-                unset($where5["t".$i]);
-                unset($where5["t".$j]);
-                //echo "t".$i .'==='."t".$j ."</br>";
-                $where3 = $where5;
-                $tickets->where($where3)->update(['deletetime'=>time()]);
-                echo $tickets->getLastsql()."</br>";
-
+        //去掉 3个的  c5 3  10*10种情况
+        // 构建两个初始数组
+// 构建结果数组
+//$results = array();
+
+// 遍历两个数组,生成所有的三个元素的组合
+foreach ($fieldsAll as $i => $key) {
+    foreach (array_slice($fieldsAll, $i + 1) as $j => $key2) {
+        foreach (array_slice($fieldsAll, $j + $i + 2) as $k => $key3) {
+            foreach ($arr as $v1) {
+                foreach (array_slice($arr, array_search($v1, $arr) + 1) as $v2) {
+                    foreach (array_slice($arr, array_search($v2, $arr) + 1) as $v3) {
+                        $where3 = array(
+                            $key => $v1,
+                            $key2 => $v2,
+                            $key3 => $v3
+                        );
+                        //$results[] = $where3;
+                        $tickets->where($where3)->update(['deletetime'=>time()]);
+                        //echo $tickets->getLastsql()."</br>";
+                    }
+                }
             }
-            // code...
         }
-
-        //$this->success("成功过滤掉".$row['title'].'号码!');
+    }
+}     
+    $this->success("成功过滤掉--".$row['title'].'--号码!');
     }
 
 }

+ 4 - 2
application/admin/controller/lottery/Tickets.php

@@ -74,9 +74,11 @@ class Tickets extends Backend
 
     //重置
     public function reset(){
-        $sql = "UPDATE `pi_tickets` SET `deletetime`=NULL";
+        set_time_limit(0);
+        $sql = "UPDATE `pi_tickets` SET `deletetime`=NULL ";
         $rs = $this->model->execute($sql);
-        echo $rs;
+        $this->success("成功还原--".$rs.'--个号码!');
+        //echo $rs;
     }
 
     public function filter(){

+ 1 - 0
application/admin/view/lottery/tickets/index.html

@@ -21,6 +21,7 @@
                         </div>
 
                         <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('lottery/tickets/recyclebin')?'':'hide'}" href="lottery/tickets/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
+                        <a class="btn bg-red  _js_recycle_tickets" href="javascript:;"><i class="fa fa-leaf"></i> 还原奖池</a>
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('lottery/tickets/edit')}"

+ 17 - 1
public/assets/js/backend/lottery/lottery.js

@@ -30,7 +30,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'title', title: __('Title'), operate: 'LIKE'},
                         {field: 'memo', title: __('Memo'), operate: 'LIKE'},
                         {field: 'createtime', title: __('Createtime')},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {
+                            field: 'operate', 
+                            title: __('Operate'), 
+                            table: table, events: 
+                            Table.api.events.operate, 
+                            buttons: [
+                                {
+                                    name: 'filter',
+                                    text: '过滤',
+                                    classname: 'btn btn-xs btn-info btn-ajax',
+                                    icon: 'fa fa-rotate-left',
+                                    url: 'lottery/lottery/filter?ids={id}',
+                                    refresh: true
+                                }  
+                            ],
+                            formatter: Table.api.formatter.operate
+                        }
                     ]
                 ]
             });

+ 36 - 11
public/assets/js/backend/lottery/ticket.js → public/assets/js/backend/lottery/tickets.js

@@ -5,13 +5,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格参数配置
             Table.api.init({
                 extend: {
-                    index_url: 'lottery/ticket/index' + location.search,
-                    add_url: 'lottery/ticket/add',
-                    edit_url: 'lottery/ticket/edit',
-                    del_url: 'lottery/ticket/del',
-                    multi_url: 'lottery/ticket/multi',
-                    import_url: 'lottery/ticket/import',
-                    table: 'ticket',
+                    index_url: 'lottery/tickets/index' + location.search,
+                    add_url: 'lottery/tickets/add',
+                    edit_url: 'lottery/tickets/edit',
+                    del_url: 'lottery/tickets/del',
+                    multi_url: 'lottery/tickets/multi',
+                    import_url: 'lottery/tickets/import',
+                    table: 'tickets',
                 }
             });
 
@@ -26,7 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'code', title: __('Code'), operate: 'LIKE'},
+                        {field: 't1', title: __('T1')},
+                        {field: 't2', title: __('T2')},
+                        {field: 't3', title: __('T3')},
+                        {field: 't4', title: __('T4')},
+                        {field: 't5', title: __('T5')},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
@@ -34,6 +38,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
             // 为表格绑定事件
             Table.api.bindevent(table);
+            // 还原奖池 点击处理
+            $(document).on("click", "._js_recycle_tickets", function () {
+                
+                Layer.confirm('确认还原?,还原和重新过滤都需要很长时间?', {
+                    icon: 3,
+                    title: '确认还原?'
+                }, function (index) {
+                    Backend.api.ajax({
+                        url: "lottery/tickets/reset"   
+                    }, function () {
+                        //$(that).closest("tr").remove();
+                        Layer.close(index);
+                        table.bootstrapTable('refresh');
+                    });
+                });
+            });
         },
         recyclebin: function () {
             // 初始化表格参数配置
@@ -47,13 +67,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
             // 初始化表格
             table.bootstrapTable({
-                url: 'lottery/ticket/recyclebin' + location.search,
+                url: 'lottery/tickets/recyclebin' + location.search,
                 pk: 'id',
                 sortName: 'id',
                 columns: [
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
+                        {field: 't1', title: __('T1')},
+                        {field: 't2', title: __('T2')},
+                        {field: 't3', title: __('T3')},
+                        {field: 't4', title: __('T4')},
+                        {field: 't5', title: __('T5')},
                         {
                             field: 'deletetime',
                             title: __('Deletetime'),
@@ -73,7 +98,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     text: __('Restore'),
                                     classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                     icon: 'fa fa-rotate-left',
-                                    url: 'lottery/ticket/restore',
+                                    url: 'lottery/tickets/restore',
                                     refresh: true
                                 },
                                 {
@@ -81,7 +106,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     text: __('Destroy'),
                                     classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                     icon: 'fa fa-times',
-                                    url: 'lottery/ticket/destroy',
+                                    url: 'lottery/tickets/destroy',
                                     refresh: true
                                 }
                             ],