__('Status normal'),'hide' => __('Status hide')]; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : $data['status']; $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } /** * 获取收费书籍信息 * @param $channel_id * @param $book_id * @return array */ public function getInfo($channel_id, $book_id) { $cache = CacheConstants::getChapterFeeCache($channel_id, $book_id); $data = Redis::instance()->hGetAll($cache); if (!$data) { $info = $this->where('book_id', $book_id) ->where('admin_id', $channel_id) ->where('status', 'normal') ->find(); if ($info) { $data = [ 'id' => $info['id'], 'chapter_charge_start' => $info->getData('chapter_charge_start'), 'chapter_kandian' => $info->getData('chapter_kandian'), ]; } else { $data = ['id' => 0]; } Redis::instance()->hMSet($cache, $data); Redis::instance()->expire($cache, 600); } if (!$data['id']) { return []; } else { return $data; } } /** * 清除缓存 * @param $channel_id * @param $book_id */ public function clearInfo($channel_id, $book_id) { $cache = CacheConstants::getChapterFeeCache($channel_id, $book_id); Redis::instance()->del($cache); } }