|
|
@@ -72,11 +72,18 @@ class MeetingService extends BaseService
|
|
|
->first();
|
|
|
$info = $info? $info->toArray() : [];
|
|
|
if($info){
|
|
|
+ $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){
|
|
|
- $info['is_book'] = MeetingRecordsModel::where(['user_id'=>$userId,'meeting_id'=>$id,'mark'=>1])->value('id');
|
|
|
+ $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;
|
|
|
}else{
|
|
|
$areaIds = [];
|
|
|
if($info['city_id']){
|
|
|
@@ -109,6 +116,14 @@ class MeetingService extends BaseService
|
|
|
$info['supervisors'] = $supervisors?$supervisors->toArray() :[];
|
|
|
$info['store_count'] = count($info['stores']);
|
|
|
$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;
|
|
|
}
|
|
|
|
|
|
RedisService::set($cacheKey, $info, rand(5,10));
|
|
|
@@ -177,7 +192,7 @@ class MeetingService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 签到
|
|
|
+ * 报名
|
|
|
* @param $userId
|
|
|
* @param $params
|
|
|
* @return array|false
|
|
|
@@ -192,33 +207,33 @@ class MeetingService extends BaseService
|
|
|
|
|
|
$cacheKey = "caches:meetingBooks:{$userId}_{$meetingId}";
|
|
|
if (RedisService::get($cacheKey)) {
|
|
|
- $this->error = '请不要重复签到';
|
|
|
+ $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'] : '';
|
|
|
+ $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);
|
|
|
- $this->error = '会议尚未开始,无法签到';
|
|
|
+ $this->error = '会议尚未开始,无法报名';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if($endAt && $nowDate > $endAt){
|
|
|
RedisService::clear($cacheKey);
|
|
|
- $this->error = '会议已结束,无法签到';
|
|
|
+ $this->error = '会议已结束,无法报名';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$record = MeetingRecordsModel::where(['meeting_id'=> $meetingId,'user_id'=>$userId,'mark'=>1])->first();
|
|
|
+ $status = isset($record['status'])?$record['status']:0;
|
|
|
if($record){
|
|
|
RedisService::clear($cacheKey);
|
|
|
- $this->error = '您已经完成签到';
|
|
|
+ $this->error = $status==1? '您已经完成报名': '您已经完成报名,请等候付费确认';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -228,7 +243,7 @@ class MeetingService extends BaseService
|
|
|
$meetingEndAt = isset($meeting['end_at'])?$meeting['end_at'] : '';
|
|
|
if($otherRecord && $meetingStartAt <= $nowDate && $nowDate <= $meetingEndAt){
|
|
|
RedisService::clear($cacheKey);
|
|
|
- $this->error = '您有未完成的会议,请完成后再签到';
|
|
|
+ $this->error = '您有未完成的会议,请完成后再报名';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -237,7 +252,8 @@ class MeetingService extends BaseService
|
|
|
'meeting_id' => $meetingId,
|
|
|
'order_count' => 0,
|
|
|
'order_total' => 0,
|
|
|
- 'expired_at' => date('Y-m-d H:i:s', time() + $orderDay * 86400),
|
|
|
+ 'is_sign' => 2,
|
|
|
+ 'status' => $fee<=0?1:2,
|
|
|
'create_time' => time(),
|
|
|
'update_time' => time(),
|
|
|
'mark' => 1,
|
|
|
@@ -245,17 +261,108 @@ class MeetingService extends BaseService
|
|
|
|
|
|
if(!$id = MeetingRecordsModel::insertGetId($data)){
|
|
|
RedisService::clear($cacheKey);
|
|
|
- $this->error = '签到失败';
|
|
|
+ $this->error = '报名失败';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $this->error = '签到成功';
|
|
|
+ $this->error = $fee>0?'报名成功,请等候付费确认':'报名成功';
|
|
|
RedisService::set($cacheKey, $data, 30);
|
|
|
+ RedisService::keyDel("caches:meeting:info_{$meetingId}_{$userId}*");
|
|
|
return ['id' => $id];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 会议报名记录
|
|
|
+ * 签到
|
|
|
+ * @param $userId
|
|
|
+ * @param $params
|
|
|
+ * @return array|false
|
|
|
+ */
|
|
|
+ public function sign($userId, $params)
|
|
|
+ {
|
|
|
+ $meetingId = isset($params['id']) ? intval($params['id']) : 0;
|
|
|
+ if ($meetingId<=0) {
|
|
|
+ $this->error = '会议参数错误,请返回重试~';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cacheKey = "caches:meetingSign:{$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;
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+
|
|
|
+ $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);
|
|
|
+ $this->error = '您有未完成的会议,请完成后再签到';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'is_sign' => 1,
|
|
|
+ 'sign_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'expired_at' => date('Y-m-d H:i:s', time() + $orderDay * 86400),
|
|
|
+ '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];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 会议报名签到记录
|
|
|
* @param $params
|
|
|
* @param int $pageSize
|
|
|
* @return array
|
|
|
@@ -275,7 +382,7 @@ class MeetingService extends BaseService
|
|
|
}
|
|
|
})
|
|
|
->where('b.id','>',0)
|
|
|
- ->where(['a.meeting_id'=>$meetingId,'a.mark'=>1])
|
|
|
+ ->where(['a.meeting_id'=>$meetingId,'a.is_sign'=>1,'a.mark'=>1])
|
|
|
->select(['a.*'])
|
|
|
->orderBy('a.id','desc')
|
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|