lizhen_gitee 1 anno fa
parent
commit
e4b1d405bd

+ 5 - 26
application/api/controller/Party.php

@@ -13,6 +13,7 @@ use think\exception\PDOException;
 use think\exception\ValidateException;
 use think\Request;
 use app\common\service\RoomService;
+use app\common\library\GatewayworkerTools;
 
 /**
  * 派对信息接口
@@ -1707,7 +1708,7 @@ class Party extends Common
 
                 $data["createtime"] = time();
                 $res5 = $giftuserpartyModel->allowField(true)->save($data);
-                //$this->bigGiftNotice($giftuserpartyModel);
+                $this->bigGiftNotice($giftuserpartyModel);
 
                 // 添加赠送用户余额
                 if($getValue > 0){
@@ -1876,34 +1877,12 @@ class Party extends Common
         if ($giftUserParty->party_id > 0) {
 
             $bigGiftNotice = config("site.bigGiftNotice");
-            $partyInfo = $giftUserParty->party;
             $money = $giftUserParty->value;
 
-
             if ($money >= $bigGiftNotice) {
-
-                $messageData = [
-                    'type'    => 'bigGiftNotice',
-                    'data' => [
-                        'party_info'  => [
-                            'party_id'   => $partyInfo['id'],
-                            'room_type'  => $partyInfo['room_type'],
-                            'party_name' => $partyInfo['party_name']
-                        ],
-                        'notice_info' => [
-                            'sender'         => $giftUserParty->user->nickname,
-                            'receiver'       => $giftUserParty->toUser->nickname,
-                            'gift_num'       => $giftUserParty['number'],
-                            'gift_name'      => $giftUserParty['gift_name'],
-                            'gift_image'     => $giftUserParty['gift_gif_image'],
-                            'value'          => $giftUserParty['value'],
-                        ]
-                    ]
-                ];
-
-
-
-
+                $partyInfo = $giftUserParty->party;
+                $notice = new GatewayworkerTools();
+                $notice->sendBigGiftInParty($giftUserParty->user->nickname,$giftUserParty->toUser->nickname,$partyInfo,$giftUserParty);
             }
         }
     }

+ 19 - 35
application/common/library/Gatewayworker.php

@@ -2,57 +2,41 @@
 
 namespace app\common\library;
 
-use think\Request;
-use GatewayClient\Gateway;
-
-require_once VENDOR_PATH . 'workerman/gatewayclient/Gateway.php';
+use \GatewayClient\Gateway;
 
 /**
  * gateway绑定接口
  */
-class Gatewayworker
+class GatewayworkerTools
 {
-    public function __construct(Request $request = null)
-    {
-        parent::__construct($request);
-        $params_from = $this->request->request('params_from'); // 客户端
-        if ($params_from == "wxmin") {
-            Gateway::$registerAddress = "127.0.0.1:1239";
-        } else {
-            Gateway::$registerAddress = "127.0.0.1:1238";
-        }
-
-    }
-
 
     /**
      * 直播间中发送大礼物,全服通告
      */
     public static function sendBigGiftInParty($sender, $receiver, $partyInfo, $giftUserParty)
     {
-        $aData = [
-            'code' => 'party',
+        $messageData = [
+            'type'    => 'bigGiftNotice',
             'data' => [
-                'cmd'     => 'send_big_gift_in_party',
-                'content' => [
-                    'party_info'  => [
-                        'party_id'   => $partyInfo['id'],
-                        'room_type'  => $partyInfo['room_type'],
-                        'party_name' => $partyInfo['party_name']
-                    ],
-                    'notice_info' => [
-                        'sender'     => $sender,
-                        'receiver'   => $receiver,
-                        'gift_num'   => $giftUserParty['number'],
-                        'gift_name'  => $giftUserParty['gift_name'],
-                        'gift_image' => $giftUserParty['gift_gif_image']
-                    ]
+                'party_info'  => [
+                    'party_id'   => $partyInfo['id'],
+                    'room_type'  => $partyInfo['room_type'],
+                    'party_name' => $partyInfo['party_name']
+                ],
+                'notice_info' => [
+                    'sender'         => $sender,
+                    'receiver'       => $receiver,
+                    'gift_num'       => $giftUserParty['number'],
+                    'gift_name'      => $giftUserParty['gift_name'],
+                    'gift_image'     => $giftUserParty['gift_gif_image'],
+                    'value'          => $giftUserParty['value'],
                 ]
             ]
         ];
 
-        dump($aData);
-        Gateway::sendToAll(json_encode($aData));
+        $Gateway = new Gateway();
+        $Gateway::$registerAddress = '127.0.0.1:2345';
+        $Gateway::sendToAll(json_encode($messageData));
     }
 
     /**