diff --git a/database/migrations/2026_07_23_030608_create_store_table.php b/database/migrations/2026_07_23_030608_create_store_table.php index 23c49db..c66bbf6 100644 --- a/database/migrations/2026_07_23_030608_create_store_table.php +++ b/database/migrations/2026_07_23_030608_create_store_table.php @@ -18,6 +18,7 @@ return new class extends Migration $table->increments('id')->comment('等级ID'); $table->integer('icon_id')->nullable()->comment('等级图标ID'); $table->string('name', 50)->comment('等级名称(如:一级客户、二级客户)'); + $table->decimal('percent', 5, 2)->default(0)->comment('价格上浮比例(%,如 30 = 成本价上浮30%)'); $table->integer('sort')->default(0)->comment('排序'); $table->integer('status')->default(1)->comment('状态(1正常 0停用)'); $table->timestamps(); diff --git a/database/migrations/2026_07_23_030609_create_product_table.php b/database/migrations/2026_07_23_030609_create_product_table.php index d84aca4..fe16929 100644 --- a/database/migrations/2026_07_23_030609_create_product_table.php +++ b/database/migrations/2026_07_23_030609_create_product_table.php @@ -8,7 +8,7 @@ return new class extends Migration { /** * Run the migrations. - * 商品中心(A1-A3):商品分类、商品档案、客户等级价格体系 + * 商品中心(A1-A3):商品分类、商品档案(等级价格 = 成本价 × customer_level.percent 上浮) */ public function up(): void { @@ -50,21 +50,6 @@ return new class extends Migration $table->comment('商品表'); }); } - - // 商品等级价格表 - if (! Schema::hasTable('product_price')) { - Schema::create('product_price', function (Blueprint $table) { - $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->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('商品等级价格表'); - }); - } } /** @@ -74,6 +59,5 @@ return new class extends Migration { Schema::dropIfExists('product_category'); Schema::dropIfExists('product'); - Schema::dropIfExists('product_price'); } }; diff --git a/database/migrations/2026_08_17_000001_update_pricing_to_level_percent.php b/database/migrations/2026_08_17_000001_update_pricing_to_level_percent.php deleted file mode 100644 index 119ab45..0000000 --- a/database/migrations/2026_08_17_000001_update_pricing_to_level_percent.php +++ /dev/null @@ -1,53 +0,0 @@ -decimal('percent', 5, 2)->default(0)->after('name')->comment('价格上浮比例(%,如 30 = 成本价上浮30%)'); - }); - } - - // 商品等级价格表废弃(历史数据随表删除) - Schema::dropIfExists('product_price'); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - // 恢复商品等级价格表(结构回滚,历史数据不恢复) - if (! Schema::hasTable('product_price')) { - Schema::create('product_price', function (Blueprint $table) { - $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->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('商品等级价格表'); - }); - } - - if (Schema::hasColumn('customer_level', 'percent')) { - Schema::table('customer_level', function (Blueprint $table) { - $table->dropColumn('percent'); - }); - } - } -};