Lottery.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace app\admin\controller\lottery;
  3. use app\common\controller\Backend;
  4. /**
  5. *
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Lottery extends Backend
  10. {
  11. /**
  12. * Lottery模型对象
  13. * @var \app\admin\model\lottery\Lottery
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\lottery\Lottery;
  20. }
  21. /**
  22. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  23. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  24. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  25. */
  26. //过滤
  27. public function filter($ids = null){
  28. $row = $this->model->get($ids);
  29. if (!$row) {
  30. $this->error(__('No Results were found'));
  31. }
  32. $adminIds = $this->getDataLimitAdminIds();
  33. if (is_array($adminIds)) {
  34. if (!in_array($row[$this->dataLimitField], $adminIds)) {
  35. $this->error(__('You have no permission'));
  36. }
  37. }
  38. $code = $row->code;
  39. $arr = explode('-',$code);
  40. if(count($arr) != 5){
  41. $this->error('录入code有问题!');
  42. }
  43. $tickets = new \app\admin\model\lottery\Tickets;
  44. $whereAll = [
  45. 't1' =>$arr[0],
  46. 't2' =>$arr[1],
  47. 't3' =>$arr[2],
  48. 't4' =>$arr[3],
  49. 't5' =>$arr[4],
  50. ];
  51. //先去掉 5个的
  52. $tickets->where($whereAll)->update(['deletetime'=>time()]);
  53. //去掉 4个 的 5 种
  54. foreach ($arr as $k => $v) {
  55. $where5= $whereAll;
  56. $key = "t" . ($k+1);
  57. unset($where5[$key]);
  58. $where4 = $where5;
  59. $tickets->where($where4)->update(['deletetime'=>time()]);
  60. echo $tickets->getLastsql()."</br>";
  61. }
  62. //去掉 3个的 c5 3 10 种情况
  63. $count = count($arr);
  64. for ($i=1; $i<=$count; $i++) {
  65. for ($j=$i+1; $j <=$count ; $j++) {
  66. $where5= $whereAll;
  67. unset($where5["t".$i]);
  68. unset($where5["t".$j]);
  69. //echo "t".$i .'==='."t".$j ."</br>";
  70. $where3 = $where5;
  71. $tickets->where($where3)->update(['deletetime'=>time()]);
  72. echo $tickets->getLastsql()."</br>";
  73. }
  74. // code...
  75. }
  76. //$this->success("成功过滤掉".$row['title'].'号码!');
  77. }
  78. }