diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 427d9b2..9bdb472 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -2,16 +2,19 @@ namespace app\api\controller; +use app\common\service\XyxServices; use ba\Tree; use Throwable; use think\facade\Db; use think\facade\Config; use app\common\controller\Frontend; use app\common\library\token\TokenExpirationException; +use app\admin\model\User as UserModel; +use app\admin\model\Config as ConfigModel; class Index extends Frontend { - protected array $noNeedLogin = ['index']; + protected array $noNeedLogin = ['index', 'xyxLogin']; public function initialize(): void { @@ -81,4 +84,27 @@ class Index extends Frontend 'menus' => $menus, ]); } + + public function xyxLogin() + { + $encodedContent = $this->request->param('userData', ''); + $merchantId = $this->request->param('clientMerchant', ''); + $gameId = $this->request->post('page'); + if (!$encodedContent || !$merchantId || !$gameId) { + $this->error(__('Parameter %s can not be empty')); + } + $config = ConfigModel::where('group', 'jdk_api')->where('name', 'access_id')->where('value', $merchantId)->find(); + if (!$config) { + $this->error(__('clientMerchant error')); + } + parse_str(base64_decode($encodedContent), $output); + $user = $output['jdkUserId'] ?? ''; + $player = UserModel::where('jk_user_id', $user)->find(); + if (!$player) { + $this->error(__('player not found')); + } + $xyxServices = new XyxServices($player); + $res = $xyxServices->login(['gameCode' => $gameId]); + $this->success('success',[$res]); + } } \ No newline at end of file