true, 'find' => null, 'channel' => null, 'replace' => null, 'params' => null, ]; /** * @var ChangeMenuService */ protected static $self = null; /** * @return BaseService|ChangeMenuService */ public static function instance() { if (self::$self == NULL) { self::$self = new self(); } return self::$self; } /** * 不推送到微信 */ public function noPushWeChat(){ $this->map['is_push'] = false; return $this; } /** * 设置要查找替换的域名 * @param $host * @return $this * @throws \Exception */ public function setFindHost($host){ if(!is_string($host)){ throw new \Exception("参数错误"); } $this->map['find'] = $host; return $this; } /** * 根据业务域名ID查找替换 * @param int $host_id * @return $this * @throws \Exception */ public function setFindHostById($host_id){ if(!is_numeric($host_id)){ throw new \Exception("参数错误"); } $host_info = model('Ophost')->getInfoById($host_id); $host = $host_info['host'] ?? null; $this->map['find'] = $host; return $this; } /** * 设置要替换的域名ID * @param int $host_id * @return $this * @throws \Exception */ public function setReplaceHostById($host_id){ if(!is_numeric($host_id)){ throw new \Exception("参数错误"); } $host_info = model('Ophost')->getInfoById($host_id); $host = $host_info['host'] ?? null; $this->map['replace'] = $host; return $this; } /** * 设置要替换的域名 * @param $host * @return $this * @throws \Exception */ public function setReplaceHost($host){ if(!is_string($host)){ throw new \Exception("参数错误"); } $this->map['replace'] = $host; return $this; } /** * 设置要替换的渠道ID * @param $channel_id * @return ChangeMenuService */ public function setChannelId($channel_id){ $this->map['channel'] = $channel_id; return $this; } /** * 设置要追加的参数 * @param array $params * @return $this */ public function setAppendParams(array $params){ $this->map['params'] = $params; return $this; } /** * 推送MQ消息 */ public function push(){ $mq = MqService::instance()->getDotMqInstance(); $mq->transferExchange($this->map, self::EXCHANGE_NAME, MqConstants::CHANNEL_CHANGE_MENU, 'topic'); } }