M240910140623AlterCensusMallPaymentSingleMonth.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\migrations;
  3. use common\enums\RabbitMqEnum;
  4. use common\listeners\census\OrderRefundListener;
  5. use yii\db\Migration;
  6. /**
  7. * 统计商城支付方式单月数据-添加退款金额统计
  8. * Class M240910140623AlterCensusMallPaymentSingleMonth
  9. */
  10. class M240910140623AlterCensusMallPaymentSingleMonth extends Migration
  11. {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function safeUp()
  16. {
  17. try {
  18. $sql = <<<SQL
  19. ALTER TABLE `qimall_census_mall_payment_single_month`
  20. ADD COLUMN `total_refund_money` decimal(12, 2) NOT NULL DEFAULT 0 COMMENT '退款金额' AFTER `total_pay_money`;
  21. SQL;
  22. $this->execute($sql);
  23. // 初始化退款月度统计
  24. \Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK_CENSUS, RabbitMqEnum::CENSUS_QUEUE, [], OrderRefundListener::class, 'initialSetMallRefundMonth');
  25. }catch (\Exception $e){
  26. }
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function safeDown()
  32. {
  33. echo "M240910140623AlterCensusMallPaymentSingleMonth cannot be reverted.\n";
  34. return false;
  35. }
  36. }