| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace addons\Store\client\controllers;
- use addons\ReservationService\common\services\BackendService;
- use addons\Store\common\models\StoreMenu;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\models\mall\MallAddons;
- use Yii;
- class MenuController extends BaseController{
- /**
- * 门店菜单
- * @Author bing
- * @DateTime 2022-04-26 18:06:53
- * @copyright: Copyright (c) 2022 广东七件事集团
- * @return void
- */
- public function actionList(){
- $route = Yii::$app->request->get('route','');
- $list = StoreMenu::lists(['where'=>[['is_addon' => StatusEnum::DISABLED, 'status'=>StatusEnum::ENABLED]]]);
- $menus = StoreMenu::getTreeMenu($list,0,$route,$this->mall['mall_sign']);
- if($this->store_id){
- $menus = StoreMenu::getFreezeMenu($menus,$this->store_id);
- }
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_RESERVATION_SERVICE)){
- $customText = BackendService::getCustomText($this->mall_id);
- foreach($menus as &$val){
- if ($val['url'] === 'store/client/reserve-data/index') {
- foreach ($val['children'] as &$child) {
- if($child['url'] === 'store/client/reserve-staff/index'){
- $child['label'] = BackendService::replaceTextToCustomText($child['label'], $customText);
- $child['title'] = BackendService::replaceTextToCustomText($child['title'], $customText);
- break;
- }
- }
- unset($child);
- break;
- }
- }
- unset($val);
- }
- if (MallAddons::isInstall($this->mall_id, 'ReservationService') == 0){
- foreach($menus as $key => $val){
- //门店股东判断商城是否安装 预约服务插件
- if($val['url'] == 'store/client/reserve-data/index'){
- unset($menus[$key]);
- }
- }
- }
- if (MallAddons::isInstall($this->mall_id, 'StoreBoss') == 0){
- foreach($menus as $key => $val){
- //门店股东判断商城是否安装 门店股东插件
- if($val['url'] == 'store/client/store-boss/index'){
- unset($menus[$key]);
- }
- }
- }
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_HI_GO) == 0){
- foreach($menus as $key => $val){
- //门店股东判断商城是否安装 海购插件
- if($val['url'] == 'store/client/merchant/profit-setting'){
- unset($menus[$key]);
- }
- }
- }
- $menus = array_values($menus);// 重新排序防止数组在前端变成对象
- return $this->success('ok',compact('menus'));
- }
- /**
- * 获取插件的菜单
- * @Author:lun
- * @Date:2023-12-19 15:50
- * @Copyright:copyright(c)2023 广东七件事集团
- * @return mixed|null
- */
- public function actionAddonsMenu(){
- $route = Yii::$app->request->get('route','');
- $addons_name = Yii::$app->request->get('addons_name','');
- if (empty($addons_name)) return $this->error('应用标识不能为空');
- $where[] = ['=', 'addons_name', $addons_name];
- $where[] = ['=', 'is_addon', StatusEnum::ENABLED];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $list = StoreMenu::lists(['where'=>$where]);
- $menus = StoreMenu::getTreeMenu($list,0,$route);
- return $this->success('ok',compact('menus'));
- }
- }
|