diff --git a/pay/pom.xml b/pay/pom.xml
new file mode 100644
index 0000000..0558d6f
--- /dev/null
+++ b/pay/pom.xml
@@ -0,0 +1,59 @@
+
+
+
+ ruoyi
+ com.ruoyi
+ 3.8.6
+
+ 4.0.0
+ pay
+ 1.0.0-SNAPSHOT
+
+
+ 8
+ 8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+ 2.7.10
+ true
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.22
+
+
+ com.alibaba
+ fastjson
+ 1.2.72
+
+
+ cn.hutool
+ hutool-all
+ 5.7.12
+
+
+ com.github.wechatpay-apiv3
+ wechatpay-apache-httpclient
+ 0.4.7
+
+
+ com.alipay.sdk
+ alipay-sdk-java
+ 4.34.8.ALL
+
+
+
+
+
\ No newline at end of file
diff --git a/pay/src/main/java/com/ruoyi/CallBackService.java b/pay/src/main/java/com/ruoyi/CallBackService.java
new file mode 100644
index 0000000..29fb770
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/CallBackService.java
@@ -0,0 +1,32 @@
+package com.ruoyi;
+
+/**
+ * 业务回调处理接口
+ */
+public interface CallBackService {
+
+ /**
+ * 成功支付--处理业务逻辑
+ * @param orderSn 订单号
+ */
+ void successPay(String orderSn);
+
+ /**
+ * 失败支付-处理业务逻辑
+ * @param orderSn 订单号
+ */
+ void failPay(String orderSn);
+
+ /**
+ * 退款成功-处理业务逻辑
+ * @param orderSn 订单号
+ */
+ void successRefund(String orderSn);
+
+ /**
+ * 退款失败-处理业务逻辑
+ * @param orderSn 订单号
+ */
+ void failRefund(String orderSn);
+
+}
diff --git a/pay/src/main/java/com/ruoyi/ElegentPay.java b/pay/src/main/java/com/ruoyi/ElegentPay.java
new file mode 100644
index 0000000..e79ae0e
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/ElegentPay.java
@@ -0,0 +1,66 @@
+package com.ruoyi;
+
+
+import com.ruoyi.dto.*;
+import com.ruoyi.exceptions.TradeException;
+
+public interface ElegentPay {
+
+
+ /**
+ * 统一下单接口
+ * @param payRequest 支付请求
+ * @param tradeType 交易类型
+ * @param platform 平台
+ * @return 支付响应
+ * @throws TradeException
+ */
+ PayResponse requestPay(PayRequest payRequest, String tradeType, String platform) throws TradeException;
+
+
+ /**
+ * 关闭订单
+ * @param orderSn 订单号
+ * @param platform 平台
+ * @return 是否成功关闭订单
+ * @throws TradeException
+ */
+ Boolean closePay(String orderSn, String platform) throws TradeException;
+
+ /**
+ * 退款
+ * @param refundRequest 退款请求封装对象
+ * @param platform 平台
+ * @return 是否成功退款
+ * @throws TradeException
+ */
+ Boolean refund(RefundRequest refundRequest, String platform) throws TradeException;
+
+ /**
+ * 根据订单号查询订单
+ * @param orderSn 订单号
+ * @param platform 平台
+ * @return 查询响应对象
+ * @throws TradeException
+ */
+ QueryResponse queryTradingOrderNo(String orderSn , String platform) throws TradeException;
+
+
+ /**
+ * 查询单笔退款API
+ * @param orderSn 订单号
+ * @param platform 平台
+ * @return 查询退款响应对象
+ * @throws TradeException
+ */
+ QueryRefundResponse queryRefundTrading(String orderSn , String platform) throws TradeException;
+
+
+ /**
+ * 获得openID
+ * @param code
+ * @return
+ */
+ public String getOpenid(String code, String platform);
+
+}
diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java b/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java
new file mode 100644
index 0000000..1648dde
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java
@@ -0,0 +1,40 @@
+package com.ruoyi.ali;
+
+import com.ruoyi.key.KeyManager;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 支付宝权限对接类
+ */
+@Component
+@ConfigurationProperties("elegent.pay.alipay")
+@Data
+public class AlipayConfig {
+ /**
+ * 应用识别码
+ */
+ private String appId;
+
+ /**
+ * 密钥加密方式 RSA2
+ */
+ @Value("${elegent.pay.alipay.charset:RSA2}")
+ private String signType;
+
+ @Autowired
+ private KeyManager keyManager;
+
+ public String getPrivateKey(){
+ return keyManager.getKey("alipay_private.key");
+ }
+
+ public String getPublicKey(){
+ return keyManager.getKey("alipay_public.key");
+ }
+
+
+}
\ No newline at end of file
diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java b/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java
new file mode 100644
index 0000000..db7417d
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java
@@ -0,0 +1,30 @@
+package com.ruoyi.ali;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ZFBConstant
+ * @description 支付宝相关的常量
+*/
+public class AlipayConstant {
+
+ public static final String SUCCESS = "SUCCESS";
+
+ public static final String FAIL = "FAIL";
+
+ /**
+ * 交易状态(用于转换)
+ */
+ public static final Map TRADE_STATE = new HashMap(){
+ {
+ put("TRADE_SUCCESS", "SUCCESS");
+ put("WAIT_BUYER_PAY", "NOTPAY");
+ put("TRADE_CLOSED", "CLOSED");
+ put("TRADE_FINISHED", "FINISHED");
+ }
+ };
+
+ public static final String domain="https://openapi.alipay.com/gateway.do";
+
+}
diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java b/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java
new file mode 100644
index 0000000..aefd560
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java
@@ -0,0 +1,461 @@
+package com.ruoyi.ali;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.request.*;
+import com.alipay.api.response.*;
+import com.ruoyi.CallBackService;
+import com.ruoyi.annotation.TradePlatform;
+import com.ruoyi.config.CallbackConfig;
+import com.ruoyi.constant.PayConstant;
+import com.ruoyi.constant.Platform;
+import com.ruoyi.constant.TradeType;
+import com.ruoyi.core.ElegentTrade;
+import com.ruoyi.dto.*;
+import com.ruoyi.exceptions.TradeException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * 支付宝支付的策略类
+ * @author wgl
+ */
+@Service
+@TradePlatform(Platform.ALI)
+@Slf4j
+public class AlipayElegentTrade implements ElegentTrade {
+
+ @Autowired
+ private AlipayConfig alipayConfig;
+
+ @Autowired
+ private CallbackConfig callbackConfig;
+
+ @Autowired
+ private CallBackService callBackService;
+
+
+ /**
+ * 获取回调地址
+ * @return
+ */
+ private String getPayNotifyUrl(){
+ return callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH+ PayConstant.NOTIFY +"/"+ Platform.ALI;
+ }
+
+ /**
+ * 获取退款回调
+ * @return
+ */
+ private String getRefundNotifyUrl(){
+ return callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH+ PayConstant.REFUND_NOTIFY +"/"+ Platform.ALI;
+ }
+
+
+
+ /**
+ * 创建支付订单
+ * @param payRequest
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public PayResponse requestPay(PayRequest payRequest, String tradeType) throws TradeException {
+ if(TradeType.NATIVE.equals( tradeType )){
+ return createNativeOrder(payRequest);
+ }
+ if(TradeType.JSAPI.equals( tradeType )){
+ return createJsApiOrder(payRequest);
+ }
+ if(TradeType.H5.equals( tradeType )){
+ return createH5Order(payRequest);
+ }
+ if(TradeType.APP.equals( tradeType )){
+ return createAPPOrder(payRequest);
+ }
+ return createNativeOrder(payRequest);
+ }
+
+
+ /**
+ * 本地支付(扫码)
+ * https://opendocs.alipay.com/open/194/106078?ref=api#预下单
+ * @param payRequest
+ * @return
+ * @throws TradeException
+ */
+ private PayResponse createNativeOrder(PayRequest payRequest) throws TradeException {
+ try {
+ AlipayClient alipayClient = getAliHttpClient();
+ AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
+
+ request.setNotifyUrl(getPayNotifyUrl());
+
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_trade_no", payRequest.getOrderSn());
+ //转换
+ //String totalFee= BigDecimal.valueOf(payRequest.getTotalFee()).divide(new BigDecimal(100) ).toString();
+ bizContent.put("total_amount", fenToYuan(payRequest.getTotalFee()));
+ bizContent.put("subject", payRequest.getBody());
+ request.setBizContent(bizContent.toString());
+ AlipayTradePrecreateResponse response = alipayClient.execute(request);
+
+ if (response.isSuccess()) {
+ PayResponse payResponse =new PayResponse();
+ payResponse.setSuccess(true);
+ payResponse.setCode_url(response.getQrCode()); //本地支付二维码
+ payResponse.setOrder_sn(payRequest.getOrderSn());
+ return payResponse;
+ } else {
+ log.error("调用失败");
+ return null;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn());
+ }
+ }
+
+
+ /**
+ * 小程序
+ * https://opendocs.alipay.com/mini/03l5wn
+ * @param payRequest
+ * @return
+ * @throws TradeException
+ */
+ private PayResponse createJsApiOrder(PayRequest payRequest) throws TradeException {
+ AlipayClient alipayClient = getAliHttpClient();
+ try {
+ AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
+ request.setNotifyUrl(getPayNotifyUrl());
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_trade_no", payRequest.getOrderSn());
+ bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() ));
+ bizContent.put("subject", payRequest.getBody());
+ bizContent.put("buyer_id", payRequest.getOpenid());
+ bizContent.put("timeout_express", "10m");
+ request.setBizContent(bizContent.toString());
+ AlipayTradeCreateResponse response = alipayClient.sdkExecute(request);
+ if (response.isSuccess()) {
+ PayResponse payResponse =new PayResponse();
+ payResponse.setSuccess(true);
+ payResponse.setPrepay_id(response.getTradeNo());
+ payResponse.setOrder_sn(response.getOutTradeNo());
+ return payResponse;
+ } else {
+ log.error("调用失败");
+ return null;
+ }
+ }catch (Exception e){
+ throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn());
+ }
+ }
+
+
+ /**
+ * H5
+ * https://opendocs.alipay.com/mini/03l5wn
+ * @param payRequest
+ * @return
+ * @throws TradeException
+ */
+ private PayResponse createH5Order(PayRequest payRequest) throws TradeException {
+ AlipayClient alipayClient = getAliHttpClient();
+ try {
+ AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
+ request.setNotifyUrl(getPayNotifyUrl());
+ request.setReturnUrl("");
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_trade_no", payRequest.getOrderSn());
+ bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() ));
+ bizContent.put("subject", payRequest.getBody());
+ bizContent.put("product_code", "QUICK_WAP_WAY");
+
+ request.setBizContent(bizContent.toString());
+ AlipayTradeWapPayResponse response = alipayClient.pageExecute(request);
+ if (response.isSuccess()) {
+ PayResponse payResponse =new PayResponse();
+ payResponse.setSuccess(true);
+ payResponse.setPrepay_id(response.getTradeNo());
+ payResponse.setOrder_sn(response.getOutTradeNo());
+ return payResponse;
+ } else {
+ log.error("调用失败");
+ return null;
+ }
+ }catch (Exception e){
+ throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn());
+ }
+ }
+
+
+ /**
+ * APP
+ * https://opendocs.alipay.com/open/02e7gq?ref=api&scene=20
+ * @param payRequest
+ * @return
+ * @throws TradeException
+ */
+ private PayResponse createAPPOrder(PayRequest payRequest) throws TradeException {
+ AlipayClient alipayClient = getAliHttpClient();
+ try {
+ AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+ request.setNotifyUrl(getPayNotifyUrl());
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_trade_no", payRequest.getOrderSn());
+ bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() ));
+ bizContent.put("subject", payRequest.getBody());
+ bizContent.put("product_code", "QUICK_MSECURITY_PAY");
+
+ request.setBizContent(bizContent.toString());
+ AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+ if (response.isSuccess()) {
+ PayResponse payResponse =new PayResponse();
+ payResponse.setSuccess(true);
+ payResponse.setPrepay_id(response.getTradeNo());
+ payResponse.setOrder_sn(response.getOutTradeNo());
+ return payResponse;
+ } else {
+ log.error("调用失败");
+ return null;
+ }
+ }catch (Exception e){
+ throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn());
+ }
+ }
+
+
+
+ /**
+ * 关闭订单
+ * @param orderSn
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public Boolean closePay(String orderSn) throws TradeException {
+ try {
+ AlipayClient alipayClient = getAliHttpClient();
+ AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("trade_no", orderSn);
+ request.setBizContent(bizContent.toString());
+ AlipayTradeCloseResponse response = alipayClient.execute(request);
+ if (response.isSuccess()) {
+ log.info("调用成功");
+ return true;
+ } else {
+ log.error("调用失败");
+ return false;
+ }
+ }catch (Exception e){
+ throw new TradeException("订单关闭失败,订单号:"+orderSn);
+ }
+ }
+
+ /**
+ * 退款接口
+ * alipay.trade.refund(统一收单交易退款接口)
+ * https://opendocs.alipay.com/open/02ekfk
+ * @param refundRequest
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public Boolean refund(RefundRequest refundRequest) throws TradeException {
+ try {
+ AlipayClient alipayClient = getAliHttpClient();
+ AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
+ request.setNotifyUrl(getRefundNotifyUrl()); //退款回调
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("refund_amount", fenToYuan(refundRequest.getRefundAmount() ));
+ bizContent.put("out_trade_no", refundRequest.getOrderSn());
+ //退款请求号,做幂等性校验
+ if(refundRequest.getRequestNo()!=null){
+ bizContent.put("out_request_no", refundRequest.getRequestNo());
+ }else{
+ bizContent.put("out_request_no", refundRequest.getOrderSn());
+ }
+ request.setBizContent(bizContent.toString());
+ AlipayTradeRefundResponse response = alipayClient.execute(request);
+ if (response.isSuccess()) {
+ if("Y".equals(response.getFundChange())) {
+ log.info("退款成功{}",refundRequest.getOrderSn());
+ callBackService.successRefund(refundRequest.getOrderSn());
+ return true;
+ }else{
+ //退款失败
+ log.error("退款失败{}",refundRequest.getOrderSn());
+ callBackService.failRefund(refundRequest.getOrderSn());
+ return false;
+ }
+ } else {
+ log.error("退款调用失败{}",refundRequest.getOrderSn());
+ return false;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new TradeException("订单退款失败,订单号:"+ refundRequest.getOrderSn());
+ }
+ }
+
+ /**
+ * 查询单笔交易订单
+ * 参考官网: https://opendocs.alipay.com/open/02e7gm?ref=api#请求示例
+ *
+ * @param orderSn
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public QueryResponse queryTradingOrderNo(String orderSn) throws TradeException {
+ AlipayClient alipayClient = getAliHttpClient();
+ try {
+ AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_trade_no", orderSn);
+ request.setBizContent(bizContent.toString());
+ AlipayTradeQueryResponse response = alipayClient.execute(request);
+ QueryResponse queryResponse=new QueryResponse();
+ queryResponse.setOrder_sn(orderSn );
+ if (response.isSuccess()) {
+ queryResponse.setTransaction_id( response.getTradeNo() );
+ queryResponse.setTrade_state(AlipayConstant.TRADE_STATE.get( response.getTradeStatus()) );//交易状态
+
+ //int total = BigDecimal.valueOf(Double.valueOf(response.getTotalAmount())).multiply(new BigDecimal(100)).intValue();
+ queryResponse.setTotal( yuanToFen(response.getTotalAmount()) ); //总金额
+
+ //int buyer_pay_amount = BigDecimal.valueOf(Double.valueOf(response.getBuyerPayAmount())).multiply(new BigDecimal(100)).intValue();
+ //queryResponse.setPayer_total( yuanToFen(response.getBuyerPayAmount()) );//支付金额
+
+ queryResponse.setOpenid( response.getBuyerUserId());
+ Map map = JSON.parseObject(response.getBody(), Map.class ) ;
+ queryResponse.setExpand(map);//全部数据
+ return queryResponse;
+ } else {
+ queryResponse.setTrade_state("NOTPAY");
+ return queryResponse;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ //throw new TradeException("订单查询失败,订单号:"+orderSn);
+ return null;
+ }
+ }
+
+ /**
+ * 查询退款订单
+ * @param orderSn
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public QueryRefundResponse queryRefundTrading(String orderSn) throws TradeException {
+ try {
+ AlipayClient alipayClient = getAliHttpClient();
+ AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();
+ JSONObject bizContent = new JSONObject();
+ bizContent.put("out_request_no", orderSn);
+ request.setBizContent(bizContent.toString());
+ AlipayTradeFastpayRefundQueryResponse response = alipayClient.execute(request);
+ if (response.isSuccess()) {
+ log.info("调用成功");
+ Map map = JSON.parseObject(response.getBody(), Map.class );
+
+ QueryRefundResponse queryRefundResponse=new QueryRefundResponse();
+
+ queryRefundResponse.setOrder_sn( (String) map.get("out_trade_no") );
+ queryRefundResponse.setTransaction_id( (String) map.get("trade_no") );
+ queryRefundResponse.setTotal( (Integer) map.get("total_amount") ); //总金额
+ //queryRefundResponse.setPayer_total( (Integer) map.get("total_amount") );//支付金额
+ queryRefundResponse.setRefund((Integer) map.get("refund_amount") ); //退款金额
+ queryRefundResponse.setRefund_id((String) map.get("trade_no") ); //退款单号
+ queryRefundResponse.setOut_refund_no( (String) map.get("out_request_no") );//退款订单号
+ //queryRefundResponse.setChannel( (String) map.get("channel") ); //通道
+ //queryRefundResponse.setUser_received_account( (String) map.get("user_received_account") ); //账号
+ queryRefundResponse.setStatus( (String) map.get("refund_status") ); //状态
+ queryRefundResponse.setSuccess_time( (String) map.get("gmt_refund_pay") );
+ //queryRefundResponse.setCreate_time( (String) map.get("gmt_refund_pay") );
+
+ queryRefundResponse.setExpand(map);
+ return queryRefundResponse;
+
+ } else {
+ log.error("调用失败");
+ return null;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ //throw new TradeException("退款订单查询失败,订单号:"+ orderSn);
+ return null;
+ }
+ }
+
+ @Override
+ public String getOpenid(String code) {
+ AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
+ alipayConfig.getAppId(), alipayConfig.getPrivateKey(), "json", "utf-8", alipayConfig.getPublicKey(), alipayConfig.getSignType());
+ AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
+ request.setCode(code);
+ request.setGrantType("authorization_code");
+ try {
+ AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(request);
+ return oauthTokenResponse.getUserId();
+ } catch (AlipayApiException e) {
+ //处理异常
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+
+ /**
+ * 获取支付宝连接
+ * 参考官网:https://opendocs.alipay.com/open/01csp3?ref=api#公钥模式加签
+ * 公钥模式加签
+ * @return
+ */
+ private AlipayClient getAliHttpClient(){
+ try {
+ com.alipay.api.AlipayConfig alipayConfig = new com.alipay.api.AlipayConfig();
+ alipayConfig.setServerUrl(AlipayConstant.domain);
+ alipayConfig.setAppId(this.alipayConfig.getAppId());
+ alipayConfig.setPrivateKey(this.alipayConfig.getPrivateKey());
+ alipayConfig.setFormat("json");
+ alipayConfig.setCharset("utf-8");
+ alipayConfig.setAlipayPublicKey(this.alipayConfig.getPublicKey());
+ alipayConfig.setSignType(this.alipayConfig.getSignType());
+ //构造client
+ AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
+ return alipayClient;
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new TradeException("支付宝支付--初始化,校验系统参数失败");
+ }
+
+ }
+
+ /**
+ * 分转换为元
+ * @param fen
+ * @return
+ */
+ private String fenToYuan(int fen){
+ //转换为元
+ return BigDecimal.valueOf(fen).divide(new BigDecimal(100) ).toString();
+ }
+
+ private int yuanToFen(String yuan){
+ return BigDecimal.valueOf(Double.valueOf(yuan)).multiply(new BigDecimal(100)).intValue();
+ }
+
+
+}
\ No newline at end of file
diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java b/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java
new file mode 100644
index 0000000..0052a4f
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java
@@ -0,0 +1,124 @@
+package com.ruoyi.ali;
+
+
+import com.alipay.api.internal.util.AlipaySignature;
+import com.ruoyi.annotation.TradePlatform;
+import com.ruoyi.constant.Platform;
+import com.ruoyi.core.ElegentValid;
+import com.ruoyi.dto.ValidResponse;
+import com.ruoyi.exceptions.TradeException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+@Service
+@TradePlatform(Platform.ALI)
+@Slf4j
+public class AlipayElegentValid implements ElegentValid {
+
+
+ @Autowired
+ private AlipayConfig alipayConfig;
+
+
+ /**
+ * 订单回调结果通知验签
+ * 参考代码: https://opendocs.alipay.com/open/194/103296?ref=api 异步返回结果的验签
+ * @param httpEntity
+ * @param httpRequest
+ * @return
+ */
+ @Override
+ public ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest httpRequest) throws TradeException {
+ ValidResponse validResponse=new ValidResponse();
+ try {
+ Map params = getParams(httpRequest);
+ //获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中
+ //String body = httpEntity.getBody();
+ //调用SDK验证签名
+ //公钥验签示例代码
+ boolean signVerified = AlipaySignature.rsaCheckV1(params, alipayConfig.getPublicKey(), "utf-8", alipayConfig.getSignType());
+ if (signVerified) {
+ validResponse.setValid(true);
+ validResponse.setOrderSn((String) params.get("out_trade_no"));
+ return validResponse;
+ } else {
+ validResponse.setValid(false);
+ validResponse.setOrderSn( (String) params.get("out_trade_no") );
+ return validResponse;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new TradeException("验签异常");
+ }
+ }
+
+ /**
+ * 退款结果通知验签
+ * 参考官网 https://opendocs.alipay.com/support/01ravh
+ * @param httpEntity
+ * @param httpRequest
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest httpRequest) throws TradeException {
+ ValidResponse validResponse=new ValidResponse();
+
+ try {
+ //获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中
+ Map params = getParams(httpRequest);
+ //调用SDK验证签名
+ //公钥验签示例代码
+ boolean signVerified = AlipaySignature.rsaCheckV1(params, alipayConfig.getPublicKey(), "utf-8", alipayConfig.getSignType());
+ if (signVerified) {
+ validResponse.setValid(true);
+ validResponse.setOrderSn( (String) params.get("out_trade_no") );
+ return validResponse;
+ } else {
+ validResponse.setValid(false);
+ validResponse.setOrderSn( (String) params.get("out_trade_no") );
+ return validResponse;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ }
+
+ private Map getParams(HttpServletRequest httpServletRequest){
+ Map params = new HashMap< String , String >();
+ Map requestParams = httpServletRequest.getParameterMap();
+
+ for(Iterator iter = requestParams.keySet().iterator(); iter.hasNext();){
+ String name = (String)iter.next();
+ String[] values = (String [])requestParams.get(name);
+ String valueStr = "";
+ for(int i = 0;i < values.length;i ++ ){
+ valueStr = (i==values.length-1)?valueStr + values [i]:valueStr + values[i] + ",";
+ }
+ //乱码解决,这段代码在出现乱码时使用。
+ //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
+ params.put (name,valueStr);
+ }
+ log.info("params:{}",params);
+ return params;
+ }
+
+ @Override
+ public String successResult() {
+ return AlipayConstant.SUCCESS;
+ }
+
+ @Override
+ public String failResult() {
+ return AlipayConstant.FAIL;
+ }
+}
diff --git a/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java b/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java
new file mode 100644
index 0000000..3cb71be
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java
@@ -0,0 +1,20 @@
+package com.ruoyi.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * create by: wgl
+ * desc: 自定义支付平台注解,支付平台 微信:wx 支付宝:zfb
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface TradePlatform {
+
+ /**
+ * 平台的id
+ * Platform.WX
+ * @return
+ */
+ String value();
+}
diff --git a/pay/src/main/java/com/ruoyi/config/CallbackConfig.java b/pay/src/main/java/com/ruoyi/config/CallbackConfig.java
new file mode 100644
index 0000000..2c656ee
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/config/CallbackConfig.java
@@ -0,0 +1,23 @@
+package com.ruoyi.config;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 微信权限对接类
+ */
+@Component
+@ConfigurationProperties("elegent.pay.callback")
+@Data
+public class CallbackConfig {
+
+ private String domain; //回调域名
+
+ @Value("${elegent.pay.callback.watch:false}")
+ private boolean watch; //是否开启监听
+
+ @Value("${elegent.pay.callback.cycle:10}")
+ private int cycle;//检查周期
+
+}
\ No newline at end of file
diff --git a/pay/src/main/java/com/ruoyi/constant/PayConstant.java b/pay/src/main/java/com/ruoyi/constant/PayConstant.java
new file mode 100644
index 0000000..77695ce
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/constant/PayConstant.java
@@ -0,0 +1,11 @@
+package com.ruoyi.constant;
+
+public class PayConstant {
+
+ public final static String CALLBACK_PATH = "/payCallBack";
+
+ public final static String NOTIFY = "/notify";
+
+ public final static String REFUND_NOTIFY = "/refund_notify";
+
+}
diff --git a/pay/src/main/java/com/ruoyi/constant/Platform.java b/pay/src/main/java/com/ruoyi/constant/Platform.java
new file mode 100644
index 0000000..fd9a8d9
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/constant/Platform.java
@@ -0,0 +1,16 @@
+package com.ruoyi.constant;
+
+/**
+ * Platform
+ * 支付方式
+*/
+public class Platform {
+ /**
+ * 微信
+ */
+ public final static String WX = "wxpay";
+ /**
+ * 支付宝
+ */
+ public final static String ALI = "alipay";
+}
diff --git a/pay/src/main/java/com/ruoyi/constant/TradeType.java b/pay/src/main/java/com/ruoyi/constant/TradeType.java
new file mode 100644
index 0000000..c0a7ace
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/constant/TradeType.java
@@ -0,0 +1,33 @@
+package com.ruoyi.constant;
+
+import lombok.Data;
+
+/**
+ * 交易类型
+ */
+@Data
+public class TradeType {
+
+ /**
+ * native(扫码)
+ */
+ public final static String NATIVE = "native";
+
+ /**
+ * jsapi(小程序)
+ */
+ public final static String JSAPI = "jsapi";
+
+
+ /**
+ * app
+ */
+ public final static String APP = "app";
+
+
+ /**
+ * h5
+ */
+ public final static String H5 = "h5";
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java b/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java
new file mode 100644
index 0000000..ea0148d
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java
@@ -0,0 +1,35 @@
+package com.ruoyi.core;
+
+import com.ruoyi.CallBackService;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 回调类
+ */
+@Slf4j
+public class CallBackServiceImpl implements CallBackService {
+
+
+ @Override
+ public void successPay(String orderSn) {
+ log.info("支付成功回调!"+orderSn);
+ }
+
+ @Override
+ public void failPay(String orderSn) {
+ log.info("支付失败回调!"+orderSn);
+ }
+
+
+ @Override
+ public void successRefund(String orderSn) {
+ log.info("退款成功回调!"+orderSn);
+ }
+
+ @Override
+ public void failRefund(String orderSn) {
+ log.info("退款失败回调!"+orderSn);
+ }
+
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/CallbackController.java b/pay/src/main/java/com/ruoyi/core/CallbackController.java
new file mode 100644
index 0000000..8b7170f
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/CallbackController.java
@@ -0,0 +1,90 @@
+package com.ruoyi.core;
+
+import com.ruoyi.CallBackService;
+import com.ruoyi.constant.PayConstant;
+import com.ruoyi.dto.ValidResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * CallbackController
+ * @description 系统默认提供的微信回调的Controller
+*/
+@RestController
+@Slf4j
+@RequestMapping(PayConstant.CALLBACK_PATH)
+public class CallbackController {
+
+ @Autowired
+ private CallBackService callBackService;
+
+ /**
+ * 系统提供的默认的微信回调的接口(支付回调)
+ * @param httpEntity
+ * @param response
+ * @return
+ */
+ @RequestMapping( PayConstant.NOTIFY + "/{platform}")
+ public String notify(HttpEntity httpEntity, HttpServletRequest request, HttpServletResponse response, @PathVariable("platform") String platform){
+
+ ElegentValid elegentValid = ElegentLoader.getElegentValid(platform); //获取验证器
+ try {
+ ValidResponse validResponse = elegentValid.validPay(httpEntity, request);//验证支付通知
+ String orderSn =validResponse.getOrderSn(); //订单号
+ if(validResponse.isValid()){ //返回码成功
+ callBackService.successPay(orderSn);
+ //返回成功消费
+ return elegentValid.successResult();
+ }else{
+ callBackService.failPay(orderSn);
+ return elegentValid.failResult();
+ }
+ }catch (Exception e){
+ log.error("支付回调处理失败",e);
+ //微信返回的状态非正常
+ return elegentValid.failResult();
+ }
+ }
+
+
+ /**
+ * 系统提供的默认的微信回调的接口(退款通知)
+ *
+ * @param httpEntity
+ * @param response
+ * @return
+ */
+ @RequestMapping( PayConstant.REFUND_NOTIFY + "/{platform}")
+ public String refundNotify(HttpEntity httpEntity, HttpServletRequest request, HttpServletResponse response,@PathVariable("platform") String platform) {
+
+ ElegentValid elegentValid = ElegentLoader.getElegentValid(platform); //获取验证器
+
+ try {
+ ValidResponse validResponse = elegentValid.validRefund(httpEntity, request);
+ String orderSn = validResponse.getOrderSn();
+ //订单号
+ if (validResponse.isValid()) { //返回码成功
+ callBackService.successRefund(orderSn);
+ //返回成功消费
+ return elegentValid.successResult();
+ } else {
+ callBackService.failRefund(orderSn);
+ return elegentValid.failResult();
+ }
+ } catch (Exception e) {
+ log.error("退款回调处理失败", e);
+ //微信返回的状态非正常
+ return elegentValid.failResult();
+ }
+
+ }
+
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/CallbackWatch.java b/pay/src/main/java/com/ruoyi/core/CallbackWatch.java
new file mode 100644
index 0000000..5bfe85e
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/CallbackWatch.java
@@ -0,0 +1,73 @@
+package com.ruoyi.core;
+
+
+
+import com.ruoyi.CallBackService;
+import com.ruoyi.ElegentPay;
+import com.ruoyi.config.CallbackConfig;
+import com.ruoyi.dto.QueryRefundResponse;
+import com.ruoyi.dto.QueryResponse;
+import com.ruoyi.dto.WatchDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import javax.annotation.PostConstruct;
+import java.util.Timer;
+import java.util.TimerTask;
+
+@Component
+@ConditionalOnProperty(prefix = "elegent.pay.callback",name = "watch",havingValue = "true")
+@Slf4j
+public class CallbackWatch {
+
+ @Autowired
+ private CallBackService callBackService;
+
+ @Autowired
+ private CallbackConfig callbackConfig;
+
+ @Autowired
+ private ElegentPay elegentPay;
+
+ @PostConstruct
+ public void queryWatch(){
+ if(callbackConfig.getCycle()<=0){
+ return;
+ }
+ //log.info("开启支付结果定期巡检");
+ Timer timer = new Timer();
+ // 2、创建 TimerTask 任务线程
+ TimerTask task=new TimerTask() {
+ @Override
+ public void run() {
+ try{
+ //查询支付状态
+ //log.info("支付状态定期巡检,{}",WatchList.payList);
+ for( WatchDTO watchDTO: WatchList.payList ){
+ //查询订单是否支付成功
+ QueryResponse queryResponse = elegentPay.queryTradingOrderNo(watchDTO.getOrderSn(),watchDTO.getPlatform());
+ if("SUCCESS".equals(queryResponse.getTrade_state())){
+ callBackService.successPay(queryResponse.getOrder_sn());
+ WatchList.payList.remove(watchDTO );
+ }
+ }
+ //log.info("退款状态定期巡检,{}",WatchList.refundList);
+ //查询退款状态
+ for( WatchDTO watchDTO: WatchList.refundList ){
+ //查询退款中订单
+ QueryRefundResponse queryResponse = elegentPay.queryRefundTrading( watchDTO.getOrderSn(),watchDTO.getPlatform());
+ if("SUCCESS".equals(queryResponse.getStatus())){
+ callBackService.successRefund(queryResponse.getOrder_sn());
+ WatchList.refundList.remove(watchDTO);
+ }
+ }
+ }catch (Exception ex){
+ }
+ }
+ };
+ // 4、启动定时任务
+ timer.schedule(task, callbackConfig.getCycle()*1000, callbackConfig.getCycle()*1000);
+ }
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/ElegentConfig.java b/pay/src/main/java/com/ruoyi/core/ElegentConfig.java
new file mode 100644
index 0000000..34cde57
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/ElegentConfig.java
@@ -0,0 +1,27 @@
+package com.ruoyi.core;
+
+
+import com.ruoyi.CallBackService;
+import com.ruoyi.key.KeyManager;
+import com.ruoyi.key.impl.DefaultKeyManager;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ElegentConfig {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public CallBackService callBackService(){
+ return new CallBackServiceImpl();
+ }
+
+
+ @Bean
+ @ConditionalOnMissingBean
+ public KeyManager keyManager(){
+ return new DefaultKeyManager();
+ }
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/ElegentLoader.java b/pay/src/main/java/com/ruoyi/core/ElegentLoader.java
new file mode 100644
index 0000000..36dcb8b
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/ElegentLoader.java
@@ -0,0 +1,82 @@
+package com.ruoyi.core;
+
+import com.ruoyi.annotation.TradePlatform;
+import com.ruoyi.exceptions.TradeException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PlatformLoader
+ * @description 第三方支付平台类加载器
+ * 服务启动的时候自动加载第三方支付组件
+*/
+@Component
+@Slf4j
+public class ElegentLoader implements ApplicationContextAware {
+
+ private static Map elegentTradeMap = new HashMap<>();
+
+ private static Map elegentValidMap = new HashMap<>();
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+
+ //加载所有的交易实现类
+ Collection elegentTrades = applicationContext.getBeansOfType(ElegentTrade.class).values();
+ elegentTrades.stream().forEach(e->{
+ //通过反射拿到类上的平台注解
+ TradePlatform annotation = e.getClass().getAnnotation(TradePlatform.class);
+ if (annotation != null) {
+ elegentTradeMap.put(annotation.value(), e);
+ }
+ });
+
+ //加载所有的验证实现类
+ Collection elegentValids = applicationContext.getBeansOfType(ElegentValid.class).values();
+ elegentValids.stream().forEach(e->{
+ //通过反射拿到类上的平台注解
+ TradePlatform annotation = e.getClass().getAnnotation(TradePlatform.class);
+ if (annotation != null) {
+ elegentValidMap.put(annotation.value(), e);
+ }
+ });
+
+ }
+
+ /**
+ * 根据平台id获取具体的第三方平台
+ * @param platform 平台id
+ * @return
+ */
+ public static ElegentTrade getElegentTrade(String platform){
+ ElegentTrade elegentPayTemplate = elegentTradeMap.get(platform);
+ if(elegentPayTemplate!=null){
+ return elegentPayTemplate;
+ }else{
+ throw new TradeException("未找到适配的交易类型,交易平台id:"+platform);
+ }
+ }
+
+
+ /**
+ * 根据平台id获取具体的验证类
+ * @param platform 平台id
+ * @return
+ */
+ public static ElegentValid getElegentValid(String platform){
+ ElegentValid elegentValidTemplate = elegentValidMap.get(platform);
+ if(elegentValidTemplate!=null){
+ return elegentValidTemplate;
+ }else{
+ throw new TradeException("未找到适配的交易类型,交易平台id:"+platform);
+ }
+ }
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java b/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java
new file mode 100644
index 0000000..97f84d2
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java
@@ -0,0 +1,136 @@
+package com.ruoyi.core;
+import com.ruoyi.ElegentPay;
+import com.ruoyi.config.CallbackConfig;
+import com.ruoyi.dto.*;
+import com.ruoyi.exceptions.TradeException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * ElegentPayTemplate
+ * @description 统一模板 在模板层进行第三方平台的选择
+*/
+@Component
+public class ElegentPayImpl implements ElegentPay {
+
+ @Autowired
+ private CallbackConfig callbackConfig;
+
+ /**
+ * 统一下单接口
+ * @param payRequest
+ * @return
+ */
+ @Override
+ public PayResponse requestPay(PayRequest payRequest, String tradeType, String platform) throws TradeException {
+ //获取交易策略
+ PayResponse payResponse = getPlatFormService(platform).requestPay(payRequest, tradeType);
+
+ //加入监听列表
+ if(callbackConfig.isWatch()){
+ WatchDTO watchDTO=new WatchDTO();
+ watchDTO.setOrderSn(payRequest.getOrderSn());
+ watchDTO.setPlatform(platform);
+ WatchList.payList.add( watchDTO );
+ }
+ return payResponse;
+ }
+
+
+ /**
+ * 关闭订单
+ * @param orderSn
+ * @param platform
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public Boolean closePay(String orderSn, String platform) throws TradeException {
+ //调用对应第三方的创建订单接口
+ Boolean aBoolean = getPlatFormService(platform).closePay(orderSn);
+ //加入监听列表
+ if(callbackConfig.isWatch()){
+ WatchDTO watchDTO=new WatchDTO();
+ watchDTO.setOrderSn(orderSn);
+ watchDTO.setPlatform(platform);
+ WatchList.payList.remove( watchDTO );
+ }
+
+ return aBoolean;
+ }
+
+ /**
+ * 退款方法
+ * @param refundRequest
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public Boolean refund(RefundRequest refundRequest, String platform) throws TradeException {
+ Boolean refund = getPlatFormService(platform).refund(refundRequest);
+ //加入监听列表
+ if(callbackConfig.isWatch() && refund){
+ WatchDTO watchDTO=new WatchDTO();
+ watchDTO.setOrderSn(refundRequest.getRequestNo());
+ watchDTO.setPlatform(platform);
+ WatchList.refundList.add( watchDTO );
+ }
+ return refund;
+ }
+
+
+ /**
+ * 手动查询订单的方法
+ * 商户订单号查询 根据订单号查询订单
+ * 该接口基于生成的订单号来进行订单的查询
+ * 可以基于查询的结果判断用户订单是否支付成功
+ * @param orderSn
+ * @param Platform
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public QueryResponse queryTradingOrderNo(String orderSn , String Platform) throws TradeException {
+ //调用具体第三方的退款接口
+ return getPlatFormService(Platform).queryTradingOrderNo(orderSn);
+ }
+
+
+ /**
+ * 查询退款单号
+ *
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public QueryRefundResponse queryRefundTrading(String orderSn , String platform) throws TradeException {
+ //获取请求参数
+ return getPlatFormService(platform).queryRefundTrading(orderSn);
+ }
+
+ /**
+ * 获得openId
+ * @param code
+ * @param platform
+ * @return
+ */
+ @Override
+ public String getOpenid(String code, String platform) {
+ return getPlatFormService(platform).getOpenid(code);
+ }
+
+/**
+ * ====================================提供的模板类需要使用的方法=====================================
+ */
+
+
+ /**
+ * 跟进具体内容获取实现类的方法
+ * @param platForm
+ * @return
+ */
+ private ElegentTrade getPlatFormService(String platForm) {
+ return ElegentLoader.getElegentTrade(platForm);
+ }
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/ElegentTrade.java b/pay/src/main/java/com/ruoyi/core/ElegentTrade.java
new file mode 100644
index 0000000..4474da3
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/ElegentTrade.java
@@ -0,0 +1,54 @@
+package com.ruoyi.core;
+
+
+import com.ruoyi.dto.*;
+import com.ruoyi.exceptions.TradeException;
+
+public interface ElegentTrade {
+
+
+ /**
+ * 单独的创建本地支付订单接口
+ * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
+ * 业务编写人员仅仅只需要准备好请求参数调用该方法即可完成下单请求
+ * @return 交易数据对象 包含有native支付的二维码+jsApi支付的支付组件
+ */
+ PayResponse requestPay(PayRequest payRequest, String tradeType) throws TradeException;
+
+ /**
+ * 关闭订单
+ * 该结构基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
+ * 业务编写人员在处理超时订单的时候需要 通知微信 由于是超时订单需要进行远程关闭
+ */
+ Boolean closePay(String orderSn) throws TradeException;
+
+ /**
+ * 退款s申请
+ * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
+ * 业务编写人员在处理业务执行失败时需要进行退款
+ */
+ Boolean refund(RefundRequest refundRequest) throws TradeException;
+
+ /**
+ * 商户订单号查询 根据订单号查询订单
+ * 该接口基于生成的订单号来进行订单的查询
+ * 可以基于查询的结果判断用户订单是否支付成功
+ */
+ QueryResponse queryTradingOrderNo(String orderSn) throws TradeException;
+
+
+ /**
+ * 查询单笔退款API
+ *
+ */
+ QueryRefundResponse queryRefundTrading(String orderSn) throws TradeException;
+
+
+ /**
+ * 获得openId
+ * @param code
+ * @return
+ */
+ String getOpenid(String code);
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/ElegentValid.java b/pay/src/main/java/com/ruoyi/core/ElegentValid.java
new file mode 100644
index 0000000..fdb7cd5
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/ElegentValid.java
@@ -0,0 +1,48 @@
+package com.ruoyi.core;
+
+
+import com.ruoyi.dto.ValidResponse;
+import com.ruoyi.exceptions.TradeException;
+import org.springframework.http.HttpEntity;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 验证器接口
+ *
+ */
+public interface ElegentValid {
+
+
+ /**
+ * 支付结果通知校验
+ * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
+ * 业务编写人员在接收到微信或支付宝回调的时候可以使用该方法验证回调是否成功,是否是伪回调
+ * @return 交易数据对象
+ */
+ ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest request) throws TradeException;
+
+
+
+ /**
+ * 退款结果通知校验
+ * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
+ * 业务编写人员在接收到微信或支付宝回调的时候可以使用该方法验证回调是否成功,是否是伪回调
+ */
+ ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest request) throws TradeException;
+
+
+ /**
+ * 成功返回结构
+ * @return
+ */
+ String successResult();
+
+
+ /**
+ * 失败返回内容
+ * @return
+ */
+ String failResult();
+
+}
diff --git a/pay/src/main/java/com/ruoyi/core/WatchList.java b/pay/src/main/java/com/ruoyi/core/WatchList.java
new file mode 100644
index 0000000..a610939
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/core/WatchList.java
@@ -0,0 +1,20 @@
+package com.ruoyi.core;
+
+
+
+import com.ruoyi.dto.WatchDTO;
+
+import java.util.concurrent.CopyOnWriteArraySet;
+
+/**
+ * 监听列表
+ */
+public class WatchList {
+
+
+
+ public static CopyOnWriteArraySet payList=new CopyOnWriteArraySet<>(); //支付中列表
+
+ public static CopyOnWriteArraySet refundList=new CopyOnWriteArraySet<>(); //退款中列表
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/PayRequest.java b/pay/src/main/java/com/ruoyi/dto/PayRequest.java
new file mode 100644
index 0000000..5d747da
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/PayRequest.java
@@ -0,0 +1,20 @@
+package com.ruoyi.dto;
+
+
+import lombok.Data;
+
+/**
+ * PayRequest
+ * 支付请求外观类
+*/
+@Data
+public class PayRequest {
+
+ private String body;//商品描述
+
+ private String orderSn; //订单号
+
+ private int totalFee; //订单金额
+
+ private String openid;//openId
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/PayResponse.java b/pay/src/main/java/com/ruoyi/dto/PayResponse.java
new file mode 100644
index 0000000..db4aafb
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/PayResponse.java
@@ -0,0 +1,29 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * 结果统一封装类
+ */
+@Data
+public class PayResponse {
+
+ private boolean success; //是否成功
+
+ private String message;//信息
+
+ private String order_sn;//订单编号
+
+ private Map expand;//扩展属性
+
+ private String code_url;//二维码连接(native返回)
+
+ private String prepay_id;//预支付Id(小程序返回)
+
+ private String h5_url;//支付跳转链接
+
+ private Map jsapiData;//小程序返回
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java b/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java
new file mode 100644
index 0000000..d938f63
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java
@@ -0,0 +1,24 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+@Data
+public class QueryRefundResponse extends QueryResponse{
+
+
+ private String refund_id; //微信支付退款单号
+
+ private String out_refund_no;//商户退款单号
+
+ private String channel;//退款渠道
+
+ private String user_received_account;//退款账号
+
+ private String success_time;//退款成功时间
+
+ private String status;//退款状态
+
+ private int refund;//退款金额
+
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/QueryResponse.java b/pay/src/main/java/com/ruoyi/dto/QueryResponse.java
new file mode 100644
index 0000000..04ddb70
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/QueryResponse.java
@@ -0,0 +1,25 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * 查询响应对象
+ */
+@Data
+public class QueryResponse {
+
+ private String openid;//用户id
+
+ private String trade_state;//交易状态
+
+ private String order_sn;//订单号
+
+ private String transaction_id;//交易单号
+
+ private int total;//金额
+
+ private Map expand;//扩展(全部的返回数据)
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/RefundRequest.java b/pay/src/main/java/com/ruoyi/dto/RefundRequest.java
new file mode 100644
index 0000000..3f17046
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/RefundRequest.java
@@ -0,0 +1,16 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+@Data
+public class RefundRequest {
+
+ private int totalFee; //订单金额
+
+ private int refundAmount; //退款金额
+
+ private String orderSn; //订单号
+
+ private String requestNo; //退款请求号,做退款幂等性校验,当部分退款时必须给出
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/ValidResponse.java b/pay/src/main/java/com/ruoyi/dto/ValidResponse.java
new file mode 100644
index 0000000..f8e3973
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/ValidResponse.java
@@ -0,0 +1,15 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+/**
+ * 验证签名
+ */
+@Data
+public class ValidResponse {
+
+ private boolean isValid;// 是否通过验签
+
+ private String orderSn;// 订单号
+
+}
diff --git a/pay/src/main/java/com/ruoyi/dto/WatchDTO.java b/pay/src/main/java/com/ruoyi/dto/WatchDTO.java
new file mode 100644
index 0000000..7411b91
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/dto/WatchDTO.java
@@ -0,0 +1,12 @@
+package com.ruoyi.dto;
+
+import lombok.Data;
+
+@Data
+public class WatchDTO {
+
+ private String orderSn; //订单号
+
+ private String platform;//平台
+
+}
diff --git a/pay/src/main/java/com/ruoyi/exceptions/TradeException.java b/pay/src/main/java/com/ruoyi/exceptions/TradeException.java
new file mode 100644
index 0000000..3a82860
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/exceptions/TradeException.java
@@ -0,0 +1,24 @@
+package com.ruoyi.exceptions;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 交易SDK提供的总的异常
+ */
+@Getter
+@Setter
+public class TradeException extends RuntimeException{
+ private String code;
+ private String msg;
+
+ public TradeException(String code, String msg) {
+ super(msg);
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public TradeException(String msg) {
+ super(msg);
+ }
+}
diff --git a/pay/src/main/java/com/ruoyi/key/KeyManager.java b/pay/src/main/java/com/ruoyi/key/KeyManager.java
new file mode 100644
index 0000000..aacfee5
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/key/KeyManager.java
@@ -0,0 +1,16 @@
+package com.ruoyi.key;
+
+/**
+ * 密钥管理器接口
+ */
+public interface KeyManager {
+
+
+ /**
+ * 根据名字获取key字符串
+ * @param name
+ * @return
+ */
+ String getKey(String name);
+
+}
diff --git a/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java b/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java
new file mode 100644
index 0000000..0d48c66
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java
@@ -0,0 +1,19 @@
+package com.ruoyi.key.impl;
+
+
+import com.ruoyi.key.KeyManager;
+import com.ruoyi.util.FileUtil;
+
+/**
+ * 默认的key管理器-文件管理器
+ */
+public class DefaultKeyManager implements KeyManager {
+
+
+ @Override
+ public String getKey(String name) {
+ return FileUtil.readToStr(name);
+ }
+
+
+}
diff --git a/pay/src/main/java/com/ruoyi/util/FileUtil.java b/pay/src/main/java/com/ruoyi/util/FileUtil.java
new file mode 100644
index 0000000..13d0e9f
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/util/FileUtil.java
@@ -0,0 +1,37 @@
+package com.ruoyi.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 文件读取类
+ */
+public class FileUtil {
+
+
+ /**
+ * 获取文件内容
+ * @param fileName
+ * @return
+ */
+ public static String readToStr(String fileName){
+ InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(fileName);
+ ByteArrayOutputStream os = new ByteArrayOutputStream(2048);
+ byte[] buffer = new byte[1024];
+
+ String str;
+ try {
+ int length;
+ while((length = is.read(buffer)) != -1) {
+ os.write(buffer, 0, length);
+ }
+
+ str = os.toString("UTF-8");
+ } catch (IOException var5) {
+ throw new IllegalArgumentException("无效的密钥", var5);
+ }
+ return str;
+ }
+
+}
diff --git a/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java b/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java
new file mode 100644
index 0000000..d1dfc8c
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java
@@ -0,0 +1,459 @@
+package com.ruoyi.wx;
+
+
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.ruoyi.annotation.TradePlatform;
+import com.ruoyi.config.CallbackConfig;
+import com.ruoyi.constant.PayConstant;
+import com.ruoyi.constant.Platform;
+import com.ruoyi.core.ElegentTrade;
+import com.ruoyi.dto.*;
+import com.ruoyi.exceptions.TradeException;
+import com.ruoyi.util.FileUtil;
+import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
+import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
+import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
+import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
+import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
+import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+@Slf4j
+@TradePlatform(Platform.WX)
+public class WxPayElegentTrade implements ElegentTrade {
+
+ @Autowired
+ private WxpayConfig wxpayConfig;
+
+ @Autowired
+ private CallbackConfig callbackConfig;
+
+ /**
+ * 创建微信支付订单方法
+ * 这里参考官网代码:
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_1.shtml Native下单
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_1.shtml JSAPI 下单
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_1.shtml H5下单
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_1.shtml APP下单
+ * @param payRequest 支付请求
+ * @return 支付响应
+ * @throws IOException
+ */
+ @Override
+ public PayResponse requestPay(PayRequest payRequest, String tradeType)throws TradeException {
+ PayResponse payResponse = new PayResponse(); //返回结果
+ try {
+ // 请求body参数构建
+ Map params = new HashMap() {
+ {
+ put("mchid", wxpayConfig.getMchId());
+ put("appid", wxpayConfig.getAppId());
+ put("notify_url", callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH + PayConstant.NOTIFY +"/"+ Platform.WX );
+ put("out_trade_no", payRequest.getOrderSn());
+ put("amount", new HashMap() {
+ {
+ put("total", payRequest.getTotalFee());//金额,单位:分
+ put("currency", "CNY");//人民币
+ }
+ });
+ put("description", payRequest.getBody());
+ }
+ };
+
+ if("h5".equals(tradeType)){ //h5
+ params.put("scene_info", new HashMap() {
+ {
+ put("payer_client_ip", "127.0.0.1");
+ put("h5_info", new HashMap() {
+ {
+ put("type", "Wap");
+ }
+ });
+ }
+ });
+ }
+ if ("jsapi".equals(tradeType)) { //如果是小程序支付
+ params.put("payer", new HashMap() {
+ {
+ put("openid", payRequest.getOpenid());
+ }
+ });
+ }
+
+
+ String url = WxpayConstant.createOrder + tradeType; //创建订单
+ log.info("elegent-pay 请求参数{}",params);
+ Map map = postApiTemplate(url, params);
+
+ if("SUCCESS".equals( map.get("code") )){
+ payResponse.setOrder_sn(payRequest.getOrderSn());
+ payResponse.setSuccess(true);
+ payResponse.setCode_url(map.get("code_url"));
+ payResponse.setMessage(map.get("message"));
+
+ payResponse.setPrepay_id(map.get("prepay_id"));
+ payResponse.setH5_url( map.get("h5_url") );
+
+ payResponse.setExpand(map); //全部数据
+
+ if("jsapi".equals(tradeType)){//如果是小程序,需要封装到Expand
+ Map data=new HashMap<>();
+ String timeStamp = String.valueOf(System.currentTimeMillis() / 1000);
+ String nonceStr = IdUtil.simpleUUID();
+ String packages = "prepay_id=" + payResponse.getPrepay_id();
+ String privateKey = FileUtil.readToStr("wxpay_private.key");
+ String paySign = this.createPaySign(wxpayConfig.getAppId(), timeStamp, nonceStr, packages, privateKey);
+ data.put("appId", wxpayConfig.getAppId());// appid
+ data.put("timeStamp", timeStamp);// 时间戳
+ data.put("nonceStr", nonceStr);// 随机字符串
+ data.put("package","prepay_id="+payResponse.getPrepay_id());
+ data.put("signType", "RSA");// 签名类型,默认为RSA,仅支持RSA
+ data.put("paySign", paySign);// 签名
+ data.put("orderNo",payRequest.getOrderSn());
+ payResponse.setJsapiData(data);
+ }
+
+
+ log.info("createOrder: {}", payResponse);
+
+ }else{
+ payResponse.setSuccess(false);
+ payResponse.setMessage( map.get("message") );
+ }
+ return payResponse;
+ }catch (Exception e){
+ e.printStackTrace();
+ payResponse.setSuccess(false);
+ }
+ return payResponse;
+ }
+
+
+ /**
+ * 关闭订单
+ * 参考官网代码
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_7_2.shtml 3.2.5. 【服务端】关闭订单
+ * @return
+ */
+ @Override
+ public Boolean closePay(String orderSn) throws TradeException {
+ // 请求body参数构建
+ Map params = new HashMap();
+ params.put("mchid", wxpayConfig.getMchId());
+ String url = WxpayConstant.closeOrder.replaceAll("\\{out_trade_no\\}",orderSn);
+ Map map = postApiTemplate(url, params);
+ if("SUCCESS".equals( map.get("code"))){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+
+ /**
+ * 退款
+ * 参考官网代码 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_9.shtml
+ * @param refundRequest
+ * @return
+ */
+ @Override
+ public Boolean refund(RefundRequest refundRequest) {
+ // 请求body参数构建
+ // 请求body参数构建
+ Map params = new HashMap();
+ params.put("notify_url", callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH +PayConstant.REFUND_NOTIFY +"/"+ Platform.WX ); //回调地址
+ params.put("out_trade_no", refundRequest.getOrderSn());//订单编号
+ //out_refund_no
+ params.put("out_refund_no", refundRequest.getRequestNo());//退款申请单编号 (多次退款需要不一样才行)
+ params.put("amount", new HashMap() {
+ {
+ put("refund",refundRequest.getRefundAmount());//退款金额
+ put("total", refundRequest.getTotalFee());//原金额,单位:分
+ put("currency", "CNY");//人民币
+ }
+ });
+ String url = WxpayConstant.refund; //创建订单
+ Map map = postApiTemplate(url, params);
+ if("SUCCESS".equals( map.get("code"))){
+
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+
+
+ /**
+ * 手动查询订单
+ * 参考官网代码: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_6_2.shtml 3.2.4. 【服务端】查询订单
+ * @param orderSn
+ * @return
+ */
+ @Override
+ public QueryResponse queryTradingOrderNo(String orderSn) throws TradeException {
+ // 请求body参数构建
+ Map params = new HashMap();
+ params.put("mchid", wxpayConfig.getMchId());
+ String url = WxpayConstant.queryOrderNo+orderSn;;
+ try {
+ Map map = getApiTemplate(url, params);
+ QueryResponse queryResponse=new QueryResponse();
+ queryResponse.setOrder_sn((String)map.get("out_trade_no") ); //订单号
+ queryResponse.setTransaction_id((String)map.get("transaction_id") ); //交易单类型
+ queryResponse.setTrade_state( (String) map.get("trade_state") );//交易状态
+ Map amount = (Map)map.get("amount");
+ if(amount!=null){
+ queryResponse.setTotal( (Integer) amount.get("total") ); //总金额
+ }
+ Map payer= (Map)map.get("payer");
+ if(payer!=null){
+ queryResponse.setOpenid( (String)payer.get("openid") );
+ }
+ queryResponse.setExpand(map);//全部数据
+ return queryResponse;
+
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+
+ /**
+ * 查询退款订单
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_10.shtml
+ * @param out_refund_no
+ * @return
+ * @throws TradeException
+ */
+ @Override
+ public QueryRefundResponse queryRefundTrading(String out_refund_no) throws TradeException {
+
+ // 请求body参数构建
+ Map params = new HashMap();
+ String url = WxpayConstant.queryRufundOrderNo + out_refund_no;
+ try {
+ Map map = getApiTemplate(url, params);
+ QueryRefundResponse queryRefundResponse=new QueryRefundResponse();
+ queryRefundResponse.setOrder_sn( (String) map.get("out_trade_no") );
+ queryRefundResponse.setTransaction_id( (String) map.get("transaction_id") );
+ Map amount = (Map)map.get("amount");
+ queryRefundResponse.setTotal( (Integer) amount.get("total") ); //总金额
+ queryRefundResponse.setRefund((Integer) amount.get("payer_refund") ); //退款金额
+ queryRefundResponse.setRefund_id((String) map.get("refund_id") ); //退款单号
+ queryRefundResponse.setOut_refund_no( (String) map.get("out_refund_no") );//退款订单号
+
+ queryRefundResponse.setChannel( (String) map.get("channel") ); //通道
+ queryRefundResponse.setUser_received_account( (String) map.get("user_received_account") ); //账号
+ queryRefundResponse.setStatus( (String) map.get("status") ); //状态
+ queryRefundResponse.setSuccess_time( (String) map.get("success_time") );
+ queryRefundResponse.setExpand(map);
+ return queryRefundResponse;
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String getOpenid(String code) {
+ String getOpenIdUrl = "https://api.weixin.qq.com/sns/jscode2session?" +
+ "appid="+wxpayConfig.getAppId()
+ +"&secret="+wxpayConfig.getAppSecret()
+ +"&js_code="+code+"&grant_type=authorization_code";
+ RestTemplate restTemplate = new RestTemplate();
+ String respResult = restTemplate.getForObject(getOpenIdUrl,String.class);
+ log.info("获取openid的url:{},respResult:{}",getOpenIdUrl,respResult);
+ if( respResult==null || "".equals(respResult) ) return "";
+ try{
+
+ Map map = JSON.parseObject(respResult, Map.class);
+ String errorCode = map.get("errcode") ;
+ if(errorCode!=null && !"".equals(errorCode)){
+ int errorCodeInt = Integer.valueOf(errorCode).intValue();
+
+ log.info("获取openid的errorCode,{}",errorCodeInt);
+ if(errorCodeInt != 0) return "";
+ }
+ return map.get("openid");
+ }catch (Exception ex){
+ ex.printStackTrace();
+ return "";
+ }
+ }
+
+
+ private Map getApiTemplate(String url, Map params) throws URISyntaxException, IOException {
+ URIBuilder uriBuilder = new URIBuilder(url);
+ //添加参数
+ for (String key : params.keySet()) {
+ uriBuilder.addParameter(key, params.get(key));
+ }
+ //完成签名并执行请求
+ HttpGet httpGet = new HttpGet(uriBuilder.build());
+ httpGet.addHeader("Accept", "application/json");
+ CloseableHttpClient httpClient = getWxHttpClient();
+ CloseableHttpResponse response = httpClient.execute(httpGet);
+ return responseTemplate(response);
+ }
+
+
+ private Map responseTemplate(CloseableHttpResponse response) {
+ Map result = null;
+ try {
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode == 200) { //处理成功
+ // log.info("success,return body = " + EntityUtils.toString(response.getEntity()));
+ result = JSON.parseObject(EntityUtils.toString(response.getEntity()), Map.class);
+ result.put("code", "SUCCESS");
+ } else if (statusCode == 204) { //处理成功,无返回Body
+ log.info("success");
+ result = new HashMap() {
+ {
+ put("code", "SUCCESS");
+ }
+ };
+ } else {
+ String returnBody = EntityUtils.toString(response.getEntity());
+ log.error("failed,resp code = " + statusCode + ",return body = " + returnBody);
+ //throw new TradeException("创建本地支付订单失败!"+payDTO.getOrderSn());
+ Map map = JSON.parseObject(returnBody, Map.class);
+ result = new HashMap() {
+ {
+ put("code", "FAIL");
+ put("message", map.get("message"));
+ }
+ };
+ }
+ } catch (Exception e) {
+ result = new HashMap() {
+ {
+ put("code", "FAIL");
+ put("message", e.getMessage());
+ }
+ };
+ } finally {
+ closeConnect(response);
+ return result;
+ }
+ }
+
+ private Map postApiTemplate(String url, Map params) {
+ try {
+ HttpPost httpPost = new HttpPost(url);
+ StringEntity entity = new StringEntity(JSON.toJSONString(params));
+ entity.setContentType("application/json");
+ httpPost.setEntity(entity);
+ httpPost.setHeader("Accept", "application/json");
+ //完成签名并执行请求
+ CloseableHttpClient httpClient = getWxHttpClient();
+ CloseableHttpResponse response = httpClient.execute(httpPost);
+ return responseTemplate( response );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+
+ /**
+ * 获取微信HTTP连接
+ *
+ * @return
+ */
+ private CloseableHttpClient getWxHttpClient() {
+ try {
+ //这里对秘钥进行加密使用的完全是官网上的代码
+ //TODO 参考官网代码 https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_6_2.shtml
+ // 加载商户私钥(privateKey:私钥字符串)
+ String key = FileUtil.readToStr("wxpay_private.key");
+
+ PrivateKey merchantPrivateKey = PemUtil
+ .loadPrivateKey(new ByteArrayInputStream(key.getBytes("utf-8")));
+ // 加载平台证书(mchId:商户号,mchSerialNo:商户证书序列号,apiV3Key:V3密钥)
+ //PrivateKey merchantPrivateKey = keyManager.getPrivateKey("wxpay_private.key");//读取私钥
+ PrivateKeySigner privateKeySigner = new PrivateKeySigner(wxpayConfig.getMchSerialNo(), merchantPrivateKey);
+ WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials(
+ wxpayConfig.getMchId(), privateKeySigner);
+ // 向证书管理器增加需要自动更新平台证书的商户信息
+ CertificatesManager certificatesManager = CertificatesManager.getInstance();
+ certificatesManager.putMerchant(wxpayConfig.getMchId(), wechatPay2Credentials, wxpayConfig.getApiV3Key().getBytes("utf-8"));
+ // 初始化httpClient
+ return WechatPayHttpClientBuilder.create()
+ .withMerchant(wxpayConfig.getMchId(), wxpayConfig.getMchSerialNo(), merchantPrivateKey)
+ .withValidator(new WechatPay2Validator(certificatesManager.getVerifier(wxpayConfig.getMchId()))).build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("微信支付--初始化,校验系统参数失败");
+ }
+
+ }
+
+
+ /**
+ * 关闭资源
+ */
+ private void closeConnect(CloseableHttpResponse response) {
+ try {
+ response.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("资源回收出错");
+ }
+ }
+
+
+ /**
+ * 创建支付签名
+ * @param appid
+ * @param timeStamp
+ * @param nonceStr
+ * @param packages
+ * @param privateKey
+ * @return
+ * @throws Exception
+ */
+ private String createPaySign(String appid, String timeStamp, String nonceStr, String packages,String privateKey) throws Exception {
+ Signature sign = Signature.getInstance("SHA256withRSA");
+ // 加载商户私钥
+ PrivateKey key = PemUtil
+ .loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes(CharsetUtil.CHARSET_UTF_8)));
+ sign.initSign(key);
+ String message = StrUtil.format("{}\n{}\n{}\n{}\n",
+ appid,
+ timeStamp,
+ nonceStr,
+ packages);
+ sign.update(message.getBytes());
+ return Base64.getEncoder().encodeToString(sign.sign());
+ }
+
+
+}
diff --git a/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java b/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java
new file mode 100644
index 0000000..c570b6f
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java
@@ -0,0 +1,153 @@
+package com.ruoyi.wx;
+
+
+import com.alibaba.fastjson.JSON;
+import com.ruoyi.annotation.TradePlatform;
+import com.ruoyi.constant.Platform;
+import com.ruoyi.core.ElegentValid;
+import com.ruoyi.dto.ValidResponse;
+import com.ruoyi.exceptions.TradeException;
+import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
+import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
+import com.wechat.pay.contrib.apache.httpclient.notification.Notification;
+import com.wechat.pay.contrib.apache.httpclient.notification.NotificationHandler;
+import com.wechat.pay.contrib.apache.httpclient.notification.NotificationRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+@Component
+@Slf4j
+@TradePlatform(Platform.WX)
+public class WxPayElegentValid implements ElegentValid {
+
+
+ @Autowired
+ private WxpayConfig wxpayConfig;
+
+ @Override
+ public ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest httpServletRequest) throws TradeException {
+ ValidResponse validResponse=new ValidResponse();
+
+ try {
+ //获取请求头
+ HttpHeaders headers = httpEntity.getHeaders();
+ //构建微信请求数据对象
+ NotificationRequest request = new NotificationRequest.Builder()
+ .withSerialNumber(headers.getFirst("Wechatpay-Serial")) //证书序列号(微信平台)
+ .withNonce(headers.getFirst("Wechatpay-Nonce")) //随机串
+ .withTimestamp(headers.getFirst("Wechatpay-Timestamp")) //时间戳
+ .withSignature(headers.getFirst("Wechatpay-Signature")) //签名字符串
+ .withBody(httpEntity.getBody())
+ .build();
+
+
+ //微信通知的业务处理
+ //验证签名,确保请求来自微信
+ Map jsonData = null;
+ try {
+ //确保在管理器中存在自动更新的商户证书
+ CertificatesManager certificatesManager = CertificatesManager.getInstance();
+ Verifier verifier = certificatesManager.getVerifier(wxpayConfig.getMchId());
+
+ //验签和解析请求数据
+ NotificationHandler notificationHandler = new NotificationHandler(verifier, wxpayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8));
+ Notification notification = notificationHandler.parse(request);
+
+ if (!"TRANSACTION.SUCCESS".equals(notification.getEventType())) {
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ //获取解密后的数据
+ jsonData = JSON.parseObject(notification.getDecryptData(),Map.class );
+ log.info("解密后的数据为:"+jsonData);
+ } catch (Exception e) {
+ throw new TradeException("验签失败");
+ }
+ if (!"SUCCESS".equals(jsonData.get("trade_state"))) {
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ validResponse.setValid(true);
+ validResponse.setOrderSn( (String) jsonData.get("out_trade_no") ); //订单号
+ return validResponse;
+ } catch (Exception e) {
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ }
+
+ @Override
+ public ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest httpServletRequest) throws TradeException {
+
+ ValidResponse validResponse=new ValidResponse();
+ try {
+ //获取请求头
+ HttpHeaders headers = httpEntity.getHeaders();
+
+ //构建微信请求数据对象
+ NotificationRequest request = new NotificationRequest.Builder()
+ .withSerialNumber(headers.getFirst("Wechatpay-Serial")) //证书序列号(微信平台)
+ .withNonce(headers.getFirst("Wechatpay-Nonce")) //随机串
+ .withTimestamp(headers.getFirst("Wechatpay-Timestamp")) //时间戳
+ .withSignature(headers.getFirst("Wechatpay-Signature")) //签名字符串
+ .withBody(httpEntity.getBody())
+ .build();
+
+ //微信通知的业务处理
+ Map jsonData = null;
+ //验证签名,确保请求来自微信
+ try {
+ //确保在管理器中存在自动更新的商户证书
+ CertificatesManager certificatesManager = CertificatesManager.getInstance();
+ Verifier verifier = certificatesManager.getVerifier(wxpayConfig.getMchId());
+
+ //验签和解析请求数据
+ NotificationHandler notificationHandler = new NotificationHandler(verifier, wxpayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8));
+ Notification notification = notificationHandler.parse(request);
+
+ if (!"REFUND.SUCCESS".equals(notification.getEventType())) {
+ //非成功请求直接返回,理论上都是成功的请求
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ //获取解密后的数据
+ jsonData = JSON.parseObject( notification.getDecryptData(),Map.class );
+
+
+ } catch (Exception e) {
+ throw new TradeException("验签失败");
+ }
+ if (!"SUCCESS".equals(jsonData.get("refund_status"))) {
+ //非成功请求直接返回,理论上都是成功的请求
+ validResponse.setValid(false);
+ return validResponse;
+ }
+
+ //交易单号
+ validResponse.setValid(true);
+ validResponse.setOrderSn( (String) jsonData.get("out_trade_no") ); //订单号
+ return validResponse;
+ } catch (Exception e) {
+ //非成功请求直接返回,理论上都是成功的请求
+ validResponse.setValid(false);
+ return validResponse;
+ }
+ }
+
+ @Override
+ public String successResult() {
+ return JSON.toJSONString(WxpayConstant.SUCCESS ) ;
+ }
+
+ @Override
+ public String failResult() {
+ return JSON.toJSONString( WxpayConstant.FAIL);
+ }
+}
diff --git a/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java b/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java
new file mode 100644
index 0000000..c5f139c
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java
@@ -0,0 +1,20 @@
+package com.ruoyi.wx;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 微信权限对接类
+ */
+@Component
+@ConfigurationProperties("elegent.pay.wxpay")
+@Data
+public class WxpayConfig {
+
+ private String mchId; //商户号
+ private String appId; //APPID
+ private String appSecret;//app密钥
+ private String mchSerialNo; //商户证书序列号
+ private String apiV3Key; //V3密钥
+
+}
\ No newline at end of file
diff --git a/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java b/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java
new file mode 100644
index 0000000..01d3415
--- /dev/null
+++ b/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java
@@ -0,0 +1,48 @@
+package com.ruoyi.wx;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WxpayConstant {
+
+ public static final Map SUCCESS = new HashMap(){
+ {
+ put("code", "SUCCESS");
+ }
+ };
+
+ public static final Map FAIL = new HashMap(){
+ {
+ put("code", "FAIL");
+ put("message","微信回调错误结果");
+ }
+ };
+
+
+ public final static String domain ="https://api.mch.weixin.qq.com/v3";
+
+ /**
+ * 创建订单
+ */
+ public final static String createOrder = domain +"/pay/transactions/";
+
+ /**
+ * 关闭订单
+ */
+ public final static String closeOrder = domain+"/pay/transactions/out-trade-no/{out_trade_no}/close";
+
+ /**
+ * 查询订单编号
+ */
+ public static String queryOrderNo = domain+"/pay/transactions/out-trade-no/";
+
+ /**
+ * 查询退款订单
+ */
+ public static String queryRufundOrderNo =domain+ "/refund/domestic/refunds/";
+
+ /**
+ * 退款接口
+ */
+ public static String refund = domain+"/refund/domestic/refunds";
+}
diff --git a/pay/src/main/resources/META-INF/spring.factories b/pay/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..da04c71
--- /dev/null
+++ b/pay/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,14 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+ com.ruoyi.config.CallbackConfig,\
+ com.ruoyi.core.CallbackWatch,\
+ com.ruoyi.core.ElegentPayImpl,\
+ com.ruoyi.core.ElegentLoader,\
+ com.ruoyi.core.ElegentConfig,\
+ com.ruoyi.key.impl.DefaultKeyManager,\
+ com.ruoyi.core.CallbackController,\
+ com.ruoyi.wx.WxpayConfig,\
+ com.ruoyi.wx.WxPayElegentTrade,\
+ com.ruoyi.wx.WxPayElegentValid,\
+ com.ruoyi.ali.AlipayConfig,\
+ com.ruoyi.ali.AlipayElegentTrade,\
+ com.ruoyi.ali.AlipayElegentValid
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9d5389d..9c62fbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,6 +180,7 @@
ruoyi-quartz
ruoyi-generator
ruoyi-common
+ pay
pom
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 1436d6d..2186d33 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -60,7 +60,11 @@
com.ruoyi
ruoyi-generator
-
+
+ com.ruoyi
+ pay
+ 1.0.0-SNAPSHOT
+
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java
new file mode 100644
index 0000000..def71be
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java
@@ -0,0 +1,33 @@
+package com.ruoyi.web.controller.bestsign;
+
+import com.ruoyi.bestsign.domain.ArbitrSignatuVO;
+import com.ruoyi.bestsign.domain.PersonRegisterVO;
+import com.ruoyi.bestsign.service.ArbitrSignatuService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+@RestController
+@RequestMapping("/arbitrSignatu")
+public class ArbitrSignatuController {
+ @Autowired
+ ArbitrSignatuService arbitrSignatuService;
+
+ /**
+ * 申请状态查询
+ *
+ * @param arbitrSignatuVO
+ * @return
+ */
+ @PostMapping("/selectApplyStatus")
+ public AjaxResult selectApplyStatus (@Validated @RequestBody ArbitrSignatuVO arbitrSignatuVO) {
+ return arbitrSignatuService.selectApplyStatus(arbitrSignatuVO);
+ }
+
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java
new file mode 100644
index 0000000..5f3b0d1
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java
@@ -0,0 +1,31 @@
+package com.ruoyi.web.controller.bestsign;
+
+import com.ruoyi.bestsign.domain.PersonRegisterVO;
+import com.ruoyi.bestsign.service.SignRegisterService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+@RestController
+@RequestMapping("/register")
+public class RegisterController {
+ @Autowired
+ SignRegisterService signRegisterService;
+
+ /**
+ * 注册上上签个人用户
+ *
+ * @param personRegisterVO
+ * @return
+ */
+ @PostMapping("/registerPerson")
+ public AjaxResult createDocument(@Validated @RequestBody PersonRegisterVO personRegisterVO) {
+ return signRegisterService.registerPerson(personRegisterVO);
+ }
+// @PostMapping("/registerEnterprise")
+// public AjaxResult
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index d959a17..60633c7 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -2,6 +2,9 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.Set;
+
+import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
+import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -19,12 +22,11 @@ import com.ruoyi.system.service.ISysMenuService;
/**
* 登录验证
- *
+ *
* @author ruoyi
*/
@RestController
-public class SysLoginController
-{
+public class SysLoginController {
@Autowired
private SysLoginService loginService;
@@ -33,32 +35,37 @@ public class SysLoginController
@Autowired
private SysPermissionService permissionService;
+ @Autowired
+ IdentityAuthenticationService identityAuthenticationService;
/**
* 登录方法
- *
+ *
* @param loginBody 登录信息
* @return 结果
*/
@PostMapping("/login")
- public AjaxResult login(@RequestBody LoginBody loginBody)
- {
+ public AjaxResult login(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
+ //判断该用户是否已经实名认证(certificationStatus1已认证0未认证)
+ IdentityAuthentication identityAuthentication=new IdentityAuthentication();
+ identityAuthentication.setUserName(loginBody.getUsername());
+ String status = identityAuthenticationService.checkIsAuthentication(identityAuthentication);
+ ajax.put("certificationStatus", status);
return ajax;
}
/**
* 获取用户信息
- *
+ *
* @return 用户信息
*/
@GetMapping("getInfo")
- public AjaxResult getInfo()
- {
+ public AjaxResult getInfo() {
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set roles = permissionService.getRolePermission(user);
@@ -73,12 +80,11 @@ public class SysLoginController
/**
* 获取路由信息
- *
+ *
* @return 路由信息
*/
@GetMapping("getRouters")
- public AjaxResult getRouters()
- {
+ public AjaxResult getRouters() {
Long userId = SecurityUtils.getUserId();
List menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java
new file mode 100644
index 0000000..ea6ce32
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java
@@ -0,0 +1,107 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
+import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO;
+import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/adjudication")
+public class AdjudicationController extends BaseController {
+ @Autowired
+ private IAdjudicationService adjudicationService;
+
+ /**
+ * 生成裁决书
+ * @param caseApplication
+ * @return
+ */
+ @PostMapping("/document")
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:createaward')")
+ public AjaxResult createDocument(@Validated @RequestBody CaseApplication caseApplication){
+ return adjudicationService.createDocument(caseApplication);
+ }
+
+ /**
+ * 裁决书送达(电子邮件)
+ * @param bookSendVO
+ * @return
+ */
+ @PostMapping("/delivery")
+ public AjaxResult sendDocumentByEmail(@RequestBody BookSendVO bookSendVO){
+ return adjudicationService.sendDocumentByEmail(bookSendVO.getId(),bookSendVO.getAppEmail(),bookSendVO.getResEmail(),bookSendVO.getApptrackingNum(),bookSendVO.getRestrackingNum());
+ }
+
+ /**
+ * 根据快递单号查询物流信息
+ * @param caseApplication
+ * @return
+ */
+ @GetMapping("/logistics")
+ @PreAuthorize("@ss.hasPermi('delivery:detail')")
+ public AjaxResult getLogisticsInfo(CaseApplication caseApplication){
+ List logisticsInfo = adjudicationService.getLogisticsInfo(caseApplication);
+ return AjaxResult.success(logisticsInfo);
+ }
+
+ /**
+ * 签名(暂时只改案件状态)
+ * @param caseApplication
+ * @return
+ */
+ @PostMapping("/signature")
+ @PreAuthorize("@ss.hasPermi('awardManagement:list:sign')")
+ public AjaxResult signature(@Validated @RequestBody CaseApplication caseApplication){
+ return adjudicationService.signature(caseApplication);
+ }
+
+ /**
+ * 归档(暂时只改案件状态)
+ * @param caseApplication
+ * @return
+ */
+ @PostMapping("/caseFile")
+ @PreAuthorize("@ss.hasPermi('awardManagement:list:file')")
+ public AjaxResult caseFile(@Validated @RequestBody CaseApplication caseApplication){
+ return adjudicationService.caseFile(caseApplication);
+ }
+
+ /**
+ * 送达(不包含发送电子邮件)
+ * @param bookSendVO
+ * @return
+ */
+ @PostMapping("/service")
+ @PreAuthorize("@ss.hasPermi('awardManagement:list:sendaward')")
+ public AjaxResult service(@RequestBody BookSendVO bookSendVO){
+ return adjudicationService.service(bookSendVO.getId(),bookSendVO.getAppEmail(),bookSendVO.getResEmail(),bookSendVO.getApptrackingNum(),bookSendVO.getRestrackingNum());
+ }
+ /**
+ * 用印(暂时只改案件状态)
+ * @param caseApplication
+ * @return
+ */
+ @PostMapping("/stamp")
+ @PreAuthorize("@ss.hasPermi('awardManagement:list:signprint')")
+ public AjaxResult stamp(@Validated @RequestBody CaseApplication caseApplication){
+ return adjudicationService.stamp(caseApplication);
+ }
+
+ /**
+ * 档案详情查询
+ * @param id 案件id
+ * @return
+ */
+ @GetMapping("/archives")
+ public AjaxResult getArchivesDetail(Long id){
+ return adjudicationService.getArchivesDetail(id);
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java
new file mode 100644
index 0000000..b87089a
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java
@@ -0,0 +1,41 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
+import com.ruoyi.wisdomarbitrate.service.IArbitratorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/arbitrator")
+public class ArbitratorController extends BaseController {
+ @Autowired
+ private IArbitratorService arbitratorService;
+
+ /**
+ * 查询仲裁员信息
+ */
+// @PreAuthorize("@ss.hasPermi('arbitrator:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(Arbitrator arbitrator)
+ {
+ startPage();
+ List list = arbitratorService.selectArbitratorList(arbitrator);
+ return getDataTable(list);
+ }
+
+
+
+
+
+
+
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java
new file mode 100644
index 0000000..de992f1
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java
@@ -0,0 +1,214 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.annotation.Anonymous;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
+import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+
+@RestController
+@RequestMapping("/caseApplication")
+public class CaseApplicationController extends BaseController {
+ @Autowired
+ private ICaseApplicationService caseApplicationService;
+
+
+ /**
+ * 查询立案数据
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(CaseApplication caseApplication) {
+ startPage();
+ List list = caseApplicationService.selectCaseApplicationList(caseApplication);
+ return getDataTable(list);
+ }
+
+ /**
+ * 新增立案数据
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:add')")
+ @Log(title = "新增立案数据", businessType = BusinessType.INSERT)
+ @PostMapping("/addCaseApplication")
+ public AjaxResult addCaseApplication(@Validated @RequestBody CaseApplication caseApplication)
+ {
+
+ caseApplication.setCreateBy(getUsername());
+ return toAjax(caseApplicationService.insertcaseApplication(caseApplication));
+ }
+
+ /**
+ * 修改立案数据
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:update')")
+ @Log(title = "修改立案数据", businessType = BusinessType.UPDATE)
+ @PostMapping("/editCaseApplication")
+ public AjaxResult editCaseApplication(@Validated @RequestBody CaseApplication caseApplication) {
+
+ caseApplication.setUpdateBy(getUsername());
+ return toAjax(caseApplicationService.editCaseApplication(caseApplication));
+ }
+
+ /**
+ * 提交立案申请
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:submit')")
+ @Log(title = "提交立案申请", businessType = BusinessType.UPDATE)
+ @PostMapping("/submitCaseApplication")
+ public AjaxResult submitCaseApplication(@Validated @RequestBody CaseApplication caseApplication) {
+
+ return toAjax(caseApplicationService.submitCaseApplication(caseApplication));
+ }
+
+ /**
+ * 删除立案数据
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:delete')")
+ @Log(title = "删除立案数据", businessType = BusinessType.DELETE)
+ @PostMapping("/removeCaseApplication")
+ public AjaxResult removeCaseApplication(@Validated @RequestBody CaseApplication caseApplication) {
+
+ return toAjax(caseApplicationService.deletecaseApplicationByIds(caseApplication));
+ }
+
+ /**
+ * 查询立案信息
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:detail')")
+ @PostMapping("/selectCaseApplication")
+ public AjaxResult selectCaseApplication(@Validated @RequestBody CaseApplication caseApplication) {
+ CaseApplication caseApplicationselect = caseApplicationService.selectCaseApplication(caseApplication);
+ return success(caseApplicationselect);
+ }
+
+ /**
+ * 立案申请导入模板下载
+ */
+ @PostMapping("/importTemplate")
+ public void importTemplate(HttpServletResponse response) {
+ ExcelUtil util = new ExcelUtil(CaseApplication.class);
+ util.importTemplateExcel(response, "立案申请数据");
+ }
+
+ @Log(title = "立案信息导入", businessType = BusinessType.IMPORT)
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:import')")
+ @PostMapping("/importData")
+ public AjaxResult importData(MultipartFile file) throws Exception {
+ if(file==null){
+ return warn("请上传文件");
+ }
+ ExcelUtil util = new ExcelUtil(CaseApplication.class);
+ List caseApplicationList = util.importExcel(file.getInputStream());
+ String operName = getUsername();
+ String message = caseApplicationService.importCaseApplication(caseApplicationList, operName);
+ return success(message);
+ }
+
+ /**
+ * 组庭
+ */
+ @PreAuthorize("@ss.hasPermi('caseApplication:pendTral')")
+ @Log(title = "组庭", businessType = BusinessType.UPDATE)
+ @PostMapping("/pendTral")
+ public AjaxResult pendTral(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.pendTral(caseApplication));
+ }
+
+ /**
+ * 组庭审核
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:checkgroup')")
+ @Log(title = "组庭审核", businessType = BusinessType.UPDATE)
+ @PostMapping("/pendTralCheck")
+ public AjaxResult pendTralCheck(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.pendTralCheck(caseApplication));
+ }
+
+ /**
+ * 组庭确认
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:confirmgroup')")
+ @Log(title = "组庭确认", businessType = BusinessType.UPDATE)
+ @PostMapping("/pendTralSure")
+ public AjaxResult pendTralSure(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.pendTralSure(caseApplication));
+ }
+
+ /**
+ * 核验裁决书
+ */
+ @PreAuthorize("@ss.hasPermi('caseApplication:verificationArbitrateRecord')")
+ @Log(title = "核验裁决书", businessType = BusinessType.UPDATE)
+ @PostMapping("/verificationArbitrateRecord")
+ public AjaxResult verificationArbitrateRecord(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.verificationArbitrateRecord(caseApplication));
+ }
+
+ /**
+ * 审核裁决书
+ */
+ @PreAuthorize("@ss.hasPermi('caseApplication:checkArbitrateRecord')")
+ @Log(title = "审核裁决书", businessType = BusinessType.UPDATE)
+ @PostMapping("/checkArbitrateRecord")
+ public AjaxResult checkArbitrateRecord(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.checkArbitrateRecord(caseApplication));
+ }
+
+
+ /**
+ * 是否指派仲裁员
+ */
+ @PreAuthorize("@ss.hasPermi('caseApplication:pendingAppointArbotrar')")
+ @Log(title = "是否指派仲裁员", businessType = BusinessType.UPDATE)
+ @PostMapping("/pendingAppointArbotrar")
+ public AjaxResult pendingAppointArbotrar(@Validated @RequestBody CaseApplication caseApplication) {
+ return toAjax(caseApplicationService.pendingAppointArbotrar(caseApplication));
+ }
+
+ /**
+ * 提交立案审查
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:check')")
+ @Log(title = "提交立案审查", businessType = BusinessType.UPDATE)
+ @PostMapping("/submitCaseApplicationCheck")
+ public AjaxResult submitCaseApplicationCheck(@Validated @RequestBody CaseApplication caseApplication) {
+
+ return toAjax(caseApplicationService.submitCaseApplicationCheck(caseApplication));
+ }
+
+ /**
+ * 确认缴费查询立案信息
+ */
+ @PreAuthorize("@ss.hasPermi('paymentManagement:list:detail')")
+ @PostMapping("/selectCaseApplicationConfirm")
+ public AjaxResult selectCaseApplicationConfirm(@Validated @RequestBody CaseApplication caseApplication) {
+ CaseApplication caseApplicationselect = caseApplicationService.selectCaseApplicationConfirm(caseApplication);
+ return success(caseApplicationselect);
+ }
+
+
+ /**
+ * 发送房间号短信
+ */
+ @Anonymous
+ @PostMapping("/sendRoomNoMessage")
+ public AjaxResult sendRoomNoMessage(@Validated @RequestBody SendRoomNoMessageVO messageVO) {
+ String result = caseApplicationService.sendRoomNoMessage(messageVO);
+ return success(result);
+ }
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java
new file mode 100644
index 0000000..20c5b17
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java
@@ -0,0 +1,42 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.service.ICaseArbitrateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/arbitrate")
+public class CaseArbitrateController extends BaseController {
+ @Autowired
+ private ICaseArbitrateService caseArbitrateService;
+
+ /**
+ * 审核仲裁方式
+ * @param caseApplication
+ * @param opinion 1同意,0拒绝
+ * @return
+ */
+ @PutMapping("/method")
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:checkarbitrationway')")
+ public AjaxResult examineArbitrateMethod(@Validated @RequestBody CaseApplication caseApplication
+ ,Integer opinion){
+ return caseArbitrateService.examineArbitrateMethod(caseApplication,opinion);
+ }
+
+ /**
+ * 书面审理
+ * @param arbitrateRecord
+ * @return
+ */
+ @PostMapping("/writtenHear")
+ @PreAuthorize("@ss.hasPermi('caseManagement:hear')")
+ public AjaxResult writtenHear(@Validated @RequestBody ArbitrateRecord arbitrateRecord){
+ return caseArbitrateService.writtenHear(arbitrateRecord);
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java
new file mode 100644
index 0000000..3a408ca
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java
@@ -0,0 +1,96 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.domain.dto.CaseEvidenceDTO;
+import com.ruoyi.wisdomarbitrate.domain.vo.CaseEvidenceVO;
+import com.ruoyi.wisdomarbitrate.service.ICaseEvidenceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 案件证据
+ */
+@RestController
+@RequestMapping("/evidence")
+public class CaseEvidenceController extends BaseController {
+ private final ICaseEvidenceService caseEvidenceService;
+
+ @Autowired
+ public CaseEvidenceController(ICaseEvidenceService caseEvidenceService) {
+ this.caseEvidenceService = caseEvidenceService;
+ }
+
+ /**
+ * 根据案件id查询案件详情
+ *
+ * @param id
+ * @return
+ */
+ @GetMapping("/{id}")
+ public AjaxResult getCaseDetailsById(@PathVariable Long id) {
+ String username = this.getUsername();
+ return caseEvidenceService.getCaseDetailsById(id, username);
+ }
+
+ /**
+ * 案件证据上传
+ *
+ * @param file 附件
+ * @param annexType 附件类型,立案申请书(1)、证据材料(2)、仲裁文书(3)、案件视频(4)、身份证件(5)
+ * @param id 案件申请id
+ * @return
+ */
+ @PostMapping("/upload")
+ public AjaxResult uploadEvidence(@RequestParam("file") MultipartFile file, Integer annexType, Long id) {
+ String username = this.getUsername();
+ Long userId = this.getUserId();
+ return caseEvidenceService.uploadEvidence(file, annexType, id, username, userId);
+ }
+
+ /**
+ * 查询当前用户案件列表
+ *
+ * @param identityNum
+ * @return
+ */
+ @GetMapping("/all")
+ public TableDataInfo getCaseListAll(@RequestParam(required = false) String identityNum) {
+ startPage();
+ List list = caseEvidenceService.getCaseListAll(identityNum);
+ if (list != null) {
+ return getDataTable(list);
+ }
+ return getDataTable(new ArrayList<>());
+ }
+
+ /**
+ * 证据确认
+ *
+ * @param caseApplication 案件对象
+ * @return 统一返回结果
+ */
+ @PutMapping("/confirm")
+ public AjaxResult evidenceConfirmation(@Validated @RequestBody CaseApplication caseApplication) {
+ return caseEvidenceService.evidenceConfirmation(caseApplication);
+ }
+
+ /**
+ * 案件质证
+ *
+ * @param caseEvidenceDTO
+ * @return
+ */
+ @PostMapping("/crossexami")
+ public AjaxResult caseCrossexamination(@Validated @RequestBody CaseEvidenceDTO caseEvidenceDTO) {
+ return caseEvidenceService.caseCrossexamination(caseEvidenceDTO);
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java
new file mode 100644
index 0000000..8fd1ee0
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java
@@ -0,0 +1,40 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord;
+import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/caseLogRecord")
+public class CaseLogRecordController extends BaseController {
+ @Autowired
+ private ICaseLogRecordService caseLogRecordService;
+
+ /**
+ * 查询案件日志列表
+ */
+ @PreAuthorize("@ss.hasPermi('caseLog:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(CaseLogRecord caseLogRecord)
+ {
+ startPage();
+ List list = caseLogRecordService.selectCaseLogRecordList(caseLogRecord);
+ return getDataTable(list);
+ }
+
+
+
+
+
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java
new file mode 100644
index 0000000..5f13ee7
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java
@@ -0,0 +1,44 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
+import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
+import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 缴费支付
+ */
+@RestController
+@RequestMapping("/pay")
+public class CasePaymentController {
+ private final ICasePaymentService paymentService;
+ @Autowired
+ public CasePaymentController(ICasePaymentService paymentService){
+ this.paymentService=paymentService;
+ }
+ /**
+ * 案件缴费
+ * @param casePayDTO 缴费传入参数
+ * @return 统一响应结果
+ */
+ @PreAuthorize("@ss.hasPermi('caseManagement:list:pay')")
+ @PostMapping("/casePay")
+ public AjaxResult casePay(@Validated @RequestBody CasePayDTO casePayDTO) {
+ return paymentService.casePay(casePayDTO);
+ }
+
+ /**
+ * 缴费确认
+ * @param caseApplication
+ * @return
+ */
+ @PreAuthorize("@ss.hasPermi('paymentManagement:list:payconfirm')")
+ @PutMapping("/confirm")
+ public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) {
+ return paymentService.confirmPayment(caseApplication);
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java
new file mode 100644
index 0000000..7260847
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java
@@ -0,0 +1,40 @@
+package com.ruoyi.web.controller.wisdomarbitrate;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
+import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+@RestController
+@RequestMapping("/identityAuthentication")
+public class IdentityAuthenticationController extends BaseController {
+ @Autowired
+ private IdentityAuthenticationService identityAuthenticationService;
+
+ /**
+ * 获取EIDtoken
+ */
+ @PostMapping("/selectIdentityAuthenticaEIDtoken")
+ public AjaxResult selectIdentityAuthenticaEIDtoken() {
+ JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken();
+ return success(tokenResult);
+ }
+
+ /**
+ * 小程序人脸核身后查询身份认证结果
+ */
+ @PostMapping("/selectIdentityAuthenticaRespon")
+ public AjaxResult selectIdentityAuthenticaRespon(@Validated @RequestBody IdentityAuthentication ientityAuthentication) {
+ AjaxResult checkResult = identityAuthenticationService.selectIdentityAuthenticaRespon(ientityAuthentication);
+ return checkResult;
+ }
+
+
+}
diff --git a/ruoyi-admin/src/main/resources/alipay_private.key b/ruoyi-admin/src/main/resources/alipay_private.key
new file mode 100644
index 0000000..6a4759b
--- /dev/null
+++ b/ruoyi-admin/src/main/resources/alipay_private.key
@@ -0,0 +1 @@
+MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQC12YM9mR+HFQYTx/fHKHZbgszVtDHDB0B/ysWl3MbcPpGtjcZlDr5aynRMRLaoduRHT++A98IaNVIVGj9RHdXrX2j9I/Uz6fYDH63cdu6FZ6Pk82yPwNZW7pebprbVHInR/7gzsKQWSWEST70BgjCRqlbfAE6xzUZFTeYxciCjptm0rUQ2MC24xRdkvZByIDIYFnQ/AdmSFqNtKDR2WpEV/M8aBjyuPPomRJZ1X8oudWuJIU4ySdas04fCbDxD10TY/wyQcDHXuG1IrQpXme4DOGQeJZ0/aOFphBkDFUyPGfYMmLshOPNdBKi2IqWHPPs4XsV4Rv6+tvTSnMF2uGqHAgMBAAECggEAPa1sifPpcZN74DGupGng2uDeQI1BY3iOM8m+h6b9+61tE4RGifgaMAkCsOuNWE4a1uURwphFyUXUdTvVxdlsuMw/e7w6akUsH5sbCO99rtmcCQdXBtrM1+dMnIpK8LUhOYyWGVIMFVMGDYPmAyD5AC7aEAC2sC+DafYl4RdoYpidq1YxeE7DVw1aQHCI2mKhYjZG+3RDDGDfNFvdyH61MgdYjoGkeXNvARzEXgfWvfiTrHZ3H1SYgvOEHofzKDTrWsQL2dvaEsc55Jiw0AgNUVcgby7al8PUekTJoK3ZvrE3pSWaUirBcqsqWISHjeR7Xx501CHIha8EnZwlnDoM4QKBgQDtnYzwQ5mHg7cRHD8Z6QdTpvBvYSEPesiUT/HeI+AKQKDCVJxKiLvJagc6zZkOzV9bZDS/WLgzXWMyxUb+OTjht0jLWAMcf7NfFp3tPKq9wkmQQ/vQSBQ1lFmO6A4Zq1eoGKeUCB4pKBG6cSM+t8+ruhm7s1ZUt+6EBwCVN/izrQKBgQDD62jIm+6NFErdidUaIrGiFUrzqdR13w6JOexfk+O6Aau3wRqsr7Wz4nqQvVVxGMRpXbOH06zpeiS+vMmjwgO973VoLAmH+hJ0GZz8qj3zA2GEOFWjD2V7tqeRvGkQvz0v46pl+8sBJkrRHLN7DWNYY5NDI+b7exwqcTc/LL19gwJ/a6r4MeZvqvgD+7zQ2uy8ZSs/xzg7wsfgG1QeRIn8+qhOL8AnEZ7jeGCS5hJDSHHGw6KkRA/vZ1bpnBfIE2naXGywj3NR9Zfnry6QYO8cbt+adcRYVghTH/QYoKiFuxvonEKPrIQBJqUBY3ngforLjwTEpEie1cSCT1Dc8sBp8QKBgQCaz8fqzRyBKknGKQXVMxj+JKknRUl3IpzP3o9jLu9BqdRQzSwQzH9d91Y2TQXY6mM5hys35xG5JCUo+vCyj7p5OWCiwjl90yMFzr93/+YXwtIpsoIo6R+d1EUxKZoz+4mT7+hT0dUlwWZZOr6wO3IHBBf3c8UvbqZg+zlWmDnblQKBgEs6jwMkb5zaG2fyBJ7PJUN/8nIz8V+X0SxQfcEqIX0J+EC+7MAgFjcdZFp+lca3Vd9z+8Ksd4rMzMa5y856ositL2NZ+K0fs8i8EBaQPny61OgCFUuXEuv5keB2YuGMSns5FYRWuByrtDXl4PxzKXvq05iKWLKCaCq9v4momvKZ
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/resources/alipay_public.key b/ruoyi-admin/src/main/resources/alipay_public.key
new file mode 100644
index 0000000..21236fb
--- /dev/null
+++ b/ruoyi-admin/src/main/resources/alipay_public.key
@@ -0,0 +1 @@
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhUnjdAKwZApwZEcfq+5L0pa77Vg3mqcoXv+th8RR0SYotkPsH1f2JkbS48ySaSCM6YNWSMNfqp5qdOla2zUJOBnJ/yaBg7s7fVD6V3M2mEog8kCDYGKt/3P4VII3xYl8lFYMQ3IcFRELkxCBBCA8JDKmf5z2R4F/Z/jFFEuOwxaJvp+7Ke9OzZHYdWGNnU6QP8YYLYUeX7VNZLHEuly34ExAw6A+yJkNDsYEho2Lu31QjT2pLh9g+88MlRfiI92iN25O9NVdeM4f5RcpvBPrBQZQs9tlFmALYSFS3prIf3FAobWM+W7iwxT6J25nFIhst1DdJQfIBpaeRUJVTkn99QIDAQAB
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index 06872aa..65f5d96 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
- url: jdbc:mysql://localhost:3306/ruyivue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: ruyivue
- password: rybackproje13689
+ url: jdbc:mysql://121.40.189.20:3306/arbitrate?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false
+ username: root
+ password: root123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index cfe0d50..3e9f5c0 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -9,7 +9,7 @@ ruoyi:
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
- profile: D:/ruoyi/uploadPath
+ profile: /home/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
@@ -18,7 +18,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
- port: 8080
+ port: 9001
servlet:
# 应用的访问路径
context-path: /
@@ -32,7 +32,6 @@ server:
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
-
# 日志配置
logging:
level:
@@ -70,9 +69,9 @@ spring:
# redis 配置
redis:
# 地址
- host: localhost
+ host: 121.40.189.20
# 端口,默认为6379
- port: 6379
+ port: 6389
# 数据库索引
database: 0
# 密码
@@ -89,6 +88,25 @@ spring:
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
+ web:
+ resources:
+ static-locations: file:/home/ruoyi/
+ mail:
+ host: smtp.163.com
+ port: 25
+ username: hjbjava@163.com
+ password: BSRSSEPJWGNNVYYL
+ default-encoding: UTF-8
+ properties:
+ mail:
+ smtp:
+ socketFactoryClass: javax.net.ssl.SSLSocketFactory
+ debug: false
+#上上签配置参数
+ssq:
+ developerId: 1695872832013855470
+ privateKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCiDRuz+dxqkWqHdov0hK+KEWLw/e8MQSqkZZ4c01Yr6cSmQiWyV8Xin0u5S/EA02FWxpjLi1nLriVtOBhZGsoryFmcJrwzSnQ5PORP/HhfcAWFE/Y+3qSQS1OiU7e5wbReCgEUvx4GHZuhdu8cOvq5DG9l33YFZrIEMBTmnf8eKT54STx0tjcKl7U6B6nsiThy3zVtpWXVv6H1HGmxC0KT4EQ388s/PFjrwmk+GFb3EpKCns/GQHf7QrtNz1ZOgCXfgQiQ+91/tcngzUH+zMCIxn5lS+ENAxVI6Ev3W9Y0QHtKwmO4ORVuAskJYzBB2xKI/gw8+PUXNziMAKXuoUAjAgMBAAECggEAd7yHw6vTGUrpE76cGsgPjEzcdoSqpLth7qbG9TWSblAEZXRqtiP0q0ZYhUl/gcSuH5gOPhdw+fZq4RCZrP0GdONMkvxsAtn4lnJPoGpD5wC2k2X0hO+tWJDP8xk4n6BozTNHKTUt0gb+f4eJlapep2xwwy0h30vKLR3504zafEV9j/2D8l5TFSv6rd3UVxUvrDKQ9mhfATEUlrTpjs0SfWupMkr4j7TuJJ8qSUSiEADe4hyUB6+LouDZCt8jV4aLojQBJKrQ6VPVdDFkHGsePu4tHtvcKsaOZJ0pjpJ7MT6D5ElD/sJjo0g/3qK5/FToVFVbrxtykVreK6mE5oSTQQKBgQDpEFSgH1d4N7NsZhviaCIUkB97hO0jpRbD7UZirzZ9ok96Fk+SmfhdmypDMoiaRHCNhQuu5dI9mg5RbUhz9mCZnAhzJRL+DmE4bhNvQmbtJA7KT6n/AdH2zy0mYulrcG17dQspvTr/5421PTEE2+FRoCbG6hBsSSUit9HLvAU13QKBgQCx/7ql+hbx+t0Yb02XckBHiA+MWrFLO4dMX9cKf3LldC0nhn0K9HOSoZmM0KcmXRnMo+/4t89xOJRl7JRXwcLoy/64OaUBVv+8FFV1yY4THka3nEnQE40vVWy+vuNJtt+eKlEhJ35N1GIHXo7/4j0POtEuNU7KSqMnLUD+Oy/t/wKBgEiajcJUASuyLnLWXFlrlzJQs34HKtiv1Se0Avk7G/6HUbr2uFMzI+wFKmVEmMl2CJoNmFYjwhruowc6xBdb6TvxH7C/G+uJD0BFCkjeprG5SeI8bvjB2GbKo4YRyiVuIK0VCSU3jemqeLq9FUguN0L2YR4WTIdvQeJO4UxWhkkBAoGBAJk7TxDHZK1XirIYTzGK928c4FWxVWMwkd7buqGc6epBwwV9r3OY0U1vtGIW1W4fQ7B5iIISqpALZyT/Lw0FDqedxWAOr8+hd3IQBynpI1et/q7d6mUoD6ip332tkrjIp2TfhQwHlaGmreUuL+h0eJ/9wEoJNhTLf/yf5o11omM9AoGBAOLVlXR9FbU2Ubpp3HwTumSzKDWzq3T5eQcqC1zE3BPOo29uAf9BQTumPxe51U64egttW/nif5FH4v4Gentmxb2B2ckdOs/u9zIWz3JPfHU7RqMyMokuWrQ6lMoiSYpH3MSHoavLyAEhAnpceX3oktXgpYHO9d8MfON3XKJl23ip
+ serverHost: https://openapi.bestsign.info/openapi/v2/
# token配置
token:
@@ -129,3 +147,23 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
+#支付相关配置
+elegent:
+ pay:
+ wxpay:
+ mchId: 1561414331
+ appId: wx6592a2db3f85ed25
+ appSecret: d9a9ff00a633cd7353a8925119063b01
+ mchSerialNo: 25FBDE3EFD31B03A4377EB9A4A47C517969E6620
+ apiV3Key: CZBK51236435wxpay435434323FFDuv3
+ alipay:
+ appId: 2021003141676135
+ callback:
+ domain: http://121.40.189.20:9001/
+ watch: true
+ cycle: 10
+identityAuthentication:
+ credentialSecretId: AKID3xfHgroY4MQHvLXUXMwIQL1UjmbBX1Tv
+ credentialSecretKey: INDrIXcT8YmomZBcsy0oNirnU0LTN4X7
+ merchantId: 0NSJ2309281116194321
+ privateKeyHexDecodeinfo: 4c3b311bf7b98969994e85928e069574a1e95777f24d1c510679cc3c2f460faf
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/resources/wxpay_private.key b/ruoyi-admin/src/main/resources/wxpay_private.key
new file mode 100644
index 0000000..d4be12f
--- /dev/null
+++ b/ruoyi-admin/src/main/resources/wxpay_private.key
@@ -0,0 +1 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDBHGgIh80193GhdpD1LtMZfTRpcWI0fImyuBCyrd3gYb3rrsARebGcHdJsQA3mVjVqVp5ybhEZDPa4ecoK4Ye1hTppNpI/lmLt4/uUV/zhF5ahli7hi+116Ty6svHSbuMQBuUZeTFOwGrxjvofU/4pGIwh8ZvkcSnyOp9uX2177UVxDBkhgbZbJp9XF2b83vUa5eHo93CziPzn3hFdAlBCdTXB7DH+m0nN3Jou0szGukvq7cIgGpHku4ycKSTkIhhl9WRhN6OoSEJxq88MXzjkzTruc85PHN52aUTUifwg3T8Y4XqFQ61dTnEmgxeD2O6/pLdB9gLsp6yCGqN5Lqk7AgMBAAECggEBAL4X+WzUSbSjFS9NKNrCMjm4H1zgqTxjj6TnPkC1mGEltjAHwLgzJBw62wWGdGhWWpSIGccpBBm1wjTMZpAZfF66fEpP1t1Ta6UjtGZNyvfFIZmE3jdWZ/WXGBnsxtFQKKKBNwrBW0Fbdqq9BQjLxLitmlxbmwrgPttcy855j6vZqq4MBT1v8CtUT/gz4UWW2xWovVnmWOrRSScv7Nh0pMbRpPLkNHXrBwSSNz/keORzXB9JSm85wlkafa7n5/IJbdTml3A/uAgW3q3JZZQotHxQsYvD4Zb5Cnc9CPAXE5L2Yk877kVXZMGt5QPIVcPMj/72AMtaJT67Y0fN0RYHEGkCgYEA38BIGDY6pePgPbxB7N/l6Df0/OKPP0u8mqR4Q0aQD3VxeGiZUN1uWXEFKsKwlOxLfIFIFk1/6zQeC0xetNTKk0gTL8hpMUTNkE7vI9gFWws2LY6DE86Lm0bdFEIwh6d7Fr7zZtyQKPzMsesC3XV9sdSUExEi5o/VwAyf+xZlOXcCgYEA3PGZYlILjg3esPNkhDz2wxFw432i8l/BCPD8ZtqIV9eguu4fVtFYcUVfawBb0T11RamJkc4eiSOqayC+2ehgb+GyRLJNK4FqbFcsIT+CK0HlscZw51jrMR0MxTc4RzuOIMoYDeZqeGB6/YnNyG4pw2sD8bIwHm8406gtJsX/v10CgYAo8g3/aEUZQHcztPS3fU2cTkkl0ev24Ew2XGypmwsX2R0XtMSBuNPNyFHyvkgEKK2zrhDcC/ihuRraZHJcUyhzBViFgP5HBtk7VEaM36YzP/z9Hzw7bqu7kZ85atdoq6xpwC3Yn/o9le17jY8rqamD1mv2hUdGvAGYsHbCQxnpBwKBgHTkeaMUBzr7yZLS4p435tHje1dQVBJpaKaDYPZFrhbTZR0g+IGlNmaPLmFdCjbUjiPyA2+Znnwt227cHz0IfWUUAo3ny3419QkmwZlBkWuzbIO2mms7lwsf9G6uvV6qepKMeVd5TWEsokVbT/03k27pQmfwPxcK/wS0GFdIL/udAoGAOYdDqY5/aadWCyhzTGI6qXPLvC+fsJBPhK2RXyc+jYV0KmrEv4ewxlK5NksuFsNkyB7wlI1oMCa/xB3T/2vTBALgGFPi8BJqceUjtnTYtI4R2JIVEl08RtEJwyU5JZ2rvWcilsotVZYwfuLZ9KfdhkTrgNxlp/KKkr+UuKce4Vs=
\ No newline at end of file
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 71fea1e..b0c399b 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -52,19 +52,19 @@
org.apache.commons
commons-lang3
-
+
com.fasterxml.jackson.core
jackson-databind
-
+
-
- com.baomidou
- dynamic-datasource-spring-boot-starter
- 3.5.2
-
+
+ com.baomidou
+ dynamic-datasource-spring-boot-starter
+ 3.5.2
+
@@ -126,6 +126,69 @@
javax.servlet-api
+
+ org.projectlombok
+ lombok
+ 1.18.22
+
+
+
+
+ com.tencentcloudapi
+ tencentcloud-sdk-java
+ 3.1.876
+
+
+
+ com.tencentcloudapi
+ tencentcloud-sdk-java-faceid
+ 3.1.875
+
+
+
+ cn.hutool
+ hutool-all
+ 5.7.15
+
+
+
+ org.bouncycastle
+ bcprov-jdk15to18
+ 1.69
+
+
+
+
+ com.deepoove
+ poi-tl
+ 1.9.1
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-mail
+ 3.1.4
+
+
+
+ javax.activation
+ activation
+ 1.1.1
+
+
+
+
+ javax.mail
+ mail
+ 1.4.7
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+
\ No newline at end of file
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java
new file mode 100644
index 0000000..f9888e2
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java
@@ -0,0 +1,13 @@
+package com.ruoyi.common.config;
+
+public class EsignDemoConfig {
+
+ // 应用ID
+ public static final String EsignAppId = "7438987614";
+ // 应用密钥
+ public static final String EsignAppSecret = "9d7844f13830931037772b9d20cf1529";
+ // e签宝接口调用域名(模拟环境)
+ public static final String EsignHost = "https://smlopenapi.esign.cn";
+ // e签宝接口调用域名(正式环境)
+ // public static final String EsignHost = "https://openapi.esign.cn";
+}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java
new file mode 100644
index 0000000..d4bcb6e
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java
@@ -0,0 +1,53 @@
+package com.ruoyi.common.constant;
+/**
+ * 立案申请案件状态
+ *
+ */
+public class CaseApplicationConstants {
+ /** 立案申请 */
+ public static final int CASE_APPLICATION = 0;
+ /** 待立案审查 */
+ public static final int CASE_CHECK = 1;
+ /** 待缴费 */
+ public static final int PENDING_PAYMENT = 2;
+ /** 待缴费确认 */
+ public static final int PENDING_PAYMENT_CONFIRM = 3;
+ /** 待案件质证 */
+ public static final int CASE_CROSSEXAMI = 4;
+
+ /** 待组庭 */
+ public static final int PENDING_TRIAL = 26;
+ /** 待组庭审核 */
+ public static final int CONFIRMDED_PENDING_TRIAL_SUBMMIT = 5;
+ /** 待组庭确定 */
+ public static final int CONFIRMDED_PENDING_TRIAL = 6;
+
+ /** 待审核仲裁方式 */
+ public static final int CHECK_ARBITRATION_METHOD = 7;
+ /** 待开庭审理 */
+ public static final int PENDING_OPENCOURT_HEAR = 8;
+ /** 待书面审理 */
+ public static final int PENDING_WRIITEN_HEAR = 9;
+ /** 待生成仲裁文书 */
+ public static final int GENERATED_ARBITRATION = 10;
+ /**待核验仲裁文书*/
+ public static final int VERPRIF_ARBITRATION = 11;
+ /**待审核仲裁文书*/
+ public static final int CHECK_ARBITRATION = 12;
+ /**待仲裁文书签名*/
+ public static final int SIGN_ARBITRATION = 13;
+ /** 待仲裁文书用印 */
+ public static final int ARBITRATED_SEAL = 14;
+ /** 待仲裁文书送达 */
+ public static final int ARBITRATION_DELIVERY = 15;
+ /** 待案件归档*/
+ public static final int CASE_FILING = 16;
+ /** 已归档*/
+ public static final int CASE_ARCHIVED = 17;
+
+
+
+
+
+
+}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java
new file mode 100644
index 0000000..ade398b
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java
@@ -0,0 +1,371 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package com.ruoyi.common.constant;
+import com.ruoyi.common.exception.EsignDemoException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.text.Collator;
+import java.text.MessageFormat;
+import java.util.*;
+
+/**
+ * @description 请求数据通用处理类
+ * @author 澄泓
+ * @date 2020年10月22日 下午14:25:31
+ * @since JDK1.7
+ */
+public class EsignEncryption {
+
+ /**
+ * 不允许外部创建实例
+ */
+ private EsignEncryption(){}
+
+ /**
+ * 拼接待签名字符串
+ * @param httpMethod
+ * @param url
+ * @return
+ */
+ public static String appendSignDataString(String httpMethod, String contentMd5,String accept,String contentType,String headers,String date, String url) throws EsignDemoException {
+ StringBuffer sb = new StringBuffer();
+ sb.append(httpMethod).append("\n").append(accept).append("\n").append(contentMd5).append("\n")
+ .append(contentType).append("\n");
+
+ if ("".equals(date) || date == null) {
+ sb.append("\n");
+ } else {
+ sb.append(date).append("\n");
+ }
+ if ("".equals(headers) || headers == null) {
+ sb.append(url);
+ } else {
+ sb.append(headers).append("\n").append(url);
+ }
+ return new String(sb);
+ }
+
+ /***
+ * Content-MD5的计算方法
+ * @param str 待计算的消息
+ * @return MD5计算后摘要值的Base64编码(ContentMD5)
+ * @throws EsignDemoException 加密过程中的异常信息
+ */
+ public static String doContentMD5(String str) throws EsignDemoException {
+ byte[] md5Bytes = null;
+ MessageDigest md5 = null;
+ String contentMD5 = null;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ // 计算md5函数
+ md5.update(str.getBytes("UTF-8"));
+ // 获取文件MD5的二进制数组(128位)
+ md5Bytes = md5.digest();
+ // 把MD5摘要后的二进制数组md5Bytes使用Base64进行编码(而不是对32位的16进制字符串进行编码)
+ contentMD5 = Base64.encodeBase64String(md5Bytes);
+
+ } catch (NoSuchAlgorithmException e) {
+ EsignDemoException ex = new EsignDemoException("不支持此算法",e);
+ ex.initCause(e);
+ throw ex;
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return contentMD5;
+ }
+
+ /***
+ * 计算请求签名值-HmacSHA256摘要
+ * @param message 待签名字符串
+ * @param secret 密钥APP KEY
+ * @return reqSignature HmacSHA256计算后摘要值的Base64编码
+ * @throws EsignDemoException 加密过程中的异常信息
+ */
+ public static String doSignatureBase64(String message, String secret) throws EsignDemoException {
+ String algorithm = "HmacSHA256";
+ Mac hmacSha256;
+ String digestBase64 = null;
+ try {
+ hmacSha256 = Mac.getInstance(algorithm);
+ byte[] keyBytes = secret.getBytes("UTF-8");
+ byte[] messageBytes = message.getBytes("UTF-8");
+ hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm));
+ // 使用HmacSHA256对二进制数据消息Bytes计算摘要
+ byte[] digestBytes = hmacSha256.doFinal(messageBytes);
+ // 把摘要后的结果digestBytes使用Base64进行编码
+ digestBase64 = Base64.encodeBase64String(digestBytes);
+ } catch (NoSuchAlgorithmException e) {
+ EsignDemoException ex = new EsignDemoException("不支持此算法",e);
+ ex.initCause(e);
+ throw ex;
+ } catch (InvalidKeyException e) {
+ EsignDemoException ex = new EsignDemoException("无效的密钥规范",e);
+ ex.initCause(e);
+ throw ex;
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return digestBase64;
+ }
+
+ /**
+ * 获取时间戳
+ * @return
+ */
+ public static String timeStamp() {
+ long timeStamp = System.currentTimeMillis();
+ return String.valueOf(timeStamp);
+ }
+
+ /**
+ * byte字节数组转换成字符串
+ * @param b
+ * @return
+ */
+ public static String byteArrayToHexString(byte[] b) {
+ StringBuilder hs = new StringBuilder();
+ String stmp;
+ for (int n = 0; b != null && n < b.length; n++) {
+ stmp = Integer.toHexString(b[n] & 0XFF);
+ if (stmp.length() == 1)
+ hs.append('0');
+ hs.append(stmp);
+ }
+ return hs.toString().toLowerCase();
+ }
+
+ /**
+ * hash散列加密算法
+ * @return
+ */
+ public static String Hmac_SHA256(String message,String key) throws EsignDemoException {
+ byte[] rawHmac=null;
+ try {
+ SecretKeySpec sk = new SecretKeySpec(key.getBytes(), "HmacSHA256");
+ Mac mac = Mac.getInstance("HmacSHA256");
+ mac.init(sk);
+ rawHmac = mac.doFinal(message.getBytes());
+ }catch (InvalidKeyException e){
+ EsignDemoException ex = new EsignDemoException("无效的密钥规范",e);
+ ex.initCause(e);
+ throw ex;
+ } catch (NoSuchAlgorithmException e) {
+ EsignDemoException ex = new EsignDemoException("不支持此算法",e);
+ ex.initCause(e);
+ throw ex;
+ }catch (Exception e){
+ EsignDemoException ex = new EsignDemoException("hash散列加密算法报错",e);
+ ex.initCause(e);
+ throw ex;
+ }finally {
+ return byteArrayToHexString(rawHmac);
+ }
+
+ }
+
+ /**
+ * MD5加密32位
+ */
+ public static String MD5Digest(String text) throws EsignDemoException {
+ byte[] digest=null;
+ try {
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+ md5.update(text.getBytes());
+ digest = md5.digest();
+ }catch (NoSuchAlgorithmException e){
+ EsignDemoException ex = new EsignDemoException("不支持此算法",e);
+ ex.initCause(e);
+ throw ex;
+ }finally {
+ return byteArrayToHexString(digest);
+ }
+
+ }
+
+ public static void formDataSort(List param) {
+ Collections.sort(param, new Comparator() {
+ @Override
+ public int compare(BasicNameValuePair o1, BasicNameValuePair o2) {
+ Comparator