zarbox added 2
This commit is contained in:
@@ -28,18 +28,24 @@ class ProductPriceService
|
||||
|
||||
public static function syncFromReference(Product $product, int $basePrice, int $baseProfit = 0): void
|
||||
{
|
||||
$offsetPercent = self::offsetPercent($product);
|
||||
if (!Product::hasStoredPriceColumns()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Product::where('id', $product->id)->update([
|
||||
'price' => self::adjustedTotal($basePrice, $baseProfit, $offsetPercent),
|
||||
'price_profit' => 0,
|
||||
]);
|
||||
$offsetPercent = self::offsetPercent($product);
|
||||
$data = ['price' => self::adjustedTotal($basePrice, $baseProfit, $offsetPercent)];
|
||||
|
||||
if (\Illuminate\Support\Facades\Schema::hasColumn($product->getTable(), 'price_profit')) {
|
||||
$data['price_profit'] = 0;
|
||||
}
|
||||
|
||||
Product::where('id', $product->id)->update($data);
|
||||
}
|
||||
|
||||
/** وقتی فقط درصد در ادمین عوض میشود (بدون sync جدید) */
|
||||
public static function reapplyOffsetPercent(Product $product, float $newOffsetPercent, ?float $oldOffsetPercent = null): void
|
||||
{
|
||||
if (!Product::hasPriceOffsetColumn()) {
|
||||
if (!Product::hasPriceOffsetColumn() || !Product::hasStoredPriceColumns()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user