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