55 lines
3.1 KiB
PHP
55 lines
3.1 KiB
PHP
<?php
|
||
|
||
use Illuminate\Database\Migrations\Migration;
|
||
use Illuminate\Database\Schema\Blueprint;
|
||
use Illuminate\Support\Facades\Schema;
|
||
|
||
return new class extends Migration
|
||
{
|
||
/**
|
||
* Run the migrations.
|
||
* 门店账单:采购单完成后按门店生成;周转筐/托盘与附加金额从门店订单迁入账单
|
||
* (store_order 的列变动已按约定折进 2026_07_23_030610 原迁移文件,本文件仅建账单表)
|
||
*/
|
||
public function up(): void
|
||
{
|
||
// 门店账单表(每个客户单独一张,商品金额由订单汇总不可修改)
|
||
if (! Schema::hasTable('bill')) {
|
||
Schema::create('bill', function (Blueprint $table) {
|
||
$table->increments('id')->comment('账单ID');
|
||
$table->string('bill_no', 32)->unique()->comment('账单编号');
|
||
$table->integer('purchase_id')->comment('关联采购单ID');
|
||
$table->integer('store_id')->comment('门店ID');
|
||
$table->date('bill_date')->comment('账单日期');
|
||
$table->decimal('product_amount', 10, 2)->default(0)->comment('商品金额(订单商品金额汇总,不可修改)');
|
||
$table->decimal('delivery_fee', 10, 2)->default(0)->comment('配送费(生成账单时填写)');
|
||
$table->integer('box_num')->default(0)->comment('周转筐数量');
|
||
$table->integer('tray_num')->default(0)->comment('周转托盘数量');
|
||
$table->decimal('box_price', 10, 2)->default(0)->comment('周转筐单价(生成时快照)');
|
||
$table->decimal('tray_price', 10, 2)->default(0)->comment('周转托盘单价(生成时快照)');
|
||
$table->decimal('added_amount', 10, 2)->default(0)->comment('附加金额(周转筐/托盘金额)');
|
||
$table->decimal('total_amount', 10, 2)->default(0)->comment('账单总金额 = 商品金额 + 配送费 + 附加金额');
|
||
$table->integer('status')->default(0)->comment('支付状态(0未支付 1已支付)');
|
||
$table->timestamp('paid_at')->nullable()->comment('付款时间(线下收款手动登记)');
|
||
$table->string('pay_remark', 255)->default('')->comment('付款备注(线下收款信息)');
|
||
$table->integer('paid_operator_id')->default(0)->comment('收款操作人(后台系统用户ID)');
|
||
$table->integer('operator_id')->default(0)->comment('生成人(后台系统用户ID)');
|
||
$table->string('remark', 255)->default('')->comment('备注');
|
||
$table->timestamps();
|
||
$table->unique(['purchase_id', 'store_id'], 'bill_purchase_store_unique');
|
||
$table->index(['store_id', 'bill_date'], 'bill_store_date_index');
|
||
$table->index(['status'], 'bill_status_index');
|
||
$table->comment('门店账单表(采购单完成后按门店生成)');
|
||
});
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Reverse the migrations.
|
||
*/
|
||
public function down(): void
|
||
{
|
||
Schema::dropIfExists('bill');
|
||
}
|
||
};
|