M220906044921QimallAddonsStoreCouponUserRelate.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906034921QimallAddonsStoreCouponUserRelate
  6. */
  7. class M220906044921QimallAddonsStoreCouponUserRelate extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon_user_relate';
  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. 'from_type' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('类型:1:平台优惠券;2:门店优惠券'),
  23. 'user_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('用户id'),
  24. 'coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券id'),
  25. 'coupon_status' => $this->tinyInteger(1)->notNull()->defaultValue(2)->comment('优惠券状态,2:领取中,3:已过期,4:已失效(后台操作失效、转赠被领取后、使用之后)'),
  26. 'start_time' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券开始生效时间'),
  27. 'end_time' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券过期时间'),
  28. 'is_use' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否已使用:0=未使用,1=已使用'),
  29. 'is_giving' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否已赠送:0-否;1-是;'),
  30. 'giving_status' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('转赠状态,0:未转赠,1:转赠中,2:已被领取(转赠完成)'),
  31. 'receive_type' => $this->string(255)->notNull()->defaultValue('')->comment('获取方式,如"商品详情页领取'),
  32. 'receive_platform' => $this->string(25)->notNull()->defaultValue('')->comment('领取来源,从哪个平台领取的,wechat:微信,mp-wx:微信小程序,h5,app,work-wx:企业微信'),
  33. 'is_force_failure' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否强制失效,后台操作用户已领取的优惠券失效'),
  34. 'is_send_reward' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否已经发放优惠券奖励,1:是,0:否'),
  35. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  36. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  37. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  38. ]);
  39. $this->addCommentOnTable($table,'用户优惠券表');
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function safeDown()
  45. {
  46. echo "M220906034921QimallAddonsStoreCouponUserRelate cannot be reverted.\n";
  47. return false;
  48. }
  49. /*
  50. // Use up()/down() to run migration code without a transaction.
  51. public function up()
  52. {
  53. }
  54. public function down()
  55. {
  56. echo "M220906034921QimallAddonsStoreCouponUserRelate cannot be reverted.\n";
  57. return false;
  58. }
  59. */
  60. }