123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package thyyxxk.wxservice_server.controller;
- import com.alibaba.fastjson.JSONObject;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import thyyxxk.wxservice_server.entity.ResultVo;
- import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
- import thyyxxk.wxservice_server.entity.appointment.WeChatPayParam;
- import thyyxxk.wxservice_server.entity.wxapi.*;
- import thyyxxk.wxservice_server.service.WxRefundService;
- import thyyxxk.wxservice_server.service.PushWxMessageService;
- import thyyxxk.wxservice_server.service.WxApiService;
- import thyyxxk.wxservice_server.utils.PropertiesUtil;
- import thyyxxk.wxservice_server.utils.ResultVoUtil;
- import javax.servlet.http.HttpServletRequest;
- import java.io.IOException;
- import java.util.Map;
- /**
- * @author dj
- */
- @Slf4j
- @RestController
- @RequestMapping("/wxApi")
- public class WxApiController {
- private final WxApiService service;
- private final WxRefundService refundService;
- private final PushWxMessageService pushWxMessageService;
- @Autowired
- public WxApiController(WxApiService payService, WxRefundService refundService, PushWxMessageService pushWxMessageService) {
- this.service = payService;
- this.refundService = refundService;
- this.pushWxMessageService = pushWxMessageService;
- }
- @GetMapping("/synchronizeAccessToken")
- public ResultVo<String> synchronizeAccessToken(@RequestParam("token") String token) {
- PropertiesUtil.writeAccessToken("access_token", token);
- return ResultVoUtil.success("同步成功。");
- }
- @GetMapping("/getJsApiSHA1")
- public ResultVo<JsApiSHA1> getJsApiSha1Sign(@RequestParam("url") String url) throws Exception {
- JsApiSHA1 data = new JsApiSHA1();
- data.setUrl(url);
- return service.getJsapiSHA1Sign(data);
- }
- @PostMapping("/createPayOrder")
- public ResultVo<WxPayOrder> createPayOrder(HttpServletRequest request,
- @RequestBody @Validated WeChatPayParam param) throws Exception {
- param.setClientIp(request.getRemoteAddr());
- return service.createPayOrder(param);
- }
- @GetMapping("/queryOrderState")
- public ResultVo<Object> queryOrderState(@RequestParam("tradeNo") String tradeNo) {
- return service.queryOrderState(tradeNo);
- }
- @GetMapping("/queryOrderStateOnly")
- public ResultVo<Object> queryOrderStateOnly(@RequestParam("tradeNo") String tradeNo) throws IOException {
- return service.queryOrderStateOnly(tradeNo);
- }
- @PostMapping("/genMzPayQrcode")
- public ResultVo<String> genMzPayQrcode(@RequestBody @Validated GenMzPayQrcodeParam param) throws Exception {
- return service.generateMzGuideBillPayQrcode(param);
- }
- @PostMapping("/pushMessage")
- public void pushMessage(@RequestBody @Validated PushMessageParam param) {
- pushWxMessageService.pushMessage2(param);
- }
- @PostMapping("/pushMessage2")
- public String pushMessage2(@RequestBody JSONObject param) {
- boolean result = pushWxMessageService.pushMessage2(param);
- return result ? "SUCCESS" : "FAIL";
- }
- @PostMapping("/getWxPayQrcode")
- public ResultVo<Map<String, String>> getWxPayQrcode(@RequestBody WxPyQrcdPrm prm) throws Exception {
- return service.getWxPayQrcode(prm);
- }
- @PostMapping("/closeWxOrder")
- public ResultVo<String> closeWxOrder(@RequestBody WxPayOrder order) throws Exception {
- return service.closeWxOrder(order);
- }
- @PostMapping("/refund")
- public ResultVo<String> refund(@RequestBody @Validated RfndPrm prm) {
- return refundService.refund(prm);
- }
- @GetMapping("/getDoctorInfo")
- public ResultVo<DoctorInfo> getDoctorInfo(@RequestParam("doctorCode") String doctorCode) {
- return service.getDoctorInfo(doctorCode);
- }
- }
|