M230816060159InsertQimallCrontabTask.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace addons\LuckyGroup\console\migrations;
  3. use common\models\common\CrontabTask;
  4. use yii\db\Migration;
  5. /**
  6. * Class M230816060159InsertQimallCrontabTask
  7. */
  8. class M230816060159InsertQimallCrontabTask extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $res = CrontabTask::findOne(['name' => '幸运拼团每日自动重置参团会员参团次数']);
  17. if (empty($res)) {
  18. $sql = "INSERT INTO `qimall_crontab_task` ( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '幸运拼团每日自动重置参团会员参团次数', 'lucky-group/lucky-group-crontab/update-attend-times', 2, '0 10 0 * * *', 0, 1, 1652930361, 1655175672);";
  19. $this->execute($sql);
  20. }
  21. $res = CrontabTask::findOne(['name' => '幸运拼团结算奖金池分红']);
  22. if (empty($res)) {
  23. $sql = "INSERT INTO `qimall_crontab_task` ( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '幸运拼团结算奖金池分红', 'lucky-group/lucky-group-crontab/bonus-pool-dividend-log', 2, '0 31 0 * * *', 0, 1, 1652930384, 1655175666);";
  24. $this->execute($sql);
  25. }
  26. } catch (\Exception $e) {
  27. }
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function safeDown()
  33. {
  34. echo "M230816060159InsertQimallCrontabTask cannot be reverted.\n";
  35. return false;
  36. }
  37. /*
  38. // Use up()/down() to run migration code without a transaction.
  39. public function up()
  40. {
  41. }
  42. public function down()
  43. {
  44. echo "M230816060159InsertQimallCrontabTask cannot be reverted.\n";
  45. return false;
  46. }
  47. */
  48. }