Bonus.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Bonus as BonusService;
  13. class Bonus extends Base {
  14. /**
  15. * 领劵中心
  16. * @return \think\response\Json
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function index(){
  22. try{
  23. return $this->returnAjax("ok",1,BonusService::getList(Request::param()));
  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 receive(){
  33. try {
  34. return $this->returnAjax("领取优惠劵成功",1,BonusService::receive(Request::param("id","0","intval")));
  35. }catch (BaseException $ex){
  36. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  37. }
  38. }
  39. }