shish 5 år sedan
förälder
incheckning
422a16629c
2 ändrade filer med 121 tillägg och 118 borttagningar
  1. 117 117
      biz-hd/admin/services/ShopAdminService.php
  2. 4 1
      sql.sql

+ 117 - 117
biz-hd/admin/services/ShopAdminService.php

@@ -20,121 +20,121 @@ use Yii;
 
 class ShopAdminService extends BaseService
 {
-	
-	public static $baseFile = '\bizHd\admin\classes\ShopAdminClass';
-	
-	///创建管理员生成小程序 ssh 2020.4.17
-	public static function prepareBindAdmin($data)
-	{
-		ShopAdminClass::prepareBindAdmin($data);
-		$page = 'admin/shopAdmin/bind';
-		$isOpen = 1;
-		$adminId = $data['adminId'];
-		$shopId = $data['shopId'];
-		$scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
-		$merchant = $data['merchant'];
-		$imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
-		return ['miniCode' => $imgUrl];
-	}
-	
-	public static function generateAdmin($data)
-	{
-		$recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
-		$mobile = isset($data['mobile']) ? $data['mobile'] : '';
-		$shopId = isset($data['shopId']) ? $data['shopId'] : 0;
-		$adminId = isset($data['adminId']) ? $data['adminId'] : 0;
-		$bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
-		$shop = ShopClass::getById($shopId);
-		if (empty($shop)) {
-			util::fail('没有找到门店');
-		}
-		$merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
-		if (empty($bindData)) {
-			util::fail('小程序码已经失效,请重新创建员工');
-		}
-		$shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
-		if (!empty($shopAdmin)) {
-			util::fail('您已经是管理员了');
-		}
-		$adminName = isset($bindData['adminName']) ? $bindData['adminName'] : '';
-		if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
-			util::fail('添加管理员时请选择角色');
-		}
-		$admin = AdminClass::getById($adminId);
-		if (empty($admin)) {
-			util::fail('没有找到管理员信息');
-		}
-		$roleId = $bindData['roleId'];
-		$remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
-		$status = isset($bindData['status']) ? $bindData['status'] : 0;
-		$password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
-		$remark = isset($bindData['remark']) ? $bindData['remark'] : '';
-		$update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark];
-		AdminClass::updateById($adminId, $update);
-		$addData = [
-			'adminId' => $adminId,
-			'shopId' => $shopId,
-			'roleId' => $roleId,
-			'remind' => $remind,
-			'status' => $status,
-			'merchantId' => $merchantId,
-		];
-		ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
-		return ShopAdminClass::add($addData);
-	}
-	
-	//获取管理员 ssh 2020.4.21
-	// $sensitive true 密码等敏感信息不显示
-	public static function getAdminList($where, $sensitive = true)
-	{
-		$data = ShopAdminClass::getList('*', $where, 'addTime DESC');
-		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-		if (empty($list)) {
-			return $data;
-		}
-		
-		//管理员基础信息
-		$ids = array_column($list, 'adminId');
-		$adminInfo = AdminClass::getByIds($ids, null, 'id');
-		$adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
-		
-		$roleIds = array_column($list, 'roleId');
-		$roleIds = array_filter(array_unique($roleIds));
-		$roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
-		
-		foreach ($list as $key => $val) {
-			$adminId = $val['adminId'];
-			$current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
-			$list[$key]['adminBaseInfo'] = $current;
-			$roleId = $val['roleId'];
-			$roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
-			$list[$key]['roleName'] = $roleName;
-		}
-		$data['list'] = $list;
-		return $data;
-	}
-	
-	//获取要通知的管理员 ssh 2020.4.28
-	public static function getNoticeAdminList($shopId)
-	{
-		$where = ['shopId' => $shopId];
-		$respond = self::getAdminList($where, false);
-		$list = isset($respond['list']) ? $respond['list'] : [];
-		if (!empty($list)) {
-			foreach ($list as $key => $val) {
-				if (isset($val['remind']) && $val['remind'] == 0) {
-					unset($list[$key]);
-				}
-			}
-		}
-		return $list;
-	}
-	
-	public static function valid($shopAdmin, $shopId)
-	{
-		if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
-			util::fail('不是您的员工');
-		}
-	}
-	
+
+    public static $baseFile = '\bizHd\admin\classes\ShopAdminClass';
+
+    ///创建管理员生成小程序 ssh 2020.4.17
+    public static function prepareBindAdmin($data)
+    {
+        ShopAdminClass::prepareBindAdmin($data);
+        $page = 'admin/shopAdmin/bind';
+        $isOpen = 1;
+        $adminId = $data['adminId'];
+        $shopId = $data['shopId'];
+        $scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
+        $merchant = $data['merchant'];
+        $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
+        return ['miniCode' => $imgUrl];
+    }
+
+    public static function generateAdmin($data)
+    {
+        $recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
+        $mobile = isset($data['mobile']) ? $data['mobile'] : '';
+        $shopId = isset($data['shopId']) ? $data['shopId'] : 0;
+        $adminId = isset($data['adminId']) ? $data['adminId'] : 0;
+        $bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
+        $shop = ShopClass::getById($shopId);
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
+        if (empty($bindData)) {
+            util::fail('小程序码已经失效,请重新创建员工');
+        }
+        $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
+        if (!empty($shopAdmin)) {
+            util::fail('您已经是管理员了');
+        }
+        $adminName = isset($bindData['adminName']) ? $bindData['adminName'] : '';
+        if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
+            util::fail('添加管理员时请选择角色');
+        }
+        $admin = AdminClass::getById($adminId);
+        if (empty($admin)) {
+            util::fail('没有找到管理员信息');
+        }
+        $roleId = $bindData['roleId'];
+        $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
+        $status = isset($bindData['status']) ? $bindData['status'] : 0;
+        $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
+        $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
+        $update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
+        AdminClass::updateById($adminId, $update);
+        $addData = [
+            'adminId' => $adminId,
+            'shopId' => $shopId,
+            'roleId' => $roleId,
+            'remind' => $remind,
+            'status' => $status,
+            'merchantId' => $merchantId,
+        ];
+        ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
+        return ShopAdminClass::add($addData);
+    }
+
+    //获取管理员 ssh 2020.4.21
+    // $sensitive true 密码等敏感信息不显示
+    public static function getAdminList($where, $sensitive = true)
+    {
+        $data = ShopAdminClass::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+
+        //管理员基础信息
+        $ids = array_column($list, 'adminId');
+        $adminInfo = AdminClass::getByIds($ids, null, 'id');
+        $adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
+
+        $roleIds = array_column($list, 'roleId');
+        $roleIds = array_filter(array_unique($roleIds));
+        $roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
+
+        foreach ($list as $key => $val) {
+            $adminId = $val['adminId'];
+            $current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
+            $list[$key]['adminBaseInfo'] = $current;
+            $roleId = $val['roleId'];
+            $roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
+            $list[$key]['roleName'] = $roleName;
+        }
+        $data['list'] = $list;
+        return $data;
+    }
+
+    //获取要通知的管理员 ssh 2020.4.28
+    public static function getNoticeAdminList($shopId)
+    {
+        $where = ['shopId' => $shopId];
+        $respond = self::getAdminList($where, false);
+        $list = isset($respond['list']) ? $respond['list'] : [];
+        if (!empty($list)) {
+            foreach ($list as $key => $val) {
+                if (isset($val['remind']) && $val['remind'] == 0) {
+                    unset($list[$key]);
+                }
+            }
+        }
+        return $list;
+    }
+
+    public static function valid($shopAdmin, $shopId)
+    {
+        if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
+            util::fail('不是您的员工');
+        }
+    }
+
 }

+ 4 - 1
sql.sql

@@ -2087,4 +2087,7 @@ ALTER TABLE xhOrderExpress ADD `sendTimeWant` DATETIME NOT NULL DEFAULT '0000-00
 ALTER TABLE xhApply CHANGE `avatar` `logo` VARCHAR(800) NOT NULL DEFAULT '' COMMENT '商家头像';
 ALTER TABLE xhAdmin DROP COLUMN `identity`;
 
-国兰原有的商品拼音需要补回去
+国兰原有的商品拼音需要补回去
+
+ALTER TABLE xhShopAdmin ADD VARCHAR(500) NOT NULL DEFAULT '' COMMENT '添加员工时的备注' AFTER `super`;
+ALTER TABLE xhShopAdmin ADD founder TINYINT NOT NULL DEFAULT 1 COMMENT '创始人 1不是 2是' AFTER `super`;