12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\main\service;
- use app\common\service\CampaignService;
- use app\main\service\BaseService;
- use app\main\service\MqService;
- use think\Config;
- class MqUserPayCancelService extends BaseService
- {
- protected const EXCHANGE_NAME ='cps.ex.delay.topic';
- protected const ROUTING_KEY = 'user.recharge.cancel';
- //新用户首冲取消
- protected const MSG_TYPE_FIRST_CANCEL = 1;
- //用户正常取消充值
- protected const MSG_TYPE_NORMAL_CANCEL = 2;
- /**
- * @var MqUserPayCancelService
- */
- protected static $self = null;
- /**
- * @return BaseService|MqUserPayCancelService
- */
- public static function instance()
- {
- if (self::$self == NULL) {
- self::$self = new self();
- }
- return self::$self;
- }
- /**
- * 授权取消支付推送客服消息
- * @param $data
- * @param $minites
- */
- public function sendFirstCancel($data,$minites){
- $data['type'] = self::MSG_TYPE_FIRST_CANCEL;
- $timeout = intval(Config::get('site.user_first_cancel_pay_time'))*1000*60;
- if($minites>0){
- $timeout = $minites*1000*60;
- }
- $mq = MqService::instance()->getDotMqInstance();
- $mq->transferDelayExchange($data, self::ROUTING_KEY,$timeout,self::EXCHANGE_NAME, 'topic');
- }
- /**
- * 取消支付推送客服消息
- * @param $data
- */
- public function sendNormalCancel($data){
- $data['type'] = self::MSG_TYPE_NORMAL_CANCEL;
- $timeout = intval(Config::get('site.user_cancel_pay_time'))*1000*60;
- $mq = MqService::instance()->getDotMqInstance();
- $mq->transferDelayExchange($data, self::ROUTING_KEY,$timeout,self::EXCHANGE_NAME, 'topic');
- }
- }
|