M230719014721InsertQimallCrontabTask.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace addons\CloudStock\console\migrations;
  3. use common\models\common\CrontabTask;
  4. use yii\db\Migration;
  5. /**
  6. * Class M230719014721InsertQimallCrontabTask
  7. */
  8. class M230719014721InsertQimallCrontabTask extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $res = CrontabTask::findOne(['command' => 'cloud-stock/index/team-reward']);
  17. if (empty($res)) {
  18. $sql = "INSERT INTO `qimall_crontab_task` ( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('云库存-云仓个人团队补货奖励', 'cloud-stock/index/team-reward', 2, '0 1 0 * * *', 0, 1, 1689665363, 1689665527);";
  19. $this->execute($sql);
  20. }
  21. $res = CrontabTask::findOne(['cloud-stock/index/pool-reward']);
  22. if (empty($res)) {
  23. $sql = "INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '云库存-平台分红池分红', 'cloud-stock/index/pool-reward', 2, '0 3 0 * * *', 0, 1, 1689665639, 1689665639);";
  24. $this->execute($sql);
  25. }
  26. } catch (\Exception $e) {
  27. }
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function safeDown()
  33. {
  34. echo "M230719014721InsertQimallCrontabTask 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 "M230719014721InsertQimallCrontabTask cannot be reverted.\n";
  45. return false;
  46. }
  47. */
  48. }