Lottery.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. // 构建五个字段数组
  45. $fieldsAll = array("t1", "t2", "t3", "t4", "t5");
  46. $where5 = array_combine($fieldsAll,$arr);
  47. //先去掉 5个的
  48. $tickets->where($where5)->update(['deletetime'=>time()]);
  49. //echo $tickets->getLastsql()."</br>";
  50. //print_r($where);exit;
  51. //去掉 4个 的 5 种
  52. foreach ($fieldsAll as $k1 => $v1) {
  53. $fields = $fieldsAll;
  54. unset($fields[$k1]);
  55. foreach ($arr as $k2 => $v2) {
  56. $temp = $arr;
  57. unset($temp[$k2]);
  58. $where4 = array_combine($fields,$temp);
  59. $tickets->where($where4)->update(['deletetime'=>time()]);
  60. //echo $tickets->getLastsql()."</br>";
  61. $where4 = [];
  62. }
  63. }
  64. //去掉 3个的 c5 3 10*10种情况
  65. // 构建两个初始数组
  66. // 构建结果数组
  67. //$results = array();
  68. // 遍历两个数组,生成所有的三个元素的组合
  69. foreach ($fieldsAll as $i => $key) {
  70. foreach (array_slice($fieldsAll, $i + 1) as $j => $key2) {
  71. foreach (array_slice($fieldsAll, $j + $i + 2) as $k => $key3) {
  72. foreach ($arr as $v1) {
  73. foreach (array_slice($arr, array_search($v1, $arr) + 1) as $v2) {
  74. foreach (array_slice($arr, array_search($v2, $arr) + 1) as $v3) {
  75. $where3 = array(
  76. $key => $v1,
  77. $key2 => $v2,
  78. $key3 => $v3
  79. );
  80. //$results[] = $where3;
  81. $tickets->where($where3)->update(['deletetime'=>time()]);
  82. //echo $tickets->getLastsql()."</br>";
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. $this->success("成功过滤掉--".$row['title'].'--号码!');
  90. }
  91. }