request->isPost()) { $params = $this->request->post("row/a"); if ($params) { /* * 已经弃用,如果为了兼容老版可取消注释 foreach ($params as $k => &$v) { $v = is_array($v) ? implode(',', $v) : $v; } */ if ($this->dataLimit) { $params[$this->dataLimitField] = $this->auth->id; } try { //是否采用模型验证 if ($this->modelValidate) { $name = basename(str_replace('\\', '/', get_class($this->model))); $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; $this->model->validate($validate); } $result = $this->model->allowField(true)->save($params); if ($result !== false) { $this->success(); } else { $this->error($this->model->getError()); } } catch (\think\exception\PDOException $e) { $this->error($e->getMessage()); } } $this->error(__('Parameter %s can not be empty', '')); } $wheres['state'] = 1; $wheres['cansee'] = 1; $books = model("Book")->where($wheres)->field('id,name')->select(); $isWrite = MiniProgramService::instance()->miniWrite($this->auth->id,$this->group); $this->assign('isWrite',$isWrite); $this->view->assign("bookList", $books); $notids = []; ExclusiveService::instance()->getExclusiveNotidsWithoutWhere($this->group, $this->auth->id,$notids); $this->assignconfig('notids',$notids); return $this->view->fetch(); } public function getactivity(){ if($this->request->isAjax()){ $current_time = time(); $model = model('activity'); if( $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_SUPER_ADMIN) || $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_OPERATOR) ){ $where['is_system'] = 1; $where['type'] = 0; } elseif( $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) || $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR) ){ $where['admin_id'] = $this->auth->id; $where['type'] = 1; } elseif( $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_CHANNEL) || $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_AGENT) ){ $where['admin_id'] = $this->auth->id; $where['type'] = 1; } $where['starttime'] = ['<=',$current_time]; $where['endtime'] = ['>',$current_time]; $where['status'] = 1; $list = $model->where($where)->order('id','desc')->field('id,name')->select(); return json($list); } } public function getcampaign(){ if($this->request->isAjax()){ $current_time = time(); $model = model('campaign_read'); $where['start_time'] = ['<=',$current_time]; $where['end_time'] = ['>',$current_time]; $where['status'] = 'normal'; $list = $model->where($where)->order('id','desc')->field('id,name')->select(); return json($list); } } public function getchapter(){ if($this->request->isAjax()) { $bookId = $this->request->request('book_id'); $chapters = model("Book")::getChapterLimit($bookId, 0, 9); if(!empty($chapters)){ return json($chapters); }else{ return []; } } } public function getbook(){ if($this->request->isAjax()) { $where['state'] = 1; $where['cansee'] = 1; $books = model("Book")->where($where)->field('id,name')->select(); if(!empty($books)){ return json($books); }else{ return []; } } } public function autocompletebookname() { if ($this->request->isAjax()) { $keyword = $this->request->post('name') ?? $this->request->param('pkey_value'); $data = []; $keyword = trim($keyword); $bookModel = model('Book'); $map = []; if ($this->group > 2) { $map['cansee'] = 1; } //获取独家书籍id ExclusiveService::instance()->getExclusiveNotidsWithWhere($this->group, $this->auth->id,$map); if (!empty($keyword)) { $bookList = $bookModel ->where('state', 'neq', BookConstants::BOOK_STATE_OFF_SALE) ->where($map) ->where(function (Query $query) use ($keyword) { $query->where('name', 'like', "%{$keyword}%") ->whereOr('id', $keyword); }) ->limit(0, 6)->select(); } else { $bookList = $bookModel->where('state', 'neq', BookConstants::BOOK_STATE_OFF_SALE)->where($map)->order('book.idx desc,book.idxx desc')->limit(0, 6)->select(); } $data = $bookList; return json(['list' => $data, 'total' => count($data)]); } } }