create_multi_groupon_tables.php.stub 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateMultiGrouponTables extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. $prefix = config('ibrand.app.database.prefix', 'ibrand_');
  15. if (!Schema::hasTable($prefix . 'multi_groupon')) {
  16. Schema::create($prefix . 'multi_groupon', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->string('title'); //活动标题
  19. $table->integer('goods_id');//商品ID
  20. $table->integer('number'); //成团人数
  21. $table->decimal('price', 15, 2); //团购价格
  22. $table->integer('rate')->default(0); //佣金比例
  23. $table->integer('sort')->default(9); //排序
  24. $table->tinyInteger('get_point')->default(0); //是否可获得积分:0 否;1是
  25. $table->tinyInteger('status')->default(1); //状态:0 无效;1有效
  26. $table->dateTime('starts_at'); //开始时间
  27. $table->dateTime('ends_at'); //结束时间
  28. $table->string('tags')->nullable(); //活动标签,预留
  29. $table->timestamps();
  30. });
  31. }
  32. if (!Schema::hasTable($prefix . 'multi_groupon_items')) {
  33. Schema::create($prefix . 'multi_groupon_items', function (Blueprint $table) {
  34. $table->increments('id');
  35. $table->integer('multi_groupon_id');
  36. $table->integer('multi_groupon_goods_id');
  37. $table->timestamp('starts_at')->nullable(); //开团时间
  38. $table->timestamp('ends_at')->nullable(); //结束时间
  39. $table->timestamp('complete_time')->nullable(); //成团时间
  40. $table->tinyInteger('status')->default(0); //是否已成团:0 未成团,1 已成团,2 已失效(时间到期)
  41. $table->timestamps();
  42. });
  43. }
  44. if (!Schema::hasTable($prefix . 'multi_groupon_users')) {
  45. Schema::create($prefix . 'multi_groupon_users', function (Blueprint $table) {
  46. $table->increments('id');
  47. $table->integer('user_id');
  48. $table->integer('multi_groupon_id');
  49. $table->integer('multi_groupon_items_id')->nullable();
  50. $table->integer('order_id');
  51. $table->text('meta'); //用户数据,json格式
  52. $table->tinyInteger('is_leader')->default(0); //是否是团长
  53. $table->tinyInteger('status')->default(0); //参与状态,付款之后更改该状态
  54. $table->string('share_img')->nullable(); //分享海报
  55. $table->timestamps();
  56. });
  57. }
  58. if (!Schema::hasTable($prefix . 'promotion_goods_relation')) {
  59. Schema::create($prefix . 'promotion_goods_relation', function (Blueprint $table) {
  60. $table->increments('id');
  61. $table->integer('goods_id');
  62. $table->string('origin_type'); //活动类型,如groupon,seckill等
  63. $table->text('origin_id'); //活动对应的ID
  64. $table->timestamps();
  65. });
  66. }
  67. if (!Schema::hasTable($prefix . 'merchant_pay')) {
  68. Schema::create($prefix .'merchant_pay', function (Blueprint $table) {
  69. $table->increments('id');
  70. $table->string('origin_type'); //打款类型:REFUND 退款;COMMISSION 分销佣金
  71. $table->integer('origin_id');
  72. $table->string('channel')->default('wechat'); //打款渠道:wechat 微信; alipay 支付宝
  73. $table->integer('channel_id')->default(0); //如果是REFUND,记录el_refund_amount 的ID
  74. $table->string('partner_trade_no'); //打款编号
  75. $table->string('payment_no')->nullable(); //交易流水号
  76. $table->integer('amount'); //金额
  77. $table->string('status'); //打款状态:SUCCESS FAIL
  78. $table->string('error_code')->nullable(); //失败状态码:NAME_MISMATCH
  79. $table->string('err_code_des')->nullable(); //失败描述:真实姓名不一致
  80. $table->dateTime('payment_time')->nullable(); //成功打款时间
  81. $table->integer('user_id'); //用户ID
  82. $table->integer('admin_id'); //操作人ID
  83. $table->timestamps();
  84. });
  85. }
  86. if (!Schema::hasTable($prefix . 'order_special_type')) {
  87. Schema::create($prefix .'order_special_type', function (Blueprint $table) {
  88. $table->increments('id');
  89. $table->integer('order_id')->unsigned()->nullable();
  90. $table->string('origin_type')->nullable(); //类型
  91. $table->integer('origin_id')->default(0);
  92. $table->timestamps();
  93. $table->softDeletes();
  94. });
  95. }
  96. }
  97. /**
  98. * Reverse the migrations.
  99. *
  100. * @return void
  101. */
  102. public function down()
  103. {
  104. $prefix = config('ibrand.app.database.prefix', 'ibrand_');
  105. Schema::dropIfExists($prefix . 'multi_groupon');
  106. Schema::dropIfExists($prefix . 'multi_groupon_items');
  107. Schema::dropIfExists($prefix . 'multi_groupon_users');
  108. Schema::dropIfExists($prefix . 'merchant_pay');
  109. Schema::dropIfExists($prefix . 'order_special_type');
  110. Schema::dropIfExists($prefix . 'promotion_goods_relation');
  111. }
  112. }