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.

94 lines
2.8 KiB

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