|
|
|
|
@ -1,13 +1,22 @@ |
|
|
|
|
package com.cjy.back.ybsjAppointment.service.impl; |
|
|
|
|
|
|
|
|
|
import com.cjy.back.ybsjAppointment.dao.YbsjyAppointmentSettingMapper; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.AppointmentTimeInfoEntity; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.YbsjyAppointmentSettingEntity; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.vo.AppletsAppointmentListVO; |
|
|
|
|
import com.cjy.back.ybsjAppointment.entity.vo.ReservationNowVO; |
|
|
|
|
import com.cjy.back.ybsjAppointment.service.YbsjyAppointmentSettingService; |
|
|
|
|
import com.cjy.back.ybsjAppointment.utils.DateUtil; |
|
|
|
|
import com.cjy.common.PageWrapper; |
|
|
|
|
import com.cjy.util.ServerResponse; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author liangjiawei |
|
|
|
|
* @createDate 2023/7/25 |
|
|
|
|
@ -17,6 +26,13 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
@Autowired |
|
|
|
|
YbsjyAppointmentSettingMapper ybsjyAppointmentSettingMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预约设置添加 |
|
|
|
|
* |
|
|
|
|
* @param ybsjyAppointmentSettingEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public ServerResponse add(YbsjyAppointmentSettingEntity ybsjyAppointmentSettingEntity) { |
|
|
|
|
@ -28,11 +44,162 @@ public class YbsjyAppointmentSettingServiceImpl implements YbsjyAppointmentSetti |
|
|
|
|
return ServerResponse.createBySuccess("创建成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预约设置编辑 |
|
|
|
|
* |
|
|
|
|
* @param ybsjyAppointmentSettingEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public ServerResponse updateYbsjyAppointmentSetting(YbsjyAppointmentSettingEntity ybsjyAppointmentSettingEntity) { |
|
|
|
|
ybsjyAppointmentSettingMapper.updateAppointmentSetting(ybsjyAppointmentSettingEntity); |
|
|
|
|
// //先删除后插入
|
|
|
|
|
// ybsjyAppointmentSettingMapper.deleteAppointmentTimeInfoEntity(ybsjyAppointmentSettingEntity.getId());
|
|
|
|
|
// //通过配置表id删除时间段表中的数据
|
|
|
|
|
// ybsjyAppointmentSettingMapper.addAppointmentTimeInfoEntityList(ybsjyAppointmentSettingEntity.getPeriodTimeList(), ybsjyAppointmentSettingEntity.getId(), ybsjyAppointmentSettingEntity.getUpdateBy());
|
|
|
|
|
//
|
|
|
|
|
ybsjyAppointmentSettingMapper.updateAppointmentTimeInfoEntityList(ybsjyAppointmentSettingEntity.getPeriodTimeList(), ybsjyAppointmentSettingEntity.getId(), ybsjyAppointmentSettingEntity.getUpdateBy()); |
|
|
|
|
return ServerResponse.createBySuccess("编辑成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预约设置列表 |
|
|
|
|
* |
|
|
|
|
* @param ybsjyAppointmentSettingEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse appointmentSettingList(YbsjyAppointmentSettingEntity ybsjyAppointmentSettingEntity) { |
|
|
|
|
// 获取当前页码,在分页组件里 参数固定为currentPage
|
|
|
|
|
String cpage = ybsjyAppointmentSettingEntity.getPage(); |
|
|
|
|
// 显示行数
|
|
|
|
|
int limit = Integer.valueOf(ybsjyAppointmentSettingEntity.getLimit()); |
|
|
|
|
int pageNo = 1; |
|
|
|
|
if (cpage != null && !("").equals(cpage)) { |
|
|
|
|
pageNo = Integer.parseInt(cpage); |
|
|
|
|
} |
|
|
|
|
/* 分页信息开始 */ |
|
|
|
|
PageWrapper pw = new PageWrapper(); |
|
|
|
|
pw.getPage().setCurrentPage(pageNo); |
|
|
|
|
pw.getPage().setPageSize(limit); // 每页条数
|
|
|
|
|
/* 分页信息结束 */ |
|
|
|
|
//根据条件进行分页查询数据
|
|
|
|
|
List<Map<String, Object>> list = ybsjyAppointmentSettingMapper.queryAppointmentSettingListByPage(pw.getPage(), ybsjyAppointmentSettingEntity); |
|
|
|
|
|
|
|
|
|
// 查询总行数
|
|
|
|
|
int userCount = pw.getPage().getTotalCount(); |
|
|
|
|
//返回数据
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
resultMap.put("count", userCount); |
|
|
|
|
resultMap.put("data", list); |
|
|
|
|
resultMap.put("msg", "查询成功"); |
|
|
|
|
resultMap.put("code", 0); |
|
|
|
|
return ServerResponse.createBySuccess(resultMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 状态切换 |
|
|
|
|
* |
|
|
|
|
* @param ybsjyAppointmentSettingEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse stateSwitch(YbsjyAppointmentSettingEntity ybsjyAppointmentSettingEntity) { |
|
|
|
|
String returnMenssage = ""; |
|
|
|
|
if (ybsjyAppointmentSettingEntity.getState() == 1) { |
|
|
|
|
if (ybsjyAppointmentSettingMapper.getSettingCountByGuid(ybsjyAppointmentSettingEntity.getGuid()) == 0) { |
|
|
|
|
ybsjyAppointmentSettingEntity.setState(0); |
|
|
|
|
returnMenssage = "开启成功"; |
|
|
|
|
} else { |
|
|
|
|
return ServerResponse.createByError("一个景区仅支持一个规则,请先关闭其他开启的规则。"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (ybsjyAppointmentSettingEntity.getState() == 0) { |
|
|
|
|
ybsjyAppointmentSettingEntity.setState(1); |
|
|
|
|
returnMenssage = "停用成功"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ybsjyAppointmentSettingMapper.stateSwitch(ybsjyAppointmentSettingEntity); |
|
|
|
|
return ServerResponse.createBySuccess(returnMenssage); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取配置详情 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse getAppointmentSettingDetail(int id) { |
|
|
|
|
//第一步获取配置信息
|
|
|
|
|
YbsjyAppointmentSettingEntity ybsjyAppointmentSettingEntity = new YbsjyAppointmentSettingEntity(); |
|
|
|
|
ybsjyAppointmentSettingEntity = ybsjyAppointmentSettingMapper.getAppointmentSettingDetail(id); |
|
|
|
|
|
|
|
|
|
List<AppointmentTimeInfoEntity> periodTimeList = ybsjyAppointmentSettingMapper.getAppointmentTimeInfoEntityDetail(id); |
|
|
|
|
ybsjyAppointmentSettingEntity.setPeriodTimeList(periodTimeList); |
|
|
|
|
//第二步获取时间段
|
|
|
|
|
return ServerResponse.createBySuccess(ybsjyAppointmentSettingEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除预约配置 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @param userId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse deleteAppointmentSetting(int id, int userId) { |
|
|
|
|
ybsjyAppointmentSettingMapper.deleteAppointmentSetting(id, userId); |
|
|
|
|
return ServerResponse.createBySuccess("删除成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除时间段 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @param userId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse delectAppointmentPeriod(int id, int userId) { |
|
|
|
|
ybsjyAppointmentSettingMapper.delectAppointmentPeriod(id, userId); |
|
|
|
|
return ServerResponse.createBySuccess("删除成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过日期和景区参数去获取预约列表 |
|
|
|
|
* @param date |
|
|
|
|
* @param scenicId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse appointmentList(String date, String scenicId) { |
|
|
|
|
//第一步通过景区id获取到对应的规则 通过日期及今天是周几判断是否返回
|
|
|
|
|
|
|
|
|
|
//知道周几
|
|
|
|
|
int whichDay = DateUtil.getWhichDay(date); |
|
|
|
|
List<AppletsAppointmentListVO> list = ybsjyAppointmentSettingMapper.appointmentList(date, scenicId, whichDay); |
|
|
|
|
list.stream().forEach(item -> { |
|
|
|
|
//通过时间段id统计目前预约了多少人
|
|
|
|
|
item.setReservedQuantity(ybsjyAppointmentSettingMapper.getAppointmentCount(item.getAppointmentTimeInfoId())); |
|
|
|
|
}); |
|
|
|
|
//第二步通过通过规则id获取到时间段列表
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
resultMap.put("data", list); |
|
|
|
|
resultMap.put("msg", "查询成功"); |
|
|
|
|
resultMap.put("code", 0); |
|
|
|
|
return ServerResponse.createBySuccess(resultMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 立即预约 |
|
|
|
|
* @param reservationNowVO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse reservationNow(ReservationNowVO reservationNowVO) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|