shish 6 лет назад
Родитель
Сommit
e116921823
2 измененных файлов с 71 добавлено и 88 удалено
  1. 63 63
      app/shop/controllers/AdminShopController.php
  2. 8 25
      biz/admin/services/AdminShopService.php

+ 63 - 63
app/shop/controllers/AdminShopController.php

@@ -12,68 +12,68 @@ use yii\web\Controller;
 
 class AdminShopController extends BaseController
 {
+	
+	//创建管理员数据准备 shish 2020.4.17
+	public function actionPrepareBind()
+	{
+		$post = Yii::$app->request->post();
+		$roleId = isset($post['roleId']) ? $post['roleId'] : 0;
+		$role = AdminRoleService::getById($roleId);
+		if (empty($role) || isset($role['merchantId']) != $this->merchantId) {
+			util::fail('请选择角色!');
+		}
+		unset($post['userId']);
+		unset($post['status']);
+		$post['shopId'] = $this->shopId;
+		$post['adminId'] = $this->adminId;
+		$merchant = WxOpenService::getWxInfo();
+		$post['merchant'] = $merchant;
+		$respond = AdminShopService::prepareBindAdmin($post);
+		$miniCode = isset($respond['miniCode']) ? Yii::$app->params['imgHost'] . $respond['miniCode'] : '';
+		util::success(['miniCode' => $miniCode]);
+	}
+	
+	//创建管理员 shish 2020.4.20
+	public function actionGenerateAdmin()
+	{
+		$post = Yii::$app->request->post();
+		$respond = AdminShopService::generateAdmin($post);
+		util::success($respond);
+	}
+	
+	//收款通知 shish 2020.1.4
+	public function actionUpdateRemind()
+	{
+		$get = Yii::$app->request->get();
+		$id = isset($get['id']) ? $get['id'] : 0;
+		$remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
+		$adminShop = AdminShopService::getById($id);
+		AdminShopService::valid($adminShop, $this->shopId);
+		AdminShopService::updateById($id, ['remind' => $remind]);
+		util::complete();
+	}
+	
+	//启用与停用 shish 2020.1.4
+	public function actionUpdateStatus()
+	{
+		$get = Yii::$app->request->get();
+		$id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
+		$status = isset($get['status']) ? $get['status'] : 0;
+		$adminShop = AdminShopService::getById($id);
+		AdminShopService::valid($adminShop, $this->shopId);
+		AdminShopService::updateById($id, ['status' => $status]);
+		util::complete();
+	}
 
-    //创建管理员数据准备 shish 2020.4.17
-    public function actionPrepareBind()
-    {
-        $post = Yii::$app->request->post();
-        $roleId = isset($post['roleId']) ? $post['roleId'] : 0;
-        $role = AdminRoleService::getById($roleId);
-        if (empty($role) || isset($role['merchantId']) != $this->merchantId) {
-            util::fail('请选择角色!');
-        }
-        unset($post['userId']);
-        unset($post['status']);
-        $post['shopId'] = $this->shopId;
-        $post['adminId'] = $this->adminId;
-        $merchant = WxOpenService::getWxInfo();
-        $post['merchant'] = $merchant;
-        $respond = AdminShopService::prepareBindAdmin($post);
-        $miniCode = isset($respond['miniCode']) ? Yii::$app->params['imgHost'] . $respond['miniCode'] : '';
-        util::success(['miniCode' => $miniCode]);
-    }
-
-    //创建管理员 shish 2020.4.20
-    public function actionGenerateAdmin()
-    {
-        $post = Yii::$app->request->post();
-        $respond = AdminShopService::generateAdmin($post);
-        util::success($respond);
-    }
-
-    //收款通知 shish 2020.1.4
-    public function actionUpdateRemind()
-    {
-        $get = Yii::$app->request->get();
-        $id = isset($get['id']) ? $get['id'] : 0;
-        $remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
-        $adminShop = AdminShopService::getByCondition(['shopId' => $this->shopId, 'adminId' => $id]);
-        AdminShopService::valid($adminShop, $this->shopId);
-        AdminShopService::updateByCondition(['shopId' => $this->shopId, 'adminId' => $id], ['remind' => $remind]);
-        util::complete();
-    }
-
-    //启用与停用 shish 2020.1.4
-    public function actionUpdateStatus()
-    {
-        $get = Yii::$app->request->get();
-        $id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
-        $status = isset($get['status']) ? $get['status'] : 0;
-        $adminShop = AdminShopService::getByCondition(['shopId' => $this->shopId, 'adminId' => $id]);
-        AdminShopService::valid($adminShop, $this->shopId);
-        AdminShopService::updateByCondition(['shopId' => $this->shopId, 'adminId' => $id], ['status' => $status]);
-        util::complete();
-    }
-
-    //员工列表 shish 2019.12.8
-    public function actionList()
-    {
-        $get = Yii::$app->request->get();
-        $where = [];
-        $where['shopId'] = $this->shopId;
-        $where['delStatus'] = 0;
-        $list = AdminShopService::getAdminList($where);
-        util::success($list);
-    }
-
+	//员工列表 shish 2019.12.8
+	public function actionList()
+	{
+		$get = Yii::$app->request->get();
+		$where = [];
+		$where['shopId'] = $this->shopId;
+		$where['delStatus'] = 0;
+		$list = AdminShopService::getAdminList($where);
+		util::success($list);
+	}
+	
 }

+ 8 - 25
biz/admin/services/AdminShopService.php

@@ -81,7 +81,7 @@ class AdminShopService extends BaseService
 		AdminShopClass::delBindAdminData($shopId, $recommendAdminId);
 		return AdminShopClass::add($addData);
 	}
-	
+
 	//获取管理员 shish 2020.4.21
 	public static function getAdminList($where)
 	{
@@ -91,34 +91,17 @@ class AdminShopService extends BaseService
 			return $data;
 		}
 
-//		$params = [];
-//		foreach ($list as $val) {
-//			$adminId = $val['adminId'];
-//			$params[$adminId] = ['remind' => $val['remind'], 'status' => $val['status']];
-//		}
-//
-//		//所有的管理员
-//		$ids = array_column($list, 'adminId');
-//		$newList = AdminClass::getByIds($ids);
-//		$newList = AdminClass::groupAdminBaseInfo($newList);
-//
-//		foreach ($newList as $newKey => $newVal) {
-//			$adminId = $newVal['id'];
-//			$newList[$newKey]['remind'] = isset($params[$adminId]['remind']) ? $params[$adminId]['remind'] : 0;
-//			$newList[$newKey]['status'] = isset($params[$adminId]['status']) ? $params[$adminId]['status'] : 0;
-//		}
-		
 		//管理员基础信息
 		$ids = array_column($list, 'adminId');
 		$adminInfo = AdminClass::getByIds($ids, null, 'id');
 		$adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo);
-		
+
 		$roleIds = array_column($list, 'roleId');
 		$roleIds = array_filter(array_unique($roleIds));
 		$roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
-		
+
 		foreach ($list as $key => $val) {
-			$adminId = $val['id'];
+			$adminId = $val['adminId'];
 			$current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
 			$list[$key]['adminBaseInfo'] = $current;
 			$roleId = $val['roleId'];
@@ -126,7 +109,7 @@ class AdminShopService extends BaseService
 			$list[$key]['roleName'] = $roleName;
 		}
 
-		$data['list'] = $newList;
+		$data['list'] = $list;
 		return $data;
 	}
 
@@ -141,12 +124,12 @@ class AdminShopService extends BaseService
 		}
 		return $list;
 	}
-	
+
 	public static function valid($adminShop, $shopId)
 	{
 		if (isset($adminShop['shopId']) == false || $adminShop['shopId'] != $shopId) {
-			util::fail('不是您的员工,没有权限操作');
+			util::fail('不是您的员工');
 		}
 	}
-	
+
 }