فهرست منبع

门店员工 ok

shish 5 سال پیش
والد
کامیت
84391c899d

+ 1 - 6
app/ghs/controllers/AdminController.php

@@ -36,6 +36,7 @@ class AdminController extends BaseController
     //删除员工 shish 2019.12.9
     public function actionDelete()
     {
+    	Yii::$app->end();
         $id = Yii::$app->request->post('id');
         $admin = AdminClass::getById($id);
         AdminService::valid($admin, $this->ghsId);
@@ -43,12 +44,6 @@ class AdminController extends BaseController
         util::complete();
     }
 
-    //修改员工 shish 2019.12.9
-    public function actionUpdate()
-    {
-
-    }
-
     //查看员工详情 shish 2019.12.9
     public function actionDetail()
     {

+ 113 - 93
app/ghs/controllers/ShopAdminController.php

@@ -14,98 +14,118 @@ 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['adminId'] = $this->adminId;
+		$merchant = WxOpenService::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 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['adminId'] = $this->adminId;
-        $merchant = WxOpenService::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 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;
-        $shopAdmin = ShopAdminService::getById($id);
-        ShopAdminService::valid($shopAdmin, $this->shopId);
-        ShopAdminService::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;
-        $shopAdmin = ShopAdminService::getById($id);
-        ShopAdminService::valid($shopAdmin, $this->shopId);
-        ShopAdminService::updateById($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 = 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 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();
+	}
+	
 }

+ 34 - 18
app/ghs/controllers/ShopController.php

@@ -3,8 +3,10 @@
 namespace ghs\controllers;
 
 use biz\merchant\services\MerchantExtendService;
+use bizGhs\merchant\classes\ShopClass;
 use bizGhs\merchant\services\ShopService;
 use common\components\dirUtil;
+use common\components\httpUtil;
 use common\components\util;
 use common\components\wxUtil;
 use Yii;
@@ -12,13 +14,13 @@ use Yii;
 class ShopController extends BaseController
 {
 	
-	//门店列表 shish 20202.2.29
+	//门店列表 shish 2021.1.14
 	public function actionList()
 	{
 		$where = [];
 		$where['ghsId'] = $this->ghsId;
 		$where['delStatus'] = 0;
-		$list = ShopService::getShopList($where);
+		$list = ShopClass::getShopList($where);
 		util::success($list);
 	}
 	
@@ -27,33 +29,40 @@ class ShopController extends BaseController
 	{
 		$data = Yii::$app->request->post();
 		$data['ghsId'] = $this->ghsId;
-		$id = isset($data['id']) ? $data['id'] : 0;
-		unset($data['id']);
+		$id = $data['id'] ?? 0;
 		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->ghsId);
-		ShopService::updateShop($id, $data);
+		if (empty($shop)) {
+			util::fail('没有找到门店');
+		}
+		ShopClass::valid($shop, $this->ghsId);
+		ShopClass::updateShop($id, $data);
 		util::complete();
 	}
 	
+	//添加门店 shish 2021.1.14
 	public function actionAdd()
 	{
 		$data = Yii::$app->request->post();
 		$data['ghsId'] = $this->ghsId;
-		ShopService::addShop($data);
+		ShopClass::addShop($data);
 		util::complete();
 	}
 	
-	//下载微信和支付宝收款码 shish 2020.2.29
+	//PC下载微信和支付宝收款码 shish 2020.2.29
 	public function actionGatheringCode()
 	{
 		$id = Yii::$app->request->get('id', 0);
 		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->ghsId);
-		$gatheringCode = ShopService::generateGatheringCode($this->ghsId, $id);
+		ShopClass::valid($shop, $this->ghsId);
+		$gatheringCode = ShopClass::generateGatheringCode($this->ghsId, $id);
 		$file = dirUtil::getImgDir() . $gatheringCode;
 		if (file_exists($file) == false) {
 			util::fail('没有找到收款码');
 		}
+		if (httpUtil::isMiniProgram()) {
+			$imgUrl = Yii::$app->params['imgHost'] . $gatheringCode;
+			util::success(['imgUrl' => $imgUrl]);
+		}
 		$fileName = "门店({$id})收款码.jpg";
 		$contentType = 'image/jpeg';
 		header("Cache-control: private");
@@ -63,7 +72,7 @@ class ShopController extends BaseController
 		readfile($file);
 	}
 	
-	//获取小程序的收款码 shish
+	//PC获取小程序的收款码 shish
 	public function actionGatheringMiniCode()
 	{
 		$id = Yii::$app->request->get('id', 0);
@@ -72,12 +81,16 @@ class ShopController extends BaseController
 			util::fail('您的小程序还没有授权');
 		}
 		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->ghsId);
+		ShopClass::valid($shop, $this->ghsId);
 		$applyMemberCode = wxUtil::generateGatheringMiniCode($this->merchant, $id);
 		$file = dirUtil::getImgDir() . $applyMemberCode;
 		if (file_exists($file) == false) {
 			util::fail('没有找到注册会员码');
 		}
+		if (httpUtil::isMiniProgram()) {
+			$imgUrl = Yii::$app->params['imgHost'] . $applyMemberCode;
+			util::success(['imgUrl' => $imgUrl]);
+		}
 		$fileName = "门店({$id})小程序收款码.jpg";
 		$contentType = 'image/jpeg';
 		header("Cache-control: private");
@@ -87,7 +100,7 @@ class ShopController extends BaseController
 		readfile($file);
 	}
 	
-	//下载会员注册码 shish 2020.2.29
+	//PC下载会员注册码 shish 2020.2.29
 	public function actionApplyMemberCode()
 	{
 		$id = Yii::$app->request->get('id', 0);
@@ -96,12 +109,16 @@ class ShopController extends BaseController
 			util::fail('您的小程序还没有授权');
 		}
 		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->ghsId);
+		ShopClass::valid($shop, $this->ghsId);
 		$applyMemberCode = wxUtil::generateMemberCode($this->merchant, $id);
 		$file = dirUtil::getImgDir() . $applyMemberCode;
 		if (file_exists($file) == false) {
 			util::fail('没有找到注册会员码');
 		}
+		if (httpUtil::isMiniProgram()) {
+			$imgUrl = Yii::$app->params['imgHost'] . $applyMemberCode;
+			util::success(['imgUrl' => $imgUrl]);
+		}
 		$fileName = "注册会员码{$id}.jpg";
 		$contentType = 'image/jpeg';
 		header("Cache-control: private");
@@ -115,11 +132,10 @@ class ShopController extends BaseController
 	public function actionDelete()
 	{
 		$id = Yii::$app->request->get('id', 0);
-		util::fail('功能开发中');
 		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->ghsId);
-		ShopService::deleteShop($shop);
+		ShopClass::valid($shop, $this->ghsId);
+		ShopClass::deleteShop($shop);
 		util::complete();
 	}
-
+	
 }

+ 14 - 17
biz-ghs/merchant/classes/ShopClass.php

@@ -27,7 +27,7 @@ class ShopClass extends BaseClass
 		return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
 	}
 	
-	//创建门店 shish 2020.2.8
+	//创建门店 shish 2021.1.14
 	public static function addShop($data)
 	{
 		$data['createTime'] = date("Y-m-d H:i:s");
@@ -35,12 +35,11 @@ class ShopClass extends BaseClass
 		if (empty($shopName)) {
 			util::fail('请填写门店名称');
 		}
-		$exists = self::getByCondition(['merchantId' => $data['merchantId'], 'shopName' => $shopName]);
+		$exists = self::getByCondition(['ghsId' => $data['ghsId'], 'shopName' => $shopName]);
 		if (!empty($exists)) {
 			util::fail('门店名称已经存在');
 		}
 		$shop = self::add($data);
-		
 		return $shop;
 	}
 	
@@ -48,8 +47,8 @@ class ShopClass extends BaseClass
 	public static function updateShop($id, $data)
 	{
 		$shopName = isset($data['shopName']) ? $data['shopName'] : '';
-		$merchantId = $data['merchantId'];
-		$findShop = self::getByCondition(['merchantId' => $merchantId, 'shopName' => $shopName]);
+		$ghsId = $data['ghsId'];
+		$findShop = self::getByCondition(['ghsId' => $ghsId, 'shopName' => $shopName]);
 		if (!empty($findShop) && $findShop['id'] != $id) {
 			util::fail('门店名称已经存在');
 		}
@@ -62,15 +61,13 @@ class ShopClass extends BaseClass
 		return self::getAllByCondition(['merchantId' => $merchantId]);
 	}
 	
-	//验证所属权限 shish 2020.2.29
-	public static function valid($shop, $merchantId)
+	//验证权限 shish 2021.1.14
+	public static function valid($shop, $ghsId)
 	{
-		if (empty($shop)) {
-			util::fail('门店无效');
-		}
-		if (isset($shop['merchantId']) == false || $shop['merchantId'] != $merchantId) {
-			util::fail('您没有权限访问');
+		if (isset($shop['ghsId']) && $shop['ghsId'] == $ghsId) {
+			return true;
 		}
+		util::fail('您没有权限访问');
 	}
 	
 	//删除门店 shish 2020.3.1
@@ -83,14 +80,14 @@ class ShopClass extends BaseClass
 		self::updateById($id, ['delStatus' => 1]);
 	}
 	
-	//生成收款码 shish 2020.3.9
-	public static function generateGatheringCode($merchantId, $shopId)
+	//生成收款码 shish 2021.1.14
+	public static function generateGatheringCode($ghsId, $shopId)
 	{
-		$url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
+		$url = Yii::$app->params['ghsDomain'] . "/#/pages/pay/index?account={$ghsId}&shopId=" . $shopId;
 		//强制转成https
 		$url = httpUtil::becomeHttps($url);
-		$gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
+		$gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $ghsId, $shopId, '', 10);
 		return $gatheringCode;
 	}
-
+	
 }

+ 1 - 30
biz-ghs/merchant/services/ShopService.php

@@ -42,41 +42,12 @@ class ShopService extends BaseService
 		return ShopClass::getById($defaultShopId);
 	}
 	
-	//验证门店
-	public static function valid($shopInfo, $merchantId)
-	{
-		ShopClass::valid($shopInfo, $merchantId);
-	}
-	
-	public static function getShopList($where)
-	{
-		$list = ShopClass::getShopList($where);
-		return $list;
-	}
-	
 	//获取默认门店 shish 2020.1.19
 	public static function getDefaultShopId($merchant)
 	{
 		return ShopClass::getDefaultShopId($merchant);
 	}
-	
-	//添加门店 shish 2020.2.29
-	public static function addShop($data)
-	{
-		return ShopClass::addShop($data);
-	}
-	
-	//更新门店 shish 2020.2.29
-	public static function updateShop($id, $data)
-	{
-		return ShopClass::updateShop($id, $data);
-	}
-	
-	//删除门店 shish 2020.3.1
-	public static function deleteShop($shop)
-	{
-		return ShopClass::deleteShop($shop);
-	}
+
 
 	//获取收款码 shish 2020.3.9
 	public static function generateGatheringCode($merchantId, $shopId)