Products.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\controller;
  10. use app\common\exception\BaseException;
  11. use think\facade\Request;
  12. use app\api\service\Products as ProductsService;
  13. class Products extends Base {
  14. /**
  15. * 热门商品
  16. * @return \think\response\Json
  17. */
  18. public function hot(){
  19. try{
  20. return $this->returnAjax("ok",1,ProductsService::getList(Request::param(),[
  21. ["g.status","=",0],
  22. ["e.attribute","=","hot"]
  23. ]));
  24. }catch (BaseException $ex){
  25. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  26. }
  27. }
  28. /**
  29. * 推荐商品
  30. * @return \think\response\Json
  31. */
  32. public function recommend(){
  33. try{
  34. return $this->returnAjax("ok",1,ProductsService::getList(Request::param(),[
  35. ["g.status","=",0],
  36. ["e.attribute","=","recommend"]
  37. ]));
  38. }catch (BaseException $ex){
  39. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  40. }
  41. }
  42. }