|
@@ -51,16 +51,31 @@ class Settlement implements ShouldQueue
|
|
|
$room_question_count = RoomQuestion::where("room_id", $this->room_id)->count();
|
|
|
//注册gateway地址
|
|
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
|
|
- //进行结算
|
|
|
- if($room_question_count > 4){
|
|
|
+ //结算当前局
|
|
|
+ $update_data["end_at"] = date("Y-m-d H:i:s");
|
|
|
+ RoomQuestion::where([
|
|
|
+ "room_id" => $this->room_id,
|
|
|
+ "question_id" => $question_id,
|
|
|
+ ])->update($update_data);
|
|
|
|
|
|
- //结算当前局
|
|
|
- $update_data["end_at"] = date("Y-m-d H:i:s");
|
|
|
- RoomQuestion::where([
|
|
|
- "room_id" => $this->room_id,
|
|
|
- "question_id" => $question_id,
|
|
|
- ])->update($update_data);
|
|
|
+ //返回各个用户回答的问题
|
|
|
+ $group_users = Gateway::getUidListByGroup($this->room_id);
|
|
|
+ $anwsers = RoomAnswer::select('user_id', 'option_id', 'question_id')->where([
|
|
|
+ "question_id" => $question_id,
|
|
|
+ "room_id" => $this->room_id,
|
|
|
+ ])->whereIn("user_id", array_values($group_users))->get();
|
|
|
+ $option_id = Option::where([
|
|
|
+ "question_id" => $question_id,
|
|
|
+ "is_answer" => 1,
|
|
|
+ ])->value("option_id");
|
|
|
+ $info['anwser'] = $option_id;
|
|
|
+ $info['players_answer'] = $anwsers;
|
|
|
+ //发送回合结算信息
|
|
|
+ $message['info'] = $info;
|
|
|
+ $message['type'] = 'round_end';
|
|
|
+ Gateway::sendToGroup($this->room_id, json_encode($message));
|
|
|
|
|
|
+ if($room_question_count > 4){
|
|
|
//当前房间结束
|
|
|
$update_data["is_end"] = 1;
|
|
|
$update_data["end_at"] = date("Y-m-d H:i:s");
|
|
@@ -146,32 +161,7 @@ class Settlement implements ShouldQueue
|
|
|
//结束当前房间
|
|
|
Gateway::ungroup($this->room_id);
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
-
|
|
|
- //结算当前局
|
|
|
- $update_data["end_at"] = date("Y-m-d H:i:s");
|
|
|
- RoomQuestion::where([
|
|
|
- "room_id" => $this->room_id,
|
|
|
- "question_id" => $question_id,
|
|
|
- ])->update($update_data);
|
|
|
-
|
|
|
- //返回各个用户回答的问题
|
|
|
- $group_users = Gateway::getUidListByGroup($this->room_id);
|
|
|
- $anwsers = RoomAnswer::select('user_id', 'option_id', 'question_id')->where([
|
|
|
- "question_id" => $question_id,
|
|
|
- "room_id" => $this->room_id,
|
|
|
- ])->whereIn("user_id", array_values($group_users))->get();
|
|
|
- $option_id = Option::where([
|
|
|
- "question_id" => $question_id,
|
|
|
- "is_answer" => 1,
|
|
|
- ])->value("option_id");
|
|
|
- $info['anwser'] = $option_id;
|
|
|
- $info['players_answer'] = $anwsers;
|
|
|
- //发送回合结算信息
|
|
|
- $message['info'] = $info;
|
|
|
- $message['type'] = 'round_end';
|
|
|
- Gateway::sendToGroup($this->room_id, json_encode($message));
|
|
|
sleep(3);
|
|
|
//执行发题
|
|
|
Distribute::dispatch($this->room_id)->onQueue('distribute');
|