Browse Source

零售端ws

林琦海 5 years ago
parent
commit
6939372497
1 changed files with 40 additions and 0 deletions
  1. 40 0
      app-hd/controllers/WsController.php

+ 40 - 0
app-hd/controllers/WsController.php

@@ -0,0 +1,40 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/5/8 20:26
+ */
+
+namespace hd\controllers;
+
+use bizGhs\ws\services\WsService;
+use common\components\util;
+use Yii;
+use GatewayClient\Gateway;
+class WsController extends BaseController
+{
+
+    //绑定用户
+    public function actionBind()
+    {
+        $post = Yii::$app->request->post();
+        $clientId = isset($post['clientId']) ? $post['clientId'] : '';
+        $shopAdminId = $this->shopAdminId;
+        Gateway::bindUid($clientId, $shopAdminId);
+        util::complete();
+    }
+
+    //关闭当前链接
+    public function actionClose()
+    {
+        $post = Yii::$app->request->post();
+        $clientId = isset($post['clientId']) ? $post['clientId'] : '';
+        Gateway::closeClient($clientId);
+    }
+
+    //模拟推送ws (仅供测试联调用)
+    public function actionSend()
+    {
+        WsService::arrivalNotice($this->shopAdminId,9866.29);
+        util::complete();
+    }
+}