|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
+use biz\admin\classes\AdminClass;
|
|
|
+use biz\shop\classes\ShopAdminClass;
|
|
|
use bizHd\admin\services\AdminRoleService;
|
|
|
use bizHd\admin\services\ShopAdminService;
|
|
|
use bizHd\wx\services\WxOpenService;
|
|
|
@@ -16,67 +18,112 @@ class ShopAdminController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['generate-admin'];
|
|
|
|
|
|
- //创建管理员数据准备 ssh 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->sjId) {
|
|
|
- util::fail('请选择角色!');
|
|
|
- }
|
|
|
- unset($post['userId']);
|
|
|
- unset($post['status']);
|
|
|
- $post['shopId'] = $this->shopId;
|
|
|
- $post['adminId'] = $this->adminId;
|
|
|
- $merchant = WxOpenService::getWxInfo();
|
|
|
- $post['merchant'] = $merchant;
|
|
|
- $respond = ShopAdminService::prepareBindAdmin($post);
|
|
|
- $miniCode = isset($respond['miniCode']) ? imgUtil::getPrefix() . $respond['miniCode'] : '';
|
|
|
- util::success(['miniCode' => $miniCode]);
|
|
|
- }
|
|
|
-
|
|
|
- //创建管理员 ssh 2020.4.20
|
|
|
- public function actionGenerateAdmin()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $respond = ShopAdminService::generateAdmin($post);
|
|
|
- util::success($respond);
|
|
|
- }
|
|
|
-
|
|
|
- //收款通知 ssh 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();
|
|
|
- }
|
|
|
-
|
|
|
- //启用与停用 ssh 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();
|
|
|
- }
|
|
|
+ //创建管理员数据准备 ssh 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->sjId) {
|
|
|
+ util::fail('请选择角色!');
|
|
|
+ }
|
|
|
+ unset($post['userId']);
|
|
|
+ unset($post['status']);
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['adminId'] = $this->adminId;
|
|
|
+ $merchant = WxOpenService::getWxInfo();
|
|
|
+ $post['merchant'] = $merchant;
|
|
|
+ $respond = ShopAdminService::prepareBindAdmin($post);
|
|
|
+ $miniCode = isset($respond['miniCode']) ? imgUtil::getPrefix() . $respond['miniCode'] : '';
|
|
|
+ util::success(['miniCode' => $miniCode]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建管理员 ssh 2020.4.20
|
|
|
+ public function actionGenerateAdmin()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $respond = ShopAdminService::generateAdmin($post);
|
|
|
+ util::success($respond);
|
|
|
+ }
|
|
|
+
|
|
|
+ //收款通知 ssh 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ //启用与停用 ssh 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ //员工列表 ssh 2019.12.8
|
|
|
+ public function actionList()
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $where['shopId'] = $this->shopId;
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $list = ShopAdminService::getAdminList($where);
|
|
|
+ util::success($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取员工信息 ssh 2021.1.13
|
|
|
+ public function actionDetail()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = isset($get['id']) ? $get['id'] : 0;
|
|
|
+ $respond = ShopAdminClass::getAdminInfo($id);
|
|
|
+ ShopAdminClass::valid($respond, $this->shopId);
|
|
|
+ util::success($respond);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改员工信息
|
|
|
+ public function actionUpdate()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $id = $post['id'] ?? 0;
|
|
|
+ if (empty($id)) {
|
|
|
+ util::fail('请选择员工');
|
|
|
+ }
|
|
|
+ $relation = ShopAdminClass::getById($id, true);
|
|
|
+ if (empty($relation)) {
|
|
|
+ util::fail('没有找到员工');
|
|
|
+ }
|
|
|
+ ShopAdminClass::valid($relation, $this->shopId);
|
|
|
+ unset($post['id']);
|
|
|
+ $roleId = $post['roleId'] ?? 0;
|
|
|
+ $remind = $post['remind'] ?? 0;
|
|
|
+ $status = $post['status'] ?? 1;
|
|
|
+ $relation->roleId = $roleId;
|
|
|
+ $relation->remind = $remind;
|
|
|
+ $relation->status = $status;
|
|
|
+ if (isset($post['name']) && !empty($post['name'])) {
|
|
|
+ $relation->name = $post['name'];
|
|
|
+ }
|
|
|
+ $relation->save();
|
|
|
+
|
|
|
+ //若有传密码,则修改密码
|
|
|
+ $password = $post['password'] ?? '';
|
|
|
+ if (!empty($password)) {
|
|
|
+ $adminId = $relation->adminId;
|
|
|
+ $password = password_hash($password, PASSWORD_BCRYPT);
|
|
|
+ AdminClass::updateById($adminId, ['password' => $password]);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::complete('修改成功');
|
|
|
+ }
|
|
|
|
|
|
- //员工列表 ssh 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);
|
|
|
- }
|
|
|
-
|
|
|
}
|