WxApiController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package thyyxxk.wxservice_server.controller;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.validation.annotation.Validated;
  5. import org.springframework.web.bind.annotation.*;
  6. import thyyxxk.wxservice_server.constant.QuerySource;
  7. import thyyxxk.wxservice_server.entity.ResultVo;
  8. import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
  9. import thyyxxk.wxservice_server.entity.appointment.WeChatPayParam;
  10. import thyyxxk.wxservice_server.entity.wxapi.*;
  11. import thyyxxk.wxservice_server.service.AutoRefundService;
  12. import thyyxxk.wxservice_server.service.PushWxMessageService;
  13. import thyyxxk.wxservice_server.service.WxApiService;
  14. import thyyxxk.wxservice_server.utils.PropertiesUtil;
  15. import thyyxxk.wxservice_server.utils.ResultVoUtil;
  16. import javax.servlet.http.HttpServletRequest;
  17. import java.util.Map;
  18. /**
  19. * @author dj
  20. */
  21. @Slf4j
  22. @RestController
  23. @RequestMapping("/wxApi")
  24. public class WxApiController {
  25. private final WxApiService service;
  26. private final AutoRefundService refundService;
  27. private final PushWxMessageService pushWxMessageService;
  28. @Autowired
  29. public WxApiController(WxApiService payService, AutoRefundService refundService, PushWxMessageService pushWxMessageService) {
  30. this.service = payService;
  31. this.refundService = refundService;
  32. this.pushWxMessageService = pushWxMessageService;
  33. }
  34. @GetMapping("/synchronizeAccessToken")
  35. public ResultVo<String> synchronizeAccessToken(@RequestParam("token") String token) {
  36. PropertiesUtil.writeAccessToken("access_token", token);
  37. return ResultVoUtil.success("同步成功。");
  38. }
  39. @GetMapping("/getJsApiSHA1")
  40. public ResultVo<JsApiSHA1> getJsApiSha1Sign(@RequestParam("url") String url) {
  41. JsApiSHA1 data = new JsApiSHA1();
  42. data.setUrl(url);
  43. return service.getJsapiSHA1Sign(data);
  44. }
  45. @PostMapping("/createPayOrder")
  46. public ResultVo<WxPayOrder> createPayOrder(HttpServletRequest request,
  47. @RequestBody @Validated WeChatPayParam param) {
  48. param.setClientIp(request.getRemoteAddr());
  49. return service.createPayOrder(param);
  50. }
  51. @GetMapping("/queryOrderState")
  52. public ResultVo<Object> queryOrderState(@RequestParam("tradeNo") String tradeNo) throws Exception {
  53. return service.queryOrderState(tradeNo, QuerySource.INTERFACE);
  54. }
  55. @PostMapping("/genMzPayQrcode")
  56. public ResultVo<String> genMzPayQrcode(@RequestBody @Validated GenMzPayQrcodeParam param) throws Exception {
  57. return service.generateMzGuideBillPayQrcode(param);
  58. }
  59. @PostMapping("/pushMessage")
  60. public void pushMessage(@RequestBody @Validated PushMessageParam param) {
  61. pushWxMessageService.pushMessage(param);
  62. }
  63. @PostMapping("/getWxPayQrcode")
  64. public ResultVo<Map<String, String>> getWxPayQrcode(@RequestBody WxPyQrcdPrm prm) throws Exception {
  65. return service.getWxPayQrcode(prm);
  66. }
  67. @PostMapping("/closeWxOrder")
  68. public ResultVo<String> closeWxOrder(@RequestBody WxPayOrder order) throws Exception {
  69. return service.closeWxOrder(order);
  70. }
  71. @PostMapping("/refund")
  72. public ResultVo<String> refund(@RequestBody @Validated RfndPrm prm) {
  73. return refundService.refund(prm);
  74. }
  75. @GetMapping("/getDoctorInfo")
  76. public ResultVo<DoctorInfo> getDoctorInfo(@RequestParam("doctorCode") String doctorCode) {
  77. return service.getDoctorInfo(doctorCode);
  78. }
  79. }