12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace app\admin\controller\lottery;
- use app\common\controller\Backend;
- /**
- *
- *
- * @icon fa fa-circle-o
- */
- class Lottery extends Backend
- {
- /**
- * Lottery模型对象
- * @var \app\admin\model\lottery\Lottery
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\lottery\Lottery;
- }
- /**
- * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
- * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
- * 需要将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'].'号码!');
- }
- }
|