M230529103356InsertQimallMenu.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\migrations;
  3. use common\models\user\MemberLabel;
  4. use yii\db\Migration;
  5. /**
  6. * Class M230529103356InsertQimallMenu
  7. */
  8. class M230529103356InsertQimallMenu extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. // 生成菜单
  17. $sql = "UPDATE `qimall_menu` SET `title` = '会员标签',`pid` = 34, `level` = 1, `tree` = 'tr_0 tr_34 ' WHERE `id` = 2076;";
  18. $sql.= "INSERT INTO `qimall_menu`(`title`, `app_id`, `cate_id`, `addons_name`, `is_addon`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES
  19. ('会员分析', 'backend', 2, '', 0, 34, 'mall/user-member-label/index', '', 1, 1, 999, NULL, 'tr_0 tr_34', 1, 1682058236, 1682058236),
  20. ('价值标签', 'backend', 2, '', 0, 2076, 'mall/member-label/value-label', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  21. ('会员等级', 'backend', 2, '', 0, 2076, 'mall/member-label/user-level', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  22. ('渠道等级', 'backend', 2, '', 0, 2076, 'mall/member-label/agent-level', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076' , 1, 1682058236, 1682058236),
  23. ('复购标签', 'backend', 2, '', 0, 2076, 'mall/member-label/repurchase', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  24. ('活跃标签', 'backend', 2, '', 0, 2076, 'mall/member-label/active', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  25. ('收入标签', 'backend', 2, '', 0, 2076, 'mall/member-label/income', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  26. ('分享标签', 'backend', 2, '', 0, 2076, 'mall/member-label/share', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  27. ('退款标签', 'backend', 2, '', 0, 2076, 'mall/member-label/refund', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  28. ('会员年龄', 'backend', 2, '', 0, 2076, 'mall/member-label/user-age', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  29. ('推广标签', 'backend', 2, '', 0, 2076, 'mall/member-label/poppularize', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  30. ('领导标签', 'backend', 2, '', 0, 2076, 'mall/member-label/lead', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236),
  31. ('智能标签', 'backend', 2, '', 0, 2076, 'mall/user-label/index', '', 2, 1, 999, NULL, 'tr_0 tr_34 tr_2076', 1, 1682058236, 1682058236);";
  32. $this->execute($sql);
  33. MemberLabel::createRbacItems();// 生成标签权限
  34. } catch (\Exception $e) {
  35. \Yii::error('会员标签迁移失败:' . $e->getMessage());
  36. }
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function safeDown()
  42. {
  43. echo "M230529103356InsertQimallMenu cannot be reverted.\n";
  44. return false;
  45. }
  46. /*
  47. // Use up()/down() to run migration code without a transaction.
  48. public function up()
  49. {
  50. }
  51. public function down()
  52. {
  53. echo "M230529103356InsertQimallMenu cannot be reverted.\n";
  54. return false;
  55. }
  56. */
  57. }