|
@@ -58,45 +58,48 @@ class MeetingService extends BaseService
|
|
|
* @param int $userId
|
|
* @param int $userId
|
|
|
* @return array|mixed
|
|
* @return array|mixed
|
|
|
*/
|
|
*/
|
|
|
- public function getInfo($id,$userId=0,$type=1)
|
|
|
|
|
|
|
+ public function getInfo($id, $userId = 0, $type = 1)
|
|
|
{
|
|
{
|
|
|
$cacheKey = "caches:meeting:info_{$id}_{$userId}_{$type}";
|
|
$cacheKey = "caches:meeting:info_{$id}_{$userId}_{$type}";
|
|
|
$info = RedisService::get($cacheKey);
|
|
$info = RedisService::get($cacheKey);
|
|
|
- if($info){
|
|
|
|
|
|
|
+ if ($info) {
|
|
|
return $info;
|
|
return $info;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $info = $this->model->with(['member','company'])
|
|
|
|
|
- ->where(['id'=>$id,'status'=>1,'mark'=>1])
|
|
|
|
|
- ->withCount(['records'])
|
|
|
|
|
|
|
+ $info = $this->model->with(['member', 'company'])
|
|
|
|
|
+ ->where(['id' => $id, 'status' => 1, 'mark' => 1])
|
|
|
->first();
|
|
->first();
|
|
|
- $info = $info? $info->toArray() : [];
|
|
|
|
|
- if($info){
|
|
|
|
|
|
|
+ $info = $info ? $info->toArray() : [];
|
|
|
|
|
+ if ($info) {
|
|
|
$info['fee'] = floatval($info['fee']);
|
|
$info['fee'] = floatval($info['fee']);
|
|
|
- if($type == 2){
|
|
|
|
|
- $info['qrcode'] = MpService::make()->getMiniQrcode('pagesSub/pages/meeting/books',$id);
|
|
|
|
|
- $info['qrcode'] = $info['qrcode']? get_image_url($info['qrcode']):'';
|
|
|
|
|
- }else if($type == 3){
|
|
|
|
|
- $bookInfo = MeetingRecordsModel::where(['user_id'=>$userId,'meeting_id'=>$id,'mark'=>1])
|
|
|
|
|
- ->select(['id','is_sign','status'])
|
|
|
|
|
|
|
+ if ($type == 2) {
|
|
|
|
|
+ $info['qrcode'] = MpService::make()->getMiniQrcode('pagesSub/pages/meeting/books', $id);
|
|
|
|
|
+ $info['qrcode'] = $info['qrcode'] ? get_image_url($info['qrcode']) : '';
|
|
|
|
|
+ } else if ($type == 3) {
|
|
|
|
|
+ $bookInfo = MeetingRecordsModel::where(['user_id' => $userId, 'meeting_id' => $id, 'mark' => 1])
|
|
|
|
|
+ ->select(['id', 'is_sign', 'money', 'is_claim', 'status'])
|
|
|
->first();
|
|
->first();
|
|
|
- $bookInfo = $bookInfo?$bookInfo->toArray() : [];
|
|
|
|
|
- $info['is_book'] = $bookInfo?1: 0;
|
|
|
|
|
- $info['is_sign'] = isset($bookInfo['is_sign'])?$bookInfo['is_sign']: 0;
|
|
|
|
|
- $info['is_fee'] = isset($bookInfo['status'])?$bookInfo['status']: 0;
|
|
|
|
|
- }else{
|
|
|
|
|
|
|
+ $bookInfo = $bookInfo ? $bookInfo->toArray() : [];
|
|
|
|
|
+ $info['is_book'] = $bookInfo ? 1 : 0;
|
|
|
|
|
+ $info['is_sign'] = isset($bookInfo['is_sign']) ? $bookInfo['is_sign'] : 0;
|
|
|
|
|
+ $info['is_claim'] = isset($bookInfo['is_claim']) ? $bookInfo['is_claim'] : 0;
|
|
|
|
|
+ $info['is_fee'] = isset($bookInfo['status']) ? $bookInfo['status'] : 0;
|
|
|
|
|
+ $info['pay_fee'] = isset($bookInfo['money']) ? floatval($bookInfo['money']) : 0;
|
|
|
|
|
+ } else {
|
|
|
$areaIds = [];
|
|
$areaIds = [];
|
|
|
- if($info['city_id']){
|
|
|
|
|
|
|
+ if ($info['city_id']) {
|
|
|
$areaIds[] = $info['city_id'];
|
|
$areaIds[] = $info['city_id'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($info['district_id']){
|
|
|
|
|
|
|
+ if ($info['district_id']) {
|
|
|
$areaIds[] = $info['district_id'];
|
|
$areaIds[] = $info['district_id'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$areas = CityModel::whereIn('citycode', $areaIds)->pluck('name');
|
|
$areas = CityModel::whereIn('citycode', $areaIds)->pluck('name');
|
|
|
- $areas = $areas?$areas->toArray() :[];
|
|
|
|
|
- $info['area'] = $areas? implode('/',$areas) : '';
|
|
|
|
|
|
|
+ $areas = $areas ? $areas->toArray() : [];
|
|
|
|
|
+ $info['area'] = $areas ? implode('/', $areas) : '';
|
|
|
|
|
+
|
|
|
|
|
+ // 企业
|
|
|
$stores = '';
|
|
$stores = '';
|
|
|
if($info['store_ids']){
|
|
if($info['store_ids']){
|
|
|
$stores = UserModel::whereIn('id', $info['store_ids'])
|
|
$stores = UserModel::whereIn('id', $info['store_ids'])
|
|
@@ -106,6 +109,16 @@ class MeetingService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$info['stores'] = $stores?$stores->toArray() : [];
|
|
$info['stores'] = $stores?$stores->toArray() : [];
|
|
|
|
|
+ $info['store_count'] = count($info['stores']);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 邀请报名人数
|
|
|
|
|
+ $info['records_count']= (int)MeetingRecordsModel::from('meetings_records as a')
|
|
|
|
|
+ ->leftJoin('member as b','b.id','=','a.user_id')
|
|
|
|
|
+ ->where(['a.meeting_id'=>$id,'b.parent_id'=>$userId,'a.status'=>1])
|
|
|
|
|
+ ->count('a.id');
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
$supervisors = '';
|
|
$supervisors = '';
|
|
|
if($info['supervisor_ids']){
|
|
if($info['supervisor_ids']){
|
|
|
$supervisors = SupervisorsModel::whereIn('id', $info['supervisor_ids'])
|
|
$supervisors = SupervisorsModel::whereIn('id', $info['supervisor_ids'])
|
|
@@ -114,19 +127,23 @@ class MeetingService extends BaseService
|
|
|
->get();
|
|
->get();
|
|
|
}
|
|
}
|
|
|
$info['supervisors'] = $supervisors?$supervisors->toArray() :[];
|
|
$info['supervisors'] = $supervisors?$supervisors->toArray() :[];
|
|
|
- $info['store_count'] = count($info['stores']);
|
|
|
|
|
$info['supervisor_count'] =count($info['supervisors']);
|
|
$info['supervisor_count'] =count($info['supervisors']);
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
- $bookInfo = MeetingRecordsModel::where(['user_id'=>$userId,'meeting_id'=>$id,'mark'=>1])
|
|
|
|
|
- ->select(['id','is_sign','status'])
|
|
|
|
|
- ->first();
|
|
|
|
|
- $bookInfo = $bookInfo?$bookInfo->toArray() : [];
|
|
|
|
|
- $info['is_book'] = $bookInfo?1: 0;
|
|
|
|
|
- $info['is_sign'] = isset($bookInfo['is_sign'])?$bookInfo['is_sign']: 0;
|
|
|
|
|
- $info['is_fee'] = isset($bookInfo['status'])?$bookInfo['status']: 0;
|
|
|
|
|
|
|
+ $bookInfo = MeetingRecordsModel::where(['user_id' => $userId, 'meeting_id' => $id, 'mark' => 1])
|
|
|
|
|
+ ->select(['id', 'is_sign', 'money', 'realname', 'mobile', 'is_claim', 'status'])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ $bookInfo = $bookInfo ? $bookInfo->toArray() : [];
|
|
|
|
|
+ $info['is_book'] = $bookInfo ? 1 : 0;
|
|
|
|
|
+ $info['is_sign'] = isset($bookInfo['is_sign']) ? $bookInfo['is_sign'] : 0;
|
|
|
|
|
+ $info['is_claim'] = isset($bookInfo['is_claim']) ? $bookInfo['is_claim'] : 0;
|
|
|
|
|
+ $info['is_fee'] = isset($bookInfo['status']) ? $bookInfo['status'] : 0;
|
|
|
|
|
+ $info['pay_fee'] = isset($bookInfo['money']) ? floatval($bookInfo['money']) : 0;
|
|
|
|
|
+ $info['book_realname'] = isset($bookInfo['realname']) ? trim($bookInfo['realname']) : '';
|
|
|
|
|
+ $info['book_mobile'] = isset($bookInfo['mobile']) ? trim($bookInfo['mobile']) : '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RedisService::set($cacheKey, $info, rand(5,10));
|
|
|
|
|
|
|
+ RedisService::set($cacheKey, $info, rand(5, 10));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $info;
|
|
return $info;
|
|
@@ -143,14 +160,14 @@ class MeetingService extends BaseService
|
|
|
$list = $query->select(['meetings.*'])
|
|
$list = $query->select(['meetings.*'])
|
|
|
->withCount(['records'])
|
|
->withCount(['records'])
|
|
|
->groupBy('meetings.id')
|
|
->groupBy('meetings.id')
|
|
|
- ->orderBy('meetings.sort','desc')
|
|
|
|
|
- ->orderBy('meetings.id','desc')
|
|
|
|
|
|
|
+ ->orderBy('meetings.sort', 'desc')
|
|
|
|
|
+ ->orderBy('meetings.id', 'desc')
|
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
- $list = $list? $list->toArray() :[];
|
|
|
|
|
|
|
+ $list = $list ? $list->toArray() : [];
|
|
|
return [
|
|
return [
|
|
|
- 'pageSize'=> $pageSize,
|
|
|
|
|
- 'total'=>isset($list['total'])? $list['total'] : 0,
|
|
|
|
|
- 'list'=> isset($list['data'])? $list['data'] : []
|
|
|
|
|
|
|
+ 'pageSize' => $pageSize,
|
|
|
|
|
+ 'total' => isset($list['total']) ? $list['total'] : 0,
|
|
|
|
|
+ 'list' => isset($list['data']) ? $list['data'] : []
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -161,31 +178,31 @@ class MeetingService extends BaseService
|
|
|
*/
|
|
*/
|
|
|
public function getQuery($params)
|
|
public function getQuery($params)
|
|
|
{
|
|
{
|
|
|
- $where = ['meetings.status'=>0,'meetings.mark' => 1];
|
|
|
|
|
- $status = isset($params['status']) && $params['status']? intval($params['status']) : 1;
|
|
|
|
|
- if($status>0){
|
|
|
|
|
|
|
+ $where = ['meetings.status' => 0, 'meetings.mark' => 1];
|
|
|
|
|
+ $status = isset($params['status']) && $params['status'] ? intval($params['status']) : 1;
|
|
|
|
|
+ if ($status > 0) {
|
|
|
$where['meetings.status'] = $status;
|
|
$where['meetings.status'] = $status;
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
unset($where['meetings.status']);
|
|
unset($where['meetings.status']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return $this->model->with(['member','company'])
|
|
|
|
|
|
|
+ return $this->model->with(['member', 'company','province','city','district'])
|
|
|
->from('meetings')
|
|
->from('meetings')
|
|
|
- ->leftJoin('meetings_records','meetings_records.meeting_id','meetings.id')
|
|
|
|
|
|
|
+ ->leftJoin('meetings_records', 'meetings_records.meeting_id', 'meetings.id')
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->where(function ($query) use($params){
|
|
|
|
|
- $keyword = isset($params['keyword'])? $params['keyword'] : '';
|
|
|
|
|
- if($keyword){
|
|
|
|
|
- $query->where('meetings.title','like',"%{$keyword}%");
|
|
|
|
|
|
|
+ ->where(function ($query) use ($params) {
|
|
|
|
|
+ $keyword = isset($params['keyword']) ? $params['keyword'] : '';
|
|
|
|
|
+ if ($keyword) {
|
|
|
|
|
+ $query->where('meetings.title', 'like', "%{$keyword}%");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $type = isset($params['type'])? $params['type'] : 0;
|
|
|
|
|
- $userId = isset($params['user_id'])?$params['user_id'] : 0;
|
|
|
|
|
|
|
+ $type = isset($params['type']) ? $params['type'] : 0;
|
|
|
|
|
+ $userId = isset($params['user_id']) ? $params['user_id'] : 0;
|
|
|
// 我组织的
|
|
// 我组织的
|
|
|
- if($type==1){
|
|
|
|
|
|
|
+ if ($type == 1) {
|
|
|
$query->where('meetings.user_id', $userId);
|
|
$query->where('meetings.user_id', $userId);
|
|
|
- }else if($type == 2){
|
|
|
|
|
- $query->where('meetings_records.user_id', $userId)->where('meetings_records.mark',1);
|
|
|
|
|
|
|
+ } else if ($type == 2) {
|
|
|
|
|
+ $query->where('meetings_records.user_id', $userId)->where('meetings_records.mark', 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
});
|
|
@@ -200,7 +217,9 @@ class MeetingService extends BaseService
|
|
|
public function books($userId, $params)
|
|
public function books($userId, $params)
|
|
|
{
|
|
{
|
|
|
$meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
$meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
|
- if ($meetingId<=0) {
|
|
|
|
|
|
|
+ $realname = isset($params['realname']) ? trim($params['realname']) : '';
|
|
|
|
|
+ $mobile = isset($params['mobile']) ? trim($params['mobile']) : '';
|
|
|
|
|
+ if ($meetingId <= 0) {
|
|
|
$this->error = '会议参数错误,请返回重试~';
|
|
$this->error = '会议参数错误,请返回重试~';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -212,36 +231,36 @@ class MeetingService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$nowDate = date('Y-m-d H:i:s');
|
|
$nowDate = date('Y-m-d H:i:s');
|
|
|
- $info = $this->model->where(['id'=>$meetingId])->first();
|
|
|
|
|
- $startAt = isset($info['start_at'])?$info['start_at'] : '';
|
|
|
|
|
- $endAt = isset($info['end_at'])?$info['end_at'] : '';
|
|
|
|
|
- $fee = isset($info['fee'])?$info['fee'] : 0;
|
|
|
|
|
- $orderDay = isset($info['order_day']) && $info['order_day']>1?intval($info['order_day']) : 1; // 订单关联天数
|
|
|
|
|
- if($startAt && $nowDate < $startAt){
|
|
|
|
|
|
|
+ $info = $this->model->where(['id' => $meetingId])->first();
|
|
|
|
|
+ $startAt = isset($info['start_at']) ? $info['start_at'] : '';
|
|
|
|
|
+ $endAt = isset($info['end_at']) ? $info['end_at'] : '';
|
|
|
|
|
+ $fee = isset($info['fee']) ? $info['fee'] : 0;
|
|
|
|
|
+ $orderDay = isset($info['order_day']) && $info['order_day'] > 1 ? intval($info['order_day']) : 1; // 订单关联天数
|
|
|
|
|
+ if ($startAt && $nowDate < $startAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '会议尚未开始,无法报名';
|
|
$this->error = '会议尚未开始,无法报名';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($endAt && $nowDate > $endAt){
|
|
|
|
|
|
|
+ if ($endAt && $nowDate > $endAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '会议已结束,无法报名';
|
|
$this->error = '会议已结束,无法报名';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $record = MeetingRecordsModel::where(['meeting_id'=> $meetingId,'user_id'=>$userId,'mark'=>1])->first();
|
|
|
|
|
- $status = isset($record['status'])?$record['status']:0;
|
|
|
|
|
- if($record){
|
|
|
|
|
|
|
+ $record = MeetingRecordsModel::where(['meeting_id' => $meetingId, 'user_id' => $userId, 'mark' => 1])->first();
|
|
|
|
|
+ $status = isset($record['status']) ? $record['status'] : 0;
|
|
|
|
|
+ if ($record) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
- $this->error = $status==1? '您已经完成报名': '您已经完成报名,请等候付费确认';
|
|
|
|
|
|
|
+ $this->error = $status == 1 ? '您已经完成报名' : '您已经完成报名,请等候付费确认';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $otherRecord = MeetingRecordsModel::with(['meeting'])->where(['user_id'=>$userId,'mark'=>1])->first();
|
|
|
|
|
- $meeting = isset($otherRecord['meeting'])?$otherRecord['meeting']:[];
|
|
|
|
|
- $meetingStartAt = isset($meeting['start_at'])?$meeting['start_at'] : '';
|
|
|
|
|
- $meetingEndAt = isset($meeting['end_at'])?$meeting['end_at'] : '';
|
|
|
|
|
- if($otherRecord && $meetingStartAt <= $nowDate && $nowDate <= $meetingEndAt){
|
|
|
|
|
|
|
+ $otherRecord = MeetingRecordsModel::with(['meeting'])->where(['user_id' => $userId, 'mark' => 1])->first();
|
|
|
|
|
+ $meeting = isset($otherRecord['meeting']) ? $otherRecord['meeting'] : [];
|
|
|
|
|
+ $meetingStartAt = isset($meeting['start_at']) ? $meeting['start_at'] : '';
|
|
|
|
|
+ $meetingEndAt = isset($meeting['end_at']) ? $meeting['end_at'] : '';
|
|
|
|
|
+ if ($otherRecord && $meetingStartAt <= $nowDate && $nowDate <= $meetingEndAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '您有未完成的会议,请完成后再报名';
|
|
$this->error = '您有未完成的会议,请完成后再报名';
|
|
|
return false;
|
|
return false;
|
|
@@ -250,22 +269,25 @@ class MeetingService extends BaseService
|
|
|
$data = [
|
|
$data = [
|
|
|
'user_id' => $userId,
|
|
'user_id' => $userId,
|
|
|
'meeting_id' => $meetingId,
|
|
'meeting_id' => $meetingId,
|
|
|
|
|
+ 'realname' => $realname,
|
|
|
|
|
+ 'mobile' => $mobile,
|
|
|
'order_count' => 0,
|
|
'order_count' => 0,
|
|
|
'order_total' => 0,
|
|
'order_total' => 0,
|
|
|
'is_sign' => 2,
|
|
'is_sign' => 2,
|
|
|
- 'status' => $fee<=0?1:2,
|
|
|
|
|
|
|
+ 'is_claim' => 2,
|
|
|
|
|
+ 'status' => $fee <= 0 ? 1 : 2,
|
|
|
'create_time' => time(),
|
|
'create_time' => time(),
|
|
|
'update_time' => time(),
|
|
'update_time' => time(),
|
|
|
'mark' => 1,
|
|
'mark' => 1,
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- if(!$id = MeetingRecordsModel::insertGetId($data)){
|
|
|
|
|
|
|
+ if (!$id = MeetingRecordsModel::insertGetId($data)) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '报名失败';
|
|
$this->error = '报名失败';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $this->error = $fee>0?'报名成功,请等候付费确认':'报名成功';
|
|
|
|
|
|
|
+ $this->error = $fee > 0 ? '报名成功,请等候付费确认' : '报名成功';
|
|
|
RedisService::set($cacheKey, $data, 30);
|
|
RedisService::set($cacheKey, $data, 30);
|
|
|
RedisService::keyDel("caches:meeting:info_{$meetingId}_{$userId}*");
|
|
RedisService::keyDel("caches:meeting:info_{$meetingId}_{$userId}*");
|
|
|
return ['id' => $id];
|
|
return ['id' => $id];
|
|
@@ -280,7 +302,7 @@ class MeetingService extends BaseService
|
|
|
public function sign($userId, $params)
|
|
public function sign($userId, $params)
|
|
|
{
|
|
{
|
|
|
$meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
$meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
|
- if ($meetingId<=0) {
|
|
|
|
|
|
|
+ if ($meetingId <= 0) {
|
|
|
$this->error = '会议参数错误,请返回重试~';
|
|
$this->error = '会议参数错误,请返回重试~';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -292,51 +314,50 @@ class MeetingService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$nowDate = date('Y-m-d H:i:s');
|
|
$nowDate = date('Y-m-d H:i:s');
|
|
|
- $info = $this->model->where(['id'=>$meetingId])->first();
|
|
|
|
|
- $startAt = isset($info['start_at'])?$info['start_at'] : '';
|
|
|
|
|
- $endAt = isset($info['end_at'])?$info['end_at'] : '';
|
|
|
|
|
- $orderDay = isset($info['order_day']) && $info['order_day']>1?intval($info['order_day']) : 1; // 订单关联天数
|
|
|
|
|
- if($startAt && $nowDate < $startAt){
|
|
|
|
|
|
|
+ $info = $this->model->where(['id' => $meetingId])->first();
|
|
|
|
|
+ $startAt = isset($info['start_at']) ? $info['start_at'] : '';
|
|
|
|
|
+ $endAt = isset($info['end_at']) ? $info['end_at'] : '';
|
|
|
|
|
+ $orderDay = isset($info['order_day']) && $info['order_day'] > 1 ? intval($info['order_day']) : 1; // 订单关联天数
|
|
|
|
|
+ if ($startAt && $nowDate < $startAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '会议尚未开始,无法签到';
|
|
$this->error = '会议尚未开始,无法签到';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($endAt && $nowDate > $endAt){
|
|
|
|
|
|
|
+ if ($endAt && $nowDate > $endAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '会议已结束,无法签到';
|
|
$this->error = '会议已结束,无法签到';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $record = MeetingRecordsModel::where(['meeting_id'=> $meetingId,'user_id'=>$userId,'mark'=>1])->first();
|
|
|
|
|
- $recordId = isset($record['id'])?$record['id'] : 0;
|
|
|
|
|
- $isSign = isset($record['is_sign'])?$record['is_sign'] : 0;
|
|
|
|
|
- $bookStatus = isset($record['status'])?$record['status'] : 0;
|
|
|
|
|
- if(empty($record) || $recordId<=0){
|
|
|
|
|
|
|
+ $record = MeetingRecordsModel::where(['meeting_id' => $meetingId, 'user_id' => $userId, 'mark' => 1])->first();
|
|
|
|
|
+ $recordId = isset($record['id']) ? $record['id'] : 0;
|
|
|
|
|
+ $isSign = isset($record['is_sign']) ? $record['is_sign'] : 0;
|
|
|
|
|
+ $bookStatus = isset($record['status']) ? $record['status'] : 0;
|
|
|
|
|
+ if (empty($record) || $recordId <= 0) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '抱歉,请先完成报名';
|
|
$this->error = '抱歉,请先完成报名';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($bookStatus!=1){
|
|
|
|
|
|
|
+ if ($bookStatus != 1) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '抱歉,请先完成报名付费确认';
|
|
$this->error = '抱歉,请先完成报名付费确认';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($isSign==1){
|
|
|
|
|
|
|
+ if ($isSign == 1) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '您已经完成签到';
|
|
$this->error = '您已经完成签到';
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $otherRecord = MeetingRecordsModel::with(['meeting'])->where(['user_id'=>$userId,'mark'=>1])->first();
|
|
|
|
|
- $meeting = isset($otherRecord['meeting'])?$otherRecord['meeting']:[];
|
|
|
|
|
- $meetingStartAt = isset($meeting['start_at'])?$meeting['start_at'] : '';
|
|
|
|
|
- $meetingEndAt = isset($meeting['end_at'])?$meeting['end_at'] : '';
|
|
|
|
|
- if($otherRecord && $meetingStartAt <= $nowDate && $nowDate <= $meetingEndAt){
|
|
|
|
|
|
|
+ $otherRecord = MeetingRecordsModel::with(['meeting'])->where(['user_id' => $userId, 'mark' => 1])->first();
|
|
|
|
|
+ $meeting = isset($otherRecord['meeting']) ? $otherRecord['meeting'] : [];
|
|
|
|
|
+ $meetingStartAt = isset($meeting['start_at']) ? $meeting['start_at'] : '';
|
|
|
|
|
+ $meetingEndAt = isset($meeting['end_at']) ? $meeting['end_at'] : '';
|
|
|
|
|
+ if ($otherRecord && $meetingStartAt <= $nowDate && $nowDate <= $meetingEndAt) {
|
|
|
RedisService::clear($cacheKey);
|
|
RedisService::clear($cacheKey);
|
|
|
$this->error = '您有未完成的会议,请完成后再签到';
|
|
$this->error = '您有未完成的会议,请完成后再签到';
|
|
|
return false;
|
|
return false;
|
|
@@ -352,7 +373,7 @@ class MeetingService extends BaseService
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
- MeetingRecordsModel::where(['id'=>$recordId])->update($data);
|
|
|
|
|
|
|
+ MeetingRecordsModel::where(['id' => $recordId])->update($data);
|
|
|
|
|
|
|
|
$this->error = '签到成功';
|
|
$this->error = '签到成功';
|
|
|
RedisService::set($cacheKey, $data, 30);
|
|
RedisService::set($cacheKey, $data, 30);
|
|
@@ -360,6 +381,91 @@ class MeetingService extends BaseService
|
|
|
return ['id' => $recordId];
|
|
return ['id' => $recordId];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 领取物料
|
|
|
|
|
+ * @param $userId
|
|
|
|
|
+ * @param $params
|
|
|
|
|
+ * @return array|false
|
|
|
|
|
+ */
|
|
|
|
|
+ public function claim($userId, $params)
|
|
|
|
|
+ {
|
|
|
|
|
+ $meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
|
|
|
+ if ($meetingId <= 0) {
|
|
|
|
|
+ $this->error = '会议参数错误,请返回重试~';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $cacheKey = "caches:meetingClaim:{$userId}_{$meetingId}";
|
|
|
|
|
+ if (RedisService::get($cacheKey)) {
|
|
|
|
|
+ $this->error = '请不要重复领取';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $nowDate = date('Y-m-d H:i:s');
|
|
|
|
|
+ $info = $this->model->where(['id' => $meetingId])->first();
|
|
|
|
|
+ $startAt = isset($info['start_at']) ? $info['start_at'] : '';
|
|
|
|
|
+ $endAt = isset($info['end_at']) ? $info['end_at'] : '';
|
|
|
|
|
+ $orderDay = isset($info['order_day']) && $info['order_day'] > 1 ? intval($info['order_day']) : 1; // 订单关联天数
|
|
|
|
|
+ if ($startAt && $nowDate < $startAt) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '会议尚未开始,无法签到';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($endAt && $nowDate > $endAt) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '会议已结束,无法签到';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $record = MeetingRecordsModel::where(['meeting_id' => $meetingId, 'user_id' => $userId, 'mark' => 1])->first();
|
|
|
|
|
+ $recordId = isset($record['id']) ? $record['id'] : 0;
|
|
|
|
|
+ $isSign = isset($record['is_sign']) ? $record['is_sign'] : 0;
|
|
|
|
|
+ $isClaim = isset($record['is_claim']) ? $record['is_claim'] : 0;
|
|
|
|
|
+ $bookStatus = isset($record['status']) ? $record['status'] : 0;
|
|
|
|
|
+ if (empty($record) || $recordId <= 0) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '抱歉,请先完成报名';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($bookStatus != 1) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '抱歉,请先完成报名付费确认';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($isSign != 1) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '请先完成签到';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ($isClaim == 1) {
|
|
|
|
|
+ RedisService::clear($cacheKey);
|
|
|
|
|
+ $this->error = '您已经领取过物料';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ 'is_claim' => 1,
|
|
|
|
|
+ 'claim_at' => date('Y-m-d H:i:s'),
|
|
|
|
|
+ 'create_time' => time(),
|
|
|
|
|
+ 'update_time' => time(),
|
|
|
|
|
+ 'mark' => 1,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ MeetingRecordsModel::where(['id' => $recordId])->update($data);
|
|
|
|
|
+
|
|
|
|
|
+ $this->error = '领取成功';
|
|
|
|
|
+ RedisService::set($cacheKey, $data, 30);
|
|
|
|
|
+ RedisService::keyDel("caches:meeting:info_{$meetingId}_{$userId}*");
|
|
|
|
|
+ return ['id' => $recordId];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 会议报名签到记录
|
|
* 会议报名签到记录
|
|
@@ -367,31 +473,40 @@ class MeetingService extends BaseService
|
|
|
* @param int $pageSize
|
|
* @param int $pageSize
|
|
|
* @return array
|
|
* @return array
|
|
|
*/
|
|
*/
|
|
|
- public function records($params,$pageSize=20)
|
|
|
|
|
|
|
+ public function records($params, $pageSize = 20, $userId = 0)
|
|
|
{
|
|
{
|
|
|
- $meetingId = isset($params['meeting_id'])?$params['meeting_id']: 0;
|
|
|
|
|
- $list = MeetingRecordsModel::with(['member'])
|
|
|
|
|
|
|
+ $meetingId = isset($params['meeting_id']) ? $params['meeting_id'] : 0;
|
|
|
|
|
+ $where = ['b.parent_id' => $userId, 'a.meeting_id' => $meetingId, 'a.mark' => 1];
|
|
|
|
|
+ $query = MeetingRecordsModel::with(['member'])
|
|
|
->from('meetings_records as a')
|
|
->from('meetings_records as a')
|
|
|
- ->leftJoin('member as b','b.id','=','a.user_id')
|
|
|
|
|
- ->where(function($query) use($params){
|
|
|
|
|
- $keyword = isset($params['keyword'])? trim($params['keyword']) : '';
|
|
|
|
|
- if($keyword){
|
|
|
|
|
- $query->where('b.mobile','like',"%{$keyword}%")
|
|
|
|
|
- ->orWhere('b.nickname','like',"%{$keyword}%")
|
|
|
|
|
- ->orWhere('b.realname','like',"%{$keyword}%");
|
|
|
|
|
|
|
+ ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
|
|
|
|
|
+ ->where(function ($query) use ($params) {
|
|
|
|
|
+ $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
|
|
|
|
|
+ if ($keyword) {
|
|
|
|
|
+ $query->where('b.mobile', 'like', "%{$keyword}%")
|
|
|
|
|
+ ->orWhere('b.nickname', 'like', "%{$keyword}%")
|
|
|
|
|
+ ->orWhere('b.realname', 'like', "%{$keyword}%");
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- ->where('b.id','>',0)
|
|
|
|
|
- ->where(['a.meeting_id'=>$meetingId,'a.is_sign'=>1,'a.mark'=>1])
|
|
|
|
|
- ->select(['a.*'])
|
|
|
|
|
- ->orderBy('a.id','desc')
|
|
|
|
|
|
|
+ ->where('b.id', '>', 0);
|
|
|
|
|
+
|
|
|
|
|
+ $query1 = clone $query;
|
|
|
|
|
+ $list = $query1->where($where)->select(['a.*'])
|
|
|
|
|
+ ->orderBy('a.id', 'desc')
|
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
- $list = $list? $list->toArray() :[];
|
|
|
|
|
|
|
+ $list = $list ? $list->toArray() : [];
|
|
|
|
|
+
|
|
|
|
|
+ $query2 = clone $query;
|
|
|
|
|
+ unset($where['b.parent_id']);
|
|
|
|
|
+// var_dump($where);
|
|
|
|
|
+ $total = $query2->where($where)->count('a.id');
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return [
|
|
return [
|
|
|
- 'pageSize'=> $pageSize,
|
|
|
|
|
- 'total'=>isset($list['total'])? $list['total'] : 0,
|
|
|
|
|
- 'list'=> isset($list['data'])? $list['data'] : []
|
|
|
|
|
|
|
+ 'pageSize' => $pageSize,
|
|
|
|
|
+ 'count' => isset($list['total']) ? $list['total'] : 0,
|
|
|
|
|
+ 'total' => $total,
|
|
|
|
|
+ 'list' => isset($list['data']) ? $list['data'] : []
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|