db->createCommand($sql)->execute(); if(!empty($res)) return ''; $this->createTable($table, [ 'id' => $this->primaryKey(), 'mall_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商城id'), 'store_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('门店id'), 'name' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券名称'), 'type' => $this->tinyInteger(1)->notNull()->defaultValue(2)->comment('优惠券类型,1:折扣,2:满减'), 'discount' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('折扣率'), 'discount_limit' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('折扣优惠金额上限'), 'min_price' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('最低消费金额'), 'sub_price' => $this->float('12,2')->notNull()->defaultValue(0.00)->comment('优惠金额'), 'total_count' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券总数量'), 'sort' => $this->integer(11)->notNull()->defaultValue(0)->comment('排序按升序排列'), 'expire_type' => $this->tinyInteger(1)->notNull()->defaultValue(2)->comment('到期类型:1=领取后n天过期,2=指定有效期,3=领取后n天生效,生效后m天过期'), 'expire_day' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效天数,expire_type=1和3时'), 'effect_days' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('领取到生效之间间隔的天数(领取后n天生效)'), 'begin_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效期开始时间'), 'end_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('有效期开始时间'), 'appoint_type' => $this->tinyInteger()->notNull()->defaultValue(3)->comment('1 指定分类 2 指定商品 3全部'), 'rule' => $this->text()->comment('使用说明'), 'is_remind' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启提醒'), 'remind_days' => $this->tinyInteger(1)->notNull()->defaultValue(3)->comment('提前提醒天数(到期前多少天提醒),is_remind=1 时有效'), 'is_receive_limit' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否限制领取'), 'receive_count' => $this->integer(11)->notNull()->defaultValue(1)->comment('每人可以领取的数量,is_receive_limit=1时有意义'), 'is_member' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否指定会员等级'), 'is_original_use' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否原价购买使用(如果是,则只有原价购买商品时可以使用该优惠券)'), 'is_public_receive' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('是否公开领取,公开领取的优惠券会展示在商品详情页'), 'is_giving' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('启用优惠券转送功能:0-否;1-是;'), 'coupon_status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('优惠券状态,1:未开始,2:领取中,3:已过期,4:已失效(后台操作失效)'), 'is_giving_reward' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启转赠奖励,开启后转赠优惠券自己可以获得额外奖励;is_giving=1 时有效'), 'is_consume_reward' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开启使用奖励,开启后使用该优惠券可以获得额外奖励;is_giving=1 时有效'), 'is_open_screen' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否开屏显示'), 'open_screen_frequency' => $this->integer(11)->notNull()->defaultValue(1)->comment('开屏频率'), 'qrcode_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享二维码保存路径,二维码包含内容:页面路径+优惠券id'), 'poster_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享海报图片保存路径'), 'video_url' => $this->string(255)->notNull()->defaultValue('')->comment('优惠券分享海报图片保存路径'), 'first_frame' => $this->string(255)->notNull()->defaultValue('')->comment('首帧'), 'watch_times' => $this->integer(11)->notNull()->defaultValue(0)->comment('观看多少秒领取成功'), 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'), 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'), 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'), ]); $this->addCommentOnTable($table,'优惠券'); } /** * {@inheritdoc} */ public function safeDown() { echo "M220906024256QimallAddonsStoreCoupon cannot be reverted.\n"; return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "M220906024256QimallAddonsStoreCoupon cannot be reverted.\n"; return false; } */ }