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

454 lines
12 KiB
PHP

<?php
namespace app\api\controller;
use app\api\logic\UserLogic;
use app\api\validate\PasswordValidate;
use app\api\validate\SetUserInfoValidate;
use app\api\validate\UserValidate;
use app\api\lists\user\{UserNoticeLists,UserMineRecordLists};
use think\facade\Request;
/**
* 用户控制器
* Class UserController
* @package app\api\controller
*/
class UserController extends BaseApiController
{
public array $notNeedLogin = ['resetPassword'];
/**
* @notes 首页数据
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author BD
* @date 2024/9/21 19:15
*/
public function index()
{
$lang = $this->request->get('lang/s');
$result = UserLogic::getIndexData([
'lang' => $lang,
'user_id' => $this->userId
]);
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/9/21 19:15
*/
public function shareIndex()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
// $params['host'] = Request::header('origin');
$result = UserLogic::getShareIndexData($params);
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/9/16 18:19
*/
public function center()
{
$data = UserLogic::center($this->userInfo);
return $this->success('', $data);
}
/**
* @notes 获取个人信息
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:46
*/
public function info()
{
$params = $this->request->get();
$params['host'] = Request::header('origin');
$params['user_id'] = $this->userId;
$result = UserLogic::info($params);
return $this->data($result);
}
/**
* @notes 重置密码
* @return \think\response\Json
* @author BD
* @date 2024/9/16 18:06
*/
public function resetPassword()
{
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
$result = UserLogic::resetPassword($params);
if (true === $result) {
return $this->success('network.modifySuccessfully', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改密码
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:16
*/
public function changePassword()
{
$params = (new PasswordValidate())->post()->goCheck('changePassword');
$result = UserLogic::changePassword($params, $this->userId);
if (true === $result) {
return $this->success('network.modifySuccessfully', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改支付密码
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:16
*/
public function changePayPassword()
{
$params = (new PasswordValidate())->post()->goCheck('changePayPassword');
$result = UserLogic::changePayPassword($params, $this->userId);
if (true === $result) {
return $this->success('network.modifySuccessfully', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 设置支付密码
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:16
*/
public function setPayPwd()
{
$params = (new PasswordValidate())->post()->goCheck('setPayPassword');
$result = UserLogic::setPayPassword($params, $this->userId);
if (true === $result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 编辑用户信息
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:01
*/
public function setInfo()
{
$params = (new SetUserInfoValidate())->post()->goCheck(null, ['id' => $this->userId]);
$result = UserLogic::setInfo($this->userId, $params);
if (false === $result) {
return $this->fail(UserLogic::getError());
}
return $this->success('network.modifySuccessfully', [], 1, 1);
}
/**
* @notes 绑定/变更 手机号
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function bindMobile()
{
$params = (new UserValidate())->post()->goCheck('bindMobile');
$params['user_id'] = $this->userId;
$result = UserLogic::bindMobile($params);
if($result) {
return $this->success('network.modifySuccessfully', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 获取用户消息
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:46
*/
public function notice()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = UserLogic::notice($params);
return $this->data($result);
}
/**
* @notes 用户消息列表
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function noticeLists()
{
return $this->dataLists(new UserNoticeLists());
}
/**
* @notes 用户消息详情
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function noticeDetail()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = UserLogic::noticeDetail($params);
if ($result === false) {
return $this->fail(UserLogic::getError());
}
return $this->data($result);
}
/**
* @notes 奖励活动数据
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:46
*/
public function activityIndex()
{
$params['user_id'] = $this->userId;
$result = UserLogic::activityIndex($params);
return $this->data($result);
}
/**
* @notes 任务中心数据
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:46
*/
public function missionIndex()
{
$params['user_id'] = $this->userId;
$result = UserLogic::missionIndex($params);
return $this->data($result);
}
/**
* @notes 领取任务奖励
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:16
*/
public function missionReward()
{
$params = $this->request->post();
$params['user_id'] = $this->userId;
$result = UserLogic::missionReward($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 意见反馈类型
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:46
*/
public function feedbackCate()
{
$params = $this->request->get();
$result = UserLogic::feedbackCate($params);
return $this->data($result);
}
/**
* @notes 意见反馈
* @return \think\response\Json
* @author BD
* @date 2024/9/20 19:16
*/
public function feedback()
{
$params = $this->request->post();
$params['user_id'] = $this->userId;
$result = UserLogic::feedback($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes Google Authenticator校验
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function verifyGoogle()
{
$params = (new UserValidate())->post()->goCheck('verifyGoogle');
$params['user_id'] = $this->userId;
$result = UserLogic::verifyGoogle($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 邮箱校验
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function verifyEmail()
{
$params = (new UserValidate())->post()->goCheck('verifyEmail');
$params['user_id'] = $this->userId;
$result = UserLogic::verifyEmail($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 实名认证
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function verifyRealname()
{
$params = (new UserValidate())->post()->goCheck('verifyRealname', [
'user_id' => $this->userId
]);
$result = UserLogic::verifyRealname($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @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 signinConfig()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = UserLogic::signinConfig($params);
return $this->data($result);
}
/**
* @notes 签到
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function signin()
{
$params = (new UserValidate())->post()->goCheck('signin', [
'user_id' => $this->userId
]);
$result = UserLogic::signin($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @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 mineIndex()
{
$params = $this->request->get();
$params['user_id'] = $this->userId;
$result = UserLogic::getMineIndexData($params);
return $this->data($result);
}
/**
* @notes 挖矿记录列表
* @return \think\response\Json
* @author BD
* @date 2024/02/22 10:54
*/
public function mineLists()
{
return $this->dataLists(new UserMineRecordLists());
}
/**
* @notes 矿机 启动
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function mineStart()
{
$params = (new UserValidate())->post()->goCheck('mineStart', [
'user_id' => $this->userId
]);
$result = UserLogic::mineStart($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 矿机 收益
* @return \think\response\Json
* @author BD
* @date 2024/9/21 17:29
*/
public function mineReceive()
{
$params = (new UserValidate())->post()->goCheck('mineReceive', [
'user_id' => $this->userId
]);
$result = UserLogic::mineReceive($params);
if($result) {
return $this->success('', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
}