feat: 修改了登录逻辑和门店商品查询功能

This commit is contained in:
mkm 2024-06-01 16:47:35 +08:00
parent 2a5bc68379
commit 20e891a596
5 changed files with 75 additions and 33 deletions

View File

@ -38,7 +38,6 @@ class LoginController extends BaseAdminController
public function account()
{
$params = (new LoginValidate())->post()->goCheck();
$params['is_admin']=$this->request->post('is_admin',1);
return $this->data((new LoginLogic())->login($params));
}

View File

@ -0,0 +1,64 @@
<?php
namespace app\admin\lists\store_branch_product;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\system_store\SystemStore;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_branch_product\StoreBranchProduct;
/**
* 门店商品辅助表
* Class StoreBranchProductLists
* @package app\admin\listssystem_store
*/
class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/05/31 17:45
*/
public function setSearch(): array
{
return [
'=' => ['product_id'],
];
}
/**
* @notes 获取门店列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/05/31 17:45
*/
public function lists(): array
{
return StoreBranchProduct::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取门店列表数量
* @return int
* @author admin
* @date 2024/05/31 17:45
*/
public function count(): int
{
return SystemStore::where($this->searchWhere)->count();
}
}

View File

@ -6,8 +6,7 @@ namespace app\admin\lists\system_store;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\system_store\SystemStore;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_product\StoreProduct;
use PDO;
use app\common\model\store_branch_product\StoreBranchProduct;
/**
* 根据商品来源查询门店列表
@ -17,6 +16,7 @@ use PDO;
class SystemStoreSourceLists extends BaseAdminDataLists implements ListsSearchInterface
{
protected $where = []; // 搜索条件数组,用于存储搜索条件,以便在列表中使用。
/**
* @notes 设置搜索条件
@ -27,7 +27,7 @@ class SystemStoreSourceLists extends BaseAdminDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['name', 'phone'],
'=' => ['product_id'],
];
}
@ -43,18 +43,11 @@ class SystemStoreSourceLists extends BaseAdminDataLists implements ListsSearchI
*/
public function lists(): array
{
$store_arr=StoreProduct::where('source_id',$this->request->get('product_id'))->column('store_id');
if($store_arr){
$this->searchWhere[]=['id', 'in', $store_arr];
}else{
return [];
}
return SystemStore::where($this->searchWhere)
->field(['id', 'name', 'phone', 'detailed_address', 'image'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
$arr = StoreBranchProduct::where($this->searchWhere)->select()->each(function ($item) {
$item['system_store_name']=SystemStore::whereIn('id', $item['store_id'])->value('name');
return $item;
});
return $arr?->toArray();
}
@ -66,11 +59,6 @@ class SystemStoreSourceLists extends BaseAdminDataLists implements ListsSearchI
*/
public function count(): int
{
if($this->searchWhere){
return SystemStore::where($this->searchWhere)->count();
}else{
return 0;
}
return StoreBranchProduct::where($this->searchWhere)->count();
}
}
}

View File

@ -44,16 +44,6 @@ class LoginLogic extends BaseLogic
{
$time = time();
$admin = Admin::where('account', '=', $params['account'])->find();
if($params['is_admin'] == 0 &&$admin){
$auth_shop=Db::name('user_auth_shop')->where(['admin_id'=>$admin['id'],'status'=>1,'apply_status'=>1,'type'=>2])->find();
if(!$auth_shop){
throw new MyBusinessException('该账户没有权限');
}
}
if($admin &&$params['is_admin'] == 1){
$role_find=AdminRole::where('admin_id',$admin['id'])->where('role_id',1)->find();
if($role_find) throw new MyBusinessException('请使用供应商后台登录');
}
//用户表登录信息更新
$admin->login_time = $time;
$admin->login_ip = request()->getLocalIp();

View File

@ -187,6 +187,7 @@ class StoreProductLogic extends BaseLogic
'keyword' => $find['keyword'],
'bar_code' => $find['bar_code'],
'cate_id' => $find['cate_id'],
'price' => $find['price'],
'store_id' => $store_id,
'sales' => 0,
'stock' =>0,