123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <?php
- namespace App\Console\Commands\Upgrade;
- use App\Models\Deed\FriendsModel;
- use App\Models\Gteam\RoomMemberModel;
- use App\Models\Gteam\RoomModel;
- use App\Services\Deed\FriendService;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- class V20190227Command extends Command
- {
- protected $signature = "upgrade:v20190227";
- protected $description = "版本升级脚本|2019-02-27号更新版本升级\n
- 更新内容:\n
- 1. 72小时匹配历史同步到好友列表\n
- 2. 晚安匹配历史同步到好友列表\n
- 3. 开黑匹配历史同步到好友列表\n
- 4. 邀请历史到好友\n";
- public function handle()
- {
- $this->gteam2friend();
- $this->goodnight2friend();
- $this->hour2friend();
- $this->invite2friend();
- }
- // 开黑到好友
- public function gteam2friend()
- {
- dump("开黑到好友:开始启动");
- $start = 13925;
- $descroom = DB::table('kdgx_gteam_room')->where('id', '>=', $start)->orderBy('id', 'desc')->first();
- for ($i = $start; $i <= $descroom->id; $i++) {
- try {
- $room = RoomModel::findOrFail($i);
- $members = RoomMemberModel::where('room_id', $room->id)->get();
- if ($descroom->type == "wz_wx" || $descroom->type == "wz_qq") {
- $friend_type = 5;
- } else {
- $friend_type = 4;
- }
- $friend1 = FriendsModel::firstOrCreate([
- 'uid' => $members[0]->uid,
- 'friend_uid' => $members[1]->uid
- ], [
- 'created_at' => $room->created_at->timestamp,
- 'uid' => $members[0]->uid,
- 'friend_uid' => $members[1]->uid,
- 'last_at' => $room->created_at->timestamp,
- 'friend_type' => $friend_type,
- 'friend_type_data' => $i
- ]);
- if ($friend1->last_at < $room->created_at->timestamp) {
- $friend1->last_at = $room->created_at->timestamp;
- $friend1->friend_type = $friend_type;
- $friend1->friend_type_data = $i;
- $friend1->save();
- }
- $friend2 = FriendsModel::firstOrCreate([
- 'uid' => $members[1]->uid,
- 'friend_uid' => $members[0]->uid
- ], [
- 'created_at' => $room->created_at->timestamp,
- 'uid' => $members[1]->uid,
- 'friend_uid' => $members[0]->uid,
- 'last_at' => $room->created_at->timestamp,
- 'friend_type' => $friend_type,
- 'friend_type_data' => $i
- ]);
- if ($friend2->last_at < $room->created_at->timestamp) {
- $friend2->last_at = $room->created_at->timestamp;
- $friend2->friend_type = $friend_type;
- $friend2->friend_type_data = $i;
- $friend2->save();
- }
- } catch (\Exception $exception) {
- }
- }
- dump("开黑到好友:结束,目前进度:{$descroom->id}");
- }
- // 晚安匹配到好友
- public function goodnight2friend()
- {
- dump("晚安匹配到好友:开始启动");
- $start = 3881;
- $descroom = DB::table('kdgx_goodnight_rooms')->where('id', '>=', $start)->orderBy('id', 'desc')->first();
- for ($i = $start; $i <= $descroom->id; $i++) {
- try {
- $room = \App\Models\Goodnight\RoomModel::findOrFail($i);
- $members = \App\Models\Goodnight\RoomMemberModel::where('room_id', $room->id)->get();
- $friend1 = FriendsModel::firstOrCreate([
- 'uid' => $members[0]->uid,
- 'friend_uid' => $members[1]->uid
- ], [
- 'created_at' => $room->created_at->timestamp,
- 'uid' => $members[0]->uid,
- 'friend_uid' => $members[1]->uid,
- 'last_at' => $room->created_at->timestamp,
- 'friend_type' => 3,
- 'friend_type_data' => $i
- ]);
- if ($friend1->last_at < $room->created_at->timestamp) {
- $friend1->last_at = $room->created_at->timestamp;
- $friend1->friend_type = 3;
- $friend1->friend_type_data = $i;
- $friend1->save();
- }
- $friend2 = FriendsModel::firstOrCreate([
- 'uid' => $members[1]->uid,
- 'friend_uid' => $members[0]->uid
- ], [
- 'created_at' => $room->created_at->timestamp,
- 'uid' => $members[1]->uid,
- 'friend_uid' => $members[0]->uid,
- 'last_at' => $room->created_at->timestamp,
- 'friend_type' => 3,
- 'friend_type_data' => $i
- ]);
- if ($friend2->last_at < $room->created_at->timestamp) {
- $friend2->last_at = $room->created_at->timestamp;
- $friend2->friend_type = 3;
- $friend2->friend_type_data = $i;
- $friend2->save();
- }
- } catch (\Exception $exception) {
- }
- }
- dump("晚安匹配到好友:结束,目前进度:{$descroom->id}");
- }
- // 72小时活动到好友
- public function hour2friend()
- {
- dump("72小时活动到好友:开始启动");
- $start = 256576;
- $descroom = \App\Models\Fpdx\RoomModel::where('room_id', '>=', $start)->where('type', 1)->orderBy(
- 'room_id',
- 'desc'
- )->first();
- for ($i = $start; $i <= $descroom->room_id; $i++) {
- try {
- $room = \App\Models\Fpdx\RoomModel::where([['type', 1], ['room_id', $i]])->first();
- $members = $room->member;
- $friend1 = FriendsModel::firstOrCreate([
- 'uid' => $members[0],
- 'friend_uid' => $members[1]
- ], [
- 'created_at' => $room->create_time,
- 'uid' => $members[0],
- 'friend_uid' => $members[1],
- 'last_at' => $room->create_time,
- 'friend_type' => 2,
- 'friend_type_data' => $i
- ]);
- if ($friend1->last_at < $room->create_time) {
- $friend1->last_at = $room->create_time;
- $friend1->friend_type = 2;
- $friend1->friend_type_data = $i;
- $friend1->save();
- }
- $friend2 = FriendsModel::firstOrCreate([
- 'uid' => $members[1],
- 'friend_uid' => $members[0]
- ], [
- 'created_at' => $room->create_time,
- 'uid' => $members[1],
- 'friend_uid' => $members[0],
- 'last_at' => $room->create_time,
- 'friend_type' => 2,
- 'friend_type_data' => $i
- ]);
- if ($friend2->last_at < $room->create_time) {
- $friend2->last_at = $room->create_time;
- $friend2->friend_type = 2;
- $friend2->friend_type_data = $i;
- $friend2->save();
- }
- } catch (\Exception $exception) {
- }
- }
- dump("72小时活动到好友:结束,目前进度:{$descroom->room_id}");
- }
- // 邀请到好友
- public function invite2friend()
- {
- dump("邀请到好友:开始启动");
- $start = 220284;
- $datas = DB::table('kdgx_fpdx_invitation_card')->where('id', '>', $start)->where('state', 1)->get();
- $fs = new FriendService();
- foreach ($datas as $data) {
- $friend1 = FriendsModel::firstOrCreate([
- 'uid' => $data->uid,
- 'friend_uid' => $data->invite_uid
- ], [
- 'created_at' => $data->created_at,
- 'uid' => $data->uid,
- 'friend_uid' => $data->invite_uid,
- 'last_at' => $data->created_at,
- 'friend_type' => 1,
- 'friend_type_data' => $data->id
- ]);
- if ($friend1->last_at < $data->created_at) {
- $friend1->last_at = $data->created_at;
- $friend1->friend_type = 1;
- $friend1->friend_type_data = $data->id;
- $friend1->save();
- }
- $friend2 = FriendsModel::firstOrCreate([
- 'uid' => $data->invite_uid,
- 'friend_uid' => $data->uid
- ], [
- 'created_at' => $data->created_at,
- 'uid' => $data->invite_uid,
- 'friend_uid' => $data->uid,
- 'last_at' => $data->created_at,
- 'friend_type' => 6,
- 'friend_type_data' => $data->id
- ]);
- if ($friend2->last_at < $data->created_at) {
- $friend2->last_at = $data->created_at;
- $friend2->friend_type = 6;
- $friend2->friend_type_data = $data->id;
- $friend2->save();
- }
- }
- dump("邀请到好友:结束,目前进度:{$data->id}");
- }
- }
|