You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Controller;
use App\Exception\BusinessException;
use App\Job\AfterLoginJob;
use App\Job\AfterRegisterJob;
use App\Job\AfterSaveRoleJob;
use App\Job\AfterSpendJob;
use App\Helper\Queue;
class GameEventController extends AbstractController
{
public function __construct()
{
}
public function recharge()
{
$payOrderNumber = $this->request->input('pay_order_number', '');
if (!$payOrderNumber) {
throw new BusinessException('缺少参数[pay_order_number]');
}
Queue::push(AfterSpendJob::class, ['pay_order_number' => $payOrderNumber]);
return $this->success();
}
public function login()
{
$userId = (int)$this->request->input('user_id', 0);
$gameId = (int)$this->request->input('game_id', 0);
$loginTime = (int)$this->request->input('login_time', 0);
if (!$userId) {
throw new BusinessException('缺少参数[user_id]');
}
if (!$gameId) {
throw new BusinessException('缺少参数[game_id]');
}
if (!$loginTime) {
throw new BusinessException('缺少参数[login_time]');
}
Queue::push(AfterLoginJob::class, [
'user_id' => $userId,
'game_id' => $gameId,
'login_time' => $loginTime
]);
return $this->success();
}
public function register()
{
$userId = $this->request->input('user_id', 0);
$source = $this->request->input('source', 'SDK');
if (!$userId) {
throw new BusinessException('缺少参数[user_id]');
}
Queue::push(AfterRegisterJob::class, [
'user_id' => $userId,
]);
return $this->success();
}
public function saveRole()
{
Queue::push(AfterSaveRoleJob::class, $this->request->all());
return $this->success();
}
}