This commit is contained in:
Your Name
2026-03-11 09:49:47 +08:00
parent 02ae537b4c
commit 38ad60f4bb
290 changed files with 36917 additions and 123 deletions
@@ -0,0 +1,69 @@
<?php
use think\migration\Migrator;
use think\migration\Migration;
class CreateOrderTables extends Migration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.io/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* log all of them to the migrations log:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
* addTimestamps
* update
* delete
* dropTable
* truncateTable
* addSoftDelete
*/
public function change()
{
// 订单表
$table = $this->table('la_order', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci', 'comment' => '订单表']);
$table->addColumn('order_no', 'string', ['limit' => 50, 'comment' => '订单号'])
->addColumn('patient_id', 'integer', ['comment' => '患者ID'])
->addColumn('creator_id', 'integer', ['comment' => '创建人ID(推广ID'])
->addColumn('order_type', 'tinyinteger', ['comment' => '订单类型 1-挂号费 2-问诊费 3-药品费用'])
->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '订单金额'])
->addColumn('status', 'tinyinteger', ['default' => 1, 'comment' => '订单状态 1-待支付 2-已支付 3-已取消 4-已退款'])
->addColumn('payment_method', 'string', ['limit' => 20, 'null' => true, 'comment' => '支付方式 alipay-支付宝 wechat-微信 bank-银行卡'])
->addColumn('payment_time', 'datetime', ['null' => true, 'comment' => '支付时间'])
->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'comment' => '备注'])
->addColumn('create_time', 'datetime', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addColumn('update_time', 'datetime', ['default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->addColumn('delete_time', 'datetime', ['null' => true, 'comment' => '删除时间'])
->addIndex(['order_no'], ['unique' => true])
->addIndex(['patient_id'])
->addIndex(['creator_id'])
->addIndex(['status'])
->addIndex(['create_time'])
->create();
// 订单详情表
$table = $this->table('la_order_detail', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci', 'comment' => '订单详情表']);
$table->addColumn('order_id', 'integer', ['comment' => '订单ID'])
->addColumn('related_type', 'string', ['limit' => 20, 'comment' => '关联类型 appointment-挂号 diagnosis-问诊 medicine-药品'])
->addColumn('related_id', 'integer', ['comment' => '关联ID'])
->addColumn('quantity', 'integer', ['default' => 1, 'comment' => '数量'])
->addColumn('unit_price', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '单价'])
->addColumn('total_price', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '总价'])
->addColumn('create_time', 'datetime', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addIndex(['order_id'])
->addIndex(['related_type', 'related_id'])
->create();
}
}