2020_08_21_145711_create_order_table.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateOrderTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('order', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->string('order_sn', 20)->comment('订单编号');
  17. $table->unsignedInteger('user_id')->comment('操作人');
  18. $table->unsignedInteger('goods_id')->nullable()->comment('商品ID');
  19. $table->unsignedInteger('coupon_id')->nullable()->comment('优惠券ID');
  20. $table->unsignedInteger('origin_amount')->default(0)->comment('订单原始总价,单位分');
  21. $table->unsignedInteger('amount')->default(0)->comment('订单总价,单位分');
  22. $table->dateTime('expired_at')->nullable()->comment('过期时间');
  23. $table->boolean('is_expire')->default(0)->comment('是否已过期:0-未过期、1-已过期');
  24. $table->boolean('pay_type')->default(0)->comment('支付渠道:0-余额、1-支付宝、2-QQ、3-微信、4-虚拟货币、5-paypal');
  25. $table->string('pay_way', 10)->default('balance')->comment('支付方式:balance、f2fpay、codepay、payjs、bitpayx等');
  26. $table->boolean('status')->default(0)->comment('订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成');
  27. $table->dateTime('created_at')->comment('创建时间');
  28. $table->dateTime('updated_at')->comment('最后更新时间');
  29. $table->index(['user_id', 'goods_id', 'is_expire', 'status'], 'idx_order_search');
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. *
  35. * @return void
  36. */
  37. public function down()
  38. {
  39. Schema::dropIfExists('order');
  40. }
  41. }