Files
cashier/app/index/controller/Index.php
你的名字 fcca45005f 1
2025-10-23 10:08:05 +08:00

64 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\index\controller;
use app\admin\model\BlackIp;
use app\admin\model\MallOrder;
use app\BaseController;
use Kaadon\Uuid\Uuids;
use think\Exception;
use think\facade\Env;
use think\response\Redirect;
class Index extends BaseController
{
/**
* @throws \think\Exception
*/
public function index()
{
if ($this->request->isPost()){
$param = $this->request->post();
$ip = $this->request->ip();
$black = BlackIp::where('ip',$ip)->find();
if (!empty($black)){
return view('error');
exit();
return error('您的IP已被禁止充值如有疑问请联系管理员');
}
$rid = Uuids::getUuid4();
$data = [
'money'=>$param['amount'],
'rid'=>$rid,
'start_time'=>time(),
'end_time'=>time()+180,
'ip'=> $ip,
];
(new MallOrder())->save($data);
return redirect('index/index/reloads?rid='.$rid);
}else{
return view();
}
}
public function reloads()
{
return view();
}
public function status()
{
$rid = $this->request->param('rid');
$data = MallOrder::where('rid',$rid)->find();
if (empty($data))
return error();
$status = match ($data['status']) {
1 => 'yellow',
2 => 'red',
default => 'blue',
};
return success([
'status'=>$status,
'color'=>$status,
'url'=>$data['url']
]);
}
}