Home.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\controller\api;
  3. use app\extra\basic\Base;
  4. use app\extra\dyLife\data\BaseData;
  5. use app\middleware\AuthMiddleware;
  6. use app\model\saas\SaasGoods;
  7. use app\model\saas\SaasStore;
  8. use LinFly\Annotation\Attributes\Route\Controller;
  9. use LinFly\Annotation\Attributes\Route\GetMapping;
  10. use LinFly\Annotation\Attributes\Route\Middleware;
  11. use support\Request;
  12. use support\Response;
  13. use Webman\RedisQueue\Redis;
  14. #[Controller("/dy/home"),Middleware(AuthMiddleware::class)]
  15. class Home extends Base
  16. {
  17. /**
  18. * @var array|string[]
  19. */
  20. protected array $noNeedLogin = ["getHomeData","getLicense"];
  21. #[GetMapping("data")]
  22. public function getHomeData(Request $request): Response
  23. {
  24. try {
  25. $param = $this->_valid([
  26. "store.require" => trans("empty.require")
  27. ],$request->method());
  28. if (!is_array($param)) return error($param);
  29. $banner = [
  30. [
  31. "cover" => "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/dc7fd761c2e2af9c340f20677f8f115d942f0bde.png"
  32. ]
  33. ];
  34. $store = (new SaasStore)->where("poi_id",$param['store'])->field("poi_name,start_at,end_at,longitude,latitude,service_mobile")->findOrEmpty();
  35. $goods = (new SaasGoods)->where("poi_id",$param['store'])->field("product_id,product_name,image_list,category,price,line_price,sale_stock,id")->select()->toArray();
  36. return success("ok",compact('banner','store','goods'));
  37. } catch (\Throwable $th) {
  38. return error($th->getMessage());
  39. }
  40. }
  41. #[GetMapping("license")]
  42. public function getLicense(): Response
  43. {
  44. try {
  45. return success("ok",['img' => sConf("service.license")]);
  46. } catch (\Throwable $throwable) {
  47. return error($throwable->getMessage());
  48. }
  49. }
  50. }