pengchanglu vor 2 Jahren
Ursprung
Commit
9f79f435b8

+ 60 - 0
application/admin/controller/lottery/Lottery.php

@@ -33,5 +33,65 @@ class Lottery extends Backend
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
 
+    //过滤
+    public function filter($ids = null){
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        $code = $row->code;
+        $arr = explode('-',$code);
+        if(count($arr) != 5){
+            $this->error('录入code有问题!');
+        }
+
+        $tickets = new \app\admin\model\lottery\Tickets;
+
+        $whereAll = [
+                't1' =>$arr[0],
+                't2' =>$arr[1],
+                't3' =>$arr[2],
+                't4' =>$arr[3],
+                't5' =>$arr[4],
+            ];
+        //先去掉 5个的
+        $tickets->where($whereAll)->update(['deletetime'=>time()]);
+
+        //去掉 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>";
+        }
+
+
+        //去掉 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>";
+
+            }
+            // code...
+        }
+
+        //$this->success("成功过滤掉".$row['title'].'号码!');
+    }
 
 }

+ 50 - 0
application/admin/controller/lottery/Tickets.php

@@ -33,5 +33,55 @@ class Tickets extends Backend
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
 
+/*    public function init(){
+        //初始化数据
+        //35 选 5
+
+        set_time_limit(0);
+
+        for ($i=1; $i<=31; $i++) {
+          for ($j=$i+1; $j<=32; $j++) {
+            $code = [];//初始化 35*35插入
+
+            for ($k=$j+1; $k<=33; $k++) {
+              for ($l=$k+1; $l<=34; $l++) {
+                for ($m=$l+1; $m<=35; $m++) {
+
+
+                    $combination = [$i, $j, $k, $l, $m];
+                    sort($combination); // 将组合数组升序排序
+                    $unique_combination = array_unique($combination); // 去掉重复的数字
+                    if (count($unique_combination) === 5) { // 确保选出的数字数量为5个
+                        $arr['t1'] = $i;
+                        $arr['t2'] = $j;
+                        $arr['t3'] = $k;
+                        $arr['t4'] = $l;
+                        $arr['t5'] = $m;
+                        $code[] =  $arr;
+                        $arr = [];
+                    }
+                    
+                }
+                //$this->model->allowField(true)->saveAll($code);
+                //exit;
+              }
+            }
+            $this->model->allowField(true)->saveAll($code);
+          }
+        }  
+    }
+    */
+
+    //重置
+    public function reset(){
+        $sql = "UPDATE `pi_tickets` SET `deletetime`=NULL";
+        $rs = $this->model->execute($sql);
+        echo $rs;
+    }
+
+    public function filter(){
+        echo '过滤';
+    }
+
 
 }