修改店铺街接口

This commit is contained in:
wangxiaowei 2024-10-21 18:00:49 +08:00
parent 37abe5abd2
commit ee708fc6d3

@ -198,8 +198,7 @@ class LocalStoreLogic extends Logic
// 搜索商家名称
$keyword = '';
if (isset($data['keyword']) && $data['keyword'] != '') {
$where[] = ['shopName|title', 'like', '%' . $data['keyword'] . '%'];
$keyword = $data['keyword'];
$where[] = ['shopName', 'like', '%' . $data['keyword'] . '%'];
}
// 价格排序
@ -217,34 +216,29 @@ class LocalStoreLogic extends Logic
$distance_sql = "6371 * acos(cos(radians(" . $data['latitude'] . ")) * cos(radians(latitude)) * cos(radians(longitude) - radians(" . $data['longitude'] . ")) + sin(radians(" . $data['latitude'] . ")) * sin(radians(latitude))) AS distance";
// 数量统计
$count = LocalStore::with(['street_goods' => function ($query) use ($keyword) {
$query->where('title', 'like', "%{$keyword}%")
->where(['state' => 1, 'audit_status' => 1, 'delete_time' => 0]);
}])
->where($where)
->where(['is_delete' => 0, 'store_state' => 1])
->whereNotNull('shopLogo')
->count();
$count = LocalStore::where($where)
->where(['is_delete' => 0, 'store_state' => 1])
->whereNotNull('shopLogo')
->count();
// 这里的Join只是为了配合with获取指定的字段
$lists = LocalStore::alias('ls')
->with(['street_goods' => function ($query) use ($keyword) {
$query->where('title', 'like', "%{$keyword}%")
->where(['state' => 1, 'audit_status' => 1, 'delete_time' => 0])
->withLimit(10);
}])
->withAttr('street_goods.url', function($v) {
return UrlServer::getFileUrl($v);
})
->leftJoin('local_store_goods lsg', 'lsg.lstore_id = ls.lstore_id')
->where(['ls.is_delete' => 0, 'ls.store_state' => 1])
->where($where)
->whereNotNull('ls.shopLogo')
->field('ls.lstore_id as ls_id, ls.shopLogo, ls.shopName, ls.longitude, ls.latitude, ' . $distance_sql . ', lsg.lstore_id')
->order($order)
->page($data['page_no'], $data['page_size'])
->group('ls.lstore_id')
->select();
->with(['street_goods' => function ($query) {
$query->where(['state' => 1, 'audit_status' => 1, 'delete_time' => 0])
->withLimit(10);
}])
->withAttr('street_goods.url', function($v) {
return UrlServer::getFileUrl($v);
})
->leftJoin('local_store_goods lsg', 'lsg.lstore_id = ls.lstore_id')
->where(['ls.is_delete' => 0, 'ls.store_state' => 1])
->where($where)
->whereNotNull('ls.shopLogo')
->field('ls.lstore_id as ls_id, ls.shopLogo, ls.shopName, ls.longitude, ls.latitude, ' . $distance_sql . ', lsg.lstore_id')
->order($order)
->page($data['page_no'], $data['page_size'])
->group('ls.lstore_id')
->select();
foreach ($lists as $key => &$value) {
// 东龙汇超时价格 *88折