|
|
@@ -0,0 +1,47 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace business\controllers;
|
|
|
+
|
|
|
+use biz\user\services\UserService;
|
|
|
+use Yii;
|
|
|
+use common\components\util;
|
|
|
+use GatewayClient\Gateway;
|
|
|
+
|
|
|
+class ChatController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ //聊天 shish 2019.12.28
|
|
|
+ public function actionIndex()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $userId = isset($get['userId']) ? $get['userId'] : 0;
|
|
|
+ $user = UserService::getById($userId);
|
|
|
+ UserService::valid($user, $this->merchantId);
|
|
|
+ return $this->renderPartial('index',['userId'=>$userId]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定 shish 2019.12.28
|
|
|
+ public function actionBind()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $clientId = isset($post['clientId']) ? $post['clientId'] : '';
|
|
|
+ $id = 'merchant_' . $this->merchantId;
|
|
|
+ Gateway::bindUid($clientId, $id);
|
|
|
+ }
|
|
|
+
|
|
|
+ //发消息给客户 shish 2019.12.28
|
|
|
+ public function actionSend()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $msg = isset($post['msg']) ? $post['msg'] : '';
|
|
|
+ $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
+ $user = UserService::getById($userId);
|
|
|
+ UserService::valid($user, $this->merchantId);
|
|
|
+ $m = json_encode(array(
|
|
|
+ 'type' => 'msg',
|
|
|
+ 'msg' => $msg,
|
|
|
+ ));
|
|
|
+ Gateway::sendToUid($userId, $m);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|