CommonController.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.kym.miniapp.controller;
  2. import com.kym.common.R;
  3. import com.kym.service.ContactService;
  4. import com.kym.service.RechargeConfigService;
  5. import com.kym.service.RechargePromotionService;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestParam;
  9. import org.springframework.web.bind.annotation.RestController;
  10. /**
  11. * @author skyline
  12. * @description
  13. * @date 2023-07-26 23:51
  14. */
  15. @RestController
  16. @RequestMapping("/common/")
  17. public class CommonController {
  18. private final ContactService contactService;
  19. private final RechargeConfigService rechargeConfigService;
  20. private final RechargePromotionService rechargePromotionService;
  21. public CommonController(ContactService contactService, RechargeConfigService rechargeConfigService,
  22. RechargePromotionService rechargePromotionService) {
  23. this.contactService = contactService;
  24. this.rechargeConfigService = rechargeConfigService;
  25. this.rechargePromotionService = rechargePromotionService;
  26. }
  27. /**
  28. * 联系我们信息
  29. *
  30. * @return
  31. */
  32. @GetMapping("/contact")
  33. R<?> contact() {
  34. return R.success(contactService.list().stream().findFirst());
  35. }
  36. /**
  37. * 充值金额配置项(按站点查询,优先返回站点专属配置,若无则返回默认配置)
  38. *
  39. * @return
  40. */
  41. @GetMapping("/rechargeConfig")
  42. R<?> rechargeConfig(@RequestParam(required = false) String stationId) {
  43. return R.success(rechargeConfigService.listByStationId(stationId));
  44. }
  45. /**
  46. * 查询优惠活动详情(扫码进入时调用)
  47. */
  48. @GetMapping("/promotionInfo")
  49. R<?> promotionInfo(@RequestParam String token) {
  50. var promotion = rechargePromotionService.getByToken(token);
  51. if (promotion == null) {
  52. return R.failed(-1, "优惠活动不存在或已过期");
  53. }
  54. return R.success(promotion);
  55. }
  56. }