Files
zzp-server/app/api/controller/RobotController.php
2026-01-19 14:19:22 +08:00

122 lines
2.9 KiB
PHP

<?php
namespace app\api\controller;
use app\api\logic\RobotLogic;
use app\api\validate\{RobotValidate};
use app\api\lists\lh\{LhRecordLists};
/**
* 抢单控制器
* Class RobotController
* @package app\shopapi\controller
*/
class RobotController extends BaseApiController
{
/**
* @notes 首页数据
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author BD
* @date 2024/02/22 10:54
*/
public function index()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = RobotLogic::getIndexData($params);
return $this->data($result);
}
/**
* @notes 量化
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function buy()
{
$params = (new RobotValidate())->post()->goCheck('buy', [
'user_id' => $this->userId,
]);
$result = RobotLogic::buy($params);
if (false === $result) {
return $this->fail(RobotLogic::getError());
}
return $this->data($result);
}
/**
* @notes 抢单记录
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function recordLists()
{
return $this->dataLists(new LhRecordLists());
}
/**
* @notes 抢单
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function grab()
{
$params = $this->request->post();
$params['user_id'] = $this->userId;
$result = RobotLogic::grab($params);
if (false === $result) {
return $this->fail(RobotLogic::getError());
}
return $this->data($result);
}
/**
* @notes 获取进行中订单
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author BD
* @date 2024/02/22 10:54
*/
public function grabIngRecord()
{
$result = RobotLogic::grabIngRecord([
'user_id' => $this->userId
]);
if (false === $result) {
return $this->fail(RobotLogic::getError());
}
return $this->data($result);
}
/**
* @notes 订单支付
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function grabPay()
{
$params = (new RobotValidate())->post()->goCheck('grabPay', [
'user_id' => $this->userId,
]);
$result = RobotLogic::grabPay($params);
if (false === $result) {
return $this->fail(RobotLogic::getError());
}
return $this->data($result);
}
}