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

97 lines
2.4 KiB
PHP

<?php
namespace app\api\controller;
use app\api\logic\MallLogic;
use app\api\validate\{MallValidate};
use app\api\lists\mall\{MallGoodsRecordLists};
/**
* 积分商城控制器
* Class MallController
* @package app\shopapi\controller
*/
class MallController 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 = MallLogic::index($params);
return $this->data($result);
}
/**
* @notes 兑换
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function buy()
{
$params = (new MallValidate())->post()->goCheck('buy', [
'user_id' => $this->userId,
]);
$result = MallLogic::buy($params);
if (false === $result) {
return $this->fail(MallLogic::getError());
}
return $this->data($result);
}
/**
* @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 drawIndex()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = MallLogic::drawIndex($params);
return $this->data($result);
}
/**
* @notes 抽奖
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function draw()
{
$params = (new MallValidate())->post()->goCheck('draw', [
'user_id' => $this->userId,
]);
$result = MallLogic::draw($params);
if (false === $result) {
return $this->fail(MallLogic::getError());
}
return $this->data($result);
}
/**
* @notes 抽奖记录
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function drawLists()
{
return $this->dataLists(new MallGoodsRecordLists());
}
}