diff --git a/pom.xml b/pom.xml
index ca57eb3..a78147a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,30 +62,6 @@
fastjson
1.2.83
-
-
- com.github.wechatpay-apiv3
- wechatpay-apache-httpclient
- 0.4.8
-
-
-
- com.squareup.okhttp3
- okhttp
- 3.5.0
-
-
- com.github.wechatpay-apiv3
- wechatpay-java
- 0.2.14
-
-
-
- com.github.binarywang
- weixin-java-pay
- 4.1.0
-
-
commons-lang
commons-lang
diff --git a/src/main/java/com/bigdata/wxappserver/config/MyWxPayConfig.java b/src/main/java/com/bigdata/wxappserver/config/MyWxPayConfig.java
deleted file mode 100644
index 5009672..0000000
--- a/src/main/java/com/bigdata/wxappserver/config/MyWxPayConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.bigdata.wxappserver.config;
-
-import com.bigdata.wxappserver.properties.WeChatProperties;
-import com.github.binarywang.wxpay.config.WxPayConfig;
-import com.github.binarywang.wxpay.service.WxPayService;
-import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @Author: Cool
- * @Date: 2024/09/03/22:19
- * @Description:
- */
-
-@Configuration
-@ConditionalOnClass(WxPayService.class)
-public class MyWxPayConfig {
-
- @Autowired
- private WeChatProperties properties;
-
- @Bean
- @ConditionalOnMissingBean
- public WxPayService wxService() {
- WxPayConfig payConfig = new WxPayConfig();
- payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
- payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
- payConfig.setMchKey(StringUtils.trimToNull(this.properties.getSecret()));
- payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiV3Key()));
- payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyFilePath()));
- payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getWeChatPayCertFilePath()));
- // payConfig.setPrivateKeyPath();
- // 可以指定是否使用沙箱环境
- payConfig.setUseSandboxEnv(false);
-
- WxPayService wxPayService = new WxPayServiceImpl();
- wxPayService.setConfig(payConfig);
- return wxPayService;
- }
-}
diff --git a/src/main/java/com/bigdata/wxappserver/controller/OrderController.java b/src/main/java/com/bigdata/wxappserver/controller/OrderController.java
index d9b596c..f8925fe 100644
--- a/src/main/java/com/bigdata/wxappserver/controller/OrderController.java
+++ b/src/main/java/com/bigdata/wxappserver/controller/OrderController.java
@@ -22,7 +22,7 @@ public class OrderController {
OrderService orderService;
@RequestMapping("addOrUpdate")
- public JSONObject addOrUpdate(@RequestBody JSONObject jsonObject){
+ public Result addOrUpdate(@RequestBody JSONObject jsonObject){
return orderService.addOrUpdate(jsonObject);
}
@@ -41,15 +41,4 @@ public class OrderController {
return orderService.delete(id);
}
- /**
- * 订单支付
- *
- * @param
- * @return
- */
- @PutMapping("/payment")
- public Result payment(@RequestBody JSONObject jsonObject) throws Exception {
- return orderService.payment(jsonObject);
- }
-
}
diff --git a/src/main/java/com/bigdata/wxappserver/controller/PayNotifyController.java b/src/main/java/com/bigdata/wxappserver/controller/PayNotifyController.java
deleted file mode 100644
index c26fa3c..0000000
--- a/src/main/java/com/bigdata/wxappserver/controller/PayNotifyController.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.bigdata.wxappserver.controller;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.bigdata.wxappserver.properties.WeChatProperties;
-import com.bigdata.wxappserver.service.OrderService;
-import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.http.entity.ContentType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-
-/**
- * 支付回调相关接口
- */
-@RestController
-@RequestMapping("/notify")
-@Slf4j
-public class PayNotifyController {
- @Autowired
- private OrderService orderService;
- @Autowired
- private WeChatProperties weChatProperties;
-
- /**
- * 支付成功回调
- *
- * @param request
- */
- @RequestMapping("/paySuccess")
- public void paySuccessNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
- //读取数据
- String body = readData(request);
- log.info("支付成功回调:{}", body);
-
- //数据解密
- String plainText = decryptData(body);
- log.info("解密后的文本:{}", plainText);
-
- JSONObject jsonObject = JSON.parseObject(plainText);
- String outTradeNo = jsonObject.getString("out_trade_no");//商户平台订单号
- String transactionId = jsonObject.getString("transaction_id");//微信支付交易号
-
- log.info("商户平台订单号:{}", outTradeNo);
- log.info("微信支付交易号:{}", transactionId);
-
- //业务处理,修改订单状态、来单提醒
- orderService.paySuccess(outTradeNo);
-
- //给微信响应
- responseToWeixin(response);
- }
-
- /**
- * 读取数据
- *
- * @param request
- * @return
- * @throws Exception
- */
- private String readData(HttpServletRequest request) throws Exception {
- BufferedReader reader = request.getReader();
- StringBuilder result = new StringBuilder();
- String line = null;
- while ((line = reader.readLine()) != null) {
- if (result.length() > 0) {
- result.append("\n");
- }
- result.append(line);
- }
- return result.toString();
- }
-
- /**
- * 数据解密
- *
- * @param body
- * @return
- * @throws Exception
- */
- private String decryptData(String body) throws Exception {
- JSONObject resultObject = JSON.parseObject(body);
- JSONObject resource = resultObject.getJSONObject("resource");
- String ciphertext = resource.getString("ciphertext");
- String nonce = resource.getString("nonce");
- String associatedData = resource.getString("associated_data");
-
- AesUtil aesUtil = new AesUtil(weChatProperties.getApiV3Key().getBytes(StandardCharsets.UTF_8));
- //密文解密
- String plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8),
- nonce.getBytes(StandardCharsets.UTF_8),
- ciphertext);
-
- return plainText;
- }
-
- /**
- * 给微信响应
- *
- * @param response
- */
- private void responseToWeixin(HttpServletResponse response) throws Exception {
- response.setStatus(200);
- HashMap