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.

45 lines
1.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Amqp\Consumer;
  4. use App\Constants\SsdbKeysPrefix;
  5. use Hyperf\Amqp\Result;
  6. use Hyperf\Amqp\Annotation\Consumer;
  7. use Hyperf\Amqp\Message\ConsumerMessage;
  8. use Hyperf\Utils\ApplicationContext;
  9. use PhpAmqpLib\Message\AMQPMessage;
  10. use App\Service\CouponRebateService;
  11. use App\Service\CouponRebateServiceInterface;
  12. use Hyperf\Di\Annotation\Inject;
  13. /**
  14. * @Consumer(exchange="deviceCouponRebate", routingKey="deviceCouponRebate", queue="deviceCouponRebate", name ="couponRebateConsumer", nums=1)
  15. */
  16. class couponRebateConsumer extends ConsumerMessage
  17. {
  18. /**
  19. * @Inject
  20. * @var CouponRebateService
  21. */
  22. protected $CouponRebateService;
  23. public function consumeMessage($data, AMQPMessage $message): string
  24. {
  25. $res = $this->CouponRebateService->couponRebate($data);
  26. if (!$res) {
  27. return Result::REQUEUE;
  28. }
  29. return Result::ACK;
  30. }
  31. public function isEnable(): bool
  32. {
  33. if(env('APP_ENV') == 'local') {
  34. return false;
  35. }
  36. return parent::isEnable();
  37. }
  38. }