Commit c7c55077 authored by 顾敏's avatar 顾敏

服务器名字里去掉渠道

parent 843c7b77
......@@ -15,6 +15,7 @@ use App\Models\BaseItem;
use App\Models\WxUserImg;
use App\Services\UploadServer;
use App\Models\User;
use Illuminate\Support\Optional;
class CardController extends Controller
{
......@@ -74,21 +75,25 @@ class CardController extends Controller
$userId = $request->session()->get("uid");
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if(Cache::has($userId.':card:bind:role')) return $this->jsonReturn(10022, '绑定角色过于频繁,请稍后再试');
$roleId = $request->input('roleId');
$serverId = $request->input('serverId');
$serverName = $request->input('serverName');
if (empty($roleId) || empty($serverId) || empty($serverName)) return $this->jsonReturn(7002, '参数错误');
$lock = Cache::lock("card:bind:role:" . $userId, 30);
if (!$lock->get()) {
return $this->jsonReturn(10022, '绑定角色过于频繁,请稍后再试');
}
$tableName = 'wx_card_role_'.$serverId;
$this->getCheckRoleInfoTable($tableName);
$verity = DB::connection('wx_mysql')->table($tableName)->where('uid',$userId)->where('role_id',$roleId)->select('id')->first();
if($verity) return $this->jsonReturn(0, '角色绑定成功');
Cache::put($userId.':card:bind:role',1,30);
$insert = $this->getInsertRoleInfo($userId,$roleId,$serverId,$serverName,$tableName);
optional($lock)->release();
if($insert['code'] == 200) return $this->jsonReturn(0, '角色绑定成功');
Cache::forget($userId.':card:bind:role');
return $this->jsonReturn($insert['code'], $insert['msg']);
}
......@@ -349,15 +354,13 @@ class CardController extends Controller
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if (empty($roleId) || empty($serverId)) return $this->jsonReturn(7002, '参数错误');
if (!Schema::connection('wx_mysql')->hasTable('wx_card_role_'.$serverId)) return redirect(route('index'));
// if (!Schema::connection('wx_mysql')->hasTable('wx_card_role_'.$serverId)) return redirect(route('index'));
$info = DB::connection('wx_mysql')->table('wx_card_role_'.$serverId)->where('uid',$userId)->where('role_id',$roleId)->where('server_id',$serverId)->first();
if(!$info) return redirect(route('index'));
$serverName = $info->server_name;
$splitIndex = strpos($info->server_name, "-");
if ($splitIndex !== false) {
$serverName = substr($info->server_name, $splitIndex + 1);
}
$filterElems = ['越狱', 'IOS', 'mg77', '抖音', '硬核', '非硬核', 'zy', '915转移', '转移', '小米', '百度'];
$nameElems = explode($info->server_name, "-");
$serverName = implode("-", array_diff($nameElems, $filterElems));
$user = User::where('uid',$userId)->select('uid','account')->first();
$data['userName'] = $user->account ?? '';
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GameUserPvp extends Model
{
protected $connection = 'wx_mysql';
protected $table = 'game_user_pvp';
}
\ No newline at end of file
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GameUserPvpCount extends Model
{
protected $connection = 'wx_mysql';
protected $table = 'game_user_pvp_count';
}
\ No newline at end of file
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GameUserRoleTime extends Model
{
protected $connection = 'wx_mysql';
protected $table = 'game_user_role_time';
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment