采购单优化

This commit is contained in:
liu
2026-08-12 14:38:20 +08:00
parent ce1f36b5b4
commit dadfdc1511
30 changed files with 1059 additions and 1441 deletions
@@ -44,6 +44,7 @@ return new class extends Migration
$table->increments('id')->comment('明细ID');
$table->integer('order_id')->comment('订单ID');
$table->integer('store_id')->comment('门店ID');
$table->integer('purchase_id')->default(0)->comment('归属采购单ID0=未归集)');
$table->integer('product_id')->comment('商品ID');
$table->integer('category_id')->default(0)->comment('分类ID');
$table->integer('supplier_id')->default(0)->comment('供应商ID');
@@ -61,6 +62,7 @@ return new class extends Migration
$table->string('remark', 255)->default('')->comment('门店下单备注');
$table->timestamps();
$table->index(['order_id'], 'store_order_item_order_index');
$table->index(['purchase_id'], 'store_order_item_purchase_index');
$table->index(['store_id', 'product_id'], 'store_order_item_store_product_index');
$table->comment('门店订货明细表');
});
@@ -30,50 +30,6 @@ return new class extends Migration
$table->comment('采购单表');
});
}
// 采购单明细表(C2/C3 按分类排序导出,C4 可修改,C5/C6 发送供应商及状态标记)
if (! Schema::hasTable('purchase_order_item')) {
Schema::create('purchase_order_item', function (Blueprint $table) {
$table->increments('id')->comment('明细ID');
$table->integer('purchase_id')->comment('采购单ID');
$table->integer('product_id')->comment('商品ID');
$table->integer('supplier_id')->default(0)->comment('供应商ID');
$table->string('product_name', 100)->comment('品名(快照)');
$table->string('product_spec', 100)->default('')->comment('规格/包规(快照)');
$table->decimal('price', 10, 2)->default(0)->comment('采购单价');
$table->decimal('quantity', 10, 2)->default(0)->comment('采购量');
$table->decimal('weight', 10, 3)->default(0)->comment('实际称重');
$table->decimal('amount', 10, 2)->default(0)->comment('采购金额');
$table->integer('sort')->default(0)->comment('排序(导出用)');
$table->integer('is_sent')->default(0)->comment('是否已发送供应商(1已发送 0未发送)');
$table->timestamp('sent_at')->nullable()->comment('发送时间');
$table->timestamp('supplier_confirmed_at')->nullable()->comment('供应商确认接单时间(NULL未确认)');
$table->string('remark', 255)->default('')->comment('备注');
$table->timestamps();
$table->index(['purchase_id'], 'purchase_order_item_purchase_index');
$table->index(['supplier_id', 'is_sent'], 'purchase_order_item_supplier_sent_index');
$table->comment('采购单明细表');
});
}
// 采购分摊表(D3 采购金额自动分配到各门店/各单品)
if (! Schema::hasTable('purchase_allocation')) {
Schema::create('purchase_allocation', function (Blueprint $table) {
$table->increments('id')->comment('分摊ID');
$table->integer('purchase_item_id')->comment('采购单明细ID');
$table->integer('order_item_id')->comment('门店订货明细ID');
$table->integer('store_id')->comment('分摊到的门店ID');
$table->integer('product_id')->comment('商品ID');
$table->decimal('quantity', 10, 2)->default(0)->comment('分摊数量');
$table->decimal('weight', 10, 3)->default(0)->comment('分摊重量');
$table->decimal('amount', 10, 2)->default(0)->comment('分摊金额');
$table->timestamps();
$table->index(['purchase_item_id'], 'purchase_allocation_item_index');
$table->index(['order_item_id'], 'purchase_allocation_order_item_index');
$table->index(['store_id'], 'purchase_allocation_store_index');
$table->comment('采购分摊表');
});
}
}
/**
@@ -82,7 +38,5 @@ return new class extends Migration
public function down(): void
{
Schema::dropIfExists('purchase_order');
Schema::dropIfExists('purchase_order_item');
Schema::dropIfExists('purchase_allocation');
}
};
@@ -40,7 +40,6 @@ return new class extends Migration
$table->increments('id')->comment('明细ID');
$table->integer('recon_id')->comment('财务对账单ID');
$table->integer('store_id')->comment('门店ID');
$table->integer('purchase_item_id')->default(0)->comment('采购单明细ID');
$table->integer('order_item_id')->default(0)->comment('门店订货明细ID');
$table->integer('product_id')->comment('商品ID');
$table->string('product_name', 100)->comment('品名(快照)');
-2
View File
@@ -194,8 +194,6 @@ class PermissionSeeder extends Seeder
['type' => 'rule', 'key' => 'purchase.order.update', 'name' => '修改'],
['type' => 'rule', 'key' => 'purchase.order.generate', 'name' => '生成采购单'],
['type' => 'rule', 'key' => 'purchase.order.export', 'name' => '导出'],
['type' => 'rule', 'key' => 'purchase.order.send', 'name' => '发送供应商'],
['type' => 'rule', 'key' => 'purchase.order.allocate', 'name' => '金额分摊'],
],
],
],