systemVoucherModel = new Voucher(); } function fetchVoucher() { $this->success($this->systemVoucherModel->order("takeAmount", "desc")->where("exchange_score", ">", 0)->select()); } function findConfig() { $params = (new BaseApiValidate([ 'config_name' => "require", ]))->checkBody(); $value = config("site." . $params["config_name"]); if (is_null($value)) { $protocol = Protocol::where('code', $params["config_name"])->find(); if ($protocol) { $value = $protocol["content"]; } } $this->success($value); } public function findAreaCode() { $params = (new BaseApiValidate([ "city_name" => "require", ]))->checkBody(); $area = (new Area())->where([ "name" => $params["city_name"], "level" => 2 ])->find(); $area ? $this->success($area) : $this->error("城市不存在!"); } public function getCitys() { $this->success((new Area())->where("use", 1)->where("level", "in", [1, 2])->select()); } public function getAllCitys() { $this->success((new Area())->where("use", 1)->select()); } public function getTags() { $this->success((new Tags())->select()); } public function fetchFeedbackReason() { $this->success([ "私单问题", "助教服务问题", "APP体验问题", "其他问题" ]); } public function fetchMembershipConfig() { $this->success((new Config())->select()); } public function question() { $this->success( (new Question()) ->order("weight", "ASC") ->select() ); } public function dynamicTopic() { $this->success((new Topic())->select()); } public function fetchFeedback($type = '*', $user_id = null, $massager_id = null, $agency_id = null, $page = 1, $size = 10) { $model = new Feedback(); $query = $model->where("status", 'in', $type == '*' ? ['default', 'dispose', 'refuse'] : [$type]); if ($user_id > 0) { $query->where("user_id", $user_id); } if ($massager_id > 0) { $query->where("massager_id", $massager_id); } if ($agency_id > 0) { $query->where("agency_id", $agency_id); } $paginate = $query ->page($page) ->paginate($size); $this->success([ $paginate->items(), $paginate->total() ]); } public function fetchHotel() { $params = (new BaseApiValidate())->checkBody([ "lng" => "require", "lat" => "require" ]); $model = new Hotel(); $subQuery = $model->field("*,round(st_distance_sphere (point({$params["lng"]},{$params["lat"]}),point ( `lng`, `lat` ))) distance"); $query = $model->table($subQuery->buildSql() . ' distance'); $paginate = $query ->order('distance', 'ASC') ->order("sort", "DESC") ->page(isset($params["page"]) ? $params["page"] : 1) ->paginate(isset($params["size"]) ? $params["size"] : 30); $this->success([ $paginate->items(), $paginate->total() ]); } }