/** * Recieve message from weconnect * * <b>Request Type: </b>POST<br/> * <b>Content-Type: </b>application/json<br/> * <b>Request Endpoint: </b>http://{server-domain}/api/chat/conversation/wechat-message<br/> * <b>Summary: </b>This api is for recieving a message from weconnect<br/> * * <b>Request Parameters: </b><br/> * message: object, the content for the message<br/> * message.msgType: string, "text"<br/> * message.content: mixed, the body of the content<br/> * account: object, the account information<br/> * user: object, the user information<br/> * userId: string, the wechat user id<br/> * * <b>Response Example</b> * <pre>{"status":"ok"}</pre> */ public function actionWechatMessage() { $message = $this->getParams('message'); $type = $message['msgType']; $content = $message['content']; $WEConnectAccountInfo = $this->getParams('account'); $WEConnectUserInfo = $this->getParams('user'); $accountId = $this->getAccountId(); $args = ['message' => $message, 'account' => $WEConnectAccountInfo, 'user' => $WEConnectUserInfo, 'accountId' => (string) $accountId]; $redis = \Yii::$app->cache->redis; $modeKey = SelfHelpDeskSetting::CONVERSATION_MODE_PREFIX . $accountId . '-' . $WEConnectUserInfo['id']; if (SelfHelpDeskSetting::exists($accountId)) { // use selfHelpDesk $selfHelpDeskFlag = $redis->get($modeKey); if (empty($selfHelpDeskFlag)) { $selfHelpDeskFlag = 'true'; } switch ($selfHelpDeskFlag) { case 'false': break; default: SelfHelpDeskSetting::autoReply($args); return ['status' => 'ok']; break; } } $redis->set($modeKey, 'false', 'EX', SelfHelpDeskSetting::EXPIRED_TIME); Yii::$app->job->create('backend\\modules\\chat\\job\\WechatMessage', $args); return ['status' => 'ok']; }