减少查询总数排序
This commit is contained in:
parent
847b30637b
commit
ea7a01ecf4
@ -55,6 +55,11 @@ class SpuDao extends BaseDao
|
|||||||
if(isset($where['order']) && $where['order'] === 'none'){
|
if(isset($where['order']) && $where['order'] === 'none'){
|
||||||
$order = '';
|
$order = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($where['order_remark']) && $where['order_remark'] === 'none'){
|
||||||
|
$order = '';
|
||||||
|
}
|
||||||
|
|
||||||
$query = Spu::getDB()->alias('S')->join('StoreProduct P','S.product_id = P.product_id', 'left');
|
$query = Spu::getDB()->alias('S')->join('StoreProduct P','S.product_id = P.product_id', 'left');
|
||||||
$query->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){
|
$query->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){
|
||||||
$query->where('P.is_del',$where['is_del']);
|
$query->where('P.is_del',$where['is_del']);
|
||||||
@ -90,9 +95,9 @@ class SpuDao extends BaseDao
|
|||||||
->when(isset($where['is_trader']) && $where['is_trader'] !== '',function($query)use($where){
|
->when(isset($where['is_trader']) && $where['is_trader'] !== '',function($query)use($where){
|
||||||
$merId = app()->make(MerchantRepository::class)->search([
|
$merId = app()->make(MerchantRepository::class)->search([
|
||||||
'is_trader' => $where['is_trader'],
|
'is_trader' => $where['is_trader'],
|
||||||
'status' => 1,
|
'status' => 1,//状态正常
|
||||||
'mer_state' => 1,
|
'mer_state' => 1,//商户开启
|
||||||
'is_del' => 1,
|
'is_del' => 1,//
|
||||||
])->column('mer_id');
|
])->column('mer_id');
|
||||||
|
|
||||||
$query->whereIn('P.mer_id',$merId);
|
$query->whereIn('P.mer_id',$merId);
|
||||||
|
@ -154,6 +154,19 @@ class SpuRepository extends BaseRepository
|
|||||||
if (!empty($this->orderField)) {
|
if (!empty($this->orderField)) {
|
||||||
$this->dao->orderField = $this->orderField;
|
$this->dao->orderField = $this->orderField;
|
||||||
}
|
}
|
||||||
|
//取消数量排序
|
||||||
|
$where['order_remark'] = "none";
|
||||||
|
$queryCount = $this->dao->search($where);
|
||||||
|
// $queryCount->with([
|
||||||
|
// 'merchant' => function ($queryCount) {
|
||||||
|
// $queryCount->field($this->merchantFiled)->with(['type_names', 'street_names']);
|
||||||
|
// },
|
||||||
|
// 'issetCoupon',
|
||||||
|
// 'product.attrValue',
|
||||||
|
// ]);
|
||||||
|
unset($where['order_remark']);
|
||||||
|
$count = $queryCount->count();
|
||||||
|
|
||||||
$query = $this->dao->search($where);
|
$query = $this->dao->search($where);
|
||||||
|
|
||||||
$query->with([
|
$query->with([
|
||||||
@ -164,7 +177,7 @@ class SpuRepository extends BaseRepository
|
|||||||
'product.attrValue',
|
'product.attrValue',
|
||||||
]);
|
]);
|
||||||
$productMake = app()->make(ProductRepository::class);
|
$productMake = app()->make(ProductRepository::class);
|
||||||
$count = $query->count();
|
// $count = $query->count();
|
||||||
if ($limit == 0) {
|
if ($limit == 0) {
|
||||||
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
||||||
->each(function ($item) use ($is_sku, $productMake, $userInfo,$where) {
|
->each(function ($item) use ($is_sku, $productMake, $userInfo,$where) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user