重写获取本地商家方法
This commit is contained in:
parent
2ceccdbb7d
commit
a78bb5d46c
@ -6,6 +6,7 @@ use app\common\basics\Logic;
|
||||
use app\common\model\LocalStore;
|
||||
use app\common\model\localstore\LocalGoodsStore;
|
||||
use app\common\model\localstore\LocalStoreBind;
|
||||
use app\common\model\localstore\LocalStoreGoodsPic;
|
||||
use app\common\model\LocalStoreOrder;
|
||||
use app\common\model\LocalStorePostStation;
|
||||
use app\common\model\user\User;
|
||||
@ -114,29 +115,36 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
// 城市搜索
|
||||
if (isset($data['c_name']) && $data['c_name'] != "") {
|
||||
$where[] = ['address', 'like', '%' . $data['c_name'] . '%'];
|
||||
$where[] = ['ls.address', 'like', '%' . $data['c_name'] . '%'];
|
||||
}
|
||||
|
||||
// 搜索商家名称
|
||||
if (isset($data['keyword']) && $data['keyword'] != '') {
|
||||
$where[] = ['shopName', 'like', '%' . $data['keyword'] . '%'];
|
||||
$where[] = ['ls.shopName|lsg.title', 'like', '%' . $data['keyword'] . '%'];
|
||||
}
|
||||
|
||||
// 数量统计
|
||||
$count = LocalStore::where(['is_delete' => 0, 'store_state' => 1])
|
||||
$count = LocalStore::alias('ls')
|
||||
->join('local_store_goods lsg', 'ls.lstore_id = lsg.lstore_id')
|
||||
->where(['ls.is_delete' => 0, 'ls.store_state' => 1])
|
||||
->where($where)
|
||||
->whereNotNull('shopLogo')
|
||||
->whereNotNull('ls.shopLogo')
|
||||
->count();
|
||||
|
||||
// 列表
|
||||
$lists = LocalStore::where(['is_delete' => 0, 'store_state' => 1])
|
||||
$lists = LocalStore::alias('ls')
|
||||
->join('local_store_goods lsg', 'ls.lstore_id = lsg.lstore_id')
|
||||
->where(['ls.is_delete' => 0, 'ls.store_state' => 1])
|
||||
->where($where)
|
||||
->whereNotNull('shopLogo')
|
||||
->order('sort desc')
|
||||
->whereNotNull('ls.shopLogo')
|
||||
->order('lsg.id desc')
|
||||
->page($data['page_no'], $data['page_size'])
|
||||
->select();
|
||||
->field('ls.lstore_id as ls_id, ls.shopName, ls.longitude, ls.latitude, lsg.id, lsg.lstore_id, lsg.title, lsg.price')
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($lists as $key => &$value) {
|
||||
$pic = LocalStoreGoodsPic::where('lsg_id', $value['id'])->field('url')->find();
|
||||
$lists[$key]['url'] = UrlServer::getFileUrl($pic['url']);
|
||||
$lists[$key]['distance'] = round($this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']) / 1000, 2) . "公里";
|
||||
$lists[$key]['store_nickname'] = $value["shopName"];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user