You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://doc.hyperf.io
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace App\Controller;
  12. use Hyperf\DbConnection\Db;
  13. use Hyperf\Redis\Redis;
  14. use Hyperf\Utils\ApplicationContext;
  15. use App\Service\CouponRebateInterface;
  16. use http\Client\Curl\User;
  17. use Hyperf\Di\Annotation\Inject;
  18. use App\Model\Coupon;
  19. use App\Model\CouponUserRecType;
  20. use App\Model\CouponRec;
  21. use App\Request\CouponRebateReceiveRequest;
  22. use App\Service\CouponRebateService;
  23. class CouponRebateController extends BaseController
  24. {
  25. /**
  26. * @Inject
  27. * @var CouponRebateInterface
  28. */
  29. protected $CouponRebate;
  30. /**
  31. * @Inject
  32. * @var CouponRebateService
  33. */
  34. protected $CouponRebateService;
  35. /**
  36. * 用户是否领取过领取优惠券
  37. */
  38. public function isCouponRebate()
  39. {
  40. $user_id = $this->request->input('user_id', 0);
  41. $res = $this->CouponRebate->isCouponRebate($user_id);
  42. return $this->success($res);
  43. }
  44. /**
  45. * 返回活动信息
  46. */
  47. public function getActiveInfo()
  48. {
  49. $res = $this->CouponRebate->getActiveInfo();
  50. return $this->success($res);
  51. }
  52. /**
  53. * 用户领取优惠券
  54. * 2020.08.04 只领一张优惠券
  55. */
  56. public function userReceiveCoupon(CouponRebateReceiveRequest $validator)
  57. {
  58. return $this->success($this->CouponRebateService->userReceiveCoupon($this->request->all()));
  59. }
  60. }