嵌入工具

宝塔Shell脚本
cd /www/wwwroot/项目根目录/
php think cron:game_rtp>> /dev/null 2>&1
This commit is contained in:
2026-06-12 17:53:43 +08:00
parent 45330cf2d8
commit 0588cbecdb
7 changed files with 458 additions and 1 deletions

View File

@@ -2,6 +2,8 @@
namespace app\common\service;
use app\admin\model\Config as ConfigModel;
use app\admin\model\Game;
use app\admin\model\Provider;
use think\Exception;
class Jk8Services
@@ -111,4 +113,72 @@ class Jk8Services
return $result['data']['transactionId'];
}
/**
* 获取厂商列表
* @return array|mixed|null
* @throws Exception
*/
public function getGameCategory(): mixed
{
$params = $this->createParam('/games/getGameCategory', []);
$result = doCurl($this->domain, $params);
if (($result['status'] ?? '') === 'ERROR') {
throw new Exception($result['data']['message'] ?? 'Remote API Error');
}
foreach ($result['data'] as $item) {
if (!empty($item['sites']) && is_array($item['sites'])) {
foreach ($item['sites'] as $siteItem) {
if (isset($siteItem['hasGameList']) && $siteItem['hasGameList'] === false) {
continue;
}
if (!empty($siteItem['site'])) {
$allSites[] = $siteItem['site'];
}
}
}
}
$uniqueSites = array_values(array_unique($allSites));
$insertData = [];
foreach ($uniqueSites as $site) {
$insertData[] = ['site' => $site, 'create_time' => time()];
}
if ($insertData) {
$p = new Provider;
$p->saveAll($insertData);
}
return $insertData;
}
/**
* 获取游戏列表
* @return array|mixed|null
* @throws Exception
*/
public function getGameList(): mixed
{
$data = [];
$sites = Provider::column('site');
foreach ($sites as $site) {
$post['site'] = $site;
$params = $this->createParam('/games/getGameList', $post);
$result = doCurl($this->domain, $params);
if (($result['status'] ?? '') === 'ERROR') {
throw new Exception($result['data']['message'] ?? 'Remote API Error');
}
foreach ($result['data'] as $game) {
$data['provider_site'] = $site;
$data['game_code'] = $game['GameCode'] ?? '';
$data['game_name'] = $game['GameName'] ?? '';
$data['game_type'] = ltrim(strstr($game['GameType'], '-'), '-') ?? '';
$data['image_url'] = $game['GameImageUrl'] ?? '';
$data['create_time'] = time();
$insert[] = $data;
}
}
if ($insert) {
$g = new Game;
$g->saveAll($insert);
}
return $insert;
}
}