增加日历日程

This commit is contained in:
vilson 2020-11-29 23:06:08 +08:00
parent bcb568f2a9
commit 760ab769f9
2 changed files with 114 additions and 2 deletions

View File

@ -103,6 +103,36 @@ class Account extends BasicApi
$this->success('', $list); $this->success('', $list);
} }
public function _allList()
{
$keyword = Request::post('keyword');
$orgCode = getCurrentOrganizationCode();
$where = [['organization_code', '=', $orgCode]];
if ($keyword) {
$where[] = ['name', 'like', "%{$keyword}%"];
}
$memberAccountList = MemberAccount::where($where)->select()->toArray();
$list = [];
if ($memberAccountList) {
foreach ($memberAccountList as $member) {
$item['memberCode'] = $member['member_code'];
$item['status'] = $member['status'];
$item['avatar'] = $member['avatar'];
if (!$item['avatar']) {
$memberInfo = Member::where(['code' => $member['member_code']])->field('id', true)->find();
if ($memberInfo) {
$item['avatar'] = $memberInfo['avatar'];
}
}
$item['name'] = $member['name'];
$item['email'] = $member['email'] ?? '未绑定邮箱';
$list[] = $item; //为了去重
}
}
$this->success('', $list);//数组下标重置
}
public function read() public function read()
{ {
$code = Request::param('code'); $code = Request::param('code');

View File

@ -6,8 +6,11 @@ use app\common\Model\EventsMember;
use app\common\Model\Member; use app\common\Model\Member;
use app\common\Model\EventsLog; use app\common\Model\EventsLog;
use controller\BasicApi; use controller\BasicApi;
use service\DataService;
use service\DateService;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\db\Where;
use think\Exception; use think\Exception;
use think\exception\DbException; use think\exception\DbException;
use think\exception\PDOException; use think\exception\PDOException;
@ -40,7 +43,6 @@ class Events extends BasicApi
$where[] = ['project_code', '=', $code]; $where[] = ['project_code', '=', $code];
} }
$where[] = ['deleted', '=', 0]; $where[] = ['deleted', '=', 0];
$where[] = ['organization_code', '=', getCurrentOrganizationCode()];
$list = $this->model->_list($where); $list = $this->model->_list($where);
// $eventMember = new EventsMember(); // $eventMember = new EventsMember();
// $list = $eventMember->_list($where); // $list = $eventMember->_list($where);
@ -70,7 +72,6 @@ class Events extends BasicApi
} }
$status = Request::post('status', -1); $status = Request::post('status', -1);
$where[] = ['deleted', '=', 0]; $where[] = ['deleted', '=', 0];
$where[] = ['organization_code', '=', getCurrentOrganizationCode()];
$where[] = ['end_time', '>=', nowTime()]; $where[] = ['end_time', '>=', nowTime()];
$memberWhere = [['member_code', '=', getCurrentMember()['code']]]; $memberWhere = [['member_code', '=', getCurrentMember()['code']]];
if ($status != -1) { if ($status != -1) {
@ -289,6 +290,87 @@ class Events extends BasicApi
$this->success(); $this->success();
} }
public function getEventsListByCalendar()
{
$date = Request::post('date');
$dateTimestamp = strtotime($date);
$month = DateService::unixtime('month', -1, 'begin', date('Y', $dateTimestamp), date('m', $dateTimestamp));
$month2 = DateService::unixtime('month', 2, 'begin', date('Y', $dateTimestamp), date('m', $dateTimestamp));
$begin = date('Y-m-d H:i:s', $month);
$end = date('Y-m-d H:i:s', $month2);
$memberCodes = Request::post('memberCodes');
if ($memberCodes) {
$memberCodes = json_decode($memberCodes, JSON_UNESCAPED_UNICODE);
}
$where[] = ['deleted', '=', 0];
$memberWhere = [['member_code', 'in', $memberCodes]];
$memberWhere[] = ['status', '<>', 2];
$eventCodes = EventsMember::where($memberWhere)->column('events_code');
$where[] = ['code', 'in', $eventCodes];
// $list = $this->model->_list($where);
$dateRange = DateService::getDateFromRange($begin, $end);
$rows = intval(Request::param('pageSize', cookie('pageSize')));
if (!$rows) {
$rows = 10;
}
cookie('pageSize', $rows);
$list = $this->model->where($where)->where(function ($query) use ($begin, $end) {
$where1 = [['begin_time', '<=', $begin], ['end_time', '>=', $begin]];
$where2 = [['begin_time', '>=', $begin], ['end_time', '<=', $end]];
$where3 = [['begin_time', '<=', $end], ['end_time', '>=', $end]];
$query->whereOr(function($query) use ($where1){
$query->where($where1);
})->whereOr(function ($query) use ($where2, $where3) {
$query->where($where2);
})->whereOr(function ($query) use ($where3) {
$query->where($where3);
});
})->select();
// $list = $page->all();
$newList = [];
$memberCode = getCurrentMember()['code'];
$dateRangeList = [];
if ($dateRange) {
foreach ($dateRange as $dateItem) {
if (!isset($dateRange[$dateItem])) {
$dateRangeList[$dateItem] = [];
}
if ($list) {
foreach ($list as &$item) {
$item['visible'] = false;
$item['visibleInner'] = false;
$item['visibleMore'] = false;
$item['waitConfirm'] = 1;
$item['myStatus'] = 0;
$waitConfirm = EventsMember::where(['events_code' => $item['code'], 'member_code' => $memberCode])->find();
if ($waitConfirm) {
if ($waitConfirm['status'] != 0) {
$item['waitConfirm'] = 0;
}
$item['myStatus'] = $waitConfirm['status'];
}else{
$item['waitConfirm'] = 0;
}
$item['memberList'] = [];
$members = EventsMember::where(['events_code' => $item['code']])->order('is_owner desc, status desc, id asc')->all();
if ($members) {
$item['memberList'] = $members;
}
if (($dateItem >= date('Y-m-d', strtotime($item['begin_time']))) && ($dateItem <= date('Y-m-d', strtotime($item['end_time'])))) {
$dateRangeList[$dateItem][] = $item;
}
}
}
}
}
$result = ['list' => $dateRangeList, 'dateRange' => $dateRange];
$this->success('', $result);
}
/** /**
* 日程日志 * 日程日志
* @throws DataNotFoundException * @throws DataNotFoundException