|
|
@@ -4,7 +4,6 @@ namespace ghs\controllers;
|
|
|
|
|
|
use biz\admin\classes\AdminClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
-use bizGhs\admin\services\AdminService;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\admin\services\AdminRoleService;
|
|
|
@@ -21,6 +20,56 @@ class ShopAdminController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['generate-admin'];
|
|
|
|
|
|
+ //设置店长 ssh 20250711
|
|
|
+ public function actionSetManager()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $staff = ShopAdminClass::getById($id, true);
|
|
|
+ if (empty($staff)) {
|
|
|
+ util::fail('没有员工');
|
|
|
+ }
|
|
|
+ if ($staff->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的');
|
|
|
+ }
|
|
|
+ $current = $this->shopAdmin;
|
|
|
+ if ($current->mobile != 15280215347) {
|
|
|
+ util::fail('无效操作');
|
|
|
+ }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $staff->founder = 2;
|
|
|
+ $staff->save();
|
|
|
+
|
|
|
+ $newAdminId = $staff->adminId;
|
|
|
+
|
|
|
+ $mainId = $staff->mainId;
|
|
|
+ $shopList = ShopClass::getAllByCondition(['mainId' => $mainId], null, 'id,shopName,mainId,adminId', null, true);
|
|
|
+ $adminId = 0;
|
|
|
+ if (!empty($shopList)) {
|
|
|
+ foreach ($shopList as $shop) {
|
|
|
+ if (!empty($shop->adminId)) {
|
|
|
+ $adminId = $shop->adminId;
|
|
|
+ }
|
|
|
+ $shop->adminId = $newAdminId;
|
|
|
+ $shop->save();
|
|
|
+ }
|
|
|
+ if (!empty($adminId)) {
|
|
|
+ ShopAdminClass::updateByCondition(['mainId' => $mainId, 'adminId' => $adminId], ['founder' => 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('操作成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("操作失败原因:" . $e->getMessage());
|
|
|
+ util::fail('操作失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//获取当前登录员工的信息 ssh 20230802
|
|
|
public function actionGetStaffInfo()
|
|
|
{
|
|
|
@@ -31,7 +80,8 @@ class ShopAdminController extends BaseController
|
|
|
//获取所有在职员工 ssh 20220507
|
|
|
public function actionGetAllStaff()
|
|
|
{
|
|
|
- $list = ShopAdminClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0, 'status' => 1, 'isPt' => 0,], 'inTurn DESC', 'id,name,mobile', null, true);
|
|
|
+ $where = ['mainId' => $this->mainId, 'delStatus' => 0, 'status' => 1, 'isPt' => 0,];
|
|
|
+ $list = ShopAdminClass::getAllByCondition($where, 'inTurn DESC', 'id,name,mobile', null, true);
|
|
|
util::success(['list' => $list]);
|
|
|
}
|
|
|
|