Files
xin-procurement/database/migrations/2026_08_14_000002_create_payment_table.php
2026-08-27 21:17:02 +08:00

50 lines
2.9 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* 支付记录:小程序端选择门店账单合并付款,提交汇款凭证,后台审核通过后账单批量置已支付
*/
public function up(): void
{
if (! Schema::hasTable('payment')) {
Schema::create('payment', function (Blueprint $table) {
$table->increments('id')->comment('支付记录ID');
$table->string('payment_no', 32)->unique()->comment('支付单号(在线支付时作为商户订单号 mer_order_id 上送网关)');
$table->integer('store_id')->comment('门店ID(提交门店即支付人)');
$table->decimal('amount', 10, 2)->default(0)->comment('支付金额(= 关联账单总金额合计,提交时快照)');
$table->integer('pay_type')->default(1)->comment('支付类型(1线下凭证支付 2旺铺在线支付)');
$table->integer('pay_method')->comment('支付方式(1微信 2支付宝 3对公汇款 4旺铺在线支付)');
$table->string('voucher_ids', 255)->default('')->comment('汇款凭证图片ID(逗号分隔,线下凭证支付)');
$table->integer('status')->default(0)->comment('状态(0待审核/待支付 1已通过/支付成功 2已拒绝/支付失败)');
$table->string('order_id', 64)->default('')->comment('旺铺平台订单号(网关返回)');
$table->string('trade_no', 64)->default('')->comment('通道交易流水号(支付成功返回)');
$table->string('openid', 64)->default('')->comment('付款人微信 openid(小程序在线支付)');
$table->timestamp('paid_at')->nullable()->comment('支付成功时间(网关交易时间)');
$table->text('pay_params')->nullable()->comment('旺铺下单返回的调起支付参数(JSON 快照)');
$table->string('remark', 255)->default('')->comment('门店备注');
$table->timestamp('audited_at')->nullable()->comment('审核时间');
$table->integer('auditor_id')->default(0)->comment('审核人(后台系统用户ID');
$table->string('audit_remark', 255)->default('')->comment('审核备注(拒绝原因)');
$table->timestamps();
$table->index(['store_id', 'status'], 'payment_store_status_index');
$table->index(['pay_type', 'status'], 'payment_type_status_index');
$table->comment('支付记录表(小程序合并付款:线下凭证后台审核 / 旺铺在线支付回调结账)');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('payment');
}
};