api-显示当前场馆的预订信息
This commit is contained in:
@@ -80,6 +80,10 @@ public class PlatformIdInterceptor implements Interceptor {
|
||||
if (checkUrl(request)){
|
||||
return sql;
|
||||
}
|
||||
// 复杂SQL
|
||||
if (sql.contains("GROUP BY")){
|
||||
return sql;
|
||||
}
|
||||
StringBuilder condition = new StringBuilder(" 1 = 1 ");
|
||||
String platformKey = PlatformContext.getKey();
|
||||
if(StringUtils.isEmpty(platformKey))
|
||||
|
||||
@@ -1,14 +1,85 @@
|
||||
package com.sv.netty.controller;
|
||||
|
||||
import com.ydd.framework.core.common.dto.ResponseDTO;
|
||||
import com.sv.dto.app.VenueLessonStatus;
|
||||
import com.sv.service.api.VenueLessonService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class AppVenueLessonController {
|
||||
|
||||
@RequestMapping("/getLessonOrder")
|
||||
public ResponseDTO sendMessage1() {
|
||||
return ResponseDTO.ok();
|
||||
@Resource
|
||||
private VenueLessonService venueLessonService;
|
||||
|
||||
/**
|
||||
* 通过返回页面来进行拼接,每个APP可以返回具体的场馆的课程预订情况
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getLessonOrder/{id}")
|
||||
public String getLessonOrder(@PathVariable("id") Integer id,String date) {
|
||||
if (date == null && "".equals(date)){
|
||||
LocalDate now = LocalDate.now();
|
||||
date = now.toString();
|
||||
}
|
||||
// 如果传入时间非法,都改为今天
|
||||
try {
|
||||
LocalDate parse = LocalDate.parse(date);
|
||||
date = parse.toString();
|
||||
}catch (Exception e){
|
||||
LocalDate now = LocalDate.now();
|
||||
date = now.toString();
|
||||
}
|
||||
List<VenueLessonStatus> lessonOrder = venueLessonService.getLessonOrder(id, date);
|
||||
if (lessonOrder != null && lessonOrder.size() > 0){
|
||||
String returnHtml = concatResult(lessonOrder);
|
||||
return returnHtml;
|
||||
}else {
|
||||
return "<h1 align=\"center\">~_~该场馆当天没有课程~_~<h1>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String concatResult(List<VenueLessonStatus> lessonOrder) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><head></head>");
|
||||
sb.append("<body bgcolor=\"#3C3C3C\">");
|
||||
sb.append("<h1 align=\"center\">【" + lessonOrder.get(0).getVenueName() + "】(" + lessonOrder.get(0).getSearchDate() + ")预订信息一览表" + "<h1>");
|
||||
sb.append("<table width = 100% bgcolor=\"#FFFFFF\" align=\"center\" border=\"1\">");
|
||||
sb.append("<tr bgcolor=\"#3399ff\" align=\"center\">" +
|
||||
// "<td width = 10% style=\"font-size: 20px;\">场馆</td>" +
|
||||
"<td width = 10% style=\"font-size: 20px;\">课程</td>" +
|
||||
// "<td width = 8% style=\"font-size: 20px;\">日期</td>" +
|
||||
"<td width = 10% style=\"font-size: 20px;\">时间</td>" +
|
||||
"<td width = 4% style=\"font-size: 20px;\">总量</td>" +
|
||||
"<td width = 4% style=\"font-size: 20px;\">预订</td>" +
|
||||
"<td width = 4% style=\"font-size: 20px;\">剩余</td>" +
|
||||
"<td width = 20% style=\"font-size: 20px;\">预约用户</td>" +
|
||||
"<td width = 38% style=\"font-size: 20px;\">说明</td>" +
|
||||
"</tr>");
|
||||
// boolean firstLine = true;
|
||||
for (VenueLessonStatus s : lessonOrder){
|
||||
sb.append("<tr>");
|
||||
// if (firstLine){
|
||||
// sb.append( "<td width = 10% rowspan=" + lessonOrder.size() + ">"+ s.getVenueName() + "</td>");
|
||||
// firstLine = false;
|
||||
// }
|
||||
sb.append( "<td width = 10% >"+ s.getLessonName() + "</td>");
|
||||
// sb.append( "<td width = 8% >"+ s.getSearchDate() + "</td>");
|
||||
sb.append( "<td width = 10%>"+ s.getStartTime() + "-" + s.getEndTime() + "</td>");
|
||||
sb.append( "<td width = 4%>"+ s.getNum() + "</td>");
|
||||
sb.append( "<td width = 4%>"+ s.getSaleNum() + "</td>");
|
||||
sb.append( "<td width = 4%>"+ s.getLimitNum() + "</td>");
|
||||
sb.append( "<td width = 20%>"+ s.getOrderUsers() + "</td>");
|
||||
sb.append( "<td width = 38%>"+ s.getNote() + "</td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
sb.append("</table></body></html>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
112
entity/src/main/java/com/sv/dto/app/VenueLessonStatus.java
Normal file
112
entity/src/main/java/com/sv/dto/app/VenueLessonStatus.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.sv.dto.app;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class VenueLessonStatus implements Serializable {
|
||||
private String venueName;
|
||||
private String lessonName;
|
||||
private String searchDate;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private int num;
|
||||
private int saleNum;
|
||||
private int limitNum;
|
||||
private String orderUsers;
|
||||
private String note;
|
||||
|
||||
public String getVenueName() {
|
||||
return venueName;
|
||||
}
|
||||
|
||||
public void setVenueName(String venueName) {
|
||||
this.venueName = venueName;
|
||||
}
|
||||
|
||||
public String getLessonName() {
|
||||
return lessonName;
|
||||
}
|
||||
|
||||
public void setLessonName(String lessonName) {
|
||||
this.lessonName = lessonName;
|
||||
}
|
||||
|
||||
public String getSearchDate() {
|
||||
return searchDate;
|
||||
}
|
||||
|
||||
public void setSearchDate(String searchDate) {
|
||||
this.searchDate = searchDate;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getSaleNum() {
|
||||
return saleNum;
|
||||
}
|
||||
|
||||
public void setSaleNum(int saleNum) {
|
||||
this.saleNum = saleNum;
|
||||
}
|
||||
|
||||
public int getLimitNum() {
|
||||
return limitNum;
|
||||
}
|
||||
|
||||
public void setLimitNum(int limitNum) {
|
||||
this.limitNum = limitNum;
|
||||
}
|
||||
|
||||
public String getOrderUsers() {
|
||||
return orderUsers;
|
||||
}
|
||||
|
||||
public void setOrderUsers(String orderUsers) {
|
||||
this.orderUsers = orderUsers;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VenueLessonStatus{" +
|
||||
"venueName='" + venueName + '\'' +
|
||||
", lessonName='" + lessonName + '\'' +
|
||||
", searchDate='" + searchDate + '\'' +
|
||||
", startTime='" + startTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
", num=" + num +
|
||||
", saleNum=" + saleNum +
|
||||
", limitNum=" + limitNum +
|
||||
", orderUsers='" + orderUsers + '\'' +
|
||||
", note='" + note + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.sv.mapper;
|
||||
|
||||
import com.sv.annotation.PlatformKey;
|
||||
import com.sv.dto.api.VenueLessonDTO;
|
||||
import com.sv.dto.app.VenueLessonStatus;
|
||||
import com.sv.dto.oms.VenueLessonOmsDTO;
|
||||
import com.sv.entity.MemberLessonTicket;
|
||||
import com.sv.entity.VenueLesson;
|
||||
@@ -131,4 +132,13 @@ public interface VenueLessonMapper {
|
||||
* api 修改库存
|
||||
*/
|
||||
void updateSaleNumBy(@Param("num")Integer num,@Param("lessonId") Integer lessonId);
|
||||
|
||||
/**
|
||||
* APP获取当前预订情况
|
||||
* @param venueId
|
||||
* @param searchDate
|
||||
* and b.date = #{searchDate} and b.venue_id = #{venueId}
|
||||
* @return
|
||||
*/
|
||||
List<VenueLessonStatus> getLessonStatus(@Param("venueId") Integer venueId,@Param("searchDate") String searchDate);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.sv.service.api;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sv.dto.api.VenueLessonDTO;
|
||||
import com.sv.dto.app.VenueLessonStatus;
|
||||
import com.sv.entity.Member;
|
||||
import com.sv.entity.MemberLessonTicket;
|
||||
import com.sv.entity.VenueLesson;
|
||||
@@ -322,5 +323,12 @@ public class VenueLessonService extends BaseServiceImpl {
|
||||
public void updateSaleNum(Integer num,Integer lessonId){
|
||||
venueLessonMapper.updateSaleNumBy(num,lessonId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<VenueLessonStatus> getLessonOrder(Integer venueId,String searchDate){
|
||||
// 校验场馆是否存在 TODO
|
||||
return venueLessonMapper.getLessonStatus(venueId,searchDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -602,4 +602,23 @@
|
||||
WHERE
|
||||
id = #{lessonId}
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 修改库存 -->
|
||||
<select id="getLessonStatus" resultType="com.sv.dto.app.VenueLessonStatus">
|
||||
select (select x.name from sv_venue x where x.id = a.venue_id) as 'venueName',
|
||||
a.`name` as 'lessonName',a.date as 'searchDate',
|
||||
a.start_time as 'startTime',a.end_time as 'endTime',a.num,
|
||||
a.sale_num as 'saleNum',(a.num-a.sale_num) as 'limitNum',
|
||||
IFNULL(t.orderUsers,'暂无预订') as 'orderUsers',a.note
|
||||
from sv_venue_lesson a LEFT JOIN
|
||||
(select b.lesson_id,group_concat(d.nickname,'(',d.mobile,')') as 'orderUsers'
|
||||
from sv_member_lesson_ticket b , sv_member d
|
||||
where b.member_id = d.id
|
||||
and b.`status` != '2'
|
||||
GROUP BY b.lesson_id) t on a.id = t.lesson_id
|
||||
where a.date = #{searchDate}
|
||||
and a.venue_id = #{venueId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user