Эх сурвалжийг харах

ws socket连接,通知到账方法

林琦海 5 жил өмнө
parent
commit
ab20e779d6

+ 27 - 0
app/ghs/controllers/WsController.php

@@ -0,0 +1,27 @@
+<?php
+
+// websocket相关
+namespace ghs\controllers;
+
+use Yii;
+use GatewayClient\Gateway;
+class WsController extends BaseController
+{
+
+    //绑定用户
+    public function actionBind()
+    {
+        $post = Yii::$app->request->post();
+        $clientId = isset($post['clientId']) ? $post['clientId'] : '';
+        $adminId = $this->adminId;
+        Gateway::bindUid($clientId, $adminId);
+    }
+
+    //关闭当前链接
+    public function actionClose()
+    {
+        $post = Yii::$app->request->post();
+        $clientId = isset($post['clientId']) ? $post['clientId'] : '';
+        Gateway::closeClient($clientId);
+    }
+}

+ 16 - 0
biz-ghs/ws/services/WsService.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace bizGhs\ws\services;
+
+use GatewayClient\Gateway;
+class WsService
+{
+    //到账通知
+    public static function arrivalNotice($adminId,$money)
+    {
+        $msg = '微信到账'.$money;
+        $data = ['type' => 'money', 'msg' => $msg,'money'=>$money];
+        Gateway::sendToUid($adminId, json_encode($data));
+        return true;
+    }
+}

+ 5 - 0
sql.sql

@@ -1070,3 +1070,8 @@ ALTER TABLE xhCustom ADD `visitTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00
 ALTER TABLE `xhGhsProduct`
 ADD COLUMN `priceLabel`  tinyint(2) UNSIGNED NOT NULL DEFAULT 1 COMMENT '价格标识(price): 1 自动调价,2改价' AFTER `price`;
 
+======
+==linqh 2021.2.2
+ALTER TABLE `xhGhsStockRecord`
+MODIFY COLUMN `itemNum`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '花材数量' AFTER `itemId`;
+