优化门店列表查询逻辑

- 移除了对经纬度的非空检查,避免在不使用时进行不必要的验证
- 将查询结果的分页限制去除,改为返回前100条数据,提高数据处理效率
- 删除了未使用的购物车相关代码,清理了冗余的逻辑判断
- 优化了距离计算的逻辑,简化了代码结构
This commit is contained in:
mkm 2024-10-16 14:33:52 +08:00
parent 054ddaddcc
commit 73800a2154

View File

@ -51,9 +51,6 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac
$latitude = $this->request->get('latitude', '');
$longitude = $this->request->get('longitude', '');
$cart_id = $this->request->get('cart_id', '');
// if(empty($longitude) || empty($latitude)){
// throw new Exception('缺失经纬度');
// }
$where[] = ['is_show', '=', YesNoEnum::YES];
$data = SystemStore::where($this->searchWhere)->where($where)
->field([
@ -73,7 +70,7 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac
'is_send',
'abbreviation'
])
->limit($this->limitOffset, $this->limitLength)
->limit(100)
->order(['id' => 'desc'])
->select()
->toArray();
@ -84,25 +81,6 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac
$values['reservation'] = 1;
}
// $cart_id = explode(',',$cart_id);
// $cart_select = Cart::whereIn('id', $cart_id)
// ->field('id,product_id,cart_num,store_id')->select()->toArray();
// foreach ($cart_select as $v) {
// foreach ($data as &$values){
// $store = StoreBranchProduct::where([
// 'store_id'=>$values['id'],
// 'product_id'=>$v['product_id'],
// ])->field('id,store_name,stock')->withTrashed()->find();
// if(empty($store)){
// $store['stock'] =0;
// }
// $values['reservation'] = 0;
// if($store['stock'] < $v['cart_num']){
// }
// }
// }
} else {
foreach ($data as &$values) {
$values['distance'] = 0;