Browse Source

兼容非管理员

shish 6 years ago
parent
commit
57872366de
1 changed files with 85 additions and 81 deletions
  1. 85 81
      app/shop/controllers/MerchantController.php

+ 85 - 81
app/shop/controllers/MerchantController.php

@@ -11,86 +11,90 @@ use common\components\util;
 
 class MerchantController extends BaseController
 {
-	
-	//运费设置 shish 2019.12.8
-	public function actionFreightSetting()
-	{
-		$get = Yii::$app->request->get();
-		$first = isset($get['first']) && is_numeric($get['first']) ? $get['first'] : 5;
-		$add = isset($get['add']) && is_numeric($get['add']) ? $get['add'] : 5;
-		MerchantExtendService::updateByCondition(['merchantId' => $this->merchantId], ['freeDistance' => $first, 'freight' => $add]);
-		util::complete();
-	}
-	
-	//商家信息 shish 2019.12.8
-	public function actionDetail()
-	{
-		$merchant = MerchantService::getInfo($this->merchant, $this->merchantExtend);
-		util::success($merchant);
-	}
-	
-	//商家现有的会员等级 shish 2019.12.12
-	public function actionMemberLevel()
-	{
-		$list = MerchantExtendService::getGradeList($this->merchantExtend, false, false);
-		$extend = $this->merchantExtend;
-		$gradeSwitch = isset($extend['gradeSwitch']) ? $extend['gradeSwitch'] : 1;
-		util::success(['list' => $list, 'gradeSwitch' => $gradeSwitch]);
-	}
-	
-	//会员等级更新 shish 2019.12.18
-	public function actionMemberLevelUpdate()
-	{
-		$extend = $this->merchantExtend;
-		if ($extend['gradeSwitch'] == 0) {
-			util::fail('会员等级已设置不能修改');
-		}
-		$list = Yii::$app->request->post('list');
-		if (empty($list) || is_array($list) == false) {
-			util::fail('请填写会员等级');
-		}
-		if (count($list) > 9) {
-			util::fail('最多可以设置9个等级');
-		}
-		$data = [];
-		foreach ($list as $key => $val) {
-			if ($key > 0) {
-				$currentGrowth = $val[1];
-				$previousGrowth = $list[$key - 1][1];
-				if ($currentGrowth <= $previousGrowth) {
-					util::fail('等级越高成长值也要越高');
-				}
-				$currentDiscount = $val[2];
-				$previousDiscount = $list[$key - 1][2];
-				if ($currentDiscount >= $previousDiscount) {
-					util::fail('等级越高折扣要越低');
-				}
-			}
-			$data[] = $val[0] . '_' . $val[1] . '_' . $val[2];
-		}
-		if (empty($data)) {
-			util::fail('请填写会员等级!');
-		}
-		$string = implode('I', $data);
-		MerchantExtendService::updateByCondition(['merchantId' => $this->merchantId], ['gradeList' => $string, 'gradeSwitch' => 0]);
-		util::complete('提交成功');
-	}
 
-	//常用链接
-	public function actionCommonUrl()
-	{
-		$list = MerchantService::getCommonUrlList();
-		util::success($list);
-	}
-	
-	//商家当前的权限id列表 shish 2020.1.23
-	public function actionAuth()
-	{
-		$merchant = $this->merchant;
-		$setId = $merchant['setId'];
-		$endId = 1;
-		$ids = SetAuthService::getAuthIdList($setId, $endId);
-		util::success(['ids' => $ids]);
-	}
-	
+    //运费设置 shish 2019.12.8
+    public function actionFreightSetting()
+    {
+        $get = Yii::$app->request->get();
+        $first = isset($get['first']) && is_numeric($get['first']) ? $get['first'] : 5;
+        $add = isset($get['add']) && is_numeric($get['add']) ? $get['add'] : 5;
+        MerchantExtendService::updateByCondition(['merchantId' => $this->merchantId], ['freeDistance' => $first, 'freight' => $add]);
+        util::complete();
+    }
+
+    //商家信息 shish 2019.12.8
+    public function actionDetail()
+    {
+        $merchant = $this->merchant;
+        if (empty($merchant)) {
+            util::success([]);
+        }
+        $merchant = MerchantService::getInfo($this->merchant, $this->merchantExtend);
+        util::success($merchant);
+    }
+
+    //商家现有的会员等级 shish 2019.12.12
+    public function actionMemberLevel()
+    {
+        $list = MerchantExtendService::getGradeList($this->merchantExtend, false, false);
+        $extend = $this->merchantExtend;
+        $gradeSwitch = isset($extend['gradeSwitch']) ? $extend['gradeSwitch'] : 1;
+        util::success(['list' => $list, 'gradeSwitch' => $gradeSwitch]);
+    }
+
+    //会员等级更新 shish 2019.12.18
+    public function actionMemberLevelUpdate()
+    {
+        $extend = $this->merchantExtend;
+        if ($extend['gradeSwitch'] == 0) {
+            util::fail('会员等级已设置不能修改');
+        }
+        $list = Yii::$app->request->post('list');
+        if (empty($list) || is_array($list) == false) {
+            util::fail('请填写会员等级');
+        }
+        if (count($list) > 9) {
+            util::fail('最多可以设置9个等级');
+        }
+        $data = [];
+        foreach ($list as $key => $val) {
+            if ($key > 0) {
+                $currentGrowth = $val[1];
+                $previousGrowth = $list[$key - 1][1];
+                if ($currentGrowth <= $previousGrowth) {
+                    util::fail('等级越高成长值也要越高');
+                }
+                $currentDiscount = $val[2];
+                $previousDiscount = $list[$key - 1][2];
+                if ($currentDiscount >= $previousDiscount) {
+                    util::fail('等级越高折扣要越低');
+                }
+            }
+            $data[] = $val[0] . '_' . $val[1] . '_' . $val[2];
+        }
+        if (empty($data)) {
+            util::fail('请填写会员等级!');
+        }
+        $string = implode('I', $data);
+        MerchantExtendService::updateByCondition(['merchantId' => $this->merchantId], ['gradeList' => $string, 'gradeSwitch' => 0]);
+        util::complete('提交成功');
+    }
+
+    //常用链接
+    public function actionCommonUrl()
+    {
+        $list = MerchantService::getCommonUrlList();
+        util::success($list);
+    }
+
+    //商家当前的权限id列表 shish 2020.1.23
+    public function actionAuth()
+    {
+        $merchant = $this->merchant;
+        $setId = $merchant['setId'];
+        $endId = 1;
+        $ids = SetAuthService::getAuthIdList($setId, $endId);
+        util::success(['ids' => $ids]);
+    }
+
 }