| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace app\api\controller;
- use app\api\validate\BaseApiValidate;
- use app\common\controller\Api;
- use think\Request;
- class Service extends Api
- {
- protected $noNeedLogin = [
- 'fetchAppCategory',
- 'fetchApp',
- 'fetchStoreCategory',
- 'fetchStore'
- ];
- private $serviceCategoryModel;
- private $serviceModel;
- public function __construct(Request $request = null)
- {
- $this->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()
- ]);
- }
- }
|