shish 5 سال پیش
والد
کامیت
869ac3e547
1فایلهای تغییر یافته به همراه116 افزوده شده و 115 حذف شده
  1. 116 115
      app/ghs/controllers/ShopAdminController.php

+ 116 - 115
app/ghs/controllers/ShopAdminController.php

@@ -15,119 +15,120 @@ use yii\web\Controller;
 
 class ShopAdminController 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['ghsId']) != $this->ghsId) {
-			util::fail('请选择角色!');
-		}
-		unset($post['userId']);
-		unset($post['status']);
-		$post['shopId'] = $this->shopId;
-		$post['ghsId'] = $this->ghsId;
-		$post['adminId'] = $this->adminId;
-		$merchant = WxOpenClass::getGhsWxInfo();
-		$post['merchant'] = $merchant;
-		$respond = ShopAdminService::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 = ShopAdminService::generateAdmin($post);
-		util::success($respond);
-	}
-	
-	//收款通知 shish 2021.1.14
-	public function actionUpdateRemind()
-	{
-		$get = Yii::$app->request->get();
-		$id = $get['id'] ?? 0;
-		$remind = $get['remind'] ?? 0;
-		$relation = ShopAdminClass::getById($id, true);
-		if (empty($relation)) {
-			util::fail('没有找到员工');
-		}
-		ShopAdminClass::valid($relation->attributes, $this->ghsId);
-		$relation->remind = $remind;
-		$relation->save();
-		util::complete();
-	}
-	
-	//启用与停用 shish 2021.1.14
-	public function actionUpdateStatus()
-	{
-		$get = Yii::$app->request->get();
-		$id = $get['id'] ?? 0;
-		$status = $get['status'] ?? 0;
-		$relation = ShopAdminClass::getById($id, true);
-		if (empty($relation)) {
-			util::fail('没有找到员工');
-		}
-		ShopAdminClass::valid($relation->attributes, $this->ghsId);
-		$relation->status = $status;
-		$relation->save();
-		util::complete();
-	}
-	
-	//员工列表 shish 2019.12.8
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$where = [];
-		$where['shopId'] = $this->shopId;
-		$where['delStatus'] = 0;
-		$list = ShopAdminService::getAdminList($where);
-		util::success($list);
-	}
-	
-	//获取员工信息 shish 2021.1.13
-	public function actionDetail()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$respond = ShopAdminService::getAdminInfo($id);
-		ShopAdminClass::valid($respond, $this->ghsId);
-		util::success($respond);
-	}
-	
-	//修改员工信息
-	public function actionUpdate()
-	{
-		$post = Yii::$app->request->post();
-		$id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
-		$relation = ShopAdminClass::getById($id, true);
-		unset($post['id']);
-		$roleId = isset($post['roleId']) && !empty($post['roleId']) ? $post['roleId'] : 0;
-		$remind = isset($post['remind']) && !empty($post['remind']) ? $post['remind'] : 0;
-		$relation->roleId = $roleId;
-		$relation->remind = $remind;
-		$relation->save();
-		
-		$adminId = isset($relation->adminId) ? $relation->adminId : 0;
-		$originalAdmin = ShopAdminService::getAdminInfo($adminId);
-		ShopAdminClass::valid($originalAdmin, $this->ghsId);
-		AdminClass::updateById($adminId, $post);
-		util::complete('修改成功');
-	}
-	
-	//删除员工关系 shish 2021.1.14
-	public function actionDelete()
-	{
-		$id = Yii::$app->request->get('id');
-		$relation = ShopAdminClass::getById($id);
-		$adminId = $relation['adminId'] ?? 0;
-		$admin = ShopAdminService::getAdminInfo($adminId);
-		ShopAdminClass::valid($admin, $this->ghsId);
-		ShopAdminClass::deleteById($id);
-		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['ghsId']) != $this->ghsId) {
+            util::fail('请选择角色!');
+        }
+        unset($post['userId']);
+        unset($post['status']);
+        $post['shopId'] = $this->shopId;
+        $post['ghsId'] = $this->ghsId;
+        $post['adminId'] = $this->adminId;
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $post['merchant'] = $merchant;
+        $respond = ShopAdminService::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();
+        $post['adminId'] = $this->adminId;
+        $respond = ShopAdminService::generateAdmin($post);
+        util::success($respond);
+    }
+
+    //收款通知 shish 2021.1.14
+    public function actionUpdateRemind()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $remind = $get['remind'] ?? 0;
+        $relation = ShopAdminClass::getById($id, true);
+        if (empty($relation)) {
+            util::fail('没有找到员工');
+        }
+        ShopAdminClass::valid($relation->attributes, $this->ghsId);
+        $relation->remind = $remind;
+        $relation->save();
+        util::complete();
+    }
+
+    //启用与停用 shish 2021.1.14
+    public function actionUpdateStatus()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $status = $get['status'] ?? 0;
+        $relation = ShopAdminClass::getById($id, true);
+        if (empty($relation)) {
+            util::fail('没有找到员工');
+        }
+        ShopAdminClass::valid($relation->attributes, $this->ghsId);
+        $relation->status = $status;
+        $relation->save();
+        util::complete();
+    }
+
+    //员工列表 shish 2019.12.8
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['shopId'] = $this->shopId;
+        $where['delStatus'] = 0;
+        $list = ShopAdminService::getAdminList($where);
+        util::success($list);
+    }
+
+    //获取员工信息 shish 2021.1.13
+    public function actionDetail()
+    {
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $respond = ShopAdminService::getAdminInfo($id);
+        ShopAdminClass::valid($respond, $this->ghsId);
+        util::success($respond);
+    }
+
+    //修改员工信息
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
+        $relation = ShopAdminClass::getById($id, true);
+        unset($post['id']);
+        $roleId = isset($post['roleId']) && !empty($post['roleId']) ? $post['roleId'] : 0;
+        $remind = isset($post['remind']) && !empty($post['remind']) ? $post['remind'] : 0;
+        $relation->roleId = $roleId;
+        $relation->remind = $remind;
+        $relation->save();
+
+        $adminId = isset($relation->adminId) ? $relation->adminId : 0;
+        $originalAdmin = ShopAdminService::getAdminInfo($adminId);
+        ShopAdminClass::valid($originalAdmin, $this->ghsId);
+        AdminClass::updateById($adminId, $post);
+        util::complete('修改成功');
+    }
+
+    //删除员工关系 shish 2021.1.14
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->get('id');
+        $relation = ShopAdminClass::getById($id);
+        $adminId = $relation['adminId'] ?? 0;
+        $admin = ShopAdminService::getAdminInfo($adminId);
+        ShopAdminClass::valid($admin, $this->ghsId);
+        ShopAdminClass::deleteById($id);
+        util::complete();
+    }
+
 }