StadiumController.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package beilv.web.controller.stadium;
  2. import beilv.common.constant.PriceOptions;
  3. import beilv.common.core.controller.BaseController;
  4. import beilv.common.core.domain.AjaxResult;
  5. import beilv.common.core.domain.entity.SysDictData;
  6. import beilv.common.core.page.PageDomain;
  7. import beilv.common.core.page.TableDataInfo;
  8. import beilv.common.core.page.TableSupport;
  9. import beilv.common.utils.DictUtils;
  10. import beilv.common.utils.StringUtils;
  11. import beilv.common.utils.uuid.IdUtils;
  12. import beilv.competition.domain.Competition;
  13. import beilv.competition.service.ICompetitionService;
  14. import beilv.stadium.domain.Stadium;
  15. import beilv.stadium.domain.StadiumBO;
  16. import beilv.stadium.service.IStadiumService;
  17. import beilv.system.domain.SysNotice;
  18. import beilv.system.service.ISysConfigService;
  19. import beilv.vipCard.domain.VipCard;
  20. import beilv.vipCard.service.IVipCardService;
  21. import com.github.pagehelper.PageHelper;
  22. import com.github.pagehelper.PageInfo;
  23. import org.apache.commons.collections4.MapUtils;
  24. import org.apache.commons.lang3.ObjectUtils;
  25. import org.apache.shiro.authz.annotation.RequiresPermissions;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.*;
  28. import javax.annotation.Resource;
  29. import java.math.BigDecimal;
  30. import java.math.RoundingMode;
  31. import java.text.SimpleDateFormat;
  32. import java.util.Date;
  33. import java.util.HashMap;
  34. import java.util.List;
  35. import java.util.Map;
  36. @RestController
  37. @RequestMapping("/app-api/stadium")
  38. public class StadiumController extends BaseController {
  39. @Autowired
  40. private IStadiumService stadiumService;
  41. @Autowired
  42. private ICompetitionService competitionService;
  43. @Autowired
  44. private ISysConfigService configService;
  45. @Autowired
  46. private IVipCardService vipCardService;
  47. /**
  48. * 查询赛事发布列表
  49. */
  50. @GetMapping("/getCompetitionList")
  51. public AjaxResult getCompetitionList(Competition competition) {
  52. startPage();
  53. competition.setCompetitionState("competiton_state_2");
  54. List<Competition> list = competitionService.selectCompetitionList(competition);
  55. Map<String, String> competitionType = DictUtils.getDictCacheToMap("competition_type");
  56. Map<String, String> competitionState = DictUtils.getDictCacheToMap("competition_state");
  57. String vipLevel = null;
  58. VipCard vipCard = vipCardService.selectVipCardByUserId(competition.getUserId());
  59. if (ObjectUtils.isNotEmpty(vipCard)) {
  60. vipLevel = vipCard.getVipLevel();
  61. }
  62. //查询会员折扣
  63. BigDecimal coefficient = BigDecimal.valueOf(Double.parseDouble(StringUtils.isEmpty(vipLevel)? "1" : configService.selectConfigByKey(vipLevel)));
  64. list.forEach(competition1 -> {
  65. competition1.setCompetitionPrice(new PriceOptions(competition1.getCompetitionExpense(), coefficient));
  66. competition1.setViewingPrice(new PriceOptions(competition1.getViewingTicket(), coefficient));
  67. competition1.setCompetitionTypeLabel(MapUtils.getString(competitionType, competition1.getCompetitionType()));
  68. competition1.setCompetitionStateLabel(MapUtils.getString(competitionState, competition1.getCompetitionState()));
  69. });
  70. return AjaxResult.success(getDataTable(list).getRows());
  71. }
  72. // /**
  73. // * 添加订单
  74. // * 写入订单信息: 下单人id, 订单编号, 下单时间, 支付状态:待支付
  75. // * 调用者传递参数: 用户id, 联系人, 联系电话, 赛事id, 订单类型,
  76. // * return orderId 订单id
  77. // */
  78. // @PostMapping("/toBeStadium")
  79. // public AjaxResult addStadium(@RequestBody Stadium stadium) {
  80. // String orderId = stadiumService.toBeStadium(stadium);
  81. // if (StringUtils.isNotEmpty(orderId)) {
  82. // return AjaxResult.success("下单成功",orderId);
  83. // } else {
  84. // return AjaxResult.error("下单失败");
  85. // }
  86. // }
  87. //
  88. // /**
  89. // * 通过订单id取消订单
  90. // * 调用者传递参数: 订单id,
  91. // * 注: 取消订单时在下单后没有支付时, 可以执行的操作. 如果已经支付了, 则需要调用申请退款接口
  92. // */
  93. // @PostMapping("/cancellStadium")
  94. // public AjaxResult cancellStadium(@RequestBody Stadium stadium) {
  95. // return toAjax(stadiumService.cancellStadium(stadium));
  96. // }
  97. //
  98. // /**
  99. // * 查询订单
  100. // * 调用者传递参数: 用户id, 订单状态, 订单类型
  101. // */
  102. // @GetMapping("/getStadiumList")
  103. // public AjaxResult getStadiumList(StadiumBO stadiumBO) {
  104. // startPage();
  105. // Map<String, String> paymentStatus = DictUtils.getDictCacheToMap("payment_status");
  106. // Map<String, String> competitionType = DictUtils.getDictCacheToMap("competition_type");
  107. // List<Stadium> stadiumList = stadiumService.getStadiumList(stadiumBO);
  108. // stadiumList.forEach(stadium -> {
  109. // stadium.setPaymentStatusLabel(paymentStatus.get(stadium.getPaymentStatus()));
  110. // stadium.setCompetitionTypeLabel(competitionType.get(stadium.getCompetitionType()));
  111. // });
  112. // return AjaxResult.success(getDataTable(stadiumList));
  113. // }
  114. //
  115. // /**
  116. // * 支付回调
  117. // * 调用着传递: 订单编号, 支付状态
  118. // */
  119. // @PostMapping("/havePaidStadium")
  120. // public AjaxResult havePaidStadium(@RequestBody Stadium stadium) {
  121. // return toAjax(stadiumService.havePaidStadium(stadium));
  122. // }
  123. //
  124. // /**
  125. // * 退款回调
  126. // * 调用者传递参数: 订单id, 用户id
  127. // */
  128. // @PostMapping("/refundStadium")
  129. // public AjaxResult refundStadium(@RequestBody Stadium stadium) {
  130. // return toAjax(stadiumService.refundStadium(stadium));
  131. // }
  132. //
  133. // /**
  134. // * 支付验证
  135. // * 支付之前调用方法, 检测是否可以进行支付
  136. // *
  137. // * @return Boolean true: 可以支付; false: 不可以支付
  138. // */
  139. // @PostMapping("/paymentVerification")
  140. // public Boolean paymentVerification(@RequestBody Stadium stadium) {
  141. // return stadiumService.paymentVerification(stadium);
  142. // }
  143. }