50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\api\logic\PointsOrderLogic;
|
|
use app\api\validate\PointsOrderValidate;
|
|
|
|
class PointsOrderController extends BaseApiController
|
|
{
|
|
public function products()
|
|
{
|
|
return $this->data(PointsOrderLogic::products());
|
|
}
|
|
|
|
public function preOrder()
|
|
{
|
|
$params = (new PointsOrderValidate())->post()->goCheck('preOrder');
|
|
$result = PointsOrderLogic::preOrder($params);
|
|
if (false === $result) {
|
|
return $this->fail(PointsOrderLogic::getError());
|
|
}
|
|
return $this->data($result);
|
|
}
|
|
|
|
public function createOrder()
|
|
{
|
|
$params = (new PointsOrderValidate())->post()->goCheck('createOrder', [
|
|
'user_id' => $this->userId,
|
|
'terminal' => $this->userInfo['terminal'],
|
|
]);
|
|
$result = PointsOrderLogic::createOrder($params);
|
|
if (false === $result) {
|
|
return $this->fail(PointsOrderLogic::getError());
|
|
}
|
|
return $this->data($result);
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
$params = (new PointsOrderValidate())->goCheck('detail', [
|
|
'user_id' => $this->userId,
|
|
]);
|
|
$result = PointsOrderLogic::detail($params);
|
|
if (false === $result) {
|
|
return $this->fail(PointsOrderLogic::getError());
|
|
}
|
|
return $this->data($result);
|
|
}
|
|
}
|