新增小游戏接口

This commit is contained in:
2026-06-17 10:12:42 +08:00
parent 7d89230a56
commit 6e1fc0c3ef

View File

@@ -2,16 +2,19 @@
namespace app\api\controller; namespace app\api\controller;
use app\common\service\XyxServices;
use ba\Tree; use ba\Tree;
use Throwable; use Throwable;
use think\facade\Db; use think\facade\Db;
use think\facade\Config; use think\facade\Config;
use app\common\controller\Frontend; use app\common\controller\Frontend;
use app\common\library\token\TokenExpirationException; use app\common\library\token\TokenExpirationException;
use app\admin\model\User as UserModel;
use app\admin\model\Config as ConfigModel;
class Index extends Frontend class Index extends Frontend
{ {
protected array $noNeedLogin = ['index']; protected array $noNeedLogin = ['index', 'xyxLogin'];
public function initialize(): void public function initialize(): void
{ {
@@ -81,4 +84,27 @@ class Index extends Frontend
'menus' => $menus, '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]);
}
} }