$val) { if (!is_array($val)) { $params[] = $key; $params[] = $val; } } } Yii::$app->redis->executeCommand('HMSET', $params); } //获取创建管理员需要的信息 ssh 2020.4.20 public static function getBindAdminData($mainId, $adminId) { $cacheKey = self::getGenerateAdminDataKey($mainId, $adminId); $cacheData = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]); $data = []; if (!empty($cacheData)) { $data = []; $list = []; $x = 0; foreach ($cacheData as $cKey => $cVal) { if ($cKey % 2 == 0) { $list[$x]['key'] = $cVal; } else { $list[$x]['value'] = $cVal; $x++; } } foreach ($list as $lKey => $lVal) { $data[$lVal['key']] = $lVal['value']; } } return $data; } //删除创建管理员需要的信息 ssh 2020.4.20 public static function delBindAdminData($mainId, $adminId) { $cacheKey = self::getGenerateAdminDataKey($mainId, $adminId); $keyNameList = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]); if (!empty($keyNameList)) { $data = array_merge([$cacheKey], $keyNameList); $cacheData = Yii::$app->redis->executeCommand('HDEL', $data); } } //取店长信息 ssh 2021.1.8 public static function getManager($mainId) { $relate = self::getByCondition(['mainId' => $mainId, 'founder' => 2]); $adminId = isset($relate['adminId']) ? $relate['adminId'] : 0; $info = []; if (!empty($adminId)) { $info = AdminClass::getById($adminId); } return $info; } public static function valid($adminInfo, $mainId) { if (isset($adminInfo['mainId']) && $adminInfo['mainId'] == $mainId) { return true; } util::fail('此员工您无法操作'); } //切换门店时增加员工关系 ssh 2021.3.1 public static function changeShopAddRelate($originShopAdmin, $newShop, $isPt = 0) { $newMainId = $newShop->mainId ?? 0; $name = $originShopAdmin->name ?? ''; $mobile = $originShopAdmin->mobile ?? 0; $avatar = $originShopAdmin->avatar ?? ''; $adminId = $originShopAdmin->adminId ?? 0; $roleId = $originShopAdmin->roleId ?? 0; $sjId = $originShopAdmin->sjId ?? 0; $super = $originShopAdmin->super ?? 0; $has = self::getByCondition(['mainId' => $newMainId, 'adminId' => $adminId], true); if (!empty($has)) { $has->delStatus = 0; $has->save(); return $has; } $data = [ 'name' => $name, 'mobile' => $mobile, 'avatar' => $avatar, 'roleId' => $roleId, 'adminId' => $adminId, 'sjId' => $sjId, 'super' => $super, 'mainId' => $newMainId, 'isPt' => $isPt, ]; $return = self::addShopAdmin($data, true); return $return; } //员工收款通知 ssh 2021.4.19 public static function incomeNotice($shopId, $money, $payWay = 0) { $list = self::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0, 'status' => 1], null, '*'); if (empty($list)) { return false; } foreach ($list as $key => $val) { if ($val['remind'] == 1) { $id = $val['id']; Yii::info("income notice shopAdminId:{$id} " . $money); WsService::arrivalNotice($id, $money, $payWay); } } } //获取基本信息 ssh 2021.4.23 public static function getAdminInfo($id) { $relation = self::getById($id); if (empty($relation)) { util::fail('没有找到员工信息'); } return $relation; } //是否有切换门店权限 0不是 1是 public static function hasSwitchShopRight($shopAdmin) { $hasRight = 0; if ($shopAdmin->switchShop == 1) { $hasRight = 1; } $ptAdminId = AdminClass::getPtSuperAdminId(); if ($shopAdmin->adminId == $ptAdminId) { $hasRight = 1; } return $hasRight; } //删除员工 ssh 2021.5.3 public static function deleteShopAdmin($relation, $thisShopAdminId, $mainId) { $id = $relation->id ?? 0; if ($relation->founder == 2) { util::fail("不能删老板"); } if ($id == $thisShopAdminId) { util::fail("不能删自己"); } ShopAdminClass::valid($relation, $mainId); $adminId = $relation->adminId ?? 0; $admin = AdminClass::getById($adminId, true); if (empty($admin)) { util::fail('没有找到员工信息'); } //员工离职,多处使用,关键词 staff_lz StaffClass::executeStaffResignation($admin, $relation); } //根据shopId 获取 员工的shopAdminId //通过shopId 获取相应的需要通知的 shopAdminIds (status=1 and delStatus=0 and remind=1) public static function getRemindShopAdminIdsByShopId($shopId) { $where = [ 'shopId' => $shopId, 'status' => 1, 'delStatus' => 0, 'remind' => 1 ]; $data = self::getAllByCondition($where, null, "id"); return array_column($data, 'id'); } //通过shopId 获取相应的需要通知的 adminIds (status=1 and delStatus=0 and remind=1) public static function getRemindAdminIdsByShopId($shopId) { $where = [ 'shopId' => $shopId, 'status' => 1, 'delStatus' => 0, 'remind' => 1 ]; $data = self::getAllByCondition($where, null, "adminId"); return array_column($data, 'adminId'); } //获取需要通知的员工 ssh 20220822 public static function getRemainAdmin($shop) { $mainId = $shop->mainId ?? 0; $where = ['mainId' => $mainId, 'status' => 1, 'delStatus' => 0, 'remind' => 1]; $shopAdmin = self::getAllByCondition($where, null, 'id,adminId'); if (empty($shopAdmin)) { return []; } $ids = array_column($shopAdmin, 'adminId'); $admin = AdminClass::getByIds($ids); return $admin; } }