价格增加百分比上浮

This commit is contained in:
liu
2026-08-06 14:52:56 +08:00
parent 07b08c8915
commit c6f69c5c55
19 changed files with 958 additions and 93 deletions
@@ -36,6 +36,7 @@ class ProductModelFactory extends Factory
'shelf_life' => 0,
'stock' => 0,
'status' => ProductModel::STATUS_ON,
'cost_price' => 0,
'remark' => '',
];
}
@@ -24,6 +24,8 @@ class ProductPriceModelFactory extends Factory
'product_id' => 0,
'level_id' => 0,
'price' => number_format(random_int(100, 10000) / 100 + $seq * 0.01, 2, '.', ''),
'price_type' => ProductPriceModel::PRICE_TYPE_FIXED,
'percent' => 0,
];
}
}
@@ -42,6 +42,7 @@ return new class extends Migration
$table->integer('shelf_life')->default(0)->comment('保质期');
$table->integer('stock')->default(0)->comment('库存');
$table->integer('status')->default(1)->comment('状态(1上架 0下架)');
$table->decimal('cost_price', 10, 2)->default(0)->comment('成本价(元,成本百分比计价基数)');
$table->string('remark', 255)->default('')->comment('备注');
$table->timestamps();
$table->softDeletes();
@@ -57,7 +58,9 @@ return new class extends Migration
$table->increments('id')->comment('价格ID');
$table->integer('product_id')->comment('商品ID');
$table->integer('level_id')->comment('客户等级ID');
$table->decimal('price', 10, 2)->default(0)->comment('该等级下的商品单价');
$table->decimal('price', 10, 2)->default(0)->comment('该等级下的商品单价(固定价=实际单价;百分比=等价固定价)');
$table->unsignedTinyInteger('price_type')->default(0)->comment('计价类型(0固定价 1成本百分比)');
$table->decimal('percent', 5, 2)->default(0)->comment('成本上浮百分点(如 30 = 上浮30%,仅 price_type=1 生效)');
$table->timestamps();
$table->unique(['product_id', 'level_id'], 'product_price_product_level_unique');
$table->comment('商品等级价格表');