serviceCategoryModel = new \app\api\model\service\Category(); $this->serviceModel = new \app\api\model\service\Service(); parent::__construct($request); } /** * 获取App服务分类 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function fetchAppCategory() { $category = $this->serviceCategoryModel->fetchServiceCategory(\E_SERVICE_TYPE::App); $this->success($category); } /** * 获取App服务 */ public function fetchApp() { $params = (new BaseApiValidate([ 'city_code' => "require|number", 'category_id' => "number", 'hot' => "number", // 'is_add_clock' ]))->checkBody(); $user = $this->auth->getUser(); list($page, $size) = [$params['page'] ?? 1, $params['size'] ?? 10]; $paginate = $this->serviceModel->fetchServices(\E_SERVICE_TYPE::App, $params, $page, $size, $user); $items = collection($paginate->items())->toArray(); $membership_discount_rate = config("site.membership_discount_rate") / 100; foreach ($items as &$item) { $item["membership_discount_price"] = fixed2Float($item["real_price"] * $membership_discount_rate); } $this->success([ $items, $paginate->total() ]); } /** * 获取球房服务分类 */ public function fetchStoreCategory() { $params = (new BaseApiValidate([ 'store_id' => "require|number", ]))->checkBody(); $category = $this->serviceCategoryModel->fetchServiceCategory(\E_SERVICE_TYPE::Store, $params['store_id']); $this->success($category); } public function fetchStore() { $params = (new BaseApiValidate([ 'store_id' => "require|number", 'category_id' => "number", 'hot' => "number" ]))->checkBody(); list($page, $size) = [$params['page'] ?? 1, $params['size'] ?? 10]; $paginate = $this->serviceModel->fetchServices(\E_SERVICE_TYPE::Store, $params, $page, $size); $items = collection($paginate->items())->toArray(); $membership_discount_rate = config("site.membership_discount_rate") / 100; foreach ($items as &$item) { $item["membership_discount_price"] = fixed2Float($item["real_price"] * $membership_discount_rate); } $this->success([ $items, $paginate->total() ]); } public function siftService() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ "page" => "require|number", "size" => "require|number" ]))->checkBody(); $paginate = $this->serviceModel->fetchServices(\E_SERVICE_TYPE::App, ["is_add_clock" => $params["is_add_clock"] ?? null, "sift" => 1], $params['page'], $params['size'], $user); $items = collection($paginate->items())->toArray(); $membership_discount_rate = config("site.membership_discount_rate") / 100; foreach ($items as &$item) { $item["membership_discount_price"] = fixed2Float($item["real_price"] * $membership_discount_rate); } $this->success([ $items, $paginate->total() ]); } }