shish 5 سال پیش
والد
کامیت
069865d8b9

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

@@ -24,7 +24,7 @@ class AdminRoleController extends BaseController
 	public function actionAdd()
 	{
 		$post = Yii::$app->request->post();
-		$post['merchantId'] = $this->ghsId;
+		$post['ghsId'] = $this->ghsId;
 		$respond = AdminRoleService::addRole($post);
 		util::success($respond);
 	}

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

@@ -18,7 +18,7 @@ class MerchantController extends BaseController
 		$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]);
+		MerchantExtendService::updateByCondition(['merchantId' => $this->ghsId], ['freeDistance' => $first, 'freight' => $add]);
 		util::complete();
 	}
 	
@@ -36,8 +36,8 @@ class MerchantController extends BaseController
 	//商家现有的会员等级 shish 2019.12.12
 	public function actionMemberLevel()
 	{
-		$list = MerchantExtendService::getGradeList($this->merchantExtend, false, false);
-		$extend = $this->merchantExtend;
+		$list = MerchantExtendService::getGradeList($this->ghsExtend, false, false);
+		$extend = $this->ghsExtend;
 		$gradeSwitch = isset($extend['gradeSwitch']) ? $extend['gradeSwitch'] : 1;
 		util::success(['list' => $list, 'gradeSwitch' => $gradeSwitch]);
 	}
@@ -45,7 +45,7 @@ class MerchantController extends BaseController
 	//会员等级更新 shish 2019.12.18
 	public function actionMemberLevelUpdate()
 	{
-		$extend = $this->merchantExtend;
+		$extend = $this->ghsExtend;
 		if ($extend['gradeSwitch'] == 0) {
 			util::fail('会员等级已设置不能修改');
 		}
@@ -76,7 +76,7 @@ class MerchantController extends BaseController
 			util::fail('请填写会员等级!');
 		}
 		$string = implode('I', $data);
-		MerchantExtendService::updateByCondition(['merchantId' => $this->merchantId], ['gradeList' => $string, 'gradeSwitch' => 0]);
+		MerchantExtendService::updateByCondition(['merchantId' => $this->ghsId], ['gradeList' => $string, 'gradeSwitch' => 0]);
 		util::complete('提交成功');
 	}
 	

+ 12 - 1
app/ghs/controllers/ShopAdminController.php

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\admin\classes\ShopAdminClass;
 use biz\admin\services\AdminRoleService;
 use bizGhs\admin\services\ShopAdminService;
 use biz\wx\services\WxOpenService;
@@ -64,7 +65,7 @@ class ShopAdminController extends BaseController
 		ShopAdminService::updateById($id, ['status' => $status]);
 		util::complete();
 	}
-
+	
 	//员工列表 shish 2019.12.8
 	public function actionList()
 	{
@@ -76,4 +77,14 @@ class ShopAdminController extends BaseController
 		util::success($list);
 	}
 	
+	//获取员工信息 shish 2021.1.13
+	public function actionDetail()
+	{
+		$get = Yii::$app->request->get();
+		$id = isset($get['id']) ? $get['id'] : 0;
+		$respond = ShopAdminService::getShopAdmin($id);
+		ShopAdminClass::valid($respond, $this->ghsId);
+		util::success($respond);
+	}
+	
 }

+ 8 - 8
biz-ghs/admin/classes/AdminRoleClass.php

@@ -21,13 +21,13 @@ class AdminRoleClass extends BaseClass
 			util::fail('没有权限操作');
 		}
 	}
-	
+
 	//添加角色 shish 2019.12.10
 	public static function addRole($data)
 	{
 		$roleName = $data['roleName'];
-		$merchantId = $data['merchantId'];
-		$nameList = self::getNameList($merchantId);
+		$ghsId = $data['ghsId'];
+		$nameList = self::getNameList($ghsId);
 		if (in_array($roleName, $nameList)) {
 			util::fail('角色已经存在');
 		}
@@ -36,17 +36,17 @@ class AdminRoleClass extends BaseClass
 	}
 	
 	//获取商家角色列表 shish 2019.12.10
-	public static function getRoleList($merchantId)
+	public static function getRoleList($ghsId)
 	{
-		$where = ['merchantId' => $merchantId, 'delStatus' => 0];
+		$where = ['ghsId' => $ghsId, 'delStatus' => 0];
 		return self::getList('*', $where, 'addTime DESC');
 	}
 
 	//获取商家所有的角色名称 shish 2019.12.10
-	public static function getNameList($merchantId)
+	public static function getNameList($ghsId)
 	{
-		$list = self::getRoleList($merchantId);
-		return !empty($list) ? array_column($list, 'roleName') : [];
+		$respond = self::getRoleList($ghsId);
+		return isset($respond['list']) && !empty($respond['list']) ? array_column($respond['list'], 'roleName') : [];
 	}
 	
 	//更新角色 shish 2019.12.10

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

@@ -17,9 +17,9 @@ class AdminRoleService extends BaseService
 	}
 	
 	//角色列表 shish 2019.12.9
-	public static function getRoleList($merchantId)
+	public static function getRoleList($ghsId)
 	{
-		return AdminRoleClass::getRoleList($merchantId);
+		return AdminRoleClass::getRoleList($ghsId);
 	}
 	
 	//添加角色 shish 2019.12.10

+ 22 - 1
biz-ghs/admin/services/ShopAdminService.php

@@ -36,7 +36,7 @@ class ShopAdminService extends BaseService
 		$imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
 		return ['miniCode' => $imgUrl];
 	}
-
+	
 	public static function generateAdmin($data)
 	{
 		$recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
@@ -140,4 +140,25 @@ class ShopAdminService extends BaseService
 		}
 	}
 	
+	//根据id取员工信息,包括基本信息和角色 shish 2021.1.13
+	public static function getShopAdmin($id)
+	{
+		$relation = ShopAdminClass::getById($id);
+		if (empty($relation)) {
+			util::fail('没有找到员工信息');
+		}
+		$adminId = isset($relation['adminId']) ? $relation['adminId'] : 0;
+		if (empty($adminId)) {
+			util::fail('没有找到员工');
+		}
+		$adminInfo = AdminClass::getDetail($adminId);
+		$adminInfo['shopId'] = isset($relation['shopId']) ? $relation['shopId'] : 0;
+		$adminInfo['ghsId'] = isset($relation['ghsId']) ? $relation['ghsId'] : 0;
+		$adminInfo['adminId'] = isset($relation['adminId']) ? $relation['adminId'] : 0;
+		$adminInfo['roleId'] = isset($relation['roleId']) ? $relation['roleId'] : 0;
+		$adminInfo['remind'] = isset($relation['remind']) ? $relation['remind'] : 0;
+		$adminInfo['shop'] = $relation;
+		return $adminInfo;
+	}
+	
 }

+ 85 - 77
biz/admin/classes/ShopAdminClass.php

@@ -9,81 +9,89 @@ use biz\base\classes\BaseClass;
 
 class ShopAdminClass extends BaseClass
 {
-
-    public static $baseFile = '\biz\admin\models\ShopAdmin';
-
-    const GENERATE_ADMIN_DATA = 'generate_admin_data_';//创建管理员需要的数据
-
-    //创建管理准备数据key shish 2020.4.17
-    public static function getGenerateAdminDataKey($shopId, $adminId)
-    {
-        return self::GENERATE_ADMIN_DATA . $shopId . '_' . $adminId;
-    }
-
-    //创建管理员数据准备 shish 2020.4.17
-    public static function prepareBindAdmin($data)
-    {
-        $adminId = $data['adminId'];
-        $shopId = $data['shopId'];
-        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-        $params = [$cacheKey];
-        if (!empty($data)) {
-            foreach ($data as $key => $val) {
-                if (!is_array($val)) {
-                    $params[] = $key;
-                    $params[] = $val;
-                }
-            }
-        }
-        Yii::$app->redis->executeCommand('HMSET', $params);
-    }
-
-    //获取创建管理员需要的信息 shish 2020.4.20
-    public static function getBindAdminData($shopId, $adminId)
-    {
-        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-        $cacheData = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]);
-        $data = [];
-        if (!empty($cacheData)) {
-            $data = [];
-            $list = [];
-            $x = 0;
-            foreach ($cacheData as $cKey => $cVal) {
-                if ($cKey % 2 == 0) {
-                    $list[$x]['key'] = $cVal;
-                } else {
-                    $list[$x]['value'] = $cVal;
-                    $x++;
-                }
-            }
-            foreach ($list as $lKey => $lVal) {
-                $data[$lVal['key']] = $lVal['value'];
-            }
-        }
-        return $data;
-    }
-
-    //删除创建管理员需要的信息 shish 2020.4.20
-    public static function delBindAdminData($shopId, $adminId)
-    {
-        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-        $keyNameList = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]);
-        if (!empty($keyNameList)) {
-            $data = array_merge([$cacheKey], $keyNameList);
-            $cacheData = Yii::$app->redis->executeCommand('HDEL', $data);
-        }
-    }
-
-    //取店长 shish 2021.1.8
-    public static function getManager($shopId)
-    {
-        $relate = self::getByCondition(['shopId' => $shopId]);
-        $adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
-        $info = [];
-        if (!empty($adminId)) {
-            $info = AdminClass::getById($adminId);
-        }
-        return $info;
-    }
-
+	
+	public static $baseFile = '\biz\admin\models\ShopAdmin';
+	
+	const GENERATE_ADMIN_DATA = 'generate_admin_data_';//创建管理员需要的数据
+	
+	//创建管理准备数据key shish 2020.4.17
+	public static function getGenerateAdminDataKey($shopId, $adminId)
+	{
+		return self::GENERATE_ADMIN_DATA . $shopId . '_' . $adminId;
+	}
+	
+	//创建管理员数据准备 shish 2020.4.17
+	public static function prepareBindAdmin($data)
+	{
+		$adminId = $data['adminId'];
+		$shopId = $data['shopId'];
+		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+		$params = [$cacheKey];
+		if (!empty($data)) {
+			foreach ($data as $key => $val) {
+				if (!is_array($val)) {
+					$params[] = $key;
+					$params[] = $val;
+				}
+			}
+		}
+		Yii::$app->redis->executeCommand('HMSET', $params);
+	}
+	
+	//获取创建管理员需要的信息 shish 2020.4.20
+	public static function getBindAdminData($shopId, $adminId)
+	{
+		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+		$cacheData = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]);
+		$data = [];
+		if (!empty($cacheData)) {
+			$data = [];
+			$list = [];
+			$x = 0;
+			foreach ($cacheData as $cKey => $cVal) {
+				if ($cKey % 2 == 0) {
+					$list[$x]['key'] = $cVal;
+				} else {
+					$list[$x]['value'] = $cVal;
+					$x++;
+				}
+			}
+			foreach ($list as $lKey => $lVal) {
+				$data[$lVal['key']] = $lVal['value'];
+			}
+		}
+		return $data;
+	}
+	
+	//删除创建管理员需要的信息 shish 2020.4.20
+	public static function delBindAdminData($shopId, $adminId)
+	{
+		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+		$keyNameList = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]);
+		if (!empty($keyNameList)) {
+			$data = array_merge([$cacheKey], $keyNameList);
+			$cacheData = Yii::$app->redis->executeCommand('HDEL', $data);
+		}
+	}
+	
+	//取店长 shish 2021.1.8
+	public static function getManager($shopId)
+	{
+		$relate = self::getByCondition(['shopId' => $shopId]);
+		$adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
+		$info = [];
+		if (!empty($adminId)) {
+			$info = AdminClass::getById($adminId);
+		}
+		return $info;
+	}
+	
+	public static function valid($adminInfo, $ghsId)
+	{
+		if (isset($adminInfo['ghsId']) && $adminInfo['ghsId'] == $ghsId) {
+			return true;
+		}
+		util::fail('此员工您没有权限操作');
+	}
+	
 }

+ 29 - 0
sql.sql

@@ -402,4 +402,33 @@ CREATE TABLE `xhGhsStockOrderItem` (
   KEY `idx_goodsItemId` (`itemId`) USING BTREE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='出库入库订单详情表';
 
+===员工相关 shish 2021.1.13
 
+CREATE TABLE `xhGhsAdminLog` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `ip` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'ip地址',
+  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `content` VARCHAR(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作内容',
+  `adminId` INT(11) NOT NULL DEFAULT '0' COMMENT '员工id;管理员id',
+  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
+  PRIMARY KEY (`id`)
+) COMMENT='员工操作日志';
+CREATE TABLE `xhGhsAdminRole` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `roleName` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '角色名称',
+  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `num` INT(11) NOT NULL DEFAULT '0' COMMENT '成员数',
+  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
+  `delStatus` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '删除状态 0未删除 1已删除',
+  `auth` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '权限id列表,存在*表示有所有权限',
+  PRIMARY KEY (`id`)
+) COMMENT='管理员角色';
+CREATE TABLE `xhGhsAdminRoleAuth` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `roleId` INT(11) NOT NULL DEFAULT '0' COMMENT '角色id',
+  `endId` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '业务端id',
+  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `auth` VARCHAR(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '权限',
+  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
+  PRIMARY KEY (`id`)
+) COMMENT='员工角色权限';