MenuController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace addons\Store\client\controllers;
  3. use addons\ReservationService\common\services\BackendService;
  4. use addons\Store\common\models\StoreMenu;
  5. use common\enums\AddonsEnum;
  6. use common\enums\StatusEnum;
  7. use common\models\mall\MallAddons;
  8. use Yii;
  9. class MenuController extends BaseController{
  10. /**
  11. * 门店菜单
  12. * @Author bing
  13. * @DateTime 2022-04-26 18:06:53
  14. * @copyright: Copyright (c) 2022 广东七件事集团
  15. * @return void
  16. */
  17. public function actionList(){
  18. $route = Yii::$app->request->get('route','');
  19. $list = StoreMenu::lists(['where'=>[['is_addon' => StatusEnum::DISABLED, 'status'=>StatusEnum::ENABLED]]]);
  20. $menus = StoreMenu::getTreeMenu($list,0,$route,$this->mall['mall_sign']);
  21. if($this->store_id){
  22. $menus = StoreMenu::getFreezeMenu($menus,$this->store_id);
  23. }
  24. if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_RESERVATION_SERVICE)){
  25. $customText = BackendService::getCustomText($this->mall_id);
  26. foreach($menus as &$val){
  27. if ($val['url'] === 'store/client/reserve-data/index') {
  28. foreach ($val['children'] as &$child) {
  29. if($child['url'] === 'store/client/reserve-staff/index'){
  30. $child['label'] = BackendService::replaceTextToCustomText($child['label'], $customText);
  31. $child['title'] = BackendService::replaceTextToCustomText($child['title'], $customText);
  32. break;
  33. }
  34. }
  35. unset($child);
  36. break;
  37. }
  38. }
  39. unset($val);
  40. }
  41. if (MallAddons::isInstall($this->mall_id, 'ReservationService') == 0){
  42. foreach($menus as $key => $val){
  43. //门店股东判断商城是否安装 预约服务插件
  44. if($val['url'] == 'store/client/reserve-data/index'){
  45. unset($menus[$key]);
  46. }
  47. }
  48. }
  49. if (MallAddons::isInstall($this->mall_id, 'StoreBoss') == 0){
  50. foreach($menus as $key => $val){
  51. //门店股东判断商城是否安装 门店股东插件
  52. if($val['url'] == 'store/client/store-boss/index'){
  53. unset($menus[$key]);
  54. }
  55. }
  56. }
  57. if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_HI_GO) == 0){
  58. foreach($menus as $key => $val){
  59. //门店股东判断商城是否安装 海购插件
  60. if($val['url'] == 'store/client/merchant/profit-setting'){
  61. unset($menus[$key]);
  62. }
  63. }
  64. }
  65. $menus = array_values($menus);// 重新排序防止数组在前端变成对象
  66. return $this->success('ok',compact('menus'));
  67. }
  68. /**
  69. * 获取插件的菜单
  70. * @Author:lun
  71. * @Date:2023-12-19 15:50
  72. * @Copyright:copyright(c)2023 广东七件事集团
  73. * @return mixed|null
  74. */
  75. public function actionAddonsMenu(){
  76. $route = Yii::$app->request->get('route','');
  77. $addons_name = Yii::$app->request->get('addons_name','');
  78. if (empty($addons_name)) return $this->error('应用标识不能为空');
  79. $where[] = ['=', 'addons_name', $addons_name];
  80. $where[] = ['=', 'is_addon', StatusEnum::ENABLED];
  81. $where[] = ['=', 'status', StatusEnum::ENABLED];
  82. $list = StoreMenu::lists(['where'=>$where]);
  83. $menus = StoreMenu::getTreeMenu($list,0,$route);
  84. return $this->success('ok',compact('menus'));
  85. }
  86. }