优化:商户移动端登录成功后返回信息

This commit is contained in:
wuhui_zzw 2024-03-06 15:15:56 +08:00
parent 6e0fcbd49c
commit b47600bc9d
2 changed files with 16 additions and 14 deletions

View File

@ -204,17 +204,19 @@ class MerchantAdminRepository extends BaseRepository
*/
$merchantRepository = app()->make(MerchantRepository::class);
$merchant = $merchantRepository->get($adminInfo->mer_id);
if (!$merchant)
throw new ValidateException('商户不存在');
if (!$merchant['status'])
throw new ValidateException('商户已被锁定');
if (!$merchant) throw new ValidateException('商户不存在');
if (!$merchant['status']) throw new ValidateException('商户已被锁定');
$adminInfo->merchant_type = $merchant->merchant_type ?? 0;
$adminInfo->last_time = date('Y-m-d H:i:s');
$adminInfo->last_ip = app('request')->ip();
$adminInfo->login_count++;
$adminInfo->save();
event('admin.merLogin',compact('adminInfo'));
$adminInfo->merchant_type = $merchant->merchant_type ?? 0;
$adminInfo->mer_name = $merchant->mer_name ?? '';
$adminInfo->mer_avatar = $merchant->mer_avatar ?? '';
return $adminInfo;
}

View File

@ -6,6 +6,7 @@ namespace app\controller\api\store\merchant;
use app\common\repositories\store\service\StoreServiceRepository;
use app\common\repositories\system\merchant\MerchantAdminRepository;
use app\common\repositories\system\merchant\MerchantRepository;
use app\common\repositories\user\UserMerchantRepository;
use crmeb\services\QrcodeService;
use think\App;
@ -168,16 +169,15 @@ class Merchant extends BaseController
$admin = $adminInfo->toArray();
// 判断:这里仅允许酒道馆和普通商户登录
if($admin['merchant_type'] == 2) throw new ValidateException('当前账号禁止登录!');
// unset($admin['pwd']);
// $data = [
// 'token' => $tokenInfo['token'],
// 'exp' => $tokenInfo['out'],
// 'admin' => $admin
// ];
return app('json')->success([
'token' => $tokenInfo['token'],
'exp' => $tokenInfo['out'],
'mer_id' => $admin['mer_id']
'token' => $tokenInfo['token'],
'exp' => $tokenInfo['out'],
'mer_id' => $admin['mer_id'],
'merchant_type' => $admin['merchant_type'],
'mer_name' => $admin['mer_name'],
'mer_avatar' => $admin['mer_avatar']
]);
}