create_reduce_tables.php.stub 6.1 KB

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