/** * @inheritdoc */ public function sendMessage(array $data) { $result = parent::sendMessage($data); if ($result && isset($data['touser'])) { // 记录发送日志 MessageHistory::add(['wid' => $this->model->id, 'from' => $this->model->original, 'to' => $data['touser'], 'message' => $data, 'type' => MessageHistory::TYPE_CUSTOM]); } return $result; }
/** * @param Wechat $wechat * @param array $config */ public function __construct(Wechat $wechat, $config = []) { $this->model = $wechat; $config = array_merge(['appId' => $this->model->key, 'appSecret' => $this->model->secret, 'token' => $this->model->token, 'encodingAesKey' => $this->model->encoding_aes_key], $config); parent::__construct($config); }