Commit c5d5d4fc authored by liyadong's avatar liyadong

Merge branch 'test' of http://gitlab.cccwangluo.com/zhoujun/uc_card into test

parents 8302b1e1 f7464781
......@@ -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']);
}
......@@ -341,44 +346,27 @@ class CardController extends Controller
$userId = $request->session()->get("uid");
$roleId = $request->input('roleId');
$serverId = $request->input('serverId');
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
if (empty($roleId) || empty($serverId)) return $this->jsonReturn(7002, '参数错误');
$data = [];
if(Cache::has('card:info:'.$userId.':'.$roleId)){
$data = Cache::get('card:info:'.$userId.':'.$roleId);
}else{
$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'));
$info = DB::connection('wx_mysql')->table('wx_card_role_'.$serverId)->where('uid',$userId)->where('role_id',$roleId)->where('server_id',$serverId)->first();
}else{
$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);
}
$serverNames = config("gameservers");
$user = User::where('uid',$userId)->select('uid','account')->first();
$data['userName'] = $user->account ?? '';
$data['serverName'] = $serverName;
$img = WxUserImg::where('uid',$userId)->where('role_id',$info->id)->where('server_id',$info->server_id)->select('id','img_url','status','is_upload')->first();
if($img){
if($img->status == 1){
if($img->is_upload == 1){
$data['userImgStatus'] = 1;
}else{
$data['userImgStatus'] = 0;
}
}else{
$data['userImgStatus'] = $img->status;
}
$data['userImg'] = $img->img_url;
}else{
$data['userImg'] = '';
$data['userImgStatus'] = -1;
}
$data['serverName'] = $serverNames[$info->server_id] ?? $info->server_id;
$armsScore = [];
$armsStrong = [];
......@@ -386,13 +374,6 @@ class CardController extends Controller
if($info->arms_score != '') $armsScore = json_decode($info->arms_score,true);
if($info->arms_strong != '') $armsStrong = json_decode($info->arms_strong,true);
if($info->arms_exciting != '') $armsExciting = json_decode($info->arms_exciting,true);
// $roleScore = '00000';
// if(strlen($info->role_score) == 1) $roleScore = '0000'.(string)$info->role_score;
// if(strlen($info->role_score) == 2) $roleScore = '000'.(string)$info->role_score;
// if(strlen($info->role_score) == 3) $roleScore = '00'.(string)$info->role_score;
// if(strlen($info->role_score) == 4) $roleScore = '0'.(string)$info->role_score;
// if(strlen($info->role_score) == 5) $roleScore = (string)$info->role_score;
$roleScore = str_pad($info->role_score, 5, "0", STR_PAD_LEFT);
......@@ -419,14 +400,7 @@ class CardController extends Controller
}
$data['rank'] = empty($info->max_rank) ? '青铜5' : $info->max_rank;
if(!empty($armsScore)){
// $armsScoreNum = '00000';
// if(strlen($armsScore[0]['score']) == 1) $armsScoreNum = '0000'.(string)$armsScore[0]['score'];
// if(strlen($armsScore[0]['score']) == 2) $armsScoreNum = '000'.(string)$armsScore[0]['score'];
// if(strlen($armsScore[0]['score']) == 3) $armsScoreNum = '00'.(string)$armsScore[0]['score'];
// if(strlen($armsScore[0]['score']) == 4) $armsScoreNum = '0'.(string)$armsScore[0]['score'];
// if(strlen($armsScore[0]['score']) == 5) $armsScoreNum = (string)$armsScore[0]['score'];
if(!empty($armsScore)){
$armsScoreNum = str_pad($armsScore[0]['score'], 5, "0", STR_PAD_LEFT);
$data['armsScoreName'] = $armsScore[0]['name'];
$data['armsScore'] = $armsScoreNum;
......@@ -469,6 +443,27 @@ class CardController extends Controller
}
Cache::put('card:info:'.$userId.':'.$roleId,$data, 86400);
}
$img = WxUserImg::where('uid',$userId)
->where('role_id', $roleId)
->where('server_id', $serverId)
->select('id','img_url','status','is_upload')
->first();
if($img){
if($img->status == 1){
if($img->is_upload == 1){
$data['userImgStatus'] = 1;
}else{
$data['userImgStatus'] = 0;
}
}else{
$data['userImgStatus'] = $img->status;
}
$data['userImg'] = $img->img_url;
}else{
$data['userImg'] = '';
$data['userImgStatus'] = -1;
}
return view('card.card', $data);
}
......
<?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
<?php
return [
269 => '月光酒馆1-36服',
267 => '月光酒馆37-53服',
268 => '月光酒馆54-71服',
271 => '月光酒馆72-77服',
272 => '月光酒馆78-79服',
3848 => '天空之城1-30服',
3868 => '时空裂缝1-30服',
3871 => '时空裂缝31-36服',
3872 => '时空裂缝37-38服',
910 => '格林之森1-50服',
888 => '诺克玛尔1-30服',
883 => '冰封雪域1-23服',
903 => '冰封雪域24-50服',
936 => '冰封雪域51-68服',
934 => '冰封雪域69-79服',
933 => '冰封雪域80-83服',
938 => '冰封雪域84-89服',
939 => '冰封雪域90-92服',
494 => '冰封雪域93服',
940 => '冰封雪域94-95服',
941 => '冰封雪域96-97服',
942 => '冰封雪域98-99服',
501 => '冰封雪域100服',
502 => '冰封雪域101服',
503 => '冰封雪域102服',
504 => '冰封雪域103服',
505 => '冰封雪域104服',
506 => '冰封雪域105服',
507 => '冰封雪域106服',
508 => '冰封雪域107服',
509 => '冰封雪域108服',
510 => '冰封雪域109服',
1000 => '天空之海1服',
1957 => '天空之海2-32服',
1953 => '元素回廊1-31服',
1933 => '元素回廊32-50服',
1993 => '元素回廊51-59服',
1908 => '元素回廊60-71服',
1904 => '元素回廊72-79服',
1909 => '元素回廊80-87服',
1918 => '元素回廊88-95服',
1939 => '元素回廊96-107服',
1944 => '元素回廊108-115服',
1947 => '元素回廊116-121服',
1936 => '元素回廊122-125服',
1951 => '元素回廊126-129服',
1954 => '元素回廊130-133服',
1952 => '元素回廊134-139服',
1960 => '元素回廊140-151服',
1182 => '元素回廊152服',
2843 => '光之宫殿1-30服',
2858 => '光之宫殿31-54服',
2859 => '光之宫殿55-60服',
2862 => '光之宫殿61-64服',
2871 => '光之宫殿65-68服',
2870 => '光之宫殿69-75服',
2872 => '光之宫殿76-79服',
2873 => '光之宫殿80-81服',
4101 => '迷雾峡谷1-2服',
5001 => '时之漩涡1服',
5002 => '时之漩涡2服',
];
\ No newline at end of file
......@@ -10,6 +10,11 @@
| contains the 'web' middleware group. Now create something great!
|
*/
Route::get("config/game_servers", function() {
return json_encode(config("gameservers"), JSON_UNESCAPED_UNICODE);
});
Route::get('health/status', 'CheckController@getCheckDB');
Route::any('/wx/home','HomeController@getIndex')->name('wxIndex');
......
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