Merge branch 'dev' of SH-Arbitrate/Arbitrate-Backend into master
This commit was merged in pull request #99.
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.6</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>pay</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<version>2.7.10</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.72</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-apache-httpclient</artifactId>
|
||||
<version>0.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.34.8.ALL</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String,String> TRADE_STATE = new HashMap<String,String>(){
|
||||
{
|
||||
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";
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String> httpEntity, HttpServletRequest httpRequest) throws TradeException {
|
||||
ValidResponse validResponse=new ValidResponse();
|
||||
try {
|
||||
Map<String, String> 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<String> httpEntity, HttpServletRequest httpRequest) throws TradeException {
|
||||
ValidResponse validResponse=new ValidResponse();
|
||||
|
||||
try {
|
||||
//获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中
|
||||
Map<String, String> 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<String,String> getParams(HttpServletRequest httpServletRequest){
|
||||
Map<String,String> 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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;//检查周期
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.constant;
|
||||
|
||||
/**
|
||||
* Platform
|
||||
* 支付方式
|
||||
*/
|
||||
public class Platform {
|
||||
/**
|
||||
* 微信
|
||||
*/
|
||||
public final static String WX = "wxpay";
|
||||
/**
|
||||
* 支付宝
|
||||
*/
|
||||
public final static String ALI = "alipay";
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String> 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<String> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, ElegentTrade> elegentTradeMap = new HashMap<>();
|
||||
|
||||
private static Map<String, ElegentValid> elegentValidMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
|
||||
//加载所有的交易实现类
|
||||
Collection<ElegentTrade> 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<ElegentValid> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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<String> httpEntity, HttpServletRequest request) throws TradeException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 退款结果通知校验
|
||||
* 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk
|
||||
* 业务编写人员在接收到微信或支付宝回调的时候可以使用该方法验证回调是否成功,是否是伪回调
|
||||
*/
|
||||
ValidResponse validRefund(HttpEntity<String> httpEntity, HttpServletRequest request) throws TradeException;
|
||||
|
||||
|
||||
/**
|
||||
* 成功返回结构
|
||||
* @return
|
||||
*/
|
||||
String successResult();
|
||||
|
||||
|
||||
/**
|
||||
* 失败返回内容
|
||||
* @return
|
||||
*/
|
||||
String failResult();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.core;
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.dto.WatchDTO;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* 监听列表
|
||||
*/
|
||||
public class WatchList {
|
||||
|
||||
|
||||
|
||||
public static CopyOnWriteArraySet<WatchDTO> payList=new CopyOnWriteArraySet<>(); //支付中列表
|
||||
|
||||
public static CopyOnWriteArraySet<WatchDTO> refundList=new CopyOnWriteArraySet<>(); //退款中列表
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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<String,String> expand;//扩展属性
|
||||
|
||||
private String code_url;//二维码连接(native返回)
|
||||
|
||||
private String prepay_id;//预支付Id(小程序返回)
|
||||
|
||||
private String h5_url;//支付跳转链接
|
||||
|
||||
private Map<String,String> jsapiData;//小程序返回
|
||||
|
||||
}
|
||||
@@ -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;//退款金额
|
||||
|
||||
|
||||
}
|
||||
@@ -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;//扩展(全部的返回数据)
|
||||
|
||||
}
|
||||
@@ -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; //退款请求号,做退款幂等性校验,当部分退款时必须给出
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
*/
|
||||
@Data
|
||||
public class ValidResponse {
|
||||
|
||||
private boolean isValid;// 是否通过验签
|
||||
|
||||
private String orderSn;// 订单号
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ruoyi.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WatchDTO {
|
||||
|
||||
private String orderSn; //订单号
|
||||
|
||||
private String platform;//平台
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.key;
|
||||
|
||||
/**
|
||||
* 密钥管理器接口
|
||||
*/
|
||||
public interface KeyManager {
|
||||
|
||||
|
||||
/**
|
||||
* 根据名字获取key字符串
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
String getKey(String name);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> params = new HashMap<String, Object>() {
|
||||
{
|
||||
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<String, Object>() {
|
||||
{
|
||||
put("total", payRequest.getTotalFee());//金额,单位:分
|
||||
put("currency", "CNY");//人民币
|
||||
}
|
||||
});
|
||||
put("description", payRequest.getBody());
|
||||
}
|
||||
};
|
||||
|
||||
if("h5".equals(tradeType)){ //h5
|
||||
params.put("scene_info", new HashMap<String, Object>() {
|
||||
{
|
||||
put("payer_client_ip", "127.0.0.1");
|
||||
put("h5_info", new HashMap<String, Object>() {
|
||||
{
|
||||
put("type", "Wap");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if ("jsapi".equals(tradeType)) { //如果是小程序支付
|
||||
params.put("payer", new HashMap<String, Object>() {
|
||||
{
|
||||
put("openid", payRequest.getOpenid());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
String url = WxpayConstant.createOrder + tradeType; //创建订单
|
||||
log.info("elegent-pay 请求参数{}",params);
|
||||
Map<String, String> 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<String, String> 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<String, Object> params = new HashMap<String, Object>();
|
||||
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<String, Object> params = new HashMap<String, Object>();
|
||||
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<String, Object>() {
|
||||
{
|
||||
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<String, String> params = new HashMap<String, String>();
|
||||
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<String, String> params = new HashMap<String, String>();
|
||||
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<String,String> 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<String, String> 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<String, Object>() {
|
||||
{
|
||||
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<String, String> map = JSON.parseObject(returnBody, Map.class);
|
||||
result = new HashMap<String, Object>() {
|
||||
{
|
||||
put("code", "FAIL");
|
||||
put("message", map.get("message"));
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new HashMap<String, Object>() {
|
||||
{
|
||||
put("code", "FAIL");
|
||||
put("message", e.getMessage());
|
||||
}
|
||||
};
|
||||
} finally {
|
||||
closeConnect(response);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private Map postApiTemplate(String url, Map<String, Object> 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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String> 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<String> 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);
|
||||
}
|
||||
}
|
||||
@@ -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密钥
|
||||
|
||||
}
|
||||
@@ -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<String,Object>(){
|
||||
{
|
||||
put("code", "SUCCESS");
|
||||
}
|
||||
};
|
||||
|
||||
public static final Map FAIL = new HashMap<String,Object>(){
|
||||
{
|
||||
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";
|
||||
}
|
||||
@@ -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
|
||||
@@ -180,6 +180,7 @@
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>pay</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
+5
-1
@@ -60,7 +60,11 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>pay</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
@@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||
@EnableScheduling
|
||||
public class RuoYiApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
|
||||
+33
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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<String> 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<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
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")
|
||||
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<LogisticsInfoVO> 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);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.ruoyi.web.controller.wisdomarbitrate;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
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 ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 查询仲裁员信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('arbitrator:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Arbitrator arbitrator)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = sysUserService.selectUserListByAdRole(arbitrator);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
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.common.exception.EsignDemoException;
|
||||
import com.ruoyi.common.utils.WxAppletNotifyUtils;
|
||||
import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
|
||||
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<CaseApplication> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已签署裁决书URL
|
||||
*/
|
||||
@PostMapping("/selectSignSealUrl")
|
||||
public AjaxResult selectSignSealUrl(@Validated @RequestBody CaseApplication caseApplication) throws EsignDemoException {
|
||||
CaseApplication caseApplicationselect = caseApplicationService.selectSignSealUrl(caseApplication);
|
||||
return success(caseApplicationselect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询签名链接
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('caseManagement:list:selectSignUrl')")
|
||||
@PostMapping("/selectSignUrl")
|
||||
public AjaxResult selectSignUrl(@Validated @RequestBody CaseApplication caseApplication) throws EsignDemoException {
|
||||
SealSignRecord sealSignRecordselect = caseApplicationService.selectSignUrl(caseApplication);
|
||||
return success(sealSignRecordselect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用印链接
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('caseManagement:list:selectSealUrl')")
|
||||
@PostMapping("/selectSealUrl")
|
||||
public AjaxResult selectSealUrl(@Validated @RequestBody CaseApplication caseApplication) throws EsignDemoException {
|
||||
SealSignRecord sealUrlRecordselect = caseApplicationService.selectSealUrl(caseApplication);
|
||||
return success(sealUrlRecordselect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 立案申请导入模板下载
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<CaseApplication> util = new ExcelUtil<CaseApplication>(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<CaseApplication> util = new ExcelUtil<CaseApplication>(CaseApplication.class);
|
||||
List<CaseApplication> 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);
|
||||
}
|
||||
/**
|
||||
* 获取UrlScheme
|
||||
*/
|
||||
@Anonymous
|
||||
@GetMapping("/getUrlScheme")
|
||||
public AjaxResult getUrlScheme() {
|
||||
String schemeUrl = WxAppletNotifyUtils.jumpAppletSchemeUrl();
|
||||
return success(schemeUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成庭审笔录
|
||||
* @param arbitrateRecord
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/creatTrialRecord")
|
||||
@PreAuthorize("@ss.hasPermi('caseManagement:list:creatTrialRecord')")
|
||||
public AjaxResult creatTrialRecord(@Validated @RequestBody ArbitrateRecord arbitrateRecord){
|
||||
return caseApplicationService.creatTrialRecord(arbitrateRecord);
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -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")
|
||||
public AjaxResult writtenHear(@Validated @RequestBody ArbitrateRecord arbitrateRecord){
|
||||
arbitrateRecord.setCreateBy(getUsername());
|
||||
return caseArbitrateService.writtenHear(arbitrateRecord);
|
||||
}
|
||||
}
|
||||
+96
@@ -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<CaseEvidenceVO> 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);
|
||||
}
|
||||
}
|
||||
+40
@@ -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<CaseLogRecord> list = caseLogRecordService.selectCaseLogRecordList(caseLogRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.web.controller.wisdomarbitrate;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.CaseConfirmPayDTO;
|
||||
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 payDTO 缴费传入参数
|
||||
* @return 统一响应结果
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('caseManagement:list:pay')")
|
||||
@PostMapping("/confirmPay")
|
||||
public AjaxResult confirmPay(@Validated @RequestBody CaseConfirmPayDTO payDTO) {
|
||||
return paymentService.confirmPay(payDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缴费确认
|
||||
* @param caseApplication
|
||||
* @return
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('paymentManagement:list:payconfirm')")
|
||||
@PutMapping("/confirm")
|
||||
public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) {
|
||||
return paymentService.confirmPayment(caseApplication);
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhUnjdAKwZApwZEcfq+5L0pa77Vg3mqcoXv+th8RR0SYotkPsH1f2JkbS48ySaSCM6YNWSMNfqp5qdOla2zUJOBnJ/yaBg7s7fVD6V3M2mEog8kCDYGKt/3P4VII3xYl8lFYMQ3IcFRELkxCBBCA8JDKmf5z2R4F/Z/jFFEuOwxaJvp+7Ke9OzZHYdWGNnU6QP8YYLYUeX7VNZLHEuly34ExAw6A+yJkNDsYEho2Lu31QjT2pLh9g+88MlRfiI92iN25O9NVdeM4f5RcpvBPrBQZQs9tlFmALYSFS3prIf3FAobWM+W7iwxT6J25nFIhst1DdJQfIBpaeRUJVTkn99QIDAQAB
|
||||
@@ -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/smart_arbitration?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||
username: root
|
||||
password: YMzc157#
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
||||
@@ -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,31 @@ spring:
|
||||
max-active: 8
|
||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-wait: -1ms
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:/home/ruoyi/
|
||||
mail:
|
||||
host: smtp.163.com
|
||||
port: 25
|
||||
username: lmj1549843951@163.com
|
||||
password: JGIOQVFCLAZKXRKO
|
||||
default-encoding: UTF-8
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
connectiontimeout: 5000
|
||||
timeout: 5000
|
||||
writetimeout: 5000
|
||||
socketFactoryClass: javax.net.ssl.SSLSocketFactory
|
||||
socketFactoryFallback: false
|
||||
socketFactoryPort: 465
|
||||
debug: false
|
||||
protocol: smtp
|
||||
#上上签配置参数
|
||||
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 +153,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
|
||||
@@ -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=
|
||||
+70
-7
@@ -52,19 +52,19 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 动态数据源 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里JSON解析器 -->
|
||||
<dependency>
|
||||
@@ -126,6 +126,69 @@
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 腾讯短信sdk -->
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<version>3.1.876</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-faceid</artifactId>
|
||||
<version>3.1.875</version>
|
||||
</dependency>
|
||||
<!--用户信息解密-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15to18</artifactId>
|
||||
<version>1.69</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi-tl-->
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 发送邮件-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<BasicNameValuePair> param) {
|
||||
Collections.sort(param, new Comparator<BasicNameValuePair>() {
|
||||
@Override
|
||||
public int compare(BasicNameValuePair o1, BasicNameValuePair o2) {
|
||||
Comparator<Object> com = Collator.getInstance(Locale.CHINA);
|
||||
return com.compare(o1.getName(), o2.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
* 字符串是否为空(含空格校验)
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isBlank(String str) {
|
||||
if (null == str || 0 == str.length()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int strLen = str.length();
|
||||
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
if (!Character.isWhitespace(str.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 对请求URL中的Query参数按照字段名的 ASCII 码从小到大排序(字典排序)
|
||||
*
|
||||
* @param apiUrl
|
||||
* @return 排序后的API接口地址
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String sortApiUrl(String apiUrl) throws EsignDemoException {
|
||||
|
||||
if (!apiUrl.contains("?")) {
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
int queryIndex = apiUrl.indexOf("?");
|
||||
String apiUrlPath =apiUrl.substring(0,queryIndex+1);
|
||||
String apiUrlQuery = apiUrl.substring(queryIndex+1);
|
||||
//apiUrlQuery为空时返回
|
||||
if(isBlank(apiUrlQuery)){
|
||||
return apiUrl.substring(0,apiUrl.length()-1);
|
||||
}
|
||||
// 请求URL中Query参数转成Map
|
||||
Map<Object, Object> queryParamsMap = new HashMap<Object, Object>();
|
||||
String[] params = apiUrlQuery.split("&");
|
||||
for (String str : params) {
|
||||
int index = str.indexOf("=");
|
||||
String key = str.substring(0, index);
|
||||
String value = str.substring(index + 1);
|
||||
if (queryParamsMap.containsKey(key)) {
|
||||
String msg = MessageFormat.format("请求URL中的Query参数的{0}重复", key);
|
||||
throw new EsignDemoException(msg);
|
||||
}
|
||||
queryParamsMap.put(key, value);
|
||||
}
|
||||
|
||||
ArrayList<String> queryMapKeys = new ArrayList<String>();
|
||||
for (Map.Entry<Object, Object> entry : queryParamsMap.entrySet()) {
|
||||
queryMapKeys.add((String) entry.getKey());
|
||||
}
|
||||
// 按照字段名的 ASCII 码从小到大排序(字典排序)
|
||||
Collections.sort(queryMapKeys, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return (o1.compareToIgnoreCase(o2) == 0 ? -o1.compareTo(o2) : o1.compareToIgnoreCase(o2));
|
||||
}
|
||||
});
|
||||
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
// 构造Query参数键值对值对的格式
|
||||
for (int i = 0; i < queryMapKeys.size(); i++) {
|
||||
String key = queryMapKeys.get(i);
|
||||
String value = (String) queryParamsMap.get(key);
|
||||
queryString.append(key);
|
||||
queryString.append("=");
|
||||
queryString.append(value);
|
||||
queryString.append("&");
|
||||
}
|
||||
if (queryString.length() > 0) {
|
||||
queryString = queryString.deleteCharAt(queryString.length() - 1);
|
||||
}
|
||||
|
||||
// Query参数排序后的接口请求地址
|
||||
StringBuffer sortApiUrl = new StringBuffer();
|
||||
sortApiUrl.append(apiUrlPath);
|
||||
sortApiUrl.append(queryString.toString());
|
||||
return sortApiUrl.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*获取query
|
||||
* @param apiUrl
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static ArrayList<BasicNameValuePair> getQuery(String apiUrl) throws EsignDemoException {
|
||||
ArrayList<BasicNameValuePair> BasicNameValuePairList = new ArrayList<>();
|
||||
|
||||
if (!apiUrl.contains("?")) {
|
||||
return BasicNameValuePairList;
|
||||
}
|
||||
|
||||
int queryIndex = apiUrl.indexOf("\\?");
|
||||
String apiUrlQuery = apiUrl.substring(queryIndex,apiUrl.length());
|
||||
|
||||
// 请求URL中Query参数转成Map
|
||||
Map<Object, Object> queryParamsMap = new HashMap<Object, Object>();
|
||||
String[] params = apiUrlQuery.split("&");
|
||||
for (String str : params) {
|
||||
int index = str.indexOf("=");
|
||||
String key = str.substring(0, index);
|
||||
String value = str.substring(index + 1);
|
||||
if (queryParamsMap.containsKey(key)) {
|
||||
String msg = MessageFormat.format("请求URL中的Query参数的{0}重复", key);
|
||||
throw new EsignDemoException(msg);
|
||||
}
|
||||
BasicNameValuePairList.add(new BasicNameValuePair(key,value));
|
||||
queryParamsMap.put(key, value);
|
||||
}
|
||||
return BasicNameValuePairList;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static boolean callBackCheck(String timestamp,String requestQuery,String body,String key,String signature){
|
||||
String algorithm="HmacSHA256";
|
||||
String encoding="UTF-8";
|
||||
Mac mac = null;
|
||||
try {
|
||||
String data = timestamp + requestQuery + body;
|
||||
mac = Mac.getInstance(algorithm);
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(encoding), algorithm);
|
||||
mac.init(secretKey);
|
||||
mac.update(data.getBytes(encoding));
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("获取Signature签名信息异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return byte2hex(mac.doFinal()).equalsIgnoreCase(signature);
|
||||
}
|
||||
|
||||
/***
|
||||
* 将byte[]转成16进制字符串
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @return 16进制字符串
|
||||
*/
|
||||
public static String byte2hex(byte[] data) {
|
||||
StringBuilder hash = new StringBuilder();
|
||||
String stmp;
|
||||
for (int n = 0; data != null && n < data.length; n++) {
|
||||
stmp = Integer.toHexString(data[n] & 0XFF);
|
||||
if (stmp.length() == 1)
|
||||
hash.append('0');
|
||||
hash.append(stmp);
|
||||
}
|
||||
return hash.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.common.constant;
|
||||
/**
|
||||
* @description 头部信息常量
|
||||
* @author 澄泓
|
||||
* @date 2020/10/22 15:05
|
||||
* @version JDK1.7
|
||||
*/
|
||||
public enum EsignHeaderConstant {
|
||||
ACCEPT("*/*"),
|
||||
DATE(""),
|
||||
HEADERS( ""),
|
||||
CONTENTTYPE_FORMDATA("application/x-www-form-urlencoded"),
|
||||
CONTENTTYPE_JSON("application/json; charset=UTF-8"),
|
||||
CONTENTTYPE_PDF("application/pdf"),
|
||||
CONTENTTYPE_STREAM("application/octet-stream"),
|
||||
AUTHMODE("Signature");
|
||||
|
||||
private String value;
|
||||
private EsignHeaderConstant(String value) {
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public String VALUE(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
*
|
||||
* 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.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.enums.EsignRequestType;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.client.HttpRequestRetryHandler;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.ConnectTimeoutException;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description Http请求 辅助类
|
||||
* @author 澄泓
|
||||
* @since JDK1.7
|
||||
*/
|
||||
public class EsignHttpCfgHelper {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(EsignHttpCfgHelper.class);
|
||||
/**
|
||||
* 超时时间,默认15000毫秒
|
||||
*/
|
||||
private static int MAX_TIMEOUT = 15000;
|
||||
/**
|
||||
* 请求池最大连接数,默认100个
|
||||
*/
|
||||
private static int MAX_TOTAL=100;
|
||||
/**
|
||||
* 单域名最大的连接数,默认50个
|
||||
*/
|
||||
private static int ROUTE_MAX_TOTAL=50;
|
||||
/**
|
||||
* 请求失败重试次数,默认3次
|
||||
*/
|
||||
private static int MAX_RETRY = 3;
|
||||
/**
|
||||
* 是否需要域名校验,默认不需要校验
|
||||
*/
|
||||
private static boolean SSL_VERIFY=false;
|
||||
|
||||
/**
|
||||
* 正向代理IP
|
||||
*/
|
||||
private static String PROXY_IP;
|
||||
/**
|
||||
* 正向代理端口,默认8888
|
||||
*/
|
||||
private static int PROXY_PORT=8888;
|
||||
/**
|
||||
* 代理协议,默认http
|
||||
*/
|
||||
private static String PROXY_AGREEMENT="http";
|
||||
|
||||
/**
|
||||
* 是否开启代理,默认false
|
||||
*/
|
||||
private static boolean OPEN_PROXY=false;
|
||||
|
||||
/**
|
||||
* 代理服务器用户名
|
||||
*/
|
||||
private static String PROXY_USERNAME="";
|
||||
|
||||
/**
|
||||
* 代理服务器密码
|
||||
*/
|
||||
private static String PROXY_PASSWORD="";
|
||||
|
||||
|
||||
private static PoolingHttpClientConnectionManager connMgr; //连接池
|
||||
private static HttpRequestRetryHandler retryHandler; //重试机制
|
||||
|
||||
private static CloseableHttpClient httpClient=null;
|
||||
|
||||
public static int getMaxTimeout() {
|
||||
return MAX_TIMEOUT;
|
||||
}
|
||||
|
||||
public static void setMaxTimeout(int maxTimeout) {
|
||||
MAX_TIMEOUT = maxTimeout;
|
||||
}
|
||||
|
||||
public static int getMaxTotal() {
|
||||
return MAX_TOTAL;
|
||||
}
|
||||
|
||||
public static void setMaxTotal(int maxTotal) {
|
||||
MAX_TOTAL = maxTotal;
|
||||
}
|
||||
|
||||
public static int getRouteMaxTotal() {
|
||||
return ROUTE_MAX_TOTAL;
|
||||
}
|
||||
|
||||
public static void setRouteMaxTotal(int routeMaxTotal) {
|
||||
ROUTE_MAX_TOTAL = routeMaxTotal;
|
||||
}
|
||||
|
||||
public static int getMaxRetry() {
|
||||
return MAX_RETRY;
|
||||
}
|
||||
|
||||
public static void setMaxRetry(int maxRetry) {
|
||||
MAX_RETRY = maxRetry;
|
||||
}
|
||||
|
||||
public static boolean isSslVerify() {
|
||||
return SSL_VERIFY;
|
||||
}
|
||||
|
||||
public static void setSslVerify(boolean sslVerify) {
|
||||
SSL_VERIFY = sslVerify;
|
||||
}
|
||||
|
||||
public static String getProxyIp() {
|
||||
return PROXY_IP;
|
||||
}
|
||||
|
||||
public static void setProxyIp(String proxyIp) {
|
||||
PROXY_IP = proxyIp;
|
||||
}
|
||||
|
||||
public static int getProxyPort() {
|
||||
return PROXY_PORT;
|
||||
}
|
||||
|
||||
public static void setProxyPort(int proxyPort) {
|
||||
PROXY_PORT = proxyPort;
|
||||
}
|
||||
|
||||
public static String getProxyAgreement() {
|
||||
return PROXY_AGREEMENT;
|
||||
}
|
||||
|
||||
public static void setProxyAgreement(String proxyAgreement) {
|
||||
PROXY_AGREEMENT = proxyAgreement;
|
||||
}
|
||||
|
||||
public static boolean getOpenProxy() {
|
||||
return OPEN_PROXY;
|
||||
}
|
||||
|
||||
public static void setOpenProxy(boolean openProxy) {
|
||||
OPEN_PROXY = openProxy;
|
||||
}
|
||||
|
||||
public static String getProxyUsername() {
|
||||
return PROXY_USERNAME;
|
||||
}
|
||||
|
||||
public static void setProxyUserame(String proxyUsername) {
|
||||
PROXY_USERNAME = proxyUsername;
|
||||
}
|
||||
|
||||
public static String getProxyPassword() {
|
||||
return PROXY_PASSWORD;
|
||||
}
|
||||
|
||||
public static void setProxyPassword(String proxyPassword) {
|
||||
PROXY_PASSWORD = proxyPassword;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 不允许外部创建实例
|
||||
*/
|
||||
private EsignHttpCfgHelper() {
|
||||
}
|
||||
|
||||
//------------------------------公有方法start--------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* @description 发起HTTP / HTTPS 请求
|
||||
*
|
||||
* @param reqType
|
||||
* {@link EsignRequestType} 请求类型 GET、 POST 、 DELETE 、 PUT
|
||||
* @param httpUrl
|
||||
* {@link String} 请求目标地址
|
||||
* @param headers
|
||||
* {@link Map} 请求头
|
||||
* @param param
|
||||
* {@link Object} 参数
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static EsignHttpResponse sendHttp(EsignRequestType reqType, String httpUrl, Map<String, String> headers, Object param, boolean debug)
|
||||
throws EsignDemoException {
|
||||
HttpRequestBase reqBase=null;
|
||||
if(httpUrl.startsWith("http")){
|
||||
reqBase=reqType.getHttpType(httpUrl);
|
||||
}else{
|
||||
throw new EsignDemoException("请求url地址格式错误");
|
||||
}
|
||||
if(debug){
|
||||
LOGGER.info("请求头:{}",headers+"\n");
|
||||
LOGGER.info("请求参数\n{}", param+"\n");
|
||||
LOGGER.info("请求地址\n:{}\n请求方式\n:{}",reqBase.getURI(),reqType+"\n");
|
||||
}
|
||||
//请求方法不是GET或者DELETE时传入body体,否则不传入。
|
||||
String[] methods = {"DELETE", "GET"};
|
||||
if(param instanceof String&&Arrays.binarySearch(methods, reqType.name())<0){//POST或者PUT请求
|
||||
((HttpEntityEnclosingRequest) reqBase).setEntity(
|
||||
new StringEntity(String.valueOf(param), ContentType.create("application/json", "UTF-8")));
|
||||
}
|
||||
//参数时字节流数组
|
||||
else if(param instanceof byte[]) {
|
||||
reqBase=reqType.getHttpType(httpUrl);
|
||||
byte[] paramBytes = (byte[])param;
|
||||
((HttpEntityEnclosingRequest) reqBase).setEntity(new ByteArrayEntity(paramBytes));
|
||||
}
|
||||
//参数是form表单时
|
||||
else if(param instanceof List){
|
||||
((HttpEntityEnclosingRequest) reqBase).setEntity(new UrlEncodedFormEntity((Iterable<? extends NameValuePair>) param));
|
||||
}
|
||||
httpClient = getHttpClient();
|
||||
config(reqBase);
|
||||
|
||||
//设置请求头
|
||||
if(headers != null &&headers.size()>0) {
|
||||
for(Map.Entry<String, String> entry :headers.entrySet()) {
|
||||
reqBase.setHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
//响应对象
|
||||
CloseableHttpResponse res = null;
|
||||
//响应内容
|
||||
String resCtx = null;
|
||||
int status;
|
||||
EsignHttpResponse esignHttpResponse = new EsignHttpResponse();
|
||||
try {
|
||||
//执行请求
|
||||
res = httpClient.execute(reqBase);
|
||||
status=res.getStatusLine().getStatusCode();
|
||||
|
||||
//获取请求响应对象和响应entity
|
||||
HttpEntity httpEntity = res.getEntity();
|
||||
if(httpEntity != null) {
|
||||
resCtx = EntityUtils.toString(httpEntity,"utf-8");
|
||||
}
|
||||
if(debug) {
|
||||
LOGGER.info("响应\n{}", resCtx + "\n");
|
||||
LOGGER.info("----------------------------end------------------------");
|
||||
}
|
||||
} catch (NoHttpResponseException e) {
|
||||
throw new EsignDemoException("服务器丢失了",e);
|
||||
} catch (SSLHandshakeException e){
|
||||
String msg = MessageFormat.format("SSL握手异常", e);
|
||||
EsignDemoException ex = new EsignDemoException(msg, e);
|
||||
throw ex;
|
||||
} catch (UnknownHostException e){
|
||||
EsignDemoException ex = new EsignDemoException("服务器找不到", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch(ConnectTimeoutException e){
|
||||
EsignDemoException ex = new EsignDemoException("连接超时", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch(SSLException e){
|
||||
EsignDemoException ex = new EsignDemoException("SSL异常",e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch (ClientProtocolException e) {
|
||||
EsignDemoException ex = new EsignDemoException("请求头异常",e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("网络请求失败",e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
if(res != null) {
|
||||
try {
|
||||
res.close();
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("--->>关闭请求响应失败",e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
esignHttpResponse.setStatus(status);
|
||||
esignHttpResponse.setBody(resCtx);
|
||||
return esignHttpResponse;
|
||||
}
|
||||
//------------------------------公有方法end----------------------------------------------
|
||||
|
||||
//------------------------------私有方法start--------------------------------------------
|
||||
|
||||
/**
|
||||
* @description 请求头和超时时间配置
|
||||
*
|
||||
* @param httpReqBase
|
||||
* @author 澄泓
|
||||
*/
|
||||
private static void config(HttpRequestBase httpReqBase) {
|
||||
// 配置请求的超时设置
|
||||
RequestConfig.Builder builder = RequestConfig.custom()
|
||||
.setConnectionRequestTimeout(MAX_TIMEOUT)
|
||||
.setConnectTimeout(MAX_TIMEOUT)
|
||||
.setSocketTimeout(MAX_TIMEOUT);
|
||||
if(OPEN_PROXY){
|
||||
HttpHost proxy=new HttpHost(PROXY_IP,PROXY_PORT,PROXY_AGREEMENT);
|
||||
builder.setProxy(proxy);
|
||||
}
|
||||
RequestConfig requestConfig = builder.build();
|
||||
httpReqBase.setConfig(requestConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 连接池配置
|
||||
*
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
private static void cfgPoolMgr() throws EsignDemoException {
|
||||
ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
|
||||
LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
|
||||
if(!SSL_VERIFY){
|
||||
sslsf=sslConnectionSocketFactory();
|
||||
}
|
||||
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", plainsf)
|
||||
.register("https", sslsf)
|
||||
.build();
|
||||
|
||||
//连接池管理器
|
||||
connMgr = new PoolingHttpClientConnectionManager(registry);
|
||||
//请求池最大连接数
|
||||
connMgr.setMaxTotal(MAX_TOTAL);
|
||||
//但域名最大的连接数
|
||||
connMgr.setDefaultMaxPerRoute(ROUTE_MAX_TOTAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description 设置重试机制
|
||||
*
|
||||
* @author 澄泓
|
||||
*/
|
||||
private static void cfgRetryHandler() {
|
||||
retryHandler = new HttpRequestRetryHandler() {
|
||||
|
||||
@Override
|
||||
public boolean retryRequest(IOException e, int excCount, HttpContext ctx) {
|
||||
//超过最大重试次数,就放弃
|
||||
if(excCount > MAX_RETRY) {
|
||||
return false;
|
||||
}
|
||||
//服务器丢掉了链接,就重试
|
||||
if(e instanceof NoHttpResponseException) {
|
||||
return true;
|
||||
}
|
||||
//不重试SSL握手异常
|
||||
if(e instanceof SSLHandshakeException) {
|
||||
return false;
|
||||
}
|
||||
//中断
|
||||
if(e instanceof InterruptedIOException) {
|
||||
return false;
|
||||
}
|
||||
//目标服务器不可达
|
||||
if(e instanceof UnknownHostException) {
|
||||
return false;
|
||||
}
|
||||
//连接超时
|
||||
//SSL异常
|
||||
if(e instanceof SSLException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpClientContext clientCtx = HttpClientContext.adapt(ctx);
|
||||
HttpRequest req = clientCtx.getRequest();
|
||||
//如果是幂等请求,就再次尝试
|
||||
if(!(req instanceof HttpEntityEnclosingRequest)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略域名校验
|
||||
*/
|
||||
private static SSLConnectionSocketFactory sslConnectionSocketFactory() throws EsignDemoException {
|
||||
try {
|
||||
SSLContext ctx = SSLContext.getInstance("TLS"); // 创建一个上下文(此处指定的协议类型似乎不是重点)
|
||||
X509TrustManager tm = new X509TrustManager() { // 创建一个跳过SSL证书的策略
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
||||
}
|
||||
};
|
||||
ctx.init(null, new TrustManager[] { tm }, null); // 使用上面的策略初始化上下文
|
||||
return new SSLConnectionSocketFactory(ctx, new String[] { "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" }, null, NoopHostnameVerifier.INSTANCE);
|
||||
}catch (Exception e){
|
||||
EsignDemoException ex = new EsignDemoException("忽略域名校验失败",e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取单例HttpClient
|
||||
*
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
private static synchronized CloseableHttpClient getHttpClient() throws EsignDemoException {
|
||||
if(httpClient==null) {
|
||||
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||
credsProvider.setCredentials(new AuthScope(PROXY_IP,PROXY_PORT),new UsernamePasswordCredentials(PROXY_USERNAME, PROXY_PASSWORD));
|
||||
cfgPoolMgr();
|
||||
cfgRetryHandler();
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
httpClient = httpClientBuilder.setDefaultCredentialsProvider(credsProvider).setConnectionManager(connMgr).setRetryHandler(retryHandler).build();
|
||||
}
|
||||
return httpClient;
|
||||
|
||||
}
|
||||
//------------------------------私有方法end----------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
*
|
||||
* 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 java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 澄泓
|
||||
* @version JDK1.7
|
||||
* @description 文件转换类
|
||||
* @date 2020/10/26 10:47
|
||||
*/
|
||||
public class FileTransformation {
|
||||
|
||||
/**
|
||||
* 传入本地文件路径转二进制byte
|
||||
*
|
||||
* @param srcFilePath 本地文件路径
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static byte[] fileToBytes(String srcFilePath) throws EsignDemoException {
|
||||
return getBytes(srcFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片转base64
|
||||
*
|
||||
* @param filePath 本地文件路径
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static String fileToBase64(String filePath) throws EsignDemoException {
|
||||
byte[] bytes;
|
||||
String base64 = null;
|
||||
bytes = fileToBytes(filePath);
|
||||
base64 = Base64.encodeBase64String(bytes);
|
||||
base64 = base64.replaceAll("\r\n", "");
|
||||
return base64;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws EsignDemoException {
|
||||
System.out.println(getFileContentMD5("D:\\文档\\PLT2022-02124CT.pdf"));
|
||||
}
|
||||
|
||||
/***
|
||||
* 计算文件内容的Content-MD5
|
||||
* @param filePath 文件路径
|
||||
* @return
|
||||
*/
|
||||
public static String getFileContentMD5(String filePath) throws EsignDemoException {
|
||||
// 获取文件MD5的二进制数组(128位)
|
||||
byte[] bytes = getFileMD5Bytes128(filePath);
|
||||
// 对文件MD5的二进制数组进行base64编码
|
||||
return new String(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param httpUrl 网络文件地址url
|
||||
* @return
|
||||
*/
|
||||
public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException {
|
||||
InputStream fis = null;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
URL url = new URL(httpUrl);
|
||||
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
||||
httpConn.connect();
|
||||
fis = httpConn.getInputStream();
|
||||
fileOutputStream = new FileOutputStream(new File(dir));
|
||||
byte[] md5Bytes = null;
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = -1;
|
||||
while ((length = fis.read(buffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(buffer, 0, length);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
try {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
if (fileOutputStream != null) {
|
||||
fileOutputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 网络文件转二进制MD5数组并获取文件大小
|
||||
*
|
||||
* @param fileUrl 网络文件地址url
|
||||
* @return
|
||||
*/
|
||||
public static Map fileUrlToBytes(String fileUrl) throws EsignDemoException {
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
URL url = new URL(fileUrl);
|
||||
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
||||
httpConn.connect();
|
||||
InputStream fis = httpConn.getInputStream();
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
outStream.close();
|
||||
map.put("fileSize", fis.available());
|
||||
byte[] md5Bytes = null;
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = -1;
|
||||
while ((length = fis.read(buffer, 0, 1024)) != -1) {
|
||||
md5.update(buffer, 0, length);
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
md5Bytes = md5.digest();
|
||||
byte[] fileData = outStream.toByteArray();
|
||||
map.put("fileData", fileData);
|
||||
outStream.close();
|
||||
fis.close();
|
||||
map.put("md5Bytes", md5Bytes);
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
EsignDemoException ex = new EsignDemoException("文件计算异常", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取文件MD5的二进制数组(128位)
|
||||
* @param filePath
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static byte[] getFileMD5Bytes128(String filePath) throws EsignDemoException {
|
||||
FileInputStream fis = null;
|
||||
byte[] md5Bytes = null;
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
fis = new FileInputStream(file);
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = -1;
|
||||
while ((length = fis.read(buffer, 0, 1024)) != -1) {
|
||||
md5.update(buffer, 0, length);
|
||||
}
|
||||
md5Bytes = md5.digest();
|
||||
fis.close();
|
||||
} catch (FileNotFoundException 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 (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("输入流或输出流异常", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("关闭文件输入流失败", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return md5Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
* @description 根据文件路径,获取文件base64
|
||||
* @author 宫清
|
||||
* @date 2019年7月21日 下午4:22:08
|
||||
*/
|
||||
public static String getBase64Str(String path) throws EsignDemoException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(new File(path));
|
||||
byte[] bytes = new byte[is.available()];
|
||||
is.read(bytes);
|
||||
return Base64.encodeBase64String(bytes);
|
||||
} catch (Exception e) {
|
||||
EsignDemoException ex = new EsignDemoException("获取文件输入流失败", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("关闭文件输入流失败", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path 文件路径
|
||||
* @return
|
||||
* @description 获取文件名称
|
||||
* @author 宫清
|
||||
* @date 2019年7月21日 下午8:21:16
|
||||
*/
|
||||
public static String getFileName(String path) {
|
||||
return new File(path).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePath {@link String} 文件地址
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
* @description 获取文件字节流
|
||||
* @date 2019年7月10日 上午9:17:00
|
||||
* @author 宫清
|
||||
*/
|
||||
public static byte[] getBytes(String filePath) throws EsignDemoException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream fis = null;
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
buffer = new byte[(int) file.length()];
|
||||
fis.read(buffer);
|
||||
} catch (Exception e) {
|
||||
EsignDemoException ex = new EsignDemoException("获取文件字节流失败", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
EsignDemoException ex = new EsignDemoException("关闭文件字节流失败", e);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +1,117 @@
|
||||
package com.ruoyi.common.core.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class BaseEntity implements Serializable
|
||||
{
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 搜索值 */
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||
private Date updateTime;
|
||||
|
||||
/** 备注 */
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue()
|
||||
{
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue)
|
||||
{
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark()
|
||||
{
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark)
|
||||
{
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams()
|
||||
{
|
||||
if (params == null)
|
||||
{
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params)
|
||||
{
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
/**
|
||||
* esignSDK-core信息类
|
||||
* @author 澄泓
|
||||
* @date 2022/2/22 13:59
|
||||
* @version
|
||||
*/
|
||||
public class EsignCoreSdkInfo {
|
||||
private static final String SdkVersion="Esign-Sdk-Core1.0";
|
||||
private static final String SupportedVersion="JDK1.7 MORE THAN";
|
||||
|
||||
private static final String Info="sdk-esign-api核心工具包,主要处理e签宝公有云产品接口调用时的签名计算以及网络请求,通过EsignHttpHelper.signAndBuildSignAndJsonHeader构造签名鉴权+json数据格式的请求头,通过HttpHelper.doCommHttp方法入参发起网络请求。让开发者无需关注具体的请求签名算法,专注于接口业务的json参数构造";
|
||||
public static String getSdkVersion() {
|
||||
return SdkVersion;
|
||||
}
|
||||
|
||||
public static String getInfo() {
|
||||
return Info;
|
||||
}
|
||||
|
||||
public static String getSupportedVersion() {
|
||||
return SupportedVersion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
/**
|
||||
* 网络请求的response类
|
||||
*/
|
||||
public class EsignHttpResponse {
|
||||
private int status;
|
||||
private String body;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,14 @@ public class SysUser extends BaseEntity
|
||||
@Excel(name = "登录名称")
|
||||
private String userName;
|
||||
|
||||
|
||||
|
||||
/** 用户昵称 */
|
||||
@Excel(name = "用户名称")
|
||||
private String nickName;
|
||||
/** 用户身份证号 */
|
||||
@Excel(name = "身份证号")
|
||||
private String idCard;
|
||||
|
||||
/** 用户邮箱 */
|
||||
@Excel(name = "用户邮箱")
|
||||
@@ -297,12 +302,21 @@ public class SysUser extends BaseEntity
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
.append("userName", getUserName())
|
||||
.append("idCard", getIdCard())
|
||||
.append("nickName", getNickName())
|
||||
.append("email", getEmail())
|
||||
.append("phonenumber", getPhonenumber())
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
import org.apache.http.client.methods.*;
|
||||
|
||||
/**
|
||||
* @description 请求类型
|
||||
* @author 澄泓
|
||||
* @since JDK1.7
|
||||
*/
|
||||
public enum EsignRequestType {
|
||||
|
||||
POST{
|
||||
@Override
|
||||
public HttpRequestBase getHttpType(String url) {
|
||||
return new HttpPost(url);
|
||||
}
|
||||
},
|
||||
GET{
|
||||
@Override
|
||||
public HttpRequestBase getHttpType(String url) {
|
||||
return new HttpGet(url);
|
||||
}
|
||||
},
|
||||
DELETE{
|
||||
@Override
|
||||
public HttpRequestBase getHttpType(String url) {
|
||||
return new HttpDelete(url);
|
||||
}
|
||||
},
|
||||
PUT{
|
||||
@Override
|
||||
public HttpRequestBase getHttpType(String url) {
|
||||
return new HttpPut(url);
|
||||
}
|
||||
},
|
||||
;
|
||||
|
||||
public abstract HttpRequestBase getHttpType(String url);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.common.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -9,28 +10,23 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum HttpMethod
|
||||
{
|
||||
public enum HttpMethod {
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
||||
|
||||
static
|
||||
{
|
||||
for (HttpMethod httpMethod : values())
|
||||
{
|
||||
static {
|
||||
for (HttpMethod httpMethod : values()) {
|
||||
mappings.put(httpMethod.name(), httpMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HttpMethod resolve(@Nullable String method)
|
||||
{
|
||||
public static HttpMethod resolve(@Nullable String method) {
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
public boolean matches(String method)
|
||||
{
|
||||
public boolean matches(String method) {
|
||||
return (this == resolve(method));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.common.exception;
|
||||
|
||||
/**
|
||||
* description 自定义全局异常
|
||||
* @author 澄泓
|
||||
* datetime 2019年7月1日上午10:43:24
|
||||
*/
|
||||
public class EsignDemoException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 4359180081622082792L;
|
||||
private Exception e;
|
||||
|
||||
public EsignDemoException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public EsignDemoException(String msg, Throwable cause) {
|
||||
super(msg,cause);
|
||||
}
|
||||
|
||||
public EsignDemoException(){
|
||||
|
||||
}
|
||||
|
||||
public Exception getE() {
|
||||
return e;
|
||||
}
|
||||
|
||||
public void setE(Exception e) {
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @ClassName EmailInUtil
|
||||
* @Description 邮件发送工具
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
@Slf4j
|
||||
public class EmailOutUtil {
|
||||
private static Pattern emailPattern = Pattern.compile("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
|
||||
// private static Pattern phonePattern = Pattern.compile("0?(13|14|15|18)[0-9]{9}");
|
||||
private static Pattern phonePattern = Pattern.compile("^1\\d{10}$");
|
||||
|
||||
|
||||
// @Autowired
|
||||
// private JavaMailSender mailSender;
|
||||
|
||||
// 发送发邮箱地址(外网地址)
|
||||
// @Value("${spring.mail-out-network.from}")
|
||||
// private static String fromOut;
|
||||
@Value("${spring.mail.host}")
|
||||
private String hostOut;
|
||||
@Value("${spring.mail.username}")
|
||||
private String usernameOut;
|
||||
@Value("${spring.mail.password}")
|
||||
private String passwordOut;
|
||||
@Value("${spring.mail.port}")
|
||||
private Integer portOut;
|
||||
|
||||
public JavaMailSender rebuildMailSender() {
|
||||
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
||||
mailSender.setHost(hostOut);
|
||||
mailSender.setUsername(usernameOut);
|
||||
mailSender.setPassword(passwordOut);
|
||||
mailSender.setPort(portOut);
|
||||
mailSender.setProtocol("smtp");
|
||||
mailSender.setDefaultEncoding("UTF-8");
|
||||
return mailSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送纯文本邮件信息
|
||||
*
|
||||
* @param to 接收方
|
||||
* @param subject 邮件主题
|
||||
* @param content 邮件内容(发送内容)
|
||||
*/
|
||||
public void sendMessage(String to, String subject, String content, String from, JavaMailSender mailSender) {
|
||||
// 创建一个邮件对象
|
||||
SimpleMailMessage msg = new SimpleMailMessage();
|
||||
msg.setFrom(from);
|
||||
msg.setTo(to);
|
||||
// 设置邮件主题
|
||||
msg.setSubject(subject);
|
||||
// 设置邮件内容
|
||||
msg.setText(content);
|
||||
// 发送邮件
|
||||
mailSender.send(msg);
|
||||
////System.out.println("发送成功:" + from + ":to:" + to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送带附件的邮件信息
|
||||
*
|
||||
* @param to 接收方
|
||||
* @param subject 邮件主题
|
||||
* @param content 邮件内容(发送内容)
|
||||
* @param fileList 文件集合 // 可发送多个附件
|
||||
*/
|
||||
public void sendMessageCarryFiles(String to, String subject, String content, List<File> fileList, String from, @NotNull JavaMailSender mailSender) {
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(from);
|
||||
helper.setTo(to);
|
||||
// 设置邮件主题
|
||||
helper.setSubject(subject);
|
||||
// 设置邮件内容
|
||||
helper.setText(content);
|
||||
// 添加附件(多个)
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
for (File file : fileList) {
|
||||
helper.addAttachment(file.getName(), file);
|
||||
}
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 发送邮件
|
||||
mailSender.send(mimeMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送带附件的邮件信息
|
||||
*
|
||||
* @param to 接收方
|
||||
* @param subject 邮件主题
|
||||
* @param content 邮件内容(发送内容)
|
||||
* @param file 单个文件
|
||||
*/
|
||||
public void sendMessageCarryFile(String to, String subject, String content, File file, String from, JavaMailSender mailSender) {
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(from);
|
||||
helper.setTo(to);
|
||||
// 设置邮件主题
|
||||
helper.setSubject(subject);
|
||||
// 设置邮件内容
|
||||
helper.setText(content);
|
||||
// 单个附件
|
||||
helper.addAttachment(file.getName(), file);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 发送邮件
|
||||
mailSender.send(mimeMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化内外网邮件发送对象
|
||||
*
|
||||
* @param num
|
||||
*/
|
||||
// public static JavaMailSender initJavaMailSender(Integer num) {
|
||||
// if (num != null && num == 1) {
|
||||
// //内网
|
||||
// return rebuildMailSender(hostIn, usernameIn, passwordIn, Integer.parseInt(portIn), "smtps");
|
||||
// } else {
|
||||
// //外网
|
||||
// return rebuildMailSender(hostOut, usernameOut, passwordOut, Integer.parseInt(portOut), "smtps");
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static String getInnerFrom() {
|
||||
// return EmailInUtil;
|
||||
// }
|
||||
//
|
||||
// public static String getOutterFrom() {
|
||||
// return fromOut;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 验证邮箱格式
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmail(String str) {
|
||||
boolean flag = false;
|
||||
Matcher matcher = emailPattern.matcher(str);
|
||||
if (matcher.matches()) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static boolean isPhoneNumber(String str) {
|
||||
boolean flag = false;
|
||||
Matcher matcher = phonePattern.matcher(str);
|
||||
if (matcher.matches()) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
public class EsignApplicaConfig {
|
||||
|
||||
// 应用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";
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
|
||||
import com.ruoyi.common.constant.EsignEncryption;
|
||||
import com.ruoyi.common.constant.EsignHeaderConstant;
|
||||
import com.ruoyi.common.constant.EsignHttpCfgHelper;
|
||||
import com.ruoyi.common.core.domain.entity.EsignCoreSdkInfo;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.enums.EsignRequestType;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description Http 请求 辅助类
|
||||
* @author 澄泓
|
||||
* @since JDK1.7
|
||||
*/
|
||||
public class EsignHttpHelper {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EsignHttpHelper.class);
|
||||
|
||||
/**
|
||||
* 不允许外部创建实例
|
||||
*/
|
||||
private EsignHttpHelper() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 发送常规HTTP 请求
|
||||
*
|
||||
* @param reqType 请求方式
|
||||
* @param url 请求路径
|
||||
* @param paramStr 请求参数
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static EsignHttpResponse doCommHttp(String host, String url, EsignRequestType reqType, Object paramStr , Map<String,String> httpHeader, boolean debug) throws EsignDemoException {
|
||||
|
||||
return EsignHttpCfgHelper.sendHttp(reqType, host+url,httpHeader, paramStr, debug);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 发送文件流上传 HTTP 请求
|
||||
*
|
||||
* @param reqType 请求方式
|
||||
* @param uploadUrl 请求路径
|
||||
* @param param 请求参数
|
||||
* @param fileContentMd5 文件fileContentMd5
|
||||
* @param contentType 文件MIME类型
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static EsignHttpResponse doUploadHttp( String uploadUrl,EsignRequestType reqType,byte[] param, String fileContentMd5,
|
||||
String contentType, boolean debug) throws EsignDemoException {
|
||||
Map<String, String> uploadHeader = buildUploadHeader(fileContentMd5, contentType);
|
||||
if(debug){
|
||||
LOGGER.info("----------------------------start------------------------");
|
||||
LOGGER.info("fileContentMd5:{}",fileContentMd5);
|
||||
LOGGER.info("contentType:{}",contentType);
|
||||
}
|
||||
return EsignHttpCfgHelper.sendHttp(reqType,uploadUrl, uploadHeader, param,debug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description 构建一个签名鉴权+json数据的esign请求头
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static Map<String, String> buildSignAndJsonHeader(String projectId,String contentMD5,String accept,String contentType,String authMode) {
|
||||
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("X-Tsign-Open-App-Id", projectId);
|
||||
header.put("X-Tsign-Open-Version-Sdk",EsignCoreSdkInfo.getSdkVersion());
|
||||
header.put("X-Tsign-Open-Ca-Timestamp", EsignEncryption.timeStamp());
|
||||
header.put("Accept",accept);
|
||||
header.put("Content-MD5",contentMD5);
|
||||
header.put("Content-Type", contentType);
|
||||
header.put("X-Tsign-Open-Auth-Mode", authMode);
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名计算并且构建一个签名鉴权+json数据的esign请求头
|
||||
* @param httpMethod
|
||||
* * The name of a supported {@linkplain java.nio.charset.Charset
|
||||
* * charset}
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> signAndBuildSignAndJsonHeader(String projectId, String secret,String paramStr,String httpMethod,String url,boolean debug) throws EsignDemoException {
|
||||
String contentMD5="";
|
||||
//统一转大写处理
|
||||
httpMethod = httpMethod.toUpperCase();
|
||||
if("GET".equals(httpMethod)||"DELETE".equals(httpMethod)){
|
||||
paramStr=null;
|
||||
contentMD5="";
|
||||
} else if("PUT".equals(httpMethod)||"POST".equals(httpMethod)){
|
||||
//对body体做md5摘要
|
||||
contentMD5= EsignEncryption.doContentMD5(paramStr);
|
||||
}else{
|
||||
throw new EsignDemoException(String.format("不支持的请求方法%s",httpMethod));
|
||||
}
|
||||
//构造一个初步的请求头
|
||||
Map<String, String> esignHeaderMap = buildSignAndJsonHeader(projectId, contentMD5, EsignHeaderConstant.ACCEPT.VALUE(), EsignHeaderConstant.CONTENTTYPE_JSON.VALUE(), EsignHeaderConstant.AUTHMODE.VALUE());
|
||||
//排序
|
||||
url=EsignEncryption.sortApiUrl(url);
|
||||
//传入生成的bodyMd5,加上其他请求头部信息拼接成字符串
|
||||
String message = EsignEncryption.appendSignDataString(httpMethod, esignHeaderMap.get("Content-MD5"),esignHeaderMap.get("Accept"),esignHeaderMap.get("Content-Type"),esignHeaderMap.get("Headers"),esignHeaderMap.get("Date"), url);
|
||||
//整体做sha256签名
|
||||
String reqSignature = EsignEncryption.doSignatureBase64(message, secret);
|
||||
//请求头添加签名值
|
||||
esignHeaderMap.put("X-Tsign-Open-Ca-Signature",reqSignature);
|
||||
if(debug){
|
||||
LOGGER.info("----------------------------start------------------------");
|
||||
LOGGER.info("待计算body值:{}", paramStr+"\n");
|
||||
LOGGER.info("MD5值:{}",contentMD5+"\n");
|
||||
LOGGER.info("待签名字符串:{}",message+"\n");
|
||||
LOGGER.info("签名值:{}",reqSignature+"\n");
|
||||
}
|
||||
return esignHeaderMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 构建一个Token鉴权+jsons数据的esign请求头
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static Map<String, String> buildTokenAndJsonHeader(String appid,String token) {
|
||||
Map<String, String> esignHeader = new HashMap<>();
|
||||
esignHeader.put("X-Tsign-Open-Version-Sdk", EsignCoreSdkInfo.getSdkVersion());
|
||||
esignHeader.put("Content-Type", EsignHeaderConstant.CONTENTTYPE_JSON.VALUE());
|
||||
esignHeader.put("X-Tsign-Open-App-Id", appid);
|
||||
esignHeader.put("X-Tsign-Open-Token", token);
|
||||
return esignHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 构建一个form表单数据的esign请求头
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static Map<String, String> buildFormDataHeader(String appid) {
|
||||
Map<String, String> esignHeader = new HashMap<>();
|
||||
esignHeader.put("X-Tsign-Open-Version-Sdk",EsignCoreSdkInfo.getSdkVersion());
|
||||
esignHeader.put("X-Tsign-Open-Authorization-Version","v2");
|
||||
esignHeader.put("Content-Type", EsignHeaderConstant.CONTENTTYPE_FORMDATA.VALUE());
|
||||
esignHeader.put("X-Tsign-Open-App-Id", appid);
|
||||
return esignHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建文件流上传 请求头
|
||||
*
|
||||
* @param fileContentMd5
|
||||
* @param contentType
|
||||
* @return
|
||||
* @author 澄泓
|
||||
*/
|
||||
public static Map<String, String> buildUploadHeader(String fileContentMd5, String contentType) {
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("Content-MD5", fileContentMd5);
|
||||
header.put("Content-Type", contentType);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
// ------------------------------私有方法end----------------------------------------------
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.cvm.v20170312.CvmClient;
|
||||
import com.tencentcloudapi.cvm.v20170312.models.DescribeRegionsRequest;
|
||||
import com.tencentcloudapi.cvm.v20170312.models.DescribeRegionsResponse;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.var;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class SmsUtils {
|
||||
//应用id
|
||||
private static final String SDK_APP_ID = "1400854852";
|
||||
//API的SecretId
|
||||
private static final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp";
|
||||
//API的SecretKey
|
||||
private static final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V";
|
||||
//签名内容
|
||||
private static final String SIGN_NAME = "西安云美电子科技有限公司";
|
||||
|
||||
public static Boolean sendSms(SendSmsRequest request) {
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEY );
|
||||
|
||||
SmsClient client = new SmsClient(cred, "ap-guangzhou");
|
||||
|
||||
final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest();
|
||||
req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()});
|
||||
req.setSmsSdkAppId(SDK_APP_ID );
|
||||
req.setSignName(SIGN_NAME);
|
||||
req.setTemplateId(request.getTemplateId());
|
||||
req.setTemplateParamSet(request.getTemplateParamSet());
|
||||
SendSmsResponse res = null;
|
||||
try {
|
||||
res = client.SendSms(req);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.error("发送短信出错:", e);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
SendStatus sendStatus = res.getSendStatusSet()[0];
|
||||
log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage());
|
||||
|
||||
if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
/**
|
||||
* 参数对象
|
||||
*/
|
||||
@Data
|
||||
public static class SendSmsRequest {
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 模板 ID: 必须填写已审核通过的模板 ID
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空
|
||||
*/
|
||||
private String[] templateParamSet;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.*;
|
||||
import com.deepoove.poi.data.style.ParagraphStyle;
|
||||
import com.deepoove.poi.data.style.Style;
|
||||
import com.deepoove.poi.util.PoitlIOUtils;
|
||||
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文档生成工具类
|
||||
*/
|
||||
public class WordUtil {
|
||||
|
||||
private CellRenderData cell;
|
||||
|
||||
/**
|
||||
* 查询生成的word文件流
|
||||
*
|
||||
* @param response
|
||||
* @param datas
|
||||
* @param modalFilePath
|
||||
* @param resultFilePath
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void getDocStreamFile(HttpServletResponse response, Map<String, Object> datas, String modalFilePath, String resultFilePath, String fileName) throws IOException {
|
||||
//获取word模板和填充数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(modalFilePath).render(datas);
|
||||
//设置返回类型及文件名
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-disposition", "attachment;filename=\"" + fileName + "\"");
|
||||
//获取返回输出流
|
||||
OutputStream out = response.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
template.write(bos);
|
||||
bos.flush();
|
||||
out.flush();
|
||||
PoitlIOUtils.closeQuietlyMulti(template, bos, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询生成的word文件路径
|
||||
*
|
||||
* @param datas
|
||||
* @param modalFilePath
|
||||
* @param resultFilePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getDocFilePath(Map<String, Object> datas, String modalFilePath, String resultFilePath) throws IOException {
|
||||
//获取word模板和填充数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(modalFilePath).render(datas);
|
||||
template.writeAndClose(new FileOutputStream(resultFilePath));
|
||||
return resultFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造绘制表格的方法
|
||||
*/
|
||||
public static TableRenderData rebuildWordTableData(List<String> headerList, String headerBackgroundColor, String textColor, List<List<String>> tableContentList) {
|
||||
RowRenderData header = rebuildWordTableHead(headerList, headerBackgroundColor, textColor);
|
||||
List<RowRenderData> content = rebuildWordTableContent(tableContentList);
|
||||
TableRenderData tableRenderData = Tables.create().addRow(header);
|
||||
for (int i = 0; content != null && i < content.size(); i++) {
|
||||
tableRenderData.addRow(content.get(i));
|
||||
}
|
||||
return tableRenderData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造表格表头
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static RowRenderData rebuildWordTableHead(List<String> headerList, String headerBackgroundColor, String textColor) {
|
||||
RowRenderData header = new RowRenderData();
|
||||
for (int i = 0; headerList != null && i < headerList.size(); i++) {
|
||||
CellRenderData cellRenderData = new CellRenderData();
|
||||
ParagraphRenderData paragraphRenderData = new ParagraphRenderData();
|
||||
Style style = new Style();
|
||||
style.setColor(textColor);
|
||||
style.setFontSize(12.0);
|
||||
ParagraphStyle paragraphStyle = ParagraphStyle.builder()
|
||||
.withAlign(ParagraphAlignment.CENTER)
|
||||
// .withBackgroundColor(headerBackgroundColor)
|
||||
.withDefaultTextStyle(style)
|
||||
.build();
|
||||
paragraphRenderData.addText(headerList.get(i));
|
||||
paragraphRenderData.setParagraphStyle(paragraphStyle);
|
||||
cellRenderData.addParagraph(paragraphRenderData);
|
||||
header.addCell(cellRenderData);
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造表格内容
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<RowRenderData> rebuildWordTableContent(List<List<String>> tableContentList) {
|
||||
List<RowRenderData> rowContentList = new ArrayList<>();
|
||||
for (int i = 0; tableContentList != null && i < tableContentList.size(); i++) {
|
||||
List<String> rowdataList = tableContentList.get(i);
|
||||
RowRenderData rowcontent = new RowRenderData();
|
||||
for (int j = 0; rowdataList != null && j < rowdataList.size(); j++) {
|
||||
CellRenderData cellRenderData = new CellRenderData();
|
||||
ParagraphRenderData paragraphRenderData = new ParagraphRenderData();
|
||||
Style style = new Style();
|
||||
style.setFontSize(12.0);
|
||||
ParagraphStyle paragraphStyle = ParagraphStyle.builder()
|
||||
.withAlign(ParagraphAlignment.CENTER)
|
||||
.withDefaultTextStyle(style)
|
||||
.build();
|
||||
paragraphRenderData.addText(rowdataList.get(j));
|
||||
paragraphRenderData.setParagraphStyle(paragraphStyle);
|
||||
cellRenderData.addParagraph(paragraphRenderData);
|
||||
rowcontent.addCell(cellRenderData);
|
||||
}
|
||||
rowContentList.add(rowcontent);
|
||||
}
|
||||
return rowContentList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建图片内容
|
||||
*/
|
||||
public static PictureRenderData rebuildImageContent(Integer with, Integer height, String imageUrl, String relatedPath, Byte[] imageBytes) {
|
||||
PictureRenderData pictureRenderData = null;
|
||||
if (!StringUtils.isBlank(imageUrl)) {
|
||||
// pictureRenderData = Pictures.of(imageUrl).size(with, height).create();
|
||||
//Pictures.PictureBuilder pictureBuilder = Pictures.of("https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1EtCRvm.png");
|
||||
}else if (!StringUtils.isBlank(relatedPath)) {
|
||||
pictureRenderData = Pictures.ofLocal(relatedPath).size(with,height).create();
|
||||
// Pictures.PictureBuilder pictureBuilder = Pictures.of("https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1EtCRvm.png");
|
||||
}
|
||||
return pictureRenderData;
|
||||
}
|
||||
public static String getResultFilePath(Map<String, Object> datas, Configure config, String modalFilePath, String resultFilePath) throws IOException {
|
||||
//获取word模板和填充数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(modalFilePath,config).render(datas);
|
||||
template.writeAndClose(new FileOutputStream(resultFilePath));
|
||||
return resultFilePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
/**
|
||||
* @author wangqiong
|
||||
* @description 获取微信小程序url scheme
|
||||
* @date 2023-10-13 10:16
|
||||
*/
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
public class WxAppletNotifyUtils {
|
||||
|
||||
/**
|
||||
* scheme 跳转微信小程序,需中转H5
|
||||
|
||||
*/
|
||||
public static String jumpAppletSchemeUrl(){
|
||||
|
||||
String token= getAccessToken();
|
||||
|
||||
//接口地址
|
||||
String url = "https://api.weixin.qq.com/wxa/generatescheme?access_token="+token;
|
||||
JSONObject body = JSONUtil.createObj();
|
||||
JSONObject jumpWxa = JSONUtil.createObj();
|
||||
jumpWxa.putOpt("path","pages/login");
|
||||
jumpWxa.putOpt("query","");
|
||||
jumpWxa.putOpt("env_version","release");
|
||||
body.putOpt("jump_wxa",jumpWxa);
|
||||
//链接过期类型:0时间戳 1间隔天数
|
||||
body.putOpt("expire_type",1);
|
||||
body.putOpt("is_expire",true);
|
||||
//指定失效天数,最多30
|
||||
body.putOpt("expire_interval",30);
|
||||
String post = HttpUtil.post(url,body.toJSONString(2));
|
||||
JSONObject result = JSONUtil.parseObj(post);
|
||||
if(result!=null && result.containsKey("openlink")){
|
||||
return result.getStr("openlink");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//凭证调用
|
||||
public static String getAccessToken(){
|
||||
String token;
|
||||
//小程序APPID
|
||||
String appid="wx91cb8459dca561b4";//自行获取
|
||||
//小程序secret
|
||||
String secret="190aaa3bda96a65d25318fbb0e133fc6";//自己去公众号后台获取
|
||||
String httpUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential";
|
||||
|
||||
httpUrl= httpUrl+"&appid="+appid+"&secret="+secret;
|
||||
//get请求
|
||||
String result = HttpUtil.get(httpUrl);
|
||||
//解析结果
|
||||
JSONObject jsonObject = JSONUtil.parseObj(result);
|
||||
//get AccessToken
|
||||
token=jsonObject.get("access_token",String.class,false);
|
||||
return token;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.common.utils.bean;
|
||||
|
||||
|
||||
import com.ruoyi.common.constant.FileTransformation;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @description 文件基础信息封装类
|
||||
* @author 澄泓
|
||||
* @date 2020/10/26 14:54
|
||||
* @version JDK1.7
|
||||
*/
|
||||
public class EsignFileBean {
|
||||
//文件名称
|
||||
private String fileName;
|
||||
//文件大小
|
||||
private int fileSize;
|
||||
//文件内容MD5
|
||||
private String fileContentMD5;
|
||||
//文件地址
|
||||
private String filePath;
|
||||
|
||||
|
||||
public EsignFileBean(String filePath) throws EsignDemoException {
|
||||
this.filePath=filePath;
|
||||
this.fileContentMD5 = FileTransformation.getFileContentMD5(filePath);
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new EsignDemoException("文件不存在");
|
||||
}
|
||||
this.fileName = file.getName();
|
||||
this.fileSize = (int) file.length();
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public int getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public String getFileContentMD5() {
|
||||
return fileContentMD5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入本地文件地址获取二进制数据
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public byte[] getFileBytes() throws EsignDemoException {
|
||||
return FileTransformation.fileToBytes(filePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.ruoyi.common.utils.file;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ruoyi.common.config.EsignDemoConfig;
|
||||
import com.ruoyi.common.constant.EsignHeaderConstant;
|
||||
import com.ruoyi.common.constant.FileTransformation;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.enums.EsignRequestType;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import com.ruoyi.common.utils.EsignHttpHelper;
|
||||
import com.ruoyi.common.utils.bean.EsignFileBean;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
public class SaaSAPIFileUtils {
|
||||
private static String eSignHost= EsignDemoConfig.EsignHost;
|
||||
private static String eSignAppId= EsignDemoConfig.EsignAppId;
|
||||
private static String eSignAppSecret=EsignDemoConfig.EsignAppSecret;
|
||||
/**
|
||||
* 获取文件上传地址
|
||||
*/
|
||||
public static EsignHttpResponse getUploadUrl(String filePath) throws EsignDemoException {
|
||||
//自定义的文件封装类,传入文件地址可以获取文件的名称大小,文件流等数据
|
||||
EsignFileBean esignFileBean = new EsignFileBean(filePath);
|
||||
String apiaddr = "/v3/files/file-upload-url";
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm = "{\n" +
|
||||
" \"contentMd5\": \"" + esignFileBean.getFileContentMD5() + "\",\n" +
|
||||
" \"fileName\":\"" + esignFileBean.getFileName() + "\"," +
|
||||
" \"fileSize\": " + esignFileBean.getFileSize() + ",\n" +
|
||||
" \"convertToPDF\":" +true+ ",\n" +
|
||||
" \"contentType\": \"" + EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE() + "\"\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
}
|
||||
/**
|
||||
* 上传文件流
|
||||
*/
|
||||
public static EsignHttpResponse uploadFile(String uploadUrl,String filePath) throws EsignDemoException {
|
||||
//根据文件地址获取文件contentMd5
|
||||
EsignFileBean esignFileBean = new EsignFileBean(filePath);
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.PUT;
|
||||
return EsignHttpHelper.doUploadHttp(uploadUrl,requestType,esignFileBean.getFileBytes(),esignFileBean.getFileContentMD5(), EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传状态
|
||||
*/
|
||||
public static EsignHttpResponse getFileStatus(String fileId) throws EsignDemoException {
|
||||
String apiaddr="/v3/files/"+fileId;
|
||||
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm=null;
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载已签署文件及附属材料
|
||||
*/
|
||||
public static EsignHttpResponse fileDownloadUrl(String signFlowId) throws EsignDemoException {
|
||||
String apiaddr = "/v3/sign-flow/"+ signFlowId +"/file-download-url";
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm=null;
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
}
|
||||
|
||||
public static void main1(String[] args) throws EsignDemoException {
|
||||
String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
|
||||
EsignHttpResponse uploadUrl = getUploadUrl(filePath);
|
||||
String body = uploadUrl.getBody();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
JSONObject dataObj = jsonObject.getJSONObject("data");
|
||||
String fileUploadUrl = dataObj.get("fileUploadUrl").toString();
|
||||
System.out.println("这是fileUploadUrl:"+fileUploadUrl);
|
||||
String fileId = dataObj.get("fileId").toString();
|
||||
System.out.println("这是fileId:"+fileId);
|
||||
//String fileUploadUrl = "https://esignoss.esign.cn/1111564182/ccf6db5a-92da-4523-89ba-385a30423596/23893bfd3f2249ffa5c82850c11c482e.docx?Expires=1697021257&OSSAccessKeyId=STS.NTmgvSC8n5Zg1y7EciQftF23N&Signature=CxVZmpwFksWmLYkxPjVz9K4mVyA%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDAyODhjOTg3LWNlNzgtNDM1OC04NWYwLTdlNmUyM2NjOTJmNiQzNDk1NzQ3MjE5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fYLMznrudPgpiMM1%2BGoWM8XelYqfeYrDz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEofT7katr4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAaxcPCSY0Du8wgErfR1llD8t2zeFG%2B1mktU4Rsl7AgxsSFxrwILBUk2x7imVsFVA0kkS8rNBMDKGIsIZTCl5M7S2L%2BD8364htwcZgIZYHK2fCN6gCuy%2Bfk9C%2FfQaTc00IWBMw8OubuJ%2Fq2mdMh32yoi7dLuJyhwt1z%2F%2BWf5vIFHdIAA%3D";
|
||||
EsignHttpResponse esignHttpResponse = uploadFile(fileUploadUrl, filePath);
|
||||
System.out.println("这是上传文件流的结果:"+esignHttpResponse.getBody());
|
||||
// EsignHttpResponse fileStatus = getFileStatus(fileId);
|
||||
// System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody());
|
||||
// getFileStatus("a808f1f39a744357a2f018e4ab34c55d");
|
||||
// fileDownloadUrl("");
|
||||
}
|
||||
public static void main(String[] args) throws EsignDemoException {
|
||||
String signFlowId = "41e6732b48c54c63a91b2379c352212d";
|
||||
Gson gson = new Gson();
|
||||
EsignHttpResponse fileDownload = fileDownloadUrl(signFlowId);
|
||||
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class);
|
||||
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
|
||||
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
|
||||
if(filesArray!=null&&filesArray.size()>0){
|
||||
JsonObject fileObject = (JsonObject)filesArray.get(0);
|
||||
String fileDownloadUrl = fileObject.get("downloadUrl").toString();
|
||||
String fileName = java.util.UUID.randomUUID().toString().replace("-", "") + ".pdf";
|
||||
String savePath = "/home/ruoyi/uploadPath/upload";
|
||||
LocalDate now = LocalDate.now();
|
||||
String year = Integer.toString(now.getYear());
|
||||
String month = String.format("%02d", now.getMonthValue());
|
||||
String day = String.format("%02d", now.getDayOfMonth());
|
||||
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||
String dir = "F:\\ymkf\\shanghaixm\\testCaijueshu\\" + fileName;
|
||||
String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
|
||||
FileTransformation.downLoadFileByUrl(fileDownloadUrlnew,dir);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class ApplicationConfig
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization()
|
||||
{
|
||||
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
|
||||
// return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
|
||||
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone("Asia/Shanghai");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
.antMatchers("/login", "/register", "/captchaImage","/uploadPath/**").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>pay</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.bestsign.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ArbitrSignatuVO {
|
||||
/**
|
||||
* 用户帐号
|
||||
* 任务id
|
||||
* 文件MD5
|
||||
* 文件内容
|
||||
* 文件总页数
|
||||
* 文件名称
|
||||
* 文件类型
|
||||
* 合同标题
|
||||
* 有效期
|
||||
* 合同编号
|
||||
* 签署者账号
|
||||
* 签名位置页码
|
||||
* x坐标
|
||||
* y坐标
|
||||
*/
|
||||
private String account;
|
||||
private String taskId;
|
||||
|
||||
private String fileMd5;
|
||||
private String fileData;
|
||||
private String filePages;
|
||||
private String fileName;
|
||||
private String fileType;
|
||||
private String contractTitle;
|
||||
private String periodValidity;
|
||||
|
||||
private String contractNum;
|
||||
private String signerAccout;
|
||||
private String pageNumSigner;
|
||||
private String pageNumSignerX;
|
||||
private String pageNumSignerY;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.bestsign.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CredentialVO {
|
||||
/**
|
||||
* 用户证件号
|
||||
*/
|
||||
private String identity;
|
||||
/**
|
||||
* 用户证件类型
|
||||
* 默认用“0”, "0"表示身份证,会校验18位身份证号格式。0-居民身份证; 1-护照;6-社会保障卡; B-港澳居民往来内地通行证; C-台湾居民来往大陆通行证; E-户口簿; F-临时居民身份证;P-外国人永久居留证;Z-其他证件
|
||||
*/
|
||||
private String identityType;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.bestsign.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class PersonRegisterVO {
|
||||
/**
|
||||
* 用户帐号
|
||||
* 用户名称
|
||||
* 用户类型
|
||||
* 用户邮箱
|
||||
* 用户手机号
|
||||
* 用户证件信息对象
|
||||
* 是否申请证书
|
||||
*/
|
||||
private String account;
|
||||
private String name;
|
||||
private String userType;
|
||||
private String mail;
|
||||
private String mobile;
|
||||
private CredentialVO credential;
|
||||
private String applyCert;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ruoyi.bestsign.service;
|
||||
|
||||
import com.ruoyi.bestsign.domain.ArbitrSignatuVO;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
public interface ArbitrSignatuService {
|
||||
|
||||
|
||||
AjaxResult selectApplyStatus(ArbitrSignatuVO arbitrSignatuVO);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.bestsign.service;
|
||||
|
||||
import com.ruoyi.bestsign.domain.PersonRegisterVO;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
public interface SignRegisterService {
|
||||
/**
|
||||
* 注册上上签个人用户
|
||||
*
|
||||
* @param personRegisterVO
|
||||
* @return
|
||||
*/
|
||||
AjaxResult registerPerson(PersonRegisterVO personRegisterVO);
|
||||
/**
|
||||
* 查询用户认证状态/user/async/applyCert/status/
|
||||
*/
|
||||
AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO);
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.bestsign.service.impl;
|
||||
|
||||
import com.ruoyi.bestsign.domain.ArbitrSignatuVO;
|
||||
import com.ruoyi.bestsign.service.ArbitrSignatuService;
|
||||
import com.ruoyi.bestsign.utils.BestsignOpenApiClient;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ArbitrSignatuServiceImpl implements ArbitrSignatuService {
|
||||
@Autowired
|
||||
BestsignOpenApiClient bestsignOpenApiClient;
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult selectApplyStatus(ArbitrSignatuVO arbitrSignatuVO) {
|
||||
String strRespon = "";
|
||||
try {
|
||||
strRespon = bestsignOpenApiClient.selectApplyStatus(arbitrSignatuVO.getAccount(),
|
||||
arbitrSignatuVO.getTaskId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.success(strRespon);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.bestsign.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.bestsign.domain.PersonRegisterVO;
|
||||
import com.ruoyi.bestsign.service.SignRegisterService;
|
||||
import com.ruoyi.bestsign.utils.BestsignOpenApiClient;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RegisterServiceImpl implements SignRegisterService {
|
||||
@Autowired
|
||||
BestsignOpenApiClient bestsignOpenApiClient;
|
||||
|
||||
/**
|
||||
* 注册上上签个人用户
|
||||
*
|
||||
* @param personRegisterVO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult registerPerson(PersonRegisterVO personRegisterVO) {
|
||||
try {
|
||||
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
|
||||
personRegisterVO.getName(),
|
||||
personRegisterVO.getMail(),
|
||||
personRegisterVO.getMobile(),
|
||||
personRegisterVO.getCredential().getIdentity(),
|
||||
personRegisterVO.getCredential().getIdentityType(),
|
||||
null, null, null, null, null, "/user/reg/");
|
||||
AjaxResult.success(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户认证状态/user/async/applyCert/status/
|
||||
*
|
||||
* @param personRegisterVO
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO) {
|
||||
try {
|
||||
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
|
||||
personRegisterVO.getName(),
|
||||
personRegisterVO.getMail(),
|
||||
personRegisterVO.getMobile(),
|
||||
personRegisterVO.getCredential().getIdentity(),
|
||||
personRegisterVO.getCredential().getIdentityType(),
|
||||
null, null, null, null, null, "/user/async/applyCert/status/");
|
||||
AjaxResult.success(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.ruoyi.bestsign.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.bestsign.domain.ArbitrSignatuVO;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 上上签混合云SDK客户端
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
@Slf4j
|
||||
public class BestsignOpenApiClient {
|
||||
/**
|
||||
* 开发者id
|
||||
*/
|
||||
@Value("${ssq.developerId}")
|
||||
private String developerId;
|
||||
/**
|
||||
* 开发者私钥
|
||||
*/
|
||||
@Value("${ssq.privateKey}")
|
||||
private String privateKey;
|
||||
/**
|
||||
* Host地址
|
||||
*/
|
||||
@Value("${ssq.serverHost}")
|
||||
private String serverHost;
|
||||
/**
|
||||
* 签名参数
|
||||
*/
|
||||
private static String urlSignParams = "?developerId=%s&rtick=%s&signType=rsa&sign=%s";
|
||||
|
||||
// public BestsignOpenApiClient(String developerId, String privateKey,
|
||||
// String serverHost) {
|
||||
// this.developerId = developerIds;
|
||||
// this.privateKey = privateKey;
|
||||
// this.serverHost = serverHost;
|
||||
// }
|
||||
|
||||
/**
|
||||
* POST方法示例
|
||||
* 个人用户注册
|
||||
*
|
||||
* @param account 用户账号
|
||||
* @param name 姓名
|
||||
* @param mail 用来接收通知邮件的电子邮箱
|
||||
* @param mobile 用来接收通知短信的手机号码
|
||||
* @param identity 证件号码
|
||||
* @param identityType 枚举值:0-身份证,目前仅支持身份证
|
||||
* @param contactMail 电子邮箱
|
||||
* @param contactMobile 手机号码
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @param method 地址
|
||||
* @return 异步申请任务单号
|
||||
* @throws IOException
|
||||
*/
|
||||
public JSONObject userPersonalReg(String account, String name, String mail,
|
||||
String mobile, String identity, String identityType,
|
||||
String contactMail, String contactMobile, String province,
|
||||
String city, String address, @NotNull String method) throws Exception {
|
||||
//body参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
|
||||
//用户帐号
|
||||
requestBody.put("account", account);
|
||||
//用户名称
|
||||
requestBody.put("name", name);
|
||||
//用户类型
|
||||
requestBody.put("userType", "1");
|
||||
//用户邮箱
|
||||
requestBody.put("mail", mail);
|
||||
//用户手机号
|
||||
requestBody.put("mobile", mobile);
|
||||
//用户证件信息对象
|
||||
JSONObject credential = new JSONObject();
|
||||
//用户证件号
|
||||
credential.put("identity", identity);
|
||||
//用户证件类型
|
||||
credential.put("identityType", identityType);
|
||||
requestBody.put("credential", credential);
|
||||
|
||||
//是否申请证书
|
||||
requestBody.put("applyCert", "1");
|
||||
// 生成一个时间戳参数
|
||||
String rtick = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
||||
this.privateKey, this.serverHost, method, rtick, null,
|
||||
requestBody.toJSONString());
|
||||
// 签名参数追加为url参数
|
||||
String fullUrlParams = String.format(urlSignParams, this.developerId,
|
||||
rtick, paramsSign);
|
||||
|
||||
// 发送POST请求
|
||||
String responseBody = HttpClientSender.sendHttpPost(this.serverHost, method,
|
||||
fullUrlParams, requestBody.toJSONString());
|
||||
System.out.println(responseBody);
|
||||
// 返回结果解析
|
||||
JSONObject userObj = JSON.parseObject(responseBody);
|
||||
System.out.println(JSON.toJSONString(userObj));
|
||||
return userObj;
|
||||
// 返回errno为0,表示成功,其他表示失败
|
||||
// if (userObj.getIntValue("errno") == 0) {
|
||||
// JSONObject data = userObj.getJSONObject("data");
|
||||
// if (data != null) {
|
||||
// //对返回data进行处理
|
||||
// String taskId = data.getString("taskId");
|
||||
// return taskId;
|
||||
// }
|
||||
// return null;
|
||||
// } else {
|
||||
// //接口返回异常
|
||||
// System.out.println(userObj.getIntValue("errno"));
|
||||
// System.out.println(userObj.getString("errmsg"));
|
||||
// throw new Exception(userObj.getIntValue("errno") + ":"
|
||||
// + userObj.getString("errmsg"));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET方法示例
|
||||
* 下载合同PDF文件
|
||||
*
|
||||
* @param contractId 合同编号
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public byte[] contractDownload(String contractId) throws Exception {
|
||||
String host = this.serverHost;
|
||||
String method = "/storage/contract/download/";
|
||||
|
||||
// 组装url参数
|
||||
String urlParams = "contractId=" + contractId;
|
||||
|
||||
// 生成一个时间戳参数
|
||||
String rtick = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
||||
this.privateKey, host, method, rtick, urlParams, null);
|
||||
// 签名参数追加为url参数
|
||||
urlParams = String.format(urlSignParams, this.developerId, rtick,
|
||||
paramsSign) + "&" + urlParams;
|
||||
// 发送请求
|
||||
byte[] responseBody = HttpClientSender.sendHttpGet(host, method,
|
||||
urlParams);
|
||||
// 返回结果解析
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
public String selectApplyStatus(String account, String taskId) throws Exception {
|
||||
String methodInvoke = "/user/async/applyCert/status/";
|
||||
JSONObject requestParam = new JSONObject();
|
||||
|
||||
//用户账号
|
||||
requestParam.put("account", account);
|
||||
//任务单号
|
||||
requestParam.put("taskId", taskId);
|
||||
String timestamsParam = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
||||
this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
||||
requestParam.toJSONString());
|
||||
// 签名参数追加为url参数
|
||||
String fullUrlParams = String.format(urlSignParams, this.developerId,
|
||||
timestamsParam, paramsSign);
|
||||
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
||||
fullUrlParams, requestParam.toJSONString());
|
||||
JSONObject responseObj = JSON.parseObject(responseResult);
|
||||
// 返回errno为0,表示成功,其他表示失败
|
||||
if (responseObj.getIntValue("errno") == 0) {
|
||||
JSONObject data = responseObj.getJSONObject("data");
|
||||
if (data != null) {
|
||||
String message = data.getString("message");
|
||||
String status = data.getString("status");
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
|
||||
log.error("查询申请状态异常:" + responseObj.toJSONString());
|
||||
}
|
||||
return responseObj.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取签署链接
|
||||
*
|
||||
* @param arbitrSignatuVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getSignLink(ArbitrSignatuVO arbitrSignatuVO) throws Exception {
|
||||
String methodInvoke = "/contract/send/";
|
||||
JSONObject requestParam = new JSONObject();
|
||||
|
||||
requestParam.put("contractId", arbitrSignatuVO.getContractNum());
|
||||
requestParam.put("signer", arbitrSignatuVO.getSignerAccout());
|
||||
|
||||
JSONArray signatureArray = new JSONArray();
|
||||
|
||||
JSONObject signatuItem = new JSONObject();
|
||||
signatuItem.put("pageNum", arbitrSignatuVO.getPageNumSigner());
|
||||
//x坐标
|
||||
signatuItem.put("x", arbitrSignatuVO.getPageNumSignerX());
|
||||
//y坐标
|
||||
signatuItem.put("y", arbitrSignatuVO.getPageNumSignerY());
|
||||
signatureArray.add(signatuItem);
|
||||
|
||||
requestParam.put("signaturePositions", signatureArray);
|
||||
|
||||
|
||||
String timestamsParam = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
||||
this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
||||
requestParam.toJSONString());
|
||||
// 签名参数追加为url参数
|
||||
String fullUrlParams = String.format(urlSignParams, this.developerId,
|
||||
timestamsParam, paramsSign);
|
||||
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
||||
fullUrlParams, requestParam.toJSONString());
|
||||
JSONObject responseObj = JSON.parseObject(responseResult);
|
||||
// 返回errno为0,表示成功,其他表示失败
|
||||
if (responseObj.getIntValue("errno") == 0) {
|
||||
JSONObject data = responseObj.getJSONObject("data");
|
||||
if (data != null) {
|
||||
String signLink = data.getString("url");
|
||||
return signLink;
|
||||
}
|
||||
} else {
|
||||
|
||||
log.error("获取签署链接异常:" + responseObj.toJSONString());
|
||||
}
|
||||
return responseObj.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成签署
|
||||
*
|
||||
* @param arbitrSignatuVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String finishSign(ArbitrSignatuVO arbitrSignatuVO) throws Exception {
|
||||
String methodInvoke = "/storage/contract/lock/";
|
||||
JSONObject requestParam = new JSONObject();
|
||||
requestParam.put("contractId", arbitrSignatuVO.getContractNum());
|
||||
String timestamsParam = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
||||
this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
||||
requestParam.toJSONString());
|
||||
// 签名参数追加为url参数
|
||||
String fullUrlParams = String.format(urlSignParams, this.developerId,
|
||||
timestamsParam, paramsSign);
|
||||
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
||||
fullUrlParams, requestParam.toJSONString());
|
||||
JSONObject responseObj = JSON.parseObject(responseResult);
|
||||
// 返回errno为0,表示成功,其他表示失败
|
||||
if (responseObj.getIntValue("errno") == 0) {
|
||||
return "完成签名";
|
||||
} else {
|
||||
|
||||
log.error("完成签署异常:" + responseObj.toJSONString());
|
||||
}
|
||||
return responseObj.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
package com.ruoyi.bestsign.utils;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
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.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpClientSender {
|
||||
|
||||
private static PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = null;
|
||||
private static Map<String, CloseableHttpClient> httpClients = new HashMap<String, CloseableHttpClient>();
|
||||
|
||||
private static Object o = new Object();
|
||||
|
||||
public static String sendHttpPost(String host, String method, String urlParams, String sendData) throws IOException {
|
||||
|
||||
String requestUrl = host + method + urlParams;
|
||||
|
||||
Map<String, Object> response = request("POST", requestUrl, sendData, null);
|
||||
int responseCode = Integer.parseInt(response.get("responseCode").toString());
|
||||
byte[] responseBytes = (byte[]) response.get("responseData");
|
||||
String responseString;
|
||||
try {
|
||||
responseString = new String(responseBytes, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
responseString = new String(responseBytes);
|
||||
}
|
||||
//请求返回结果无论成功失败,http-status均为200
|
||||
if (responseCode == 200) {
|
||||
//返回结果
|
||||
return responseString;
|
||||
} else {
|
||||
throw new IOException(responseCode + ":" + responseString);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] sendHttpGet(String host, String method, String urlParams) throws IOException {
|
||||
String requestUrl = host + method + urlParams;
|
||||
Map<String, Object> response = request("GET", requestUrl, null, null);
|
||||
int responseCode = Integer.parseInt(response.get("responseCode").toString());
|
||||
byte[] responseBytes = (byte[]) response.get("responseData");
|
||||
//请求返回结果无论成功失败,http-status均为200
|
||||
if (responseCode == 200) {
|
||||
//返回结果
|
||||
return responseBytes;
|
||||
} else {
|
||||
throw new IOException(responseCode + "");
|
||||
}
|
||||
}
|
||||
|
||||
public static String urlencode(String data) {
|
||||
return urlencode(data, "UTF-8");
|
||||
}
|
||||
|
||||
public static String urlencode(String data, String charset) {
|
||||
try {
|
||||
return URLEncoder.encode(data, charset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> request(String method, String url, Object sendData, Map<String, String> headers) throws IOException {
|
||||
|
||||
|
||||
String requestPath;
|
||||
try {
|
||||
requestPath = new URL(url).getPath();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
CloseableHttpClient httpClient = getHttpClient(requestPath);
|
||||
|
||||
Map<String, Object> response = null;
|
||||
if ("POST".equals(method)) {
|
||||
response = sendPost(httpClient, url, headers, sendData);
|
||||
} else {
|
||||
response = sendGet(httpClient, url, headers);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendPost(CloseableHttpClient httpClient, String url, Map<String, String> headers, Object sendData) throws IOException {
|
||||
String tag = "[HttpRequester] [POST " + url + "]";
|
||||
int responseCode = -1;
|
||||
byte[] responseBytes = null;
|
||||
|
||||
HttpPost request = new HttpPost(url);
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (String name : headers.keySet()) {
|
||||
String value = headers.get(name);
|
||||
request.setHeader(name, value);
|
||||
}
|
||||
}
|
||||
if (sendData != null) {
|
||||
StringEntity stringEntity = new StringEntity((String) sendData, "UTF-8");
|
||||
stringEntity.setContentType("application/json");
|
||||
request.setEntity(stringEntity);
|
||||
|
||||
HttpEntity httpEntity = null;
|
||||
IOException exception = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(request);
|
||||
responseCode = response.getStatusLine().getStatusCode();
|
||||
httpEntity = response.getEntity();
|
||||
|
||||
String responseBody = EntityUtils.toString(httpEntity, "utf-8");
|
||||
if (responseBody != null) {
|
||||
responseBytes = responseBody.getBytes();
|
||||
} else {
|
||||
InputStream respStream = null;
|
||||
try {
|
||||
respStream = httpEntity.getContent();
|
||||
int respBodySize = respStream.available();
|
||||
if (respBodySize <= 0)
|
||||
throw new IOException("Invalid respBodySize: " + respBodySize);
|
||||
responseBytes = new byte[respBodySize];
|
||||
if (respStream.read(responseBytes) != respBodySize)
|
||||
throw new IOException("Read respBody Error");
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
if (respStream != null) {
|
||||
respStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exception = null;
|
||||
break;
|
||||
} catch (UnsupportedOperationException e) {
|
||||
try {
|
||||
EntityUtils.consume(httpEntity);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
try {
|
||||
EntityUtils.consume(httpEntity);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
if (i < 2) {
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
|
||||
}
|
||||
Map<String, Object> response = new HashMap<String, Object>();
|
||||
response.put("responseCode", responseCode);
|
||||
response.put("responseData", responseBytes);
|
||||
String loggerResponseString = getLoggerString(responseBytes, 256);
|
||||
return response;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendGet(CloseableHttpClient httpClient, String url, Map<String, String> headers) throws IOException {
|
||||
String tag = "[HttpRequester] [GET " + url + "]";
|
||||
int responseCode = -1;
|
||||
byte[] responseBytes = null;
|
||||
|
||||
HttpGet request = new HttpGet(url);
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (String name : headers.keySet()) {
|
||||
String value = headers.get(name);
|
||||
request.setHeader(name, value);
|
||||
}
|
||||
}
|
||||
HttpEntity httpEntity = null;
|
||||
IOException exception = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(request);
|
||||
responseCode = response.getStatusLine().getStatusCode();
|
||||
httpEntity = response.getEntity();
|
||||
|
||||
byte[] responseBody = EntityUtils.toByteArray(httpEntity);
|
||||
if (responseBody != null) {
|
||||
responseBytes = responseBody;
|
||||
} else {
|
||||
InputStream respStream = null;
|
||||
try {
|
||||
respStream = httpEntity.getContent();
|
||||
int respBodySize = respStream.available();
|
||||
if (respBodySize <= 0)
|
||||
throw new IOException("Invalid respBodySize: " + respBodySize);
|
||||
responseBytes = new byte[respBodySize];
|
||||
if (respStream.read(responseBytes) != respBodySize)
|
||||
throw new IOException("Read respBody Error");
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
if (respStream != null) {
|
||||
respStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exception = null;
|
||||
break;
|
||||
} catch (UnsupportedOperationException e) {
|
||||
try {
|
||||
EntityUtils.consume(httpEntity);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
try {
|
||||
EntityUtils.consume(httpEntity);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
if (i < 2) {
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
Map<String, Object> response = new HashMap<String, Object>();
|
||||
response.put("responseCode", responseCode);
|
||||
response.put("responseData", responseBytes);
|
||||
String loggerResponseString = getLoggerString(responseBytes, 256);
|
||||
System.out.println(tag + " response " + responseCode + " " + loggerResponseString);
|
||||
return response;
|
||||
}
|
||||
|
||||
private static String getLoggerString(final byte[] data, int maxLength) {
|
||||
String loggerString;
|
||||
if (data.length > maxLength) {
|
||||
byte[] shortData = new byte[maxLength];
|
||||
System.arraycopy(data, 0, shortData, 0, shortData.length);
|
||||
try {
|
||||
loggerString = new String(shortData, "UTF-8") + "...";
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
loggerString = new String(shortData) + "...";
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
loggerString = new String(data, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
loggerString = new String(data);
|
||||
}
|
||||
}
|
||||
|
||||
char[] chars = new char[loggerString.length()];
|
||||
loggerString.getChars(0, loggerString.length(), chars, 0);
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
if (c == '\n' || c == '\r') {
|
||||
chars[i] = ' ';
|
||||
}
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
private static CloseableHttpClient getHttpClient(String requestPath) {
|
||||
if (httpClients.containsKey(requestPath)) {
|
||||
return httpClients.get(requestPath);
|
||||
}
|
||||
if (poolingHttpClientConnectionManager == null) {
|
||||
synchronized (o) {
|
||||
if (poolingHttpClientConnectionManager == null) {
|
||||
poolingHttpClientConnectionManager = HttpClientUtils.createHttpClientConnectionManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
synchronized (httpClients) {
|
||||
if (httpClients.containsKey(requestPath)) {
|
||||
return httpClients.get(requestPath);
|
||||
}
|
||||
CloseableHttpClient httpClient = HttpClientUtils.createHttpClient(poolingHttpClientConnectionManager);
|
||||
httpClients.put(requestPath, httpClient);
|
||||
return httpClient;
|
||||
}
|
||||
}
|
||||
|
||||
private static class HttpClientUtils {
|
||||
|
||||
// 默认连接超时
|
||||
private static int defaultConnectTimeout = 6000;
|
||||
// 默认读取超时
|
||||
private static int defaultReadTimeout = 30000;
|
||||
|
||||
public static CloseableHttpClient createHttpClient(PoolingHttpClientConnectionManager connManager) {
|
||||
//HttpHost httpHost = new HttpHost("10.211.55.4", 8888);
|
||||
CloseableHttpClient httpClient = HttpClients.custom()
|
||||
//.setProxy(httpHost)
|
||||
.setConnectionManager(connManager)
|
||||
.disableContentCompression()
|
||||
.setSSLContext(getSslcontext())
|
||||
.setDefaultRequestConfig(getRequestConfig())
|
||||
.build();
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public static PoolingHttpClientConnectionManager createHttpClientConnectionManager() {
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = null;
|
||||
try {
|
||||
sslConnectionSocketFactory = new SSLConnectionSocketFactory(getSslcontext(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("https", sslConnectionSocketFactory)
|
||||
.register("http", new PlainConnectionSocketFactory())
|
||||
.build();
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
cm.setMaxTotal(500);
|
||||
cm.setDefaultMaxPerRoute(500);
|
||||
return cm;
|
||||
}
|
||||
|
||||
private static RequestConfig getRequestConfig() {
|
||||
RequestConfig defaultRequestConfig = RequestConfig.custom()
|
||||
.setConnectionRequestTimeout(defaultConnectTimeout)
|
||||
.setSocketTimeout(defaultReadTimeout)
|
||||
.build();
|
||||
return defaultRequestConfig;
|
||||
}
|
||||
|
||||
private static SSLContext getSslcontext() {
|
||||
SSLContext sslContext = null;
|
||||
try {
|
||||
sslContext = SSLContext.getInstance("TLS");
|
||||
TrustManager tm = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
sslContext.init(null, new TrustManager[]{tm}, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sslContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
package com.ruoyi.bestsign.utils;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.*;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 参数签名算法工具类
|
||||
*/
|
||||
public class RSAUtils {
|
||||
|
||||
/**
|
||||
* 获取当前的时间戳参数
|
||||
* @return
|
||||
*/
|
||||
public static String getRtick(){
|
||||
long timestamp = System.currentTimeMillis();
|
||||
int rnd = (int)Math.random() * 1000;
|
||||
String rtick = timestamp + "" + rnd;
|
||||
return rtick;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算参数签名
|
||||
* @param developerId 开发者ID
|
||||
* @param privateKey 用户私钥
|
||||
* @param host 请求的HOST地址(http://ip:port/context)
|
||||
* @param methodName 请求的接口方法名
|
||||
* @param rtick 时间戳参数
|
||||
* @param urlParams url参数(param1=value1¶m2=value2¶m3=value3)
|
||||
* @param requestBody request body 参数(JSON字符串)
|
||||
* @return
|
||||
*/
|
||||
public static String calcRsaSign(String developerId, String privateKey, String host, String methodName, String rtick, String urlParams, String requestBody) {
|
||||
String url = host+methodName;
|
||||
|
||||
Map<String, String> mySignedURLParams = new TreeMap<String, String>();
|
||||
mySignedURLParams.put("developerId", developerId);
|
||||
mySignedURLParams.put("rtick", rtick);
|
||||
mySignedURLParams.put("signType", "rsa");
|
||||
|
||||
if(urlParams != null && !"".equals(urlParams)){
|
||||
String[] params = urlParams.split("&");
|
||||
for(String p1 : params){
|
||||
String[] p2 = p1.split("=");
|
||||
String key = p2[0];
|
||||
String value = "";
|
||||
if(p2.length == 2){
|
||||
value = p2[1];
|
||||
}
|
||||
mySignedURLParams.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
String requestPath;
|
||||
try {
|
||||
requestPath = new URL(url).getPath();
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
StringBuilder signStringBuilder = new StringBuilder();
|
||||
for (String name : mySignedURLParams.keySet()) {
|
||||
String value = mySignedURLParams.get(name);
|
||||
signStringBuilder.append(name);
|
||||
signStringBuilder.append("=");
|
||||
signStringBuilder.append(value);
|
||||
}
|
||||
signStringBuilder.append(requestPath);
|
||||
|
||||
if (requestBody != null && !"".equals(requestBody) ) {
|
||||
String requestMd5 = getRequestMd5(requestBody);
|
||||
signStringBuilder.append(requestMd5);
|
||||
}
|
||||
|
||||
String signString = signStringBuilder.toString();
|
||||
String rsaSign = calcRsaSign(privateKey, signString);
|
||||
//rsa算出来的sign,需要urlencode
|
||||
try {
|
||||
rsaSign = URLEncoder.encode(rsaSign,"UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
rsaSign = null;
|
||||
}
|
||||
return rsaSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取request body 的MD5
|
||||
* @param requestBody
|
||||
* @return
|
||||
*/
|
||||
private static String getRequestMd5(final String requestBody) {
|
||||
byte[] data;
|
||||
|
||||
String newRequestBody = convertToUtf8(requestBody);
|
||||
try {
|
||||
data = newRequestBody.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
return md5(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算参数RSA签名
|
||||
* @param privateKey
|
||||
* @param signData
|
||||
* @return
|
||||
*/
|
||||
private static String calcRsaSign(String privateKey, final String signData) {
|
||||
byte[] data;
|
||||
try {
|
||||
data = signData.getBytes("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
byte[] sign = null;
|
||||
// 解密由base64编码的私钥
|
||||
byte[] privateKeyBytes = base64decode(privateKey.getBytes());
|
||||
|
||||
// 构造PKCS8EncodedKeySpec对象
|
||||
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
|
||||
|
||||
// KEY_ALGORITHM 指定的加密算法
|
||||
KeyFactory keyFactory;
|
||||
try {
|
||||
keyFactory = KeyFactory.getInstance("RSA");
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
// 取私钥匙对象
|
||||
PrivateKey priKey;
|
||||
try {
|
||||
priKey = keyFactory.generatePrivate(pkcs8KeySpec);
|
||||
}
|
||||
catch (InvalidKeySpecException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
// 用私钥对信息生成数字签名
|
||||
Signature signature;
|
||||
try {
|
||||
signature = Signature.getInstance("SHA1withRSA");
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
signature.initSign(priKey);
|
||||
}
|
||||
catch (InvalidKeyException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
signature.update(data);
|
||||
sign = signature.sign();
|
||||
}
|
||||
catch (SignatureException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
return new String(base64encode(sign));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符集到utf8
|
||||
*
|
||||
* @param src
|
||||
* @return
|
||||
*/
|
||||
private static String convertToUtf8(String src) {
|
||||
if (src == null || src.length() == 0) {
|
||||
return src;
|
||||
}
|
||||
if ("UTF-8".equalsIgnoreCase(Charset.defaultCharset().name())) {
|
||||
return src;
|
||||
}
|
||||
|
||||
byte[] srcData = src.getBytes();
|
||||
try {
|
||||
return new String(srcData, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* md5
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String md5(byte[] data) {
|
||||
char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
||||
byte[] btInput = data;
|
||||
// 获得MD5摘要算法的 MessageDigest 对象
|
||||
MessageDigest mdInst;
|
||||
try {
|
||||
mdInst = MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
// 使用指定的字节更新摘要
|
||||
mdInst.update(btInput);
|
||||
// 获得密文
|
||||
byte[] md = mdInst.digest();
|
||||
// 把密文转换成十六进制的字符串形式
|
||||
int j = md.length;
|
||||
char str[] = new char[j * 2];
|
||||
int k = 0;
|
||||
for (int i = 0; i < j; i++) {
|
||||
byte byte0 = md[i];
|
||||
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
|
||||
str[k++] = hexDigits[byte0 & 0xf];
|
||||
}
|
||||
return new String(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static byte[] base64encode(byte[] data) {
|
||||
return Base64.encodeBase64(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码字符串
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String base64encodeString(byte[] data) {
|
||||
return Base64.encodeBase64String(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64解码
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static byte[] base64decode(byte[] data) {
|
||||
try {
|
||||
return Base64.decodeBase64(data);
|
||||
} catch (Exception e) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
byte c = data[i];
|
||||
if (c == 13 || c == 10) {
|
||||
continue;
|
||||
}
|
||||
outputStream.write(c);
|
||||
}
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
data = outputStream.toByteArray();
|
||||
return Base64.decodeBase64(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,4 +115,6 @@ public interface SysDeptMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById(Long deptId);
|
||||
|
||||
List<Long> selectUserDeptListByRoleId(@Param("roleId")Long roleId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
|
||||
@@ -19,6 +21,12 @@ public interface SysUserMapper
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 查询仲裁员角色下的用户
|
||||
* @return
|
||||
*/
|
||||
public List<SysUser> selectUserListByAdRole(Arbitrator arbitrator);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
@@ -124,4 +132,6 @@ public interface SysUserMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
List<SysUser> selectUserListByIds(@Param("idList") List<Long> idList);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
@@ -17,6 +18,7 @@ public interface ISysUserService
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser user);
|
||||
public List<SysUser> selectUserListByAdRole(Arbitrator arbitrator);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -74,6 +76,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUserListByAdRole(Arbitrator arbitrator) {
|
||||
return userMapper.selectUserListByAdRole(arbitrator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Adjudication {
|
||||
/**
|
||||
* 申请人姓名
|
||||
*/
|
||||
private String appName;
|
||||
/**
|
||||
* 申请人性别
|
||||
*/
|
||||
private String appSex;
|
||||
/**
|
||||
* 申请人身份证号码
|
||||
*/
|
||||
private String appIDNo;
|
||||
/**
|
||||
* 申请人住所
|
||||
*/
|
||||
private String appAddress;
|
||||
|
||||
/**
|
||||
* 申请人代理人姓名
|
||||
*/
|
||||
private String appAgentName;
|
||||
/**
|
||||
* 申请人代理人身份证
|
||||
*/
|
||||
private String appAgentIDNo;
|
||||
/**
|
||||
* 被申请人姓名
|
||||
*/
|
||||
private String resName;
|
||||
/**
|
||||
* 被申请人性别
|
||||
*/
|
||||
private String resSex;
|
||||
/**
|
||||
* 被申请人身份证号码
|
||||
*/
|
||||
private String resIDNo;
|
||||
/**
|
||||
* 被申请人住所
|
||||
*/
|
||||
private String resAddress;
|
||||
|
||||
/**
|
||||
* 被申请人代理人姓名
|
||||
*/
|
||||
private String resAgentName;
|
||||
/**
|
||||
* 被申请人代理人身份证
|
||||
*/
|
||||
private String resAgentIDNo;
|
||||
|
||||
/**
|
||||
* 案件名称
|
||||
*/
|
||||
private String caseName;
|
||||
|
||||
/**
|
||||
* 仲裁员名称
|
||||
*/
|
||||
private String arbitratorName;
|
||||
/**
|
||||
* 开庭年
|
||||
*/
|
||||
private String hearYear;
|
||||
/**
|
||||
* 开庭月
|
||||
*/
|
||||
private String hearMonths;
|
||||
/**
|
||||
* 开庭日
|
||||
*/
|
||||
private String hearDay;
|
||||
|
||||
/**
|
||||
* 申请人具体仲裁请求
|
||||
*/
|
||||
private String appArbitrationClaims;
|
||||
|
||||
/**
|
||||
* 申请人证据名称
|
||||
*/
|
||||
private String appEvidenceName;
|
||||
|
||||
/**
|
||||
* 申请人拟证事实
|
||||
*/
|
||||
private String appProveFacts;
|
||||
/**
|
||||
* 被申请人对申请人答辩内容
|
||||
*/
|
||||
private String resDefenseContentToApp;
|
||||
|
||||
/**
|
||||
* 被申请人具体仲裁请求
|
||||
*/
|
||||
private String resArbitrationClaims;
|
||||
/**
|
||||
* 被申请人证据名称
|
||||
*/
|
||||
private String resEvidenceName;
|
||||
/**
|
||||
* 被申请人拟证事实
|
||||
*/
|
||||
private String resProveFacts;
|
||||
/**
|
||||
* 申请人对被申请人答辩内容
|
||||
*/
|
||||
private String appDefenseContentToRes;
|
||||
/**
|
||||
* 第三人答辩内容
|
||||
*/
|
||||
private String thirdDefenseContent;
|
||||
/**
|
||||
* 第三人证据名称
|
||||
*/
|
||||
private String thirdEvidenceName;
|
||||
/**
|
||||
* 第三人拟证事实
|
||||
*/
|
||||
private String thirdProveFacts;
|
||||
/**
|
||||
* 申请人对第三人答辩内容
|
||||
*/
|
||||
private String appDefenseContentToThird;
|
||||
/**
|
||||
* 被申请人对第三人答辩内容
|
||||
*/
|
||||
private String resDefenseContentToThird;
|
||||
/**
|
||||
* 证据认定
|
||||
*/
|
||||
private String evidenDetermi;
|
||||
/**
|
||||
* 认定事实
|
||||
*/
|
||||
private String factDetermi;
|
||||
/**
|
||||
* 综上所述
|
||||
*/
|
||||
private String caseSketch;
|
||||
/**
|
||||
* 本庭认为
|
||||
*/
|
||||
private String arbitrateThink;
|
||||
/**
|
||||
* 裁决如下
|
||||
*/
|
||||
private String rulingFollows;
|
||||
/**
|
||||
* 法律条款
|
||||
*/
|
||||
private String legalProvisions;
|
||||
/**
|
||||
* 首席仲裁
|
||||
*/
|
||||
private String umpire;
|
||||
/**
|
||||
* 仲裁员1
|
||||
*/
|
||||
private String arbitratorName1;
|
||||
/**
|
||||
* 仲裁员2
|
||||
*/
|
||||
private String arbitratorName2;
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private String year;
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private String months;
|
||||
/**
|
||||
* 日
|
||||
*/
|
||||
private String day;
|
||||
/**
|
||||
* 书记员
|
||||
*/
|
||||
private String clerk;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ArbitrateRecord extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
/** 案件申请id */
|
||||
private Long caseAppliId;
|
||||
/** 证据认定 */
|
||||
private String evidenDetermi;
|
||||
/** 认定事实 */
|
||||
private String factDetermi;
|
||||
/** 综上所述 */
|
||||
private String caseSketch;
|
||||
/** 本庭认为 */
|
||||
private String arbitrateThink;
|
||||
/** 裁决如下 */
|
||||
private String rulingFollows;
|
||||
/** 核验裁决书意见 */
|
||||
private String verificaOpinion;
|
||||
/** 审核裁决书意见 */
|
||||
private String checkOpinion;
|
||||
/** 裁决书附件id */
|
||||
private Integer annexId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Arbitrator extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
/** 仲裁员姓名 */
|
||||
private String arbitratorName;
|
||||
/** 职称 */
|
||||
private String title;
|
||||
/** 职业 */
|
||||
private String career;
|
||||
/** 专业分类 */
|
||||
private String professiClassifi;
|
||||
/** 学历 */
|
||||
private String education;
|
||||
/** 所在地区 */
|
||||
private String area;
|
||||
/** 联系电话 */
|
||||
private String telephone;
|
||||
|
||||
List<Long> idList;
|
||||
|
||||
public List<Long> getIdList() {
|
||||
return idList;
|
||||
}
|
||||
|
||||
public void setIdList(List<Long> idList) {
|
||||
this.idList = idList;
|
||||
}
|
||||
|
||||
public String getArbitratorName() {
|
||||
return arbitratorName;
|
||||
}
|
||||
|
||||
public void setArbitratorName(String arbitratorName) {
|
||||
this.arbitratorName = arbitratorName;
|
||||
}
|
||||
|
||||
/** 当前案件数量 */
|
||||
private int currentCaseNum;
|
||||
/** 已结案数量 */
|
||||
private int closedCaseNum;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getCareer() {
|
||||
return career;
|
||||
}
|
||||
|
||||
public void setCareer(String career) {
|
||||
this.career = career;
|
||||
}
|
||||
|
||||
public String getProfessiClassifi() {
|
||||
return professiClassifi;
|
||||
}
|
||||
|
||||
public void setProfessiClassifi(String professiClassifi) {
|
||||
this.professiClassifi = professiClassifi;
|
||||
}
|
||||
|
||||
public String getEducation() {
|
||||
return education;
|
||||
}
|
||||
|
||||
public void setEducation(String education) {
|
||||
this.education = education;
|
||||
}
|
||||
|
||||
public String getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(String area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public int getCurrentCaseNum() {
|
||||
return currentCaseNum;
|
||||
}
|
||||
|
||||
public void setCurrentCaseNum(int currentCaseNum) {
|
||||
this.currentCaseNum = currentCaseNum;
|
||||
}
|
||||
|
||||
public int getClosedCaseNum() {
|
||||
return closedCaseNum;
|
||||
}
|
||||
|
||||
public void setClosedCaseNum(int closedCaseNum) {
|
||||
this.closedCaseNum = closedCaseNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
public class CaseAffiliate extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/** ID */
|
||||
@Excel(name = "ID", cellType = Excel.ColumnType.NUMERIC, prompt = "ID")
|
||||
private Long id;
|
||||
/** 案件申请id */
|
||||
private Long caseAppliId;
|
||||
/** 身份类型 */
|
||||
private int identityType;
|
||||
/** 姓名 */
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
/**
|
||||
* 申请机构id
|
||||
*/
|
||||
private String applicationOrganId;
|
||||
/**
|
||||
* 申请机构名称
|
||||
*/
|
||||
private String applicationOrganName;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "身份证号")
|
||||
private String identityNum;
|
||||
/** 单位电话 */
|
||||
@Excel(name = "单位电话")
|
||||
private String workTelphone;
|
||||
/** 联系电话 */
|
||||
@Excel(name = "联系电话")
|
||||
private String contactTelphone;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "联系地址")
|
||||
private String contactAddress;
|
||||
/** 单位地址 */
|
||||
@Excel(name = "单位地址")
|
||||
private String workAddress;
|
||||
|
||||
/** 代理人姓名 */
|
||||
@Excel(name = "代理人姓名")
|
||||
private String nameAgent;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "代理人身份证号")
|
||||
private String identityNumAgent;
|
||||
/** 联系电话 */
|
||||
@Excel(name = "代理人联系电话")
|
||||
private String contactTelphoneAgent;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "代理人联系地址")
|
||||
private String contactAddressAgent;
|
||||
|
||||
/** 送达电子邮件 */
|
||||
private String sendEmail;
|
||||
/** 快递单号 */
|
||||
private String trackNum;
|
||||
|
||||
public String getApplicationOrganId() {
|
||||
return applicationOrganId;
|
||||
}
|
||||
|
||||
public void setApplicationOrganId(String applicationOrganId) {
|
||||
this.applicationOrganId = applicationOrganId;
|
||||
}
|
||||
|
||||
public String getApplicationOrganName() {
|
||||
return applicationOrganName;
|
||||
}
|
||||
|
||||
public void setApplicationOrganName(String applicationOrganName) {
|
||||
this.applicationOrganName = applicationOrganName;
|
||||
}
|
||||
|
||||
public String getSendEmail() {
|
||||
return sendEmail;
|
||||
}
|
||||
|
||||
public void setSendEmail(String sendEmail) {
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
|
||||
public String getTrackNum() {
|
||||
return trackNum;
|
||||
}
|
||||
|
||||
public void setTrackNum(String trackNum) {
|
||||
this.trackNum = trackNum;
|
||||
}
|
||||
|
||||
public String getNameAgent() {
|
||||
return nameAgent;
|
||||
}
|
||||
|
||||
public void setNameAgent(String nameAgent) {
|
||||
this.nameAgent = nameAgent;
|
||||
}
|
||||
|
||||
public String getIdentityNumAgent() {
|
||||
return identityNumAgent;
|
||||
}
|
||||
|
||||
public void setIdentityNumAgent(String identityNumAgent) {
|
||||
this.identityNumAgent = identityNumAgent;
|
||||
}
|
||||
|
||||
public String getContactTelphoneAgent() {
|
||||
return contactTelphoneAgent;
|
||||
}
|
||||
|
||||
public void setContactTelphoneAgent(String contactTelphoneAgent) {
|
||||
this.contactTelphoneAgent = contactTelphoneAgent;
|
||||
}
|
||||
|
||||
public String getContactAddressAgent() {
|
||||
return contactAddressAgent;
|
||||
}
|
||||
|
||||
public void setContactAddressAgent(String contactAddressAgent) {
|
||||
this.contactAddressAgent = contactAddressAgent;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getCaseAppliId() {
|
||||
return caseAppliId;
|
||||
}
|
||||
|
||||
public void setCaseAppliId(Long caseAppliId) {
|
||||
this.caseAppliId = caseAppliId;
|
||||
}
|
||||
|
||||
public int getIdentityType() {
|
||||
return identityType;
|
||||
}
|
||||
|
||||
public void setIdentityType(int identityType) {
|
||||
this.identityType = identityType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIdentityNum() {
|
||||
return identityNum;
|
||||
}
|
||||
|
||||
public void setIdentityNum(String identityNum) {
|
||||
this.identityNum = identityNum;
|
||||
}
|
||||
|
||||
public String getWorkTelphone() {
|
||||
return workTelphone;
|
||||
}
|
||||
|
||||
public void setWorkTelphone(String workTelphone) {
|
||||
this.workTelphone = workTelphone;
|
||||
}
|
||||
|
||||
public String getContactTelphone() {
|
||||
return contactTelphone;
|
||||
}
|
||||
|
||||
public void setContactTelphone(String contactTelphone) {
|
||||
this.contactTelphone = contactTelphone;
|
||||
}
|
||||
|
||||
public String getContactAddress() {
|
||||
return contactAddress;
|
||||
}
|
||||
|
||||
public void setContactAddress(String contactAddress) {
|
||||
this.contactAddress = contactAddress;
|
||||
}
|
||||
|
||||
public String getWorkAddress() {
|
||||
return workAddress;
|
||||
}
|
||||
|
||||
public void setWorkAddress(String workAddress) {
|
||||
this.workAddress = workAddress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,811 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class CaseApplication extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
/** 案件编号 */
|
||||
// @Excel(name = "案件编号")
|
||||
private String caseNum;
|
||||
/** 案件标的 */
|
||||
@Excel(name = "案件标的")
|
||||
private BigDecimal caseSubjectAmount;
|
||||
|
||||
|
||||
/** 立案日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date registerDate;
|
||||
/** 仲裁方式 */
|
||||
private Integer arbitratMethod;
|
||||
|
||||
public Integer getArbitratMethod() {
|
||||
return arbitratMethod;
|
||||
}
|
||||
|
||||
public void setArbitratMethod(Integer arbitratMethod) {
|
||||
this.arbitratMethod = arbitratMethod;
|
||||
}
|
||||
/** 仲裁方式名称 */
|
||||
private String arbitratMethodName;
|
||||
|
||||
public String getArbitratMethodName() {
|
||||
return arbitratMethodName;
|
||||
}
|
||||
|
||||
public void setArbitratMethodName(String arbitratMethodName) {
|
||||
this.arbitratMethodName = arbitratMethodName;
|
||||
}
|
||||
|
||||
/** 案件状态 */
|
||||
private Integer caseStatus;
|
||||
|
||||
public Integer getCaseStatus() {
|
||||
return caseStatus;
|
||||
}
|
||||
|
||||
public void setCaseStatus(Integer caseStatus) {
|
||||
this.caseStatus = caseStatus;
|
||||
}
|
||||
|
||||
/** 开庭日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date hearDate;
|
||||
|
||||
/** 借款开始日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "借款开始日期")
|
||||
private Date loanStartDate;
|
||||
/** 借款结束日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "借款结束日期")
|
||||
private Date loanEndDate;
|
||||
/** 合同编号 */
|
||||
@Excel(name = "合同编号")
|
||||
private String contractNumber;
|
||||
/** 申请人主张欠本金 */
|
||||
@Excel(name = "申请人主张欠本金")
|
||||
private BigDecimal claimPrinciOwed;
|
||||
/** 申请人主张欠利息 */
|
||||
@Excel(name = "申请人主张欠利息")
|
||||
private BigDecimal claimInterestOwed;
|
||||
/** 申请人主张违约金 */
|
||||
@Excel(name = "申请人主张违约金")
|
||||
private BigDecimal claimLiquidDamag;
|
||||
/** 申请人仲裁诉求 */
|
||||
@Excel(name = "申请人仲裁诉求")
|
||||
private String arbitratClaims;
|
||||
/** 仲裁应缴费用 */
|
||||
private BigDecimal feePayable;
|
||||
|
||||
/** 开始在线视频时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date beginVideoDate;
|
||||
/** 在线视频人员 */
|
||||
private String onlineVideoPerson;
|
||||
|
||||
/** 仲裁员id */
|
||||
private String arbitratorId;
|
||||
/** 仲裁员名称 */
|
||||
private String arbitratorName;
|
||||
|
||||
/** 案件名称 */
|
||||
private String caseName;
|
||||
|
||||
/** 案件描述 */
|
||||
private String caseDescribe;
|
||||
/** 裁决书URL */
|
||||
private String filearbitraUrl;
|
||||
|
||||
public String getFilearbitraUrl() {
|
||||
return filearbitraUrl;
|
||||
}
|
||||
|
||||
public void setFilearbitraUrl(String filearbitraUrl) {
|
||||
this.filearbitraUrl = filearbitraUrl;
|
||||
}
|
||||
|
||||
/** 是否同意组庭 */
|
||||
private Integer isAgreePendTral;
|
||||
|
||||
/** 是否有异议需要举证 */
|
||||
private Integer objectionAddEviden;
|
||||
/** 是否需要开庭审理 */
|
||||
private Integer openCourtHear;
|
||||
|
||||
/** 支付状态 */
|
||||
private Integer paymentStatus;
|
||||
/** 支付状态描述 */
|
||||
private String paymentStatusName;
|
||||
/**
|
||||
* 支付方式code,0线上支付,1线下支付
|
||||
*/
|
||||
private Integer payTypeCode;
|
||||
/**
|
||||
* 支付方式name,0线上支付,1线下支付
|
||||
*/
|
||||
private String payTypeName;
|
||||
/**
|
||||
* 缴费凭证
|
||||
*/
|
||||
private List<CaseAttach> payOrderList;
|
||||
// 导入校验失败信息
|
||||
private StringBuilder errorMsg;
|
||||
|
||||
public Integer getPayTypeCode() {
|
||||
return payTypeCode;
|
||||
}
|
||||
|
||||
public void setPayTypeCode(Integer payTypeCode) {
|
||||
this.payTypeCode = payTypeCode;
|
||||
}
|
||||
|
||||
public String getPayTypeName() {
|
||||
return payTypeName;
|
||||
}
|
||||
|
||||
public void setPayTypeName(String payTypeName) {
|
||||
this.payTypeName = payTypeName;
|
||||
}
|
||||
|
||||
public List<CaseAttach> getPayOrderList() {
|
||||
return payOrderList;
|
||||
}
|
||||
|
||||
public void setPayOrderList(List<CaseAttach> payOrderList) {
|
||||
this.payOrderList = payOrderList;
|
||||
}
|
||||
|
||||
public StringBuilder getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(StringBuilder errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public Integer getPaymentStatus() {
|
||||
return paymentStatus;
|
||||
}
|
||||
|
||||
public void setPaymentStatus(Integer paymentStatus) {
|
||||
this.paymentStatus = paymentStatus;
|
||||
}
|
||||
|
||||
public String getPaymentStatusName() {
|
||||
return paymentStatusName;
|
||||
}
|
||||
|
||||
public void setPaymentStatusName(String paymentStatusName) {
|
||||
this.paymentStatusName = paymentStatusName;
|
||||
}
|
||||
|
||||
public Integer getIsAgreePendTral() {
|
||||
return isAgreePendTral;
|
||||
}
|
||||
|
||||
public void setIsAgreePendTral(Integer isAgreePendTral) {
|
||||
this.isAgreePendTral = isAgreePendTral;
|
||||
}
|
||||
|
||||
public Integer getObjectionAddEviden() {
|
||||
return objectionAddEviden;
|
||||
}
|
||||
|
||||
public void setObjectionAddEviden(Integer objectionAddEviden) {
|
||||
this.objectionAddEviden = objectionAddEviden;
|
||||
}
|
||||
|
||||
public Integer getOpenCourtHear() {
|
||||
return openCourtHear;
|
||||
}
|
||||
|
||||
public void setOpenCourtHear(Integer openCourtHear) {
|
||||
this.openCourtHear = openCourtHear;
|
||||
}
|
||||
|
||||
/** 案件状态名称 */
|
||||
private String caseStatusName;
|
||||
/** 是否同意审核 */
|
||||
private Integer agreeOrNotCheck;
|
||||
|
||||
public Integer getAgreeOrNotCheck() {
|
||||
return agreeOrNotCheck;
|
||||
}
|
||||
|
||||
public void setAgreeOrNotCheck(Integer agreeOrNotCheck) {
|
||||
this.agreeOrNotCheck = agreeOrNotCheck;
|
||||
}
|
||||
|
||||
public String getCaseStatusName() {
|
||||
return caseStatusName;
|
||||
}
|
||||
|
||||
public void setCaseStatusName(String caseStatusName) {
|
||||
this.caseStatusName = caseStatusName;
|
||||
}
|
||||
|
||||
/** 申请人名称 */
|
||||
private String applicantName;
|
||||
/** 被申请人名称 */
|
||||
private String respondentName;
|
||||
/**
|
||||
* 用户身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
private List<Long> deptIds;
|
||||
|
||||
public List<Long> getDeptIds() {
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
public void setDeptIds(List<Long> deptIds) {
|
||||
this.deptIds = deptIds;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
public String getApplicantName() {
|
||||
return applicantName;
|
||||
}
|
||||
|
||||
public void setApplicantName(String applicantName) {
|
||||
this.applicantName = applicantName;
|
||||
}
|
||||
|
||||
public String getRespondentName() {
|
||||
return respondentName;
|
||||
}
|
||||
|
||||
public void setRespondentName(String respondentName) {
|
||||
this.respondentName = respondentName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCaseName() {
|
||||
return caseName;
|
||||
}
|
||||
|
||||
public void setCaseName(String caseName) {
|
||||
this.caseName = caseName;
|
||||
}
|
||||
|
||||
public String getCaseDescribe() {
|
||||
return caseDescribe;
|
||||
}
|
||||
|
||||
public void setCaseDescribe(String caseDescribe) {
|
||||
this.caseDescribe = caseDescribe;
|
||||
}
|
||||
|
||||
public String getCaseResult() {
|
||||
return caseResult;
|
||||
}
|
||||
|
||||
public void setCaseResult(String caseResult) {
|
||||
this.caseResult = caseResult;
|
||||
}
|
||||
|
||||
/** 仲裁结果 */
|
||||
private String caseResult;
|
||||
|
||||
|
||||
|
||||
public String getArbitratorName() {
|
||||
return arbitratorName;
|
||||
}
|
||||
|
||||
public void setArbitratorName(String arbitratorName) {
|
||||
this.arbitratorName = arbitratorName;
|
||||
}
|
||||
|
||||
/** 是否指派仲裁员 */
|
||||
private int pendingAppointArbotrar;
|
||||
|
||||
public int getPendingAppointArbotrar() {
|
||||
return pendingAppointArbotrar;
|
||||
}
|
||||
|
||||
public void setPendingAppointArbotrar(int pendingAppointArbotrar) {
|
||||
this.pendingAppointArbotrar = pendingAppointArbotrar;
|
||||
}
|
||||
|
||||
public String getArbitratorId() {
|
||||
return arbitratorId;
|
||||
}
|
||||
|
||||
public void setArbitratorId(String arbitratorId) {
|
||||
this.arbitratorId = arbitratorId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 案件关联人信息 */
|
||||
private List<CaseAffiliate> caseAffiliates;
|
||||
|
||||
/** 案件仲裁员 */
|
||||
private List<Arbitrator> arbitrators;
|
||||
|
||||
private List<Integer> caseStatusList;
|
||||
|
||||
private List<Integer> annexTypeList;
|
||||
|
||||
private Integer annexType;
|
||||
|
||||
public Integer getAnnexType() {
|
||||
return annexType;
|
||||
}
|
||||
|
||||
public void setAnnexType(Integer annexType) {
|
||||
this.annexType = annexType;
|
||||
}
|
||||
|
||||
public List<Integer> getAnnexTypeList() {
|
||||
return annexTypeList;
|
||||
}
|
||||
|
||||
public void setAnnexTypeList(List<Integer> annexTypeList) {
|
||||
this.annexTypeList = annexTypeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 案件附件列表
|
||||
*/
|
||||
private List<CaseAttach> caseAttachList;
|
||||
|
||||
public List<CaseAttach> getCaseAttachList() {
|
||||
return caseAttachList;
|
||||
}
|
||||
|
||||
public void setCaseAttachList(List<CaseAttach> caseAttachList) {
|
||||
this.caseAttachList = caseAttachList;
|
||||
}
|
||||
|
||||
public List<Integer> getCaseStatusList() {
|
||||
return caseStatusList;
|
||||
}
|
||||
|
||||
public void setCaseStatusList(List<Integer> caseStatusList) {
|
||||
this.caseStatusList = caseStatusList;
|
||||
}
|
||||
|
||||
/** 仲裁记录 */
|
||||
private ArbitrateRecord arbitrateRecord;
|
||||
|
||||
public ArbitrateRecord getArbitrateRecord() {
|
||||
return arbitrateRecord;
|
||||
}
|
||||
|
||||
public void setArbitrateRecord(ArbitrateRecord arbitrateRecord) {
|
||||
this.arbitrateRecord = arbitrateRecord;
|
||||
}
|
||||
|
||||
public List<Arbitrator> getArbitrators() {
|
||||
return arbitrators;
|
||||
}
|
||||
|
||||
public void setArbitrators(List<Arbitrator> arbitrators) {
|
||||
this.arbitrators = arbitrators;
|
||||
}
|
||||
|
||||
/** 身份类型 */
|
||||
// @Excel(name = "身份类型")
|
||||
private int identityType;
|
||||
/**
|
||||
* 申请人主体信息
|
||||
*/
|
||||
/** 姓名 */
|
||||
@Excel(name = "申请人主体信息-申请人(机构)",width = 26)
|
||||
private String name;
|
||||
/**
|
||||
* 申请人主体信息-申请人(机构)id
|
||||
*/
|
||||
private String nameId;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "申请人主体信息-代码",width = 26)
|
||||
private String identityNum;
|
||||
|
||||
/** 联系电话 */
|
||||
@Excel(name = "申请人主体信息-联系电话",width = 26)
|
||||
private String contactTelphone;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "申请人主体信息-联系地址",width = 26)
|
||||
private String contactAddress;
|
||||
/** 单位电话 */
|
||||
@Excel(name = "申请人主体信息-单位电话",width = 26)
|
||||
private String workTelphone;
|
||||
/** 单位地址 */
|
||||
@Excel(name = "申请人主体信息-单位地址",width = 26)
|
||||
private String workAddress;
|
||||
|
||||
/** 代理人姓名 */
|
||||
@Excel(name = "申请人主体信息-代理人姓名",width = 26)
|
||||
private String nameAgent;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "申请人主体信息-代理人身份证号",width = 26)
|
||||
private String identityNumAgent;
|
||||
/** 联系电话 */
|
||||
@Excel(name = "申请人主体信息-代理人联系电话",width = 26)
|
||||
private String contactTelphoneAgent;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "申请人主体信息-代理人联系地址",width = 26)
|
||||
private String contactAddressAgent;
|
||||
/**
|
||||
* 被申请人主体信息
|
||||
*/
|
||||
/** 姓名 */
|
||||
@Excel(name = "被申请人主体信息-申请人姓名",width = 26)
|
||||
private String debtorName;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "被申请人主体信息-身份证号",width = 26)
|
||||
private String debtorIdentityNum;
|
||||
|
||||
/** 联系电话 */
|
||||
@Excel(name = "被申请人主体信息-联系电话",width = 26)
|
||||
private String debtorContactTelphone;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "被申请人主体信息-联系地址",width = 26)
|
||||
private String debtorContactAddress;
|
||||
/** 单位电话 */
|
||||
@Excel(name = "被申请人主体信息-单位电话",width = 26)
|
||||
private String debtorWorkTelphone;
|
||||
/** 单位地址 */
|
||||
@Excel(name = "被申请人主体信息-单位地址",width = 26)
|
||||
private String debtorWorkAddress;
|
||||
|
||||
/** 代理人姓名 */
|
||||
@Excel(name = "被申请人主体信息-代理人姓名",width = 26)
|
||||
private String debtorNameAgent;
|
||||
/** 身份证号 */
|
||||
@Excel(name = "被申请人主体信息-代理人身份证号",width = 26)
|
||||
private String debtorIdentityNumAgent;
|
||||
/** 联系电话 */
|
||||
@Excel(name = "被申请人主体信息-代理人联系电话",width = 26)
|
||||
private String debtorContactTelphoneAgent;
|
||||
/** 联系地址 */
|
||||
@Excel(name = "被申请人主体信息-代理人联系地址",width = 26)
|
||||
private String debtorContactAddressAgent;
|
||||
|
||||
public int getIdentityType() {
|
||||
return identityType;
|
||||
}
|
||||
|
||||
public void setIdentityType(int identityType) {
|
||||
this.identityType = identityType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNameId() {
|
||||
return nameId;
|
||||
}
|
||||
|
||||
public void setNameId(String nameId) {
|
||||
this.nameId = nameId;
|
||||
}
|
||||
|
||||
public String getIdentityNum() {
|
||||
return identityNum;
|
||||
}
|
||||
|
||||
public void setIdentityNum(String identityNum) {
|
||||
this.identityNum = identityNum;
|
||||
}
|
||||
|
||||
public String getWorkTelphone() {
|
||||
return workTelphone;
|
||||
}
|
||||
|
||||
public void setWorkTelphone(String workTelphone) {
|
||||
this.workTelphone = workTelphone;
|
||||
}
|
||||
|
||||
public String getContactTelphone() {
|
||||
return contactTelphone;
|
||||
}
|
||||
|
||||
public void setContactTelphone(String contactTelphone) {
|
||||
this.contactTelphone = contactTelphone;
|
||||
}
|
||||
|
||||
public String getContactAddress() {
|
||||
return contactAddress;
|
||||
}
|
||||
|
||||
public void setContactAddress(String contactAddress) {
|
||||
this.contactAddress = contactAddress;
|
||||
}
|
||||
|
||||
public String getWorkAddress() {
|
||||
return workAddress;
|
||||
}
|
||||
|
||||
public void setWorkAddress(String workAddress) {
|
||||
this.workAddress = workAddress;
|
||||
}
|
||||
|
||||
public String getNameAgent() {
|
||||
return nameAgent;
|
||||
}
|
||||
|
||||
public void setNameAgent(String nameAgent) {
|
||||
this.nameAgent = nameAgent;
|
||||
}
|
||||
|
||||
public String getIdentityNumAgent() {
|
||||
return identityNumAgent;
|
||||
}
|
||||
|
||||
public void setIdentityNumAgent(String identityNumAgent) {
|
||||
this.identityNumAgent = identityNumAgent;
|
||||
}
|
||||
|
||||
public String getContactTelphoneAgent() {
|
||||
return contactTelphoneAgent;
|
||||
}
|
||||
|
||||
public void setContactTelphoneAgent(String contactTelphoneAgent) {
|
||||
this.contactTelphoneAgent = contactTelphoneAgent;
|
||||
}
|
||||
|
||||
public String getContactAddressAgent() {
|
||||
return contactAddressAgent;
|
||||
}
|
||||
|
||||
public void setContactAddressAgent(String contactAddressAgent) {
|
||||
this.contactAddressAgent = contactAddressAgent;
|
||||
}
|
||||
|
||||
|
||||
public String getDebtorName() {
|
||||
return debtorName;
|
||||
}
|
||||
|
||||
public void setDebtorName(String debtorName) {
|
||||
this.debtorName = debtorName;
|
||||
}
|
||||
|
||||
public String getDebtorIdentityNum() {
|
||||
return debtorIdentityNum;
|
||||
}
|
||||
|
||||
public void setDebtorIdentityNum(String debtorIdentityNum) {
|
||||
this.debtorIdentityNum = debtorIdentityNum;
|
||||
}
|
||||
|
||||
public String getDebtorContactTelphone() {
|
||||
return debtorContactTelphone;
|
||||
}
|
||||
|
||||
public void setDebtorContactTelphone(String debtorContactTelphone) {
|
||||
this.debtorContactTelphone = debtorContactTelphone;
|
||||
}
|
||||
|
||||
public String getDebtorContactAddress() {
|
||||
return debtorContactAddress;
|
||||
}
|
||||
|
||||
public void setDebtorContactAddress(String debtorContactAddress) {
|
||||
this.debtorContactAddress = debtorContactAddress;
|
||||
}
|
||||
|
||||
public String getDebtorWorkTelphone() {
|
||||
return debtorWorkTelphone;
|
||||
}
|
||||
|
||||
public void setDebtorWorkTelphone(String debtorWorkTelphone) {
|
||||
this.debtorWorkTelphone = debtorWorkTelphone;
|
||||
}
|
||||
|
||||
public String getDebtorWorkAddress() {
|
||||
return debtorWorkAddress;
|
||||
}
|
||||
|
||||
public void setDebtorWorkAddress(String debtorWorkAddress) {
|
||||
this.debtorWorkAddress = debtorWorkAddress;
|
||||
}
|
||||
|
||||
public String getDebtorNameAgent() {
|
||||
return debtorNameAgent;
|
||||
}
|
||||
|
||||
public void setDebtorNameAgent(String debtorNameAgent) {
|
||||
this.debtorNameAgent = debtorNameAgent;
|
||||
}
|
||||
|
||||
public String getDebtorIdentityNumAgent() {
|
||||
return debtorIdentityNumAgent;
|
||||
}
|
||||
|
||||
public void setDebtorIdentityNumAgent(String debtorIdentityNumAgent) {
|
||||
this.debtorIdentityNumAgent = debtorIdentityNumAgent;
|
||||
}
|
||||
|
||||
public String getDebtorContactTelphoneAgent() {
|
||||
return debtorContactTelphoneAgent;
|
||||
}
|
||||
|
||||
public void setDebtorContactTelphoneAgent(String debtorContactTelphoneAgent) {
|
||||
this.debtorContactTelphoneAgent = debtorContactTelphoneAgent;
|
||||
}
|
||||
|
||||
public String getDebtorContactAddressAgent() {
|
||||
return debtorContactAddressAgent;
|
||||
}
|
||||
|
||||
public void setDebtorContactAddressAgent(String debtorContactAddressAgent) {
|
||||
this.debtorContactAddressAgent = debtorContactAddressAgent;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCaseNum() {
|
||||
return caseNum;
|
||||
}
|
||||
|
||||
public void setCaseNum(String caseNum) {
|
||||
this.caseNum = caseNum;
|
||||
}
|
||||
|
||||
public String getContractNumber() {
|
||||
return contractNumber;
|
||||
}
|
||||
|
||||
public void setContractNumber(String contractNumber) {
|
||||
this.contractNumber = contractNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getCaseSubjectAmount() {
|
||||
return caseSubjectAmount;
|
||||
}
|
||||
|
||||
public void setCaseSubjectAmount(BigDecimal caseSubjectAmount) {
|
||||
this.caseSubjectAmount = caseSubjectAmount;
|
||||
}
|
||||
|
||||
public Date getRegisterDate() {
|
||||
return registerDate;
|
||||
}
|
||||
|
||||
public void setRegisterDate(Date registerDate) {
|
||||
this.registerDate = registerDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Date getHearDate() {
|
||||
return hearDate;
|
||||
}
|
||||
|
||||
public void setHearDate(Date hearDate) {
|
||||
this.hearDate = hearDate;
|
||||
}
|
||||
|
||||
public String getArbitratClaims() {
|
||||
return arbitratClaims;
|
||||
}
|
||||
|
||||
public void setArbitratClaims(String arbitratClaims) {
|
||||
this.arbitratClaims = arbitratClaims;
|
||||
}
|
||||
|
||||
public Date getLoanStartDate() {
|
||||
return loanStartDate;
|
||||
}
|
||||
|
||||
public void setLoanStartDate(Date loanStartDate) {
|
||||
this.loanStartDate = loanStartDate;
|
||||
}
|
||||
|
||||
public Date getLoanEndDate() {
|
||||
return loanEndDate;
|
||||
}
|
||||
|
||||
public void setLoanEndDate(Date loanEndDate) {
|
||||
this.loanEndDate = loanEndDate;
|
||||
}
|
||||
|
||||
public BigDecimal getClaimPrinciOwed() {
|
||||
return claimPrinciOwed;
|
||||
}
|
||||
|
||||
public void setClaimPrinciOwed(BigDecimal claimPrinciOwed) {
|
||||
this.claimPrinciOwed = claimPrinciOwed;
|
||||
}
|
||||
|
||||
public BigDecimal getClaimInterestOwed() {
|
||||
return claimInterestOwed;
|
||||
}
|
||||
|
||||
public void setClaimInterestOwed(BigDecimal claimInterestOwed) {
|
||||
this.claimInterestOwed = claimInterestOwed;
|
||||
}
|
||||
|
||||
public BigDecimal getClaimLiquidDamag() {
|
||||
return claimLiquidDamag;
|
||||
}
|
||||
|
||||
public void setClaimLiquidDamag(BigDecimal claimLiquidDamag) {
|
||||
this.claimLiquidDamag = claimLiquidDamag;
|
||||
}
|
||||
|
||||
public BigDecimal getFeePayable() {
|
||||
return feePayable;
|
||||
}
|
||||
|
||||
public void setFeePayable(BigDecimal feePayable) {
|
||||
this.feePayable = feePayable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Date getBeginVideoDate() {
|
||||
return beginVideoDate;
|
||||
}
|
||||
|
||||
public void setBeginVideoDate(Date beginVideoDate) {
|
||||
this.beginVideoDate = beginVideoDate;
|
||||
}
|
||||
|
||||
public String getOnlineVideoPerson() {
|
||||
return onlineVideoPerson;
|
||||
}
|
||||
|
||||
public void setOnlineVideoPerson(String onlineVideoPerson) {
|
||||
this.onlineVideoPerson = onlineVideoPerson;
|
||||
}
|
||||
|
||||
public List<CaseAffiliate> getCaseAffiliates() {
|
||||
return caseAffiliates;
|
||||
}
|
||||
|
||||
public void setCaseAffiliates(List<CaseAffiliate> caseAffiliates) {
|
||||
this.caseAffiliates = caseAffiliates;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user