调整商品毛利率计算

This commit is contained in:
luofei 2024-02-28 14:27:43 +08:00
parent 717a1c2a1c
commit 7f38a8183e

View File

@ -24,8 +24,8 @@ class SetProductProfitRateListen extends TimerService implements ListenerInterfa
->limit(100) ->limit(100)
->select(); ->select();
foreach ($storeProducts as $storeProduct) { foreach ($storeProducts as $storeProduct) {
$storeProduct->profit_rate = bcdiv(bcsub($storeProduct->price, $storeProduct->procure_price, 2), $storeProduct->price, 2) * 100; $profitRate = bcdiv(bcsub($storeProduct->price, $storeProduct->procure_price, 2), $storeProduct->price, 2) * 100;
$storeProduct->save(); ProductAttrValue::where('unique', $storeProduct->unique)->update(['profit_rate' => $profitRate]);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
Log::info('定时任务更新商品利润率error => ' . $e->getMessage()); Log::info('定时任务更新商品利润率error => ' . $e->getMessage());