|
|
@@ -5,7 +5,6 @@ namespace bizHd\staff\classes;
|
|
|
use bizHd\admin\classes\AdminClass;
|
|
|
use bizHd\admin\classes\AdminRoleClass;
|
|
|
use bizHd\shop\classes\ShopClass;
|
|
|
-use common\components\dict;
|
|
|
use common\components\sms;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -16,6 +15,45 @@ class StaffClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\staff\models\Staff';
|
|
|
|
|
|
+ //删除员工 ssh 2021.5.3
|
|
|
+ public static function deleteStaff($relation, $thisShopAdminId, $mainId)
|
|
|
+ {
|
|
|
+ $id = $relation->id ?? 0;
|
|
|
+ if ($relation->founder == 2) {
|
|
|
+ util::fail("超管不能删除");
|
|
|
+ }
|
|
|
+ if ($id == $thisShopAdminId) {
|
|
|
+ util::fail("不能删自己");
|
|
|
+ }
|
|
|
+ self::valid($relation, $mainId);
|
|
|
+ $adminId = $relation->adminId ?? 0;
|
|
|
+ $currentShopId = $relation->shopId ?? 0;
|
|
|
+ $admin = AdminClass::getById($adminId, true);
|
|
|
+ if (empty($admin)) {
|
|
|
+ util::fail('没有找到员工信息');
|
|
|
+ }
|
|
|
+ $admin->currentShopId = 0;
|
|
|
+ $admin->save();
|
|
|
+ $relation->delStatus = 1;
|
|
|
+ $relation->save();
|
|
|
+ //删除员工关系后,再找出这个员工还有没其它门店员工身份补上
|
|
|
+ if (!empty($admin) && isset($admin->currentShopId) && $admin->currentShopId == $currentShopId) {
|
|
|
+ $has = self::getByCondition(['adminId' => $adminId, 'delStatus' => 0, 'status' => 1], true);
|
|
|
+ $hasCurrentShopId = $has->shopId ?? 0;
|
|
|
+ $admin->currentShopId = $hasCurrentShopId;
|
|
|
+ $admin->save();
|
|
|
+ }
|
|
|
+ // 员工数-1
|
|
|
+ AdminRoleClass::counters(['num' => -1], ['id' => $relation->roleId]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function valid($relation, $mainId)
|
|
|
+ {
|
|
|
+ if (isset($relation->mainId) == false || $relation->mainId != $mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//创建员工 ssh 2021.5.9
|
|
|
public static function appGenerateStaff($data, $admin)
|
|
|
{
|