xieruidong il y a 2 ans
Parent
commit
751c42c0b7

+ 0 - 74
application/admin/controller/AdIndexOrderedFlow.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 已购展示管理
- *
- * @icon fa fa-circle-o
- */
-class AdIndexOrderedFlow extends Backend
-{
-    
-    /**
-     * AdIndexOrderedFlow模型对象
-     * @var \app\admin\model\AdIndexOrderedFlow
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\AdIndexOrderedFlow;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-                $row->visible(['id','num','name','no','create_time','update_time']);
-                
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-}

+ 0 - 82
application/admin/controller/Comment.php

@@ -1,82 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 
- *
- * @icon fa fa-comment
- */
-class Comment extends Backend
-{
-    
-    /**
-     * Comment模型对象
-     * @var \app\admin\model\Comment
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\Comment;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = true;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $map=[];
-            if(input('info')){
-                $map['commentable_type']='info';
-                $map['commentable_id']=input('info');
-            }
-
-            $list = $this->model
-                    ->with(['user'])
-                    ->where($where)
-                    ->where($map)
-                ->join('video','video.id=commentable_id','left')
-                    ->order($sort, $order)
-                ->field(['comment.*','video.title as video_title','video.src as video_src'])
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-				$row->getRelation('user')->visible(['nickname']);
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-}

+ 0 - 81
application/admin/controller/DataView.php

@@ -1,81 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\model\Admin;
-use app\admin\model\AuthGroup;
-use app\admin\model\AuthGroupAccess;
-use app\common\controller\Backend;
-use app\common\model\MobileOrder;
-/**
- * 
- *
- * @icon fa fa-mobile
- */
-class DataView extends Backend
-{
-    public function mobile_data(){
-        $noCount=\app\common\model\Mobile::group('status')->column('count(*)','status');
-        return view('',compact('noCount'));
-    }
-    public function order_data(){
-        $timerange=input('timerange');
-        $map=[];
-        if($timerange){
-            list($stime,$etime)=explode(' - ',$timerange);
-            $map['create_time']=['BETWEEN',[strtotime($stime),strtotime($etime)]];
-        }
-        if($this->admin('is_sub')){
-            $map['s_id']=$this->admin('id');
-        }
-        $order_count= MobileOrder::where($map)->count();
-        $sale_amount=MobileOrder::filterSaled()->where($map)->sum('amount');
-        $sale_profit=MobileOrder::filterSaled()->where($map)->sum('amount_profit');
-        return view('',compact('order_count','sale_amount','sale_profit'));
-    }
-    public function proxy_data(){
-        if ($this->request->isAjax()) {
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = (new Admin)
-                ->where($where)
-                ->where('proxy',1)
-                ->field(['password', 'salt', 'token'], true)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-            foreach ($list as $k => &$v) {
-                $v['mobile_count']=$v->mobile()->count();
-                $v['mobile_saled_count']=$v->mobile()->filterSaled()->count();
-            }
-            unset($v);
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-    public function sub_data(){
-        if ($this->request->isAjax()) {
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = (new Admin)
-                ->where($where)
-                ->where('sub',1)
-                ->field(['password', 'salt', 'token'], true)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-            foreach ($list as $k => &$v) {
-                $v['order_count']=$v->subOrder()->count();
-                $v['sell_amount']=$v->subOrder()->filterSaled()->sum('amount');
-                $v['profit_amount']=$v->subOrder()->filterSaled()->sum('amount_profit');
-            }
-            unset($v);
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-}

+ 0 - 77
application/admin/controller/Favourite.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 
- *
- * @icon fa fa-circle-o
- */
-class Favourite extends Backend
-{
-    
-    /**
-     * Favourite模型对象
-     * @var \app\admin\model\Favourite
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\Favourite;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = true;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    ->with(['user','video'])
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-                $row->visible(['id','created_at']);
-                $row->visible(['user']);
-				$row->getRelation('user')->visible(['nickname']);
-				$row->visible(['video']);
-				$row->getRelation('video')->visible(['src','title']);
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-}

+ 0 - 79
application/admin/controller/FeedbackBusiness.php

@@ -1,79 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 商务合作
- *
- * @icon fa fa-circle-o
- */
-class FeedbackBusiness extends Backend
-{
-    
-    /**
-     * FeedbackBusiness模型对象
-     * @var \app\admin\model\FeedbackBusiness
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\FeedbackBusiness;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    public function edit($ids = null)
-    {
-        $this->model->where('id',$ids)->update(['is_read'=>1]);
-        $this->success();
-    }
-
-}

+ 0 - 1189
application/admin/controller/Mobile.php

@@ -1,1189 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\model\Admin;
-use app\admin\model\MobileExportLog;
-use app\common\controller\Backend;
-use app\common\library\MobileConstant;
-use app\common\model\MobileInfo;
-use app\common\model\MobileSub;
-use app\common\service\MobileImport;
-use app\service\EsMobileService;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use PhpOffice\PhpSpreadsheet\Spreadsheet;
-use PhpOffice\PhpSpreadsheet\Style\Alignment;
-use PhpOffice\PhpSpreadsheet\Style\Border;
-use PhpOffice\PhpSpreadsheet\Style\Fill;
-use think\Db;
-use think\db\Query;
-use think\Loader;
-use app\admin\model\Mobile as MO;
-
-/**
- *
- *
- * @icon fa fa-mobile
- */
-class Mobile extends Backend
-{
-    protected $noNeedRight=['mobile_rules','status','constant','exclude_nums'];
-    /**
-     * Mobile模型对象
-     * @var \app\admin\model\Mobile
-     */
-    protected $model = null;
-    protected $relationSearch=true;
-
-    public function _initialize()
-    {
-        //ini_set('memory_limit',-1);
-        parent::_initialize();
-        $this->model = new \app\admin\model\Mobile;
-        $this->assign('status',\app\common\model\Mobile::$status);
-        $this->assign('network',MobileConstant::getNetworkString());
-        $this->assign('network_color',MobileConstant::getNetworkColor());
-        $this->assign('network_select',MobileConstant::getNetworkSelect());
-    }
-
-    public function import()
-    {
-        //MobileImport::import(input('file'),$this->auth->id);
-        MobileImport::saveFile(input('file'),$this->auth->id);
-        $this->success('上传成功,请等待导入');
-    }
-    public function import_status_disabled(){
-        //MobileImport::import(input('file'),$this->auth->id,1,\app\common\model\Mobile::cantOrderStatus());
-        MobileImport::saveFile(input('file'),$this->auth->id,1,\app\common\model\Mobile::cantOrderStatus());
-        $this->success('上传成功,请等待导入');
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        list($where, $sort, $order, $offset, $limit,$page) = $this->buildindexparams();
-
-        if($this->request->get('export')==1 && $this->auth->check('mobile/_mobile_export')){
-            if(MobileExportLog::exists()){
-                die('有未完成导出,请稍后再试');
-            }
-            $export=MobileExportLog::make($this->admin('id'));
-            ini_set('memory_limit',-1);
-            ini_set('max_execution_time',0);
-            $db=Db::name('mobile');
-            $db->getConnection()->setConfig('resultset_type','array');
-            $list= $db
-                ->where($where)
-                ->where('mobile.type',1)
-                ->orderRaw($this->getOrder())
-                ->buildSql();
-            //dd($list);
-            $export['sql']=$list;
-            $export->save();
-            die('已添加到导出日志,请稍后查看');
-            //return MobileExport::export($list,$this->admin());
-        }
-
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-
-            $deleteMode=input('_delete_condition');
-            if($deleteMode==='true'){
-                if(!$this->auth->check('mobile/del_condition')){
-                    $this->error('您无权进行此操作');
-                }
-                $num=$this->model
-                    ->alias(null)
-                    ->where($where)
-                    ->where('mobile.type',1)
-                    ->delete();
-                \app\common\model\Mobile::deleteOtherTableInfo();
-                $deleteConditionMsg=sprintf("成功删除%d个号码",$num);
-            }
-
-            if(!$this->admin('is_sub')){
-                $list = $this->model
-                    ->with(['info','proxy'])
-                    ->where($where)
-                    ->where('mobile.type',1)
-                    ->orderRaw($this->getOrder())
-                    ->page($page)
-                    ->limit($limit)
-                    ->select();
-                    //->paginate($limit);
-            }else{
-                $list=$this->model
-                    ->with(['info'])
-                    //->join('mobile_sub','mobile_sub.mobile_id=mobile.id and mobile_sub.sub_admin_id='.$this->auth->id,'left')
-                    //->field('mobile.*,mobile_sub.*')
-                    ->field('mobile.*')
-                    ->where($where)
-                    ->where('mobile.type',1)
-                    ->orderRaw($this->getOrder())
-                    ->page($page)
-                    ->limit($limit)
-                    ->select();
-                    //->paginate($limit);
-            }
-
-            foreach ($list as $row) {
-                $rules=[];
-                foreach (MobileConstant::getFilters() as $rule=>$field){
-                    foreach (array_values($field) as $column){
-                        if($row[$column]==1){
-                            $rules[]=$rule;
-                        }
-                    }
-                }
-                $row['rules']=array_values(array_unique($rules));
-
-               /* if($this->admin('is_sub')) {
-                    $row['mobile_sub'] = [
-                        'sub_sort' => (int)$row['sub_sort'],
-                        'sub_rec_time' => (int)$row['sub_rec_time'],
-                        'sub_top_time' => (int)$row['sub_top_time'],
-                    ];
-                }*/
-            }
-
-            //$result = array("total" => $list->total(), "rows" => $list->items(),'input'=>input(),'delete_condition_msg'=>$deleteConditionMsg??null);
-            $result = array("total" => EsMobileService::count(), "rows" => $list,'input'=>input(),'delete_condition_msg'=>$deleteConditionMsg??null,'url'=>$this->request->url().'&export=1');
-
-            return json($result);
-        }
-        $this->assign('no_type',array_column(MobileConstant::getNoType(),'name','id'));
-        $this->assign('filters',MobileConstant::getFilters());
-        return $this->view->fetch();
-    }
-    protected function getOrder(){
-        $filter=json_decode(input('filter'),true);
-        $default='mobile.id desc';
-        return $default;
-        if(!$filter||empty($filter['no'])){
-            return $default;
-        }
-        $value=str_replace('%','',$filter['no']);
-        if(!$value){
-            return $default;
-        }
-        $lastNum=substr($value,-1);
-        if(strlen($value)==1){
-            return "FIELD(`mobile.filter_no_pos_11`,$lastNum) DESC";
-        }else{
-            $arr=[];
-            $numLen=strlen($value);
-            $idx=1;
-            for ($i=11;$i>=2;$i--){
-                if($idx>$numLen){
-                    break;
-                }
-                $numPos=$value[$numLen-$idx];
-                $arr[]="FIELD(mobile.filter_no_pos_{$i},$numPos) DESC";
-                $idx++;
-            }
-
-            return implode(',',$arr);
-        }
-    }
-    #秒杀
-    public function mobile_kill()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildindexparams();
-
-            $map=[];
-            if($this->admin('is_sub')){
-                $map['hold_chan']=$this->auth->id;
-            }
-
-            if(!$this->admin('is_sub')){
-                $list = $this->model
-                    ->with(['info','proxy'])
-                    ->where($where)
-                    ->where($map)
-                    ->where('mobile.type',1)
-                    ->where('mobile.is_activity',1)
-                    ->orderRaw($this->getOrder())
-                    ->paginate($limit);
-            }else{
-                $list=$this->model
-                    ->with(['info'])
-                    ->join('mobile_sub','mobile_sub.mobile_id=mobile.id and mobile_sub.sub_admin_id='.$this->auth->id,'left')
-                    ->field('mobile.*,mobile_sub.*')
-                    ->where($where)
-                    ->where($map)
-                    ->where('mobile.type',1)
-                    ->where('mobile.is_activity',1)
-                    ->orderRaw($this->getOrder())
-                    ->paginate($limit);
-            }
-
-            foreach ($list as $row) {
-                $rules=[];
-                foreach (MobileConstant::getFilters() as $rule=>$field){
-                    foreach (array_values($field) as $column){
-                        if($row[$column]==1){
-                            $rules[]=$rule;
-                        }
-                    }
-                }
-                $row['rules']=array_values(array_unique($rules));
-
-                if($this->admin('is_sub')) {
-                    $row['mobile_sub'] = [
-                        'sub_sort' => (int)$row['sub_sort'],
-                        'sub_rec_time' => (int)$row['sub_rec_time'],
-                        'sub_top_time' => (int)$row['sub_top_time'],
-                    ];
-                }
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        $this->assign('no_type',array_column(MobileConstant::getNoType(),'name','id'));
-        $this->assign('filters',MobileConstant::getFilters());
-        return $this->view->fetch();
-    }
-
-    public function constant(){
-        return json([
-            'no_type'=>MobileConstant::getNoType(),
-        ]);
-    }
-
-    #置顶推荐
-    public function batch(){
-        $this->validate($data=input(),[
-            'id'=>'require',
-            'field'=>['require','in:rec_time,top_time'],
-            'status'=>'require',
-        ]);
-        $time=$data['status']?time():null;
-        $this->model->where('id',$data['id'])->update([
-            $data['field']=>$time
-        ]);
-        $this->success('','',[
-            'status'=>$time,
-        ]);
-    }
-    #设为特价
-/*    public function setdiscount($ids){
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $this->validate($data=input('row/a'),[
-                'activity_time_end'=>['date','requireIf:activity_forever,0'],
-                'activity_forever'=>['require','in:0,1'],
-            ]);
-            if($data['activity_forever']){
-                $activity_time_end=null;
-            }else {
-                if (strtotime($data['activity_time_end']) <= time()) {
-                    $this->error('请选择将来时间');
-                }
-                $activity_time_end=$data['activity_time_end'];
-            }
-            $this->model->whereIn('id',$ids)->update([
-                'is_activity'=>1,
-                'activity_time_end'=>$activity_time_end,
-            ]);
-            $this->success();
-        }
-    }*/
-    #取消设为特价
-/*    public function cancelsetdiscount(){
-        $ids=input('ids/a');
-        if($ids){
-            $this->model->whereIn('id',$ids)->update([
-                'is_activity'=>0,
-                'activity_time_end'=>null,
-            ]);
-        }
-        $this->success('');
-    }*/
-    #
-    protected function subDisabled(){
-        if($this->admin('is_manager')){
-            return false;
-        }
-        return true;
-    }
-    protected function killDisabled($mobile){
-        if($this->admin('is_manager')){
-            return false;
-        }
-        if ($mobile['is_activity']) {
-            return $mobile['hold_chan']!=$this->admin('id');
-        }else{
-            //!$this->auth->check('mobile/mobile_sort')
-            return false;
-        }
-    }
-    protected function canEditActivity(){
-
-    }
-    #预占
-    public function takeit($ids){
-        if($this->request->isGet()){
-            $mobile=$this->model->find($ids);
-            $this->assign('row',$mobile);
-            $this->assign('subDisabled',$this->subDisabled());
-            $this->assign('killDisabled',$this->killDisabled($mobile));
-            return view();
-        }else{
-            Db::startTrans();
-            $mobile=$this->model->lock(true)->find($ids);
-            $data=input('row/a');
-            $editField=[];
-            if($this->admin('is_manager')){
-                $editField=['amount_original','amount_di','amount_base','amount_charge','amount_kill','is_activity','activity_time_end'];
-            }elseif (!$this->killDisabled($mobile)){
-                $editField=['amount_kill','is_activity','activity_time_end'];
-            }else{
-                Db::rollback();
-                $this->error('无权操作');
-            }
-            foreach ($editField as $field){
-                $mobile[$field]=$data[$field];
-            }
-            if($mobile['amount_kill']<$mobile['amount_di']){
-                Db::rollback();
-                $this->error('秒杀价不能低于底价');
-            }
-            $change=$mobile->getChangedData();
-            $admin=Admin::get($this->auth->id);
-            if(isset($change['is_activity']) && $change['is_activity']){
-                if($admin['sub']){
-                    $mobile['hold_chan']=$this->auth->id;
-                }
-                $mobile['hold_user']=$this->auth->id;
-            }
-            $mobile->save();
-            Db::commit();
-            $this->success();
-        }
-    }
-
-    public function edit($ids=null){
-        if($this->request->isGet()){
-            $mobile=$this->model->find($ids);
-            $mobile['province']=\app\common\model\Area::where('id',$mobile['province_id'])->value('name');
-            $mobile['city']=\app\common\model\Area::where('id',$mobile['city_id'])->value('name');
-            if($this->admin('is_sub')){
-                $sub=MobileSub::getBy($mobile,$this->admin());
-                $mobile['rec_time']=$sub['sub_rec_time'];
-                $mobile['top_time']=$sub['sub_top_time'];
-                $mobile['sort']=$sub['sub_sort'];
-            }
-            $this->assign('row',$mobile);
-            $this->assign('disabled',$this->subDisabled());
-            $this->assign('otherSubDisabled',$this->killDisabled($mobile));
-            return view();
-        }else{
-            $data=input('row/a');
-            Db::startTrans();
-            //$mobiles=$this->model->whereIn('id',$ids)->select();
-            $mobile=$this->model->where('id',$ids)->lock(true)->find();
-            if(!$mobile){
-                $this->error('号码不存在');
-            }
-            $editField=[];
-            if($this->admin('is_manager')){
-                $editField=['network','proxy_id','brand','remark','status','amount_original','amount_di','amount_base','amount_charge','amount_kill','is_activity','activity_time_end','sort','top_time','rec_time'];
-            }elseif (!$this->killDisabled($mobile)){
-                $editField=['amount_kill','is_activity','activity_time_end'];
-            }
-            foreach ($editField as $field){
-                if(isset($data[$field])) {
-                    $mobile[$field] = $data[$field];
-                }
-            }
-            /*foreach ($mobiles as $mobile){*/
-                if($mobile['amount_kill']<$mobile['amount_di']){
-                    $this->error('秒杀价不能低于底价');
-                }
-                if($this->admin('is_manager')) {
-                    $city = $data['city'] ?? null;
-                    if ($city) {
-                        $ex = explode('/', $city);
-                        list($data['province'], $data['city']) = $ex;
-                        $data['province_id'] = \app\common\model\Area::getIdByName($data['province']);
-                        $data['city_id'] = \app\common\model\Area::getIdByName($data['city']);
-                    }
-                    $describe = $data['describe'] ?? '';
-                    if ($describe) {
-                        $mobile->info()->update(compact('describe'));
-                    }
-                }else{
-                    $sub=MobileSub::getBy($mobile,$this->admin());
-                    if($this->service()->hasRecPower()){
-                        $sub['sub_rec_time']=$data['rec_time'];
-                    }
-                    if($this->service()->hasTopPower()){
-                        $sub['sub_top_time']=$data['top_time'];
-                    }
-                    if($this->service()->hasSortPower()){
-                        $sub['sub_sort']=$data['sort'];
-                    }
-                    $sub->save();
-                }
-            $mobile->save();
-            //$mobile->makeSortLine($this->admin());
-            Db::commit();
-            /*}*/
-            $this->success();
-        }
-    }
-
-    public function multi_edit($ids){
-        if($this->request->isGet()) {
-            return view();
-        }else{
-            $tempData=input('row/a');
-            $data=[];
-            $infoData=[];
-            if(!empty($tempData['brand'])){
-                $data['brand']=$tempData['brand'];
-            }
-            if(!empty($tempData['remark'])){
-                $data['remark']=$tempData['remark'];
-            }
-            if(isset($tempData['top_time'])){
-                $data['top_time']=$tempData['top_time'];
-            }
-            if(isset($tempData['rec_time'])){
-                $data['rec_time']=$tempData['rec_time'];
-            }
-            if(!empty($tempData['describe'])){
-                $infoData['describe']=$tempData['describe'];
-            }
-
-            if($data) {
-                $mobiles = $this->model->whereIn('id', $ids)->select();
-                foreach ($mobiles as $mobile) {
-                    foreach ($data as $key => $value) {
-                        $mobile[$key] = $value;
-                        $mobile->save();
-                    }
-                }
-            }
-            if($infoData){
-                MobileInfo::whereIn('mobile_id',$ids)->update($infoData);
-            }
-            $this->success();
-        }
-    }
-
-    public function multi_edit_proxy(){
-        if($this->request->isGet()) {
-            return view();
-        }else{
-            $this->validate(input('row/a'),[
-                'proxy_id'=>['require','integer'],
-            ]);
-            $mobiles=$this->model->whereIn('id',input('ids'))->select();
-            foreach ($mobiles as $mobile){
-                $mobile->save([
-                    'proxy_id'=>input('row.proxy_id'),
-                ]);
-            }
-            $this->success();
-        }
-    }
-
-    public function multi_edit_status(){
-        if($this->request->isGet()) {
-            return view();
-        }else{
-            $this->validate(input('row/a'),[
-                'status'=>['require','integer'],
-            ]);
-            $status=input('row.status');
-            if(!isset(MO::beautiStatus()[$status])){
-                $this->error('状态有误');
-            }
-            $this->model->whereIn('id',$ids=input('ids'))->update($field=[
-                'status'=>$status,
-            ]);
-            EsMobileService::updateById($ids,$field);
-            $this->success();
-        }
-    }
-
-    protected function buildindexparams($searchfields = null, $relationSearch = null)
-    {
-        $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
-        $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
-        $search = $this->request->get("search", '');
-        $filter = $this->request->get("filter", '');
-        $op = $this->request->get("op", '', 'trim');
-        $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
-        $order = $this->request->get("order", "DESC");
-        $offset = $this->request->get("offset/d", 0);
-        $limit = $this->request->get("limit/d", 999999);
-        //新增自动计算页码
-        $page = $limit ? intval($offset / $limit) + 1 : 1;
-        if ($this->request->has("page")) {
-            $page = $this->request->get("page/d", 1);
-        }
-        $this->request->get([config('paginate.var_page') => $page]);
-        $filter = (array)json_decode($filter, true);
-        $op = (array)json_decode($op, true);
-        $filter = $filter ? $filter : [];
-        $where = [];
-        $alias = [];
-        $bind = [];
-        $name = '';
-        $aliasName = '';
-        if (!empty($this->model) && $this->relationSearch) {
-            $name = $this->model->getTable();
-            $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
-            $aliasName = $alias[$name] . '.';
-        }
-        $sortArr = explode(',', $sort);
-        foreach ($sortArr as $index => & $item) {
-            $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
-        }
-        unset($item);
-        $sort = implode(',', $sortArr);
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
-        }
-        if ($search) {
-            $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
-            foreach ($searcharr as $k => &$v) {
-                $v = stripos($v, ".") === false ? $aliasName . $v : $v;
-            }
-            unset($v);
-            $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
-        }
-        $index = 0;
-        foreach ($filter as $k => $v) {
-            if($k=='rules'){
-                continue;
-            }
-            if (!preg_match('/^[a-zA-Z0-9_\-.]+$/', $k)) {
-                continue;
-            }
-            $sym = isset($op[$k]) ? $op[$k] : '=';
-            if (stripos($k, ".") === false) {
-                $k = $aliasName . $k;
-            }
-            $v = !is_array($v) ? trim($v) : $v;
-            $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
-            //null和空字符串特殊处理
-            if (!is_array($v)) {
-                if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
-                    $sym = strtoupper($v);
-                }
-                if (in_array($v, ['""', "''"])) {
-                    $v = '';
-                    $sym = '=';
-                }
-            }
-
-            switch ($sym) {
-                case '=':
-                case '<>':
-                    $where[] = [$k, $sym, (string)$v];
-                    break;
-                case 'LIKE':
-                case 'NOT LIKE':
-                case 'LIKE %...%':
-                case 'NOT LIKE %...%':
-                    $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
-                    break;
-                case '>':
-                case '>=':
-                case '<':
-                case '<=':
-                    $where[] = [$k, $sym, intval($v)];
-                    break;
-                case 'FINDIN':
-                case 'FINDINSET':
-                case 'FIND_IN_SET':
-                    $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
-                    $findArr = array_values($v);
-                    foreach ($findArr as $idx => $item) {
-                        $bindName = "item_" . $index . "_" . $idx;
-                        $bind[$bindName] = $item;
-                        $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
-                    }
-                    break;
-                case 'IN':
-                case 'IN(...)':
-                case 'NOT IN':
-                case 'NOT IN(...)':
-                    $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
-                    break;
-                case 'BETWEEN':
-                case 'NOT BETWEEN':
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'BETWEEN' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'BETWEEN' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $where[] = [$k, $sym, $arr];
-                    break;
-                case 'RANGE':
-                case 'NOT RANGE':
-                    $v = str_replace(' - ', ',', $v);
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'RANGE' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'RANGE' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $tableArr = explode('.', $k);
-                    if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
-                        //修复关联模型下时间无法搜索的BUG
-                        $relation = Loader::parseName($tableArr[0], 1, false);
-                        $alias[$this->model->$relation()->getTable()] = $tableArr[0];
-                    }
-                    $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
-                    break;
-                case 'NULL':
-                case 'IS NULL':
-                case 'NOT NULL':
-                case 'IS NOT NULL':
-                    $where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
-                    break;
-                default:
-                    break;
-            }
-            $index++;
-        }
-        if (!empty($this->model)) {
-            $this->model->alias($alias);
-        }
-        if(isset($filter['rules']) && $filter['rules']){
-            $temp=[];
-            foreach (MobileConstant::getFilters()[$filter['rules']] as $pos=>$column){
-                $temp[]=$column;
-            }
-            $flip=array_flip($temp);
-
-            if(isset($filter['filter_first_last'])){
-                if($filter['filter_first_last']==1){
-                    $where[] = [$temp[1],1];
-                }elseif ($filter['filter_first_last']==2){
-                    $where[] = [$temp[0],1];
-                }
-            }else {
-                $where[] = [implode("|", $temp), 1];
-            }
-        }
-
-        $model = $this->model;
-        $where = function ($query) use ($where, $alias, $bind, &$model,$filter) {
-            if (!empty($model)) {
-                $model->alias($alias);
-                $model->bind($bind);
-            }
-            foreach ($where as $k => $v) {
-                if (is_array($v)) {
-                    if(in_array($v[0],['mobile_sub.sub_top_time','mobile_sub.sub_rec_time'])){
-                        if($v[2]) {
-                            $query->whereIn($v[0], 1);
-                        }else{
-                            $query->where(function ($query)use ($v){
-                                $query->whereRaw("{$v[0]}=0 or {$v[0]} is null");
-                            });
-                        }
-                        continue;
-                    }elseif ($v[0]=='proxy.nickname'){
-                        $proxy_id=Admin::where('proxy',1)->where('nickname','like',"%{$v[2]}%")->column('id')?:[0];
-                        $query->whereIn('proxy_id',$proxy_id);
-                        continue;
-                    }elseif ($v[0]=='mobile.exclude_nums'){
-                        $arr=explode(',',$v[2]);
-                        foreach ($arr as $num){
-                            if(!is_numeric($num)){
-                                continue;
-                            }
-                            $query->where(sprintf("filter_num_%s",$num),0);
-                        }
-                        continue;
-                    }elseif ($v[0]=='mobile.filter_first_last'){
-                        continue;
-                    }elseif ($v[0]=='mobile.no'){
-                        $noSearch=$filter['no'];
-                        if(isset($filter['filter_first_last'])){
-                            if($filter['filter_first_last']==1) {
-                                $noPad = str_pad($noSearch, 11, 'a',STR_PAD_LEFT);
-                                for ($i = 11; $i >1; $i--) {
-                                    if ($noPad[$i-1] !== 'a') {
-                                        $query->where("filter_no_pos_{$i}", $noPad[$i-1]);
-                                    }
-                                }
-                            }elseif ($filter['filter_first_last']==2){
-                                $query->where('filter_no_pos_11','<>',$noSearch[strlen($noSearch)-1])->whereRaw("LOCATE('{$noSearch}',no)");
-                            }
-                        }else{
-                            //$query->where('no','like',"%{$noSearch}%");
-                            $query->whereRaw("LOCATE('{$noSearch}',no)");
-                        }
-                        continue;
-                    }
-                    call_user_func_array([$query, 'where'], $v);
-                } else {
-                    $query->where($v);
-                }
-            }
-
-            $precise_search=input('precise_search/a');
-            if(is_array($precise_search) && $precise_search){
-                foreach ($precise_search as $idx=>$num){
-                    if(!is_numeric($num)){
-                        continue;
-                    }
-                    $query->where(sprintf('mobile.filter_no_pos_%d',$idx),(int)$num);
-                }
-            }
-        };
-        return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
-    }
-
-    public function status(){
-        return \app\common\model\Mobile::$status;
-    }
-
-    public function add()
-    {
-        if($this->request->isPost()) {
-            $data = input('row/a');
-            if (!empty($data['city'])) {
-                $data['city'] = explode('/', $data['city'])[1];
-            }
-            Db::startTrans();
-            $this->validate($data, \app\admin\validate\Mobile::class);
-            $data['type'] = 1;
-            $info = [];
-            if (isset($data['describe'])) {
-                $info['describe'] = $data['describe'];
-                unset($data['describe']);
-            }
-            $mobile = $this->model::create($data);
-            $mobile->info()->save($info);
-            Db::commit();
-            $this->success();
-        }else{
-            return view();
-        }
-    }
-    public function export($ids){
-        $mobiles=$this->model->whereIn('id',$ids)->select();
-        $excel = new Spreadsheet();
-        $excel->getProperties()
-            ->setCreator("admin")
-            ->setLastModifiedBy("admin")
-            ->setTitle("导出号码")
-            ->setSubject("导出号码");
-        $excel->getDefaultStyle()->getFont()->setName('Microsoft Yahei');
-        $excel->getDefaultStyle()->getFont()->setSize(12);
-        $excel->getDefaultStyle()->applyFromArray(
-            array(
-                'fill'      => array(
-                    'type'  => Fill::FILL_SOLID,
-                    'color' => array('rgb' => '000000')
-                ),
-                'font'      => array(
-                    'color' => array('rgb' => "000000"),
-                ),
-                'alignment' => array(
-                    'vertical'   => Alignment::VERTICAL_CENTER,
-                    'horizontal' => Alignment::HORIZONTAL_CENTER,
-                    'indent'     => 1
-                ),
-                'borders'   => array(
-                    'allborders' => array('style' => Border::BORDER_THIN),
-                )
-            ));
-        $excel->getActiveSheet()->setCellValue('A1','ID');
-        $excel->getActiveSheet()->setCellValue('B1','手机号');
-        $excel->getActiveSheet()->setCellValue('C1','省份');
-        $excel->getActiveSheet()->setCellValue('D1','归属地');
-        $excel->getActiveSheet()->setCellValue('E1','运营商');
-        $excel->getActiveSheet()->setCellValue('F1','供应商');
-        $excel->getActiveSheet()->setCellValue('G1','卡品牌');
-        $excel->getActiveSheet()->setCellValue('H1','规律');
-        $excel->getActiveSheet()->setCellValue('I1','套餐信息');
-        $excel->getActiveSheet()->setCellValue('J1','原价');
-        $excel->getActiveSheet()->setCellValue('K1','底价');
-        $excel->getActiveSheet()->setCellValue('L1','售价');
-        $excel->getActiveSheet()->setCellValue('M1','秒杀价');
-        $excel->getActiveSheet()->setCellValue('N1','预存话费');
-        $excel->getActiveSheet()->setCellValue('O1','备注');
-        $excel->getActiveSheet()->setCellValue('P1','置顶');
-        $excel->getActiveSheet()->setCellValue('Q1','推荐');
-        $excel->getActiveSheet()->setCellValue('R1','号码状态');
-        $excel->getActiveSheet()->setCellValue('S1','更新时间');
-        $excel->getActiveSheet()->setCellValue('T1','上架时间');
-        $excel->getActiveSheet()->setCellValue('U1','排序');
-        $excel->getActiveSheet()->setCellValue('V1','预占通道');
-        $excel->getActiveSheet()->setCellValue('W1','预占用户ID');
-        $excel->getActiveSheet()->setCellValue('X1','上传用户');
-        $i=2;
-        foreach ($mobiles as $mobile){
-            $rules=[];
-            foreach (MobileConstant::getFilters() as $rule=>$field){
-                foreach (array_values($field) as $column){
-                    if($mobile[$column]==1){
-                        $rules[]=$rule;
-                    }
-                }
-            }
-            $mobile['rules']=array_values(array_unique($rules));
-            $status=$mobile['is_activity']?'预占':\app\common\model\Mobile::$status[$mobile['status']];
-            $excel->getActiveSheet()->setCellValue('A'.$i,$mobile['id']);
-            $excel->getActiveSheet()->setCellValue('B'.$i,$mobile['no']);
-            $excel->getActiveSheet()->setCellValue('C'.$i,$mobile['province']);
-            $excel->getActiveSheet()->setCellValue('D'.$i,$mobile['city']);
-            $excel->getActiveSheet()->setCellValue('E'.$i,$mobile['network']);
-            $excel->getActiveSheet()->setCellValue('F'.$i,$mobile['proxy']['nickname']??'');
-            $excel->getActiveSheet()->setCellValue('G'.$i,$mobile['brand']);
-            $excel->getActiveSheet()->setCellValue('H'.$i,implode(',',$mobile['rules']));
-            $excel->getActiveSheet()->setCellValue('I'.$i,$mobile['info']['describe']??'');
-            $excel->getActiveSheet()->setCellValue('J'.$i,$mobile['amount_original']);
-            $excel->getActiveSheet()->setCellValue('K'.$i,$mobile['amount_di']);
-            $excel->getActiveSheet()->setCellValue('L'.$i,$mobile['amount_base']);
-            $excel->getActiveSheet()->setCellValue('M'.$i,$mobile['amount_kill']);
-            $excel->getActiveSheet()->setCellValue('N'.$i,$mobile['amount_charge']);
-            $excel->getActiveSheet()->setCellValue('O'.$i,$mobile['remark']);
-            $excel->getActiveSheet()->setCellValue('P'.$i,$mobile['top_time']?'是':'否');
-            $excel->getActiveSheet()->setCellValue('Q'.$i,$mobile['rec_time']?'是':'否');
-            $excel->getActiveSheet()->setCellValue('R'.$i,$status);
-            $excel->getActiveSheet()->setCellValue('S'.$i,date('Y-m-d H:i:s',$mobile['update_time']));
-            $excel->getActiveSheet()->setCellValue('T'.$i,date('Y-m-d H:i:s',$mobile['create_time']));
-            $excel->getActiveSheet()->setCellValue('U'.$i,$mobile['sort']);
-            $excel->getActiveSheet()->setCellValue('V'.$i,$mobile['hold_chan']);
-            $excel->getActiveSheet()->setCellValue('W'.$i,$mobile['hold_user']);
-            $excel->getActiveSheet()->setCellValue('X'.$i,$mobile['admin_id']);
-            $i++;
-        }
-        $excel->createSheet();
-        // Redirect output to a client’s web browser (Excel2007)
-        $title = date("YmdHis");
-        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
-        header('Content-Disposition: attachment;filename="' . $title . '.xlsx"');
-        header('Cache-Control: max-age=0');
-        // If you're serving to IE 9, then the following may be needed
-        header('Cache-Control: max-age=1');
-
-        // If you're serving to IE over SSL, then the following may be needed
-        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
-        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
-        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
-        header('Pragma: public'); // HTTP/1.0
-
-
-        $objWriter = IOFactory::createWriter($excel, 'Xlsx');
-        $objWriter->save('php://output');
-    }
-    public function force_update(){
-        $this->success();
-    }
-    public function batch_set_amount($ids){
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $data=input('row/a');
-            $this->validate($data,[
-                'amount_base|售价'=>['require','number','gt:0'],
-                'amount_di|底价'=>['require','number','egt:0'],
-            ]);
-            $mobiles=$this->model->whereIn('id',$ids)->select();
-            foreach ($mobiles as $mobile){
-                $mobile['amount_base']=$data['amount_base'];
-                $mobile['amount_di']=$data['amount_di'];
-                $mobile->save();
-            }
-            $this->success();
-        }
-    }
-
-    public function set_kill($ids){
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $data=input('row/a');
-
-            $discount=$data['discount']??0;
-            if(!empty($data['discount_diy']) && is_numeric($data['discount_diy'])){
-                $discount=$data['discount_diy'];
-            }
-            if($discount==0){
-                $this->error('折扣有误');
-            }
-            $mobiles=$this->model->whereIn('id',$ids)->where(function (Query $query){
-                if($this->admin('is_sub')) {
-                    $query->where('hold_chan', 0)->whereOr('hold_chan', $this->admin('id'));
-                }
-            })->select();
-            Db::startTrans();
-            foreach ($mobiles as $mobile){
-                $mobile['amount_kill']=bcmul($mobile['amount_base'],$discount,0);
-                if($mobile['amount_kill']==0){
-                    $mobile['amount_kill']=bcmul($mobile['amount_base'],$discount);
-                }
-                $mobile['is_activity']=1;
-                $mobile['hold_user']=$this->admin('id');
-                $mobile['hold_chan']=$this->admin('is_manager')?0:$this->admin('id');
-                $mobile->save();
-            }
-            Db::commit();
-            $this->success();
-        }
-    }
-
-    public function set_online_clear(){
-        $type = input('type',1);
-        if($this->request->isGet()) {
-            $this->assign('type',$type);
-            return view();
-        }else{
-            $data=[];
-            $act=input('act');
-            $reserve=input('reserve');
-            if($type==1){
-                switch ($act){
-                    case 'check':
-                        $num=$this->model->where('status',0)->group('no')->having('no_cf_count>1')->column('count(no) as no_cf_count');
-                        $data['num']=array_sum($num);
-                        break;
-                    case 'del':
-                        $data['num']=$this->set_online_clear_del($reserve,$type);
-                        break;
-                }
-            }elseif ($type==2){
-                switch ($act){
-                    case 'check':
-                        $num=$this->model->where('status',1)->group('no')->having('no_cf_count>1')->column('count(no) as no_cf_count');
-                        $data['num']=array_sum($num);
-                        break;
-                    case 'del':
-                        $data['num']=$this->set_online_clear_del($reserve,$type);
-                        break;
-                }
-            }
-            $this->result($data,1);
-        }
-    }
-
-    protected function set_online_clear_del($reserve,$type){
-        if(in_array($reserve,[1,2])){
-            return $this->set_online_clear_query($type,'id',$reserve==1);
-        }elseif(in_array($reserve,[3,4])){
-            return $this->set_online_clear_query($type,'amount_base',$reserve==3);
-        }elseif(in_array($reserve,[5,6])){
-            return $this->set_online_clear_query($type,'amount_di',$reserve==5);
-        }
-    }
-
-    protected function set_online_clear_query($type,$column,$asc){
-        $map=[];
-        if($type==1) {
-            $map['status'] = ['eq',0];
-        }elseif($type==2) {
-            $map['status'] = ['eq',1];
-        }
-        $res=$this->model->where($map)->group('no')->having('num>1')->column("count(no) as num,no,group_concat(id) as ids,GROUP_CONCAT($column) as $column",'no');
-        $ids=[];
-        $num=0;
-        foreach ($res as $item){
-            $tempIds=explode(',',$item['ids']);
-            $tempAmount=explode(',',$item[$column]);
-            $tempNew=array_combine($tempIds,$tempAmount);
-            $asc?asort($tempNew,1):arsort($tempNew,1);
-            unset($tempNew[array_keys($tempNew)[0]]);
-            //$ids=array_merge($ids,array_keys($tempNew));
-            $newIds=array_keys($tempNew);
-            $num+=count($newIds);
-            $ids=array_merge($ids,$newIds);
-            if(count($ids)>8000) {
-                $this->model->whereIn('id', $ids)->delete();
-                $ids=[];
-            }
-        }
-        if($ids) {
-            $this->model->whereIn('id', $ids)->delete();
-        }
-        return $num;
-    }
-
-    public function batch_copy_operation(){
-        if($this->request->isGet()) {
-            return view();
-        }else{
-            $num=0;
-            $data=input('row/a');
-            $this->validate($data,[
-                'no|手机号'=>['require'],
-                'act'=>'require',
-            ]);
-            $noFiltered=array_unique(array_filter(explode("\n",$data['no'])));
-            if($data['act']=='delete'){
-                $mobiles=$this->model->whereIn('no',$noFiltered)->select();
-                Db::startTrans();
-                foreach ($mobiles as $mobile){
-                    $mobile->delete();
-                }
-                $num=count($mobiles);
-                Db::commit();
-            }elseif($data['act']=='up'){
-                $num=$this->model->whereIn('no',$noFiltered)->update(['status'=>0]);
-                $ids=$this->model->whereIn('no',$noFiltered)->column('id');
-                EsMobileService::updateById($ids,['status'=>0]);
-            }elseif($data['act']=='down'){
-                $num=$this->model->whereIn('no',$noFiltered)->update(['status'=>2]);
-                $ids=$this->model->whereIn('no',$noFiltered)->column('id');
-                EsMobileService::updateById($ids,['status'=>2]);
-            }elseif ($data['act']=='top'){
-                if($noFiltered){
-                    $mobiles=$this->model->where('top_time',0)->whereIn('no',$noFiltered)->select();
-                    foreach ($mobiles as $mobile){
-                        $mobile['top_time']=1;
-                        $mobile->save();
-                    }
-                    $num=$mobiles->count();
-                }
-            }elseif ($data['act']=='rec'){
-                if($noFiltered){
-                    $mobiles=$this->model->where('rec_time',0)->whereIn('no',$noFiltered)->select();
-                    foreach ($mobiles as $mobile){
-                        $mobile['rec_time']=1;
-                        $mobile->save();
-                    }
-                    $num=$mobiles->count();
-                }
-            }
-            $this->result(['num'=>$num],1);
-        }
-    }
-
-    public function mobile_rules(){
-        return MobileConstant::getRuleKeys();
-    }
-
-    public function activity_cancel($ids){
-        $mobile=$this->model->findOrFail($ids);
-        if(!$mobile['is_activity']){
-            $this->error('该号码没有被预占无法取消');
-        }
-        if($this->admin('is_proxy')){
-            $this->error('您是供应商,无法使用此功能');
-        }
-        if($this->admin('sub') && $mobile['hold_chan']!=$this->auth->id){
-            $this->error('您无法取消');
-        }
-        $mobile->makeNotActivity();
-        $this->success();
-    }
-    public function batch_activity_cancel($ids){
-        $map=[];
-        if($this->admin('is_sub')){
-            $map['hold_chan']=$this->admin('id');
-        }
-       $mobiles=$this->model->whereIn('id',$ids)->where($map)->select();
-        foreach ($mobiles as $mobile){
-            $mobile['is_activity']=0;
-            $mobile->save();
-        }
-       $this->success();
-    }
-
-    /** 排序 */
-    public function mobile_sort($ids){
-        $mobile=$this->model->find($ids);
-        if(!$mobile){
-            return '';
-        }
-        $row=[
-            'sort'=>0,
-        ];
-        if($this->request->isGet()){
-            if($this->admin('is_sub')){
-                $row['sort']=MobileSub::getBy($mobile,$this->admin())['sub_sort'];
-            }else{
-                $row['sort']=$mobile['sort'];
-            }
-            $this->assign('row',$row);
-            return view();
-        }else{
-            $data=input('row/a');
-            $this->validate($data,[
-                'sort|排序'=>['require','integer','gt:0'],
-            ]);
-            if($this->admin('is_sub')){
-                $mobileSub=MobileSub::getBy($mobile,$this->admin());
-                $mobileSub['sub_sort']=$data['sort'];
-                $mobileSub->save();
-            }else{
-                $mobile['sort']=$data['sort'];
-                $mobile->save();
-            }
-            $this->success();
-        }
-    }
-
-    public function del_all(){
-        $data=['num'=>0];
-        $data['num']=\app\admin\model\Mobile::where('type',1)->delete();
-        \app\common\model\Mobile::deleteOtherTableInfo();
-        EsMobileService::clear();
-        $this->success('',null,$data);
-    }
-
-    public function exclude_nums(){
-        return json([
-            'list'=>[
-                ['id'=>2,'title'=>'2'],
-                ['id'=>3,'title'=>'3'],
-                ['id'=>4,'title'=>'4'],
-                ['id'=>5,'title'=>'5'],
-                ['id'=>6,'title'=>'6'],
-                ['id'=>7,'title'=>'7'],
-                ['id'=>8,'title'=>'8'],
-                ['id'=>9,'title'=>'9'],
-                ['id'=>0,'title'=>'0'],
-            ],
-            'total'=>10,
-        ]);
-    }
-}

+ 0 - 223
application/admin/controller/MobileAnchor.php

@@ -1,223 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-use fast\Tree;
-use think\Model;
-
-/**
- * 主播
- *
- * @icon fa fa-circle-o
- */
-class MobileAnchor extends Backend
-{
-    
-    /**
-     * MobileAnchor模型对象
-     * @var \app\admin\model\MobileAnchor
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileAnchor;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $map=[];
-            if($this->admin('is_sub')){
-                $map['admin_id']=$this->auth->id;
-            }
-
-            $list = $this->model
-                    ->with(['admin'])
-                    ->where($where)
-                    ->where($map)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    public function edit($ids = null)
-    {
-        $this->checkSubPower($ids);
-        return parent::edit($ids);
-    }
-
-    public function del($ids = "")
-    {
-        $this->checkSubPower($ids);
-        parent::del($ids);
-    }
-
-    protected function selectpage()
-    {
-        //设置过滤方法
-        $this->request->filter(['trim', 'strip_tags', 'htmlspecialchars']);
-
-        //搜索关键词,客户端输入以空格分开,这里接收为数组
-        $word = (array)$this->request->request("q_word/a");
-        //当前页
-        $page = $this->request->request("pageNumber");
-        //分页大小
-        $pagesize = $this->request->request("pageSize");
-        //搜索条件
-        $andor = $this->request->request("andOr", "and", "strtoupper");
-        //排序方式
-        $orderby = (array)$this->request->request("orderBy/a");
-        //显示的字段
-        $field = $this->request->request("showField");
-        //主键
-        $primarykey = $this->request->request("keyField");
-        //主键值
-        $primaryvalue = $this->request->request("keyValue");
-        //搜索字段
-        $searchfield = (array)$this->request->request("searchField/a");
-        //自定义搜索条件
-        $custom = (array)$this->request->request("custom/a");
-        //是否返回树形结构
-        $istree = $this->request->request("isTree", 0);
-        $ishtml = $this->request->request("isHtml", 0);
-        if ($istree) {
-            $word = [];
-            $pagesize = 999999;
-        }
-        $order = [];
-        foreach ($orderby as $k => $v) {
-            $order[$v[0]] = $v[1];
-        }
-        $field = $field ? $field : 'name';
-
-        //如果有primaryvalue,说明当前是初始化传值
-        if ($primaryvalue !== null) {
-            $where = [$primarykey => ['in', $primaryvalue]];
-            $pagesize = 999999;
-        } else {
-            $where = function ($query) use ($word, $andor, $field, $searchfield, $custom) {
-                $logic = $andor == 'AND' ? '&' : '|';
-                $searchfield = is_array($searchfield) ? implode($logic, $searchfield) : $searchfield;
-                $searchfield = str_replace(',', $logic, $searchfield);
-                $word = array_filter(array_unique($word));
-                if (count($word) == 1) {
-                    $query->where($searchfield, "like", "%" . reset($word) . "%");
-                } else {
-                    $query->where(function ($query) use ($word, $searchfield) {
-                        foreach ($word as $index => $item) {
-                            $query->whereOr(function ($query) use ($item, $searchfield) {
-                                $query->where($searchfield, "like", "%{$item}%");
-                            });
-                        }
-                    });
-                }
-                if ($custom && is_array($custom)) {
-                    foreach ($custom as $k => $v) {
-                        if (is_array($v) && 2 == count($v)) {
-                            $query->where($k, trim($v[0]), $v[1]);
-                        } else {
-                            $query->where($k, '=', $v);
-                        }
-                    }
-                }
-            };
-        }
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $this->model->where($this->dataLimitField, 'in', $adminIds);
-        }
-        $list = [];
-        $map=[];
-        if($this->admin('is_sub')){
-            $map['admin_id']=$this->admin('id');
-        }
-        $total = $this->model->where($where)->where($map)->count();
-        if ($total > 0) {
-            if (is_array($adminIds)) {
-                $this->model->where($this->dataLimitField, 'in', $adminIds);
-            }
-
-            $fields = is_array($this->selectpageFields) ? $this->selectpageFields : ($this->selectpageFields && $this->selectpageFields != '*' ? explode(',', $this->selectpageFields) : []);
-
-            //如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序
-            if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) {
-                $primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue));
-                //修复自定义data-primary-key为字符串内容时,给排序字段添加上引号
-                $primaryvalue = array_map(function ($value) {
-                    return '\'' . $value . '\'';
-                }, $primaryvalue);
-
-                $primaryvalue = implode(',', $primaryvalue);
-
-                $this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})");
-            } else {
-                $this->model->order($order);
-            }
-
-            $datalist = $this->model->where($where)->where($map)
-                ->page($page, $pagesize)
-                ->select();
-
-            foreach ($datalist as $index => $item) {
-                unset($item['password'], $item['salt']);
-                if ($this->selectpageFields == '*') {
-                    $result = [
-                        $primarykey => isset($item[$primarykey]) ? $item[$primarykey] : '',
-                        $field      => isset($item[$field]) ? $item[$field] : '',
-                    ];
-                } else {
-                    $result = array_intersect_key(($item instanceof Model ? $item->toArray() : (array)$item), array_flip($fields));
-                }
-                $result['pid'] = isset($item['pid']) ? $item['pid'] : (isset($item['parent_id']) ? $item['parent_id'] : 0);
-                $list[] = $result;
-            }
-            if ($istree && !$primaryvalue) {
-                $tree = Tree::instance();
-                $tree->init(collection($list)->toArray(), 'pid');
-                $list = $tree->getTreeList($tree->getTreeArray(0), $field);
-                if (!$ishtml) {
-                    foreach ($list as &$item) {
-                        $item = str_replace('&nbsp;', ' ', $item);
-                    }
-                    unset($item);
-                }
-            }
-        }
-        //这里一定要返回有list这个字段,total是可选的,如果total<=list的数量,则会隐藏分页按钮
-        return json(['list' => $list, 'total' => $total]);
-    }
-}

+ 0 - 77
application/admin/controller/MobileExportLog.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 
- *
- * @icon fa fa-circle-o
- */
-class MobileExportLog extends Backend
-{
-    
-    /**
-     * MobileExportLog模型对象
-     * @var \app\admin\model\MobileExportLog
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileExportLog;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    public function del($ids = "")
-    {
-        $export=$this->model->find($ids);
-        if($export['status']==1){
-            $this->error('导出中无法删除');
-        }
-        $export->delete();
-        $this->success();
-    }
-}

+ 0 - 365
application/admin/controller/MobileFlow.php

@@ -1,365 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\library\Auth;
-use app\common\controller\Backend;
-use app\common\library\MobileConstant;
-use think\App;
-use think\Db;
-use think\Exception;
-use think\exception\PDOException;
-use think\Loader;
-use think\Url;
-
-/**
- * 
- *
- * @icon fa fa-mobile
- */
-class MobileFlow extends Backend
-{
-    
-    /**
-     * Mobile模型对象
-     * @var \app\admin\model\Mobile
-     */
-    protected $model = null;
-    protected $relationSearch=true;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\Mobile;
-        $this->assign('status',\app\common\model\Mobile::flowStatus());
-    }
-
-    public function import()
-    {
-        //MobileImport::import(input('file'),$this->auth->id,2);
-        $this->success();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildindexparams();
-
-            $list = $this->model
-                    ->with(['info'])
-                ->where('type',2)
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-                $rules=[];
-                foreach (MobileConstant::getFilters() as $rule=>$field){
-                    foreach (array_values($field) as $column){
-                        if($row[$column]==1){
-                            $rules[]=$rule;
-                        }
-                    }
-                }
-                $row['rules']=array_unique($rules);
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        $this->assign('no_type',array_column(MobileConstant::getNoType(),'name','id'));
-        $this->assign('network',array_column(MobileConstant::getNetwork(),'name','id'));
-        $this->assign('filters',MobileConstant::getFilters());
-        return $this->view->fetch();
-    }
-
-    public static $rule=[
-        'name'=>['require'],
-        'brand'=>['require'],
-        'amount_base'=>['require','number','egt:0'],
-        'stock_num'=>['require','integer'],
-        'summary'=>['require','max:50'],
-        'logo'=>['require'],
-        //'describe'=>['require'],
-    ];
-    public function add()
-    {
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $data=input('row/a');
-            $this->validate($data,self::$rule);
-            $describe=$data['describe']??'';
-            $free_app=$data['free_app']??'';
-            $content=$data['content']??'';
-            $flow_images=$data['images']??[];
-            foreach (self::$rule as $key=>$r){
-                if(in_array($key,$this->model->getTableInfo('','fields'))) {
-                    $this->model[$key] = $data[$key];
-                }
-            }
-            $this->model['type']=\app\common\model\Mobile::FLOW;
-            $this->model->save();
-            $this->model->info()->save(compact('describe','free_app','content','flow_images'));
-            $this->success();
-        }
-    }
-
-    public function constant(){
-        return json([
-            'no_type'=>MobileConstant::getNoType(),
-        ]);
-    }
-
-    public function status(){
-        return \app\common\model\MobileOrder::flowStatus();
-    }
-
-    public function edit($ids=null){
-        if($this->request->isGet()){
-            $mobile=$this->model->find($ids);
-            $this->assign('row',$mobile);
-            return view();
-        }else{
-            $data=input('row/a');
-            self::$rule['status']=['in:'.implode(',',array_keys(\app\common\model\Mobile::flowStatus()))];
-            $this->validate($data,self::$rule);
-            $describe=$data['describe']??'';
-            $free_app=$data['free_app']??'';
-            $content=$data['content']??'';
-            $flow_images=$data['images']??[];
-            $mobiles=$this->model->whereIn('id',$ids)->select();
-            foreach ($mobiles as $mobile) {
-                Db::startTrans();
-                foreach (self::$rule as $key=>$r){
-                    if(in_array($key,$this->model->getTableInfo('','fields'))) {
-                        $mobile[$key] = $data[$key];
-                    }
-                }
-                $mobile->save();
-                $mobile->info->save(compact('describe','free_app','content','flow_images'));
-                Db::commit();
-            }
-            $this->success();
-        }
-    }
-
-    protected function buildindexparams($searchfields = null, $relationSearch = null)
-    {
-        $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
-        $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
-        $search = $this->request->get("search", '');
-        $filter = $this->request->get("filter", '');
-        $op = $this->request->get("op", '', 'trim');
-        $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
-        $order = $this->request->get("order", "DESC");
-        $offset = $this->request->get("offset/d", 0);
-        $limit = $this->request->get("limit/d", 999999);
-        //新增自动计算页码
-        $page = $limit ? intval($offset / $limit) + 1 : 1;
-        if ($this->request->has("page")) {
-            $page = $this->request->get("page/d", 1);
-        }
-        $this->request->get([config('paginate.var_page') => $page]);
-        $filter = (array)json_decode($filter, true);
-        $op = (array)json_decode($op, true);
-        $filter = $filter ? $filter : [];
-        $where = [];
-        $alias = [];
-        $bind = [];
-        $name = '';
-        $aliasName = '';
-        if (!empty($this->model) && $this->relationSearch) {
-            $name = $this->model->getTable();
-            $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
-            $aliasName = $alias[$name] . '.';
-        }
-        $sortArr = explode(',', $sort);
-        foreach ($sortArr as $index => & $item) {
-            $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
-        }
-        unset($item);
-        $sort = implode(',', $sortArr);
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
-        }
-        if ($search) {
-            $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
-            foreach ($searcharr as $k => &$v) {
-                $v = stripos($v, ".") === false ? $aliasName . $v : $v;
-            }
-            unset($v);
-            $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
-        }
-        $index = 0;
-        foreach ($filter as $k => $v) {
-            if($k=='rules'){
-                continue;
-            }
-            if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
-                continue;
-            }
-            $sym = isset($op[$k]) ? $op[$k] : '=';
-            if (stripos($k, ".") === false) {
-                $k = $aliasName . $k;
-            }
-            $v = !is_array($v) ? trim($v) : $v;
-            $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
-            //null和空字符串特殊处理
-            if (!is_array($v)) {
-                if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
-                    $sym = strtoupper($v);
-                }
-                if (in_array($v, ['""', "''"])) {
-                    $v = '';
-                    $sym = '=';
-                }
-            }
-
-            switch ($sym) {
-                case '=':
-                case '<>':
-                    $where[] = [$k, $sym, (string)$v];
-                    break;
-                case 'LIKE':
-                case 'NOT LIKE':
-                case 'LIKE %...%':
-                case 'NOT LIKE %...%':
-                    $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
-                    break;
-                case '>':
-                case '>=':
-                case '<':
-                case '<=':
-                    $where[] = [$k, $sym, intval($v)];
-                    break;
-                case 'FINDIN':
-                case 'FINDINSET':
-                case 'FIND_IN_SET':
-                    $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
-                    $findArr = array_values($v);
-                    foreach ($findArr as $idx => $item) {
-                        $bindName = "item_" . $index . "_" . $idx;
-                        $bind[$bindName] = $item;
-                        $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
-                    }
-                    break;
-                case 'IN':
-                case 'IN(...)':
-                case 'NOT IN':
-                case 'NOT IN(...)':
-                    $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
-                    break;
-                case 'BETWEEN':
-                case 'NOT BETWEEN':
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'BETWEEN' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'BETWEEN' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $where[] = [$k, $sym, $arr];
-                    break;
-                case 'RANGE':
-                case 'NOT RANGE':
-                    $v = str_replace(' - ', ',', $v);
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'RANGE' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'RANGE' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $tableArr = explode('.', $k);
-                    if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
-                        //修复关联模型下时间无法搜索的BUG
-                        $relation = Loader::parseName($tableArr[0], 1, false);
-                        $alias[$this->model->$relation()->getTable()] = $tableArr[0];
-                    }
-                    $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
-                    break;
-                case 'NULL':
-                case 'IS NULL':
-                case 'NOT NULL':
-                case 'IS NOT NULL':
-                    $where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
-                    break;
-                default:
-                    break;
-            }
-            $index++;
-        }
-        if (!empty($this->model)) {
-            $this->model->alias($alias);
-        }
-        if(isset($filter['rules']) && $filter['rules']){
-            $temp=[];
-            foreach (MobileConstant::getFilters()[$filter['rules']] as $pos=>$column){
-                $temp[]=$column;
-            }
-            $where[]=[implode("|",$temp),1];
-        }
-
-        $model = $this->model;
-        $where = function ($query) use ($where, $alias, $bind, &$model) {
-            if (!empty($model)) {
-                $model->alias($alias);
-                $model->bind($bind);
-            }
-            foreach ($where as $k => $v) {
-                if (is_array($v)) {
-                    call_user_func_array([$query, 'where'], $v);
-                } else {
-                    $query->where($v);
-                }
-            }
-        };
-        return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
-    }
-
-    public function multi_down($ids){
-        $flow=$this->model->whereIn('id',$ids)->select();
-        foreach ($flow as $mobile){
-            $mobile->flowMakeDown();
-        }
-        $this->success();
-    }
-    public function multi_up($ids){
-        $flow=$this->model->whereIn('id',$ids)->select();
-        foreach ($flow as $mobile){
-            $mobile->flowMakeUp();
-        }
-        $this->success();
-    }
-}

+ 0 - 589
application/admin/controller/MobileOrder.php

@@ -1,589 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\model\Admin;
-use app\admin\model\MobileOrderAdmin;
-use app\admin\model\MobileOrderRefundLog;
-use app\admin\model\MobileOrderSubAnchor;
-use app\admin\model\ShortcutContent;
-use app\common\controller\Backend;
-use app\common\model\LogisticsCompany;
-use app\common\model\MobileOrderOperation;
-use app\common\service\MobileOrderExport;
-use app\common\service\TransferCheck;
-use app\common\validate\RefundValidate;
-use think\Db;
-use think\db\Query;
-use think\Loader;
-
-/**
- *
- *
- * @icon fa fa-circle-o
- */
-class MobileOrder extends Backend
-{
-    protected $noNeedRight=['status','pay_type'];
-    /**
-     * MobileOrder模型对象
-     * @var \app\admin\model\MobileOrder
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileOrder;
-        $this->assign('status',\app\common\model\MobileOrder::$status);
-        $this->assign('logistics_list',json_encode(LogisticsCompany::all()));
-    }
-
-    public function import()
-    {
-        $this->error('not support');
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = true;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-
-        $map=[];
-        if($this->admin('is_sub')){
-            $map['s_id']=$this->admin('id');
-        }
-        $export=input('export');
-        if($export){
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                ->with(['info','operation','operation.admin','admin','admin.admin'])
-                ->where($where)
-                ->where($map)
-                ->where('type',1)
-                ->order($sort, $order)
-                ->paginate($limit);
-            return MobileOrderExport::export($list,$this->admin());
-        }
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-            if($this->admin('is_manager')){
-                $relation=['info','operation','operation.admin','admin','admin.admin','refund_log','refund_log.refunduser',
-                    'sub_remark','sub_remark.admin','anchor','sub_anchor','sub_anchor.mobileAnchor','proxy'];
-            }else{
-                $relation=['info','admin','admin.admin','refund_log','refund_log.refunduser','sub_remark'=>function(Query $query){
-                    $query->where('sub_admin_id',$this->auth->id);
-                },'sub_remark.admin','anchor','sub_anchor','sub_anchor.mobileAnchor','proxy'];
-            }
-
-            $list = $this->model
-                ->with($relation)
-                ->where($where)
-                ->where($map)
-                ->where('type',1)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-            $upStatus=[];
-            if($list->items()) {
-                $upStatus = \app\admin\model\Mobile::whereIn('id', array_column($list->items(), 'mobile_id'))->where('status', '<>',0)->column('id');
-            }
-
-            foreach ($list as $row) {
-                $row['pay_link']=h5_link("oder-detail/{$row['id']}");
-                $row->append(['phone_order_count']);
-                $row['mobile_can_up']=!in_array($row['mobile_id'],$upStatus);
-            }
-
-            $extend=[];
-            $amountMap=[];
-            $amountMap['type']=1;
-            if(!$this->admin('is_manager')){
-                $amountMap['s_id']=$this->admin('id');
-            }
-            $extend['total']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount');
-            $extend['alipay']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',2)->sum('amount');
-            $extend['wechat']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',1)->sum('amount');
-            $extend['jd']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',3)->sum('amount');
-            $extend['di']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_di');
-            $extend['profit']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_profit');
-            $extend['refund']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_refund');
-
-            $result = array("total" => $list->total(), "rows" => $list->items(),'extend'=>$extend);
-            $result['link']=$this->request->url().'&export=1';
-
-            return json($result);
-        }
-        $this->assign('admins',Admin::getAdmins());
-        return $this->view->fetch();
-    }
-    protected function buildparams($searchfields = null, $relationSearch = null)
-    {
-        $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
-        $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
-        $search = $this->request->get("search", '');
-        $filter = $this->request->get("filter", '');
-        $op = $this->request->get("op", '', 'trim');
-        $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
-        $order = $this->request->get("order", "DESC");
-        $offset = $this->request->get("offset/d", 0);
-        $limit = $this->request->get("limit/d", 999999);
-        //新增自动计算页码
-        $page = $limit ? intval($offset / $limit) + 1 : 1;
-        if ($this->request->has("page")) {
-            $page = $this->request->get("page/d", 1);
-        }
-        $this->request->get([config('paginate.var_page') => $page]);
-        $filter = (array)json_decode($filter, true);
-        $op = (array)json_decode($op, true);
-        $filter = $filter ? $filter : [];
-        $where = [];
-        $alias = [];
-        $bind = [];
-        $name = '';
-        $aliasName = '';
-        if (!empty($this->model) && $this->relationSearch) {
-            $name = $this->model->getTable();
-            $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
-            $aliasName = $alias[$name] . '.';
-        }
-        $sortArr = explode(',', $sort);
-        foreach ($sortArr as $index => & $item) {
-            $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
-        }
-        unset($item);
-        $sort = implode(',', $sortArr);
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
-        }
-        if ($search) {
-            $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
-            foreach ($searcharr as $k => &$v) {
-                $v = stripos($v, ".") === false ? $aliasName . $v : $v;
-            }
-            unset($v);
-            $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
-        }
-        $index = 0;
-        foreach ($filter as $k => $v) {
-            if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
-                continue;
-            }
-            $sym = isset($op[$k]) ? $op[$k] : '=';
-            if (stripos($k, ".") === false) {
-                $k = $aliasName . $k;
-            }
-            $v = !is_array($v) ? trim($v) : $v;
-            $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
-            //null和空字符串特殊处理
-            if (!is_array($v)) {
-                if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
-                    $sym = strtoupper($v);
-                }
-                if (in_array($v, ['""', "''"])) {
-                    $v = '';
-                    $sym = '=';
-                }
-            }
-
-            switch ($sym) {
-                case '=':
-                case '<>':
-                    $where[] = [$k, $sym, (string)$v];
-                    break;
-                case 'LIKE':
-                case 'NOT LIKE':
-                case 'LIKE %...%':
-                case 'NOT LIKE %...%':
-                    $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
-                    break;
-                case '>':
-                case '>=':
-                case '<':
-                case '<=':
-                    $where[] = [$k, $sym, intval($v)];
-                    break;
-                case 'FINDIN':
-                case 'FINDINSET':
-                case 'FIND_IN_SET':
-                    $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
-                    $findArr = array_values($v);
-                    foreach ($findArr as $idx => $item) {
-                        $bindName = "item_" . $index . "_" . $idx;
-                        $bind[$bindName] = $item;
-                        $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
-                    }
-                    break;
-                case 'IN':
-                case 'IN(...)':
-                case 'NOT IN':
-                case 'NOT IN(...)':
-                    $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
-                    break;
-                case 'BETWEEN':
-                case 'NOT BETWEEN':
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'BETWEEN' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'BETWEEN' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $where[] = [$k, $sym, $arr];
-                    break;
-                case 'RANGE':
-                case 'NOT RANGE':
-                    $v = str_replace(' - ', ',', $v);
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'RANGE' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'RANGE' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $tableArr = explode('.', $k);
-                    if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
-                        //修复关联模型下时间无法搜索的BUG
-                        $relation = Loader::parseName($tableArr[0], 1, false);
-                        $alias[$this->model->$relation()->getTable()] = $tableArr[0];
-                    }
-                    $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
-                    break;
-                case 'NULL':
-                case 'IS NULL':
-                case 'NOT NULL':
-                case 'IS NOT NULL':
-                    $where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
-                    break;
-                default:
-                    break;
-            }
-            $index++;
-        }
-        if (!empty($this->model)) {
-            $this->model->alias($alias);
-        }
-        $model = $this->model;
-        $where = function (Query $query) use ($where, $alias, $bind, &$model) {
-            if (!empty($model)) {
-                $model->alias($alias);
-                $model->bind($bind);
-            }
-            foreach ($where as $k => $v) {
-                if (is_array($v)) {
-                    if($v[0]=='rules.rule'){
-                        $query->whereExists("select * from mobile_order_rules where mobile_order_rules.mobile_order_id=mobile_order.id and rule='{$v[2]}'");
-                        continue;
-                    }elseif ($v[0]=='admin.admin_id'){
-                        $query->whereExists("select * from mobile_order_admin where mobile_order_admin.mobile_order_id=mobile_order.id and admin_id={$v[2]}");
-                        continue;
-                    }elseif ($v[0]=='mobile_order.sub_mobile_anchor_id'){
-                        $query->whereExists("select * from mobile_order_sub_anchor where mobile_order_sub_anchor.mobile_order_id=mobile_order.id and sub_mobile_anchor_id={$v[2]}");
-                        continue;
-                    }elseif ($v[0]=='status'){
-                        $v[0]='mobile_order.status';
-                    }elseif ($v[0]=='create_time'){
-                        $v[0]='mobile_order.create_time';
-                    }elseif ($v[0]=='update_time'){
-                        $v[0]='mobile_order.update_time';
-                    }elseif ($v[0]=='mobile_order.status' && $v[2]==10){
-                        $query->whereNotIn('status',[0,50,90]);
-                        continue;
-                    }
-                    call_user_func_array([$query, 'where'], $v);
-                } else {
-                    $query->where($v);
-                }
-            }
-        };
-        return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
-    }
-    public function edit($ids = null)
-    {
-        $model=$this->model->find($ids);
-        $originStatus=$model['status'];
-        $row=$model->toArray();
-        if($this->request->isGet()){
-            $row['address']=$model->originData()['address'];
-            $row['city']=\app\common\model\Area::getNameString($row['city'],'/');
-            $this->assign('row',$row);
-            return view();
-        }else{
-            $field=[
-                'name',
-                'phone',
-                'id_no',
-                'address',
-                'trans_no',
-                'trans_id',
-                'status',
-            ];
-            $data=input('row/a');
-            Db::startTrans();
-            if(isset($data['city'])){
-                $data['city']=\app\common\model\Area::whereIn('name|shortname',str_replace('/',',',$data['city']))->column('id');
-            }
-            $this->validate($data,[
-                'status'=>'in:'.implode(',',array_keys(\app\common\model\MobileOrder::$status))
-            ]);
-            foreach ($data as $key=>$value){
-                if(in_array($key,$field)) {
-                    $model[$key] = $value;
-                }
-            }
-            MobileOrderAdmin::add($model,$originStatus!=$model['status'],$this->auth->id);
-            $model->save();
-            Db::commit();
-            $this->success('');
-        }
-    }
-    public function refund($ids){
-        $model=$this->model->find($ids);
-        $this->assign('row',$model);
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $data=input('row/a');
-            $this->validate($data,RefundValidate::class);
-            Db::startTrans();
-            $model=$this->model->where('id',$ids)->lock(true)->findOrFail();
-            $model->makeRefund('admin',Admin::find($this->auth->id),$data);
-            Db::commit();
-            $this->success();
-        }
-    }
-    public function status(){
-        return \app\common\model\MobileOrder::$status;
-    }
-    public function pay_type(){
-        return \app\common\model\MobileOrder::$payTypes;
-    }
-    public function add_operation(){
-        $id=input('ids/d');
-        if($this->request->isGet()){
-            $this->assign('shortcut',ShortcutContent::getList());
-            return view();
-        }else{
-            $content=input('row.content');
-            $this->validate(compact('content'),[
-                'content'=>'max:250',
-            ]);
-            MobileOrderOperation::create([
-                'mobile_order_id'=>$id,
-                'admin_id'=>$this->auth->id,
-                'content'=>$content,
-            ]);
-            $this->success();
-        }
-    }
-
-    public function send(){
-        $id=input('ids/d');
-        if($this->request->isGet()){
-            $row=$this->model->find($id);
-            $this->assign('row',$row);
-            return view();
-        }else{
-            $data=input('row/a');
-            Db::startTrans();
-            $row=$this->model->lock(true)->findOrFail($id);
-            $row->dealSend($data['trans_no'],$data['trans_id']);
-            Db::commit();
-            $this->success();
-        }
-    }
-    #展示开卡资料
-    public function show_open_data($id){
-        $row=$this->model->find($id);
-        return view('',compact('row'));
-    }
-    public function see_logistics($ids){
-        $order=$this->model->find($ids);
-        $data=TransferCheck::instance()->setNo($order['trans_no'])->setName($order['name'])->setPhone($order['phone'])->setLogisticsCompany(LogisticsCompany::get($order['trans_id']))->get();
-        $this->assign('data',$data);
-        return view('mobile_order/see_logistics');
-    }
-    #备注
-    public function sub_remark($id){
-        $order=$this->model->find($id);
-        if($this->admin('is_sub') && $this->auth->id!=$order['s_id']){
-            $this->error('操作失败(a)');
-        }
-        if($this->request->isGet()){
-            return view();
-        }else{
-            $data=input('row/a');
-            $this->validate($data,[
-                'content|备注'=>['require','max:50'],
-            ]);
-            $order->subRemark()->save([
-                'sub_admin_id'=>$this->auth->id,
-                'content'=>$data['content'],
-            ]);
-            $this->success();
-        }
-    }
-    public function set_anchor($ids){
-        $order=$this->model->find($ids);
-        if(!$order){
-            $this->error('订单不存在');
-        }
-        if($this->request->isGet()){
-            if($this->admin('is_manager')){
-                $anchor_id=$order['mobile_anchor_id'];
-                $this->assign('mobile_anchor_id',$anchor_id);
-            }
-            $sub_anchor_id=$order->subAnchor()->value('sub_mobile_anchor_id');
-            $this->assign('sub_mobile_anchor_id',$sub_anchor_id);
-            $this->assign('order',$order);
-            return view('sub_anchor');
-        }else{
-            $data=input('row/a');
-            if(!empty($data['mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['mobile_anchor_id'])){
-                $this->error('主播不存在');
-            }
-            if(!empty($data['sub_mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['sub_mobile_anchor_id'])){
-                $this->error('主播不存在');
-            }
-            if($this->admin('is_manager')){
-                if(!empty($data['mobile_anchor_id'])){
-                    $order['mobile_anchor_id']=$data['mobile_anchor_id'];
-                    if(!$order->save()){
-                        $this->error('保存失败');
-                    }
-                }
-                if(!empty($data['sub_mobile_anchor_id'])){
-                    MobileOrderSubAnchor::sync($order,$data['sub_mobile_anchor_id']);
-                }
-
-            }elseif ($this->admin('is_sub') && $this->admin('id')==$order['s_id']){
-                if(!empty($data['sub_mobile_anchor_id'])){
-                    if($order->subAnchor()->find()){
-                        $this->error('无法再次设置');
-                    }
-                    MobileOrderSubAnchor::sync($order,$data['sub_mobile_anchor_id']);
-                }
-            }
-            $this->success();
-        }
-    }
-
-    public function mobile_up($ids){
-        $order=$this->model->find($ids);
-        $mobile=$order->mobile()->find();
-        if($this->request->isGet()) {
-            $this->assign('row', $mobile);
-            $this->assign('disabled', 1);
-            $this->assign('otherSubDisabled', 1);
-            return view();
-        }else{
-            if($mobile){
-                $mobile->again_sell();
-            }
-            $this->success();
-        }
-    }
-
-    public function refund_log(){
-        if($this->request->isAjax()){
-            $this->relationSearch=true;
-            $limit=input('limit',10);
-            $offset=input('offset',0);
-            $filter=json_decode(input('filter'),true)?:[];
-            $map=[];
-            if(!empty($filter['od.mobile_id'])){
-                $map['mobile_order.mobile_id']=['eq',$filter['od.mobile_id']];
-            }
-            if(!empty($filter['od.s_id'])){
-                $map['mobile_order.s_id']=['eq',$filter['od.s_id']];
-            }
-            if(isset($filter['pass'])){
-                $map['pass']=['eq',$filter['pass']];
-            }
-            if(!empty($filter['od.no'])){
-                $map['mobile_order.no']=['like',"%{$filter['od.no']}%"];
-            }
-            if(!empty($filter['od.order_no'])){
-                $map['mobile_order.order_no']=['like',"%{$filter['od.order_no']}%"];
-            }
-            if(!empty($filter['reason'])){
-                $map['reason']=['like',"%{$filter['reason']}%"];
-            }
-            if(!empty($filter['admin.nickname'])){
-                $map['admin.nickname']=['like',"%{$filter['admin.nickname']}%"];
-            }
-            if(!empty($filter['od.amount'])){
-                $amountArr=explode(',',$filter['od.amount']);
-                if(empty($amountArr[0])){
-                    $amountArr[0]=0;
-                }
-                if(empty($amountArr[1])){
-                    $amountArr[1]=10000000000000;
-                }
-                $map['mobile_order.amount']=['between',$amountArr];
-            }
-            if(!empty($filter['amount_backend'])){
-                $amountArr=explode(',',$filter['amount_backend']);
-                if(empty($amountArr[0])){
-                    $amountArr[0]=0;
-                }
-                if(empty($amountArr[1])){
-                    $amountArr[1]=10000000000000;
-                }
-                $map['amount_backend']=['between',$amountArr];
-            }
-            $log=(new MobileOrderRefundLog)->getTable();
-            if(!empty($filter['create_time'])){
-                list($s,$e)=explode(' - ',$filter['create_time']);
-                $map["{$log}.create_time"]=['between',[strtotime($s),strtotime($e)]];
-            }
-            $page=$offset/$limit+1;
-            $data=MobileOrderRefundLog::where($map)
-                ->where(function (Query $query){
-                    if(!$this->admin('is_manager')){
-                        $query->where('mobile_order.s_id',$this->admin('id'));
-                    }
-                })
-                ->with(['od','admin'])
-                ->order('id','desc')
-                ->paginate($limit,false,['page'=>$page]);
-           /* foreach ($data as $model){
-                $model->setAttr('s_name',Admin::where('id',$model['od']['s_id'])->value('nickname'));
-            }*/
-            return json([
-                'total'=>$data->total(),
-                'rows'=>$data->items(),
-                'filter'=>$filter,
-            ]);
-        }
-        return $this->fetch();
-    }
-}

+ 0 - 377
application/admin/controller/MobileOrderFlow.php

@@ -1,377 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\model\Admin;
-use app\admin\model\MobileOrderAdmin;
-use app\admin\model\ShortcutContent;
-use app\common\controller\Backend;
-use app\common\model\LogisticsCompany;
-use app\common\model\MobileOrderOperation;
-use app\common\service\MobileOrderExport;
-use app\common\service\Refund;
-use think\Db;
-use think\db\Query;
-use think\Loader;
-
-/**
- * 
- *
- * @icon fa fa-circle-o
- */
-class MobileOrderFlow extends Backend
-{
-    protected $noNeedRight=['status','pay_type'];
-    /**
-     * MobileOrder模型对象
-     * @var \app\admin\model\MobileOrder
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileOrder;
-        $this->assign('status',$this->status());
-        $this->assign('logistics_list',json_encode(LogisticsCompany::all()));
-    }
-
-    public function import()
-    {
-        $this->error('');
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = true;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-
-        $map=[];
-        if(!$this->admin('is_manager')){
-            $map['s_id']=$this->admin('id');
-        }
-        $export=input('export');
-        if($export){
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                ->with(['info','operation','operation.admin','admin','admin.admin'])
-                ->where($where)
-                ->where($map)
-                ->where('type',2)
-                ->order($sort, $order)
-                ->paginate($limit);
-            return MobileOrderExport::export($list,$this->admin());
-        }
-
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            if($this->admin('is_manager')){
-                $relation=['info','operation','operation.admin','admin','admin.admin','sub_remark','sub_remark.admin','anchor'];
-            }else{
-                $relation=['info','admin','admin.admin','sub_remark','sub_remark.admin'];
-            }
-            $relation=array_merge($relation,['sub_anchor','sub_anchor.mobileAnchor']);
-
-            $list = $this->model
-                ->with($relation)
-                ->where($where)
-                ->where($map)
-                ->where('type',2)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-    /*        foreach ($list as $row) {
-            }*/
-
-            $extend=[];
-
-            $result = array("total" => $list->total(), "rows" => $list->items(),'extend'=>$extend);
-            $result['link']=$this->request->url().'&export=1';
-
-            return json($result);
-        }
-        $this->assign('admins',Admin::getAdmins());
-        return $this->view->fetch();
-    }
-    protected function buildparams($searchfields = null, $relationSearch = null)
-    {
-        $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
-        $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
-        $search = $this->request->get("search", '');
-        $filter = $this->request->get("filter", '');
-        $op = $this->request->get("op", '', 'trim');
-        $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
-        $order = $this->request->get("order", "DESC");
-        $offset = $this->request->get("offset/d", 0);
-        $limit = $this->request->get("limit/d", 999999);
-        //新增自动计算页码
-        $page = $limit ? intval($offset / $limit) + 1 : 1;
-        if ($this->request->has("page")) {
-            $page = $this->request->get("page/d", 1);
-        }
-        $this->request->get([config('paginate.var_page') => $page]);
-        $filter = (array)json_decode($filter, true);
-        $op = (array)json_decode($op, true);
-        $filter = $filter ? $filter : [];
-        $where = [];
-        $alias = [];
-        $bind = [];
-        $name = '';
-        $aliasName = '';
-        if (!empty($this->model) && $this->relationSearch) {
-            $name = $this->model->getTable();
-            $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
-            $aliasName = $alias[$name] . '.';
-        }
-        $sortArr = explode(',', $sort);
-        foreach ($sortArr as $index => & $item) {
-            $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
-        }
-        unset($item);
-        $sort = implode(',', $sortArr);
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
-        }
-        if ($search) {
-            $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
-            foreach ($searcharr as $k => &$v) {
-                $v = stripos($v, ".") === false ? $aliasName . $v : $v;
-            }
-            unset($v);
-            $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
-        }
-        $index = 0;
-        foreach ($filter as $k => $v) {
-            if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
-                continue;
-            }
-            $sym = isset($op[$k]) ? $op[$k] : '=';
-            if (stripos($k, ".") === false) {
-                $k = $aliasName . $k;
-            }
-            $v = !is_array($v) ? trim($v) : $v;
-            $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
-            //null和空字符串特殊处理
-            if (!is_array($v)) {
-                if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
-                    $sym = strtoupper($v);
-                }
-                if (in_array($v, ['""', "''"])) {
-                    $v = '';
-                    $sym = '=';
-                }
-            }
-
-            switch ($sym) {
-                case '=':
-                case '<>':
-                    $where[] = [$k, $sym, (string)$v];
-                    break;
-                case 'LIKE':
-                case 'NOT LIKE':
-                case 'LIKE %...%':
-                case 'NOT LIKE %...%':
-                    $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
-                    break;
-                case '>':
-                case '>=':
-                case '<':
-                case '<=':
-                    $where[] = [$k, $sym, intval($v)];
-                    break;
-                case 'FINDIN':
-                case 'FINDINSET':
-                case 'FIND_IN_SET':
-                    $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
-                    $findArr = array_values($v);
-                    foreach ($findArr as $idx => $item) {
-                        $bindName = "item_" . $index . "_" . $idx;
-                        $bind[$bindName] = $item;
-                        $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
-                    }
-                    break;
-                case 'IN':
-                case 'IN(...)':
-                case 'NOT IN':
-                case 'NOT IN(...)':
-                    $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
-                    break;
-                case 'BETWEEN':
-                case 'NOT BETWEEN':
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'BETWEEN' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'BETWEEN' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $where[] = [$k, $sym, $arr];
-                    break;
-                case 'RANGE':
-                case 'NOT RANGE':
-                    $v = str_replace(' - ', ',', $v);
-                    $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr)) {
-                        continue 2;
-                    }
-                    //当出现一边为空时改变操作符
-                    if ($arr[0] === '') {
-                        $sym = $sym == 'RANGE' ? '<=' : '>';
-                        $arr = $arr[1];
-                    } elseif ($arr[1] === '') {
-                        $sym = $sym == 'RANGE' ? '>=' : '<';
-                        $arr = $arr[0];
-                    }
-                    $tableArr = explode('.', $k);
-                    if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
-                        //修复关联模型下时间无法搜索的BUG
-                        $relation = Loader::parseName($tableArr[0], 1, false);
-                        $alias[$this->model->$relation()->getTable()] = $tableArr[0];
-                    }
-                    $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
-                    break;
-                case 'NULL':
-                case 'IS NULL':
-                case 'NOT NULL':
-                case 'IS NOT NULL':
-                    $where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
-                    break;
-                default:
-                    break;
-            }
-            $index++;
-        }
-        if (!empty($this->model)) {
-            $this->model->alias($alias);
-        }
-        $model = $this->model;
-        $where = function (Query $query) use ($where, $alias, $bind, &$model) {
-            if (!empty($model)) {
-                $model->alias($alias);
-                $model->bind($bind);
-            }
-            foreach ($where as $k => $v) {
-                if (is_array($v)) {
-                    if ($v[0]=='admin.admin_id'){
-                        $query->whereExists("select * from mobile_order_admin where mobile_order_admin.mobile_order_id=mobile_order.id and admin_id={$v[2]}");
-                        continue;
-                    }elseif ($v[0]=='mobile_order.sub_mobile_anchor_id'){
-                        $query->whereExists("select * from mobile_order_sub_anchor where mobile_order_sub_anchor.mobile_order_id=mobile_order.id and sub_mobile_anchor_id={$v[2]}");
-                        continue;
-                    }
-                    call_user_func_array([$query, 'where'], $v);
-                } else {
-                    $query->where($v);
-                }
-            }
-        };
-        return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
-    }
-    public function edit($ids = null)
-    {
-        $model=$this->model->find($ids);
-        $originStatus=$model['status'];
-        $row=$model->toArray();
-        if($this->request->isGet()){
-            $row['address']=$model->originData()['address'];
-            $row['city']=\app\common\model\Area::getNameString($row['city'],'/');
-            $this->assign('row',$row);
-            return view();
-        }else{
-            $data=input('row/a');
-            if(isset($data['city'])){
-                $data['city']=\app\common\model\Area::whereIn('name|shortname',str_replace('/',',',$data['city']))->column('id');
-            }
-            $this->validate($data,[
-                'status'=>'in:'.implode(',',array_keys($this->status()))
-            ]);
-            foreach ($data as $key=>$value){
-                $model[$key]=$value;
-            }
-            MobileOrderAdmin::add($model,$originStatus!=$model['status'],$this->auth->id);
-            $model->save();
-            $this->success('');
-        }
-    }
-    public function status(){
-        $status=\app\common\model\MobileOrder::flowStatus();
-        return $status;
-    }
-    public function pay_type(){
-        return \app\common\model\MobileOrder::$payTypes;
-    }
-    public function add_operation(){
-        $id=input('ids/d');
-        if($this->request->isGet()){
-            $this->assign('shortcut',ShortcutContent::getList());
-            return view();
-        }else{
-            $content=input('row.content');
-            $this->validate(compact('content'),[
-                'content'=>'max:250',
-            ]);
-            MobileOrderOperation::create([
-                'mobile_order_id'=>$id,
-                'admin_id'=>$this->auth->id,
-                'content'=>$content,
-            ]);
-            $this->success();
-        }
-    }
-    public function send(){
-        $id=input('ids/d');
-        if($this->request->isGet()){
-            $row=$this->model->find($id);
-            $this->assign('row',$row);
-            return view();
-        }else{
-            $data=input('row/a');
-            Db::startTrans();
-            $row=$this->model->lock(true)->findOrFail($id);
-            $row->dealSend($data['trans_no'],$data['trans_id']);
-            Db::commit();
-            $this->success();
-        }
-    }
-    #备注
-    public function sub_remark($id){
-        $order=$this->model->filterFlow()->find($id);
-        if($this->request->isGet()){
-            return view('mobile_order/sub_remark');
-        }else{
-            $data=input('row/a');
-            $this->validate($data,[
-                'content|备注'=>['require','max:50'],
-            ]);
-            $order->subRemark()->save([
-                'sub_admin_id'=>$this->auth->id,
-                'content'=>$data['content'],
-            ]);
-            $this->success();
-        }
-    }
-}

+ 0 - 76
application/admin/controller/MobileOrderNo.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 预定号码
- *
- * @icon fa fa-circle-o
- */
-class MobileOrderNo extends Backend
-{
-    
-    /**
-     * MobileOrderNo模型对象
-     * @var \app\admin\model\MobileOrderNo
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileOrderNo;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    public function edit($ids=null){
-        $this->model->where('id',$ids)->update(['is_read'=>1]);
-        $this->success();
-    }
-}

+ 0 - 81
application/admin/controller/MobilePriceLog.php

@@ -1,81 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- *  改价记录
- *
- * @icon fa fa-circle-o
- */
-class MobilePriceLog extends Backend
-{
-    
-    /**
-     * MobilePriceLog模型对象
-     * @var \app\admin\model\MobilePriceLog
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobilePriceLog;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        $mobile_id=input('ids');
-        //当前是否为关联查询
-        $this->relationSearch = true;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $map=[];
-            if($mobile_id){
-                $map['mobile_id']=$mobile_id;
-            }
-            $list = $this->model
-                ->where($map)
-                    ->with(['admin'])
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-                $row->visible(['id','admin_id','mobile_id','no','before_price','after_price','create_time']);
-                $row->visible(['admin']);
-				$row->getRelation('admin')->visible(['nickname']);
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-}

+ 0 - 77
application/admin/controller/MobileUpload.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 号码导入日志
- *
- * @icon fa fa-circle-o
- */
-class MobileUpload extends Backend
-{
-    
-    /**
-     * MobileUpload模型对象
-     * @var \app\admin\model\MobileUpload
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\MobileUpload;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    public function error_log($ids){
-        $upload=$this->model->find($ids);
-        $this->assign('logs',$upload->log);
-        return view();
-    }
-}

+ 0 - 74
application/admin/controller/Network.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\common\controller\Backend;
-
-/**
- * 运营商
- *
- * @icon fa fa-circle-o
- */
-class Network extends Backend
-{
-    
-    /**
-     * Network模型对象
-     * @var \app\admin\model\Network
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\Network;
-
-    }
-
-    public function import()
-    {
-        parent::import();
-    }
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-    
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //当前是否为关联查询
-        $this->relationSearch = false;
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                    
-                    ->where($where)
-                    ->order($sort, $order)
-                    ->paginate($limit);
-
-            foreach ($list as $row) {
-                $row->visible(['id','no_field','name','create_time','update_time']);
-                
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-}

+ 0 - 301
application/admin/controller/auth/Proxy.php

@@ -1,301 +0,0 @@
-<?php
-
-namespace app\admin\controller\auth;
-
-use app\admin\model\AuthGroup;
-use app\admin\model\AuthGroupAccess;
-use app\common\controller\Backend;
-use fast\Random;
-use fast\Tree;
-use think\Db;
-use think\Validate;
-
-/**
- * 管理员管理
- *
- * @icon   fa fa-users
- * @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
- */
-class Proxy extends Backend
-{
-
-    /**
-     * @var \app\admin\model\Admin
-     */
-    protected $model = null;
-    protected $selectpageFields = 'id,username,nickname,avatar';
-    protected $searchFields = 'id,username,nickname';
-    protected $childrenGroupIds = [];
-    protected $childrenAdminIds = [];
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = model('Admin');
-
-        $this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
-        $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
-
-        $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
-
-        Tree::instance()->init($groupList);
-        $groupdata = [];
-        if ($this->auth->isSuperAdmin()) {
-            $result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
-            foreach ($result as $k => $v) {
-                $groupdata[$v['id']] = $v['name'];
-            }
-        } else {
-            $result = [];
-            $groups = $this->auth->getGroups();
-            foreach ($groups as $m => $n) {
-                $childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id']));
-                $temp = [];
-                foreach ($childlist as $k => $v) {
-                    $temp[$v['id']] = $v['name'];
-                }
-                $result[__($n['name'])] = $temp;
-            }
-            $groupdata = $result;
-        }
-
-        $this->view->assign('groupdata', $groupdata);
-        $this->assignconfig("admin", ['id' => $this->auth->id]);
-    }
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            $childrenGroupIds = $this->childrenGroupIds;
-            $groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
-                ->column('id,name');
-            $authGroupList = AuthGroupAccess::where('group_id', 'in', $childrenGroupIds)
-                ->field('uid,group_id')
-                ->select();
-
-            $adminGroupName = [];
-            foreach ($authGroupList as $k => $v) {
-                if (isset($groupName[$v['group_id']])) {
-                    $adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
-                }
-            }
-            $groups = $this->auth->getGroups();
-            foreach ($groups as $m => $n) {
-                $adminGroupName[$this->auth->id][$n['id']] = $n['name'];
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                ->where($where)
-                ->where('proxy',1)
-                ->where('id', 'in', $this->childrenAdminIds)
-                ->field(['password', 'salt', 'token'], true)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-            foreach ($list as $k => &$v) {
-                $groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : [];
-                $v['groups'] = implode(',', array_keys($groups));
-                $v['groups_text'] = implode(',', array_values($groups));
-            }
-            unset($v);
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 添加
-     */
-    public function add()
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-            $params = $this->request->post("row/a");
-            if ($params) {
-                Db::startTrans();
-                try {
-                    if (!Validate::is($params['password'], '\S{6,16}')) {
-                        exception(__("Please input correct password"));
-                    }
-                    $params['salt'] = Random::alnum();
-                    $params['sub']=0;
-                    $params['proxy']=1;
-                    $params['password'] = md5(md5($params['password']) . $params['salt']);
-                    $params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
-                    $result = $this->model->validate('Admin.add')->save($params);
-                    if ($result === false) {
-                        exception($this->model->getError());
-                    }
-                    $group = $this->request->post("group/a");
-
-                    //过滤不允许的组别,避免越权
-                    $group = array_intersect($this->childrenGroupIds, $group);
-                    if (!$group) {
-                        exception(__('The parent group exceeds permission limit'));
-                    }
-
-                    $dataset = [];
-                    foreach ($group as $value) {
-                        $dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
-                    }
-                    model('AuthGroupAccess')->saveAll($dataset);
-                    Db::commit();
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                $this->success();
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit($ids = null)
-    {
-        $row = $this->model->get(['id' => $ids]);
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        if (!in_array($row->id, $this->childrenAdminIds)) {
-            $this->error(__('You have no permission'));
-        }
-        if ($this->request->isPost()) {
-            $this->token();
-            $params = $this->request->post("row/a");
-            unset($params['sub']);
-            if ($params) {
-                Db::startTrans();
-                try {
-                    if ($params['password']) {
-                        if (!Validate::is($params['password'], '\S{6,16}')) {
-                            exception(__("Please input correct password"));
-                        }
-                        $params['salt'] = Random::alnum();
-                        $params['password'] = md5(md5($params['password']) . $params['salt']);
-                    } else {
-                        unset($params['password'], $params['salt']);
-                    }
-                    //这里需要针对username和email做唯一验证
-                    $adminValidate = \think\Loader::validate('Admin');
-                    $adminValidate->rule([
-                        'username' => 'require|regex:\w{3,20}|unique:admin,username,' . $row->id,
-                        'email'    => 'require|email|unique:admin,email,' . $row->id,
-                        'password' => 'regex:\S{32}',
-                    ]);
-                    unset($params['proxy'],$params['sub']);
-                    $result = $row->validate('Admin.edit')->save($params);
-                    if ($result === false) {
-                        exception($row->getError());
-                    }
-
-                    // 先移除所有权限
-                    model('AuthGroupAccess')->where('uid', $row->id)->delete();
-
-                    $group = $this->request->post("group/a");
-
-                    // 过滤不允许的组别,避免越权
-                    $group = array_intersect($this->childrenGroupIds, $group);
-                    if (!$group) {
-                        exception(__('The parent group exceeds permission limit'));
-                    }
-
-                    $dataset = [];
-                    foreach ($group as $value) {
-                        $dataset[] = ['uid' => $row->id, 'group_id' => $value];
-                    }
-                    model('AuthGroupAccess')->saveAll($dataset);
-                    Db::commit();
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                $this->success();
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        $grouplist = $this->auth->getGroups($row['id']);
-        $groupids = [];
-        foreach ($grouplist as $k => $v) {
-            $groupids[] = $v['id'];
-        }
-        $this->view->assign("row", $row);
-        $this->view->assign("groupids", $groupids);
-        return $this->view->fetch();
-    }
-
-    /**
-     * 删除
-     */
-    public function del($ids = "")
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__("Invalid parameters"));
-        }
-        $ids = $ids ? $ids : $this->request->post("ids");
-        if ($ids) {
-            $ids = array_intersect($this->childrenAdminIds, array_filter(explode(',', $ids)));
-            // 避免越权删除管理员
-            $childrenGroupIds = $this->childrenGroupIds;
-            $adminList = $this->model->where('id', 'in', $ids)->where('id', 'in', function ($query) use ($childrenGroupIds) {
-                $query->name('auth_group_access')->where('group_id', 'in', $childrenGroupIds)->field('uid');
-            })->select();
-            if ($adminList) {
-                $deleteIds = [];
-                foreach ($adminList as $k => $v) {
-                    $deleteIds[] = $v->id;
-                }
-                $deleteIds = array_values(array_diff($deleteIds, [$this->auth->id]));
-                if ($deleteIds) {
-                    Db::startTrans();
-                    try {
-                        $this->model->destroy($deleteIds);
-                        model('AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
-                        Db::commit();
-                    } catch (\Exception $e) {
-                        Db::rollback();
-                        $this->error($e->getMessage());
-                    }
-                    $this->success();
-                }
-                $this->error(__('No rows were deleted'));
-            }
-        }
-        $this->error(__('You have no permission'));
-    }
-
-    /**
-     * 批量更新
-     * @internal
-     */
-    public function multi($ids = "")
-    {
-        // 管理员禁止批量操作
-        $this->error();
-    }
-
-    /**
-     * 下拉搜索
-     */
-    public function selectpage()
-    {
-        $this->dataLimit = 'auth';
-        $this->dataLimitField = 'id';
-        return parent::selectpage();
-    }
-}

+ 0 - 323
application/admin/controller/auth/Sub.php

@@ -1,323 +0,0 @@
-<?php
-
-namespace app\admin\controller\auth;
-
-use app\admin\model\AuthGroup;
-use app\admin\model\AuthGroupAccess;
-use app\common\controller\Backend;
-use fast\Random;
-use fast\Tree;
-use think\Db;
-use think\Validate;
-
-/**
- * 管理员管理
- *
- * @icon   fa fa-users
- * @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
- */
-class Sub extends Backend
-{
-
-    /**
-     * @var \app\admin\model\Admin
-     */
-    protected $model = null;
-    protected $selectpageFields = 'id,username,nickname,avatar';
-    protected $searchFields = 'id,username,nickname';
-    protected $childrenGroupIds = [];
-    protected $childrenAdminIds = [];
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = model('Admin');
-
-        $this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
-        $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
-
-        $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
-
-        Tree::instance()->init($groupList);
-        $groupdata = [];
-        if ($this->auth->isSuperAdmin()) {
-            $result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
-            foreach ($result as $k => $v) {
-                $groupdata[$v['id']] = $v['name'];
-            }
-        } else {
-            $result = [];
-            $groups = $this->auth->getGroups();
-            foreach ($groups as $m => $n) {
-                $childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id']));
-                $temp = [];
-                foreach ($childlist as $k => $v) {
-                    $temp[$v['id']] = $v['name'];
-                }
-                $result[__($n['name'])] = $temp;
-            }
-            $groupdata = $result;
-        }
-
-        $this->view->assign('groupdata', $groupdata);
-        $this->assignconfig("admin", ['id' => $this->auth->id]);
-    }
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            $childrenGroupIds = $this->childrenGroupIds;
-            $groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
-                ->column('id,name');
-            $authGroupList = AuthGroupAccess::where('group_id', 'in', $childrenGroupIds)
-                ->field('uid,group_id')
-                ->select();
-
-            $adminGroupName = [];
-            foreach ($authGroupList as $k => $v) {
-                if (isset($groupName[$v['group_id']])) {
-                    $adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
-                }
-            }
-            $groups = $this->auth->getGroups();
-            foreach ($groups as $m => $n) {
-                $adminGroupName[$this->auth->id][$n['id']] = $n['name'];
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
-            $list = $this->model
-                ->where($where)
-                ->where('sub',1)
-                ->where('id', 'in', $this->childrenAdminIds)
-                ->field(['password', 'salt', 'token'], true)
-                ->order($sort, $order)
-                ->paginate($limit);
-
-            foreach ($list as $k => &$v) {
-                $groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : [];
-                $v['groups'] = implode(',', array_keys($groups));
-                $v['groups_text'] = implode(',', array_values($groups));
-            }
-            unset($v);
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 添加
-     */
-    public function add()
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-            $params = $this->request->post("row/a");
-            unset($params['proxy']);
-            if ($params) {
-                Db::startTrans();
-                try {
-                    $params['salt'] = Random::alnum();
-                    $params['sub'] = 1;
-                    $params['proxy'] = 0;
-                    $params['avatar'] = isset($params['avatar'])?$params['avatar']:'/assets/img/avatar.png'; //设置新管理员默认头像。
-
-                    unset($params['id']);
-                    if(!$this->admin('is_manager')){
-                        unset($params['wx_qr']);
-                    }
-
-                    $result = $this->model->validate('Admin.subAdd')->save($params);
-                    if ($result === false) {
-                        exception($this->model->getError());
-                    }
-                    $group = $this->request->post("group/a");
-
-                    //过滤不允许的组别,避免越权
-                    $group = array_intersect($this->childrenGroupIds, $group);
-                    if (!$group) {
-                        exception(__('The parent group exceeds permission limit'));
-                    }
-
-                    $dataset = [];
-                    foreach ($group as $value) {
-                        $dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
-                    }
-                    model('AuthGroupAccess')->saveAll($dataset);
-                    Db::commit();
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                $this->success();
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit($ids = null)
-    {
-        $row = $this->model->get(['id' => $ids]);
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        if (!in_array($row->id, $this->childrenAdminIds)) {
-            $this->error(__('You have no permission'));
-        }
-        if ($this->request->isPost()) {
-            $this->token();
-            $params = $this->request->post("row/a");
-            if ($params) {
-                Db::startTrans();
-                try {
-                    if (!empty($params['password'])) {
-                        if (!Validate::is($params['password'], '\S{6,16}')) {
-                            exception(__("Please input correct password"));
-                        }
-                        $params['salt'] = Random::alnum();
-                        $params['password'] = md5(md5($params['password']) . $params['salt']);
-                    } else {
-                        unset($params['password'], $params['salt']);
-                    }
-                    if(!$this->admin('is_manager')){
-                        unset($params['wx_qr']);
-                    }
-                    //这里需要针对username和email做唯一验证
-                    $adminValidate = \think\Loader::validate('Admin');
-                    $adminValidate->rule([
-                        'username' => 'require|regex:\w{3,20}|unique:admin,username,' . $row->id,
-                        'email'    => 'require|email|unique:admin,email,' . $row->id,
-                        'password' => 'regex:\S{32}',
-                    ]);
-                    unset($params['proxy'],$params['sub']);
-                    $result = $row->validate('Admin.edit')->save($params);
-                    if ($result === false) {
-                        exception($row->getError());
-                    }
-
-                    // 先移除所有权限
-                    model('AuthGroupAccess')->where('uid', $row->id)->delete();
-
-                    $group = $this->request->post("group/a");
-
-                    // 过滤不允许的组别,避免越权
-                    $group = array_intersect($this->childrenGroupIds, $group);
-                    if (!$group) {
-                        exception(__('The parent group exceeds permission limit'));
-                    }
-
-                    $dataset = [];
-                    foreach ($group as $value) {
-                        $dataset[] = ['uid' => $row->id, 'group_id' => $value];
-                    }
-                    model('AuthGroupAccess')->saveAll($dataset);
-                    Db::commit();
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                $this->success();
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        $grouplist = $this->auth->getGroups($row['id']);
-        $groupids = [];
-        foreach ($grouplist as $k => $v) {
-            $groupids[] = $v['id'];
-        }
-        $this->view->assign("row", $row);
-        $this->view->assign("groupids", $groupids);
-        return $this->view->fetch();
-    }
-
-    /**
-     * 删除
-     */
-    public function del($ids = "")
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__("Invalid parameters"));
-        }
-        $ids = $ids ? $ids : $this->request->post("ids");
-        if ($ids) {
-            $ids = array_intersect($this->childrenAdminIds, array_filter(explode(',', $ids)));
-            // 避免越权删除管理员
-            $childrenGroupIds = $this->childrenGroupIds;
-            $adminList = $this->model->where('id', 'in', $ids)->where('id', 'in', function ($query) use ($childrenGroupIds) {
-                $query->name('auth_group_access')->where('group_id', 'in', $childrenGroupIds)->field('uid');
-            })->select();
-            if ($adminList) {
-                $deleteIds = [];
-                foreach ($adminList as $k => $v) {
-                    $deleteIds[] = $v->id;
-                }
-                $deleteIds = array_values(array_diff($deleteIds, [$this->auth->id]));
-                if ($deleteIds) {
-                    Db::startTrans();
-                    try {
-                        $this->model->destroy($deleteIds);
-                        model('AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
-                        Db::commit();
-                    } catch (\Exception $e) {
-                        Db::rollback();
-                        $this->error($e->getMessage());
-                    }
-                    $this->success();
-                }
-                $this->error(__('No rows were deleted'));
-            }
-        }
-        $this->error(__('You have no permission'));
-    }
-
-    /**
-     * 批量更新
-     * @internal
-     */
-    public function multi($ids = "")
-    {
-        // 管理员禁止批量操作
-        $this->error();
-    }
-
-    /**
-     * 下拉搜索
-     */
-    public function selectpage()
-    {
-        $this->dataLimit = 'auth';
-        $this->dataLimitField = 'id';
-        $input=input();
-        $map=[];
-        $map['sub']=1;
-        if(!empty($input['nickname'])){
-            $map['nickname']=['like',"%{$input['nickname']}%"];
-        }
-        if(!empty($input['keyValue'])){
-            $map['id']=$input['keyValue'];
-        }
-        $data=$this
-            ->model
-            ->where($map)
-            ->field('id,nickname')
-            ->paginate(6,false,['page'=>$input['pageNumber']??1]);
-        return json([
-            'list'=>$data->items(),
-            'total'=>$data->total(),
-        ]);
-    }
-}

+ 0 - 153
application/admin/controller/user/Guest.php

@@ -1,153 +0,0 @@
-<?php
-
-namespace app\admin\controller\user;
-
-use app\admin\model\UserGroup;
-use app\common\controller\Backend;
-use app\common\library\Auth;
-use think\Db;
-use think\exception\PDOException;
-use think\exception\ValidateException;
-
-/**
- * 会员管理
- *
- * @icon fa fa-user
- */
-class Guest extends Backend
-{
-
-    protected $relationSearch = true;
-    protected $searchFields = 'id,username,nickname';
-    protected $noNeedLogin=['levels'];
-    /**
-     * @var \app\admin\model\User
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->assign('levels',\app\common\model\User::$levels);
-        $this->model = model('User');
-    }
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-            $list = $this->model
-                ->with('group')
-                ->where('user.level',\app\common\model\User::LEVEL_0)
-                ->where($where)
-                ->order($sort, $order)
-                ->paginate($limit);
-            foreach ($list as $k => $v) {
-                $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
-                $v->hidden(['password', 'salt']);
-                $v->appendArea();
-            }
-            $result = array("total" => $list->total(), "rows" => $list->items());
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 添加
-     */
-    public function add()
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-        }
-        return parent::add();
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit($ids = null)
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-        }
-        $row = $this->model->get($ids);
-        $this->modelValidate = true;
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        $this->view->assign('groupList', build_select('row[group_id]', UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
-        if ($this->request->isPost()) {
-            $params = $this->request->post("row/a");
-            if ($params) {
-                $params = $this->preExcludeFields($params);
-                if(!empty($params['level_close_at'])){
-                    $params['level_close_at']=strtotime($params['level_close_at']);
-                }
-                $result = false;
-                Db::startTrans();
-                try {
-                    //是否采用模型验证
-                    if ($this->modelValidate) {
-                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
-                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
-                        $row->validateFailException(true)->validate($validate);
-                    }
-                    $result = $row->allowField(true)->save($params);
-                    Db::commit();
-                } catch (ValidateException $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                } catch (PDOException $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                if ($result !== false) {
-                    $this->success();
-                } else {
-                    $this->error(__('No rows were updated'));
-                }
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }else{
-            $this->view->assign("row", $row);
-            return view();
-        }
-    }
-
-    /**
-     * 删除
-     */
-    public function del($ids = "")
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__("Invalid parameters"));
-        }
-        $ids = $ids ? $ids : $this->request->post("ids");
-        $row = $this->model->get($ids);
-        $this->modelValidate = true;
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        Auth::instance()->delete($row['id']);
-        $this->success();
-    }
-
-    public function levels(){
-        return \app\common\model\User::$levels;
-    }
-}

+ 0 - 29
application/admin/controller/user/Rights.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace app\admin\controller\user;
-
-use app\common\controller\Backend;
-use app\common\model\UserRights;
-use fast\Tree;
-
-/**
- * 会员权益管理
- *
- * @icon fa fa-circle-o
- */
-class Rights extends Backend
-{
-    /**
-     * @var UserRights
-     */
-    protected $model = null;
-    protected $rulelist = [];
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new UserRights;
-        $this->assign('levels',\app\common\model\User::$levels);
-    }
-
-}

+ 0 - 199
application/admin/controller/user/Suber.php

@@ -1,199 +0,0 @@
-<?php
-
-namespace app\admin\controller\user;
-
-use app\admin\model\Area;
-use app\admin\model\UserGroup;
-use app\common\controller\Backend;
-use app\common\library\Auth;
-use app\common\model\UserInfo;
-use think\Db;
-use think\exception\PDOException;
-use think\exception\ValidateException;
-
-/**
- * 会员管理
- *
- * @icon fa fa-user
- */
-class Suber extends Backend
-{
-
-    protected $relationSearch = true;
-    protected $searchFields = 'id,username,nickname';
-    protected $noNeedLogin=['levels'];
-    /**
-     * @var \app\admin\model\User
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->assign('levels',\app\common\model\User::$levels);
-        $this->model = new \app\admin\model\User;
-    }
-
-    /**
-     * 查看
-     */
-    public function index()
-    {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-            $list = $this->model
-                ->with('userinfo')
-                ->where('user.type',1)
-                ->where($where)
-                ->order($sort, $order)
-                ->paginate($limit);
-            foreach ($list as $k => $v) {
-                $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
-                $v->hidden(['password', 'salt']);
-                $v->appendArea();
-            }
-            $right_per=$this->model
-                ->where('user.level','>',\app\common\model\User::LEVEL_0)
-                ->with('userinfo')
-                ->where($where)
-                ->avg('userinfo.right_per');
-            $result = array("total" => $list->total(), "rows" => $list->items(),'right_per'=>$right_per);
-
-            return json($result);
-        }
-        return $this->view->fetch();
-    }
-
-    /**
-     * 添加
-     */
-    public function add()
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-        }
-        return parent::add();
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit($ids = null)
-    {
-        if ($this->request->isPost()) {
-            $this->token();
-        }
-        $row = $this->model->get($ids);
-        $this->modelValidate = true;
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        $this->view->assign('groupList', build_select('row[group_id]', UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
-        if ($this->request->isPost()) {
-            $params = $this->request->post("row/a");
-            if ($params) {
-                $params = $this->preExcludeFields($params);
-                if(!empty($params['level_close_at'])){
-                    $params['level_close_at']=strtotime($params['level_close_at']);
-                }
-                $result = false;
-                Db::startTrans();
-                try {
-                    //是否采用模型验证
-                    if ($this->modelValidate) {
-                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
-                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
-                        $row->validateFailException(true)->validate($validate);
-                    }
-                    $result = $row->allowField(true)->save($params);
-                    Db::commit();
-                } catch (ValidateException $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                } catch (PDOException $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                } catch (\Exception $e) {
-                    Db::rollback();
-                    $this->error($e->getMessage());
-                }
-                if ($result !== false) {
-                    $this->success();
-                } else {
-                    $this->error(__('No rows were updated'));
-                }
-            }
-            $this->error(__('Parameter %s can not be empty', ''));
-        }else{
-            $this->view->assign("row", $row);
-            return view();
-        }
-    }
-
-    /**
-     * 删除
-     */
-    public function del($ids = "")
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__("Invalid parameters"));
-        }
-        $ids = $ids ? $ids : $this->request->post("ids");
-        $row = $this->model->get($ids);
-        $this->modelValidate = true;
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        Auth::instance()->delete($row['id']);
-        $this->success();
-    }
-
-    public function levels(){
-        return \app\common\model\User::$levels;
-    }
-
-    public function rate($ids){
-        $user=$this->model->findOrFail($ids);
-        $inputDate=input('time');
-        if(!$inputDate){
-            $inputDate=date('Y-m-01 00:00:00').' - '.date('Y-m-01 00:00:00',strtotime('+1month',strtotime(date('Y-m-01 00:00:00'))));
-        }
-        $this->assign('date',$inputDate);
-        list($start,$end)=explode(' - ',$inputDate);
-        $x=[];
-        $temp=[];
-        $values=[];
-        $start=strtotime($start);
-        $end=strtotime($end);
-        for ($i=0;$i<($end-$start)/86400;$i++){
-            $temp[]=$a=strtotime("+{$i}days",$start);
-            $x[]=date('Y/m/d',$a);
-        }
-        $data=$user->crate()->whereBetween('day',[$start,$end])->column('right_per','day');
-        $idx=0;
-        $prev_per=0;
-        foreach ($temp as $day){
-            if(isset($data[$day])){
-                $per=$data[$day];
-            }else{
-                if($idx==0){
-                    $per=UserInfo::where('user_id',$ids)->value('right_per',0);
-                }else{
-                    $per=$prev_per;
-                }
-            }
-            $values[]=$per;
-            $idx++;
-            $prev_per=$per;
-        }
-        $this->assign('x',$x);
-        $this->assign('value',$values);
-        return view();
-    }
-}

+ 0 - 630
application/api/controller/MobileController.php

@@ -1,630 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use addons\epay\library\Service;
-use app\common\controller\UserApi;
-use app\common\library\MobileConstant;
-use app\common\model\AdIndexOrderedFlow;
-use app\common\model\Area;
-use app\common\model\LogisticsCompany;
-use app\common\model\Mobile;
-use app\common\model\MobileInfo;
-use app\common\model\MobileOrder;
-use app\common\model\MobileOrderNo;
-use app\common\model\Payment;
-use app\common\model\SysConfig;
-use app\common\service\Jdpay;
-use app\common\service\SmsSend;
-use app\common\service\TransferCheck;
-use app\service\byte_dance\ByteDancePay;
-use app\service\byte_dance\OceanEngineService;
-use app\service\id\IdVerify;
-use think\App;
-use think\Db;
-use think\db\Query;
-
-/**
- * 靓号管理
- */
-class MobileController extends UserApi
-{
-    protected $noNeedLogin = "*";
-    protected $noNeedRight = '*';
-
-    /**
-     * 列表
-     * @ApiMethod (POST)
-     * @ApiParams (name="type",description="1靓号,2流量卡,默认1")
-     * @ApiParams (name="search_type",description="fuzzy模糊,precise精准")
-     * @ApiParams (name="search_last",description="0,1是否搜索尾部")
-     * @ApiParams (name="city_id",description="地区id")
-     * @ApiParams (name="keyword",description="搜索内容,模糊就是字符串,精准就是数组")
-     * @ApiParams (name="sort",description="price_asc价格从低到高,price_desc价格从高到低")
-     * @ApiParams (name="network",description="网络")
-     * @ApiParams (name="price_min",description="价格最低数字")
-     * @ApiParams (name="price_max",description="价格最高数字")
-     * @ApiParams (name="exclude_num",description="排除数字,数字[1,2,3]")
-     * @ApiParams (name="num_max",description="数字较多,传数字")
-     * @ApiParams (name="rule_position",description="规律位置,middle中间,tail尾部")
-     * @ApiParams (name="rule_name",description="规律名,AAAA什么的")
-     * @ApiParams (name="limit",description="limit")
-     * @ApiParams (name="page",description="page")
-     * @ApiParams (name="is_activity",description="是否是优惠号码")
-     * @ApiParams (name="chanId",description="分站ID")
-     * @ApiReturnParams (name=id,description=id)
-     * @ApiReturnParams  (name="type",description="1靓号,2流量卡")
-     * @ApiReturnParams (name=logo,description=缩略图)
-     * @ApiReturnParams (name=name,description=号码名称)
-     * @ApiReturnParams (name=no,description=手机号)
-     * @ApiReturnParams (name=type,description=1靓号2流量卡)
-     * @ApiReturnParams (name=network,description=运营商)
-     * @ApiReturnParams (name=city,description=城市)
-     * @ApiReturnParams (name=privince,description=省份)
-     * @ApiReturnParams (name=amount,description=售价)
-     * @ApiReturnParams (name=amount_original,description=原价)
-     * @ApiReturnParams (name=amount_exists,description=含话费)
-     * @ApiReturnParams (name=amount_base,description=售价)
-     * @ApiReturnParams (name=amount_charge,description=预充)
-     * @ApiReturnParams (name=summary,description=简介)
-     * @ApiReturnParams (name=saled,description=是否已出售)
-     * @ApiReturnParams (name=status,description=0正常1已售2已下架)
-     * @ApiReturnParams (name=is_activity,description=是否特价号)
-     * @ApiReturnParams (name=activity_time_end,description=特价过期时间null永不过期)
-     * @ApiReturnParams (name=view_count,description=正在浏览人数)
-     * @ApiReturnParams (name=is_private,description=是否民营运营商)
-     * @ApiReturnParams (name="info.free_app",description=免流APP列表)
-     * @ApiReturnParams (name="info.describe",description="套餐说明|资费详情")
-     * @ApiReturnParams (name="info.content",description="详细内容|注意事项")
-     * @ApiReturnParams (name="info.flow_year",description="每年流量(G)")
-     * @ApiReturnParams (name="info.fee",description="资费")
-     * @ApiReturnParams (name="info.first_month_free",description="首月是否免月租")
-     * @ApiReturnParams (name="info.discount_title",description="简要优惠介绍")
-     * @ApiReturnParams (name="info.flow_free_limit",description="前多少名免单")
-     * @ApiReturnParams (name="info.flow_images",description="流量卡详情图片")
-     */
-    public function list(){
-        $data=input();
-        $page=empty($data['page'])?1:$data['page'];
-        $limit=input('limit',15);
-        $chanId=getChanId();
-        $this->validate($data,[
-            'keyword'=>['max:11'],
-            'num_max'=>['integer','between:0,9'],
-            'rule_position'=>['in:middle,tail'],
-        ]);
-        if(empty($data['type'])){
-            $data['type']=1;
-        }
-        $map=[];
-        $model=Mobile::show($data);
-        $model->field(Mobile::hiddenColumn(),true);
-        $model->where('type',$data['type']);
-        if(isset($data['price_min']) && is_numeric($data['price_min'])){
-            $model->where('amount','>=',$data['price_min']);
-        }
-        if(!empty($data['price_max']) && is_numeric($data['price_max'])){
-            $model->where('amount','<=',$data['price_max']);
-        }
-        if(!empty($data['search_type']) && !empty($data['keyword'])){
-            if($data['search_type']=='fuzzy'){
-                if(isset($data['search_last']) && $data['search_last']==1){
-                    $no=str_pad($data['keyword'],11,'-',STR_PAD_LEFT);
-                    for ($i=0;$i<11;$i++){
-                        if($no[$i]=='-'){
-                            continue;
-                        }
-                        if($i==0){
-                            continue;
-                        }
-                        $pos=$i+1;
-                        $model->where("filter_no_pos_{$pos}",$no[$i]);
-                    }
-                }else {
-                    $model->where('no', 'like', "%{$data['keyword']}%");
-                }
-            }elseif ($data['search_type']=='precise'){
-                foreach ($data['keyword'] as $k=>$v){
-                    $pos=$k+1;
-                    if($pos==1||$v===""||is_null($v))continue;
-                    $model->where("filter_no_pos_{$pos}",$v);
-                }
-            }
-        }
-        if(!empty($data['city_id'])){
-            if (str_contains($data['city_id'],'-all')){
-                $model->where('province_id',str_replace('-all','',$data['city_id']));
-            }elseif (is_numeric($data['city_id'])) {
-                $model->where('city_id', $data['city_id']);
-            }elseif (preg_match('/\d+-\d+/',$data['city_id'])){
-                $model->where('city_id',explode('-',$data['city_id']))[1];
-            }
-        }
-        if(!empty($data['network'])){
-            /*$network=array_column(MobileConstant::getNetwork(),'search','name');
-            $works=[$data['network']];
-            foreach ($network as $key=>$networkArr){
-                if($key==$data['network']){
-                    $works=$networkArr;
-                    break;
-                }
-            }
-            $model->whereIn('network',$works);*/
-            $model->where('network',$data['network']);
-        }
-        if(isset($data['is_activity']) && $data['is_activity']){
-            $model->where('is_activity',1);
-        }
-        if(!empty($data['exclude_num']) && is_array($data['exclude_num'])){
-            //$model->whereNotLike('no',"%{$data['exclude_num']}%");
-            foreach ($data['exclude_num'] as $num){
-                if($num==1){
-                    continue;
-                }
-                $model->where("filter_num_{$num}",0);
-            }
-        }
-        if(!empty($data['num_max'])){
-            $model->where("filter_num_{$data['num_max']}",'>',3);
-        }
-        $rules=MobileConstant::getFilters();
-        if(!empty($data['rule_name'])){
-            if (!isset($rules[$data['rule_name']])) {
-                $this->error('规律规则不支持');
-            }
-            $rule=$rules[$data['rule_name']];
-            if(!empty($data['rule_position'])) {
-                $model->where($rule[$data['rule_position']], 1);
-            }else{
-                $model->where(function (Query $query)use ($rule){
-                    $query->where($rule['middle'],1)->whereOr($rule['tail'],1);
-                });
-            }
-        }
-        /*if($chanId){
-            $model->whereIn('hold_chan',[0,$chanId]);
-        }else{
-            $model->where('hold_chan',0);
-        }*/
-
-        $subIds=[];
-        if($chanId){
-            if(empty($data['sort'])) {
-                $activityData = (clone $model)->where('hold_chan', $chanId)->order('sort_line')->select();
-                /*$topRecData = (clone $model)
-                    ->join('mobile_sub', "mobile_sub.mobile_id=mobile.id and sub_admin_id=$chanId")
-                    ->where('sub_top_time|sub_rec_time', 1)
-                    ->where(function (Query $query) use ($activityData) {
-                        if ($activityData && $activityData->column('id')) {
-                            $query->whereNotIn('id', $activityData->column('id'));
-                        }
-                    })
-                    ->field('mobile.*')
-                    ->order('sub_sort_line')
-                    ->select();
-                $subData = $activityData->merge($topRecData);
-                $subIds = $subData->column('id');*/
-                $subData=$activityData;
-                $subIds=$activityData->column('id');
-                $model->where('is_activity',0);
-            }
-        }else{
-            $model->where('hold_chan',0);
-        }
-        if($subIds){
-            $model->whereNotIn('id',$subIds);
-        }
-
-        if(!empty($data['sort'])){
-            if($data['sort']=='price_asc'){
-                $model->order('amount','asc');
-            }elseif($data['sort']=='price_desc'){
-                $model->order('amount','desc');
-            }
-        }else{
-            if($data['type']==1) {
-                $model->order('sort_line');
-            }else{
-                $model->order('id','desc');
-            }
-        }
-
-        $list=$model->paginate($limit,true)->toArray();
-        $listData=$list['data'];
-        if($page==1  && isset($subData)){
-            foreach (array_reverse($subData->toArray()) as $item){
-                array_unshift($listData,$item);
-            }
-        }
-        $list['data']=$listData;
-        $this->success('',$list);
-    }
-    /**
-     * 号码详情
-     * @ApiParams (name=id,description=号码id)
-     */
-    public function show(){
-        $data=$this->_validate([
-            'id'=>['require']
-        ]);
-        $mobile=Mobile::where('id','id')->with(['info'])->findOrFail($data['id']);
-        $mobile->addViewCount();
-        $mobile->append(['view_count']);
-        MobileInfo::makeFreeApp($mobile['info']);
-        $this->success('',$mobile);
-    }
-    /**
-     * 下单
-     * @ApiMethod (POST)
-     * @ApiParams (name=mobile_id,description=手机号ID)
-     * @ApiParams (name=name,description=姓名)
-     * @ApiParams (name=phone,description=手机号)
-     * @ApiParams (name=sms_code,description=验证码)
-     * @ApiParams (name=id_no,description="身份号码,450804198608275870",sample="450804198608275870")
-     * @ApiParams (name=county,description="城市ID,区县id")
-     * @ApiParams (name=address,description=详细地址)
-     * @ApiParams (name=remark,description=备注)
-     * @ApiParams (name=pay_type,description="1微信2支付宝3京东4抖音小程序")
-     * @ApiParams (name=return_url,description="支付完成回调页面链接")
-     * @ApiReturnParams (name=pay_url,description="支付链接")
-     * @ApiReturnParams (name=without_pay,description="是否不需要支付")
-     * @ApiReturnParams (name=res,description="抖音支付时返回参数")
-     * @ApiParams (name=clickid,description="巨量引擎clickid")
-     */
-    public function apply(){
-        $needId=config('site.system_id_form_open')?true:false;
-        $data=$this->_validate([
-            'mobile_id'=>'require',
-            'name|姓名'=>['require','max:20'],
-            'phone|手机号'=>'require|mobile',
-            //'id_no|身份证'=>['require','regex'=>'/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/'],
-            'county|地区'=>'require|integer',
-            'address|详细地址'=>['require','max:100'],
-        ]);
-        if($needId){
-            $this->_validate([
-                'id_no|身份证'=>['require','regex'=>'/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/'],
-            ]);
-        }
-
-        Db::startTrans();
-        $mobile=Mobile::lock(true)->findOrFail($data['mobile_id']);
-        if($mobile['type']==1){
-            $this->_validate([
-                'pay_type'=>'require|in:1,2,3,4',
-            ]);
-        }
-        if($needId||$mobile['type']==2){
-            if(!App::$debug) {
-                IdVerify::instance()->check($data['name'] ?? '', $data['id_no'] ?? '');
-            }
-        }
-        $mobile->shouldBuy();
-        Area::shouldSend($data['county']);
-        if($mobile->needCheckSmsCode()) {
-            SmsSend::setMobile($data['phone'])->setCode($data['sms_code'] ?? '')->setEvent('order')->check();
-        }
-        $order = $data;
-        $order['s_id']=getChanId();
-        $order['admin_id'] = $mobile['proxy_id'];
-        $order['no'] = $mobile['no'];
-        $order['city'] = implode(',', Area::getTreeId($data['county']));
-        $order['amount_original'] = $mobile['amount_original'];
-        $order['amount_hd'] = $mobile['amount'];
-        $order['amount_charge'] = $mobile['amount_charge'];
-        $order['amount'] = $mobile['amount'];
-        $order['amount_di'] = $mobile['amount_di'];
-        $order['amount_base'] = $mobile['amount_base'];
-        $order['type'] = $mobile['type'];
-        unset($order['county'], $order['status'], $order['sms_code']);
-        $mobileOrder = (new MobileOrder);
-        if($mobile['type']==2){
-            $mobileOrder->flowOrderSubmit();
-        }
-        $mobileOrder->allowField(true)->save($order);
-        //$succ=$mobileOrder;
-        //if($mobile['type']==1) {
-            $succ = $this->pay($mobileOrder, $data);
-        //}
-        Db::commit();
-        $this->success('', $succ);
-    }
-    protected function pay(MobileOrder $mobileOrder,$data){
-        $data['return_url']=h5_link('pay-success/'.$mobileOrder['id']);
-        if($mobileOrder['type']==2){
-            OceanEngineService::setQuery(['clickid'=>input('clickid')])->setAddon(['order_no'=>input('clickid')])->form();
-        }
-        $succ=[
-            'pay_url'=>'',
-            'id'=>$mobileOrder['id'],
-            'without_pay'=>0,
-            'res'=>null,
-        ];
-        if($mobileOrder['amount']==0){
-            $succ['without_pay']=1;
-            $mobileOrder->paySuccessCallback();
-            try {
-                OceanEngineService::setQuery(['clickid'=>input('clickid')])->setAddon(['order_no'=>input('clickid')])->shopping();
-            }catch (\Exception $e){}
-            return $succ;
-        }
-
-        $payment=Payment::create([
-            'order_no'=>session_create_id(),
-            'amount'=>$mobileOrder['amount'],
-            'mobile_order_id'=>$mobileOrder['id'],
-            'params'=>[
-                'clickid'=>input('clickid'),
-            ]
-        ]);
-        $filename=session_create_id(date('Ymd'));
-        if(!is_dir($dir=RUNTIME_PATH.'/payment/')) {
-            @mkdir($dir, 0777, true);
-        }
-        if($data['pay_type']==1){
-            $info=Service::submitOrder($payment['amount'],
-                $payment['order_no'],'wechat',"购买手机号{$mobileOrder['no']}",
-                Service::notifyUrl('wechat',$payment['order_no']),$data['return_url']??'','wap');
-            file_put_contents(RUNTIME_PATH.'/payment/'.$filename,$info->getContent());
-            $succ['pay_url']=url('/index/index/payment/a/'.$filename,[],true,true);
-        }elseif ($data['pay_type']==2){
-            $info=Service::submitOrder($payment['amount'],
-                $payment['order_no'],'alipay',"购买手机号{$mobileOrder['no']}",
-                Service::notifyUrl('alipay',$payment['order_no']),$data['return_url']??'','wap');
-            file_put_contents(RUNTIME_PATH.'/payment/'.$filename,view('alipay',['form'=>$info->getContent()])->getContent());
-            $succ['pay_url']=url('/index/index/payment/a/'.$filename,[],true,true);
-        }elseif ($data['pay_type']==3){
-            $jdpay=App::invokeClass(Jdpay::class);
-            $payData=$jdpay->order($payment['order_no'],$payment['amount'],"购买手机号{$mobileOrder['no']}");
-            $succ=array_merge($succ,$payData);
-        }elseif ($data['pay_type']==4){
-            $payData=ByteDancePay::setInfo($payment['order_no'],$payment['amount'],"购买手机号{$mobileOrder['no']}")->get();
-            $succ['res']=$payData;
-        }
-        return $succ;
-    }
-    /**
-     * 继续支付
-     * @ApiParams (name=id,description=订单id)
-     * @ApiParams (name=pay_type,description=支付方式与下单一样)
-     * @ApiParams (name=return_url,description="支付完成回调页面链接")
-     */
-    public function continue_pay(){
-        $data=$this->_validate([
-            'id'=>['require'],
-            'pay_type'=>'require|in:1,2,3',
-        ]);
-        $mobileOrder=MobileOrder::whereNull('pay_time')->findOrFail($data['id']);
-
-        $mobileOrder->continuePay();
-
-        $succ=$this->pay($mobileOrder,$data);
-
-        $this->success('',$succ);
-    }
-    /**
-     * 订单详情
-     * @ApiParams (name=id,description=订单id)
-     * @ApiReturnParams (name=no,description=手机号)
-     * @ApiReturnParams (name=order_no,description=订单号)
-     * @ApiReturnParams (name=amount_hd,description=活动价)
-     * @ApiReturnParams (name=amount_original,description=原价)
-     * @ApiReturnParams (name=amount_charge,description=预充)
-     * @ApiReturnParams (name=describe,description=套餐说明)
-     * @ApiReturnParams (name=proxy.wx_qr,description=客服二维码)
-     * @ApiReturnParams (name=name,description=收货人)
-     * @ApiReturnParams (name=phone,description=收货人手机号)
-     * @ApiReturnParams (name=id_no,description=收货人身份证)
-     * @ApiReturnParams (name=address,description=收货地址)
-     * @ApiReturnParams (name=remark,description=备注)
-     * @ApiReturnParams (name=create_time,description=下单时间)
-     * @ApiReturnParams (name=amount,description=订单金额)
-     * @ApiReturnParams (name=trans_name,description=快递名称)
-     * @ApiReturnParams (name=trans_no,description=快递单号)
-     * @ApiReturnParams (name=status,description="0=>'待付款',10=>'已付款',15=>'待发货',17=>'有号码未发货',20=>'待开卡',25=>'已完成',30=>'申请退款',50=>'已关闭',60=>'无号码',70=>'换卡',80=>'争议单',90=>'已退款',100=>'退款驳回'")
-     * @ApiReturnParams (name=open_uploaded,description=是否已上传开卡资料)
-     * @ApiReturnParams (name=open_idcard_face_img,description=身份证正面照)
-     * @ApiReturnParams (name=open_idcard_back_img,description=身份证反面照)
-     * @ApiReturnParams (name=open_face_img,description=头像照)
-     * @ApiReturnParams (name=open_name,description=姓名)
-     * @ApiReturnParams (name=open_id_no,description=身份证号码)
-     * @ApiReturnParams (name=open_phone,description=手机号)
-     * @ApiReturnParams (name=pay_time,description=支付时间)
-     * @ApiReturnParams (name=expire_time,description=过期时间)
-     */
-    public function order_detail(){
-        $order=MobileOrder::with(['proxy','info'])->findOrFail(input('id'));
-        $order['proxy'] && $order['proxy']->hidden(['password']);
-        $order['describe']=MobileInfo::where('mobile_id',$order['mobile_id'])->value('describe','');
-        $this->success('',$order);
-    }
-    /**
-     * 订单列表
-     * @ApiParams (name=page,description=page)
-     * @ApiParams (name=limit,description=limit)
-     * @ApiParams (name=phone,description=手机号)
-     * @ApiParams (name=type,description=1靓号2流量卡)
-     * @ApiParams (name=status,description="状态:0待付款10:已付款15:可发货17:有号码未发货20:待开卡25:已完成30:申请退款50:已关闭60:无号码70:换卡80:争议单90:已退款100:退款驳回")
-     * @ApiSummary (流量卡状态15:已提运营25:已完成)
-     */
-    public function order_list(){
-        $data=$this->_validate([
-            'phone|手机号'=>['require'],
-            'type|类型'=>['in:1,2'],
-        ]);
-        $type=$data['type']??1;
-        $type=$type?:1;
-        $order=MobileOrder::with(['proxy','info'])
-            ->filterShow($type)
-            ->where('type',$type)
-            ->where('phone',$data['phone'])->order('id','desc');
-
-        if(isset($data['status']) && $data['status']!=='' && $data['status']!==null){
-            $order->where('status',$data['status']);
-        }
-
-        $ret=$order->paginate(input('limit',15));
-
-        $this->success('',$ret);
-    }
-    /**
-     * 筛选配置
-     *
-     */
-    public function config(){
-        $config=[];
-        $networks=MobileConstant::getNetworkString();
-        $config['network']=$networks;
-        $config['rule']=MobileConstant::getRuleKeys();
-
-        $this->success('',$config);
-    }
-    /**
-     * 上传开卡资料
-     * @ApiParams (name=id,description=订单id)
-     * @ApiParams (name=idcard_face_img,description=身份证正面照片)
-     * @ApiParams (name=idcard_back_img,description=身份证反面照片)
-     * @ApiParams (name=face_img,description=本人照片)
-     * @ApiParams (name=name,description=本人姓名)
-     * @ApiParams (name=id_no,description=本人身份证号码)
-     * @ApiParams (name=phone,description=本人联系电话)
-     */
-    public function upload_identity(){
-        $data=$this->_validate([
-            'id'=>['require'],
-            'idcard_face_img|身份证正面照片'=>['require','url'],
-            'idcard_back_img|身份证反面照片'=>['require','url'],
-            'face_img|本人照片'=>['require','url'],
-            'name|本人姓名'=>['require','max:10'],
-            'id_no|本人身份证号码'=>['require'],
-            'phone|本人联系电话'=>['require','integer'],
-        ]);
-        $order=MobileOrder::findOrFail($data['id']);
-        if($order['open_uploaded']){
-            $this->error('请勿再次上传');
-        }
-        IdVerify::instance()->check($data['name'],$data['id_no']);
-        $order['open_uploaded']=1;
-        $order['open_idcard_face_img']=$data['idcard_face_img'];
-        $order['open_idcard_back_img']=$data['idcard_back_img'];
-        $order['open_face_img']=$data['face_img'];
-        $order['open_name']=$data['name'];
-        $order['open_id_no']=$data['id_no'];
-        $order['open_phone']=$data['phone'];
-        if(!$order->save()){
-            $this->error('保存失败');
-        }
-        $this->success('');
-    }
-    /**
-     * 预定号码
-     * @ApiParams (name=no,description=号码)
-     * @ApiParams (name=price_min,description=最低承受价格)
-     * @ApiParams (name=price_max,description=最高承受价格)
-     * @ApiParams (name=remark,description=备注)
-     * @ApiParams (name=name,description=姓名)
-     * @ApiParams (name=phone,description=联系电话)
-     * @ApiParams (name=county,description=区县ID)
-     * @ApiParams (name=address,description=详细地址)
-     */
-    public function order_no(){
-        $data=$this->_validate([
-            'no|预定号码'=>['require','integer','min:3','max:8'],
-            //'price_min'=>['require','integer','min:0'],
-            'price_max|可承受价格'=>['require','integer','min:0'],
-            'name|姓名'=>['require'],
-            'phone|联系电话'=>['require','integer','length:11'],
-            'county|城市'=>['require','integer'],
-            'address|详细地址'=>['require','length:0,250'],
-        ]);
-        $no=new MobileOrderNo;
-        $data['city']=implode(',',Area::getTreeId($data['county']));
-        $no->allowField(true)->save($data);
-        $this->success('');
-    }
-    /**
-     * 横幅播报
-     * @ApiReturnParams (name=ordered_num,description=已订购人数)
-     * @ApiReturnParams (name=no,description=号码)
-     * @ApiReturnParams (name=name,description=人名)
-     * @ApiReturnParams (name=num,description=人数)
-     */
-    public function ordered_show(){
-        $data=[];
-        $data['ordered_num']=SysConfig::look('mo_ordered_num',0);
-        $data['ordered_list']=AdIndexOrderedFlow::field('name,no,num')
-            ->order('num','asc')
-            ->select();
-        foreach ($data['ordered_list'] as $item){
-            $item['no']=substr($item['no'],0,3).'****'.substr($item['no'],7,4);
-            $item['name']=mb_substr($item['name'],0,mb_strlen($item['name'])-1).'*';
-        }
-        $this->success('',$data);
-    }
-    /**
-     * 退款
-     * @ApiMethod (POST)
-     * @ApiParams (name=id,description=订单id)
-     * @ApiParams (name=reason,description=退款原因)
-     */
-    public function refund(){
-        $data=$this->_validate([
-            'id'=>'require',
-            'reason'=>'require|max:250',
-        ]);
-        Db::startTrans();
-        $order=MobileOrder::where('type',1)->findOrFail($data['id']);
-        $order->checkAllowRefund();
-        $order->makeUserRefund($data['reason']);
-        Db::commit();
-        $this->success();
-    }
-    /**
-     * 查询物流
-     * @ApiMethod (POST)
-     * @ApiParams (name=id,description=订单id)
-     * @ApiReturnParams (name=AcceptTime,description=时间)
-     * @ApiReturnParams (name=AcceptStation,description=描述)
-     */
-    public function logistics(){
-        $data=$this->_validate([
-            'id'=>['require'],
-        ]);
-        $order=MobileOrder::findOrFail($data['id']);
-        $logistics=[];
-        if(!$order['trans_id']||!$order['trans_no']){
-            $this->success('',$logistics);
-        }
-        $logistics=TransferCheck::instance()->setNo($order['trans_no'])->setLogisticsCompany(LogisticsCompany::get($order['trans_id']))->setPhone($order['phone'])->setName($order['name'])->get();
-        $this->success('',$logistics);
-    }
-    /**
-     * 预占号码
-     * @ApiParams (name=id,description=号码ID)
-     * @ApiParams (name=chanId,description=通道ID)
-     */
-    public function take(){
-        $data=$this->_validate([
-            'id|号码'=>['require','gt:0'],
-        ]);
-        $open=config('site.auto_take_open');
-        $discount=config('site.auto_take_discount');
-        if(!$open){
-            $this->success('未开启');
-        }
-        if($discount<=0||$discount>10){
-            $this->success('参数错误');
-        }
-        Db::startTrans();
-        $mobile=Mobile::lock(true)->findOrFail($data['id']);
-        if($mobile['is_activity']){
-            Db::rollback();
-            $this->success('已开启');
-        }
-        $chanId=getChanId();
-        $amount_kill=bcmul($mobile['amount_base'],$discount/10,0);
-        $mobile->makeActivity($amount_kill,$chanId);
-        Db::commit();
-        $this->success('改价成功');
-    }
-}

+ 0 - 21
commands/Admin_disable.php

@@ -1,21 +0,0 @@
-<?php
-
-use app\admin\model\Admin;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class AdminDisable extends Com{
-    public static function run(){
-        $work=self::newWorker();
-        $work->onWorkerStart=function (WO $worker){
-            Timer::add(3,function ()use ($worker){
-                $userNum=Admin::where('id','>',1)
-                    ->where('logintime','<',strtotime('-1month'))
-                    ->where('status','normal')
-                    ->update(['status'=>'hidden']);
-                $userNum && self::log("禁用了{$userNum}个管理员");
-            });
-        };
-    }
-}
-AdminDisable::run();

+ 0 - 58
commands/bug_report.php

@@ -1,58 +0,0 @@
-<?php
-
-use app\admin\model\Admin;
-use think\Db;
-use think\Env;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class BugReport extends Com{
-    public static function run(){
-        $work=self::newWorker();
-        $work->onWorkerStart=function (WO $worker){
-            $file=ROOT_PATH.'/webhook';
-            $table= Db::name('bug_report');
-            Timer::add(3,function ()use ($worker,$file,$table){
-                try {
-                    if(file_exists($file)){
-                        $url=preg_replace('/\s+/','',file_get_contents(ROOT_PATH.'/webhook'));
-                        if($url){
-                            $bug=$table->where('send',0)->order('id','desc')->find();
-                            if($bug){
-                                $table->where('id',$bug['id'])->update(['send'=>1]);
-                                $bug['content']=json_decode($bug['content'],true);
-                                $bug['content']['msg']=str_replace("\\",'/',$bug['content']['msg']);
-                                $bug['content']['file']=str_replace("\\",'/',$bug['content']['file']);
-                                $bug['content']['line']=str_replace("\\",'/',$bug['content']['line']);
-                                $res=(new \GuzzleHttp\Client())
-                                    ->post($url,[
-                                        'json'=>[
-                                            /*'msgtype'=>'markdown',
-                                            'markdown'=>[
-                                                'content'=>"ERROR:<font color='warning'>{$bug['content']['msg']}</font>\n
-                                            >FILE:<font color='comment'>{$bug['content']['file']}</font>
-                                            >LINE:<font color='comment'>{$bug['content']['line']}</font>
-                                            "
-                                            ],*/
-
-                                            'msgtype'=>'text',
-                                            'text'=>[
-                                                'content'=>"错误:{$bug['content']['msg']}\n文件:{$bug['content']['file']}\n行数:{$bug['content']['line']}"
-                                            ],
-                                            'at'=>[
-                                                'isAtAll'=>true,
-                                            ],
-                                        ]
-                                    ]);
-                                self::log($res->getBody()->getContents());
-                            }
-                        }
-                    }
-                }catch (\Exception $e){
-                    self::logError($e);
-                }
-            });
-        };
-    }
-}
-BugReport::run();

+ 0 - 18
commands/mobile_delete.php

@@ -1,18 +0,0 @@
-<?php
-
-use app\common\model\MobileId;
-use app\service\EsMobileService;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class MobileDelete extends Com{
-    public static function run(){
-        $work=self::newWorker();
-        $work->onWorkerStart=function (WO $worker){
-            Timer::add(3,function ()use ($worker){
-                EsMobileService::delByMobile();
-            });
-        };
-    }
-}
-MobileDelete::run();

+ 0 - 35
commands/mobile_import.php

@@ -1,35 +0,0 @@
-<?php
-
-use app\admin\model\MobileUpload;
-use app\common\service\MobileImport;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class MobileImportWork extends Com{
-    public static function run(){
-        $work=self::newWorker();
-        $work->onWorkerStart=function (WO $worker){
-            Timer::add(3,function ()use ($worker){
-                self::import();
-            });
-        };
-    }
-    public static function import(){
-        $upload= MobileUpload::where('status',0)->find();
-        if(!$upload){
-            return;
-        }
-        $upload['status']=1;
-        $upload->save();
-        try {
-            MobileImport::import($upload['file'],$upload['admin_id'],$upload['params']['type'],$upload['params']['status'],$upload);
-        }catch (\Exception $e){
-            $upload['remark']=$e->getMessage();
-            $upload['status']=2;
-            $upload->save();
-            self::logError($e);
-        }
-    }
-}
-//MobileImportWork::run();

+ 0 - 32
commands/mobile_order_expired.php

@@ -1,32 +0,0 @@
-<?php
-use app\common\model\MobileOrder;
-use think\Db;
-use think\Log;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class MobileOrderExpired extends Com{
-    public static function run()
-    {
-        $work=self::newWorker();
-        $work->onWorkerStart=function ($conn){
-            Timer::add(3,function (){
-                $orders= MobileOrder::expired()->field('id')->select();
-                foreach ($orders as $order){
-                    try {
-                        Db::startTrans();
-                        $order=MobileOrder::where('id',$order['id'])->lock(true)->find();
-                        $order->cancel();
-                        Db::commit();
-                        self::log("处理订单:{$order['id']},成功");
-                    }catch (\Exception $e){
-                        self::log("处理订单:{$order['id']},失败");
-                        Db::rollback();
-                        self::logError($e);
-                    }
-                }
-            });
-        };
-    }
-}
-MobileOrderExpired::run();

+ 0 - 41
commands/mobile_order_unpay_notify.php

@@ -1,41 +0,0 @@
-<?php
-use app\common\model\MobileOrder;
-use app\common\service\SmsSend;
-
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class MobileOrderUnPayNotify extends Com{
-    public static function run()
-    {
-        $work=self::newWorker();
-        $work->onWorkerStart=function ($conn){
-            Timer::add(1,function (){
-                $orders= MobileOrder::waitPay()
-                    ->where('type',1)
-                    ->where('create_time','<',time()-300)
-                    ->field('id')
-                    ->whereNotExists('select * from mobile_order_mind where mobile_order.id=mobile_order_mind.mobile_order_id')
-                    ->select()
-                    ->toArray();
-                foreach ($orders as $orderId){
-                    try {
-                        $order=MobileOrder::find($orderId);
-                        if(!$order){
-                            continue;
-                        }
-                        SmsSend::orderUnPay($order['phone'],$order['no']);
-                        $order->mind()->save([]);
-                    }catch (\Exception $e){
-                        self::logError($e);
-                    }
-                }
-            });
-        };
-    }
-
-    public static function logname(){
-        return class_basename(__CLASS__);
-    }
-}
-MobileOrderUnPayNotify::run();

+ 0 - 17
commands/status.php

@@ -1,17 +0,0 @@
-<?php
-
-use app\admin\model\Admin;
-use Workerman\Lib\Timer;
-use Workerman\Worker as WO;
-
-class WorkStatus extends Com{
-    public static function run(){
-        $work=self::newWorker();
-        $work->onWorkerStart=function (WO $worker){
-            Timer::add(3,function ()use ($worker){
-                file_put_contents(RUNTIME_PATH.'/workerman.status','');
-            });
-        };
-    }
-}
-WorkStatus::run();