fixbug— 预定展示
This commit is contained in:
115
api/src/main/java/com/sv/netty/config/OrderTools.java
Normal file
115
api/src/main/java/com/sv/netty/config/OrderTools.java
Normal file
File diff suppressed because one or more lines are too long
@@ -1,11 +1,12 @@
|
|||||||
package com.sv.netty.controller;
|
package com.sv.netty.controller;
|
||||||
|
|
||||||
|
import com.dw.ccm.wechat.base.utils.JsonUtils;
|
||||||
import com.sv.dto.app.VenueItem;
|
import com.sv.dto.app.VenueItem;
|
||||||
import com.sv.dto.app.VenueLessonStatus;
|
import com.sv.dto.app.VenueLessonStatus;
|
||||||
import com.sv.entity.Venue;
|
import com.sv.entity.Venue;
|
||||||
|
import com.sv.netty.config.OrderTools;
|
||||||
import com.sv.service.api.VenueLessonService;
|
import com.sv.service.api.VenueLessonService;
|
||||||
import com.sv.service.oms.VenueService;
|
import com.sv.service.oms.VenueService;
|
||||||
import org.apache.http.client.fluent.Request;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -13,13 +14,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class AppVenueLessonController {
|
public class AppVenueLessonController {
|
||||||
@@ -51,80 +49,129 @@ public class AppVenueLessonController {
|
|||||||
LocalDate now = LocalDate.now();
|
LocalDate now = LocalDate.now();
|
||||||
date = now.toString();
|
date = now.toString();
|
||||||
}
|
}
|
||||||
|
List<String> th = fetchDays(LocalDate.parse(date));
|
||||||
|
Venue venue = venueService.getVenue(id);
|
||||||
|
List<String> lessonTypes = venueLessonService.getLessonTypes(id);
|
||||||
List<VenueLessonStatus> lessonOrder = venueLessonService.getLessonOrder(id);
|
List<VenueLessonStatus> lessonOrder = venueLessonService.getLessonOrder(id);
|
||||||
String returnHtml = concatResult(lessonOrder);
|
String returnHtml = concatResult(lessonOrder,th,lessonTypes,venue);
|
||||||
return returnHtml;
|
return returnHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String concatResult(List<VenueLessonStatus> lessonOrder) {
|
private List<String> fetchDays(LocalDate date) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
list.add(date.toString());
|
||||||
|
date = date.plusDays(1);
|
||||||
|
}
|
||||||
|
list.add(date.toString());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String concatResult(List<VenueLessonStatus> lessonOrder, List<String> th, List<String> lessonTypes, Venue venue) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
|
sb.append("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
|
||||||
"<meta http-equiv=\"refresh\" content=\"10\"/><head>");
|
"<meta http-equiv=\"refresh\" content=\"10\"/><head>");
|
||||||
sb.append("<style type=\"text/css\">");
|
sb.append("<script>" + OrderTools.JS + "</script>");
|
||||||
sb.append("table {" +
|
sb.append("<style>" + OrderTools.STYLE + "</style>");
|
||||||
" border-collapse: collapse;" +
|
|
||||||
" margin: 0 auto;" +
|
|
||||||
" text-align: center;" +
|
|
||||||
"}" +
|
|
||||||
"" +
|
|
||||||
"table td," +
|
|
||||||
"table th {" +
|
|
||||||
" border: 1px solid #cad9ea;" +
|
|
||||||
" color: #666;" +
|
|
||||||
" height: 30px;" +
|
|
||||||
"}" +
|
|
||||||
"" +
|
|
||||||
"table tr th {" +
|
|
||||||
" background-color: #CCE8EB;" +
|
|
||||||
" width: 100px;" +
|
|
||||||
"}" +
|
|
||||||
"" +
|
|
||||||
"table tr:nth-child(odd) {" +
|
|
||||||
" background: #fff;" +
|
|
||||||
"}" +
|
|
||||||
"" +
|
|
||||||
".nl {" +
|
|
||||||
" text-align: left;" +
|
|
||||||
"}" +
|
|
||||||
"" +
|
|
||||||
"table tr:nth-child(even) {" +
|
|
||||||
" background: #F5FAFA;" +
|
|
||||||
"}");
|
|
||||||
sb.append("</style>");
|
|
||||||
sb.append("</head>");
|
sb.append("</head>");
|
||||||
sb.append("<body>");
|
sb.append("<body background = \"" + OrderTools.BG + "\" >");
|
||||||
sb.append("<h1 align=\"center\">【" + lessonOrder.get(0).getVenueName() + "】预订信息" + "<h1>");
|
// 显示LOGO && 场馆名 && 二维码
|
||||||
sb.append("<table cellspacing=\"0\" cellpadding=\"0\" width = 100% align=\"center\">");
|
sb.append("<div id=\"qrcode\">"
|
||||||
sb.append("<tr align=\"center\">" +
|
+ "<img width=\"50\" height=\"50\" src=\"" + venue.getCodeUrl() + "\" />"
|
||||||
// "<td width = 10%>场馆</td>" +
|
+ "</div>"
|
||||||
"<th width = 10%>课程</th>" +
|
+ "<div id=\"venue\">" +
|
||||||
"<th width = 10%>日期</th>" +
|
"<img width=\"200\" height=\"50\" src=\"" + OrderTools.LOGO
|
||||||
"<th width = 10%>时间</th>" +
|
+ "\" /><span>"
|
||||||
"<th width = 6%>总量</th>" +
|
+ venue.getName()
|
||||||
"<th width = 6%>预订</th>" +
|
+ "预定信息</span></div>");
|
||||||
"<th width = 6%>剩余</th>" +
|
sb.append("<div id=\"coursesTable\"></div>");
|
||||||
"<th width = 22%>预约用户</th>" +
|
sb.append("<script>");
|
||||||
"<th width = 30%>说明</th>" +
|
sb.append("var week = " + JsonUtils.toJson(th)
|
||||||
"</tr>");
|
.replaceAll("\"","'") + ";");
|
||||||
// boolean firstLine = true;
|
String courseType = OrderTools.COMMON_TYPE;
|
||||||
for (VenueLessonStatus s : lessonOrder){
|
if (lessonTypes != null && lessonTypes.size() >= 0){
|
||||||
sb.append("<tr>");
|
StringBuffer type = new StringBuffer();
|
||||||
// if (firstLine){
|
type.append("[");
|
||||||
// sb.append( "<td width = 10% rowspan=" + lessonOrder.size() + ">"+ s.getVenueName() + "</td>");
|
int temp = 1;
|
||||||
// firstLine = false;
|
for (String t : lessonTypes){
|
||||||
// }
|
if (temp != 1){
|
||||||
sb.append( "<td width = 10%>"+ s.getLessonName() + "</td>");
|
type.append(",");
|
||||||
sb.append( "<td width = 10%>"+ s.getSearchDate() + "</td>");
|
}
|
||||||
sb.append( "<td width = 10%>"+ s.getStartTime() + "-" + s.getEndTime() + "</td>");
|
type.append("[{index:" + temp + ",name:'" + t.substring(0,5) + "'},1]");
|
||||||
sb.append( "<td width = 6%>"+ s.getNum() + "</td>");
|
temp ++;
|
||||||
sb.append( "<td width = 6%>"+ s.getSaleNum() + "</td>");
|
}
|
||||||
sb.append( "<td width = 6%>"+ s.getLimitNum() + "</td>");
|
type.append("]");
|
||||||
sb.append( "<td class=\"nl\" width = 22%>"+ s.getOrderUsers() + "</td>");
|
courseType = type.toString();
|
||||||
String note = s.getNote().replaceAll("<br data-mce-bogus=\"1\">","").replaceAll("<br>","").replaceAll("<p>", "").replaceAll("</p>", "<br/>");
|
|
||||||
sb.append( "<td class=\"nl\" width = 30%>"+ note + "</td>");
|
|
||||||
sb.append("</tr>");
|
|
||||||
}
|
}
|
||||||
sb.append("</table></body></html>");
|
sb.append("var courseType = " + courseType + ";");
|
||||||
|
String courseList = "[]";
|
||||||
|
if (lessonOrder != null && lessonOrder.size() >= 0){
|
||||||
|
int col = lessonTypes.size();
|
||||||
|
StringBuffer course = new StringBuffer();
|
||||||
|
course.append("[");
|
||||||
|
int temp1 = 1;
|
||||||
|
for (String d : th){
|
||||||
|
if (temp1 != 1){
|
||||||
|
course.append(",");
|
||||||
|
}
|
||||||
|
course.append("[");
|
||||||
|
temp1 ++;
|
||||||
|
List<VenueLessonStatus> theDay = lessonOrder.stream().filter(x -> d.equals(x.getSearchDate()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (theDay != null && theDay.size() > 0){
|
||||||
|
int temp2 = 1;
|
||||||
|
for (String t : lessonTypes){
|
||||||
|
if (temp2 != 1){
|
||||||
|
course.append(",");
|
||||||
|
}
|
||||||
|
temp2 ++;
|
||||||
|
List<VenueLessonStatus> collect = theDay.stream().filter(y -> t.equals(y.getStartTime()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (collect != null && collect.size()>0){
|
||||||
|
course.append(ForEachCourse(collect));
|
||||||
|
}else {
|
||||||
|
course.append("''");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
course.append(getEmptyStr(col));
|
||||||
|
}
|
||||||
|
course.append("]");
|
||||||
|
}
|
||||||
|
course.append("]");
|
||||||
|
courseList = course.toString();
|
||||||
|
}
|
||||||
|
sb.append("var courseList = " + courseList + ";");
|
||||||
|
sb.append("// 实例化(初始化课表)\n" +
|
||||||
|
" var Timetable = new Timetables({\n" +
|
||||||
|
" el: '#coursesTable',\n" +
|
||||||
|
" timetables: courseList,\n" +
|
||||||
|
" week: week,\n" +
|
||||||
|
" timetableType: courseType,\n" +
|
||||||
|
" styles: {\n" +
|
||||||
|
" Gheight: 100\n" +
|
||||||
|
" }\n" +
|
||||||
|
" });");
|
||||||
|
sb.append("</script></body></html>");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ForEachCourse(List<VenueLessonStatus> collect) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (VenueLessonStatus v : collect){
|
||||||
|
sb.append("'" + v.getLessonName() + "(" + v.getStartTime().substring(0,5) + "-" + v.getEndTime().substring(0,5) + ")");
|
||||||
|
sb.append("【总计:" + v.getNum() + "," + (v.getLimitNum() == 0 ? "已约满】" : "剩余:" + v.getLimitNum()) + "】");
|
||||||
|
sb.append("@预订用户:(" + v.getOrderUsers() + ")'");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEmptyStr(int i) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int j = 1 ; j < i; j ++){
|
||||||
|
sb.append("'',");
|
||||||
|
}
|
||||||
|
sb.append("''");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,13 @@ public interface VenueLessonMapper {
|
|||||||
*/
|
*/
|
||||||
void updateSaleNumBy(@Param("num")Integer num,@Param("lessonId") Integer lessonId);
|
void updateSaleNumBy(@Param("num")Integer num,@Param("lessonId") Integer lessonId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP获取当前预订时间列
|
||||||
|
* @param venueId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getLessonTypes(@Param("venueId") Integer venueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP获取当前预订情况
|
* APP获取当前预订情况
|
||||||
* @param venueId
|
* @param venueId
|
||||||
|
|||||||
@@ -323,6 +323,10 @@ public class VenueLessonService extends BaseServiceImpl {
|
|||||||
public void updateSaleNum(Integer num,Integer lessonId){
|
public void updateSaleNum(Integer num,Integer lessonId){
|
||||||
venueLessonMapper.updateSaleNumBy(num,lessonId);
|
venueLessonMapper.updateSaleNumBy(num,lessonId);
|
||||||
}
|
}
|
||||||
|
@Transactional
|
||||||
|
public List<String> getLessonTypes(Integer venueId) {
|
||||||
|
return venueLessonMapper.getLessonTypes(venueId);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<VenueLessonStatus> getLessonOrder(Integer venueId){
|
public List<VenueLessonStatus> getLessonOrder(Integer venueId){
|
||||||
|
|||||||
@@ -213,5 +213,10 @@ public class VenueService extends BaseServiceImpl {
|
|||||||
public void clearNumber(Integer id) {
|
public void clearNumber(Integer id) {
|
||||||
venueMapper.updateNumber(0, id);
|
venueMapper.updateNumber(0, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Venue getVenue(Integer id){
|
||||||
|
return venueMapper.findById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -604,7 +604,15 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<!-- 修改库存 -->
|
<select id="getLessonTypes" resultType="string">
|
||||||
|
select DISTINCT start_time from sv_venue_lesson a
|
||||||
|
where a.date <![CDATA[ >= ]]> DATE_SUB(NOW(),INTERVAL 1 DAY)
|
||||||
|
AND a.date <![CDATA[ <= ]]> DATE_ADD(NOW(),INTERVAL 4 DAY)
|
||||||
|
and a.venue_id = #{venueId}
|
||||||
|
ORDER BY a.start_time
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取预定信息 -->
|
||||||
<select id="getLessonStatus" resultType="com.sv.dto.app.VenueLessonStatus">
|
<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',
|
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.`name` as 'lessonName',a.date as 'searchDate',
|
||||||
@@ -612,14 +620,15 @@
|
|||||||
a.sale_num as 'saleNum',(a.num-a.sale_num) as 'limitNum',
|
a.sale_num as 'saleNum',(a.num-a.sale_num) as 'limitNum',
|
||||||
IFNULL(t.orderUsers,'暂无预订') as 'orderUsers',a.note
|
IFNULL(t.orderUsers,'暂无预订') as 'orderUsers',a.note
|
||||||
from sv_venue_lesson a LEFT JOIN
|
from sv_venue_lesson a LEFT JOIN
|
||||||
(select b.lesson_id,group_concat(distinct d.nickname,'(',d.mobile,')' SEPARATOR '<![CDATA[ <br/> ]]>') as 'orderUsers'
|
(select b.lesson_id,group_concat(distinct d.nickname SEPARATOR ',') as 'orderUsers'
|
||||||
from sv_member_lesson_ticket b , sv_member d
|
from sv_member_lesson_ticket b , sv_member d
|
||||||
where b.member_id = d.id
|
where b.member_id = d.id
|
||||||
and b.`status` != '2'
|
and b.`status` != '2'
|
||||||
GROUP BY b.lesson_id) t on a.id = t.lesson_id
|
GROUP BY b.lesson_id) t on a.id = t.lesson_id
|
||||||
where a.date <![CDATA[ >= ]]> NOW()
|
where a.date <![CDATA[ >= ]]> DATE_SUB(NOW(),INTERVAL 1 DAY)
|
||||||
AND a.date <![CDATA[ <= ]]> DATE_ADD(NOW(),INTERVAL 2 DAY)
|
AND a.date <![CDATA[ <= ]]> DATE_ADD(NOW(),INTERVAL 4 DAY)
|
||||||
and a.venue_id = #{venueId}
|
and a.venue_id = #{venueId}
|
||||||
|
ORDER BY a.date,a.start_time
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- api 查询需要copy的信息 -->
|
<!-- api 查询需要copy的信息 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user