Przeglądaj źródła

商家详情接口修复

shish 5 lat temu
rodzic
commit
3aa289f806

+ 2 - 2
app/ghs/controllers/AdminController.php

@@ -2,8 +2,8 @@
 
 namespace ghs\controllers;
 
-use biz\admin\classes\AdminClass;
-use biz\admin\services\AdminService;
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\admin\services\AdminService;
 use biz\wx\services\WxOpenService;
 use common\components\util;
 use Yii;

+ 7 - 7
app/ghs/controllers/AdminRoleController.php

@@ -2,9 +2,9 @@
 
 namespace ghs\controllers;
 
-use biz\admin\classes\AdminClass;
-use biz\admin\services\AdminRoleService;
-use biz\admin\services\AdminService;
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\admin\services\AdminRoleService;
+use bizGhs\admin\services\AdminService;
 use common\components\jwt;
 use common\components\util;
 use Yii;
@@ -16,7 +16,7 @@ class AdminRoleController extends BaseController
 	//角色列表 shish 2019.12.9
 	public function actionList()
 	{
-		$list = AdminRoleService::getRoleList($this->merchantId);
+		$list = AdminRoleService::getRoleList($this->ghsId);
 		util::success($list);
 	}
 	
@@ -24,7 +24,7 @@ class AdminRoleController extends BaseController
 	public function actionAdd()
 	{
 		$post = Yii::$app->request->post();
-		$post['merchantId'] = $this->merchantId;
+		$post['merchantId'] = $this->ghsId;
 		$respond = AdminRoleService::addRole($post);
 		util::success($respond);
 	}
@@ -36,7 +36,7 @@ class AdminRoleController extends BaseController
 		$id = isset($post['id']) ? $post['id'] : 0;
 		unset($post['id']);
 		$role = AdminRoleService::getById($id);
-		AdminRoleService::valid($role, $this->merchantId);
+		AdminRoleService::valid($role, $this->ghsId);
 		AdminRoleService::updateRole($role, $post);
 		util::complete('修改成功');
 	}
@@ -46,7 +46,7 @@ class AdminRoleController extends BaseController
 	{
 		$id = Yii::$app->request->post('id', 0);
 		$role = AdminRoleService::getById($id);
-		AdminRoleService::valid($role, $this->merchantId);
+		AdminRoleService::valid($role, $this->ghsId);
 		AdminRoleService::deleteRole($role);
 		util::complete('删除成功');
 	}

+ 1 - 1
app/ghs/controllers/CouponController.php

@@ -2,7 +2,7 @@
 
 namespace ghs\controllers;
 
-use biz\admin\classes\AdminClass;
+use bizGhs\admin\classes\AdminClass;
 use biz\admin\services\AdminService;
 use biz\promote\services\CouponAssetService;
 use biz\promote\services\CouponService;

+ 86 - 86
app/ghs/controllers/MerchantController.php

@@ -11,92 +11,92 @@ 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 = $this->ghs;
+		if (empty($merchant)) {
+			util::success([]);
+		}
+		$merchant = MerchantService::getInfo($this->ghs, $this->ghsExtend);
+		util::success($merchant);
+	}
 
-    //运费设置 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]);
-    }
-
+	//商家现有的会员等级 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->ghs;
+		$setId = $merchant['setId'];
+		$endId = 1;
+		$ids = SetAuthService::getAuthIdList($setId, $endId);
+		util::success(['ids' => $ids]);
+	}
+	
 	//商家信息 shish 2020.1.11
 	public function actionIntroduceShop()
 	{
@@ -111,5 +111,5 @@ class MerchantController extends BaseController
 		$data = ['merchantName' => $merchantName, 'smallLogoUrl' => $smallLogoUrl, 'id' => $id, 'logoUrl' => $logoUrl, 'fullAddress' => '暂无'];
 		util::success($data);
 	}
-
+	
 }

+ 13 - 11
biz-ghs/admin/classes/AdminClass.php

@@ -47,7 +47,7 @@ class AdminClass extends BaseClass
 	{
 		$detail = self::getById($id);
 		if (empty($detail)) {
-			util::fail('没有找到员工信息' . $id . '|');
+			util::fail('没有找到员工信息');
 		}
 		$list = self::groupAdminBaseInfo([$detail]);
 		return current($list);
@@ -68,7 +68,7 @@ class AdminClass extends BaseClass
 	public static function addAdmin($data)
 	{
 		$merchantId = $data['merchantId'];
-
+		
 		//验证角色
 		$roleId = $data['roleId'];
 		$role = AdminRoleClass::getById($roleId);
@@ -84,13 +84,13 @@ class AdminClass extends BaseClass
 		$respond = self::add($data);
 		return $respond;
 	}
-
+	
 	//获取商家的所有员工 shish 2019.12.9
 	public static function getAdminList($merchantId)
 	{
 		return self::getAllByCondition(['merchantId' => $merchantId, 'delStatus' => 0, 'status' => 1], null, '*');
 	}
-
+	
 	//获取商家所有员工的名字 shish 2019.12.9
 	public static function getAdminNameList($merchantId)
 	{
@@ -106,16 +106,18 @@ class AdminClass extends BaseClass
 	}
 	
 	//验证权限
-	public static function valid($admin, $merchantId)
+	public static function valid($admin, $ghsId)
 	{
 		if (empty($admin)) {
-			util::fail('员工无效');
+			util::fail('员工无效');
 		}
-		if ($admin['merchantId'] != $merchantId) {
+		$adminId = $admin['id'];
+		$staff = ShopAdminClass::getByCondition(['ghsId' => $ghsId, 'adminId' => $adminId]);
+		if (empty($staff)) {
 			util::fail('您没有权限操作此员工');
 		}
 	}
-	
+
 	//删除员工,需要考虑权限 shish 2019.12.9
 	public static function deleteAdmin($admin, $adminId)
 	{
@@ -186,7 +188,7 @@ class AdminClass extends BaseClass
 		}
 		return $admin;
 	}
-
+	
 	//更新员工信息 shish 2020.5.30
 	public static function updateAdmin($originalAdmin, $getAdminInfo)
 	{
@@ -225,7 +227,7 @@ class AdminClass extends BaseClass
 		if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
 			$data['isFull'] = 1;
 		}
-
+		
 		//更新头像
 		$merchantId = 0;
 		if (isset($originalAdmin['avatar']) == false || empty($originalAdmin['avatar'])) {
@@ -237,7 +239,7 @@ class AdminClass extends BaseClass
 				}
 			}
 		}
-
+		
 		self::updateById($adminId, $data);
 		$admin = self::getById($adminId);
 		return $admin;

+ 2 - 2
biz-ghs/admin/services/AdminService.php

@@ -120,9 +120,9 @@ class AdminService extends BaseService
     }
 
     //验证权限 shish 2019.12.9
-    public static function valid($admin, $merchantId)
+    public static function valid($admin, $ghsId)
     {
-        return AdminClass::valid($admin, $merchantId);
+        return AdminClass::valid($admin, $ghsId);
     }
 
     public static function getByMiniOpenId($miniOpenId)