feat: 购物车商品数量限制为100个,超出时无法添加更多商品 fix: 修复订单创建时支付方式验证错误 refactor: 重构订单创建逻辑,优化代码结构 style: 修改金额计算方式,保留两位小数 test: 增加购物车列表接口测试用例 docs: 更新购物车相关接口文档 build: 更新依赖包版本
88 lines
2.9 KiB
PHP
88 lines
2.9 KiB
PHP
<?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\store\logic;
|
||
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\system_store\SystemStoreStaff;
|
||
use app\store\service\AdminTokenService;
|
||
use app\common\model\auth\AdminRole;
|
||
use app\common\service\FileService;
|
||
use app\MyBusinessException;
|
||
use think\facade\Db;
|
||
use Webman\Config;
|
||
|
||
/**
|
||
* 登录逻辑
|
||
* Class LoginLogic
|
||
* @package app\store\logic
|
||
*/
|
||
class LoginLogic extends BaseLogic
|
||
{
|
||
/**
|
||
* @notes 管理员账号登录
|
||
* @param $params
|
||
* @return false|mixed
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author 乔峰
|
||
* @date 2021/6/30 17:00
|
||
*/
|
||
public function login($params)
|
||
{
|
||
$time = time();
|
||
$admin = SystemStoreStaff::where('account', '=', $params['account'])->find();
|
||
//用户表登录信息更新
|
||
$admin->last_time = $time;
|
||
$admin->last_ip = request()->getLocalIp();
|
||
$admin->save();
|
||
//设置token
|
||
$adminInfo = AdminTokenService::setToken($admin->id, $params['terminal']);
|
||
|
||
//返回登录信息
|
||
$avatar = $admin->avatar ? $admin->avatar : Config::get('project.default_image.admin_avatar');
|
||
$avatar = FileService::getFileUrl($avatar);
|
||
return [
|
||
'name' => $adminInfo['name'],
|
||
'avatar' => $avatar,
|
||
'role_name' => $adminInfo['role_name'],
|
||
'token' => $adminInfo['token'],
|
||
'store_id' => $admin['store_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 退出登录
|
||
* @param $adminInfo
|
||
* @return bool
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author 乔峰
|
||
* @date 2021/7/5 14:34
|
||
*/
|
||
public function logout($adminInfo)
|
||
{
|
||
//token不存在,不注销
|
||
if (!isset($adminInfo['token'])) {
|
||
return false;
|
||
}
|
||
//设置token过期
|
||
return AdminTokenService::expireToken($adminInfo['token']);
|
||
}
|
||
}
|