shish 6 년 전
부모
커밋
76782ce306
3개의 변경된 파일214개의 추가작업 그리고 217개의 파일을 삭제
  1. 214 150
      app/shop/controllers/AdminController.php
  2. 0 2
      app/shop/controllers/BaseController.php
  3. 0 65
      app/shop/controllers/UserController.php

+ 214 - 150
app/shop/controllers/AdminController.php

@@ -4,159 +4,223 @@ namespace shop\controllers;
 
 use biz\admin\classes\AdminClass;
 use biz\admin\services\AdminService;
-use common\components\jwt;
+use biz\wx\services\WxOpenService;
 use common\components\util;
 use Yii;
-use yii\web\Controller;
+use yii\helpers\Json;
+use biz\user\classes\UserClass;
 
 class AdminController extends BaseController
 {
-	
-	public $withoutLogin = [];
-	
-	//获取登陆员工的权限 shish 2019.11.24
-	public function actionLoginAuth()
-	{
-		$auth = AdminService::getAuth($this->adminId, $this->merchantId);
-		util::success($auth);
-	}
-	
-	//员工列表 shish 2019.12.8
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$where = [];
-		$where['merchantId'] = $this->merchantId;
-		$where['delStatus'] = 0;
-		$list = AdminService::getAdminList($where);
-		util::success($list);
-	}
-
-	//添加员工 shish 2019.12.8
-	public function actionAdd()
-	{
-		$post = Yii::$app->request->post();
-		$post['merchantId'] = $this->merchantId;
-		$admin = AdminService::addAdmin($post);
-		$id = $admin['id'];
-		$info = AdminService::getDetail($id);
-		util::success($info);
-	}
-	
-	//删除员工 shish 2019.12.9
-	public function actionDelete()
-	{
-		$id = Yii::$app->request->post('id');
-		$admin = AdminClass::getById($id);
-		AdminService::valid($admin, $this->merchantId);
-		AdminService::deleteAdmin($admin, $this->adminId);
-		util::complete();
-	}
-	
-	//修改员工 shish 2019.12.9
-	public function actionUpdate()
-	{
-		$post = Yii::$app->request->post();
-		$id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
-		unset($post['id']);
-		$originalAdmin = AdminService::getById($id);
-		$post['merchantId'] = $this->merchantId;
-		AdminService::updateAdmin($originalAdmin, $post);
-		util::complete('修改成功');
-	}
-	
-	//查看员工详情 shish 2019.12.9
-	public function actionDetail()
-	{
-		$id = Yii::$app->request->get('id');
-		$admin = AdminService::getDetail($id);
-		AdminService::valid($admin, $this->merchantId);
-		util::success($admin);
-	}
-	
-	//密码修改
-	public function actionPassword()
-	{
-		$post = Yii::$app->request->post();
-		$old = isset($post['old']) ? $post['old'] : '';
-		$new = isset($post['new']) ? $post['new'] : '';
-		$confirm = isset($post['confirm']) ? $post['confirm'] : '';
-		if (empty($new)) {
-			util::fail('请输入新密码');
-		}
-		if ($new != $confirm) {
-			util::fail('二次密码不一致');
-		}
-		$admin = $this->admin;
-		$adminId = $this->adminId;
-		if (!empty($admin['password'])) {
-			if (empty($old)) {
-				util::fail('请填写旧密码');
-			}
-			if (password_verify($old, $admin['password']) == false) {
-				util::fail('旧密码错误');
-			}
-		}
-		AdminService::updateById($adminId, ['password' => password_hash($new, PASSWORD_BCRYPT)]);
-		util::complete('修改成功');
-	}
-	
-	//确认密码修改
-	public function actionConfirmPassword()
-	{
-		$post = Yii::$app->request->post();
-		$old = isset($post['old']) ? $post['old'] : '';
-		$new = isset($post['new']) ? $post['new'] : '';
-		$confirm = isset($post['confirm']) ? $post['confirm'] : '';
-		if (empty($new)) {
-			util::fail('请输入新密码');
-		}
-		if ($new != $confirm) {
-			util::fail('二次密码不一致');
-		}
-		$admin = $this->admin;
-		$adminId = $this->adminId;
-		if (!empty($admin['confirmPassword'])) {
-			if (empty($old)) {
-				util::fail('请填写旧密码');
-			}
-			if (password_verify($old, $admin['confirmPassword']) == false) {
-				util::fail('旧密码错误');
-			}
-		}
-		AdminService::updateById($adminId, ['confirmPassword' => password_hash($new, PASSWORD_BCRYPT)]);
-		util::complete('修改成功');
-	}
-	
-	//登陆员工的详情 shish 2019.12.26
-	public function actionLoginDetail()
-	{
-		$detail = AdminService::getDetail($this->adminId);
-		util::success($detail);
-	}
-	
-	//收款通知 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;
-		$admin = AdminService::getAdminById($id);
-		AdminService::valid($admin, $this->merchantId);
-		AdminService::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;
-		$admin = AdminService::getAdminById($id);
-		AdminService::valid($admin, $this->merchantId);
-		AdminService::updateById($id, ['status' => $status]);
-		util::complete();
-	}
-	
+
+    public $withoutLogin = [];
+
+    //获取登陆员工的权限 shish 2019.11.24
+    public function actionLoginAuth()
+    {
+        $auth = AdminService::getAuth($this->adminId, $this->merchantId);
+        util::success($auth);
+    }
+
+    //员工列表 shish 2019.12.8
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['merchantId'] = $this->merchantId;
+        $where['delStatus'] = 0;
+        $list = AdminService::getAdminList($where);
+        util::success($list);
+    }
+
+    //添加员工 shish 2019.12.8
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->merchantId;
+        $admin = AdminService::addAdmin($post);
+        $id = $admin['id'];
+        $info = AdminService::getDetail($id);
+        util::success($info);
+    }
+
+    //删除员工 shish 2019.12.9
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->post('id');
+        $admin = AdminClass::getById($id);
+        AdminService::valid($admin, $this->merchantId);
+        AdminService::deleteAdmin($admin, $this->adminId);
+        util::complete();
+    }
+
+    //修改员工 shish 2019.12.9
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
+        unset($post['id']);
+        $originalAdmin = AdminService::getById($id);
+        $post['merchantId'] = $this->merchantId;
+        AdminService::updateAdmin($originalAdmin, $post);
+        util::complete('修改成功');
+    }
+
+    //查看员工详情 shish 2019.12.9
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('id');
+        $admin = AdminService::getDetail($id);
+        AdminService::valid($admin, $this->merchantId);
+        util::success($admin);
+    }
+
+    //密码修改
+    public function actionPassword()
+    {
+        $post = Yii::$app->request->post();
+        $old = isset($post['old']) ? $post['old'] : '';
+        $new = isset($post['new']) ? $post['new'] : '';
+        $confirm = isset($post['confirm']) ? $post['confirm'] : '';
+        if (empty($new)) {
+            util::fail('请输入新密码');
+        }
+        if ($new != $confirm) {
+            util::fail('二次密码不一致');
+        }
+        $admin = $this->admin;
+        $adminId = $this->adminId;
+        if (!empty($admin['password'])) {
+            if (empty($old)) {
+                util::fail('请填写旧密码');
+            }
+            if (password_verify($old, $admin['password']) == false) {
+                util::fail('旧密码错误');
+            }
+        }
+        AdminService::updateById($adminId, ['password' => password_hash($new, PASSWORD_BCRYPT)]);
+        util::complete('修改成功');
+    }
+
+    //确认密码修改
+    public function actionConfirmPassword()
+    {
+        $post = Yii::$app->request->post();
+        $old = isset($post['old']) ? $post['old'] : '';
+        $new = isset($post['new']) ? $post['new'] : '';
+        $confirm = isset($post['confirm']) ? $post['confirm'] : '';
+        if (empty($new)) {
+            util::fail('请输入新密码');
+        }
+        if ($new != $confirm) {
+            util::fail('二次密码不一致');
+        }
+        $admin = $this->admin;
+        $adminId = $this->adminId;
+        if (!empty($admin['confirmPassword'])) {
+            if (empty($old)) {
+                util::fail('请填写旧密码');
+            }
+            if (password_verify($old, $admin['confirmPassword']) == false) {
+                util::fail('旧密码错误');
+            }
+        }
+        AdminService::updateById($adminId, ['confirmPassword' => password_hash($new, PASSWORD_BCRYPT)]);
+        util::complete('修改成功');
+    }
+
+    //登陆员工的详情 shish 2019.12.26
+    public function actionLoginDetail()
+    {
+        $detail = AdminService::getDetail($this->adminId);
+        util::success($detail);
+    }
+
+    //收款通知 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;
+        $admin = AdminService::getAdminById($id);
+        AdminService::valid($admin, $this->merchantId);
+        AdminService::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;
+        $admin = AdminService::getAdminById($id);
+        AdminService::valid($admin, $this->merchantId);
+        AdminService::updateById($id, ['status' => $status]);
+        util::complete();
+    }
+
+    //小程序用户完整信息 shish 2019.12.12
+    public function actionMiniFullInfo()
+    {
+        $post = Yii::$app->request->post();
+        $iv = isset($post['iv']) ? $post['iv'] : '';
+        $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
+        $merchant = WxOpenService::getWxInfo();
+        $appId = $merchant['miniAppId'];
+        $admin = $this->admin;
+        $miniOpenId = $admin['miniOpenId'];
+        if (empty($miniOpenId)) {
+            util::fail('没有找到管理员信息(miniOpenId)');
+        }
+        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
+        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
+        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
+        $pc = new \WXBizDataCrypt($appId, $sessionKey);
+        $errCode = $pc->decryptData($encryptedData, $iv, $result);
+        if ($errCode != 0) {
+            Yii::info($result . ' ' . $errCode);
+            util::fail('获取用户信息失败');
+        }
+        Yii::info('小程序获取用户信息:' . $result);
+        $originalInfo = Json::decode($result);
+        $source = UserClass::$userSourceId['mini']['name'];
+        $admin = AdminService::replaceAdmin($originalInfo, $source);
+        $adminId = $admin['id'];
+        $admin = AdminService::getAdminById($adminId);
+        util::success($admin);
+    }
+
+    //小程序用户手机号
+    public function actionMiniMobile()
+    {
+        $post = Yii::$app->request->post();
+        $iv = $post['iv'];
+        $encryptedData = $post['encryptedData'];
+        $merchant = WxOpenService::getWxInfo();
+        $appId = $merchant['miniAppId'];
+        $admin = $this->admin;
+        $miniOpenId = $admin['miniOpenId'];
+        if (empty($miniOpenId)) {
+            util::fail('没有找到管理员信息(miniOpenId)');
+        }
+        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
+        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (empty($sessionKey)) {
+            util::fail('sesstion key empty');
+        }
+        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
+        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
+
+        $pc = new \WXBizDataCrypt($appId, $sessionKey);
+        $errCode = $pc->decryptData($encryptedData, $iv, $result);
+        if ($errCode != 0) {
+            util::fail('解密失败');
+        }
+        $arr = Json::decode($result);
+        $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
+        util::success(['mobile' => $mobile]);
+    }
+
 }

+ 0 - 2
app/shop/controllers/BaseController.php

@@ -16,7 +16,6 @@ class BaseController extends PublicController
 {
 	public $admin, $adminId, $adminAvatar, $account;
 	public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
-	public $openMerchant;
 	public $appId;
 	public $isWx = false;
 	public $isLogin = false;
@@ -68,7 +67,6 @@ class BaseController extends PublicController
 		$this->merchantId = $merchantId;
 		$this->merchant = $merchant;
 		$this->merchantExtend = $merchantExtend;
-		$this->openMerchant = WxOpenService::getWxInfo();
 		return parent::beforeAction($action);
 	}
 

+ 0 - 65
app/shop/controllers/UserController.php

@@ -5,7 +5,6 @@ namespace shop\controllers;
 use biz\admin\services\AdminService;
 use biz\merchant\services\MerchantAssetService;
 use biz\merchant\services\MerchantRemarkService;
-use biz\user\classes\UserClass;
 use biz\user\services\UserAssetService;
 use biz\user\services\UserGrowthService;
 use biz\user\services\UserService;
@@ -18,7 +17,6 @@ use common\services\xhUserIntegralService;
 use Yii;
 use common\components\stringUtil;
 use common\components\util;
-use yii\helpers\Json;
 
 class UserController extends BaseController
 {
@@ -238,67 +236,4 @@ class UserController extends BaseController
         util::complete();
     }
 
-    //小程序用户完整信息 shish 2019.12.12
-    public function actionMiniFullInfo()
-    {
-        $post = Yii::$app->request->post();
-        $iv = isset($post['iv']) ? $post['iv'] : '';
-        $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
-        $merchant = $this->openMerchant;
-        $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
-        $miniOpenId = $admin['miniOpenId'];
-        if (empty($miniOpenId)) {
-            util::fail('没有找到管理员信息(miniOpenId)');
-        }
-        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
-        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
-        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
-        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
-        $pc = new \WXBizDataCrypt($appId, $sessionKey);
-        $errCode = $pc->decryptData($encryptedData, $iv, $result);
-        if ($errCode != 0) {
-            Yii::info($result . ' ' . $errCode);
-            util::fail('获取用户信息失败');
-        }
-        Yii::info('小程序获取用户信息:' . $result);
-        $originalInfo = Json::decode($result);
-        $source = UserClass::$userSourceId['mini']['name'];
-        $admin = AdminService::replaceAdmin($originalInfo, $source);
-        $adminId = $admin['id'];
-        $admin = AdminService::getAdminById($adminId);
-        util::success($admin);
-    }
-
-    //小程序用户手机号
-    public function actionMiniMobile()
-    {
-        $post = Yii::$app->request->post();
-        $iv = $post['iv'];
-        $encryptedData = $post['encryptedData'];
-        $merchant = $this->openMerchant;
-        $appId = $merchant['miniAppId'];
-        $admin = $this->admin;
-        $miniOpenId = $admin['miniOpenId'];
-        if (empty($miniOpenId)) {
-            util::fail('没有找到管理员信息(miniOpenId)');
-        }
-        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
-        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
-        if (empty($sessionKey)) {
-            util::fail('sesstion key empty');
-        }
-        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
-        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
-
-        $pc = new \WXBizDataCrypt($appId, $sessionKey);
-        $errCode = $pc->decryptData($encryptedData, $iv, $result);
-        if ($errCode != 0) {
-            util::fail('解密失败');
-        }
-        $arr = Json::decode($result);
-        $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
-        util::success(['mobile' => $mobile]);
-    }
-
 }