Переглянути джерело

开始聊天的头像信息

shish 6 роки тому
батько
коміт
d9541c3ea7

+ 1 - 1
app/business/controllers/BaseController.php

@@ -55,7 +55,7 @@ class BaseController extends PublicController
 		if (empty($merchantId)) {
 			util::fail('没有找到商家信息');
 		}
-		$merchant = MerchantService::getById($merchantId);
+		$merchant = MerchantService::getMerchantById($merchantId);
 		$merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
 		$merchantAsset = MerchantAssetService::getByMerchantId($merchantId);
 		$this->admin = $admin;

+ 12 - 3
app/business/controllers/ChatController.php

@@ -13,7 +13,7 @@ use GatewayClient\Gateway;
 
 class ChatController extends BaseController
 {
-	
+
 	//聊天 shish 2019.12.28
 	public function actionIndex()
 	{
@@ -23,7 +23,16 @@ class ChatController extends BaseController
 		UserService::valid($user, $this->merchantId);
 		return $this->renderPartial('index', ['userId' => $userId]);
 	}
-	
+
+	//聊天双方的用户信息 shish 2019.12.30
+	public function actionBegin()
+	{
+		$id = Yii::$app->request->get('id', 0);
+		$user = UserService::getUserInfo($id);
+		UserService::valid($user, $this->merchantId);
+		util::success(['merchant'=>$this->merchant,'user'=>$user]);
+	}
+
 	//绑定 shish 2019.12.28
 	public function actionBindMerchant()
 	{
@@ -40,7 +49,7 @@ class ChatController extends BaseController
 			Gateway::sendToUid($consoleId, json_encode($data));
 		}
 	}
-
+	
 	//关闭当前链接
 	public function actionClose()
 	{

+ 5 - 5
app/client/controllers/BaseController.php

@@ -30,14 +30,14 @@ class BaseController extends PublicController
 		//token验证
 		//$userId = jwt::getLoginId();
 		$userId = 12536630;
-
+		
 		$header = httpUtil::getHeader();
 		$account = isset($header['account']) ? $header['account'] : 0;
 		$account = 12358;
 		if (empty($account)) {
 			util::fail('商家无效');
 		}
-		$merchant = MerchantService::getById($account);
+		$merchant = MerchantService::getMerchantById($account);
 		if (empty($merchant)) {
 			util::fail('商家信息无效');
 		}
@@ -48,13 +48,13 @@ class BaseController extends PublicController
 		Yii::$app->params['merchant'] = $merchant;
 		Yii::$app->params['userId'] = $userId;
 		$this->isWeixin = util::isWeixin();
-
+		
 		if (empty($userId)) {
 			$this->validate = false;
 		} else {
 			$this->validate = true;
 			$this->userId = $userId;
-			$this->user = UserService::getById($userId);
+			$this->user = UserService::getUserInfo($userId);
 		}
 		//游客可以访问的方法
 		if (in_array($action->id, $this->withoutLogin)) {
@@ -65,5 +65,5 @@ class BaseController extends PublicController
 		}
 		return parent::beforeAction($action);
 	}
-
+	
 }

+ 7 - 6
app/client/controllers/ChatController.php

@@ -12,12 +12,7 @@ use GatewayClient\Gateway;
 
 class ChatController extends BaseController
 {
-	
-	public function beforeAction($action)
-	{
-		return parent::beforeAction($action);
-	}
-	
+
 	//聊天首页,前端使用
 	public function actionIndex()
 	{
@@ -33,6 +28,12 @@ class ChatController extends BaseController
 		Gateway::bindUid($clientId, $userId);
 	}
 	
+	//聊天双方的用户信息 shish 2019.12.30
+	public function actionBegin()
+	{
+		util::success(['merchant'=>$this->merchant,'user'=>$this->user]);
+	}
+	
 	//发消息给老板 shish 2019.12.28
 	public function actionSend()
 	{

+ 20 - 1
biz/merchant/classes/MerchantClass.php

@@ -2,6 +2,7 @@
 
 namespace biz\merchant\classes;
 
+use common\components\business;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -16,7 +17,7 @@ class MerchantClass extends BaseClass
 		2 => ['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
 		3 => ['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
 	];
-
+	
 	//商家信息组合 shish 2019.12.20
 	public static function groupMerchantBaseInfo($list)
 	{
@@ -27,5 +28,23 @@ class MerchantClass extends BaseClass
 	{
 		return self::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
 	}
+
+	public static function getMerchantById($id)
+	{
+		$merchant = self::getById($id);
+		if (empty($merchant)) {
+			return $merchant;
+		}
+		$list = self::groupBaseInfo([$merchant]);
+		return current($list);
+	}
+
+	public static function groupBaseInfo($list)
+	{
+		foreach ($list as $key => $val) {
+			$list[$key] = business::formatMerchantLogo($list[$key]);
+		}
+		return $list;
+	}
 	
 }

+ 6 - 0
biz/merchant/services/MerchantService.php

@@ -120,4 +120,10 @@ class MerchantService extends BaseService
 		return MerchantClass::getMerchantByIds($ids);
 	}
 	
+	//获取商家 shish 2019.12.30
+	public static function getMerchantById($id)
+	{
+		return MerchantClass::getMerchantById($id);
+	}
+	
 }