Files
hyperf_service/app/Controller/Api/OrderController.php
2025-04-09 10:13:40 +08:00

180 lines
4.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Controller\Api;
use App\Controller\AbstractController;
use App\Middleware\Api\JwtAuthMiddleware;
use App\Service\Api\Evaluation\EvaluationService;
use App\Service\Api\Evaluation\ViewService as EvaluationViewService;
use App\Service\Api\Evaluation\InfoService as EvaluationInfoService;
use App\Service\Api\Evaluation\ListService as EvaluationListService;
use App\Service\Api\Order\CancelOrderService;
use App\Service\Api\Order\CheckCartService;
use App\Service\Api\Order\CheckStockService;
use App\Service\Api\Order\ConfirmationOrderService;
use App\Service\Api\Order\OrderInfoService;
use App\Service\Api\Order\OrderListService;
use App\Service\Api\Order\PlaceOrderService;
use App\Service\Api\Order\RefundOrderService;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\Validation\Annotation\Scene;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
#[Controller(prefix: 'api/order')]
#[Middlewares([
JwtAuthMiddleware::class,
])]
class OrderController extends AbstractController
{
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'check_cart',methods: 'post')]
#[Scene(scene: 'check_cart')]
public function checkCart()
{
return (new CheckCartService)->handle();
}
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'check_stock',methods: 'post')]
#[Scene(scene: 'check_stock')]
public function checkGoodStock()
{
return (new CheckStockService)->handle();
}
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'confirmation_order',methods: 'post')]
#[Scene(scene: 'confirmation_order')]
public function confirmationOrder()
{
return (new ConfirmationOrderService)->handle();
}
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'place_order',methods: 'post')]
#[Scene(scene: 'place_order')]
public function placeOrder()
{
return (new PlaceOrderService)->handle();
}
/**
* 取消订单 type 1|2 good|balance
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'cancel_order',methods: 'post')]
#[Scene(scene: 'cancel_order')]
public function cancelOrder()
{
return (new CancelOrderService)->handle();
}
/**
* 订单退款(同理)
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'refund_order',methods: 'post')]
#[Scene(scene: 'refund_order')]
public function refundOrder()
{
return (new RefundOrderService)->handle();
}
/**
* 订单列表
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'order_list',methods: 'get')]
#[Scene(scene: 'order_list')]
public function orderList()
{
return (new OrderListService)->handle();
}
/**
* 订单详情
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'order_info',methods: 'get')]
#[Scene(scene: 'order_info')]
public function orderInfo()
{
return (new OrderInfoService)->handle();
}
/**
* 评论
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'evaluation',methods: 'POST')]
#[Scene(scene: 'evaluation')]
public function evaluation()
{
return (new EvaluationService)->handle();
}
/**
* 评论视图 (商品信息)
* @return array
*/
#[RequestMapping(path: 'evaluation_view',methods: 'get')]
#[Scene(scene: 'evaluation_view')]
public function evaluationView()
{
return (new EvaluationViewService)->handle();
}
/**
* 评论详情
* @return array
*/
#[RequestMapping(path: 'evaluation_info',methods: 'get')]
#[Scene(scene: 'evaluation_info')]
public function evaluationInfo()
{
return (new EvaluationInfoService)->handle();
}
/**
* 我的评论
* @return array
*/
#[RequestMapping(path: 'evaluation_list',methods: 'get')]
#[Scene(scene: 'evaluation_list')]
public function evaluationList()
{
return (new EvaluationListService)->handle();
}
}