|
|
@@ -69,62 +69,7 @@ class ChatController extends BaseController
|
|
|
$id = 'merchantConsole_' . $this->sjId;
|
|
|
Gateway::bindUid($clientId, $id);
|
|
|
}
|
|
|
-
|
|
|
- //发消息给客户 ssh 2019.12.28
|
|
|
- public function actionSend()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $type = isset($post['type']) ? $post['type'] : 'text';
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $user = UserService::getById($userId);
|
|
|
- UserService::valid($user, $this->sjId);
|
|
|
- $arr = [];
|
|
|
- $arr['type'] = $type;
|
|
|
- $arr['source'] = 'merchant';
|
|
|
- $arr['time'] = '12:51';
|
|
|
- switch ($type) {
|
|
|
- case 'text':
|
|
|
- //文字
|
|
|
- $content = $post['content'];
|
|
|
- $arr['content'] = $content;
|
|
|
- break;
|
|
|
- case 'img':
|
|
|
- //图片
|
|
|
- $shortUrl = $post['shortUrl'];
|
|
|
- $return = business::formatUploadImg($shortUrl);
|
|
|
- $arr['url'] = $return['url'];
|
|
|
- $arr['smallUrl'] = $return['smallUrl'];
|
|
|
- break;
|
|
|
- case 'link':
|
|
|
- //常用链接
|
|
|
- $id = $post['linkId'];
|
|
|
- $respond = MerchantService::getCommonUrl($id);
|
|
|
- $arr['name'] = $respond['name'];
|
|
|
- $arr['img'] = $respond['img'];
|
|
|
- $arr['url'] = $respond['url'];
|
|
|
- break;
|
|
|
- case 'goods':
|
|
|
- //商品
|
|
|
- $id = $post['goodsId'];
|
|
|
- $info = GoodsService::getGoodsInfo($id);
|
|
|
- GoodsService::valid($info, $this->sjId);
|
|
|
- $arr['name'] = $info['name'];
|
|
|
- $arr['img'] = isset($info['smallImgList'][0]) ? $info['smallImgList'][0] : '';
|
|
|
- $arr['price'] = isset($info['price']) ? $info['price'] : 300;
|
|
|
- break;
|
|
|
- }
|
|
|
- $data[] = $arr;
|
|
|
- //放入缓存
|
|
|
- ChatService::saveMessage($data, $userId);
|
|
|
- $online = Gateway::getClientIdByUid($userId);
|
|
|
- if ($online) {
|
|
|
- //直接发送
|
|
|
- Gateway::sendToUid($userId, json_encode($data));
|
|
|
- util::success($data);
|
|
|
- }
|
|
|
- util::success($data);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
//最近联系人 ssh 2019.12.29
|
|
|
public function actionRecentlyUser()
|
|
|
{
|