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.

93 lines
2.7 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
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\CouponRebateServiceInterface;
  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. use App\Request\CouponRebateTieRequest;
  24. class CouponRebateController extends BaseController
  25. {
  26. /**
  27. * @Inject
  28. * @var CouponRebateService
  29. */
  30. protected $CouponRebateService;
  31. /**
  32. * 用户是否领取过领取优惠券
  33. */
  34. public function isCouponRebate()
  35. {
  36. $user_id = $this->request->input('user_id', 0);
  37. $res = $this->CouponRebateService->isCouponRebate($user_id);
  38. return $this->success($res);
  39. }
  40. /**
  41. * 返回活动信息
  42. */
  43. public function getActiveInfo()
  44. {
  45. $res = $this->CouponRebateService->getActiveInfo();
  46. return $this->success($res);
  47. }
  48. /**
  49. * 用户领取优惠券
  50. */
  51. public function userReceiveCoupon(CouponRebateReceiveRequest $validator)
  52. {
  53. return $this->success($this->CouponRebateService->userReceiveCoupon($this->request->all()));
  54. }
  55. public function couponRebate()
  56. {
  57. $order_id = $this->request->input('order_id', 0);
  58. $res = $this->CouponRebateService->couponRebate($order_id);
  59. return $this->success($res);
  60. }
  61. /**
  62. * 将优惠券绑定活动
  63. */
  64. public function tieCouponActive(CouponRebateTieRequest $validator)
  65. {
  66. $couponForward = $this->request->input('coupon_forward_ids',[]);
  67. $couponForward = is_array($couponForward) ? implode(',',$couponForward) : $couponForward ;
  68. $couponRepay = $this->request->input('coupon_repay_id',0);
  69. $couponActivity = $this->request->input('coupon_activity',0);
  70. $res = $this->CouponRebateService->tieCouponActive($couponActivity,$couponForward,$couponRepay);
  71. return $this->success($res);
  72. }
  73. /**
  74. * 清优惠券领取记录(SSDB)
  75. */
  76. public function clearSsdbCouponReceiveByName(){
  77. $activity = $this->request->input('activity_type',0);
  78. $userId = $this->request->input('user_id',0);
  79. $get = $this->request->input('get',0);
  80. $isAll = $this->request->input('is_all',0);;
  81. return $this->success($this->CouponRebateService->clearSsdbCouponReceiveByName($activity,$userId, $get, $isAll));
  82. }
  83. }