新增通过链接邀请项目成员
This commit is contained in:
parent
a9ab9baf59
commit
ea4b622d8d
@ -14,9 +14,9 @@ class DepartmentMember extends CommonModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $accountCode
|
* @param $accountCode
|
||||||
* @param string $departmentCode
|
* @param string $departmentCode 部门code
|
||||||
* @param int $isOwner
|
* @param int $isOwner 是否拥有者
|
||||||
* @param int $isPrincipal
|
* @param int $isPrincipal 是否负责人
|
||||||
* @return DepartmentMember|MemberAccount
|
* @return DepartmentMember|MemberAccount
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
@ -51,33 +51,12 @@ class DepartmentMember extends CommonModel
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
$hasJoined = MemberAccount::where(['member_code' => $accountCode, 'organization_code' => $orgCode])->find();
|
try {
|
||||||
if ($hasJoined) {
|
$result = MemberAccount::inviteMember($accountCode, $orgCode);
|
||||||
throw new \Exception('已加入该组织', 3);
|
} catch (\Exception $e) {
|
||||||
|
throw new \Exception($e->getMessage(), 3);
|
||||||
}
|
}
|
||||||
$memberDate = Member::where(['code' => $accountCode])->find();
|
return $result;
|
||||||
if (!$memberDate) {
|
|
||||||
throw new \Exception('该用户不存在', 4);
|
|
||||||
}
|
|
||||||
$auth = ProjectAuth::where(['organization_code' => $orgCode, 'is_default' => 1])->field('id')->find();
|
|
||||||
$authId = '';
|
|
||||||
if ($auth) {
|
|
||||||
$authId = $auth['id'];//权限id
|
|
||||||
}
|
|
||||||
$data = [
|
|
||||||
'position' => '资深工程师',
|
|
||||||
'department' => '某某公司-某某某事业群-某某平台部-某某技术部',
|
|
||||||
'code' => createUniqueCode('memberAccount'),
|
|
||||||
'member_code' => $accountCode,
|
|
||||||
'organization_code' => $orgCode,
|
|
||||||
'is_owner' => 0,
|
|
||||||
'authorize' => $authId,
|
|
||||||
'status' => 1,
|
|
||||||
'create_time' => nowTime(),
|
|
||||||
'name' => $memberDate['name'],
|
|
||||||
'email' => $memberDate['email'],
|
|
||||||
];
|
|
||||||
return MemberAccount::create($data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,19 +36,26 @@ class InviteLink extends CommonModel
|
|||||||
switch ($inviteType) {
|
switch ($inviteType) {
|
||||||
case 'project':
|
case 'project':
|
||||||
$source = Project::where(['code' => $sourceCode])->find();
|
$source = Project::where(['code' => $sourceCode])->find();
|
||||||
|
break;
|
||||||
|
case 'organization':
|
||||||
|
$source = Organization::where(['code' => $sourceCode])->find();
|
||||||
}
|
}
|
||||||
if (!$source) {
|
if (!$source) {
|
||||||
throw new \Exception('该资源不存在', 1);
|
throw new \Exception('该资源不存在', 1);
|
||||||
}
|
}
|
||||||
$fileData = [
|
if (!$inviteLink) {
|
||||||
'code' => createUniqueCode('inviteLink'),
|
$fileData = [
|
||||||
'create_by' => $memberCode,
|
'code' => createUniqueCode('inviteLink'),
|
||||||
'invite_type' => $inviteType,
|
'create_by' => $memberCode,
|
||||||
'source_code' => $sourceCode,
|
'invite_type' => $inviteType,
|
||||||
'create_time' => nowTime(),
|
'source_code' => $sourceCode,
|
||||||
'over_time' => Date('Y-m-d H:i:s', strtotime(nowTime()) + 3600 * 24),
|
'create_time' => nowTime(),
|
||||||
];
|
'over_time' => Date('Y-m-d H:i:s', strtotime(nowTime()) + 3600 * 24),
|
||||||
$result = self::create($fileData);
|
];
|
||||||
|
$result = self::create($fileData);
|
||||||
|
}else{
|
||||||
|
$result = $inviteLink;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +70,13 @@ class InviteLink extends CommonModel
|
|||||||
if ($linkDetail) {
|
if ($linkDetail) {
|
||||||
$link['name'] = $linkDetail['name'];
|
$link['name'] = $linkDetail['name'];
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 'organization':
|
||||||
|
$link['name'] = '';
|
||||||
|
$linkDetail = Organization::where(['code' => $link['source_code']])->field('id', true)->find();
|
||||||
|
if ($linkDetail) {
|
||||||
|
$link['name'] = $linkDetail['name'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$link['member'] = Member::where(['code' => $link['create_by']])->field('id', true)->find();
|
$link['member'] = Member::where(['code' => $link['create_by']])->field('id', true)->find();
|
||||||
$link['sourceDetail'] = $linkDetail;
|
$link['sourceDetail'] = $linkDetail;
|
||||||
|
@ -25,6 +25,46 @@ class MemberAccount extends CommonModel
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请成员
|
||||||
|
* @param $memberCode
|
||||||
|
* @param $organizationCode
|
||||||
|
* @return MemberAccount
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @throws \think\exception\DbException
|
||||||
|
*/
|
||||||
|
public static function inviteMember($memberCode, $organizationCode)
|
||||||
|
{
|
||||||
|
$hasJoined = MemberAccount::where(['member_code' => $memberCode, 'organization_code' => $organizationCode])->find();
|
||||||
|
if ($hasJoined) {
|
||||||
|
throw new \Exception('已加入该组织', 3);
|
||||||
|
}
|
||||||
|
$memberDate = Member::where(['code' => $memberCode])->find();
|
||||||
|
if (!$memberDate) {
|
||||||
|
throw new \Exception('该用户不存在', 4);
|
||||||
|
}
|
||||||
|
$auth = ProjectAuth::where(['organization_code' => $organizationCode, 'is_default' => 1])->field('id')->find();
|
||||||
|
$authId = '';
|
||||||
|
if ($auth) {
|
||||||
|
$authId = $auth['id'];//权限id
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'position' => '资深工程师',
|
||||||
|
'department' => '某某公司-某某某事业群-某某平台部-某某技术部',
|
||||||
|
'code' => createUniqueCode('memberAccount'),
|
||||||
|
'member_code' => $memberCode,
|
||||||
|
'organization_code' => $organizationCode,
|
||||||
|
'is_owner' => 0,
|
||||||
|
'authorize' => $authId,
|
||||||
|
'status' => 1,
|
||||||
|
'create_time' => nowTime(),
|
||||||
|
'name' => $memberDate['name'],
|
||||||
|
'email' => $memberDate['email'],
|
||||||
|
];
|
||||||
|
return MemberAccount::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param File $file
|
* @param File $file
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace app\project\controller;
|
namespace app\project\controller;
|
||||||
|
|
||||||
use app\common\Model\Member;
|
use app\common\Model\Member;
|
||||||
|
use app\common\Model\MemberAccount;
|
||||||
use app\common\Model\SystemConfig;
|
use app\common\Model\SystemConfig;
|
||||||
use controller\BasicApi;
|
use controller\BasicApi;
|
||||||
use service\FileService;
|
use service\FileService;
|
||||||
@ -21,7 +22,7 @@ class Account extends BasicApi
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
if (!$this->model) {
|
if (!$this->model) {
|
||||||
$this->model = new \app\common\Model\MemberAccount();
|
$this->model = new MemberAccount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ class Account extends BasicApi
|
|||||||
list($start, $end) = explode('~', $params['date']);
|
list($start, $end) = explode('~', $params['date']);
|
||||||
$where[] = ['last_login_time', 'between', ["{$start} 00:00:00", "{$end} 23:59:59"]];
|
$where[] = ['last_login_time', 'between', ["{$start} 00:00:00", "{$end} 23:59:59"]];
|
||||||
}
|
}
|
||||||
$list = $this->model->_list($where,'id asc');
|
$list = $this->model->_list($where, 'id asc');
|
||||||
if ($list['list']) {
|
if ($list['list']) {
|
||||||
foreach ($list['list'] as &$item) {
|
foreach ($list['list'] as &$item) {
|
||||||
$memberInfo = Member::where(['code' => $item['member_code']])->field('id', true)->find();
|
$memberInfo = Member::where(['code' => $item['member_code']])->field('id', true)->find();
|
||||||
@ -114,6 +115,30 @@ class Account extends BasicApi
|
|||||||
$this->error("操作失败,请稍候再试!");
|
$this->error("操作失败,请稍候再试!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过邀请连接邀请成员
|
||||||
|
*/
|
||||||
|
public function _joinByInviteLink()
|
||||||
|
{
|
||||||
|
$inviteCode = Request::param('inviteCode');
|
||||||
|
$inviteLink = \app\common\Model\InviteLink::where(['code' => $inviteCode])->find();
|
||||||
|
if (!$inviteLink || nowTime() >= $inviteLink['over_time']) {
|
||||||
|
$this->error('该链接已失效');
|
||||||
|
}
|
||||||
|
if ($inviteLink['invite_type'] == 'organization') {
|
||||||
|
$organization = \app\common\Model\Organization::where(['code' => $inviteLink['source_code']])->find();
|
||||||
|
if (!$organization) {
|
||||||
|
$this->error('该组织不存在');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
MemberAccount::inviteMember(getCurrentMember()['code'], $organization['code']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->success('');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户添加
|
* 账户添加
|
||||||
* @return array|string
|
* @return array|string
|
||||||
|
@ -106,6 +106,7 @@ class DepartmentMember extends BasicApi
|
|||||||
$this->success('', array_values($tempList));//数组下标重置
|
$this->success('', array_values($tempList));//数组下标重置
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邀请成员
|
* 邀请成员
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user