module(); //获取指定入口域名 if($modulename == 'admin' && PHP_SAPI != 'cli'){ //如果是后台 $obj = $this->where('id',$id)->find(); $arr = is_object($obj) ? $obj->toArray() : []; }else{ $key = 'EH:'.$id; if($redis->exists($key)){ $arr = $redis->hgetall($key); }else{ $arr = $this->where('id',$id)->find(); if($arr){ $arr = $arr->toArray(); $redis->hmset($key,$arr); $redis->expire($key,3600); } } } return $arr; } return false; } //获取所有可用的支付域名 public function getHosts(){ $modulename = request()->module(); if($modulename == 'admin' && PHP_SAPI != 'cli'){ $res = $this->column('host'); }else{ $redis = Redis::instance(); $key = 'ENTRYHOST'; if ($ret = $redis->get($key)) { $res = json_decode($ret, true); }else{ $res = $this->column('host'); $redis->setex($key,86400,json_encode($res)); } } return $res; } public function getStatusList() { return ['0' => __('Status 0'),'1' => __('Status 1')]; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : $data['status']; $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } }