getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); }); } public function getShowTypeList() { return ['0' => __('全部用户'),'1' => __('未付费'),'2' => __('普通付费'),'3' => __('年费会员')]; } public function getTypeList() { return ['0' => __('书币充值'),'1' => __('VIP充值'),'2'=>__('书币赠送')]; } public function getClassifyList() { return ['0' => __('微信充值'),'1' => __('支付宝充值')]; } public function getStatusList() { return ['1' => __('开启'),'2' => __('关闭')]; } public function getPopRangeList() { return ['0' => __('最近阅读'),'1' => __('男生'),'2' => __('女生'),'3' => __('个人中心'),'4' => __('分类'),'5' => __('免费'),'6' => __('完本')]; } public function getShowTypeTextAttr($value, $data) { $value = $value ? $value : $data['show_type']; $list = $this->getShowTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getClassifyTextAttr($value, $data) { $value = $value ? $value : $data['classify']; $list = $this->getClassifyList(); return isset($list[$value]) ? $list[$value] : ''; } public function getTypeTextAttr($value, $data) { $value = $value ? $value : $data['type']; $list = $this->getTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : $data['status']; $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getPopRangeTextAttr($value, $data) { $value = $value ? $value : $data['pop_range']; $valueArr = explode(',', $value); $list = $this->getPopRangeList(); return implode(',', array_intersect_key($list, array_flip($valueArr))); } protected function setPopRangeAttr($value) { return is_array($value) ? implode(',', $value) : $value; } /** * 获取基本信息 * @param $id * @return array * @throws \think\Exception */ public function getInfo($id) { $row = []; $key = 'R-I:'.$id; $redis = Redis::instance(); if ($redis->exists($key)) { $redis_key_type = $redis->type($key); if($redis_key_type == \Redis::REDIS_STRING){ $row = []; }else{ $row = $redis->hGetAll($key); } } else { $rowModel = model('Resource')->where('id', $id)->find(); if ($rowModel) { $row = $rowModel->toArray(); $redis->hMSet($key, $row); $redis->expire($key, 600); } else { $redis->set($key, 'null', 600); } } return $row; } }