Files
chazhi_admin_broker/app/api/controller/UserController.php
2026-03-11 18:24:59 +08:00

281 lines
8.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
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\validate\UserAddressValidate;
/**
* 用户控制器
* Class UserController
* @package app\api\controller
*/
class UserController extends BaseApiController
{
public array $notNeedLogin = ['resetPassword'];
/**
* @notes 获取个人中心
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 胥聪
* @date 2025/11/4 16:53
*/
public function center()
{
$data = UserLogic::center($this->userInfo);
return $this->success('', $data);
}
/**
* @notes 获取个人信息
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:46
*/
public function info()
{
$result = UserLogic::info($this->userId);
return $this->data($result);
}
/**
* @notes 获取门店钱包余额
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:46
*/
public function userStoreMoneyList()
{
$result = UserLogic::userStoreMoneyList($this->userId);
return $this->data($result);
}
/**
* @notes 重置密码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 18:06
*/
public function resetPassword()
{
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
$result = UserLogic::resetPassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改密码
* @return \think\response\Json
* @author 段誉
* @date 2022/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('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 获取小程序手机号
* @return \think\response\Json
* @author 段誉
* @date 2022/9/21 16:46
*/
public function getMobileByMnp()
{
$params = (new UserValidate())->post()->goCheck('getMobileByMnp');
$params['user_id'] = $this->userId;
$result = UserLogic::getMobileByMnp($params);
if ($result === false) {
return $this->fail(UserLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
}
/**
* @notes 编辑用户信息
* @return \think\response\Json
* @author 段誉
* @date 2022/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('操作成功', [], 1, 1);
}
/**
* @notes 绑定/变更 手机号
* @return \think\response\Json
* @author 段誉
* @date 2022/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('绑定成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 地址列表
* @return \think\response\Json
* @author 胥聪
* @date 2022/10/21 15:00
*/
public function addressList()
{
$data['user_id'] = $this->userId;
$result = UserLogic::addressList($data);
return $this->success('', $result, 1, 1);
}
/**
* @notes 地址详情
* @return \think\response\Json
* params['id':'地址id']
* @author 胥聪
* @date 2022/10/21 16:43
*/
public function addressDetails()
{
$data = $this->request->post();
$result = UserLogic::addressDetails($data);
if($result) {
return $this->success('查询成功', $result, 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 上传地址
* @return \think\response\Json
* @author 胥聪
* @date 2022/10/21 15:00
*/
public function addAddress(){
$data = (new UserAddressValidate())->post()->goCheck('addAddress');
$data['user_id'] = $this->userId;
$result = UserLogic::addAddress($data);
if($result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改地址
* @return \think\response\Json
* @author 胥聪
* @date 2022/10/21 15:48
*/
public function editAddress(){
$data = (new UserAddressValidate())->post()->goCheck('addAddress');
$user_id = $this->userId;
$result = UserLogic::editAddress($data,$user_id);
if($result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改地址
* @return \think\response\Json
* @author 胥聪
* @date 2022/10/21 15:48
*/
public function delAddress(){
$data = $this->request->post();
$result = UserLogic::delAddress($data);
if($result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 金额记录
* @return \think\response\Json
* @author 胥聪
* @date 2022/11/4 17:28
*/
public function moneyLogList(){
$data = $this->request->post();
$user_id = $this->userId;
$result = UserLogic::getMoneyLogList($data,$user_id);
return $this->success('查询成功', $result, 1, 1);
}
/**
* @notes 获取用户门店余额
* @return \think\response\Json
* @author 胥聪
* @date 2022/11/18 15:00
*/
public function userStoreMoney(){
$data = $this->request->post();
$user_id = $this->userId;
$result = UserLogic::getUserStoreMoney($data,$user_id);
return $this->success('查询成功', $result, 1, 1);
}
/**
* @notes 获取会员信息
* @return \think\response\Json
* @author 胥聪
* @date 2022/11/20 21:59
*/
public function UserMember(){
$user_id = $this->userId;
$result = UserLogic::UserMember($user_id);
return $this->success('查询成功', $result, 1, 1);
}
/**
* @notes 获取会员信息详情
* @return \think\response\Json
* @author 胥聪
* @date 2022/11/20 22:34
*/
public function accountDetails(){
$data = $this->request->post();
$result = UserLogic::accountDetails($data);
return $this->success('查询成功', $result, 1, 1);
}
}