where('is_chat', PatientCard::IS_CHAT_1)->first(); if (!$user) { $this->error()->fail('请先创建"就诊人"或默认选中一个"就诊人"。栏目位置:我的-就诊人'); } $data = [ 'address' => config('console.third_consult.scoket_address'), 'data' =>[ 'appid' => config('console.third_consult.appid'), 'app_type' => 1, 'customer_open_id' => $user->third_customer_openid, 'timestamp' => time() ] ]; $signStr = config('console.third_consult.secret').$data['data']['app_type'].$data['data']['customer_open_id'].$data['data']['timestamp']; $data['data']['auth_sign'] = md5(md5($signStr)); return $this->response($data); } public function getList(array $conditions, array $fields, string $sort, int $page, int $limit) { $result = SysConfig::where(function($query) use($conditions){ if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } })->orderByRaw($sort)->paginate($limit, $fields); return $this->response($result); } public function findBy(array $conditions, array $fields){ $result = SysConfig::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } })->first($fields); $carbon = Carbon::now(); $result->now_time = $carbon->toDateTimeString(); $result->today = $carbon->toDateString(); $result->month = number2Chinese(intval($carbon->format('m'))); $result->month_n = $carbon->format('m'); $result->day = $carbon->format('d'); $result->time = $carbon->format('H:i'); $result->week = week2Chinese($carbon->dayOfWeek); $result->last12hour = $carbon->subHours(12)->toDateTimeString(); return $result ? $this->response($result) : $this->error()->dataDoesNotExist(); } public function create(array $data) { $result = SysConfig::create($data); return $result ? $this->response($result) : $this->error()->fail(); } public function updateBy(array $conditions, array $data) { $result = SysConfig::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } })->update($data); return $result ? $this->response($result) : $this->error()->fail(); } public function deleteBy(array $conditions) { $result = SysConfig::where(function($query) use($conditions){ if (isset($conditions['id'])){ $query->where('id', $conditions['id']); } if (isset($conditions['uid'])){ $query->where('uid', $conditions['uid']); } })->delete(); return $result ? $this->response($result) : $this->error()->fail(); } public function weather(string $cityid) { $redisKey = config('console.redis_key.weather'); $rData = Redis::GET($redisKey); if ($rData){ $this->setLog(self::TYPENAME.'获取天气 redis 得到', $this->startTime(), [$rData]); $data = json_decode($rData, true); return $this->response($data); } //请求地址 $url = config('console.weather'); try { $client = new httpClient(); $res = $client->request('get', $url); $body = $res->getBody()->getContents(); $data = json_decode($body, true); Redis::SET($redisKey, json_encode($data)); Redis::EXPIRE($redisKey, 15*60); return $this->response($data); } catch (\Exception $e) { $this->setLog(self::TYPENAME.'weather 远程请求失败', $this->startTime, [$e->getMessage()]); $this->error()->fail(); } } }