金额/单价列精度提升到 8 位小数(展示仍两位),修复原始价格精度丢失导致的 1 分钱差异
This commit is contained in:
parent
05760bd0a5
commit
1ab9a45d1d
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
private const COLUMNS = [
|
||||
'opening_unit_price', 'opening_original_amount', 'adjusted_unit_price',
|
||||
'opening_amount', 'purchase_quantity', 'purchase_unit_price',
|
||||
'purchase_amount', 'weighted_average_unit_price',
|
||||
];
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$connection = (string) config('upstream_mirrors.connection', 'business_mirror');
|
||||
if (! Schema::connection($connection)->hasTable('product_monthly_weighted_average_rows')) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (self::COLUMNS as $column) {
|
||||
DB::connection($connection)->statement(
|
||||
"alter table `product_monthly_weighted_average_rows` modify `{$column}` decimal(24,8) null",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// 缩放回 4 位会丢失精度,这里保持不回退。
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user