|
|
|
@ -1,7 +1,9 @@ |
|
|
|
|
package com.cjy.back.ybsjAppointment.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.cjy.back.ybsjAppointment.dao.YbsjyAppointmentRecordMapper; |
|
|
|
|
import com.cjy.back.ybsjAppointment.dao.YbsjyAppointmentSettingMapper; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.AppointmentRequestTurnstileLogEntity; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.AppointmentTimeInfoEntity; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.YbsjyAppointmentSettingEntity; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.vo.*; |
|
|
|
@ -9,8 +11,10 @@ import com.cjy.back.ybsjAppointment.service.YbsjyAppointmentSettingService; |
|
|
|
|
import com.cjy.back.ybsjAppointment.utils.AppointmentNumberUtil; |
|
|
|
|
import com.cjy.back.ybsjAppointment.utils.DateUtil; |
|
|
|
|
import com.cjy.common.PageWrapper; |
|
|
|
|
import com.cjy.util.HttpUtil; |
|
|
|
|
import com.cjy.util.ServerResponse; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
@ -29,6 +33,16 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
@Autowired |
|
|
|
|
YbsjyAppointmentRecordMapper ybsjyAppointmentRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${turnstile.url}") |
|
|
|
|
private String turnstileUrl; |
|
|
|
|
@Value("${turnstile.addAccessRight}") |
|
|
|
|
private String addAccessRight; |
|
|
|
|
@Value("${turnstile.addVisitor}") |
|
|
|
|
private String addVisitor; |
|
|
|
|
@Value("${turnstile.updateQRCodev}") |
|
|
|
|
private String updateQRCodev; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预约设置添加 |
|
|
|
|
* |
|
|
|
@ -205,6 +219,10 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public ServerResponse reservationNow(ReservationNowVO reservationNowVO) { |
|
|
|
|
// 先判断是否有未核销的预约单 如果有未核销的订单则提示请先取消或者等待 预约过期
|
|
|
|
|
if(ybsjyAppointmentSettingMapper.getNotWrittenOffAppointmentDocumentsCount(reservationNowVO.getAppointmentDate(),reservationNowVO.getUnionId()) >0){ |
|
|
|
|
return ServerResponse.createByError("预约失败,有待核销的预约单。请先取消订单或等待订单过期!"); |
|
|
|
|
} |
|
|
|
|
//获取该时间段预约了多少人
|
|
|
|
|
int reservedCount = ybsjyAppointmentSettingMapper.getAppointmentCount(reservationNowVO.getAppointmentTimeInfoId(),reservationNowVO.getAppointmentDate()); |
|
|
|
|
AppointmentTimeInfoEntity appointmentTimeInfoEntity = ybsjyAppointmentSettingMapper.getPeriodInfo(reservationNowVO.getAppointmentTimeInfoId()); |
|
|
|
@ -218,7 +236,6 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
return ServerResponse.createByError("预约失败,当前时间大于预约时段的结束时间"); |
|
|
|
|
} else { |
|
|
|
|
//生成预约单
|
|
|
|
|
|
|
|
|
|
appointmentFormVO.setAppointmentNumber(AppointmentNumberUtil.generateOrderNumber()); |
|
|
|
|
appointmentFormVO.setAppointmentCount(reservationNowVO.getAppointmentPersonList().size()); |
|
|
|
|
appointmentFormVO.setAppointmentDate(reservationNowVO.getAppointmentDate()); |
|
|
|
@ -227,6 +244,7 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
appointmentFormVO.setCreateBy(reservationNowVO.getUnionId()); |
|
|
|
|
appointmentFormVO.setScenicId(reservationNowVO.getScenicId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//生成预约单
|
|
|
|
|
appointmentFormVO.setAppointmentNumber(AppointmentNumberUtil.generateOrderNumber()); |
|
|
|
@ -237,23 +255,72 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
appointmentFormVO.setCreateBy(reservationNowVO.getUnionId()); |
|
|
|
|
appointmentFormVO.setScenicId(reservationNowVO.getScenicId()); |
|
|
|
|
} |
|
|
|
|
//插入预约单
|
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentDocumentsInfo(appointmentFormVO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这里还需要判断一下预约人中是否有过预约的
|
|
|
|
|
if(ybsjyAppointmentSettingMapper.getReservationInformation(reservationNowVO.getAppointmentTimeInfoId(),reservationNowVO.getAppointmentPersonList(),reservationNowVO.getAppointmentDate()) >0){ |
|
|
|
|
return ServerResponse.createByError("预约失败,预约单中有人已预约。"); |
|
|
|
|
} |
|
|
|
|
//插入预约单
|
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentDocumentsInfo(appointmentFormVO); |
|
|
|
|
//插入预约人信息表
|
|
|
|
|
reservationNowVO.getAppointmentPersonList().stream().forEach(item ->{ |
|
|
|
|
item.setReservationCode(AppointmentNumberUtil.generateOrderNumber()); |
|
|
|
|
item.setAppointmentTimeInfoId(reservationNowVO.getAppointmentTimeInfoId()); |
|
|
|
|
item.setAppointmentDocumentsId(appointmentFormVO.getId()); |
|
|
|
|
item.setAppointmentDate(reservationNowVO.getAppointmentDate()); |
|
|
|
|
//设置权限
|
|
|
|
|
|
|
|
|
|
Map<String,String> map= new HashMap<>(); |
|
|
|
|
map.put("idCard",item.getDocumentsNumber()); |
|
|
|
|
map.put("startTime",item.getAppointmentDate()+" " +reservationNowVO.getStartTime()+":00"); |
|
|
|
|
map.put("endTime",item.getAppointmentDate()+" " +reservationNowVO.getEndTime()+":00"); |
|
|
|
|
String responseString =HttpUtil.sendPost(turnstileUrl+addAccessRight,map); |
|
|
|
|
//记录访问日志
|
|
|
|
|
JSONObject accessRightResponseJson = JSONObject.parseObject(responseString); |
|
|
|
|
//记录访问日志
|
|
|
|
|
AppointmentRequestTurnstileLogEntity addAccessRightAppointmentRequestTurnstileLogEntity=new AppointmentRequestTurnstileLogEntity(); |
|
|
|
|
addAccessRightAppointmentRequestTurnstileLogEntity.setRequestUrl(turnstileUrl+addAccessRight); |
|
|
|
|
addAccessRightAppointmentRequestTurnstileLogEntity.setRequestParams(map.toString()); |
|
|
|
|
addAccessRightAppointmentRequestTurnstileLogEntity.setResponseBody(responseString); |
|
|
|
|
addAccessRightAppointmentRequestTurnstileLogEntity.setState(accessRightResponseJson.get("code").toString()); |
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentRequestTurnstileLog(addAccessRightAppointmentRequestTurnstileLogEntity); |
|
|
|
|
|
|
|
|
|
//添加访客
|
|
|
|
|
Map<String,String> map1= new HashMap<>(); |
|
|
|
|
map1.put("idCard",item.getDocumentsNumber()); |
|
|
|
|
map1.put("startTime",item.getAppointmentDate()+" " +reservationNowVO.getStartTime()+":00"); |
|
|
|
|
map1.put("endTime",item.getAppointmentDate()+" " +reservationNowVO.getEndTime()+":00"); |
|
|
|
|
String addVisitorResponseString = HttpUtil.sendPost(turnstileUrl+addVisitor,map1); |
|
|
|
|
JSONObject addVisitorResponseJson = JSONObject.parseObject(addVisitorResponseString); |
|
|
|
|
//记录访问日志
|
|
|
|
|
AppointmentRequestTurnstileLogEntity VisitorResponseJsonAppointmentRequestTurnstileLogEntity=new AppointmentRequestTurnstileLogEntity(); |
|
|
|
|
VisitorResponseJsonAppointmentRequestTurnstileLogEntity.setRequestUrl(turnstileUrl+addVisitor); |
|
|
|
|
VisitorResponseJsonAppointmentRequestTurnstileLogEntity.setRequestParams(map1.toString()); |
|
|
|
|
VisitorResponseJsonAppointmentRequestTurnstileLogEntity.setResponseBody(addVisitorResponseString); |
|
|
|
|
VisitorResponseJsonAppointmentRequestTurnstileLogEntity.setState(addVisitorResponseJson.get("code").toString()); |
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentRequestTurnstileLog(VisitorResponseJsonAppointmentRequestTurnstileLogEntity); |
|
|
|
|
|
|
|
|
|
//获取二维码信息
|
|
|
|
|
Map<String,String> map2= new HashMap<>(); |
|
|
|
|
map2.put("idCard",item.getDocumentsNumber()); |
|
|
|
|
map2.put("endTime",item.getAppointmentDate()+" " +reservationNowVO.getEndTime()+":00"); |
|
|
|
|
|
|
|
|
|
String updateQRCodevResponseString = HttpUtil.sendPost(turnstileUrl+updateQRCodev,map2); |
|
|
|
|
JSONObject json = JSONObject.parseObject(updateQRCodevResponseString); |
|
|
|
|
JSONObject json1= JSONObject.parseObject(json.get("data").toString()); |
|
|
|
|
|
|
|
|
|
//记录访问日志
|
|
|
|
|
AppointmentRequestTurnstileLogEntity appointmentRequestTurnstileLogEntity=new AppointmentRequestTurnstileLogEntity(); |
|
|
|
|
appointmentRequestTurnstileLogEntity.setRequestUrl(turnstileUrl+updateQRCodev); |
|
|
|
|
appointmentRequestTurnstileLogEntity.setRequestParams(map2.toString()); |
|
|
|
|
appointmentRequestTurnstileLogEntity.setResponseBody(updateQRCodevResponseString); |
|
|
|
|
appointmentRequestTurnstileLogEntity.setState(json.get("code").toString()); |
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentRequestTurnstileLog(appointmentRequestTurnstileLogEntity); |
|
|
|
|
item.setQrContent(json1.get("二维码信息").toString()); |
|
|
|
|
}); |
|
|
|
|
ybsjyAppointmentSettingMapper.saveAppointmentPeopleInfo(reservationNowVO.getAppointmentPersonList()); |
|
|
|
|
//设置权限
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
return ServerResponse.createByError("预约失败,预约人数已满"); |
|
|
|
|
} |
|
|
|
@ -309,4 +376,6 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
appointmentDocumentsDetails.setList(list); |
|
|
|
|
return ServerResponse.createBySuccess(appointmentDocumentsDetails); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|