From 60f5898c9af1467f0192de57fee3323b2827a7de Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 24 Oct 2021 23:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20pay.html=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=EF=BC=8C=E5=AF=B9=E6=8E=A5=E5=BE=AE=E4=BF=A1=20JS=20S?= =?UTF-8?q?DK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/member/package-info.java | 9 ++-- .../controller/order/PayOrderController.java | 5 +-- .../modules/pay/controller/package-info.java | 1 - .../weixin/controller/mp/WxMpController.http | 2 + .../weixin/controller/mp/WxMpController.java | 37 ++++++++++++++++ .../modules/weixin/package-info.java | 7 ++++ .../src/main/resources/application.yaml | 6 +++ .../src/main/resources/static/pay.html | 42 +++++++++++++++++++ 8 files changed, 100 insertions(+), 9 deletions(-) delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.http create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/package-info.java diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/package-info.java index 4b11f981b..2334d44bf 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/package-info.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/package-info.java @@ -1,7 +1,8 @@ /** - * member 包下,我们放会员业务. - * 例如说:会员中心等等 + * weixin 包下,我们放微信相关业务. + * 例如说:微信公众号、等等 + * ps:微信支付,还是放在 pay 包下 * - * 缩写:mbr + * 缩写:wx */ -package cn.iocoder.yudao.userserver.modules.member; \ No newline at end of file +package cn.iocoder.yudao.userserver.modules.member; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java index 2b298e4c2..a38396e3d 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java @@ -12,10 +12,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/package-info.java deleted file mode 100644 index 739bfdd5a..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.pay.controller; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.http b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.http new file mode 100644 index 000000000..60f28c64d --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.http @@ -0,0 +1,2 @@ +### 请求 /login 接口 => 成功 +GET {{userServerUrl}}/wx/mp/get-jsapi-ticket diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.java new file mode 100644 index 000000000..decd907a0 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/controller/mp/WxMpController.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.userserver.modules.weixin.controller.mp; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Api(tags = "微信公众号") +@RestController +@RequestMapping("/wx/mp") +@Validated +@Slf4j +public class WxMpController { + + @Resource + private WxMpService mpService; + + @PostMapping("/create-jsapi-signature") + @ApiOperation(value = "创建微信 JS SDK 初始化所需的签名", + notes = "参考 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 文档") + public CommonResult createJsapiSignature(@RequestParam("url") String url) throws WxErrorException { + return success(mpService.createJsapiSignature(url)); + } + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/package-info.java new file mode 100644 index 000000000..69d3e2221 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/weixin/package-info.java @@ -0,0 +1,7 @@ +/** + * weixin 包下,我们放通用业务,支撑上层的核心业务。 + * 例如说:用户、部门、权限、数据字典等等 + * + * 缩写:wx + */ +package cn.iocoder.yudao.userserver.modules.weixin; diff --git a/yudao-user-server/src/main/resources/application.yaml b/yudao-user-server/src/main/resources/application.yaml index 4e1d1f279..209543380 100644 --- a/yudao-user-server/src/main/resources/application.yaml +++ b/yudao-user-server/src/main/resources/application.yaml @@ -20,6 +20,10 @@ spring: write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 fail-on-empty-beans: false # 允许序列化无属性的 Bean + # 静态资源 + mvc: + static-path-pattern: /static/** + # MyBatis Plus 的配置项 mybatis-plus: configuration: @@ -33,6 +37,8 @@ mybatis-plus: mapper-locations: classpath*:mapper/*.xml type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject, ${yudao.core-service.base-package}.modules.*.dal.dataobject + + --- #################### 芋道相关配置 #################### yudao: diff --git a/yudao-user-server/src/main/resources/static/pay.html b/yudao-user-server/src/main/resources/static/pay.html index e69de29bb..d7e36a719 100644 --- a/yudao-user-server/src/main/resources/static/pay.html +++ b/yudao-user-server/src/main/resources/static/pay.html @@ -0,0 +1,42 @@ + + + + + 支付测试页 + + + + +
点击如下按钮,发起支付的测试
+
+ +
+ + +