优化通过邀请链接邀请成员逻辑
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
fec6c56d27
commit
e091fd72cc
@ -38,11 +38,11 @@ class MemberAccount extends CommonModel
|
|||||||
{
|
{
|
||||||
$hasJoined = MemberAccount::where(['member_code' => $memberCode, 'organization_code' => $organizationCode])->find();
|
$hasJoined = MemberAccount::where(['member_code' => $memberCode, 'organization_code' => $organizationCode])->find();
|
||||||
if ($hasJoined) {
|
if ($hasJoined) {
|
||||||
throw new \Exception('已加入该组织', 3);
|
return error(3, '已加入该组织');
|
||||||
}
|
}
|
||||||
$memberDate = Member::where(['code' => $memberCode])->find();
|
$memberDate = Member::where(['code' => $memberCode])->find();
|
||||||
if (!$memberDate) {
|
if (!$memberDate) {
|
||||||
throw new \Exception('该用户不存在', 4);
|
return error(4, '该用户不存在');
|
||||||
}
|
}
|
||||||
$auth = ProjectAuth::where(['organization_code' => $organizationCode, 'is_default' => 1])->field('id')->find();
|
$auth = ProjectAuth::where(['organization_code' => $organizationCode, 'is_default' => 1])->field('id')->find();
|
||||||
$authId = '';
|
$authId = '';
|
||||||
|
@ -39,6 +39,7 @@ class ProjectMember extends CommonModel
|
|||||||
'join_time' => nowTime()
|
'join_time' => nowTime()
|
||||||
];
|
];
|
||||||
$result = self::create($data);
|
$result = self::create($data);
|
||||||
|
MemberAccount::inviteMember(getCurrentMember()['code'], $project['organization_code']);
|
||||||
Project::projectHook(getCurrentMember()['code'], $projectCode, 'inviteMember', $memberCode);
|
Project::projectHook(getCurrentMember()['code'], $projectCode, 'inviteMember', $memberCode);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace app\project\controller;
|
|||||||
|
|
||||||
use app\common\Model\Member;
|
use app\common\Model\Member;
|
||||||
use app\common\Model\MemberAccount;
|
use app\common\Model\MemberAccount;
|
||||||
|
use app\common\Model\Organization;
|
||||||
use app\common\Model\SystemConfig;
|
use app\common\Model\SystemConfig;
|
||||||
use controller\BasicApi;
|
use controller\BasicApi;
|
||||||
use service\FileService;
|
use service\FileService;
|
||||||
@ -153,13 +154,23 @@ class Account extends BasicApi
|
|||||||
if (!$organization) {
|
if (!$organization) {
|
||||||
$this->error('该组织不存在');
|
$this->error('该组织不存在');
|
||||||
}
|
}
|
||||||
try {
|
$result = MemberAccount::inviteMember(getCurrentMember()['code'], $organization['code']);
|
||||||
MemberAccount::inviteMember(getCurrentMember()['code'], $organization['code']);
|
if (isError($result)) {
|
||||||
} catch (\Exception $e) {
|
$this->error($result['msg'], $result['errno']);
|
||||||
$this->error($e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->success('');
|
$currentOrganization = null;
|
||||||
|
$list = MemberAccount::where(['member_code' => getCurrentMember()['code']])->order('id asc')->select()->toArray();
|
||||||
|
$organizationList = [];
|
||||||
|
if ($list) {
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$organizationInfo = Organization::where(['code' => $item['organization_code']])->find();
|
||||||
|
if ($organizationInfo) {
|
||||||
|
$organizationList[] = $organizationInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->success('', ['organizationList' => $organizationList, 'currentOrganization' => $organization]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ namespace app\project\controller;
|
|||||||
use app\common\Model\InviteLink;
|
use app\common\Model\InviteLink;
|
||||||
use app\common\Model\Member;
|
use app\common\Model\Member;
|
||||||
use app\common\Model\MemberAccount;
|
use app\common\Model\MemberAccount;
|
||||||
|
use app\common\Model\Organization;
|
||||||
use controller\BasicApi;
|
use controller\BasicApi;
|
||||||
use think\facade\Request;
|
use think\facade\Request;
|
||||||
|
|
||||||
@ -122,7 +123,19 @@ class ProjectMember extends BasicApi
|
|||||||
$this->error($e->getMessage(), $e->getCode());
|
$this->error($e->getMessage(), $e->getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->success('');
|
$currentOrganization = null;
|
||||||
|
$list = MemberAccount::where(['member_code' => getCurrentMember()['code']])->order('id asc')->select()->toArray();
|
||||||
|
$organizationList = [];
|
||||||
|
if ($list) {
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$organization = Organization::where(['code' => $item['organization_code']])->find();
|
||||||
|
if ($organization) {
|
||||||
|
$organizationList[] = $organization;
|
||||||
|
}
|
||||||
|
$item['organization_code'] == $project['organization_code'] && $currentOrganization = $organization;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->success('', ['organizationList' => $organizationList, 'currentOrganization' => $currentOrganization]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user