AppletOrderController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.zsElectric.boot.business.controller.applet;
  2. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  3. import com.zsElectric.boot.business.model.entity.RechargeLevel;
  4. import com.zsElectric.boot.business.model.form.applet.LevelOrderForm;
  5. import com.zsElectric.boot.business.model.form.applet.UserPayForm;
  6. import com.zsElectric.boot.business.service.RechargeLevelService;
  7. import com.zsElectric.boot.business.service.UserOrderInfoService;
  8. import com.zsElectric.boot.common.annotation.RepeatSubmit;
  9. import com.zsElectric.boot.common.constant.SystemConstants;
  10. import com.zsElectric.boot.core.web.Result;
  11. import io.swagger.v3.oas.annotations.Operation;
  12. import io.swagger.v3.oas.annotations.tags.Tag;
  13. import jakarta.servlet.http.HttpServletRequest;
  14. import jakarta.servlet.http.HttpServletResponse;
  15. import lombok.RequiredArgsConstructor;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.springframework.web.bind.annotation.*;
  18. import java.io.IOException;
  19. import java.util.List;
  20. import java.util.Map;
  21. @Tag(name = "订单相关接口")
  22. @Slf4j
  23. @RestController
  24. @RequestMapping("/applet/v1/order")
  25. @RequiredArgsConstructor
  26. public class AppletOrderController {
  27. private final RechargeLevelService rechargeLevelService;
  28. private final UserOrderInfoService userOrderInfoService;
  29. /**
  30. * 获取充电档位
  31. *
  32. * @return
  33. */
  34. @Operation(summary = "获取充电档位")
  35. @GetMapping("/getReChargeLevel")
  36. public Result<List<RechargeLevel>> getReChargeLevel() {
  37. List<RechargeLevel> list = rechargeLevelService.list(Wrappers.lambdaQuery(RechargeLevel.class).eq(RechargeLevel::getStatus, SystemConstants.STATUS_ONE));
  38. return Result.success(list);
  39. }
  40. /**
  41. * 创建订单
  42. *
  43. * @param levelOrderForm
  44. * @return
  45. */
  46. @Operation(summary = "创建订单")
  47. @PostMapping("/createOrder")
  48. public Result<UserPayForm> createOrder(@RequestBody LevelOrderForm levelOrderForm) {
  49. UserPayForm payForm = userOrderInfoService.createOrder(levelOrderForm);
  50. return Result.success(payForm);
  51. }
  52. /**
  53. * 订单-支付
  54. *
  55. * @param orderId
  56. * @return
  57. */
  58. @Operation(summary = "订单-支付")
  59. @PutMapping("/payOrder/{orderId}")
  60. public Result<UserPayForm> payOrder(@PathVariable("orderId") String orderId) {
  61. return Result.success(userOrderInfoService.payOrder(orderId));
  62. }
  63. /**
  64. * 支付回调
  65. *
  66. * @param request
  67. * @return
  68. */
  69. @Operation(summary = "支付回调")
  70. @RequestMapping("/wechatPayNotify")
  71. public Map<String, String> wechatPayNotify(HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
  72. log.info("--------------------------------------------支付回调");
  73. return userOrderInfoService.wechatPayNotify(request, response);
  74. }
  75. /**
  76. * 订单支付是否成功查询
  77. *
  78. * @param orderNo
  79. * @return
  80. */
  81. @Operation(summary = "订单支付是否成功查询")
  82. @GetMapping("/orderQuery/{orderNo}")
  83. public Result<String> orderQuery(@PathVariable("orderNo") String orderNo) throws IOException {
  84. return Result.success(userOrderInfoService.orderQuery(orderNo));
  85. }
  86. }