|
|
@@ -8,16 +8,22 @@ use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
use bizGhs\admin\services\AdminService;
|
|
|
use common\components\dict;
|
|
|
-use common\components\noticeUtil;
|
|
|
-use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
+use ghs\models\Admin\AddForm;
|
|
|
+use ghs\models\Admin\BindAutoLoginForm;
|
|
|
+use ghs\models\Admin\ConfirmPasswordForm;
|
|
|
+use ghs\models\Admin\MiniFullInfoForm;
|
|
|
+use ghs\models\Admin\MiniMobileForm;
|
|
|
+use ghs\models\Admin\ModifyPasswordForm;
|
|
|
+use ghs\models\Admin\PasswordForm;
|
|
|
+use ghs\models\Admin\ReplaceClientIdForm;
|
|
|
+use ghs\models\Admin\UpdateAdminForm;
|
|
|
use Yii;
|
|
|
use yii\helpers\Json;
|
|
|
use bizHd\user\classes\UserClass;
|
|
|
|
|
|
class AdminController extends BaseController
|
|
|
{
|
|
|
-
|
|
|
public $guestAccess = ['recent-shop', 'mini-full-info', 'mini-mobile', 'login-detail'];
|
|
|
|
|
|
//清空登录信息 ssh 20240428
|
|
|
@@ -40,18 +46,23 @@ class AdminController extends BaseController
|
|
|
//修改个人信息 ssh 20230505
|
|
|
public function actionUpdateAdmin()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $ghsOpenId = $post['ghsOpenId'] ?? '';
|
|
|
- $name = $post['name'] ?? '';
|
|
|
+ $model = new UpdateAdminForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$admin = $this->admin;
|
|
|
- $admin->ghsOpenId = $ghsOpenId;
|
|
|
- if (!empty($name)) {
|
|
|
- $admin->name = $name;
|
|
|
+ $admin->ghsOpenId = $model->ghsOpenId;
|
|
|
+ if (!empty($model->name)) {
|
|
|
+ $admin->name = $model->name;
|
|
|
}
|
|
|
$admin->save();
|
|
|
- if (!empty($name)) {
|
|
|
+
|
|
|
+ if (!empty($model->name)) {
|
|
|
$adminId = $this->adminId;
|
|
|
- ShopAdminClass::updateByCondition(['adminId' => $adminId], ['name' => $name]);
|
|
|
+ ShopAdminClass::updateByCondition(['adminId' => $adminId], ['name' => $model->name]);
|
|
|
}
|
|
|
util::complete();
|
|
|
}
|
|
|
@@ -59,21 +70,23 @@ class AdminController extends BaseController
|
|
|
//绑定帐号自动登录 ssh 20210121
|
|
|
public function actionBindAutoLogin()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $iv = isset($post['iv']) ? $post['iv'] : '';
|
|
|
- $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
|
|
|
+ $model = new BindAutoLoginForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$merchant = WxOpenClass::getGhsWxInfo();
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
- $miniOpenId = $post['miniOpenId'];
|
|
|
- if (empty($miniOpenId)) {
|
|
|
- util::fail('绑定失败');
|
|
|
- }
|
|
|
+ $miniOpenId = $model->miniOpenId;
|
|
|
+
|
|
|
$cacheKey = 'GHS_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);
|
|
|
+ $errCode = $pc->decryptData($model->encryptedData, $model->iv, $result);
|
|
|
if ($errCode != 0) {
|
|
|
Yii::info($result . ' ' . $errCode);
|
|
|
util::fail('绑定失败了');
|
|
|
@@ -96,12 +109,15 @@ class AdminController extends BaseController
|
|
|
//修改保存安卓clientId
|
|
|
public function actionReplaceClientId()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $id = $get['id'] ?? '';
|
|
|
- if (empty($id)) {
|
|
|
+ $model = new ReplaceClientIdForm();
|
|
|
+ $model->load(Yii::$app->request->get(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
util::success(['returnStatus' => 'FAILURE']);
|
|
|
+ return;
|
|
|
}
|
|
|
- $this->admin->clientId = $id;
|
|
|
+
|
|
|
+ $this->admin->clientId = $model->id;
|
|
|
$this->admin->save();
|
|
|
//noticeUtil::push("保存客户端ID:" . $id, '15280215347');
|
|
|
util::complete();
|
|
|
@@ -110,14 +126,15 @@ class AdminController extends BaseController
|
|
|
//修改密码 ssh 20220106
|
|
|
public function actionModifyPassword()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $password = $get['password'] ?? '';
|
|
|
- if (empty($password)) {
|
|
|
- util::fail('请填写密码');
|
|
|
+ $model = new ModifyPasswordForm();
|
|
|
+ $model->load(Yii::$app->request->get(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
}
|
|
|
- stringUtil::passwordCheck($password);
|
|
|
+
|
|
|
$adminId = $this->adminId;
|
|
|
- $password = password_hash($password, PASSWORD_BCRYPT);
|
|
|
+ $password = password_hash($model->password, PASSWORD_BCRYPT);
|
|
|
AdminClass::updateById($adminId, ['password' => $password]);
|
|
|
util::complete('操作成功');
|
|
|
}
|
|
|
@@ -140,8 +157,15 @@ class AdminController extends BaseController
|
|
|
//添加员工 ssh 2019.12.8
|
|
|
public function actionAdd()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $post['sjId'] = $this->sjId;
|
|
|
+ $model = new AddForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+ $model->sjId = $this->sjId;
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $post = $model->attributes;
|
|
|
$admin = AdminService::addAdmin($post);
|
|
|
$id = $admin['id'];
|
|
|
$info = AdminService::getDetail($id);
|
|
|
@@ -171,54 +195,32 @@ class AdminController extends BaseController
|
|
|
//密码修改
|
|
|
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('二次密码不一致');
|
|
|
+ $model = new PasswordForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+ $model->setAdmin($this->admin);
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
}
|
|
|
- $admin = $this->admin->attributes;
|
|
|
+
|
|
|
$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)]);
|
|
|
+ AdminService::updateById($adminId, ['password' => password_hash($model->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('二次密码不一致');
|
|
|
+ $model = new ConfirmPasswordForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+ $model->setAdmin($this->admin);
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
}
|
|
|
- $admin = $this->admin->attributes;
|
|
|
+
|
|
|
$adminId = $this->adminId;
|
|
|
- if (!empty($admin['payPassword'])) {
|
|
|
- if (empty($old)) {
|
|
|
- util::fail('请填写旧密码');
|
|
|
- }
|
|
|
- if (password_verify($old, $admin['payPassword']) == false) {
|
|
|
- util::fail('旧密码错误');
|
|
|
- }
|
|
|
- }
|
|
|
- AdminService::updateById($adminId, ['payPassword' => password_hash($new, PASSWORD_BCRYPT)]);
|
|
|
+ AdminService::updateById($adminId, ['payPassword' => password_hash($model->new, PASSWORD_BCRYPT)]);
|
|
|
util::complete('修改成功');
|
|
|
}
|
|
|
|
|
|
@@ -232,9 +234,13 @@ class AdminController extends BaseController
|
|
|
//小程序用户完整信息 ssh 2019.12.12
|
|
|
public function actionMiniFullInfo()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $iv = isset($post['iv']) ? $post['iv'] : '';
|
|
|
- $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
|
|
|
+ $model = new MiniFullInfoForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$merchant = WxOpenClass::getGhsWxInfo();
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
$admin = $this->admin;
|
|
|
@@ -252,7 +258,7 @@ class AdminController extends BaseController
|
|
|
$wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
$pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
- $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ $errCode = $pc->decryptData($model->encryptedData, $model->iv, $result);
|
|
|
if ($errCode != 0) {
|
|
|
Yii::info($result . ' ' . $errCode);
|
|
|
util::fail('获取用户信息失败');
|
|
|
@@ -272,9 +278,13 @@ class AdminController extends BaseController
|
|
|
//小程序用户手机号
|
|
|
public function actionMiniMobile()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $iv = $post['iv'];
|
|
|
- $encryptedData = $post['encryptedData'];
|
|
|
+ $model = new MiniMobileForm();
|
|
|
+ $model->load(Yii::$app->request->post(), '');
|
|
|
+
|
|
|
+ if (!$model->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$merchant = WxOpenClass::getGhsWxInfo();
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
$admin = $this->admin->attributes;
|
|
|
@@ -291,7 +301,7 @@ class AdminController extends BaseController
|
|
|
require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
|
|
|
$pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
- $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ $errCode = $pc->decryptData($model->encryptedData, $model->iv, $result);
|
|
|
if ($errCode != 0) {
|
|
|
util::fail('解密失败');
|
|
|
}
|