shish 6 年 前
コミット
4c961b8ed6

+ 25 - 0
app/business/controllers/ApplyController.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace business\controllers;
+
+use biz\saas\services\ApplyService;
+use Yii;
+use common\components\util;
+
+class ApplyController extends BaseController
+{
+
+	//我的代理 shish 2019.12.26
+	public function actionList()
+	{
+		$status = Yii::$app->request->get('status', 0);
+		$where = [];
+		$where['oldId'] = $this->merchantId;
+		if ($status != -1) {
+			$where['status'] = $status;
+		}
+		$data = ApplyService::getApplyList($where);
+		util::success($data);
+	}
+
+}

+ 52 - 0
app/business/controllers/MainController.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace business\controllers;
+
+use common\components\stringUtil;
+use common\components\util;
+use Yii;
+use GatewayClient\Gateway;
+
+class MainController extends BaseController
+{
+	
+	public function actionDemo()
+	{
+		return $this->renderPartial('demo');
+	}
+
+	public function actionBind()
+	{
+		//加载GatewayClient。安装GatewayClient参见本页面底部介绍
+		require_once '/your/path/GatewayClient/Gateway.php';
+		// GatewayClient 3.0.0版本开始要使用命名空间
+		
+		
+		// 设置GatewayWorker服务的Register服务ip和端口,请根据实际情况改成实际值
+		Gateway::$registerAddress = '127.0.0.1:1236';
+		
+		// 假设用户已经登录,用户uid和群组id在session中
+		$uid = $_SESSION['uid'];
+		$group_id = $_SESSION['group'];
+		// client_id与uid绑定
+		Gateway::bindUid($client_id, $uid);
+		// 加入某个群组(可调用多次加入多个群组)
+		Gateway::joinGroup($client_id, $group_id);
+	}
+
+	public function actionSend()
+	{
+		//加载GatewayClient。安装GatewayClient参见本页面底部介绍
+		require_once '/your/path/GatewayClient/Gateway.php';
+		// GatewayClient 3.0.0版本开始要使用命名空间
+		
+		// 设置GatewayWorker服务的Register服务ip和端口,请根据实际情况改成实际值
+		Gateway::$registerAddress = '127.0.0.1:1236';
+		
+		// 向任意uid的网站页面发送数据
+		Gateway::sendToUid($uid, $message);
+		// 向任意群组的网站页面发送数据
+		Gateway::sendToGroup($group, $message);
+	}
+	
+}

+ 27 - 0
app/business/views/main/demo.php

@@ -0,0 +1,27 @@
+<script>
+
+    /**
+     * 与GatewayWorker建立websocket连接,域名和端口改为你实际的域名端口,
+     * 其中端口为Gateway端口,即start_gateway.php指定的端口。
+     * start_gateway.php 中需要指定websocket协议,像这样
+     * $gateway = new Gateway(websocket://0.0.0.0:7272);
+     */
+    ws = new WebSocket("ws://192.168.204.128:8282");
+    // 服务端主动推送消息时会触发这里的onmessage
+    ws.onmessage = function(e){
+        // json数据转换成js对象
+        var data = eval("("+e.data+")");
+        var type = data.type || '';
+        switch(type){
+            // Events.php中返回的init类型的消息,将client_id发给后台进行uid绑定
+            case 'init':
+                // 利用jquery发起ajax请求,将client_id发给后端进行uid绑定
+                $.post('./bind.php', {client_id: data.client_id}, function(data){}, 'json');
+                break;
+            // 当mvc框架调用GatewayClient发消息时直接alert出来
+            default :
+                alert(e.data);
+        }
+    };
+	
+</script>

+ 4 - 4
biz/saas/services/ApplyService.php

@@ -33,16 +33,16 @@ class ApplyService extends BaseService
 		if (!empty($idList)) {
 			$merchant = MerchantService::getMerchantByIds($idList);
 		}
-		
+
 		foreach ($list as $key => $val) {
 			$userId = $val['userId'];
 			$oldId = $val['oldId'];
 			$list[$key]['userName'] = isset($user[$userId]) ? $user[$userId]['userName'] : '';
+			$list[$key]['userAvatar'] = isset($user[$userId]['avatarUrl']) ? $user[$userId]['avatarUrl'] : '';
 			$list[$key]['oldName'] = isset($merchant[$oldId]['merchantName']) ? $merchant[$oldId]['merchantName'] : '';
 		}
 		$data['list'] = $list;
 		return $data;
-		
 	}
 	
 	//审核通过
@@ -64,10 +64,10 @@ class ApplyService extends BaseService
 		}
 		$oldId = isset($data['oldId']) ? $data['oldId'] : 0;
 		//有人邀请
-		if(!empty($oldId)){
+		if (!empty($oldId)) {
 		
 		}
 		ApplyClass::add($data);
 	}
-
+	
 }

+ 1 - 0
biz/user/classes/UserClass.php

@@ -429,6 +429,7 @@ class UserClass extends BaseClass
 		$imgUrl = Yii::$app->params['imgUrl'];
 		foreach ($info as $userId => $user) {
 			$info[$userId]['avatar'] = !empty($user['avatar']) ? $imgUrl . $user['avatar'] : '';
+			$info[$userId]['avatarUrl'] = !empty($user['avatar']) ? $imgUrl . $user['avatar'] : '';
 		}
 		return $info;
 	}

+ 1 - 0
sql.txt

@@ -1,5 +1,6 @@
 2019.12.25 shish 员工备注
 ALTER TABLE `xhAdmin` ADD remark VARCHAR(500) NOT NULL DEFAULT '' COMMENT '员工备注' AFTER `remind`;
+ALTER TABLE `xhApply` MODIFY `userId` INT NOT NULL DEFAULT 0 COMMENT '邀请花店的用户id,没有邀请花店,刚是平台花卉宝的用户';
 
 2019.12.24
 DROP TABLE IF EXISTS `xhRenew`;