Files
cashier/app/index/controller/Index.php
你的名字 f524cee505 1
2025-11-28 16:58:38 +08:00

68 lines
1.8 KiB
PHP
Raw Permalink 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已被禁止充值如有疑问请联系管理员');
}
$order = MallOrder::where('ip',$ip)->where('start_time','>',time()-5)->find();
if (!empty($order)){
return error('请勿频繁提交订单请5s后再试');
}
$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']
]);
}
}