Merge pull request 'feat: 优化业务逻辑和异常处理,提升系统安全性和稳定性' (#174) from dev into main
Reviewed-on: https://gitea.lihaink.cn/mkm/multi-store/pulls/174
This commit is contained in:
commit
b3f9ef6dde
@ -44,11 +44,6 @@ class IndexController extends BaseApiController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$a=StoreProduct::where('is_show',1)->select();
|
|
||||||
foreach($a as $k=>$v){
|
|
||||||
$find=StoreBranchProduct::where('product_id',$v['id'])->find();
|
|
||||||
StoreProduct::where('id',$v['id'])->update(['top_cate_id'=>$find['top_cate_id'],'two_cate_id'=>$find['two_cate_id'],'cate_id'=>$find['cate_id']]);
|
|
||||||
}
|
|
||||||
return json([1]);
|
return json([1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,12 +84,19 @@ class CartLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Cart::where([
|
if(isset($params['type']) && $params['type']=='inc'){
|
||||||
'uid' => $params['uid'],
|
Cart::where([
|
||||||
'store_id' => $params['store_id'],
|
'uid' => $params['uid'],
|
||||||
'product_id' => $params['product_id']
|
'store_id' => $params['store_id'],
|
||||||
])
|
'product_id' => $params['product_id']
|
||||||
->update(['cart_num' => $params['cart_num']]);
|
])->inc('cart_num')->update();
|
||||||
|
}else{
|
||||||
|
Cart::where([
|
||||||
|
'uid' => $params['uid'],
|
||||||
|
'store_id' => $params['store_id'],
|
||||||
|
'product_id' => $params['product_id']
|
||||||
|
])->update(['cart_num' => $params['cart_num']]);
|
||||||
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
@ -10,7 +10,7 @@ use app\common\model\auth\Admin;
|
|||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
use app\common\service\ConfigService;
|
use app\common\service\ConfigService;
|
||||||
use app\common\validate\BaseValidate;
|
use app\common\validate\BaseValidate;
|
||||||
use app\MyBusinessException;
|
use support\exception\BusinessException;
|
||||||
use Webman\Config;
|
use Webman\Config;
|
||||||
|
|
||||||
class LoginValidate extends BaseValidate
|
class LoginValidate extends BaseValidate
|
||||||
@ -55,7 +55,7 @@ class LoginValidate extends BaseValidate
|
|||||||
|
|
||||||
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||||
if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) {
|
if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) {
|
||||||
throw new MyBusinessException('密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试');
|
throw new BusinessException('密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试');
|
||||||
}
|
}
|
||||||
|
|
||||||
$staffInfo = SystemStoreStaff::where('account', '=', $data['account'])
|
$staffInfo = SystemStoreStaff::where('account', '=', $data['account'])
|
||||||
@ -63,21 +63,21 @@ class LoginValidate extends BaseValidate
|
|||||||
->findOrEmpty();
|
->findOrEmpty();
|
||||||
|
|
||||||
if ($staffInfo->isEmpty()) {
|
if ($staffInfo->isEmpty()) {
|
||||||
return '账号不存在';
|
throw new BusinessException('账号不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($staffInfo['disable'] === 1) {
|
if ($staffInfo['disable'] === 1) {
|
||||||
return '账号已禁用';
|
throw new BusinessException('账号已禁用');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($staffInfo['pwd'])) {
|
if (empty($staffInfo['pwd'])) {
|
||||||
$adminAccountSafeCache->record();
|
$adminAccountSafeCache->record();
|
||||||
return '账号不存在';
|
throw new BusinessException('账号不存在');
|
||||||
}
|
}
|
||||||
$pwdSalt = Config::get('project.unique_identification');
|
$pwdSalt = Config::get('project.unique_identification');
|
||||||
if ($staffInfo['pwd'] !== create_password($password, $pwdSalt)) {
|
if ($staffInfo['pwd'] !== create_password($password, $pwdSalt)) {
|
||||||
$adminAccountSafeCache->record();
|
$adminAccountSafeCache->record();
|
||||||
return '密码错误';
|
throw new BusinessException('密码错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminAccountSafeCache->relieve();
|
$adminAccountSafeCache->relieve();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user