M220906024256QimallAddonsStoreCoupon.php 5.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906024256QimallAddonsStoreCoupon
  6. */
  7. class M220906024256QimallAddonsStoreCoupon extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon';
  15. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if(!empty($res)) return '';
  18. $this->createTable($table, [
  19. 'id' => $this->primaryKey(),
  20. 'mall_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商城id'),
  21. 'store_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('门店id'),
  22. 'name' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券名称'),
  23. 'type' => $this->tinyInteger(1)->notNull()->defaultValue(2)->comment('优惠券类型,1:折扣,2:满减'),
  24. 'discount' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('折扣率'),
  25. 'discount_limit' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('折扣优惠金额上限'),
  26. 'min_price' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('最低消费金额'),
  27. 'sub_price' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('优惠金额'),
  28. 'total_count' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券总数量'),
  29. 'sort' => $this->integer(11)->notNull()->defaultValue(0)->comment('排序按升序排列'),
  30. 'expire_type' => $this->tinyInteger(1)->notNull()->defaultValue(2)->comment('到期类型:1=领取后n天过期,2=指定有效期,3=领取后n天生效,生效后m天过期'),
  31. 'expire_day' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效天数,expire_type=1和3时'),
  32. 'effect_days' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('领取到生效之间间隔的天数(领取后n天生效)'),
  33. 'begin_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效期开始时间'),
  34. 'end_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效期开始时间'),
  35. 'appoint_type' => $this->tinyInteger()->notNull()->defaultValue(3)->comment('1 指定分类 2 指定商品 3全部'),
  36. 'rule' => $this->text()->comment('使用说明'),
  37. 'is_remind' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启提醒'),
  38. 'remind_days' => $this->tinyInteger(1)->notNull()->defaultValue(3)->comment('提前提醒天数(到期前多少天提醒),is_remind=1 时有效'),
  39. 'is_receive_limit' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否限制领取'),
  40. 'receive_count' => $this->integer(11)->notNull()->defaultValue(1)->comment('每人可以领取的数量,is_receive_limit=1时有意义'),
  41. 'is_member' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否指定会员等级'),
  42. 'is_original_use' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否原价购买使用(如果是,则只有原价购买商品时可以使用该优惠券)'),
  43. 'is_public_receive' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('是否公开领取,公开领取的优惠券会展示在商品详情页'),
  44. 'is_giving' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('启用优惠券转送功能:0-否;1-是;'),
  45. 'coupon_status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('优惠券状态,1:未开始,2:领取中,3:已过期,4:已失效(后台操作失效)'),
  46. 'is_giving_reward' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启转赠奖励,开启后转赠优惠券自己可以获得额外奖励;is_giving=1 时有效'),
  47. 'is_consume_reward' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启使用奖励,开启后使用该优惠券可以获得额外奖励;is_giving=1 时有效'),
  48. 'is_open_screen' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开屏显示'),
  49. 'open_screen_frequency' => $this->integer(11)->notNull()->defaultValue(1)->comment('开屏频率'),
  50. 'qrcode_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享二维码保存路径,二维码包含内容:页面路径+优惠券id'),
  51. 'poster_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享海报图片保存路径'),
  52. 'video_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享海报图片保存路径'),
  53. 'first_frame' => $this->string(255)->notNull()->defaultValue('')->comment('首帧'),
  54. 'watch_times' => $this->integer(11)->notNull()->defaultValue(0)->comment('观看多少秒领取成功'),
  55. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  56. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  57. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  58. ]);
  59. $this->addCommentOnTable($table,'优惠券');
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function safeDown()
  65. {
  66. echo "M220906024256QimallAddonsStoreCoupon cannot be reverted.\n";
  67. return false;
  68. }
  69. /*
  70. // Use up()/down() to run migration code without a transaction.
  71. public function up()
  72. {
  73. }
  74. public function down()
  75. {
  76. echo "M220906024256QimallAddonsStoreCoupon cannot be reverted.\n";
  77. return false;
  78. }
  79. */
  80. }