|
@@ -124,6 +124,7 @@ public class UserTicketController extends BaseApiController {
|
|
|
/**
|
|
|
* 查看盲票详情
|
|
|
*/
|
|
|
+ // TODO: 下个版本删除
|
|
|
@PostMapping("/mall/ticket/detail")
|
|
|
@ApiOperation(value = "查看盲票详情", notes = "根据盲票组ID,获取盲票信息")
|
|
|
@ApiResponses(
|
|
@@ -212,6 +213,128 @@ public class UserTicketController extends BaseApiController {
|
|
|
return AjaxResult.success(ticketBoxVO);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看盲票详情
|
|
|
+ */
|
|
|
+ @PostMapping("/mall/ticket/detail/new")
|
|
|
+ @ApiOperation(value = "查看盲票详情(新)", notes = "根据盲票组ID,获取盲票信息")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "成功", response = TicketBoxVO.class)
|
|
|
+ )
|
|
|
+ public AjaxResult getInfoNew(@RequestBody TicketBoxParam param) {
|
|
|
+ if (StringUtils.isBlank(param.getBoxId())) {
|
|
|
+ return AjaxResult.error("参数异常,盲票组ID缺失");
|
|
|
+ }
|
|
|
+ TicketBox ticketBox = ticketBoxService.getById(param.getBoxId());
|
|
|
+ TicketBoxVO ticketBoxVO = mapperFacade.map(ticketBox, TicketBoxVO.class);
|
|
|
+
|
|
|
+
|
|
|
+ // 设置经销商佣金比
|
|
|
+ if (hostHolder.getUser() != null) {
|
|
|
+ Long channelId = hostHolder.getUser().getChannelId();
|
|
|
+ if (channelId != null && channelId > 0) {
|
|
|
+ Channel channel = channelService.getById(channelId);
|
|
|
+ if (channel != null) {
|
|
|
+ ticketBoxVO.setChannelCommRate(channel.getCommRate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 设置奖项标签信息
|
|
|
+ QueryWrapper<TicketAwards> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("box_id",ticketBox.getBoxId());
|
|
|
+ queryWrapper.isNotNull("awards_label");
|
|
|
+ queryWrapper.ne("awards_label", "");
|
|
|
+ queryWrapper.groupBy("awards_label");
|
|
|
+ StringBuilder sortField = new StringBuilder("FIELD(awards_label,'");
|
|
|
+ int index = 0;
|
|
|
+ for (AwardsLabelEnum awardsLabelEnum : AwardsLabelEnum.values()) {
|
|
|
+ index++;
|
|
|
+ if (index == AwardsLabelEnum.values().length) {
|
|
|
+ sortField.append(awardsLabelEnum.getValue()).append("'");
|
|
|
+ }else {
|
|
|
+ sortField.append(awardsLabelEnum.getValue()).append("','");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sortField.append(")");
|
|
|
+ queryWrapper.orderByAsc(sortField.toString());
|
|
|
+ List<TicketAwardsLabelVO> ticketAwardsLabelVOS = ticketAwardsService.groupSumQuantityByQueryWrapper(queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(ticketAwardsLabelVOS)) {
|
|
|
+ for (TicketAwardsLabelVO ticketAwardsLabelVO : ticketAwardsLabelVOS) {
|
|
|
+ AwardsLabelEnum awardsLabelEnum = AwardsLabelEnum.getByValue(ticketAwardsLabelVO.getLabelTitle());
|
|
|
+ if (Objects.isNull(awardsLabelEnum)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ticketAwardsLabelVO.setPicUrl(awardsLabelEnum.getPicUrl());
|
|
|
+ Integer quantity = ticketBox.getQuantity();
|
|
|
+ int num = ticketAwardsLabelVO.getQuantity();
|
|
|
+ ticketAwardsLabelVO.setHitRate(BigDecimal.valueOf(num).divide(BigDecimal.valueOf(quantity), 3, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(ticketAwardsLabelVOS)) {
|
|
|
+ // 精度问题处理
|
|
|
+ int maxIndex = 0;
|
|
|
+ BigDecimal maxHitRate = BigDecimal.valueOf(100);
|
|
|
+ for (int i = 0; i < ticketAwardsLabelVOS.size(); i++) {
|
|
|
+ TicketAwardsLabelVO ticketAwardsLabelVO = ticketAwardsLabelVOS.get(i);
|
|
|
+ if (BigDecimal.ZERO.equals(ticketAwardsLabelVO.getHitRate())) {
|
|
|
+ ticketAwardsLabelVO.setHitRate(BigDecimal.valueOf(0.1));
|
|
|
+ }
|
|
|
+ if (ticketAwardsLabelVO.getHitRate().compareTo(ticketAwardsLabelVOS.get(maxIndex).getHitRate()) > 0) {
|
|
|
+ maxIndex = i;
|
|
|
+ }
|
|
|
+ maxHitRate = maxHitRate.subtract(ticketAwardsLabelVO.getHitRate());
|
|
|
+ }
|
|
|
+ if (maxHitRate.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ TicketAwardsLabelVO ticketAwardsLabelVO = ticketAwardsLabelVOS.get(maxIndex);
|
|
|
+ ticketAwardsLabelVO.setHitRate(ticketAwardsLabelVO.getHitRate().subtract(maxHitRate));
|
|
|
+ } else {
|
|
|
+ TicketAwardsLabelVO ticketAwardsLabelVO = ticketAwardsLabelVOS.get(maxIndex);
|
|
|
+ ticketAwardsLabelVO.setHitRate(ticketAwardsLabelVO.getHitRate().add(maxHitRate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ticketBoxVO.setTicketAwardsLabelList(ticketAwardsLabelVOS);
|
|
|
+
|
|
|
+
|
|
|
+ // 轮播图的十个奖品
|
|
|
+ StringBuilder sb = new StringBuilder("FIELD(t1.awards_label,'");
|
|
|
+ int i = 0;
|
|
|
+ for (AwardsLabelEnum awardsLabelEnum : AwardsLabelEnum.values()) {
|
|
|
+ i++;
|
|
|
+ if (i == AwardsLabelEnum.values().length) {
|
|
|
+ sb.append(awardsLabelEnum.getValue()).append("'");
|
|
|
+ }else {
|
|
|
+ sb.append(awardsLabelEnum.getValue()).append("','");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sb.append(")");
|
|
|
+
|
|
|
+ List<TicketAwardsPrizeVO> ticketAwardsPrizeVOS = ticketAwardsPrizeService.listPrizeVO(new QueryWrapper<TicketAwardsPrize>()
|
|
|
+ .eq("t1.box_id", ticketBox.getBoxId())
|
|
|
+ .eq("t2.is_deleted", 0)
|
|
|
+ .orderByAsc(sb.toString())
|
|
|
+ .orderByAsc("t1.sort")
|
|
|
+ .orderByDesc("t2.sort_weight")
|
|
|
+ .orderByDesc("t2.value")
|
|
|
+ .last("limit 10"));
|
|
|
+ ticketBoxVO.setPrizeList(ticketAwardsPrizeVOS);
|
|
|
+ return AjaxResult.success(ticketBoxVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/ticket/prize/list/{boxId}")
|
|
|
+ @ApiOperation("查询盲票下奖品列表")
|
|
|
+ public TableDataInfo listPrize(@PathVariable("boxId") String boxId) {
|
|
|
+ startPage();
|
|
|
+ List<TicketAwardsPrizeVO> ticketAwardsPrizeVOS = ticketAwardsPrizeService.listPrizeVO(boxId);
|
|
|
+ return getDataTable(ticketAwardsPrizeVOS);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 扫码查看盲票幸运数字
|
|
|
*/
|