| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace app\api\controller;
- use app\admin\model\dynamic\Topic;
- use app\admin\model\Hotel;
- use app\admin\model\membership\Config;
- use app\admin\model\Protocol;
- use app\admin\model\Question;
- use app\api\model\Area;
- use app\api\model\system\Feedback;
- use app\api\model\Tags;
- use app\api\model\Voucher;
- use app\api\validate\BaseApiValidate;
- use app\common\controller\Api;
- use think\Request;
- class System extends Api
- {
- protected $noNeedLogin = ["*"];
- private $systemVoucherModel;
- public function __construct(Request $request = null)
- {
- parent::__construct($request);
- $this->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()
- ]);
- }
- }
|