multi-store/app/api/controller/LoginController.php
mkm 40ec3e5ee0 feat: 修改了订单相关的API,优化了支付逻辑;
fix: 修复了用户地址、商品库存等错误;
refactor: 重构了登录逻辑,提高了代码可读性;
style: 调整了代码格式,使其更加规范;
test: 增加了订单支付的测试用例;
docs: 更新了相关文档;
build: 更新了依赖;
ops: 优化了服务器性能;
chore: 更新了.gitignore文件;
2024-08-27 11:56:48 +08:00

94 lines
2.3 KiB
PHP

<?php
namespace app\api\controller;
use app\api\logic\LoginLogic;
use app\common\model\system_store\SystemStore;
use app\api\validate\{LoginAccountValidate, WechatLoginValidate};
use app\common\model\user\UserAuth;
class LoginController extends BaseApiController
{
public $notNeedLogin = ['account','logout','mnpLogin','OaAuthBind'];
/**
* @notes 账号登录
*/
public function account()
{
$params = (new LoginAccountValidate())->post()->goCheck();
$result = LoginLogic::login($params);
return $this->success('', $result);
}
/**
* @notes 退出登录
*/
public function logout()
{
LoginLogic::logout($this->userInfo);
return $this->success();
}
/**
* @notes 小程序-登录接口
* @return
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpLogin()
{
$params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
$res = LoginLogic::mnpLogin($params);
$res = LoginLogic::dealStaff($res);
return $this->success('', $res);
}
/**
* @notes 小程序绑定微信
* @return
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpAuthBind()
{
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
$params['user_id'] = $this->userId;
$result = LoginLogic::mnpAuthLogin($params);
return $this->success('绑定成功', [], 1, 1);
}
/**
* @notes 更新用户头像昵称
* @return
* @author 段誉
* @date 2023/2/22 11:15
*/
public function updateUser()
{
$params = $this->request->post();
$result = LoginLogic::updateUser($params, $this->userId);
return $this->success('操作成功', [], 1, 0);
}
/**
* @notes 公众号授权绑定
*/
public function OaAuthBind(){
$params=$this->request->post();
if($params){
$find=UserAuth::where('user_id',$params['uid'])->where('terminal',2)->find();
if(!$find){
UserAuth::create([
'user_id'=>$params['uid'],
'terminal'=>2,
'openid'=>$params['openid'],
]);
}
}
}
}