MqUserPayCancelService.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\main\service;
  3. use app\common\service\CampaignService;
  4. use app\main\service\BaseService;
  5. use app\main\service\MqService;
  6. use think\Config;
  7. class MqUserPayCancelService extends BaseService
  8. {
  9. protected const EXCHANGE_NAME ='cps.ex.delay.topic';
  10. protected const ROUTING_KEY = 'user.recharge.cancel';
  11. //新用户首冲取消
  12. protected const MSG_TYPE_FIRST_CANCEL = 1;
  13. //用户正常取消充值
  14. protected const MSG_TYPE_NORMAL_CANCEL = 2;
  15. /**
  16. * @var MqUserPayCancelService
  17. */
  18. protected static $self = null;
  19. /**
  20. * @return BaseService|MqUserPayCancelService
  21. */
  22. public static function instance()
  23. {
  24. if (self::$self == NULL) {
  25. self::$self = new self();
  26. }
  27. return self::$self;
  28. }
  29. /**
  30. * 授权取消支付推送客服消息
  31. * @param $data
  32. * @param $minites
  33. */
  34. public function sendFirstCancel($data,$minites){
  35. $data['type'] = self::MSG_TYPE_FIRST_CANCEL;
  36. $timeout = intval(Config::get('site.user_first_cancel_pay_time'))*1000*60;
  37. if($minites>0){
  38. $timeout = $minites*1000*60;
  39. }
  40. $mq = MqService::instance()->getDotMqInstance();
  41. $mq->transferDelayExchange($data, self::ROUTING_KEY,$timeout,self::EXCHANGE_NAME, 'topic');
  42. }
  43. /**
  44. * 取消支付推送客服消息
  45. * @param $data
  46. */
  47. public function sendNormalCancel($data){
  48. $data['type'] = self::MSG_TYPE_NORMAL_CANCEL;
  49. $timeout = intval(Config::get('site.user_cancel_pay_time'))*1000*60;
  50. $mq = MqService::instance()->getDotMqInstance();
  51. $mq->transferDelayExchange($data, self::ROUTING_KEY,$timeout,self::EXCHANGE_NAME, 'topic');
  52. }
  53. }