调整商品列表查询

This commit is contained in:
luofei 2024-02-26 15:46:00 +08:00
parent 55163e82b0
commit 981d63ba98
3 changed files with 7 additions and 6 deletions

View File

@ -200,11 +200,12 @@ class SpuDao extends BaseDao
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){ ->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
$query->where('svip_price_type','>',0)->where('mer_svip_status',1); $query->where('svip_price_type','>',0)->where('mer_svip_status',1);
}) })
->when(isset($where['exchange_rate']) && $where['exchange_rate'] !== '',function($query)use($where){ ->when(isset($where['deduction_rate']) && $where['deduction_rate'] !== '',function($query)use($where){
$productIds = ProductAttrValue::where('profit_rate', $where['exchange_rate'])->column('product_id'); $productIds = ProductAttrValue::where('profit_rate', $where['deduction_rate'])->column('product_id');
if (!empty($productIds)) { if (empty($productIds)) {
$query->whereIn('product_id', $productIds); $productIds = [0];
} }
$query->whereIn('S.product_id', $productIds);
}) })
; ;
return $query->order($order); return $query->order($order);

View File

@ -60,7 +60,7 @@ class StoreSpu extends BaseController
'mer_id', 'mer_id',
'filter_params', 'filter_params',
'mer_type_id', 'mer_type_id',
'exchange_rate' 'deduction_rate'
]); ]);
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['product_type'] = 0; $where['product_type'] = 0;

View File

@ -21,7 +21,7 @@ class SetProductProfitRateListen extends TimerService implements ListenerInterfa
$storeProducts = ProductAttrValue::where('profit_rate', 0) $storeProducts = ProductAttrValue::where('profit_rate', 0)
->where('procure_price', '>', 0) ->where('procure_price', '>', 0)
->whereRaw('price>procure_price') ->whereRaw('price>procure_price')
->limit(50) ->limit(100)
->select(); ->select();
foreach ($storeProducts as $storeProduct) { foreach ($storeProducts as $storeProduct) {
$storeProduct->profit_rate = bcdiv($storeProduct->procure_price, $storeProduct->price, 2) * 100; $storeProduct->profit_rate = bcdiv($storeProduct->procure_price, $storeProduct->price, 2) * 100;