修改统计
This commit is contained in:
parent
bd0958cbe3
commit
271a2abe49
@ -518,36 +518,6 @@ class GoodsLogic extends Logic
|
||||
// dump($wh);
|
||||
// dump($where);
|
||||
// dump($order);die;
|
||||
$cate = [];
|
||||
if (isset($get['keyword'])) {
|
||||
$cate = GoodsCategory::where(['is_show' => 1, 'del' => 0])
|
||||
->where([['name', 'like', '%' . trim($get['keyword']) . '%']])
|
||||
->field('id, level')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
if (!empty($cate)) {
|
||||
$where = array_filter($where, function($item) {
|
||||
return $item[0] !== "name";
|
||||
});
|
||||
$where = array_values($where);
|
||||
|
||||
$con = array(
|
||||
1 => 'first_cate_id',
|
||||
2 => 'second_cate_id',
|
||||
3 => 'second_cate_id',
|
||||
);
|
||||
foreach ($cate as &$v) {
|
||||
$list = Goods::with(['shop'])
|
||||
->field($field)
|
||||
->where($where)
|
||||
->where([
|
||||
[$con[$v['level']], 'like', '%' . $v['id'] . '%'],
|
||||
])
|
||||
->order($order)
|
||||
->select();
|
||||
}
|
||||
} else {
|
||||
$list = Goods::with(['shop'])
|
||||
->field($field)
|
||||
->where($wh)
|
||||
@ -555,7 +525,6 @@ class GoodsLogic extends Logic
|
||||
->order($order)
|
||||
->page($get['page_no'], $get['page_size'])
|
||||
->select();
|
||||
}
|
||||
// foreach ($list as &$v) {
|
||||
// $v['market_price'] = round($v['min_price'],2);
|
||||
// $v['min_price'] = round(0.88*$v['min_price'],2);
|
||||
@ -623,14 +592,7 @@ class GoodsLogic extends Logic
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cate)) {
|
||||
$list = Goods::where($where)
|
||||
->where([
|
||||
[$con[$v['level']], 'like', '%' . $v['id'] . '%'],
|
||||
])->count();
|
||||
} else {
|
||||
$count = Goods::where($where)->where($wh)->count();
|
||||
}
|
||||
|
||||
$list = $list ? $list->toArray() : [];
|
||||
|
||||
@ -967,11 +929,37 @@ class GoodsLogic extends Logic
|
||||
'del' => 0
|
||||
]);
|
||||
|
||||
$category = GoodsCategory::where(['is_show' => 1, 'del' => 0])
|
||||
->where([['name', 'like', '%' . trim($shop_name) . '%']])
|
||||
->field('id')
|
||||
->select()
|
||||
->toArray();
|
||||
if (!empty($category)) {
|
||||
$ids = array_column($category, 'id');
|
||||
$ids = implode(',', $ids);
|
||||
$like1 = [
|
||||
['first_cate_id', 'like', '%' . $ids . '%'],
|
||||
];
|
||||
$like2 = [
|
||||
['second_cate_id', 'like', '%' . $ids . '%'],
|
||||
];
|
||||
$like3 = [
|
||||
['third_cate_id', 'like', '%' . $ids . '%'],
|
||||
];
|
||||
$goods = Goods::where($onSaleWhere)
|
||||
->whereOr([$like1, $like2, $like3])->order('sort_weight asc, sort asc, id desc')
|
||||
->field('id, name')
|
||||
->limit(30)
|
||||
->select()
|
||||
->toArray();
|
||||
} else {
|
||||
$goods = Goods::field('id, name')
|
||||
->where($onSaleWhere)
|
||||
->where($where)
|
||||
->order('sort_weight asc, sort asc, id desc')
|
||||
->select()->toArray();
|
||||
}
|
||||
|
||||
if ($goods) {
|
||||
return $goods;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user