123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?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){
- $restore = $this->request->get("restore");
- if(isset($restore) && $restore ==1 ){
-
- $deletetime = null;
- }else{
- $deletetime = time();
- }
- $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;
- $tickets = $tickets->withTrashed();//包含软连的数据
- // 构建五个字段数组
- $fieldsAll = array("t1", "t2", "t3", "t4", "t5");
- $where5 = array_combine($fieldsAll,$arr);
- //先去掉 5个的
- $tickets->where($where5)->update(['deletetime'=>$deletetime]);
- //echo $tickets->getLastsql()."</br>";
- //print_r($where);exit;
- //去掉 4个 的 5 种
- 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'=>$deletetime]);
- //echo $tickets->getLastsql()."</br>";
- $where4 = [];
- }
- }
- //去掉 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'=>$deletetime]);
- //echo $tickets->getLastsql()."</br>";
- }
- }
- }
- }
- }
- }
- $this->success("成功处理--".$row['title'].'--号码!');
- }
- }
|