model = new \app\admin\model\Mobile; $this->assign('status',\app\common\model\Mobile::$status); $this->assign('network',MobileConstant::getNetworkString()); $this->assign('network_select',MobileConstant::getNetworkSelect()); } public function import() { MobileImport::import(input('file'),$this->auth->id); $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']); 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','proxy']) ->where($where) ->where('mobile.type',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)); } $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(); } protected function getOrder(){ $filter=json_decode(input('filter'),true); $default='mobile.id desc'; 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('sub')){ $map['hold_chan']=$this->auth->id; } $list = $this->model ->with(['info','proxy']) ->where($where) ->where($map) ->where('mobile.type',1) ->where('mobile.is_activity',1) ->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_values(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('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(''); } #预占 public function takeit($ids){ if($this->request->isGet()){ $mobile=$this->model->find($ids); $this->assign('row',$mobile); return view(); }else{ Db::startTrans(); $mobile=$this->model->lock(true)->find($ids); $data=input('row/a'); $data['is_activity']=intval($data['is_activity']); //(new MobilePriceLogService)->setMobile($mobile)->setAdminId($this->auth->id)->setBeforePrice($mobile['amount_base'])->setAfterPrice($data['amount_base'])->log(); foreach (['amount_original','amount_di','amount_base','amount_charge','amount_kill','is_activity','activity_time_end'] as $field){ $mobile[$field]=$data[$field]; } if($mobile['amount_kill']<$mobile['amount_di']){ $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->allowField(true)->save($data); 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'); $this->assign('row',$mobile); return view(); }else{ $mobiles=$this->model->whereIn('id',$ids)->select(); foreach ($mobiles as $mobile){ Db::startTrans(); $data=input('row/a'); unset($data['no']); $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']); } if(isset($data['amount_base'])) { //(new MobilePriceLogService)->setMobile($mobile)->setAdminId($this->auth->id)->setBeforePrice($mobile['amount_base'])->setAfterPrice($data['amount_base'])->log(); } $mobile->allowField(true)->save($data); $describe=$data['describe']??''; if($describe) { $mobile->info()->update(compact('describe')); } Db::commit(); } $this->success(); } } public function multi_edit(){ if($this->request->isGet()) { return view(); }else{ $this->edit(input('ids')); } } public function multi_edit_proxy(){ if($this->request->isGet()) { return view(); }else{ $this->validate(input('row/a'),[ 'proxy_id'=>['require','integer'], ]); $this->model->whereIn('id',input('ids'))->update([ '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'], ]); $this->model->whereIn('id',input('ids'))->update([ 'status'=>input('row.status'), ]); $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_reverse($temp); $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 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'); $this->validate($data,[ 'amount_kill|秒杀价'=>['require','number','gt:0'], ]); $mobiles=$this->model->whereIn('id',$ids)->select(); Db::startTrans(); foreach ($mobiles as $mobile){ $mobile['amount_kill']=$data['amount_kill']; $mobile['is_activity']=1; if(!$mobile->save()){ Db::rollback(); $this->error('保存失败'); } } 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=[]; 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)); } return $this->model->whereIn('id',$ids)->delete(); } 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', ]); if($data['act']=='delete'){ $mobiles=$this->model->whereIn('no',$data['no'])->select(); Db::startTrans(); foreach ($mobiles as $mobile){ $mobile->delete(); } $num=count($mobiles); Db::commit(); }elseif($data['act']=='up'){ $num=$this->model->whereIn('no',$data['no'])->update(['status'=>0]); }elseif($data['act']=='down'){ $num=$this->model->whereIn('no',$data['no'])->update(['status'=>2]); } $this->result(['num'=>$num],1); } } public function mobile_rules(){ return MobileConstant::getRuleKeys(); } public function activity_cancel($ids){ $mobile=$this->model->findOrFail($ids); $admin=Admin::get($this->auth->id); if(!$mobile['is_activity']){ $this->error('该号码没有被预占无法取消'); } if($admin['proxy']){ $this->error('您是供应商,无法使用此功能'); } if($admin['sub'] && $mobile['hold_chan']!=$admin['id']){ $this->error('您无法取消'); } $mobile->makeNotActivity(); $this->success(); } public function batch_activity_cancel($ids){ $map=[]; if($this->admin('sub')){ $map['hold_chan']=$this->admin('id'); } $this->model->whereIn('id',$ids)->where($map)->update([ 'is_activity'=>0, 'activity_time'=>0, 'hold_chan' =>0, 'hold_user' =>0, ]); $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('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('sub')){ $mobileSub=MobileSub::getBy($mobile,$this->admin()); $mobileSub['sub_sort']=$data['sort']; $mobileSub->save(); }else{ $mobile['sort']=$data['sort']; $mobile->save(); } $this->success(); } } }