|
@@ -15,8 +15,10 @@ use App\Model\RoomAnswer;
|
|
|
use App\Model\RoomQuestion;
|
|
|
use App\Jobs\Distribute;
|
|
|
use GuzzleHttp\Client;
|
|
|
+use GuzzleHttp\Cookie\CookieJar;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
use GatewayWorker\Lib\Gateway;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class Settlement implements ShouldQueue
|
|
|
{
|
|
@@ -86,16 +88,71 @@ class Settlement implements ShouldQueue
|
|
|
])->get();
|
|
|
$winer = '';
|
|
|
$winer_score = 0;
|
|
|
+ $pkresult = [];
|
|
|
foreach ($players as $k => $player) {
|
|
|
if($player->score > $winer_score){
|
|
|
$winer = $player->user_id;
|
|
|
$winer_score = $player->score;
|
|
|
}
|
|
|
+ $user = User::select("user_id", "cmcc_id", "mt", "is_robot")->where("user_id", $player->user_id)->first();
|
|
|
+ if($user->is_robot != 1){
|
|
|
+ $mt = $user->mt;
|
|
|
+ $cmcc_id = $user->cmcc_id;
|
|
|
+ }
|
|
|
+ $pkresult[] = [
|
|
|
+ "robot_flag" => $user->is_robot,
|
|
|
+ "user_id" => $user->cmcc_id,
|
|
|
+ "score" => $player->score,
|
|
|
+ ];
|
|
|
}
|
|
|
- //通知卓望平台跟用户端
|
|
|
+ //通知平台
|
|
|
+ $user_power = [];
|
|
|
+ if($mt){
|
|
|
+ //上传用户游戏信息
|
|
|
+ $client = new Client([
|
|
|
+ 'verify' => false,
|
|
|
+ ]);
|
|
|
+ $ip = '211.139.191.175';
|
|
|
+ $port = '38083';
|
|
|
+ $req_time = date('YmdHis');
|
|
|
+ $sign = md5($cmcc_id . $req_time . $mt);
|
|
|
+ $params['req_param'] = [
|
|
|
+ "pub_info" => [
|
|
|
+ "req_src" => "1",
|
|
|
+ "ver" => "1.0",
|
|
|
+ "mt" => $mt,
|
|
|
+ "user_id" => $cmcc_id,
|
|
|
+ "req_time" => $req_time,
|
|
|
+ "sign" => $sign,
|
|
|
+ ],
|
|
|
+ "page_info" => [
|
|
|
+ // "current_page" => 1,
|
|
|
+ // "page_size" => 10,
|
|
|
+ ],
|
|
|
+ "busi_info" => [
|
|
|
+ "pk_result" => $pktaskresult
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ Log::info("通知平台放请求信息: \n ". json_encode($params) ."\n");
|
|
|
+
|
|
|
+ $result = $client->request('POST', "http://{$ip}:{$port}/hgs/uc/pktaskresult",[
|
|
|
+ 'json' => $params
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if($result->getStatusCode() == 200){
|
|
|
+ $cmcc_result = json_decode($result->getBody()->getContents());
|
|
|
+ if($cmcc_user->rsp_param->pub_info->code == "0000"){
|
|
|
+ $user_power = $cmcc_result->rsp_param->busi_info->user_power;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::info("平台返回信息: \n ". json_encode($cmcc_result) ."\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ //给用户发送信息
|
|
|
foreach ($players as $k => $player) {
|
|
|
$is_win = 0;
|
|
|
- //获取用户令牌
|
|
|
$user = User::where("user_id", $player->user_id)->first();
|
|
|
if($winer == $player->user_id){
|
|
|
//更新胜利局数
|
|
@@ -115,42 +172,19 @@ class Settlement implements ShouldQueue
|
|
|
"room_id" => $this->room_id,
|
|
|
])->update($update_data);
|
|
|
|
|
|
- //非机器人上传游戏得分
|
|
|
- if($user->is_robot != 1){
|
|
|
- $client = new Client([
|
|
|
- 'verify' => false,
|
|
|
- ]);
|
|
|
- $ip = '211.139.191.175';
|
|
|
- $port = '38083';
|
|
|
- $req_time = date('YmdHis');
|
|
|
- $sign = md5($user->cmcc_id . $req_time . $user->mt);
|
|
|
- $params['req_param'] = [
|
|
|
- "pub_info" => [
|
|
|
- "req_src" => 1,
|
|
|
- "ver" => "1.0",
|
|
|
- "req_time" => $req_time,
|
|
|
- "sign" => $sign,
|
|
|
- ],
|
|
|
- "page_info" => [
|
|
|
- "current_page" => 1,
|
|
|
- "page_size" => 10,
|
|
|
- ],
|
|
|
- "busi_info" => [],
|
|
|
- ];
|
|
|
- // $response = $client->request('POST', "http://{$ip}:{$port}/hgs/biz/pktaskresult",[
|
|
|
- // 'form_params' => [
|
|
|
- // 'username' => $user->name,
|
|
|
- // ]
|
|
|
- // ]);
|
|
|
- // $result = $response->getBody()->getContents();
|
|
|
- }
|
|
|
-
|
|
|
- //测试固定用户信息
|
|
|
+ //用户信息
|
|
|
$info['user_id'] = $user->user_id;
|
|
|
$info['name'] = $user->name;
|
|
|
$info['avatar'] = $user->avatar;
|
|
|
$info['is_win'] = $is_win;
|
|
|
- $info['play_next'] = 1;
|
|
|
+ $info['play_next'] = 0;
|
|
|
+ $info['power_change'] = 0;
|
|
|
+ foreach ($user_power as $k => $up) {
|
|
|
+ if(isset($up->user_id) && $up->user_id == $user->cmcc_id){
|
|
|
+ $info['play_next'] = $up->play_next;
|
|
|
+ $info['power_change'] = $up->power_change;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//获取用户星力变化等信息返回
|
|
|
$message['info'] = $info;
|
|
@@ -158,8 +192,6 @@ class Settlement implements ShouldQueue
|
|
|
$message['winer_score'] = $winer_score;
|
|
|
$message['type'] = 'game_end';
|
|
|
Gateway::sendToUid($user->user_id, json_encode($message));
|
|
|
- //结束当前房间
|
|
|
- // Gateway::ungroup($this->room_id);
|
|
|
}
|
|
|
}else{
|
|
|
sleep(3);
|