记得上下班打卡 | git大法好,push需谨慎

Commit 8d12e6ee authored by 张国柄's avatar 张国柄

验票API:

 演出列表添加模糊搜索、票种合计;
parent 92258581
...@@ -38,6 +38,7 @@ import java.util.*; ...@@ -38,6 +38,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Api(tags = "验票") @Api(tags = "验票")
...@@ -105,13 +106,15 @@ public class KylinStationController { ...@@ -105,13 +106,15 @@ public class KylinStationController {
@ApiOperation(value = "演出列表") @ApiOperation(value = "演出列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mod", value = "模块[recent-近期的,over-历史]", allowableValues = "recent,over"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mod", value = "模块[recent-近期的,over-历史]", allowableValues = "recent,over"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "match", value = "匹配字符[title|cityName|fieldName]"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "pageNo", value = "页码", example = "1"), @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "pageNo", value = "页码", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "pageSize", value = "页记录数", example = "5"), @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "pageSize", value = "页记录数", example = "5"),
}) })
@GetMapping("performances") @GetMapping("performances")
public ResponseDto<PageInfo<KylinStationPerformanceVo>> performances(@RequestParam String mod, public ResponseDto<PageInfo<KylinStationPerformanceVo>> performances(@RequestParam String mod,
@RequestParam(defaultValue = "1", required = false) int pageNo, @RequestParam(required = false) String match,
@RequestParam(defaultValue = "5", required = false) int pageSize) { @RequestParam(defaultValue = "1", required = false) int pageNo,
@RequestParam(defaultValue = "5", required = false) int pageSize) {
List<KylinStationPerformanceVo> voList = new ArrayList<>(); List<KylinStationPerformanceVo> voList = new ArrayList<>();
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
long count = 0; long count = 0;
...@@ -124,25 +127,34 @@ public class KylinStationController { ...@@ -124,25 +127,34 @@ public class KylinStationController {
if (!CollectionUtils.isEmpty(performanceRelationList)) { if (!CollectionUtils.isEmpty(performanceRelationList)) {
LocalDateTime tmpDt = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0, 0)); LocalDateTime tmpDt = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0, 0));
String tmpDtStr = DateUtil.format(tmpDt, DateUtil.Formatter.yyyyMMddHHmmss); String tmpDtStr = DateUtil.format(tmpDt, DateUtil.Formatter.yyyyMMddHHmmss);
Query performancesVoQuery = Query.query(Criteria.where("performancesId").in( Criteria criteria = Criteria.where("performancesId").in(
performanceRelationList.stream().map(CheckPerformanceRelationParam::getPerformanceId).toArray() performanceRelationList.stream().map(CheckPerformanceRelationParam::getPerformanceId).toArray()
)); );
switch (mod) { switch (mod) {
case "recent": case "recent":
log.info(":::performances/recent:{}", currentUid); log.debug(":::performances/recent:{},match:{}", currentUid, match);
performancesVoQuery.addCriteria(Criteria.where("timeEnd").gt(tmpDtStr)); criteria.andOperator(Criteria.where("timeEnd").gt(tmpDtStr));
break; break;
// case "down": // case "down":
// log.info(":::performances/down:{}", currentUid); // log.info(":::performances/down:{}", currentUid);
// break; // break;
case "over": case "over":
log.info(":::performances/over:{}", currentUid); log.info(":::performances/over:{}", currentUid);
performancesVoQuery.addCriteria(Criteria.where("timeEnd").lte(tmpDtStr)); criteria.andOperator(Criteria.where("timeEnd").lte(tmpDtStr));
break; break;
default: default:
log.info(":::performances/default:{}", currentUid); log.info(":::performances/default:{}", currentUid);
return ResponseDto.success(new PageInfo<>()); return ResponseDto.success(new PageInfo<>());
} }
if (StringUtils.isNotBlank(match)) {
Pattern pattern = Pattern.compile("^.*" + match + ".*$", Pattern.CASE_INSENSITIVE);
criteria.orOperator(
Criteria.where("title").regex(pattern),
Criteria.where("cityName").regex(pattern),
Criteria.where("fieldName").regex(pattern)
);
}
Query performancesVoQuery = Query.query(criteria);
count = mongoTemplate.count(performancesVoQuery, KylinPerformanceVo.class.getSimpleName()); count = mongoTemplate.count(performancesVoQuery, KylinPerformanceVo.class.getSimpleName());
if (count <= 0) return ResponseDto.success(new PageInfo<>()); if (count <= 0) return ResponseDto.success(new PageInfo<>());
...@@ -178,6 +190,8 @@ public class KylinStationController { ...@@ -178,6 +190,8 @@ public class KylinStationController {
List<KylinStationTicketVo> ticketVoList = new ArrayList<>(); List<KylinStationTicketVo> ticketVoList = new ArrayList<>();
BigDecimal priceSum = BigDecimal.ZERO;
int number = 0, checkedNum = 0, remainderNum = 0;
for (Map.Entry<String, List<KylinOrderTicketEntitiesVo>> entry : performanceTicketEntitiesVoMap.entrySet()) { for (Map.Entry<String, List<KylinOrderTicketEntitiesVo>> entry : performanceTicketEntitiesVoMap.entrySet()) {
KylinTicketVo ticketVo = performanceTicketMap.get(entry.getKey()); KylinTicketVo ticketVo = performanceTicketMap.get(entry.getKey());
...@@ -200,9 +214,23 @@ public class KylinStationController { ...@@ -200,9 +214,23 @@ public class KylinStationController {
List<KylinOrderTicketEntitiesVo> remainderEntitiesVoList = subStatusPerformanceTicketEntitiesVoMap.get(0); List<KylinOrderTicketEntitiesVo> remainderEntitiesVoList = subStatusPerformanceTicketEntitiesVoMap.get(0);
stationTicketVo.setRemainderNum(CollectionUtils.isEmpty(remainderEntitiesVoList) ? 0 : remainderEntitiesVoList.size()); stationTicketVo.setRemainderNum(CollectionUtils.isEmpty(remainderEntitiesVoList) ? 0 : remainderEntitiesVoList.size());
number += stationTicketVo.getNumber();
checkedNum += stationTicketVo.getCheckedNum();
remainderNum += stationTicketVo.getRemainderNum();
priceSum = priceSum.add(stationTicketVo.getPriceSum());
ticketVoList.add(stationTicketVo); ticketVoList.add(stationTicketVo);
} }
KylinStationTicketVo sumTicketVo = KylinStationTicketVo.getNew();
sumTicketVo.setTicketId("TT");
sumTicketVo.setTitle("合计");
sumTicketVo.setPriceSum(priceSum);
sumTicketVo.setNumber(number);
sumTicketVo.setCheckedNum(checkedNum);
sumTicketVo.setRemainderNum(remainderNum);
ticketVoList.add(sumTicketVo);
r.setTicketVoList(ticketVoList); r.setTicketVoList(ticketVoList);
r.setCanDownTime(performanceRelationMap.get(r.getPerformancesId())); r.setCanDownTime(performanceRelationMap.get(r.getPerformancesId()));
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment