M220906033139QimallAddonsStoreCouponStatistics.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906033139QimallAddonsStoreCouponStatistics
  6. */
  7. class M220906033139QimallAddonsStoreCouponStatistics extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon_statistics';
  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. 'coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券id'),
  23. 'received_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('已领取数量'),
  24. 'used_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('已使用数量'),
  25. 'giveing_times' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券被转赠的次数'),
  26. 'use_probability' => $this->float('5,2')->notNull()->defaultValue(0)->comment('优惠券使用率,等于领取数量比使用数量'),
  27. 'total_discount_amount' => $this->float('12,2')->notNull()->defaultValue(0)->comment('累计优惠金额'),
  28. 'receive_user_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('领券会员总数量'),
  29. 'use_user_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('用券会员总数量'),
  30. 'giving_user_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('转赠优惠券的会员总数量'),
  31. 'use_order_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('使用优惠券支付的订单总数量'),
  32. 'total_use_coupon_payed_amount' => $this->float('12,2')->notNull()->defaultValue(0)->comment('使用优惠券后实际支付的总金额'),
  33. 'total_payed_amount' => $this->float('12,2')->notNull()->defaultValue(0)->comment('使用优惠券支付的订单原价总金额'),
  34. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  35. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  36. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  37. ]);
  38. $this->addCommentOnTable($table,'优惠券相关数据统计记录表');
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function safeDown()
  44. {
  45. echo "M220906033139QimallAddonsStoreCouponStatistics cannot be reverted.\n";
  46. return false;
  47. }
  48. /*
  49. // Use up()/down() to run migration code without a transaction.
  50. public function up()
  51. {
  52. }
  53. public function down()
  54. {
  55. echo "M220906033139QimallAddonsStoreCouponStatistics cannot be reverted.\n";
  56. return false;
  57. }
  58. */
  59. }