|
|
@@ -62,7 +62,7 @@ class AdminClass extends BaseClass
|
|
|
{
|
|
|
$detail = AdminClass::getById($id);
|
|
|
if (empty($detail)) {
|
|
|
- util::fail('没有找到员工信息');
|
|
|
+ util::fail('没有找到员工信息!');
|
|
|
}
|
|
|
$list = self::groupAdminBaseInfo([$detail]);
|
|
|
return current($list);
|
|
|
@@ -238,7 +238,7 @@ class AdminClass extends BaseClass
|
|
|
} else {
|
|
|
$user = self::updateAdminInfo($user, $adminInfo);
|
|
|
}
|
|
|
- //存在相同unionid则进行合并
|
|
|
+ //存在相同unionId进行合并
|
|
|
$unionId = isset($adminInfo['unionId']) ? $adminInfo['unionId'] : '';
|
|
|
if (!empty($unionId)) {
|
|
|
$same = self::getSameUnionId($unionId);
|
|
|
@@ -256,9 +256,12 @@ class AdminClass extends BaseClass
|
|
|
$data = [];
|
|
|
$adminId = $originalUser['id'];
|
|
|
//替换掉微信不支持的图片
|
|
|
- $userName = isset($getUserInfo['userName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getUserInfo['userName']) : '';
|
|
|
- if (!empty($userName)) {
|
|
|
- $data['userName'] = $userName;
|
|
|
+ $nickname = isset($getUserInfo['nickname']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getUserInfo['nickname']) : '';
|
|
|
+ if (!empty($nickname)) {
|
|
|
+ $data['nickname'] = $nickname;
|
|
|
+ }
|
|
|
+ if (isset($originalUser['adminName']) && empty($originalUser['adminName'])) {
|
|
|
+ $data['adminName'] = $nickname;
|
|
|
}
|
|
|
if (isset($getUserInfo['openId']) && !empty($getUserInfo['openId'])) {
|
|
|
$openId = $getUserInfo['openId'];
|
|
|
@@ -303,10 +306,11 @@ class AdminClass extends BaseClass
|
|
|
|
|
|
public static function generateAdmin($getAdminInfo)
|
|
|
{
|
|
|
- $date = date("Y-m-d H:i:s");
|
|
|
$time = time();
|
|
|
//替换掉微信名称不支持的图片
|
|
|
- $getAdminInfo['adminName'] = isset($getAdminInfo['userName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['userName']) : '';
|
|
|
+ $nickname = isset($getAdminInfo['nickname']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickname']) : '';
|
|
|
+ $getAdminInfo['nickname'] = $nickname;
|
|
|
+ $getAdminInfo['adminName'] = $nickname;
|
|
|
$subscribe = isset($getAdminInfo['subscribe']) ? $getAdminInfo['subscribe'] : 0;
|
|
|
$getAdminInfo['subscribe'] = $subscribe;
|
|
|
$getAdminInfo['avatar'] = '';
|
|
|
@@ -316,11 +320,20 @@ class AdminClass extends BaseClass
|
|
|
$getAdminInfo['addTime'] = $time;
|
|
|
$getAdminInfo['source'] = isset($getAdminInfo['source']) ? $getAdminInfo['source'] : 0;
|
|
|
$getAdminInfo['hasSubscribe'] = 0;
|
|
|
- //生成用户基础信息
|
|
|
+
|
|
|
+ $merchantId = 0;
|
|
|
+ if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
|
|
|
+ $imgUrl = $getAdminInfo['headImgUrl'];
|
|
|
+ $name = ImageService::generateAvatar($merchantId, $imgUrl);
|
|
|
+ if (!empty($name)) {
|
|
|
+ $getAdminInfo['avatar'] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$admin = self::add($getAdminInfo);
|
|
|
$adminId = $admin['id'];
|
|
|
- if (empty($admin['adminName'])) {
|
|
|
- self::updateById($adminId, ['adminName' => $adminId]);
|
|
|
+ if (empty($nickname)) {
|
|
|
+ self::updateById($adminId, ['adminName' => $adminId, 'nickname' => $adminId]);
|
|
|
}
|
|
|
return $admin;
|
|
|
}
|
|
|
@@ -331,6 +344,11 @@ class AdminClass extends BaseClass
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
+
|
|
|
+ $delAdminId = $delAdmin['id'];
|
|
|
+ $clearData = ['openId' => '', 'miniOpenId' => '', 'unionId' => ''];
|
|
|
+ self::updateById($delAdminId, $clearData);
|
|
|
+
|
|
|
$transaction->commit();
|
|
|
} catch (Exception $e) {
|
|
|
$transaction->rollBack();
|