moonsflyer 8 bulan lalu
induk
melakukan
a72e9b164c
3 mengubah file dengan 72 tambahan dan 46 penghapusan
  1. 2 0
      app/model/system/Menu.php
  2. 14 2
      app/shop/controller/BaseShop.php
  3. 56 44
      app/shop/controller/Index.php

+ 2 - 0
app/model/system/Menu.php

@@ -34,7 +34,9 @@ class Menu extends BaseModel
     {
 
         $data = json_encode([ $condition, $field, $order, $limit ]);
+
         $cache = Cache::get("getMenuList_" . $data);
+
         if (!empty($cache)) {
             return $this->success($cache);
         }

+ 14 - 2
app/shop/controller/BaseShop.php

@@ -65,6 +65,7 @@ class BaseShop extends Controller
         $this->checkLogin();
         //检测用户组
         $this->getGroupInfo();
+
         if ($this->app_module == 'store') {
 
             $this->replace = [
@@ -95,6 +96,8 @@ class BaseShop extends Controller
             }
 
         }
+
+
         //获取店铺信息
         $site_model = new Site();
         $shop_info = $site_model->getSiteInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_name,logo,seo_keywords,seo_description, create_time');
@@ -108,7 +111,6 @@ class BaseShop extends Controller
 
             $this->initBaseInfo();
         }
-
         // 加载自定义图标库
         $diy_view = new DiyViewModel();
         $diy_icon_url = $diy_view->getIconUrl()[ 'data' ];
@@ -138,6 +140,7 @@ class BaseShop extends Controller
         $this->getTopMenu();
         $menu_model = new Menu();
         $info_result = $menu_model->getMenuInfoByUrl($this->url, $this->app_module, $this->addon);
+
         $info = [];
         if (!empty($info_result[ "data" ])) {
             $info = $info_result[ "data" ];
@@ -150,6 +153,7 @@ class BaseShop extends Controller
             }
         }
         $this->menu_info = $info;
+
         $this->assign("menu_info", $info);
         if (!empty($this->crumbs)) {
             $this->crumbs = array_reverse($this->crumbs);
@@ -308,15 +312,23 @@ class BaseShop extends Controller
         if ($this->user_info[ 'is_admin' ] || $this->group_info[ 'is_system' ] == 1) {
             $menus = $menu_model->getMenuList([ [ 'app_module', "=", $this->app_module ] ], '*', 'level asc, sort asc');
         } else {
+
             $menus = $menu_model->getMenuList([ [ 'name', 'in', $this->group_info[ 'menu_array' ] ], [ 'app_module', "=", $this->app_module ] ], '*', 'level asc,sort asc');
+
             $control_menu = $menu_model->getMenuList([ [ 'is_control', '=', 0 ], [ 'app_module', "=", $this->app_module ] ], '*', 'sort asc');
+
             $menus[ 'data' ] = array_merge($control_menu[ 'data' ], $menus[ 'data' ]);
+//            dump( $menus[ 'data' ]);die;
             $keys = array_column($menus[ 'data' ], 'sort');
+
             if (!empty($keys)) {
                 array_multisort($keys, SORT_ASC, SORT_NUMERIC, $menus[ 'data' ]);
             }
         }
-
+        $user_info = $this->user_info;
+        if($user_info['is_admin'] ==0){
+            $menus[ 'data' ]['1']['is_show']=0;
+        }
         return $menus[ 'data' ];
     }
 

+ 56 - 44
app/shop/controller/Index.php

@@ -15,6 +15,7 @@ use addon\fenxiao\model\FenxiaoApply;
 use addon\fenxiao\model\FenxiaoWithdraw;
 use addon\niusms\model\Config as NiuSmsConfig;
 use addon\niusms\model\Sms as NiuSms;
+use addon\weapp\model\Config as WeappConfig;
 use addon\weapp\model\Config as WeappConfigModel;
 use app\model\goods\Goods as GoodsModel;
 use app\model\member\Member;
@@ -29,7 +30,6 @@ use Carbon\Carbon;
 use app\model\order\OrderRefund as OrderRefundModel;
 use think\facade\Cache;
 use addon\wechat\model\Config as WechatConfig;
-use addon\weapp\model\Config as WeappConfig;
 use addon\alipay\model\Config as AlipayConfig;
 use addon\wechatpay\model\Config as WechatpayConfig;
 use app\model\order\Order;
@@ -42,6 +42,8 @@ class Index extends BaseShop
      */
     public function index()
     {
+        $demain = $_SERVER['HTTP_HOST'];
+
         Cache::tag("cache_tablestat_shop")->clear();
         Cache::tag("cache_tablemember")->clear();
         Cache::tag("cache_tablegoods")->clear();
@@ -50,53 +52,63 @@ class Index extends BaseShop
         Cache::tag("cache_tablefenxiao_withdraw")->clear();
         $shop_info = $this->shop_info;
         $time = time();
-        $this->assign('shop_status', 1);
-
-        $this->handlePromotion();
-
-        //分销插件是否存在
-        $is_fenxiao = addon_is_exit('fenxiao', $this->site_id);
-        $this->assign('is_fenxiao', $is_fenxiao);
-
-        //基础统计信息
-        $today = Carbon::now();
-        $this->assign("today", $today);
-
-        // 牛云短信余额查询
-        if (addon_is_exit('niusms', $this->site_id)) {
-            $sms_config = ( new NiuSmsConfig() )->getSmsConfig($this->site_id)[ 'data' ];
-            if ($sms_config[ 'is_use' ]) {
-                $account_info = ( new NiuSms() )->getChildAccountInfo([
-                    'username' => $sms_config[ 'value' ][ 'username' ],
-                ]);
-                $this->assign('sms_num', $account_info[ 'data' ][ 'balance' ] ?? 0);
-            }
-        }
-        $this->assign('guide_close', cookie('guideClose'));
-        if (!cookie('guideClose')) {
-            $goods = ( new GoodsModel() )->getGoodsInfo([ [ 'site_id', '=', $this->site_id ] ], 'goods_id')[ 'data' ];
-            $this->assign('goods_complete', !empty($goods));
-
-            $wechat_config = ( new WechatConfig() )->getWechatConfig($this->site_id)[ 'data' ][ 'value' ];
-            $this->assign('wechat_complete', !empty($wechat_config));
-            if (addon_is_exit('weapp', $this->site_id)) {
-                $weapp_config = ( new WeappConfig() )->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
-                $this->assign('weapp_complete', !empty($weapp_config));
-            } else {
-                $this->assign('weapp_complete', false);
+        $user_info = $this->user_info;
+        if($user_info['is_admin']){
+            $this->assign('shop_status', 1);
+
+            $this->handlePromotion();
+
+            //分销插件是否存在
+            $is_fenxiao = addon_is_exit('fenxiao', $this->site_id);
+            $this->assign('is_fenxiao', $is_fenxiao);
+
+            //基础统计信息
+            $today = Carbon::now();
+            $this->assign("today", $today);
+
+            // 牛云短信余额查询
+            if (addon_is_exit('niusms', $this->site_id)) {
+                $sms_config = ( new NiuSmsConfig() )->getSmsConfig($this->site_id)[ 'data' ];
+                if ($sms_config[ 'is_use' ]) {
+                    $account_info = ( new NiuSms() )->getChildAccountInfo([
+                        'username' => $sms_config[ 'value' ][ 'username' ],
+                    ]);
+                    $this->assign('sms_num', $account_info[ 'data' ][ 'balance' ] ?? 0);
+                }
             }
+            $this->assign('guide_close', cookie('guideClose'));
+            if (!cookie('guideClose')) {
+                $goods = ( new GoodsModel() )->getGoodsInfo([ [ 'site_id', '=', $this->site_id ] ], 'goods_id')[ 'data' ];
+                $this->assign('goods_complete', !empty($goods));
+
+                $wechat_config = ( new WechatConfig() )->getWechatConfig($this->site_id)[ 'data' ][ 'value' ];
+                $this->assign('wechat_complete', !empty($wechat_config));
+                if (addon_is_exit('weapp', $this->site_id)) {
+                    $weapp_config = ( new WeappConfig() )->getWeappConfig($this->site_id)[ 'data' ][ 'value' ];
+                    $this->assign('weapp_complete', !empty($weapp_config));
+                } else {
+                    $this->assign('weapp_complete', false);
+                }
 
-            $alipay_config = addon_is_exit('alipay', $this->site_id) ? ( new AlipayConfig() )->getPayConfig($this->site_id)[ 'data' ][ 'value' ] : [];
-            $wechatpay_config = [];
-            $wechatpay_config = ( new WechatpayConfig() )->getPayConfig($this->site_id)[ 'data' ][ 'value' ];
-            unset($wechatpay_config[ 'transfer_type' ]);
-            $this->assign('pay_complete', ( !( empty($alipay_config) ) || !( empty($wechatpay_config) ) ));
+                $alipay_config = addon_is_exit('alipay', $this->site_id) ? ( new AlipayConfig() )->getPayConfig($this->site_id)[ 'data' ][ 'value' ] : [];
+                $wechatpay_config = [];
+                $wechatpay_config = ( new WechatpayConfig() )->getPayConfig($this->site_id)[ 'data' ][ 'value' ];
+                unset($wechatpay_config[ 'transfer_type' ]);
+                $this->assign('pay_complete', ( !( empty($alipay_config) ) || !( empty($wechatpay_config) ) ));
 
-            $this->assign('site_complete', !empty($this->shop_info[ 'logo' ]));
+                $this->assign('site_complete', !empty($this->shop_info[ 'logo' ]));
+            }
+            $this->init();
+            $this->assign('img_extension_error', config('upload.driver') == 'imagick' && !extension_loaded('imagick'));
+            return $this->fetch("index/index");
+        }else{
+            $demain = $_SERVER['HTTP_HOST'];
+            var_dump($demain);
+//            header('Localtion:zhongshen.demo.com/shop/stat/shop.html');
+            header('Location:../../shop/stat/shop');
+            exit;
         }
-        $this->init();
-        $this->assign('img_extension_error', config('upload.driver') == 'imagick' && !extension_loaded('imagick'));
-        return $this->fetch("index/index");
+
     }
 
     private function init()