diff --git a/pay/pom.xml b/pay/pom.xml new file mode 100644 index 0000000..0558d6f --- /dev/null +++ b/pay/pom.xml @@ -0,0 +1,59 @@ + + + + ruoyi + com.ruoyi + 3.8.6 + + 4.0.0 + pay + 1.0.0-SNAPSHOT + + + 8 + 8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-autoconfigure + 2.7.10 + true + + + + org.projectlombok + lombok + 1.18.22 + + + com.alibaba + fastjson + 1.2.72 + + + cn.hutool + hutool-all + 5.7.12 + + + com.github.wechatpay-apiv3 + wechatpay-apache-httpclient + 0.4.7 + + + com.alipay.sdk + alipay-sdk-java + 4.34.8.ALL + + + + + \ No newline at end of file diff --git a/pay/src/main/java/com/ruoyi/CallBackService.java b/pay/src/main/java/com/ruoyi/CallBackService.java new file mode 100644 index 0000000..29fb770 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/CallBackService.java @@ -0,0 +1,32 @@ +package com.ruoyi; + +/** + * 业务回调处理接口 + */ +public interface CallBackService { + + /** + * 成功支付--处理业务逻辑 + * @param orderSn 订单号 + */ + void successPay(String orderSn); + + /** + * 失败支付-处理业务逻辑 + * @param orderSn 订单号 + */ + void failPay(String orderSn); + + /** + * 退款成功-处理业务逻辑 + * @param orderSn 订单号 + */ + void successRefund(String orderSn); + + /** + * 退款失败-处理业务逻辑 + * @param orderSn 订单号 + */ + void failRefund(String orderSn); + +} diff --git a/pay/src/main/java/com/ruoyi/ElegentPay.java b/pay/src/main/java/com/ruoyi/ElegentPay.java new file mode 100644 index 0000000..e79ae0e --- /dev/null +++ b/pay/src/main/java/com/ruoyi/ElegentPay.java @@ -0,0 +1,66 @@ +package com.ruoyi; + + +import com.ruoyi.dto.*; +import com.ruoyi.exceptions.TradeException; + +public interface ElegentPay { + + + /** + * 统一下单接口 + * @param payRequest 支付请求 + * @param tradeType 交易类型 + * @param platform 平台 + * @return 支付响应 + * @throws TradeException + */ + PayResponse requestPay(PayRequest payRequest, String tradeType, String platform) throws TradeException; + + + /** + * 关闭订单 + * @param orderSn 订单号 + * @param platform 平台 + * @return 是否成功关闭订单 + * @throws TradeException + */ + Boolean closePay(String orderSn, String platform) throws TradeException; + + /** + * 退款 + * @param refundRequest 退款请求封装对象 + * @param platform 平台 + * @return 是否成功退款 + * @throws TradeException + */ + Boolean refund(RefundRequest refundRequest, String platform) throws TradeException; + + /** + * 根据订单号查询订单 + * @param orderSn 订单号 + * @param platform 平台 + * @return 查询响应对象 + * @throws TradeException + */ + QueryResponse queryTradingOrderNo(String orderSn , String platform) throws TradeException; + + + /** + * 查询单笔退款API + * @param orderSn 订单号 + * @param platform 平台 + * @return 查询退款响应对象 + * @throws TradeException + */ + QueryRefundResponse queryRefundTrading(String orderSn , String platform) throws TradeException; + + + /** + * 获得openID + * @param code + * @return + */ + public String getOpenid(String code, String platform); + +} diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java b/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java new file mode 100644 index 0000000..1648dde --- /dev/null +++ b/pay/src/main/java/com/ruoyi/ali/AlipayConfig.java @@ -0,0 +1,40 @@ +package com.ruoyi.ali; + +import com.ruoyi.key.KeyManager; +import lombok.Data; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 支付宝权限对接类 + */ +@Component +@ConfigurationProperties("elegent.pay.alipay") +@Data +public class AlipayConfig { + /** + * 应用识别码 + */ + private String appId; + + /** + * 密钥加密方式 RSA2 + */ + @Value("${elegent.pay.alipay.charset:RSA2}") + private String signType; + + @Autowired + private KeyManager keyManager; + + public String getPrivateKey(){ + return keyManager.getKey("alipay_private.key"); + } + + public String getPublicKey(){ + return keyManager.getKey("alipay_public.key"); + } + + +} \ No newline at end of file diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java b/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java new file mode 100644 index 0000000..db7417d --- /dev/null +++ b/pay/src/main/java/com/ruoyi/ali/AlipayConstant.java @@ -0,0 +1,30 @@ +package com.ruoyi.ali; + +import java.util.HashMap; +import java.util.Map; + +/** + * ZFBConstant + * @description 支付宝相关的常量 +*/ +public class AlipayConstant { + + public static final String SUCCESS = "SUCCESS"; + + public static final String FAIL = "FAIL"; + + /** + * 交易状态(用于转换) + */ + public static final Map TRADE_STATE = new HashMap(){ + { + put("TRADE_SUCCESS", "SUCCESS"); + put("WAIT_BUYER_PAY", "NOTPAY"); + put("TRADE_CLOSED", "CLOSED"); + put("TRADE_FINISHED", "FINISHED"); + } + }; + + public static final String domain="https://openapi.alipay.com/gateway.do"; + +} diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java b/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java new file mode 100644 index 0000000..aefd560 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/ali/AlipayElegentTrade.java @@ -0,0 +1,461 @@ +package com.ruoyi.ali; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.request.*; +import com.alipay.api.response.*; +import com.ruoyi.CallBackService; +import com.ruoyi.annotation.TradePlatform; +import com.ruoyi.config.CallbackConfig; +import com.ruoyi.constant.PayConstant; +import com.ruoyi.constant.Platform; +import com.ruoyi.constant.TradeType; +import com.ruoyi.core.ElegentTrade; +import com.ruoyi.dto.*; +import com.ruoyi.exceptions.TradeException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * 支付宝支付的策略类 + * @author wgl + */ +@Service +@TradePlatform(Platform.ALI) +@Slf4j +public class AlipayElegentTrade implements ElegentTrade { + + @Autowired + private AlipayConfig alipayConfig; + + @Autowired + private CallbackConfig callbackConfig; + + @Autowired + private CallBackService callBackService; + + + /** + * 获取回调地址 + * @return + */ + private String getPayNotifyUrl(){ + return callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH+ PayConstant.NOTIFY +"/"+ Platform.ALI; + } + + /** + * 获取退款回调 + * @return + */ + private String getRefundNotifyUrl(){ + return callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH+ PayConstant.REFUND_NOTIFY +"/"+ Platform.ALI; + } + + + + /** + * 创建支付订单 + * @param payRequest + * @return + * @throws TradeException + */ + @Override + public PayResponse requestPay(PayRequest payRequest, String tradeType) throws TradeException { + if(TradeType.NATIVE.equals( tradeType )){ + return createNativeOrder(payRequest); + } + if(TradeType.JSAPI.equals( tradeType )){ + return createJsApiOrder(payRequest); + } + if(TradeType.H5.equals( tradeType )){ + return createH5Order(payRequest); + } + if(TradeType.APP.equals( tradeType )){ + return createAPPOrder(payRequest); + } + return createNativeOrder(payRequest); + } + + + /** + * 本地支付(扫码) + * https://opendocs.alipay.com/open/194/106078?ref=api#预下单 + * @param payRequest + * @return + * @throws TradeException + */ + private PayResponse createNativeOrder(PayRequest payRequest) throws TradeException { + try { + AlipayClient alipayClient = getAliHttpClient(); + AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); + + request.setNotifyUrl(getPayNotifyUrl()); + + JSONObject bizContent = new JSONObject(); + bizContent.put("out_trade_no", payRequest.getOrderSn()); + //转换 + //String totalFee= BigDecimal.valueOf(payRequest.getTotalFee()).divide(new BigDecimal(100) ).toString(); + bizContent.put("total_amount", fenToYuan(payRequest.getTotalFee())); + bizContent.put("subject", payRequest.getBody()); + request.setBizContent(bizContent.toString()); + AlipayTradePrecreateResponse response = alipayClient.execute(request); + + if (response.isSuccess()) { + PayResponse payResponse =new PayResponse(); + payResponse.setSuccess(true); + payResponse.setCode_url(response.getQrCode()); //本地支付二维码 + payResponse.setOrder_sn(payRequest.getOrderSn()); + return payResponse; + } else { + log.error("调用失败"); + return null; + } + }catch (Exception e){ + e.printStackTrace(); + throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn()); + } + } + + + /** + * 小程序 + * https://opendocs.alipay.com/mini/03l5wn + * @param payRequest + * @return + * @throws TradeException + */ + private PayResponse createJsApiOrder(PayRequest payRequest) throws TradeException { + AlipayClient alipayClient = getAliHttpClient(); + try { + AlipayTradeCreateRequest request = new AlipayTradeCreateRequest(); + request.setNotifyUrl(getPayNotifyUrl()); + JSONObject bizContent = new JSONObject(); + bizContent.put("out_trade_no", payRequest.getOrderSn()); + bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() )); + bizContent.put("subject", payRequest.getBody()); + bizContent.put("buyer_id", payRequest.getOpenid()); + bizContent.put("timeout_express", "10m"); + request.setBizContent(bizContent.toString()); + AlipayTradeCreateResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + PayResponse payResponse =new PayResponse(); + payResponse.setSuccess(true); + payResponse.setPrepay_id(response.getTradeNo()); + payResponse.setOrder_sn(response.getOutTradeNo()); + return payResponse; + } else { + log.error("调用失败"); + return null; + } + }catch (Exception e){ + throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn()); + } + } + + + /** + * H5 + * https://opendocs.alipay.com/mini/03l5wn + * @param payRequest + * @return + * @throws TradeException + */ + private PayResponse createH5Order(PayRequest payRequest) throws TradeException { + AlipayClient alipayClient = getAliHttpClient(); + try { + AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); + request.setNotifyUrl(getPayNotifyUrl()); + request.setReturnUrl(""); + JSONObject bizContent = new JSONObject(); + bizContent.put("out_trade_no", payRequest.getOrderSn()); + bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() )); + bizContent.put("subject", payRequest.getBody()); + bizContent.put("product_code", "QUICK_WAP_WAY"); + + request.setBizContent(bizContent.toString()); + AlipayTradeWapPayResponse response = alipayClient.pageExecute(request); + if (response.isSuccess()) { + PayResponse payResponse =new PayResponse(); + payResponse.setSuccess(true); + payResponse.setPrepay_id(response.getTradeNo()); + payResponse.setOrder_sn(response.getOutTradeNo()); + return payResponse; + } else { + log.error("调用失败"); + return null; + } + }catch (Exception e){ + throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn()); + } + } + + + /** + * APP + * https://opendocs.alipay.com/open/02e7gq?ref=api&scene=20 + * @param payRequest + * @return + * @throws TradeException + */ + private PayResponse createAPPOrder(PayRequest payRequest) throws TradeException { + AlipayClient alipayClient = getAliHttpClient(); + try { + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + request.setNotifyUrl(getPayNotifyUrl()); + JSONObject bizContent = new JSONObject(); + bizContent.put("out_trade_no", payRequest.getOrderSn()); + bizContent.put("total_amount", fenToYuan( payRequest.getTotalFee() )); + bizContent.put("subject", payRequest.getBody()); + bizContent.put("product_code", "QUICK_MSECURITY_PAY"); + + request.setBizContent(bizContent.toString()); + AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); + if (response.isSuccess()) { + PayResponse payResponse =new PayResponse(); + payResponse.setSuccess(true); + payResponse.setPrepay_id(response.getTradeNo()); + payResponse.setOrder_sn(response.getOutTradeNo()); + return payResponse; + } else { + log.error("调用失败"); + return null; + } + }catch (Exception e){ + throw new TradeException("订单创建失败,订单号:"+ payRequest.getOrderSn()); + } + } + + + + /** + * 关闭订单 + * @param orderSn + * @return + * @throws TradeException + */ + @Override + public Boolean closePay(String orderSn) throws TradeException { + try { + AlipayClient alipayClient = getAliHttpClient(); + AlipayTradeCloseRequest request = new AlipayTradeCloseRequest(); + JSONObject bizContent = new JSONObject(); + bizContent.put("trade_no", orderSn); + request.setBizContent(bizContent.toString()); + AlipayTradeCloseResponse response = alipayClient.execute(request); + if (response.isSuccess()) { + log.info("调用成功"); + return true; + } else { + log.error("调用失败"); + return false; + } + }catch (Exception e){ + throw new TradeException("订单关闭失败,订单号:"+orderSn); + } + } + + /** + * 退款接口 + * alipay.trade.refund(统一收单交易退款接口) + * https://opendocs.alipay.com/open/02ekfk + * @param refundRequest + * @return + * @throws TradeException + */ + @Override + public Boolean refund(RefundRequest refundRequest) throws TradeException { + try { + AlipayClient alipayClient = getAliHttpClient(); + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + request.setNotifyUrl(getRefundNotifyUrl()); //退款回调 + JSONObject bizContent = new JSONObject(); + bizContent.put("refund_amount", fenToYuan(refundRequest.getRefundAmount() )); + bizContent.put("out_trade_no", refundRequest.getOrderSn()); + //退款请求号,做幂等性校验 + if(refundRequest.getRequestNo()!=null){ + bizContent.put("out_request_no", refundRequest.getRequestNo()); + }else{ + bizContent.put("out_request_no", refundRequest.getOrderSn()); + } + request.setBizContent(bizContent.toString()); + AlipayTradeRefundResponse response = alipayClient.execute(request); + if (response.isSuccess()) { + if("Y".equals(response.getFundChange())) { + log.info("退款成功{}",refundRequest.getOrderSn()); + callBackService.successRefund(refundRequest.getOrderSn()); + return true; + }else{ + //退款失败 + log.error("退款失败{}",refundRequest.getOrderSn()); + callBackService.failRefund(refundRequest.getOrderSn()); + return false; + } + } else { + log.error("退款调用失败{}",refundRequest.getOrderSn()); + return false; + } + }catch (Exception e){ + e.printStackTrace(); + throw new TradeException("订单退款失败,订单号:"+ refundRequest.getOrderSn()); + } + } + + /** + * 查询单笔交易订单 + * 参考官网: https://opendocs.alipay.com/open/02e7gm?ref=api#请求示例 + * + * @param orderSn + * @return + * @throws TradeException + */ + @Override + public QueryResponse queryTradingOrderNo(String orderSn) throws TradeException { + AlipayClient alipayClient = getAliHttpClient(); + try { + AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); + JSONObject bizContent = new JSONObject(); + bizContent.put("out_trade_no", orderSn); + request.setBizContent(bizContent.toString()); + AlipayTradeQueryResponse response = alipayClient.execute(request); + QueryResponse queryResponse=new QueryResponse(); + queryResponse.setOrder_sn(orderSn ); + if (response.isSuccess()) { + queryResponse.setTransaction_id( response.getTradeNo() ); + queryResponse.setTrade_state(AlipayConstant.TRADE_STATE.get( response.getTradeStatus()) );//交易状态 + + //int total = BigDecimal.valueOf(Double.valueOf(response.getTotalAmount())).multiply(new BigDecimal(100)).intValue(); + queryResponse.setTotal( yuanToFen(response.getTotalAmount()) ); //总金额 + + //int buyer_pay_amount = BigDecimal.valueOf(Double.valueOf(response.getBuyerPayAmount())).multiply(new BigDecimal(100)).intValue(); + //queryResponse.setPayer_total( yuanToFen(response.getBuyerPayAmount()) );//支付金额 + + queryResponse.setOpenid( response.getBuyerUserId()); + Map map = JSON.parseObject(response.getBody(), Map.class ) ; + queryResponse.setExpand(map);//全部数据 + return queryResponse; + } else { + queryResponse.setTrade_state("NOTPAY"); + return queryResponse; + } + }catch (Exception e){ + e.printStackTrace(); + //throw new TradeException("订单查询失败,订单号:"+orderSn); + return null; + } + } + + /** + * 查询退款订单 + * @param orderSn + * @return + * @throws TradeException + */ + @Override + public QueryRefundResponse queryRefundTrading(String orderSn) throws TradeException { + try { + AlipayClient alipayClient = getAliHttpClient(); + AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest(); + JSONObject bizContent = new JSONObject(); + bizContent.put("out_request_no", orderSn); + request.setBizContent(bizContent.toString()); + AlipayTradeFastpayRefundQueryResponse response = alipayClient.execute(request); + if (response.isSuccess()) { + log.info("调用成功"); + Map map = JSON.parseObject(response.getBody(), Map.class ); + + QueryRefundResponse queryRefundResponse=new QueryRefundResponse(); + + queryRefundResponse.setOrder_sn( (String) map.get("out_trade_no") ); + queryRefundResponse.setTransaction_id( (String) map.get("trade_no") ); + queryRefundResponse.setTotal( (Integer) map.get("total_amount") ); //总金额 + //queryRefundResponse.setPayer_total( (Integer) map.get("total_amount") );//支付金额 + queryRefundResponse.setRefund((Integer) map.get("refund_amount") ); //退款金额 + queryRefundResponse.setRefund_id((String) map.get("trade_no") ); //退款单号 + queryRefundResponse.setOut_refund_no( (String) map.get("out_request_no") );//退款订单号 + //queryRefundResponse.setChannel( (String) map.get("channel") ); //通道 + //queryRefundResponse.setUser_received_account( (String) map.get("user_received_account") ); //账号 + queryRefundResponse.setStatus( (String) map.get("refund_status") ); //状态 + queryRefundResponse.setSuccess_time( (String) map.get("gmt_refund_pay") ); + //queryRefundResponse.setCreate_time( (String) map.get("gmt_refund_pay") ); + + queryRefundResponse.setExpand(map); + return queryRefundResponse; + + } else { + log.error("调用失败"); + return null; + } + }catch (Exception e){ + e.printStackTrace(); + //throw new TradeException("退款订单查询失败,订单号:"+ orderSn); + return null; + } + } + + @Override + public String getOpenid(String code) { + AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", + alipayConfig.getAppId(), alipayConfig.getPrivateKey(), "json", "utf-8", alipayConfig.getPublicKey(), alipayConfig.getSignType()); + AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); + request.setCode(code); + request.setGrantType("authorization_code"); + try { + AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(request); + return oauthTokenResponse.getUserId(); + } catch (AlipayApiException e) { + //处理异常 + e.printStackTrace(); + return ""; + } + } + + + /** + * 获取支付宝连接 + * 参考官网:https://opendocs.alipay.com/open/01csp3?ref=api#公钥模式加签 + * 公钥模式加签 + * @return + */ + private AlipayClient getAliHttpClient(){ + try { + com.alipay.api.AlipayConfig alipayConfig = new com.alipay.api.AlipayConfig(); + alipayConfig.setServerUrl(AlipayConstant.domain); + alipayConfig.setAppId(this.alipayConfig.getAppId()); + alipayConfig.setPrivateKey(this.alipayConfig.getPrivateKey()); + alipayConfig.setFormat("json"); + alipayConfig.setCharset("utf-8"); + alipayConfig.setAlipayPublicKey(this.alipayConfig.getPublicKey()); + alipayConfig.setSignType(this.alipayConfig.getSignType()); + //构造client + AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); + return alipayClient; + }catch (Exception e){ + e.printStackTrace(); + throw new TradeException("支付宝支付--初始化,校验系统参数失败"); + } + + } + + /** + * 分转换为元 + * @param fen + * @return + */ + private String fenToYuan(int fen){ + //转换为元 + return BigDecimal.valueOf(fen).divide(new BigDecimal(100) ).toString(); + } + + private int yuanToFen(String yuan){ + return BigDecimal.valueOf(Double.valueOf(yuan)).multiply(new BigDecimal(100)).intValue(); + } + + +} \ No newline at end of file diff --git a/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java b/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java new file mode 100644 index 0000000..0052a4f --- /dev/null +++ b/pay/src/main/java/com/ruoyi/ali/AlipayElegentValid.java @@ -0,0 +1,124 @@ +package com.ruoyi.ali; + + +import com.alipay.api.internal.util.AlipaySignature; +import com.ruoyi.annotation.TradePlatform; +import com.ruoyi.constant.Platform; +import com.ruoyi.core.ElegentValid; +import com.ruoyi.dto.ValidResponse; +import com.ruoyi.exceptions.TradeException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +@Service +@TradePlatform(Platform.ALI) +@Slf4j +public class AlipayElegentValid implements ElegentValid { + + + @Autowired + private AlipayConfig alipayConfig; + + + /** + * 订单回调结果通知验签 + * 参考代码: https://opendocs.alipay.com/open/194/103296?ref=api 异步返回结果的验签 + * @param httpEntity + * @param httpRequest + * @return + */ + @Override + public ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest httpRequest) throws TradeException { + ValidResponse validResponse=new ValidResponse(); + try { + Map params = getParams(httpRequest); + //获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中 + //String body = httpEntity.getBody(); + //调用SDK验证签名 + //公钥验签示例代码 + boolean signVerified = AlipaySignature.rsaCheckV1(params, alipayConfig.getPublicKey(), "utf-8", alipayConfig.getSignType()); + if (signVerified) { + validResponse.setValid(true); + validResponse.setOrderSn((String) params.get("out_trade_no")); + return validResponse; + } else { + validResponse.setValid(false); + validResponse.setOrderSn( (String) params.get("out_trade_no") ); + return validResponse; + } + }catch (Exception e){ + e.printStackTrace(); + throw new TradeException("验签异常"); + } + } + + /** + * 退款结果通知验签 + * 参考官网 https://opendocs.alipay.com/support/01ravh + * @param httpEntity + * @param httpRequest + * @return + * @throws TradeException + */ + @Override + public ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest httpRequest) throws TradeException { + ValidResponse validResponse=new ValidResponse(); + + try { + //获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中 + Map params = getParams(httpRequest); + //调用SDK验证签名 + //公钥验签示例代码 + boolean signVerified = AlipaySignature.rsaCheckV1(params, alipayConfig.getPublicKey(), "utf-8", alipayConfig.getSignType()); + if (signVerified) { + validResponse.setValid(true); + validResponse.setOrderSn( (String) params.get("out_trade_no") ); + return validResponse; + } else { + validResponse.setValid(false); + validResponse.setOrderSn( (String) params.get("out_trade_no") ); + return validResponse; + } + }catch (Exception e){ + e.printStackTrace(); + validResponse.setValid(false); + return validResponse; + } + } + + private Map getParams(HttpServletRequest httpServletRequest){ + Map params = new HashMap< String , String >(); + Map requestParams = httpServletRequest.getParameterMap(); + + for(Iterator iter = requestParams.keySet().iterator(); iter.hasNext();){ + String name = (String)iter.next(); + String[] values = (String [])requestParams.get(name); + String valueStr = ""; + for(int i = 0;i < values.length;i ++ ){ + valueStr = (i==values.length-1)?valueStr + values [i]:valueStr + values[i] + ","; + } + //乱码解决,这段代码在出现乱码时使用。 + //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); + params.put (name,valueStr); + } + log.info("params:{}",params); + return params; + } + + @Override + public String successResult() { + return AlipayConstant.SUCCESS; + } + + @Override + public String failResult() { + return AlipayConstant.FAIL; + } +} diff --git a/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java b/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java new file mode 100644 index 0000000..3cb71be --- /dev/null +++ b/pay/src/main/java/com/ruoyi/annotation/TradePlatform.java @@ -0,0 +1,20 @@ +package com.ruoyi.annotation; + +import java.lang.annotation.*; + +/** + * create by: wgl + * desc: 自定义支付平台注解,支付平台 微信:wx 支付宝:zfb + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface TradePlatform { + + /** + * 平台的id + * Platform.WX + * @return + */ + String value(); +} diff --git a/pay/src/main/java/com/ruoyi/config/CallbackConfig.java b/pay/src/main/java/com/ruoyi/config/CallbackConfig.java new file mode 100644 index 0000000..2c656ee --- /dev/null +++ b/pay/src/main/java/com/ruoyi/config/CallbackConfig.java @@ -0,0 +1,23 @@ +package com.ruoyi.config; +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 微信权限对接类 + */ +@Component +@ConfigurationProperties("elegent.pay.callback") +@Data +public class CallbackConfig { + + private String domain; //回调域名 + + @Value("${elegent.pay.callback.watch:false}") + private boolean watch; //是否开启监听 + + @Value("${elegent.pay.callback.cycle:10}") + private int cycle;//检查周期 + +} \ No newline at end of file diff --git a/pay/src/main/java/com/ruoyi/constant/PayConstant.java b/pay/src/main/java/com/ruoyi/constant/PayConstant.java new file mode 100644 index 0000000..77695ce --- /dev/null +++ b/pay/src/main/java/com/ruoyi/constant/PayConstant.java @@ -0,0 +1,11 @@ +package com.ruoyi.constant; + +public class PayConstant { + + public final static String CALLBACK_PATH = "/payCallBack"; + + public final static String NOTIFY = "/notify"; + + public final static String REFUND_NOTIFY = "/refund_notify"; + +} diff --git a/pay/src/main/java/com/ruoyi/constant/Platform.java b/pay/src/main/java/com/ruoyi/constant/Platform.java new file mode 100644 index 0000000..fd9a8d9 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/constant/Platform.java @@ -0,0 +1,16 @@ +package com.ruoyi.constant; + +/** + * Platform + * 支付方式 +*/ +public class Platform { + /** + * 微信 + */ + public final static String WX = "wxpay"; + /** + * 支付宝 + */ + public final static String ALI = "alipay"; +} diff --git a/pay/src/main/java/com/ruoyi/constant/TradeType.java b/pay/src/main/java/com/ruoyi/constant/TradeType.java new file mode 100644 index 0000000..c0a7ace --- /dev/null +++ b/pay/src/main/java/com/ruoyi/constant/TradeType.java @@ -0,0 +1,33 @@ +package com.ruoyi.constant; + +import lombok.Data; + +/** + * 交易类型 + */ +@Data +public class TradeType { + + /** + * native(扫码) + */ + public final static String NATIVE = "native"; + + /** + * jsapi(小程序) + */ + public final static String JSAPI = "jsapi"; + + + /** + * app + */ + public final static String APP = "app"; + + + /** + * h5 + */ + public final static String H5 = "h5"; + +} diff --git a/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java b/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java new file mode 100644 index 0000000..ea0148d --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/CallBackServiceImpl.java @@ -0,0 +1,35 @@ +package com.ruoyi.core; + +import com.ruoyi.CallBackService; +import lombok.extern.slf4j.Slf4j; + +/** + * 回调类 + */ +@Slf4j +public class CallBackServiceImpl implements CallBackService { + + + @Override + public void successPay(String orderSn) { + log.info("支付成功回调!"+orderSn); + } + + @Override + public void failPay(String orderSn) { + log.info("支付失败回调!"+orderSn); + } + + + @Override + public void successRefund(String orderSn) { + log.info("退款成功回调!"+orderSn); + } + + @Override + public void failRefund(String orderSn) { + log.info("退款失败回调!"+orderSn); + } + + +} diff --git a/pay/src/main/java/com/ruoyi/core/CallbackController.java b/pay/src/main/java/com/ruoyi/core/CallbackController.java new file mode 100644 index 0000000..8b7170f --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/CallbackController.java @@ -0,0 +1,90 @@ +package com.ruoyi.core; + +import com.ruoyi.CallBackService; +import com.ruoyi.constant.PayConstant; +import com.ruoyi.dto.ValidResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * CallbackController + * @description 系统默认提供的微信回调的Controller +*/ +@RestController +@Slf4j +@RequestMapping(PayConstant.CALLBACK_PATH) +public class CallbackController { + + @Autowired + private CallBackService callBackService; + + /** + * 系统提供的默认的微信回调的接口(支付回调) + * @param httpEntity + * @param response + * @return + */ + @RequestMapping( PayConstant.NOTIFY + "/{platform}") + public String notify(HttpEntity httpEntity, HttpServletRequest request, HttpServletResponse response, @PathVariable("platform") String platform){ + + ElegentValid elegentValid = ElegentLoader.getElegentValid(platform); //获取验证器 + try { + ValidResponse validResponse = elegentValid.validPay(httpEntity, request);//验证支付通知 + String orderSn =validResponse.getOrderSn(); //订单号 + if(validResponse.isValid()){ //返回码成功 + callBackService.successPay(orderSn); + //返回成功消费 + return elegentValid.successResult(); + }else{ + callBackService.failPay(orderSn); + return elegentValid.failResult(); + } + }catch (Exception e){ + log.error("支付回调处理失败",e); + //微信返回的状态非正常 + return elegentValid.failResult(); + } + } + + + /** + * 系统提供的默认的微信回调的接口(退款通知) + * + * @param httpEntity + * @param response + * @return + */ + @RequestMapping( PayConstant.REFUND_NOTIFY + "/{platform}") + public String refundNotify(HttpEntity httpEntity, HttpServletRequest request, HttpServletResponse response,@PathVariable("platform") String platform) { + + ElegentValid elegentValid = ElegentLoader.getElegentValid(platform); //获取验证器 + + try { + ValidResponse validResponse = elegentValid.validRefund(httpEntity, request); + String orderSn = validResponse.getOrderSn(); + //订单号 + if (validResponse.isValid()) { //返回码成功 + callBackService.successRefund(orderSn); + //返回成功消费 + return elegentValid.successResult(); + } else { + callBackService.failRefund(orderSn); + return elegentValid.failResult(); + } + } catch (Exception e) { + log.error("退款回调处理失败", e); + //微信返回的状态非正常 + return elegentValid.failResult(); + } + + } + + +} diff --git a/pay/src/main/java/com/ruoyi/core/CallbackWatch.java b/pay/src/main/java/com/ruoyi/core/CallbackWatch.java new file mode 100644 index 0000000..5bfe85e --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/CallbackWatch.java @@ -0,0 +1,73 @@ +package com.ruoyi.core; + + + +import com.ruoyi.CallBackService; +import com.ruoyi.ElegentPay; +import com.ruoyi.config.CallbackConfig; +import com.ruoyi.dto.QueryRefundResponse; +import com.ruoyi.dto.QueryResponse; +import com.ruoyi.dto.WatchDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import java.util.Timer; +import java.util.TimerTask; + +@Component +@ConditionalOnProperty(prefix = "elegent.pay.callback",name = "watch",havingValue = "true") +@Slf4j +public class CallbackWatch { + + @Autowired + private CallBackService callBackService; + + @Autowired + private CallbackConfig callbackConfig; + + @Autowired + private ElegentPay elegentPay; + + @PostConstruct + public void queryWatch(){ + if(callbackConfig.getCycle()<=0){ + return; + } + //log.info("开启支付结果定期巡检"); + Timer timer = new Timer(); + // 2、创建 TimerTask 任务线程 + TimerTask task=new TimerTask() { + @Override + public void run() { + try{ + //查询支付状态 + //log.info("支付状态定期巡检,{}",WatchList.payList); + for( WatchDTO watchDTO: WatchList.payList ){ + //查询订单是否支付成功 + QueryResponse queryResponse = elegentPay.queryTradingOrderNo(watchDTO.getOrderSn(),watchDTO.getPlatform()); + if("SUCCESS".equals(queryResponse.getTrade_state())){ + callBackService.successPay(queryResponse.getOrder_sn()); + WatchList.payList.remove(watchDTO ); + } + } + //log.info("退款状态定期巡检,{}",WatchList.refundList); + //查询退款状态 + for( WatchDTO watchDTO: WatchList.refundList ){ + //查询退款中订单 + QueryRefundResponse queryResponse = elegentPay.queryRefundTrading( watchDTO.getOrderSn(),watchDTO.getPlatform()); + if("SUCCESS".equals(queryResponse.getStatus())){ + callBackService.successRefund(queryResponse.getOrder_sn()); + WatchList.refundList.remove(watchDTO); + } + } + }catch (Exception ex){ + } + } + }; + // 4、启动定时任务 + timer.schedule(task, callbackConfig.getCycle()*1000, callbackConfig.getCycle()*1000); + } + +} diff --git a/pay/src/main/java/com/ruoyi/core/ElegentConfig.java b/pay/src/main/java/com/ruoyi/core/ElegentConfig.java new file mode 100644 index 0000000..34cde57 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/ElegentConfig.java @@ -0,0 +1,27 @@ +package com.ruoyi.core; + + +import com.ruoyi.CallBackService; +import com.ruoyi.key.KeyManager; +import com.ruoyi.key.impl.DefaultKeyManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ElegentConfig { + + @Bean + @ConditionalOnMissingBean + public CallBackService callBackService(){ + return new CallBackServiceImpl(); + } + + + @Bean + @ConditionalOnMissingBean + public KeyManager keyManager(){ + return new DefaultKeyManager(); + } + +} diff --git a/pay/src/main/java/com/ruoyi/core/ElegentLoader.java b/pay/src/main/java/com/ruoyi/core/ElegentLoader.java new file mode 100644 index 0000000..36dcb8b --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/ElegentLoader.java @@ -0,0 +1,82 @@ +package com.ruoyi.core; + +import com.ruoyi.annotation.TradePlatform; +import com.ruoyi.exceptions.TradeException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * PlatformLoader + * @description 第三方支付平台类加载器 + * 服务启动的时候自动加载第三方支付组件 +*/ +@Component +@Slf4j +public class ElegentLoader implements ApplicationContextAware { + + private static Map elegentTradeMap = new HashMap<>(); + + private static Map elegentValidMap = new HashMap<>(); + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + + //加载所有的交易实现类 + Collection elegentTrades = applicationContext.getBeansOfType(ElegentTrade.class).values(); + elegentTrades.stream().forEach(e->{ + //通过反射拿到类上的平台注解 + TradePlatform annotation = e.getClass().getAnnotation(TradePlatform.class); + if (annotation != null) { + elegentTradeMap.put(annotation.value(), e); + } + }); + + //加载所有的验证实现类 + Collection elegentValids = applicationContext.getBeansOfType(ElegentValid.class).values(); + elegentValids.stream().forEach(e->{ + //通过反射拿到类上的平台注解 + TradePlatform annotation = e.getClass().getAnnotation(TradePlatform.class); + if (annotation != null) { + elegentValidMap.put(annotation.value(), e); + } + }); + + } + + /** + * 根据平台id获取具体的第三方平台 + * @param platform 平台id + * @return + */ + public static ElegentTrade getElegentTrade(String platform){ + ElegentTrade elegentPayTemplate = elegentTradeMap.get(platform); + if(elegentPayTemplate!=null){ + return elegentPayTemplate; + }else{ + throw new TradeException("未找到适配的交易类型,交易平台id:"+platform); + } + } + + + /** + * 根据平台id获取具体的验证类 + * @param platform 平台id + * @return + */ + public static ElegentValid getElegentValid(String platform){ + ElegentValid elegentValidTemplate = elegentValidMap.get(platform); + if(elegentValidTemplate!=null){ + return elegentValidTemplate; + }else{ + throw new TradeException("未找到适配的交易类型,交易平台id:"+platform); + } + } + +} diff --git a/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java b/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java new file mode 100644 index 0000000..97f84d2 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/ElegentPayImpl.java @@ -0,0 +1,136 @@ +package com.ruoyi.core; +import com.ruoyi.ElegentPay; +import com.ruoyi.config.CallbackConfig; +import com.ruoyi.dto.*; +import com.ruoyi.exceptions.TradeException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * ElegentPayTemplate + * @description 统一模板 在模板层进行第三方平台的选择 +*/ +@Component +public class ElegentPayImpl implements ElegentPay { + + @Autowired + private CallbackConfig callbackConfig; + + /** + * 统一下单接口 + * @param payRequest + * @return + */ + @Override + public PayResponse requestPay(PayRequest payRequest, String tradeType, String platform) throws TradeException { + //获取交易策略 + PayResponse payResponse = getPlatFormService(platform).requestPay(payRequest, tradeType); + + //加入监听列表 + if(callbackConfig.isWatch()){ + WatchDTO watchDTO=new WatchDTO(); + watchDTO.setOrderSn(payRequest.getOrderSn()); + watchDTO.setPlatform(platform); + WatchList.payList.add( watchDTO ); + } + return payResponse; + } + + + /** + * 关闭订单 + * @param orderSn + * @param platform + * @return + * @throws Exception + */ + @Override + public Boolean closePay(String orderSn, String platform) throws TradeException { + //调用对应第三方的创建订单接口 + Boolean aBoolean = getPlatFormService(platform).closePay(orderSn); + //加入监听列表 + if(callbackConfig.isWatch()){ + WatchDTO watchDTO=new WatchDTO(); + watchDTO.setOrderSn(orderSn); + watchDTO.setPlatform(platform); + WatchList.payList.remove( watchDTO ); + } + + return aBoolean; + } + + /** + * 退款方法 + * @param refundRequest + * @return + * @throws Exception + */ + @Override + public Boolean refund(RefundRequest refundRequest, String platform) throws TradeException { + Boolean refund = getPlatFormService(platform).refund(refundRequest); + //加入监听列表 + if(callbackConfig.isWatch() && refund){ + WatchDTO watchDTO=new WatchDTO(); + watchDTO.setOrderSn(refundRequest.getRequestNo()); + watchDTO.setPlatform(platform); + WatchList.refundList.add( watchDTO ); + } + return refund; + } + + + /** + * 手动查询订单的方法 + * 商户订单号查询 根据订单号查询订单 + * 该接口基于生成的订单号来进行订单的查询 + * 可以基于查询的结果判断用户订单是否支付成功 + * @param orderSn + * @param Platform + * @return + * @throws Exception + */ + @Override + public QueryResponse queryTradingOrderNo(String orderSn , String Platform) throws TradeException { + //调用具体第三方的退款接口 + return getPlatFormService(Platform).queryTradingOrderNo(orderSn); + } + + + /** + * 查询退款单号 + * + * @return + * @throws Exception + */ + @Override + public QueryRefundResponse queryRefundTrading(String orderSn , String platform) throws TradeException { + //获取请求参数 + return getPlatFormService(platform).queryRefundTrading(orderSn); + } + + /** + * 获得openId + * @param code + * @param platform + * @return + */ + @Override + public String getOpenid(String code, String platform) { + return getPlatFormService(platform).getOpenid(code); + } + +/** + * ====================================提供的模板类需要使用的方法===================================== + */ + + + /** + * 跟进具体内容获取实现类的方法 + * @param platForm + * @return + */ + private ElegentTrade getPlatFormService(String platForm) { + return ElegentLoader.getElegentTrade(platForm); + } + +} diff --git a/pay/src/main/java/com/ruoyi/core/ElegentTrade.java b/pay/src/main/java/com/ruoyi/core/ElegentTrade.java new file mode 100644 index 0000000..4474da3 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/ElegentTrade.java @@ -0,0 +1,54 @@ +package com.ruoyi.core; + + +import com.ruoyi.dto.*; +import com.ruoyi.exceptions.TradeException; + +public interface ElegentTrade { + + + /** + * 单独的创建本地支付订单接口 + * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk + * 业务编写人员仅仅只需要准备好请求参数调用该方法即可完成下单请求 + * @return 交易数据对象 包含有native支付的二维码+jsApi支付的支付组件 + */ + PayResponse requestPay(PayRequest payRequest, String tradeType) throws TradeException; + + /** + * 关闭订单 + * 该结构基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk + * 业务编写人员在处理超时订单的时候需要 通知微信 由于是超时订单需要进行远程关闭 + */ + Boolean closePay(String orderSn) throws TradeException; + + /** + * 退款s申请 + * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk + * 业务编写人员在处理业务执行失败时需要进行退款 + */ + Boolean refund(RefundRequest refundRequest) throws TradeException; + + /** + * 商户订单号查询 根据订单号查询订单 + * 该接口基于生成的订单号来进行订单的查询 + * 可以基于查询的结果判断用户订单是否支付成功 + */ + QueryResponse queryTradingOrderNo(String orderSn) throws TradeException; + + + /** + * 查询单笔退款API + * + */ + QueryRefundResponse queryRefundTrading(String orderSn) throws TradeException; + + + /** + * 获得openId + * @param code + * @return + */ + String getOpenid(String code); + +} diff --git a/pay/src/main/java/com/ruoyi/core/ElegentValid.java b/pay/src/main/java/com/ruoyi/core/ElegentValid.java new file mode 100644 index 0000000..fdb7cd5 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/ElegentValid.java @@ -0,0 +1,48 @@ +package com.ruoyi.core; + + +import com.ruoyi.dto.ValidResponse; +import com.ruoyi.exceptions.TradeException; +import org.springframework.http.HttpEntity; + +import javax.servlet.http.HttpServletRequest; + +/** + * 验证器接口 + * + */ +public interface ElegentValid { + + + /** + * 支付结果通知校验 + * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk + * 业务编写人员在接收到微信或支付宝回调的时候可以使用该方法验证回调是否成功,是否是伪回调 + * @return 交易数据对象 + */ + ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest request) throws TradeException; + + + + /** + * 退款结果通知校验 + * 该接口基于设计模式实现,对接了微信V3版支付代码和支付宝支付sdk + * 业务编写人员在接收到微信或支付宝回调的时候可以使用该方法验证回调是否成功,是否是伪回调 + */ + ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest request) throws TradeException; + + + /** + * 成功返回结构 + * @return + */ + String successResult(); + + + /** + * 失败返回内容 + * @return + */ + String failResult(); + +} diff --git a/pay/src/main/java/com/ruoyi/core/WatchList.java b/pay/src/main/java/com/ruoyi/core/WatchList.java new file mode 100644 index 0000000..a610939 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/core/WatchList.java @@ -0,0 +1,20 @@ +package com.ruoyi.core; + + + +import com.ruoyi.dto.WatchDTO; + +import java.util.concurrent.CopyOnWriteArraySet; + +/** + * 监听列表 + */ +public class WatchList { + + + + public static CopyOnWriteArraySet payList=new CopyOnWriteArraySet<>(); //支付中列表 + + public static CopyOnWriteArraySet refundList=new CopyOnWriteArraySet<>(); //退款中列表 + +} diff --git a/pay/src/main/java/com/ruoyi/dto/PayRequest.java b/pay/src/main/java/com/ruoyi/dto/PayRequest.java new file mode 100644 index 0000000..5d747da --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/PayRequest.java @@ -0,0 +1,20 @@ +package com.ruoyi.dto; + + +import lombok.Data; + +/** + * PayRequest + * 支付请求外观类 +*/ +@Data +public class PayRequest { + + private String body;//商品描述 + + private String orderSn; //订单号 + + private int totalFee; //订单金额 + + private String openid;//openId +} diff --git a/pay/src/main/java/com/ruoyi/dto/PayResponse.java b/pay/src/main/java/com/ruoyi/dto/PayResponse.java new file mode 100644 index 0000000..db4aafb --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/PayResponse.java @@ -0,0 +1,29 @@ +package com.ruoyi.dto; + +import lombok.Data; + +import java.util.Map; + +/** + * 结果统一封装类 + */ +@Data +public class PayResponse { + + private boolean success; //是否成功 + + private String message;//信息 + + private String order_sn;//订单编号 + + private Map expand;//扩展属性 + + private String code_url;//二维码连接(native返回) + + private String prepay_id;//预支付Id(小程序返回) + + private String h5_url;//支付跳转链接 + + private Map jsapiData;//小程序返回 + +} diff --git a/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java b/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java new file mode 100644 index 0000000..d938f63 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/QueryRefundResponse.java @@ -0,0 +1,24 @@ +package com.ruoyi.dto; + +import lombok.Data; + +@Data +public class QueryRefundResponse extends QueryResponse{ + + + private String refund_id; //微信支付退款单号 + + private String out_refund_no;//商户退款单号 + + private String channel;//退款渠道 + + private String user_received_account;//退款账号 + + private String success_time;//退款成功时间 + + private String status;//退款状态 + + private int refund;//退款金额 + + +} diff --git a/pay/src/main/java/com/ruoyi/dto/QueryResponse.java b/pay/src/main/java/com/ruoyi/dto/QueryResponse.java new file mode 100644 index 0000000..04ddb70 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/QueryResponse.java @@ -0,0 +1,25 @@ +package com.ruoyi.dto; + +import lombok.Data; + +import java.util.Map; + +/** + * 查询响应对象 + */ +@Data +public class QueryResponse { + + private String openid;//用户id + + private String trade_state;//交易状态 + + private String order_sn;//订单号 + + private String transaction_id;//交易单号 + + private int total;//金额 + + private Map expand;//扩展(全部的返回数据) + +} diff --git a/pay/src/main/java/com/ruoyi/dto/RefundRequest.java b/pay/src/main/java/com/ruoyi/dto/RefundRequest.java new file mode 100644 index 0000000..3f17046 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/RefundRequest.java @@ -0,0 +1,16 @@ +package com.ruoyi.dto; + +import lombok.Data; + +@Data +public class RefundRequest { + + private int totalFee; //订单金额 + + private int refundAmount; //退款金额 + + private String orderSn; //订单号 + + private String requestNo; //退款请求号,做退款幂等性校验,当部分退款时必须给出 + +} diff --git a/pay/src/main/java/com/ruoyi/dto/ValidResponse.java b/pay/src/main/java/com/ruoyi/dto/ValidResponse.java new file mode 100644 index 0000000..f8e3973 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/ValidResponse.java @@ -0,0 +1,15 @@ +package com.ruoyi.dto; + +import lombok.Data; + +/** + * 验证签名 + */ +@Data +public class ValidResponse { + + private boolean isValid;// 是否通过验签 + + private String orderSn;// 订单号 + +} diff --git a/pay/src/main/java/com/ruoyi/dto/WatchDTO.java b/pay/src/main/java/com/ruoyi/dto/WatchDTO.java new file mode 100644 index 0000000..7411b91 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/dto/WatchDTO.java @@ -0,0 +1,12 @@ +package com.ruoyi.dto; + +import lombok.Data; + +@Data +public class WatchDTO { + + private String orderSn; //订单号 + + private String platform;//平台 + +} diff --git a/pay/src/main/java/com/ruoyi/exceptions/TradeException.java b/pay/src/main/java/com/ruoyi/exceptions/TradeException.java new file mode 100644 index 0000000..3a82860 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/exceptions/TradeException.java @@ -0,0 +1,24 @@ +package com.ruoyi.exceptions; + +import lombok.Getter; +import lombok.Setter; + +/** + * 交易SDK提供的总的异常 + */ +@Getter +@Setter +public class TradeException extends RuntimeException{ + private String code; + private String msg; + + public TradeException(String code, String msg) { + super(msg); + this.code = code; + this.msg = msg; + } + + public TradeException(String msg) { + super(msg); + } +} diff --git a/pay/src/main/java/com/ruoyi/key/KeyManager.java b/pay/src/main/java/com/ruoyi/key/KeyManager.java new file mode 100644 index 0000000..aacfee5 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/key/KeyManager.java @@ -0,0 +1,16 @@ +package com.ruoyi.key; + +/** + * 密钥管理器接口 + */ +public interface KeyManager { + + + /** + * 根据名字获取key字符串 + * @param name + * @return + */ + String getKey(String name); + +} diff --git a/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java b/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java new file mode 100644 index 0000000..0d48c66 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/key/impl/DefaultKeyManager.java @@ -0,0 +1,19 @@ +package com.ruoyi.key.impl; + + +import com.ruoyi.key.KeyManager; +import com.ruoyi.util.FileUtil; + +/** + * 默认的key管理器-文件管理器 + */ +public class DefaultKeyManager implements KeyManager { + + + @Override + public String getKey(String name) { + return FileUtil.readToStr(name); + } + + +} diff --git a/pay/src/main/java/com/ruoyi/util/FileUtil.java b/pay/src/main/java/com/ruoyi/util/FileUtil.java new file mode 100644 index 0000000..13d0e9f --- /dev/null +++ b/pay/src/main/java/com/ruoyi/util/FileUtil.java @@ -0,0 +1,37 @@ +package com.ruoyi.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * 文件读取类 + */ +public class FileUtil { + + + /** + * 获取文件内容 + * @param fileName + * @return + */ + public static String readToStr(String fileName){ + InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(fileName); + ByteArrayOutputStream os = new ByteArrayOutputStream(2048); + byte[] buffer = new byte[1024]; + + String str; + try { + int length; + while((length = is.read(buffer)) != -1) { + os.write(buffer, 0, length); + } + + str = os.toString("UTF-8"); + } catch (IOException var5) { + throw new IllegalArgumentException("无效的密钥", var5); + } + return str; + } + +} diff --git a/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java b/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java new file mode 100644 index 0000000..d1dfc8c --- /dev/null +++ b/pay/src/main/java/com/ruoyi/wx/WxPayElegentTrade.java @@ -0,0 +1,459 @@ +package com.ruoyi.wx; + + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.ruoyi.annotation.TradePlatform; +import com.ruoyi.config.CallbackConfig; +import com.ruoyi.constant.PayConstant; +import com.ruoyi.constant.Platform; +import com.ruoyi.core.ElegentTrade; +import com.ruoyi.dto.*; +import com.ruoyi.exceptions.TradeException; +import com.ruoyi.util.FileUtil; +import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder; +import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner; +import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials; +import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator; +import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager; +import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.util.EntityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.net.URISyntaxException; +import java.security.PrivateKey; +import java.security.Signature; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; + +@Component +@Slf4j +@TradePlatform(Platform.WX) +public class WxPayElegentTrade implements ElegentTrade { + + @Autowired + private WxpayConfig wxpayConfig; + + @Autowired + private CallbackConfig callbackConfig; + + /** + * 创建微信支付订单方法 + * 这里参考官网代码: + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_1.shtml Native下单 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_1.shtml JSAPI 下单 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_1.shtml H5下单 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_1.shtml APP下单 + * @param payRequest 支付请求 + * @return 支付响应 + * @throws IOException + */ + @Override + public PayResponse requestPay(PayRequest payRequest, String tradeType)throws TradeException { + PayResponse payResponse = new PayResponse(); //返回结果 + try { + // 请求body参数构建 + Map params = new HashMap() { + { + put("mchid", wxpayConfig.getMchId()); + put("appid", wxpayConfig.getAppId()); + put("notify_url", callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH + PayConstant.NOTIFY +"/"+ Platform.WX ); + put("out_trade_no", payRequest.getOrderSn()); + put("amount", new HashMap() { + { + put("total", payRequest.getTotalFee());//金额,单位:分 + put("currency", "CNY");//人民币 + } + }); + put("description", payRequest.getBody()); + } + }; + + if("h5".equals(tradeType)){ //h5 + params.put("scene_info", new HashMap() { + { + put("payer_client_ip", "127.0.0.1"); + put("h5_info", new HashMap() { + { + put("type", "Wap"); + } + }); + } + }); + } + if ("jsapi".equals(tradeType)) { //如果是小程序支付 + params.put("payer", new HashMap() { + { + put("openid", payRequest.getOpenid()); + } + }); + } + + + String url = WxpayConstant.createOrder + tradeType; //创建订单 + log.info("elegent-pay 请求参数{}",params); + Map map = postApiTemplate(url, params); + + if("SUCCESS".equals( map.get("code") )){ + payResponse.setOrder_sn(payRequest.getOrderSn()); + payResponse.setSuccess(true); + payResponse.setCode_url(map.get("code_url")); + payResponse.setMessage(map.get("message")); + + payResponse.setPrepay_id(map.get("prepay_id")); + payResponse.setH5_url( map.get("h5_url") ); + + payResponse.setExpand(map); //全部数据 + + if("jsapi".equals(tradeType)){//如果是小程序,需要封装到Expand + Map data=new HashMap<>(); + String timeStamp = String.valueOf(System.currentTimeMillis() / 1000); + String nonceStr = IdUtil.simpleUUID(); + String packages = "prepay_id=" + payResponse.getPrepay_id(); + String privateKey = FileUtil.readToStr("wxpay_private.key"); + String paySign = this.createPaySign(wxpayConfig.getAppId(), timeStamp, nonceStr, packages, privateKey); + data.put("appId", wxpayConfig.getAppId());// appid + data.put("timeStamp", timeStamp);// 时间戳 + data.put("nonceStr", nonceStr);// 随机字符串 + data.put("package","prepay_id="+payResponse.getPrepay_id()); + data.put("signType", "RSA");// 签名类型,默认为RSA,仅支持RSA + data.put("paySign", paySign);// 签名 + data.put("orderNo",payRequest.getOrderSn()); + payResponse.setJsapiData(data); + } + + + log.info("createOrder: {}", payResponse); + + }else{ + payResponse.setSuccess(false); + payResponse.setMessage( map.get("message") ); + } + return payResponse; + }catch (Exception e){ + e.printStackTrace(); + payResponse.setSuccess(false); + } + return payResponse; + } + + + /** + * 关闭订单 + * 参考官网代码 + * https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_7_2.shtml 3.2.5. 【服务端】关闭订单 + * @return + */ + @Override + public Boolean closePay(String orderSn) throws TradeException { + // 请求body参数构建 + Map params = new HashMap(); + params.put("mchid", wxpayConfig.getMchId()); + String url = WxpayConstant.closeOrder.replaceAll("\\{out_trade_no\\}",orderSn); + Map map = postApiTemplate(url, params); + if("SUCCESS".equals( map.get("code"))){ + return true; + }else{ + return false; + } + } + + + /** + * 退款 + * 参考官网代码 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_9.shtml + * @param refundRequest + * @return + */ + @Override + public Boolean refund(RefundRequest refundRequest) { + // 请求body参数构建 + // 请求body参数构建 + Map params = new HashMap(); + params.put("notify_url", callbackConfig.getDomain()+ PayConstant.CALLBACK_PATH +PayConstant.REFUND_NOTIFY +"/"+ Platform.WX ); //回调地址 + params.put("out_trade_no", refundRequest.getOrderSn());//订单编号 + //out_refund_no + params.put("out_refund_no", refundRequest.getRequestNo());//退款申请单编号 (多次退款需要不一样才行) + params.put("amount", new HashMap() { + { + put("refund",refundRequest.getRefundAmount());//退款金额 + put("total", refundRequest.getTotalFee());//原金额,单位:分 + put("currency", "CNY");//人民币 + } + }); + String url = WxpayConstant.refund; //创建订单 + Map map = postApiTemplate(url, params); + if("SUCCESS".equals( map.get("code"))){ + + return true; + }else{ + return false; + } + } + + + + /** + * 手动查询订单 + * 参考官网代码: https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_6_2.shtml 3.2.4. 【服务端】查询订单 + * @param orderSn + * @return + */ + @Override + public QueryResponse queryTradingOrderNo(String orderSn) throws TradeException { + // 请求body参数构建 + Map params = new HashMap(); + params.put("mchid", wxpayConfig.getMchId()); + String url = WxpayConstant.queryOrderNo+orderSn;; + try { + Map map = getApiTemplate(url, params); + QueryResponse queryResponse=new QueryResponse(); + queryResponse.setOrder_sn((String)map.get("out_trade_no") ); //订单号 + queryResponse.setTransaction_id((String)map.get("transaction_id") ); //交易单类型 + queryResponse.setTrade_state( (String) map.get("trade_state") );//交易状态 + Map amount = (Map)map.get("amount"); + if(amount!=null){ + queryResponse.setTotal( (Integer) amount.get("total") ); //总金额 + } + Map payer= (Map)map.get("payer"); + if(payer!=null){ + queryResponse.setOpenid( (String)payer.get("openid") ); + } + queryResponse.setExpand(map);//全部数据 + return queryResponse; + + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + + /** + * 查询退款订单 + * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_10.shtml + * @param out_refund_no + * @return + * @throws TradeException + */ + @Override + public QueryRefundResponse queryRefundTrading(String out_refund_no) throws TradeException { + + // 请求body参数构建 + Map params = new HashMap(); + String url = WxpayConstant.queryRufundOrderNo + out_refund_no; + try { + Map map = getApiTemplate(url, params); + QueryRefundResponse queryRefundResponse=new QueryRefundResponse(); + queryRefundResponse.setOrder_sn( (String) map.get("out_trade_no") ); + queryRefundResponse.setTransaction_id( (String) map.get("transaction_id") ); + Map amount = (Map)map.get("amount"); + queryRefundResponse.setTotal( (Integer) amount.get("total") ); //总金额 + queryRefundResponse.setRefund((Integer) amount.get("payer_refund") ); //退款金额 + queryRefundResponse.setRefund_id((String) map.get("refund_id") ); //退款单号 + queryRefundResponse.setOut_refund_no( (String) map.get("out_refund_no") );//退款订单号 + + queryRefundResponse.setChannel( (String) map.get("channel") ); //通道 + queryRefundResponse.setUser_received_account( (String) map.get("user_received_account") ); //账号 + queryRefundResponse.setStatus( (String) map.get("status") ); //状态 + queryRefundResponse.setSuccess_time( (String) map.get("success_time") ); + queryRefundResponse.setExpand(map); + return queryRefundResponse; + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String getOpenid(String code) { + String getOpenIdUrl = "https://api.weixin.qq.com/sns/jscode2session?" + + "appid="+wxpayConfig.getAppId() + +"&secret="+wxpayConfig.getAppSecret() + +"&js_code="+code+"&grant_type=authorization_code"; + RestTemplate restTemplate = new RestTemplate(); + String respResult = restTemplate.getForObject(getOpenIdUrl,String.class); + log.info("获取openid的url:{},respResult:{}",getOpenIdUrl,respResult); + if( respResult==null || "".equals(respResult) ) return ""; + try{ + + Map map = JSON.parseObject(respResult, Map.class); + String errorCode = map.get("errcode") ; + if(errorCode!=null && !"".equals(errorCode)){ + int errorCodeInt = Integer.valueOf(errorCode).intValue(); + + log.info("获取openid的errorCode,{}",errorCodeInt); + if(errorCodeInt != 0) return ""; + } + return map.get("openid"); + }catch (Exception ex){ + ex.printStackTrace(); + return ""; + } + } + + + private Map getApiTemplate(String url, Map params) throws URISyntaxException, IOException { + URIBuilder uriBuilder = new URIBuilder(url); + //添加参数 + for (String key : params.keySet()) { + uriBuilder.addParameter(key, params.get(key)); + } + //完成签名并执行请求 + HttpGet httpGet = new HttpGet(uriBuilder.build()); + httpGet.addHeader("Accept", "application/json"); + CloseableHttpClient httpClient = getWxHttpClient(); + CloseableHttpResponse response = httpClient.execute(httpGet); + return responseTemplate(response); + } + + + private Map responseTemplate(CloseableHttpResponse response) { + Map result = null; + try { + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode == 200) { //处理成功 + // log.info("success,return body = " + EntityUtils.toString(response.getEntity())); + result = JSON.parseObject(EntityUtils.toString(response.getEntity()), Map.class); + result.put("code", "SUCCESS"); + } else if (statusCode == 204) { //处理成功,无返回Body + log.info("success"); + result = new HashMap() { + { + put("code", "SUCCESS"); + } + }; + } else { + String returnBody = EntityUtils.toString(response.getEntity()); + log.error("failed,resp code = " + statusCode + ",return body = " + returnBody); + //throw new TradeException("创建本地支付订单失败!"+payDTO.getOrderSn()); + Map map = JSON.parseObject(returnBody, Map.class); + result = new HashMap() { + { + put("code", "FAIL"); + put("message", map.get("message")); + } + }; + } + } catch (Exception e) { + result = new HashMap() { + { + put("code", "FAIL"); + put("message", e.getMessage()); + } + }; + } finally { + closeConnect(response); + return result; + } + } + + private Map postApiTemplate(String url, Map params) { + try { + HttpPost httpPost = new HttpPost(url); + StringEntity entity = new StringEntity(JSON.toJSONString(params)); + entity.setContentType("application/json"); + httpPost.setEntity(entity); + httpPost.setHeader("Accept", "application/json"); + //完成签名并执行请求 + CloseableHttpClient httpClient = getWxHttpClient(); + CloseableHttpResponse response = httpClient.execute(httpPost); + return responseTemplate( response ); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + + /** + * 获取微信HTTP连接 + * + * @return + */ + private CloseableHttpClient getWxHttpClient() { + try { + //这里对秘钥进行加密使用的完全是官网上的代码 + //TODO 参考官网代码 https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_6_2.shtml + // 加载商户私钥(privateKey:私钥字符串) + String key = FileUtil.readToStr("wxpay_private.key"); + + PrivateKey merchantPrivateKey = PemUtil + .loadPrivateKey(new ByteArrayInputStream(key.getBytes("utf-8"))); + // 加载平台证书(mchId:商户号,mchSerialNo:商户证书序列号,apiV3Key:V3密钥) + //PrivateKey merchantPrivateKey = keyManager.getPrivateKey("wxpay_private.key");//读取私钥 + PrivateKeySigner privateKeySigner = new PrivateKeySigner(wxpayConfig.getMchSerialNo(), merchantPrivateKey); + WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials( + wxpayConfig.getMchId(), privateKeySigner); + // 向证书管理器增加需要自动更新平台证书的商户信息 + CertificatesManager certificatesManager = CertificatesManager.getInstance(); + certificatesManager.putMerchant(wxpayConfig.getMchId(), wechatPay2Credentials, wxpayConfig.getApiV3Key().getBytes("utf-8")); + // 初始化httpClient + return WechatPayHttpClientBuilder.create() + .withMerchant(wxpayConfig.getMchId(), wxpayConfig.getMchSerialNo(), merchantPrivateKey) + .withValidator(new WechatPay2Validator(certificatesManager.getVerifier(wxpayConfig.getMchId()))).build(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("微信支付--初始化,校验系统参数失败"); + } + + } + + + /** + * 关闭资源 + */ + private void closeConnect(CloseableHttpResponse response) { + try { + response.close(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("资源回收出错"); + } + } + + + /** + * 创建支付签名 + * @param appid + * @param timeStamp + * @param nonceStr + * @param packages + * @param privateKey + * @return + * @throws Exception + */ + private String createPaySign(String appid, String timeStamp, String nonceStr, String packages,String privateKey) throws Exception { + Signature sign = Signature.getInstance("SHA256withRSA"); + // 加载商户私钥 + PrivateKey key = PemUtil + .loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes(CharsetUtil.CHARSET_UTF_8))); + sign.initSign(key); + String message = StrUtil.format("{}\n{}\n{}\n{}\n", + appid, + timeStamp, + nonceStr, + packages); + sign.update(message.getBytes()); + return Base64.getEncoder().encodeToString(sign.sign()); + } + + +} diff --git a/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java b/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java new file mode 100644 index 0000000..c570b6f --- /dev/null +++ b/pay/src/main/java/com/ruoyi/wx/WxPayElegentValid.java @@ -0,0 +1,153 @@ +package com.ruoyi.wx; + + +import com.alibaba.fastjson.JSON; +import com.ruoyi.annotation.TradePlatform; +import com.ruoyi.constant.Platform; +import com.ruoyi.core.ElegentValid; +import com.ruoyi.dto.ValidResponse; +import com.ruoyi.exceptions.TradeException; +import com.wechat.pay.contrib.apache.httpclient.auth.Verifier; +import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager; +import com.wechat.pay.contrib.apache.httpclient.notification.Notification; +import com.wechat.pay.contrib.apache.httpclient.notification.NotificationHandler; +import com.wechat.pay.contrib.apache.httpclient.notification.NotificationRequest; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.nio.charset.StandardCharsets; +import java.util.Map; + +@Component +@Slf4j +@TradePlatform(Platform.WX) +public class WxPayElegentValid implements ElegentValid { + + + @Autowired + private WxpayConfig wxpayConfig; + + @Override + public ValidResponse validPay(HttpEntity httpEntity, HttpServletRequest httpServletRequest) throws TradeException { + ValidResponse validResponse=new ValidResponse(); + + try { + //获取请求头 + HttpHeaders headers = httpEntity.getHeaders(); + //构建微信请求数据对象 + NotificationRequest request = new NotificationRequest.Builder() + .withSerialNumber(headers.getFirst("Wechatpay-Serial")) //证书序列号(微信平台) + .withNonce(headers.getFirst("Wechatpay-Nonce")) //随机串 + .withTimestamp(headers.getFirst("Wechatpay-Timestamp")) //时间戳 + .withSignature(headers.getFirst("Wechatpay-Signature")) //签名字符串 + .withBody(httpEntity.getBody()) + .build(); + + + //微信通知的业务处理 + //验证签名,确保请求来自微信 + Map jsonData = null; + try { + //确保在管理器中存在自动更新的商户证书 + CertificatesManager certificatesManager = CertificatesManager.getInstance(); + Verifier verifier = certificatesManager.getVerifier(wxpayConfig.getMchId()); + + //验签和解析请求数据 + NotificationHandler notificationHandler = new NotificationHandler(verifier, wxpayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8)); + Notification notification = notificationHandler.parse(request); + + if (!"TRANSACTION.SUCCESS".equals(notification.getEventType())) { + validResponse.setValid(false); + return validResponse; + } + //获取解密后的数据 + jsonData = JSON.parseObject(notification.getDecryptData(),Map.class ); + log.info("解密后的数据为:"+jsonData); + } catch (Exception e) { + throw new TradeException("验签失败"); + } + if (!"SUCCESS".equals(jsonData.get("trade_state"))) { + validResponse.setValid(false); + return validResponse; + } + validResponse.setValid(true); + validResponse.setOrderSn( (String) jsonData.get("out_trade_no") ); //订单号 + return validResponse; + } catch (Exception e) { + validResponse.setValid(false); + return validResponse; + } + } + + @Override + public ValidResponse validRefund(HttpEntity httpEntity, HttpServletRequest httpServletRequest) throws TradeException { + + ValidResponse validResponse=new ValidResponse(); + try { + //获取请求头 + HttpHeaders headers = httpEntity.getHeaders(); + + //构建微信请求数据对象 + NotificationRequest request = new NotificationRequest.Builder() + .withSerialNumber(headers.getFirst("Wechatpay-Serial")) //证书序列号(微信平台) + .withNonce(headers.getFirst("Wechatpay-Nonce")) //随机串 + .withTimestamp(headers.getFirst("Wechatpay-Timestamp")) //时间戳 + .withSignature(headers.getFirst("Wechatpay-Signature")) //签名字符串 + .withBody(httpEntity.getBody()) + .build(); + + //微信通知的业务处理 + Map jsonData = null; + //验证签名,确保请求来自微信 + try { + //确保在管理器中存在自动更新的商户证书 + CertificatesManager certificatesManager = CertificatesManager.getInstance(); + Verifier verifier = certificatesManager.getVerifier(wxpayConfig.getMchId()); + + //验签和解析请求数据 + NotificationHandler notificationHandler = new NotificationHandler(verifier, wxpayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8)); + Notification notification = notificationHandler.parse(request); + + if (!"REFUND.SUCCESS".equals(notification.getEventType())) { + //非成功请求直接返回,理论上都是成功的请求 + validResponse.setValid(false); + return validResponse; + } + //获取解密后的数据 + jsonData = JSON.parseObject( notification.getDecryptData(),Map.class ); + + + } catch (Exception e) { + throw new TradeException("验签失败"); + } + if (!"SUCCESS".equals(jsonData.get("refund_status"))) { + //非成功请求直接返回,理论上都是成功的请求 + validResponse.setValid(false); + return validResponse; + } + + //交易单号 + validResponse.setValid(true); + validResponse.setOrderSn( (String) jsonData.get("out_trade_no") ); //订单号 + return validResponse; + } catch (Exception e) { + //非成功请求直接返回,理论上都是成功的请求 + validResponse.setValid(false); + return validResponse; + } + } + + @Override + public String successResult() { + return JSON.toJSONString(WxpayConstant.SUCCESS ) ; + } + + @Override + public String failResult() { + return JSON.toJSONString( WxpayConstant.FAIL); + } +} diff --git a/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java b/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java new file mode 100644 index 0000000..c5f139c --- /dev/null +++ b/pay/src/main/java/com/ruoyi/wx/WxpayConfig.java @@ -0,0 +1,20 @@ +package com.ruoyi.wx; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 微信权限对接类 + */ +@Component +@ConfigurationProperties("elegent.pay.wxpay") +@Data +public class WxpayConfig { + + private String mchId; //商户号 + private String appId; //APPID + private String appSecret;//app密钥 + private String mchSerialNo; //商户证书序列号 + private String apiV3Key; //V3密钥 + +} \ No newline at end of file diff --git a/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java b/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java new file mode 100644 index 0000000..01d3415 --- /dev/null +++ b/pay/src/main/java/com/ruoyi/wx/WxpayConstant.java @@ -0,0 +1,48 @@ +package com.ruoyi.wx; + +import java.util.HashMap; +import java.util.Map; + +public class WxpayConstant { + + public static final Map SUCCESS = new HashMap(){ + { + put("code", "SUCCESS"); + } + }; + + public static final Map FAIL = new HashMap(){ + { + put("code", "FAIL"); + put("message","微信回调错误结果"); + } + }; + + + public final static String domain ="https://api.mch.weixin.qq.com/v3"; + + /** + * 创建订单 + */ + public final static String createOrder = domain +"/pay/transactions/"; + + /** + * 关闭订单 + */ + public final static String closeOrder = domain+"/pay/transactions/out-trade-no/{out_trade_no}/close"; + + /** + * 查询订单编号 + */ + public static String queryOrderNo = domain+"/pay/transactions/out-trade-no/"; + + /** + * 查询退款订单 + */ + public static String queryRufundOrderNo =domain+ "/refund/domestic/refunds/"; + + /** + * 退款接口 + */ + public static String refund = domain+"/refund/domestic/refunds"; +} diff --git a/pay/src/main/resources/META-INF/spring.factories b/pay/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..da04c71 --- /dev/null +++ b/pay/src/main/resources/META-INF/spring.factories @@ -0,0 +1,14 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.ruoyi.config.CallbackConfig,\ + com.ruoyi.core.CallbackWatch,\ + com.ruoyi.core.ElegentPayImpl,\ + com.ruoyi.core.ElegentLoader,\ + com.ruoyi.core.ElegentConfig,\ + com.ruoyi.key.impl.DefaultKeyManager,\ + com.ruoyi.core.CallbackController,\ + com.ruoyi.wx.WxpayConfig,\ + com.ruoyi.wx.WxPayElegentTrade,\ + com.ruoyi.wx.WxPayElegentValid,\ + com.ruoyi.ali.AlipayConfig,\ + com.ruoyi.ali.AlipayElegentTrade,\ + com.ruoyi.ali.AlipayElegentValid \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9d5389d..9c62fbb 100644 --- a/pom.xml +++ b/pom.xml @@ -180,6 +180,7 @@ ruoyi-quartz ruoyi-generator ruoyi-common + pay pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 1436d6d..2186d33 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -60,7 +60,11 @@ com.ruoyi ruoyi-generator - + + com.ruoyi + pay + 1.0.0-SNAPSHOT + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java new file mode 100644 index 0000000..def71be --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/ArbitrSignatuController.java @@ -0,0 +1,33 @@ +package com.ruoyi.web.controller.bestsign; + +import com.ruoyi.bestsign.domain.ArbitrSignatuVO; +import com.ruoyi.bestsign.domain.PersonRegisterVO; +import com.ruoyi.bestsign.service.ArbitrSignatuService; +import com.ruoyi.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/arbitrSignatu") +public class ArbitrSignatuController { + @Autowired + ArbitrSignatuService arbitrSignatuService; + + /** + * 申请状态查询 + * + * @param arbitrSignatuVO + * @return + */ + @PostMapping("/selectApplyStatus") + public AjaxResult selectApplyStatus (@Validated @RequestBody ArbitrSignatuVO arbitrSignatuVO) { + return arbitrSignatuService.selectApplyStatus(arbitrSignatuVO); + } + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java new file mode 100644 index 0000000..5f3b0d1 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bestsign/RegisterController.java @@ -0,0 +1,31 @@ +package com.ruoyi.web.controller.bestsign; + +import com.ruoyi.bestsign.domain.PersonRegisterVO; +import com.ruoyi.bestsign.service.SignRegisterService; +import com.ruoyi.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/register") +public class RegisterController { + @Autowired + SignRegisterService signRegisterService; + + /** + * 注册上上签个人用户 + * + * @param personRegisterVO + * @return + */ + @PostMapping("/registerPerson") + public AjaxResult createDocument(@Validated @RequestBody PersonRegisterVO personRegisterVO) { + return signRegisterService.registerPerson(personRegisterVO); + } +// @PostMapping("/registerEnterprise") +// public AjaxResult +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index d959a17..60633c7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -2,6 +2,9 @@ package com.ruoyi.web.controller.system; import java.util.List; import java.util.Set; + +import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication; +import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -19,12 +22,11 @@ import com.ruoyi.system.service.ISysMenuService; /** * 登录验证 - * + * * @author ruoyi */ @RestController -public class SysLoginController -{ +public class SysLoginController { @Autowired private SysLoginService loginService; @@ -33,32 +35,37 @@ public class SysLoginController @Autowired private SysPermissionService permissionService; + @Autowired + IdentityAuthenticationService identityAuthenticationService; /** * 登录方法 - * + * * @param loginBody 登录信息 * @return 结果 */ @PostMapping("/login") - public AjaxResult login(@RequestBody LoginBody loginBody) - { + public AjaxResult login(@RequestBody LoginBody loginBody) { AjaxResult ajax = AjaxResult.success(); // 生成令牌 String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid()); ajax.put(Constants.TOKEN, token); + //判断该用户是否已经实名认证(certificationStatus1已认证0未认证) + IdentityAuthentication identityAuthentication=new IdentityAuthentication(); + identityAuthentication.setUserName(loginBody.getUsername()); + String status = identityAuthenticationService.checkIsAuthentication(identityAuthentication); + ajax.put("certificationStatus", status); return ajax; } /** * 获取用户信息 - * + * * @return 用户信息 */ @GetMapping("getInfo") - public AjaxResult getInfo() - { + public AjaxResult getInfo() { SysUser user = SecurityUtils.getLoginUser().getUser(); // 角色集合 Set roles = permissionService.getRolePermission(user); @@ -73,12 +80,11 @@ public class SysLoginController /** * 获取路由信息 - * + * * @return 路由信息 */ @GetMapping("getRouters") - public AjaxResult getRouters() - { + public AjaxResult getRouters() { Long userId = SecurityUtils.getUserId(); List menus = menuService.selectMenuTreeByUserId(userId); return AjaxResult.success(menuService.buildMenus(menus)); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java new file mode 100644 index 0000000..ea6ce32 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java @@ -0,0 +1,107 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO; +import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO; +import com.ruoyi.wisdomarbitrate.service.IAdjudicationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/adjudication") +public class AdjudicationController extends BaseController { + @Autowired + private IAdjudicationService adjudicationService; + + /** + * 生成裁决书 + * @param caseApplication + * @return + */ + @PostMapping("/document") + @PreAuthorize("@ss.hasPermi('caseManagement:list:createaward')") + public AjaxResult createDocument(@Validated @RequestBody CaseApplication caseApplication){ + return adjudicationService.createDocument(caseApplication); + } + + /** + * 裁决书送达(电子邮件) + * @param bookSendVO + * @return + */ + @PostMapping("/delivery") + public AjaxResult sendDocumentByEmail(@RequestBody BookSendVO bookSendVO){ + return adjudicationService.sendDocumentByEmail(bookSendVO.getId(),bookSendVO.getAppEmail(),bookSendVO.getResEmail(),bookSendVO.getApptrackingNum(),bookSendVO.getRestrackingNum()); + } + + /** + * 根据快递单号查询物流信息 + * @param caseApplication + * @return + */ + @GetMapping("/logistics") + @PreAuthorize("@ss.hasPermi('delivery:detail')") + public AjaxResult getLogisticsInfo(CaseApplication caseApplication){ + List logisticsInfo = adjudicationService.getLogisticsInfo(caseApplication); + return AjaxResult.success(logisticsInfo); + } + + /** + * 签名(暂时只改案件状态) + * @param caseApplication + * @return + */ + @PostMapping("/signature") + @PreAuthorize("@ss.hasPermi('awardManagement:list:sign')") + public AjaxResult signature(@Validated @RequestBody CaseApplication caseApplication){ + return adjudicationService.signature(caseApplication); + } + + /** + * 归档(暂时只改案件状态) + * @param caseApplication + * @return + */ + @PostMapping("/caseFile") + @PreAuthorize("@ss.hasPermi('awardManagement:list:file')") + public AjaxResult caseFile(@Validated @RequestBody CaseApplication caseApplication){ + return adjudicationService.caseFile(caseApplication); + } + + /** + * 送达(不包含发送电子邮件) + * @param bookSendVO + * @return + */ + @PostMapping("/service") + @PreAuthorize("@ss.hasPermi('awardManagement:list:sendaward')") + public AjaxResult service(@RequestBody BookSendVO bookSendVO){ + return adjudicationService.service(bookSendVO.getId(),bookSendVO.getAppEmail(),bookSendVO.getResEmail(),bookSendVO.getApptrackingNum(),bookSendVO.getRestrackingNum()); + } + /** + * 用印(暂时只改案件状态) + * @param caseApplication + * @return + */ + @PostMapping("/stamp") + @PreAuthorize("@ss.hasPermi('awardManagement:list:signprint')") + public AjaxResult stamp(@Validated @RequestBody CaseApplication caseApplication){ + return adjudicationService.stamp(caseApplication); + } + + /** + * 档案详情查询 + * @param id 案件id + * @return + */ + @GetMapping("/archives") + public AjaxResult getArchivesDetail(Long id){ + return adjudicationService.getArchivesDetail(id); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java new file mode 100644 index 0000000..b87089a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/ArbitratorController.java @@ -0,0 +1,41 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.wisdomarbitrate.domain.Arbitrator; +import com.ruoyi.wisdomarbitrate.service.IArbitratorService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/arbitrator") +public class ArbitratorController extends BaseController { + @Autowired + private IArbitratorService arbitratorService; + + /** + * 查询仲裁员信息 + */ +// @PreAuthorize("@ss.hasPermi('arbitrator:list')") + @GetMapping("/list") + public TableDataInfo list(Arbitrator arbitrator) + { + startPage(); + List list = arbitratorService.selectArbitratorList(arbitrator); + return getDataTable(list); + } + + + + + + + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java new file mode 100644 index 0000000..de992f1 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java @@ -0,0 +1,214 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO; +import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.utils.poi.ExcelUtil; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + + +@RestController +@RequestMapping("/caseApplication") +public class CaseApplicationController extends BaseController { + @Autowired + private ICaseApplicationService caseApplicationService; + + + /** + * 查询立案数据 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list')") + @GetMapping("/list") + public TableDataInfo list(CaseApplication caseApplication) { + startPage(); + List list = caseApplicationService.selectCaseApplicationList(caseApplication); + return getDataTable(list); + } + + /** + * 新增立案数据 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:add')") + @Log(title = "新增立案数据", businessType = BusinessType.INSERT) + @PostMapping("/addCaseApplication") + public AjaxResult addCaseApplication(@Validated @RequestBody CaseApplication caseApplication) + { + + caseApplication.setCreateBy(getUsername()); + return toAjax(caseApplicationService.insertcaseApplication(caseApplication)); + } + + /** + * 修改立案数据 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:update')") + @Log(title = "修改立案数据", businessType = BusinessType.UPDATE) + @PostMapping("/editCaseApplication") + public AjaxResult editCaseApplication(@Validated @RequestBody CaseApplication caseApplication) { + + caseApplication.setUpdateBy(getUsername()); + return toAjax(caseApplicationService.editCaseApplication(caseApplication)); + } + + /** + * 提交立案申请 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:submit')") + @Log(title = "提交立案申请", businessType = BusinessType.UPDATE) + @PostMapping("/submitCaseApplication") + public AjaxResult submitCaseApplication(@Validated @RequestBody CaseApplication caseApplication) { + + return toAjax(caseApplicationService.submitCaseApplication(caseApplication)); + } + + /** + * 删除立案数据 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:delete')") + @Log(title = "删除立案数据", businessType = BusinessType.DELETE) + @PostMapping("/removeCaseApplication") + public AjaxResult removeCaseApplication(@Validated @RequestBody CaseApplication caseApplication) { + + return toAjax(caseApplicationService.deletecaseApplicationByIds(caseApplication)); + } + + /** + * 查询立案信息 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:detail')") + @PostMapping("/selectCaseApplication") + public AjaxResult selectCaseApplication(@Validated @RequestBody CaseApplication caseApplication) { + CaseApplication caseApplicationselect = caseApplicationService.selectCaseApplication(caseApplication); + return success(caseApplicationselect); + } + + /** + * 立案申请导入模板下载 + */ + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) { + ExcelUtil util = new ExcelUtil(CaseApplication.class); + util.importTemplateExcel(response, "立案申请数据"); + } + + @Log(title = "立案信息导入", businessType = BusinessType.IMPORT) + @PreAuthorize("@ss.hasPermi('caseManagement:list:import')") + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file) throws Exception { + if(file==null){ + return warn("请上传文件"); + } + ExcelUtil util = new ExcelUtil(CaseApplication.class); + List caseApplicationList = util.importExcel(file.getInputStream()); + String operName = getUsername(); + String message = caseApplicationService.importCaseApplication(caseApplicationList, operName); + return success(message); + } + + /** + * 组庭 + */ + @PreAuthorize("@ss.hasPermi('caseApplication:pendTral')") + @Log(title = "组庭", businessType = BusinessType.UPDATE) + @PostMapping("/pendTral") + public AjaxResult pendTral(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.pendTral(caseApplication)); + } + + /** + * 组庭审核 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:checkgroup')") + @Log(title = "组庭审核", businessType = BusinessType.UPDATE) + @PostMapping("/pendTralCheck") + public AjaxResult pendTralCheck(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.pendTralCheck(caseApplication)); + } + + /** + * 组庭确认 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:confirmgroup')") + @Log(title = "组庭确认", businessType = BusinessType.UPDATE) + @PostMapping("/pendTralSure") + public AjaxResult pendTralSure(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.pendTralSure(caseApplication)); + } + + /** + * 核验裁决书 + */ + @PreAuthorize("@ss.hasPermi('caseApplication:verificationArbitrateRecord')") + @Log(title = "核验裁决书", businessType = BusinessType.UPDATE) + @PostMapping("/verificationArbitrateRecord") + public AjaxResult verificationArbitrateRecord(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.verificationArbitrateRecord(caseApplication)); + } + + /** + * 审核裁决书 + */ + @PreAuthorize("@ss.hasPermi('caseApplication:checkArbitrateRecord')") + @Log(title = "审核裁决书", businessType = BusinessType.UPDATE) + @PostMapping("/checkArbitrateRecord") + public AjaxResult checkArbitrateRecord(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.checkArbitrateRecord(caseApplication)); + } + + + /** + * 是否指派仲裁员 + */ + @PreAuthorize("@ss.hasPermi('caseApplication:pendingAppointArbotrar')") + @Log(title = "是否指派仲裁员", businessType = BusinessType.UPDATE) + @PostMapping("/pendingAppointArbotrar") + public AjaxResult pendingAppointArbotrar(@Validated @RequestBody CaseApplication caseApplication) { + return toAjax(caseApplicationService.pendingAppointArbotrar(caseApplication)); + } + + /** + * 提交立案审查 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:check')") + @Log(title = "提交立案审查", businessType = BusinessType.UPDATE) + @PostMapping("/submitCaseApplicationCheck") + public AjaxResult submitCaseApplicationCheck(@Validated @RequestBody CaseApplication caseApplication) { + + return toAjax(caseApplicationService.submitCaseApplicationCheck(caseApplication)); + } + + /** + * 确认缴费查询立案信息 + */ + @PreAuthorize("@ss.hasPermi('paymentManagement:list:detail')") + @PostMapping("/selectCaseApplicationConfirm") + public AjaxResult selectCaseApplicationConfirm(@Validated @RequestBody CaseApplication caseApplication) { + CaseApplication caseApplicationselect = caseApplicationService.selectCaseApplicationConfirm(caseApplication); + return success(caseApplicationselect); + } + + + /** + * 发送房间号短信 + */ + @Anonymous + @PostMapping("/sendRoomNoMessage") + public AjaxResult sendRoomNoMessage(@Validated @RequestBody SendRoomNoMessageVO messageVO) { + String result = caseApplicationService.sendRoomNoMessage(messageVO); + return success(result); + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java new file mode 100644 index 0000000..20c5b17 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseArbitrateController.java @@ -0,0 +1,42 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.service.ICaseArbitrateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/arbitrate") +public class CaseArbitrateController extends BaseController { + @Autowired + private ICaseArbitrateService caseArbitrateService; + + /** + * 审核仲裁方式 + * @param caseApplication + * @param opinion 1同意,0拒绝 + * @return + */ + @PutMapping("/method") + @PreAuthorize("@ss.hasPermi('caseManagement:list:checkarbitrationway')") + public AjaxResult examineArbitrateMethod(@Validated @RequestBody CaseApplication caseApplication + ,Integer opinion){ + return caseArbitrateService.examineArbitrateMethod(caseApplication,opinion); + } + + /** + * 书面审理 + * @param arbitrateRecord + * @return + */ + @PostMapping("/writtenHear") + @PreAuthorize("@ss.hasPermi('caseManagement:hear')") + public AjaxResult writtenHear(@Validated @RequestBody ArbitrateRecord arbitrateRecord){ + return caseArbitrateService.writtenHear(arbitrateRecord); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java new file mode 100644 index 0000000..3a408ca --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java @@ -0,0 +1,96 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.dto.CaseEvidenceDTO; +import com.ruoyi.wisdomarbitrate.domain.vo.CaseEvidenceVO; +import com.ruoyi.wisdomarbitrate.service.ICaseEvidenceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; + +/** + * 案件证据 + */ +@RestController +@RequestMapping("/evidence") +public class CaseEvidenceController extends BaseController { + private final ICaseEvidenceService caseEvidenceService; + + @Autowired + public CaseEvidenceController(ICaseEvidenceService caseEvidenceService) { + this.caseEvidenceService = caseEvidenceService; + } + + /** + * 根据案件id查询案件详情 + * + * @param id + * @return + */ + @GetMapping("/{id}") + public AjaxResult getCaseDetailsById(@PathVariable Long id) { + String username = this.getUsername(); + return caseEvidenceService.getCaseDetailsById(id, username); + } + + /** + * 案件证据上传 + * + * @param file 附件 + * @param annexType 附件类型,立案申请书(1)、证据材料(2)、仲裁文书(3)、案件视频(4)、身份证件(5) + * @param id 案件申请id + * @return + */ + @PostMapping("/upload") + public AjaxResult uploadEvidence(@RequestParam("file") MultipartFile file, Integer annexType, Long id) { + String username = this.getUsername(); + Long userId = this.getUserId(); + return caseEvidenceService.uploadEvidence(file, annexType, id, username, userId); + } + + /** + * 查询当前用户案件列表 + * + * @param identityNum + * @return + */ + @GetMapping("/all") + public TableDataInfo getCaseListAll(@RequestParam(required = false) String identityNum) { + startPage(); + List list = caseEvidenceService.getCaseListAll(identityNum); + if (list != null) { + return getDataTable(list); + } + return getDataTable(new ArrayList<>()); + } + + /** + * 证据确认 + * + * @param caseApplication 案件对象 + * @return 统一返回结果 + */ + @PutMapping("/confirm") + public AjaxResult evidenceConfirmation(@Validated @RequestBody CaseApplication caseApplication) { + return caseEvidenceService.evidenceConfirmation(caseApplication); + } + + /** + * 案件质证 + * + * @param caseEvidenceDTO + * @return + */ + @PostMapping("/crossexami") + public AjaxResult caseCrossexamination(@Validated @RequestBody CaseEvidenceDTO caseEvidenceDTO) { + return caseEvidenceService.caseCrossexamination(caseEvidenceDTO); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java new file mode 100644 index 0000000..8fd1ee0 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseLogRecordController.java @@ -0,0 +1,40 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; +import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/caseLogRecord") +public class CaseLogRecordController extends BaseController { + @Autowired + private ICaseLogRecordService caseLogRecordService; + + /** + * 查询案件日志列表 + */ + @PreAuthorize("@ss.hasPermi('caseLog:list')") + @GetMapping("/list") + public TableDataInfo list(CaseLogRecord caseLogRecord) + { + startPage(); + List list = caseLogRecordService.selectCaseLogRecordList(caseLogRecord); + return getDataTable(list); + } + + + + + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java new file mode 100644 index 0000000..5f13ee7 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CasePaymentController.java @@ -0,0 +1,44 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.service.ICasePaymentService; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * 缴费支付 + */ +@RestController +@RequestMapping("/pay") +public class CasePaymentController { + private final ICasePaymentService paymentService; + @Autowired + public CasePaymentController(ICasePaymentService paymentService){ + this.paymentService=paymentService; + } + /** + * 案件缴费 + * @param casePayDTO 缴费传入参数 + * @return 统一响应结果 + */ + @PreAuthorize("@ss.hasPermi('caseManagement:list:pay')") + @PostMapping("/casePay") + public AjaxResult casePay(@Validated @RequestBody CasePayDTO casePayDTO) { + return paymentService.casePay(casePayDTO); + } + + /** + * 缴费确认 + * @param caseApplication + * @return + */ + @PreAuthorize("@ss.hasPermi('paymentManagement:list:payconfirm')") + @PutMapping("/confirm") + public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) { + return paymentService.confirmPayment(caseApplication); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java new file mode 100644 index 0000000..7260847 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/IdentityAuthenticationController.java @@ -0,0 +1,40 @@ +package com.ruoyi.web.controller.wisdomarbitrate; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication; +import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/identityAuthentication") +public class IdentityAuthenticationController extends BaseController { + @Autowired + private IdentityAuthenticationService identityAuthenticationService; + + /** + * 获取EIDtoken + */ + @PostMapping("/selectIdentityAuthenticaEIDtoken") + public AjaxResult selectIdentityAuthenticaEIDtoken() { + JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(); + return success(tokenResult); + } + + /** + * 小程序人脸核身后查询身份认证结果 + */ + @PostMapping("/selectIdentityAuthenticaRespon") + public AjaxResult selectIdentityAuthenticaRespon(@Validated @RequestBody IdentityAuthentication ientityAuthentication) { + AjaxResult checkResult = identityAuthenticationService.selectIdentityAuthenticaRespon(ientityAuthentication); + return checkResult; + } + + +} diff --git a/ruoyi-admin/src/main/resources/alipay_private.key b/ruoyi-admin/src/main/resources/alipay_private.key new file mode 100644 index 0000000..6a4759b --- /dev/null +++ b/ruoyi-admin/src/main/resources/alipay_private.key @@ -0,0 +1 @@ +MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQC12YM9mR+HFQYTx/fHKHZbgszVtDHDB0B/ysWl3MbcPpGtjcZlDr5aynRMRLaoduRHT++A98IaNVIVGj9RHdXrX2j9I/Uz6fYDH63cdu6FZ6Pk82yPwNZW7pebprbVHInR/7gzsKQWSWEST70BgjCRqlbfAE6xzUZFTeYxciCjptm0rUQ2MC24xRdkvZByIDIYFnQ/AdmSFqNtKDR2WpEV/M8aBjyuPPomRJZ1X8oudWuJIU4ySdas04fCbDxD10TY/wyQcDHXuG1IrQpXme4DOGQeJZ0/aOFphBkDFUyPGfYMmLshOPNdBKi2IqWHPPs4XsV4Rv6+tvTSnMF2uGqHAgMBAAECggEAPa1sifPpcZN74DGupGng2uDeQI1BY3iOM8m+h6b9+61tE4RGifgaMAkCsOuNWE4a1uURwphFyUXUdTvVxdlsuMw/e7w6akUsH5sbCO99rtmcCQdXBtrM1+dMnIpK8LUhOYyWGVIMFVMGDYPmAyD5AC7aEAC2sC+DafYl4RdoYpidq1YxeE7DVw1aQHCI2mKhYjZG+3RDDGDfNFvdyH61MgdYjoGkeXNvARzEXgfWvfiTrHZ3H1SYgvOEHofzKDTrWsQL2dvaEsc55Jiw0AgNUVcgby7al8PUekTJoK3ZvrE3pSWaUirBcqsqWISHjeR7Xx501CHIha8EnZwlnDoM4QKBgQDtnYzwQ5mHg7cRHD8Z6QdTpvBvYSEPesiUT/HeI+AKQKDCVJxKiLvJagc6zZkOzV9bZDS/WLgzXWMyxUb+OTjht0jLWAMcf7NfFp3tPKq9wkmQQ/vQSBQ1lFmO6A4Zq1eoGKeUCB4pKBG6cSM+t8+ruhm7s1ZUt+6EBwCVN/izrQKBgQDD62jIm+6NFErdidUaIrGiFUrzqdR13w6JOexfk+O6Aau3wRqsr7Wz4nqQvVVxGMRpXbOH06zpeiS+vMmjwgO973VoLAmH+hJ0GZz8qj3zA2GEOFWjD2V7tqeRvGkQvz0v46pl+8sBJkrRHLN7DWNYY5NDI+b7exwqcTc/LL19gwJ/a6r4MeZvqvgD+7zQ2uy8ZSs/xzg7wsfgG1QeRIn8+qhOL8AnEZ7jeGCS5hJDSHHGw6KkRA/vZ1bpnBfIE2naXGywj3NR9Zfnry6QYO8cbt+adcRYVghTH/QYoKiFuxvonEKPrIQBJqUBY3ngforLjwTEpEie1cSCT1Dc8sBp8QKBgQCaz8fqzRyBKknGKQXVMxj+JKknRUl3IpzP3o9jLu9BqdRQzSwQzH9d91Y2TQXY6mM5hys35xG5JCUo+vCyj7p5OWCiwjl90yMFzr93/+YXwtIpsoIo6R+d1EUxKZoz+4mT7+hT0dUlwWZZOr6wO3IHBBf3c8UvbqZg+zlWmDnblQKBgEs6jwMkb5zaG2fyBJ7PJUN/8nIz8V+X0SxQfcEqIX0J+EC+7MAgFjcdZFp+lca3Vd9z+8Ksd4rMzMa5y856ositL2NZ+K0fs8i8EBaQPny61OgCFUuXEuv5keB2YuGMSns5FYRWuByrtDXl4PxzKXvq05iKWLKCaCq9v4momvKZ \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/alipay_public.key b/ruoyi-admin/src/main/resources/alipay_public.key new file mode 100644 index 0000000..21236fb --- /dev/null +++ b/ruoyi-admin/src/main/resources/alipay_public.key @@ -0,0 +1 @@ +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhUnjdAKwZApwZEcfq+5L0pa77Vg3mqcoXv+th8RR0SYotkPsH1f2JkbS48ySaSCM6YNWSMNfqp5qdOla2zUJOBnJ/yaBg7s7fVD6V3M2mEog8kCDYGKt/3P4VII3xYl8lFYMQ3IcFRELkxCBBCA8JDKmf5z2R4F/Z/jFFEuOwxaJvp+7Ke9OzZHYdWGNnU6QP8YYLYUeX7VNZLHEuly34ExAw6A+yJkNDsYEho2Lu31QjT2pLh9g+88MlRfiI92iN25O9NVdeM4f5RcpvBPrBQZQs9tlFmALYSFS3prIf3FAobWM+W7iwxT6J25nFIhst1DdJQfIBpaeRUJVTkn99QIDAQAB \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 06872aa..65f5d96 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ruyivue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: ruyivue - password: rybackproje13689 + url: jdbc:mysql://121.40.189.20:3306/arbitrate?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: root123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index cfe0d50..3e9f5c0 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath + profile: /home/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数字计算 char 字符验证 @@ -18,7 +18,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 9001 servlet: # 应用的访问路径 context-path: / @@ -32,7 +32,6 @@ server: max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 - # 日志配置 logging: level: @@ -70,9 +69,9 @@ spring: # redis 配置 redis: # 地址 - host: localhost + host: 121.40.189.20 # 端口,默认为6379 - port: 6379 + port: 6389 # 数据库索引 database: 0 # 密码 @@ -89,6 +88,25 @@ spring: max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms + web: + resources: + static-locations: file:/home/ruoyi/ + mail: + host: smtp.163.com + port: 25 + username: hjbjava@163.com + password: BSRSSEPJWGNNVYYL + default-encoding: UTF-8 + properties: + mail: + smtp: + socketFactoryClass: javax.net.ssl.SSLSocketFactory + debug: false +#上上签配置参数 +ssq: + developerId: 1695872832013855470 + privateKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCiDRuz+dxqkWqHdov0hK+KEWLw/e8MQSqkZZ4c01Yr6cSmQiWyV8Xin0u5S/EA02FWxpjLi1nLriVtOBhZGsoryFmcJrwzSnQ5PORP/HhfcAWFE/Y+3qSQS1OiU7e5wbReCgEUvx4GHZuhdu8cOvq5DG9l33YFZrIEMBTmnf8eKT54STx0tjcKl7U6B6nsiThy3zVtpWXVv6H1HGmxC0KT4EQ388s/PFjrwmk+GFb3EpKCns/GQHf7QrtNz1ZOgCXfgQiQ+91/tcngzUH+zMCIxn5lS+ENAxVI6Ev3W9Y0QHtKwmO4ORVuAskJYzBB2xKI/gw8+PUXNziMAKXuoUAjAgMBAAECggEAd7yHw6vTGUrpE76cGsgPjEzcdoSqpLth7qbG9TWSblAEZXRqtiP0q0ZYhUl/gcSuH5gOPhdw+fZq4RCZrP0GdONMkvxsAtn4lnJPoGpD5wC2k2X0hO+tWJDP8xk4n6BozTNHKTUt0gb+f4eJlapep2xwwy0h30vKLR3504zafEV9j/2D8l5TFSv6rd3UVxUvrDKQ9mhfATEUlrTpjs0SfWupMkr4j7TuJJ8qSUSiEADe4hyUB6+LouDZCt8jV4aLojQBJKrQ6VPVdDFkHGsePu4tHtvcKsaOZJ0pjpJ7MT6D5ElD/sJjo0g/3qK5/FToVFVbrxtykVreK6mE5oSTQQKBgQDpEFSgH1d4N7NsZhviaCIUkB97hO0jpRbD7UZirzZ9ok96Fk+SmfhdmypDMoiaRHCNhQuu5dI9mg5RbUhz9mCZnAhzJRL+DmE4bhNvQmbtJA7KT6n/AdH2zy0mYulrcG17dQspvTr/5421PTEE2+FRoCbG6hBsSSUit9HLvAU13QKBgQCx/7ql+hbx+t0Yb02XckBHiA+MWrFLO4dMX9cKf3LldC0nhn0K9HOSoZmM0KcmXRnMo+/4t89xOJRl7JRXwcLoy/64OaUBVv+8FFV1yY4THka3nEnQE40vVWy+vuNJtt+eKlEhJ35N1GIHXo7/4j0POtEuNU7KSqMnLUD+Oy/t/wKBgEiajcJUASuyLnLWXFlrlzJQs34HKtiv1Se0Avk7G/6HUbr2uFMzI+wFKmVEmMl2CJoNmFYjwhruowc6xBdb6TvxH7C/G+uJD0BFCkjeprG5SeI8bvjB2GbKo4YRyiVuIK0VCSU3jemqeLq9FUguN0L2YR4WTIdvQeJO4UxWhkkBAoGBAJk7TxDHZK1XirIYTzGK928c4FWxVWMwkd7buqGc6epBwwV9r3OY0U1vtGIW1W4fQ7B5iIISqpALZyT/Lw0FDqedxWAOr8+hd3IQBynpI1et/q7d6mUoD6ip332tkrjIp2TfhQwHlaGmreUuL+h0eJ/9wEoJNhTLf/yf5o11omM9AoGBAOLVlXR9FbU2Ubpp3HwTumSzKDWzq3T5eQcqC1zE3BPOo29uAf9BQTumPxe51U64egttW/nif5FH4v4Gentmxb2B2ckdOs/u9zIWz3JPfHU7RqMyMokuWrQ6lMoiSYpH3MSHoavLyAEhAnpceX3oktXgpYHO9d8MfON3XKJl23ip + serverHost: https://openapi.bestsign.info/openapi/v2/ # token配置 token: @@ -129,3 +147,23 @@ xss: excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* +#支付相关配置 +elegent: + pay: + wxpay: + mchId: 1561414331 + appId: wx6592a2db3f85ed25 + appSecret: d9a9ff00a633cd7353a8925119063b01 + mchSerialNo: 25FBDE3EFD31B03A4377EB9A4A47C517969E6620 + apiV3Key: CZBK51236435wxpay435434323FFDuv3 + alipay: + appId: 2021003141676135 + callback: + domain: http://121.40.189.20:9001/ + watch: true + cycle: 10 +identityAuthentication: + credentialSecretId: AKID3xfHgroY4MQHvLXUXMwIQL1UjmbBX1Tv + credentialSecretKey: INDrIXcT8YmomZBcsy0oNirnU0LTN4X7 + merchantId: 0NSJ2309281116194321 + privateKeyHexDecodeinfo: 4c3b311bf7b98969994e85928e069574a1e95777f24d1c510679cc3c2f460faf \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/wxpay_private.key b/ruoyi-admin/src/main/resources/wxpay_private.key new file mode 100644 index 0000000..d4be12f --- /dev/null +++ b/ruoyi-admin/src/main/resources/wxpay_private.key @@ -0,0 +1 @@ +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDBHGgIh80193GhdpD1LtMZfTRpcWI0fImyuBCyrd3gYb3rrsARebGcHdJsQA3mVjVqVp5ybhEZDPa4ecoK4Ye1hTppNpI/lmLt4/uUV/zhF5ahli7hi+116Ty6svHSbuMQBuUZeTFOwGrxjvofU/4pGIwh8ZvkcSnyOp9uX2177UVxDBkhgbZbJp9XF2b83vUa5eHo93CziPzn3hFdAlBCdTXB7DH+m0nN3Jou0szGukvq7cIgGpHku4ycKSTkIhhl9WRhN6OoSEJxq88MXzjkzTruc85PHN52aUTUifwg3T8Y4XqFQ61dTnEmgxeD2O6/pLdB9gLsp6yCGqN5Lqk7AgMBAAECggEBAL4X+WzUSbSjFS9NKNrCMjm4H1zgqTxjj6TnPkC1mGEltjAHwLgzJBw62wWGdGhWWpSIGccpBBm1wjTMZpAZfF66fEpP1t1Ta6UjtGZNyvfFIZmE3jdWZ/WXGBnsxtFQKKKBNwrBW0Fbdqq9BQjLxLitmlxbmwrgPttcy855j6vZqq4MBT1v8CtUT/gz4UWW2xWovVnmWOrRSScv7Nh0pMbRpPLkNHXrBwSSNz/keORzXB9JSm85wlkafa7n5/IJbdTml3A/uAgW3q3JZZQotHxQsYvD4Zb5Cnc9CPAXE5L2Yk877kVXZMGt5QPIVcPMj/72AMtaJT67Y0fN0RYHEGkCgYEA38BIGDY6pePgPbxB7N/l6Df0/OKPP0u8mqR4Q0aQD3VxeGiZUN1uWXEFKsKwlOxLfIFIFk1/6zQeC0xetNTKk0gTL8hpMUTNkE7vI9gFWws2LY6DE86Lm0bdFEIwh6d7Fr7zZtyQKPzMsesC3XV9sdSUExEi5o/VwAyf+xZlOXcCgYEA3PGZYlILjg3esPNkhDz2wxFw432i8l/BCPD8ZtqIV9eguu4fVtFYcUVfawBb0T11RamJkc4eiSOqayC+2ehgb+GyRLJNK4FqbFcsIT+CK0HlscZw51jrMR0MxTc4RzuOIMoYDeZqeGB6/YnNyG4pw2sD8bIwHm8406gtJsX/v10CgYAo8g3/aEUZQHcztPS3fU2cTkkl0ev24Ew2XGypmwsX2R0XtMSBuNPNyFHyvkgEKK2zrhDcC/ihuRraZHJcUyhzBViFgP5HBtk7VEaM36YzP/z9Hzw7bqu7kZ85atdoq6xpwC3Yn/o9le17jY8rqamD1mv2hUdGvAGYsHbCQxnpBwKBgHTkeaMUBzr7yZLS4p435tHje1dQVBJpaKaDYPZFrhbTZR0g+IGlNmaPLmFdCjbUjiPyA2+Znnwt227cHz0IfWUUAo3ny3419QkmwZlBkWuzbIO2mms7lwsf9G6uvV6qepKMeVd5TWEsokVbT/03k27pQmfwPxcK/wS0GFdIL/udAoGAOYdDqY5/aadWCyhzTGI6qXPLvC+fsJBPhK2RXyc+jYV0KmrEv4ewxlK5NksuFsNkyB7wlI1oMCa/xB3T/2vTBALgGFPi8BJqceUjtnTYtI4R2JIVEl08RtEJwyU5JZ2rvWcilsotVZYwfuLZ9KfdhkTrgNxlp/KKkr+UuKce4Vs= \ No newline at end of file diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 71fea1e..b0c399b 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -52,19 +52,19 @@ org.apache.commons commons-lang3 - + com.fasterxml.jackson.core jackson-databind - + - - com.baomidou - dynamic-datasource-spring-boot-starter - 3.5.2 - + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.5.2 + @@ -126,6 +126,69 @@ javax.servlet-api + + org.projectlombok + lombok + 1.18.22 + + + + + com.tencentcloudapi + tencentcloud-sdk-java + 3.1.876 + + + + com.tencentcloudapi + tencentcloud-sdk-java-faceid + 3.1.875 + + + + cn.hutool + hutool-all + 5.7.15 + + + + org.bouncycastle + bcprov-jdk15to18 + 1.69 + + + + + com.deepoove + poi-tl + 1.9.1 + + + + + org.springframework.boot + spring-boot-starter-mail + 3.1.4 + + + + javax.activation + activation + 1.1.1 + + + + + javax.mail + mail + 1.4.7 + + + org.apache.httpcomponents + httpclient + + + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java new file mode 100644 index 0000000..f9888e2 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/EsignDemoConfig.java @@ -0,0 +1,13 @@ +package com.ruoyi.common.config; + +public class EsignDemoConfig { + + // 应用ID + public static final String EsignAppId = "7438987614"; + // 应用密钥 + public static final String EsignAppSecret = "9d7844f13830931037772b9d20cf1529"; + // e签宝接口调用域名(模拟环境) + public static final String EsignHost = "https://smlopenapi.esign.cn"; + // e签宝接口调用域名(正式环境) + // public static final String EsignHost = "https://openapi.esign.cn"; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java new file mode 100644 index 0000000..d4bcb6e --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CaseApplicationConstants.java @@ -0,0 +1,53 @@ +package com.ruoyi.common.constant; +/** + * 立案申请案件状态 + * + */ +public class CaseApplicationConstants { + /** 立案申请 */ + public static final int CASE_APPLICATION = 0; + /** 待立案审查 */ + public static final int CASE_CHECK = 1; + /** 待缴费 */ + public static final int PENDING_PAYMENT = 2; + /** 待缴费确认 */ + public static final int PENDING_PAYMENT_CONFIRM = 3; + /** 待案件质证 */ + public static final int CASE_CROSSEXAMI = 4; + + /** 待组庭 */ + public static final int PENDING_TRIAL = 26; + /** 待组庭审核 */ + public static final int CONFIRMDED_PENDING_TRIAL_SUBMMIT = 5; + /** 待组庭确定 */ + public static final int CONFIRMDED_PENDING_TRIAL = 6; + + /** 待审核仲裁方式 */ + public static final int CHECK_ARBITRATION_METHOD = 7; + /** 待开庭审理 */ + public static final int PENDING_OPENCOURT_HEAR = 8; + /** 待书面审理 */ + public static final int PENDING_WRIITEN_HEAR = 9; + /** 待生成仲裁文书 */ + public static final int GENERATED_ARBITRATION = 10; + /**待核验仲裁文书*/ + public static final int VERPRIF_ARBITRATION = 11; + /**待审核仲裁文书*/ + public static final int CHECK_ARBITRATION = 12; + /**待仲裁文书签名*/ + public static final int SIGN_ARBITRATION = 13; + /** 待仲裁文书用印 */ + public static final int ARBITRATED_SEAL = 14; + /** 待仲裁文书送达 */ + public static final int ARBITRATION_DELIVERY = 15; + /** 待案件归档*/ + public static final int CASE_FILING = 16; + /** 已归档*/ + public static final int CASE_ARCHIVED = 17; + + + + + + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java new file mode 100644 index 0000000..ade398b --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignEncryption.java @@ -0,0 +1,371 @@ +/* + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ruoyi.common.constant; +import com.ruoyi.common.exception.EsignDemoException; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.message.BasicNameValuePair; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.Collator; +import java.text.MessageFormat; +import java.util.*; + +/** + * @description 请求数据通用处理类 + * @author 澄泓 + * @date 2020年10月22日 下午14:25:31 + * @since JDK1.7 + */ +public class EsignEncryption { + + /** + * 不允许外部创建实例 + */ + private EsignEncryption(){} + + /** + * 拼接待签名字符串 + * @param httpMethod + * @param url + * @return + */ + public static String appendSignDataString(String httpMethod, String contentMd5,String accept,String contentType,String headers,String date, String url) throws EsignDemoException { + StringBuffer sb = new StringBuffer(); + sb.append(httpMethod).append("\n").append(accept).append("\n").append(contentMd5).append("\n") + .append(contentType).append("\n"); + + if ("".equals(date) || date == null) { + sb.append("\n"); + } else { + sb.append(date).append("\n"); + } + if ("".equals(headers) || headers == null) { + sb.append(url); + } else { + sb.append(headers).append("\n").append(url); + } + return new String(sb); + } + + /*** + * Content-MD5的计算方法 + * @param str 待计算的消息 + * @return MD5计算后摘要值的Base64编码(ContentMD5) + * @throws EsignDemoException 加密过程中的异常信息 + */ + public static String doContentMD5(String str) throws EsignDemoException { + byte[] md5Bytes = null; + MessageDigest md5 = null; + String contentMD5 = null; + try { + md5 = MessageDigest.getInstance("MD5"); + // 计算md5函数 + md5.update(str.getBytes("UTF-8")); + // 获取文件MD5的二进制数组(128位) + md5Bytes = md5.digest(); + // 把MD5摘要后的二进制数组md5Bytes使用Base64进行编码(而不是对32位的16进制字符串进行编码) + contentMD5 = Base64.encodeBase64String(md5Bytes); + + } catch (NoSuchAlgorithmException e) { + EsignDemoException ex = new EsignDemoException("不支持此算法",e); + ex.initCause(e); + throw ex; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return contentMD5; + } + + /*** + * 计算请求签名值-HmacSHA256摘要 + * @param message 待签名字符串 + * @param secret 密钥APP KEY + * @return reqSignature HmacSHA256计算后摘要值的Base64编码 + * @throws EsignDemoException 加密过程中的异常信息 + */ + public static String doSignatureBase64(String message, String secret) throws EsignDemoException { + String algorithm = "HmacSHA256"; + Mac hmacSha256; + String digestBase64 = null; + try { + hmacSha256 = Mac.getInstance(algorithm); + byte[] keyBytes = secret.getBytes("UTF-8"); + byte[] messageBytes = message.getBytes("UTF-8"); + hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm)); + // 使用HmacSHA256对二进制数据消息Bytes计算摘要 + byte[] digestBytes = hmacSha256.doFinal(messageBytes); + // 把摘要后的结果digestBytes使用Base64进行编码 + digestBase64 = Base64.encodeBase64String(digestBytes); + } catch (NoSuchAlgorithmException e) { + EsignDemoException ex = new EsignDemoException("不支持此算法",e); + ex.initCause(e); + throw ex; + } catch (InvalidKeyException e) { + EsignDemoException ex = new EsignDemoException("无效的密钥规范",e); + ex.initCause(e); + throw ex; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return digestBase64; + } + + /** + * 获取时间戳 + * @return + */ + public static String timeStamp() { + long timeStamp = System.currentTimeMillis(); + return String.valueOf(timeStamp); + } + + /** + * byte字节数组转换成字符串 + * @param b + * @return + */ + public static String byteArrayToHexString(byte[] b) { + StringBuilder hs = new StringBuilder(); + String stmp; + for (int n = 0; b != null && n < b.length; n++) { + stmp = Integer.toHexString(b[n] & 0XFF); + if (stmp.length() == 1) + hs.append('0'); + hs.append(stmp); + } + return hs.toString().toLowerCase(); + } + + /** + * hash散列加密算法 + * @return + */ + public static String Hmac_SHA256(String message,String key) throws EsignDemoException { + byte[] rawHmac=null; + try { + SecretKeySpec sk = new SecretKeySpec(key.getBytes(), "HmacSHA256"); + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(sk); + rawHmac = mac.doFinal(message.getBytes()); + }catch (InvalidKeyException e){ + EsignDemoException ex = new EsignDemoException("无效的密钥规范",e); + ex.initCause(e); + throw ex; + } catch (NoSuchAlgorithmException e) { + EsignDemoException ex = new EsignDemoException("不支持此算法",e); + ex.initCause(e); + throw ex; + }catch (Exception e){ + EsignDemoException ex = new EsignDemoException("hash散列加密算法报错",e); + ex.initCause(e); + throw ex; + }finally { + return byteArrayToHexString(rawHmac); + } + + } + + /** + * MD5加密32位 + */ + public static String MD5Digest(String text) throws EsignDemoException { + byte[] digest=null; + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + md5.update(text.getBytes()); + digest = md5.digest(); + }catch (NoSuchAlgorithmException e){ + EsignDemoException ex = new EsignDemoException("不支持此算法",e); + ex.initCause(e); + throw ex; + }finally { + return byteArrayToHexString(digest); + } + + } + + public static void formDataSort(List param) { + Collections.sort(param, new Comparator() { + @Override + public int compare(BasicNameValuePair o1, BasicNameValuePair o2) { + Comparator 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 queryParamsMap = new HashMap(); + 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 queryMapKeys = new ArrayList(); + for (Map.Entry entry : queryParamsMap.entrySet()) { + queryMapKeys.add((String) entry.getKey()); + } + // 按照字段名的 ASCII 码从小到大排序(字典排序) + Collections.sort(queryMapKeys, new Comparator() { + @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 getQuery(String apiUrl) throws EsignDemoException { + ArrayList BasicNameValuePairList = new ArrayList<>(); + + if (!apiUrl.contains("?")) { + return BasicNameValuePairList; + } + + int queryIndex = apiUrl.indexOf("\\?"); + String apiUrlQuery = apiUrl.substring(queryIndex,apiUrl.length()); + + // 请求URL中Query参数转成Map + Map queryParamsMap = new HashMap(); + 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(); + } + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHeaderConstant.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHeaderConstant.java new file mode 100644 index 0000000..ae1e035 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHeaderConstant.java @@ -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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHttpCfgHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHttpCfgHelper.java new file mode 100644 index 0000000..78162ed --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/EsignHttpCfgHelper.java @@ -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 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) param)); + } + httpClient = getHttpClient(); + config(reqBase); + + //设置请求头 + if(headers != null &&headers.size()>0) { + for(Map.Entry 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 registry = RegistryBuilder.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---------------------------------------------- + + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java new file mode 100644 index 0000000..f63a3d9 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java @@ -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 map = new HashMap(); + 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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index 15bf66b..b121515 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -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 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 getParams() - { - if (params == null) - { + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; } - public void setParams(Map params) - { + public void setParams(Map params) { this.params = params; } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignCoreSdkInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignCoreSdkInfo.java new file mode 100644 index 0000000..d97603d --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignCoreSdkInfo.java @@ -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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignHttpResponse.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignHttpResponse.java new file mode 100644 index 0000000..26375c0 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/EsignHttpResponse.java @@ -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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/EsignRequestType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EsignRequestType.java new file mode 100644 index 0000000..8b87de6 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EsignRequestType.java @@ -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); +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java index be6f739..a0cf8e5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java @@ -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 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)); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/EsignDemoException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/EsignDemoException.java new file mode 100644 index 0000000..7be2957 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/EsignDemoException.java @@ -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; + } + + + + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java new file mode 100644 index 0000000..f796034 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java @@ -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 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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EsignHttpHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EsignHttpHelper.java new file mode 100644 index 0000000..ed255e5 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EsignHttpHelper.java @@ -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 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 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 buildSignAndJsonHeader(String projectId,String contentMD5,String accept,String contentType,String authMode) { + + Map 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 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 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 buildTokenAndJsonHeader(String appid,String token) { + Map 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 buildFormDataHeader(String appid) { + Map 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 buildUploadHeader(String fileContentMd5, String contentType) { + Map header = new HashMap<>(); + header.put("Content-MD5", fileContentMd5); + header.put("Content-Type", contentType); + + return header; + } + + // ------------------------------私有方法end---------------------------------------------- +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java new file mode 100644 index 0000000..f7d7e62 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java @@ -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; + + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java new file mode 100644 index 0000000..af78611 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java @@ -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 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 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 headerList, String headerBackgroundColor, String textColor, List> tableContentList) { + RowRenderData header = rebuildWordTableHead(headerList, headerBackgroundColor, textColor); + List 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 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 rebuildWordTableContent(List> tableContentList) { + List rowContentList = new ArrayList<>(); + for (int i = 0; tableContentList != null && i < tableContentList.size(); i++) { + List 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 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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/EsignFileBean.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/EsignFileBean.java new file mode 100644 index 0000000..5f46713 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/EsignFileBean.java @@ -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); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java new file mode 100644 index 0000000..6033c25 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java @@ -0,0 +1,83 @@ +package com.ruoyi.common.utils.file; + +import cn.hutool.json.JSONObject; +import com.ruoyi.common.config.EsignDemoConfig; +import com.ruoyi.common.constant.EsignHeaderConstant; +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 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 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 header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true); + //发起接口请求 + return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true); + } + +// public static void main(String[] args) throws EsignDemoException { + // String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\b442880179844a848f1f8b08c29e3d0c.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); +// EsignHttpResponse esignHttpResponse = uploadFile(fileUploadUrl, filePath); +// System.out.println("这是上传文件流的结果:"+esignHttpResponse.getBody()); +// EsignHttpResponse fileStatus = getFileStatus(fileId); +// System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody()); +// getFileStatus("a0c2ad21065f48ff8b872412c39d5d3a"); +// } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java index 1d4dc1f..46ab4b2 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java @@ -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"); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 2125853..7078344 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -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() diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 85d4f3c..435e8f1 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,7 +22,11 @@ com.ruoyi ruoyi-common - + + com.ruoyi + pay + 1.0.0-SNAPSHOT + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java new file mode 100644 index 0000000..6210f34 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java @@ -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; + + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/CredentialVO.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/CredentialVO.java new file mode 100644 index 0000000..c9fba91 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/CredentialVO.java @@ -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; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/PersonRegisterVO.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/PersonRegisterVO.java new file mode 100644 index 0000000..159bcd4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/PersonRegisterVO.java @@ -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; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/ArbitrSignatuService.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/ArbitrSignatuService.java new file mode 100644 index 0000000..d15b083 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/ArbitrSignatuService.java @@ -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); + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/SignRegisterService.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/SignRegisterService.java new file mode 100644 index 0000000..e72b247 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/SignRegisterService.java @@ -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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/ArbitrSignatuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/ArbitrSignatuServiceImpl.java new file mode 100644 index 0000000..998de51 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/ArbitrSignatuServiceImpl.java @@ -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); + + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/RegisterServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/RegisterServiceImpl.java new file mode 100644 index 0000000..3a731fa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/service/impl/RegisterServiceImpl.java @@ -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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java new file mode 100644 index 0000000..67594e6 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java @@ -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(); + } + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/HttpClientSender.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/HttpClientSender.java new file mode 100644 index 0000000..3a1af73 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/HttpClientSender.java @@ -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 httpClients = new HashMap(); + + 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 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 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 request(String method, String url, Object sendData, Map 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 response = null; + if ("POST".equals(method)) { + response = sendPost(httpClient, url, headers, sendData); + } else { + response = sendGet(httpClient, url, headers); + } + return response; + } + + private static Map sendPost(CloseableHttpClient httpClient, String url, Map 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 response = new HashMap(); + response.put("responseCode", responseCode); + response.put("responseData", responseBytes); + String loggerResponseString = getLoggerString(responseBytes, 256); + return response; + } + + private static Map sendGet(CloseableHttpClient httpClient, String url, Map 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 response = new HashMap(); + 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 socketFactoryRegistry = RegistryBuilder.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; + } + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/RSAUtils.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/RSAUtils.java new file mode 100644 index 0000000..957e1fb --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/RSAUtils.java @@ -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 mySignedURLParams = new TreeMap(); + 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); + } + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Adjudication.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Adjudication.java new file mode 100644 index 0000000..75eb96e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Adjudication.java @@ -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; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ArbitrateRecord.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ArbitrateRecord.java new file mode 100644 index 0000000..967f9b4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ArbitrateRecord.java @@ -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; + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Arbitrator.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Arbitrator.java new file mode 100644 index 0000000..4e73c8d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/Arbitrator.java @@ -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 idList; + + public List getIdList() { + return idList; + } + + public void setIdList(List 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; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java new file mode 100644 index 0000000..e7721e9 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java @@ -0,0 +1,171 @@ +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; + /** 身份证号 */ + @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 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; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java new file mode 100644 index 0000000..ac77efe --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java @@ -0,0 +1,732 @@ +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; + + /** 是否同意组庭 */ + private Integer isAgreePendTral; + + /** 是否有异议需要举证 */ + private Integer objectionAddEviden; + /** 是否需要开庭审理 */ + private Integer openCourtHear; + + /** 支付状态 */ + private Integer paymentStatus; + /** 支付状态描述 */ + private String paymentStatusName; + // 导入校验失败信息 + private StringBuilder errorMsg; + + 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; + + 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 caseAffiliates; + + /** 案件仲裁员 */ + private List arbitrators; + + private List caseStatusList; + + private List annexTypeList; + + private Integer annexType; + + public Integer getAnnexType() { + return annexType; + } + + public void setAnnexType(Integer annexType) { + this.annexType = annexType; + } + + public List getAnnexTypeList() { + return annexTypeList; + } + + public void setAnnexTypeList(List annexTypeList) { + this.annexTypeList = annexTypeList; + } + + /** + * 案件附件列表 + */ + private List caseAttachList; + + public List getCaseAttachList() { + return caseAttachList; + } + + public void setCaseAttachList(List caseAttachList) { + this.caseAttachList = caseAttachList; + } + + public List getCaseStatusList() { + return caseStatusList; + } + + public void setCaseStatusList(List caseStatusList) { + this.caseStatusList = caseStatusList; + } + + /** 仲裁记录 */ + private ArbitrateRecord arbitrateRecord; + + public ArbitrateRecord getArbitrateRecord() { + return arbitrateRecord; + } + + public void setArbitrateRecord(ArbitrateRecord arbitrateRecord) { + this.arbitrateRecord = arbitrateRecord; + } + + public List getArbitrators() { + return arbitrators; + } + + public void setArbitrators(List 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 getCaseAffiliates() { + return caseAffiliates; + } + + public void setCaseAffiliates(List caseAffiliates) { + this.caseAffiliates = caseAffiliates; + } + + + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAttach.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAttach.java new file mode 100644 index 0000000..9827fc7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAttach.java @@ -0,0 +1,46 @@ +package com.ruoyi.wisdomarbitrate.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CaseAttach { + /** + * 附件id + */ + private Integer annexId; + /** + * 案件申请id + */ + private Long caseAppliId; + /** + * 附件名称 + */ + private String annexName; + /** + * 附件路径 + */ + private String annexPath; + /** + * 附件类型,立案申请书(1)、证据材料(2)、仲裁文书(3)、案件视频(4)、身份证件(5) + */ + private Integer annexType; + /** + * 备注 + */ + private String note; + /** + * 用户id + */ + private Long userId; + /** + * 用户账户 + */ + private String userName; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseLogRecord.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseLogRecord.java new file mode 100644 index 0000000..7a2c680 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseLogRecord.java @@ -0,0 +1,105 @@ +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.util.Date; + +public class CaseLogRecord extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** ID */ + private Long id; + /** 案件申请id */ + private Long caseAppliId; + /** 案件节点 */ + private Integer caseNode; + + /** 案件节点时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date caseNodeTime; + + /** 备注 */ + private String notes; + + /** 案件编号 */ + private String caseNum; + /** + * 展示的内容 + */ + private String content; + /** + * 用户昵称 + */ + private String createNickName; + + + public String getCaseNum() { + return caseNum; + } + + public void setCaseNum(String caseNum) { + this.caseNum = caseNum; + } + + 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 Integer getCaseNode() { + return caseNode; + } + + public void setCaseNode(int caseNode) { + this.caseNode = caseNode; + } + + public Date getCaseNodeTime() { + return caseNodeTime; + } + + public void setCaseNodeTime(Date caseNodeTime) { + this.caseNodeTime = caseNodeTime; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public void setCaseNode(Integer caseNode) { + this.caseNode = caseNode; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getCreateNickName() { + return createNickName; + } + + public void setCreateNickName(String nickName) { + this.createNickName = nickName; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CasePaymentRecord.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CasePaymentRecord.java new file mode 100644 index 0000000..4bae1db --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CasePaymentRecord.java @@ -0,0 +1,41 @@ +package com.ruoyi.wisdomarbitrate.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +import java.util.Date; + +@Data +public class CasePaymentRecord { + private static final long serialVersionUID = 1L; + /** + * 主键 + */ + private Integer id; + /** + * 案件id + */ + private Long caseId; + /** + * 订单号 + */ + private String orderNumber; + /** + * 支付状态(0未支付,1已支付) + */ + private Integer paymentStatus; + /** + * 支付时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date paymentTime; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/IdentityAuthentication.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/IdentityAuthentication.java new file mode 100644 index 0000000..ce47855 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/IdentityAuthentication.java @@ -0,0 +1,129 @@ +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.util.Date; + +public class IdentityAuthentication extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** ID */ + private Long id; + /** 姓名 */ + private String name; + /** 身份证号 */ + private String identityNo; + /** 认证时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date certificationTime; + /** 认证状态 */ + private Integer certificationStatus; + + public Integer getCertificationStatus() { + return certificationStatus; + } + + public void setCertificationStatus(Integer certificationStatus) { + this.certificationStatus = certificationStatus; + } + + /** 认证状态名称 */ + private String certificationStatusName; + + public String getCertificationStatusName() { + return certificationStatusName; + } + + public void setCertificationStatusName(String certificationStatusName) { + this.certificationStatusName = certificationStatusName; + } + + /** 用户ID */ + private Long userId; + /** 用户账号 */ + private String userName; + + /** EID商户id */ + private String merchantId; + + /** EidToken */ + private String eidToken; + /** 请求 ID */ + private String requestId; + + public String getMerchantId() { + return merchantId; + } + + public void setMerchantId(String merchantId) { + this.merchantId = merchantId; + } + + public String getEidToken() { + return eidToken; + } + + public void setEidToken(String eidToken) { + this.eidToken = eidToken; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIdentityNo() { + return identityNo; + } + + public void setIdentityNo(String identityNo) { + this.identityNo = identityNo; + } + + public Date getCertificationTime() { + return certificationTime; + } + + public void setCertificationTime(Date certificationTime) { + this.certificationTime = certificationTime; + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CaseEvidenceDTO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CaseEvidenceDTO.java new file mode 100644 index 0000000..142b68f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CaseEvidenceDTO.java @@ -0,0 +1,37 @@ +package com.ruoyi.wisdomarbitrate.domain.dto; + +import com.ruoyi.wisdomarbitrate.domain.Arbitrator; +import lombok.Data; + +import java.util.List; + +/** + * 案件质证传入对象 + */ +@Data +public class CaseEvidenceDTO { + /** + * 案件id + */ + private Long caseId; + + /** + * 是否有异议需要举证,1是,0否 + */ + private Integer objectionAddEviden; + + /** + * 是否需要开庭审理,1是,0否 + */ + private Integer openCourtHear; + + /** + * 是否指派仲裁员,1是,2否 + */ + private Integer pendingAppointArbotrar; + + /** + * 案件仲裁员 + */ + private List arbitrators; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java new file mode 100644 index 0000000..b440235 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java @@ -0,0 +1,26 @@ +package com.ruoyi.wisdomarbitrate.domain.dto; + +import lombok.Data; +/** + * 案件缴费传入对象 + */ +@Data +public class CasePayDTO { + /** + * 案件id + */ + private Long caseId; + + /** + * 订单金额 单位:分 + */ + private int totalFee; + /** + * 交易类型 native(扫码) / jsapi(小程序) / app / h5 + */ + private String tradeType; + /** + * 支付方式 wxpay(微信) alipay(支付宝) + */ + private String platform; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ArchivesDetailVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ArchivesDetailVO.java new file mode 100644 index 0000000..dfe4abc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ArchivesDetailVO.java @@ -0,0 +1,24 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; +import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper; +import lombok.Data; + +import java.util.List; + +@Data +public class ArchivesDetailVO { + /** + * 案件信息 + */ + private CaseApplication caseApplication; + /** + * 案件日志信息 + */ + private List caseLogRecordList; + /** + * 快递信息 + */ + private List logisticsInfoVOList; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/BookSendVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/BookSendVO.java new file mode 100644 index 0000000..790e705 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/BookSendVO.java @@ -0,0 +1,26 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BookSendVO { + /** + * 案件id + * 申请人邮箱 + * 被申请人邮箱 + * 申请人快递编号 + * 被申请人快递编号 + */ + private Long id; + private String appEmail; + private String resEmail; + private String apptrackingNum; + private String restrackingNum; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseDetailVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseDetailVO.java new file mode 100644 index 0000000..b67c73f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseDetailVO.java @@ -0,0 +1,67 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + +import com.ruoyi.wisdomarbitrate.domain.CaseAttach; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CaseDetailVO { + /** + * ID + */ + private Long id; + /** + * 案件编号 + */ + private String caseNum; + /** + * 申请人姓名 + */ + private String applicantName; + /** + * 被申请人姓名 + */ + private String respondentName; + /** + * 借款开始日期 + */ + private Date loanStartDate; + /** + * 借款结束日期 + */ + private Date loanEndDate; + /** + * 案件标的 + */ + private BigDecimal caseSubjectAmount; + /** + * 申请人主张欠本金 + */ + private BigDecimal claimPrinciOwed; + /** + * 申请人主张欠利息 + */ + private BigDecimal claimInterestOwed; + /** + * 申请人主张违约金 + */ + private BigDecimal claimLiquidDamag; + + /** + * 证据材料 + */ + private List evidenceMaterialList; + /** + * 当前登录人身份类型 + */ + private Integer identityType; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseEvidenceVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseEvidenceVO.java new file mode 100644 index 0000000..7dca799 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CaseEvidenceVO.java @@ -0,0 +1,28 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + + +import lombok.Data; + +@Data +public class CaseEvidenceVO { + /** + * 案件id + */ + private Long id; + /** + * 案件编号 + */ + private String caseNum; + /** + * 申请人姓名 + */ + private String applicantName; + /** + * 被申请人姓名 + */ + private String respondentName; + /** + * 案件状态 + */ + private Integer caseStatus; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/LogisticsInfoVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/LogisticsInfoVO.java new file mode 100644 index 0000000..480a96a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/LogisticsInfoVO.java @@ -0,0 +1,16 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + +import lombok.Data; + +@Data +public class LogisticsInfoVO { + /** + * 案件关联人身份类型 + */ + private Integer identityType; + + /** + * 物流信息 + */ + private String logisticsInfo; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SendRoomNoMessageVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SendRoomNoMessageVO.java new file mode 100644 index 0000000..0ba7248 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SendRoomNoMessageVO.java @@ -0,0 +1,24 @@ +package com.ruoyi.wisdomarbitrate.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author wangqiong + * @description 发送房间号短信入参类 + * @date 2023-10-10 15:20 + */ +@Data +public class SendRoomNoMessageVO implements Serializable { + private static final long serialVersionUID = 1L; + @NotNull(message = "案件id不能为空") + private Long id; + @NotEmpty(message = "房间号不能为空") + private String roomNo; + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitrateRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitrateRecordMapper.java new file mode 100644 index 0000000..c4aaa18 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitrateRecordMapper.java @@ -0,0 +1,17 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord; +import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; + +import java.util.List; + +public interface ArbitrateRecordMapper { + int insertArbitrateRecord(ArbitrateRecord arbitrateRecord); + + int updataArbitrateRecord(ArbitrateRecord arbitrateRecord); + + ArbitrateRecord selectArbitrateRecord(ArbitrateRecord arbitrateRecord); + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitratorMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitratorMapper.java new file mode 100644 index 0000000..04bda03 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ArbitratorMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.Arbitrator; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ArbitratorMapper { + List selectArbitratorList(Arbitrator arbitrator); + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAffiliateMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAffiliateMapper.java new file mode 100644 index 0000000..9c0ce9d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAffiliateMapper.java @@ -0,0 +1,22 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface CaseAffiliateMapper { + + + int batchCaseAffiliate(List caseAffiliates); + + + void deletecaseAffiliate(CaseApplication caseApplication); + + + List selectCaseAffiliate(CaseAffiliate caseAffiliate); + CaseAffiliate selectCaseAffiliateByIdentityType(@Param("caseAppliId") Long caseAppliId, @Param("identityType")int identityType); + + int updataCaseAffiliate(CaseAffiliate caseAffiliate); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java new file mode 100644 index 0000000..7e9e4e1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java @@ -0,0 +1,34 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface CaseApplicationMapper { + List selectCaseApplicationList(CaseApplication caseApplication); + + int selectCaseApplicationCount(CaseApplication caseApplication); + + int insertCaseApplication(CaseApplication caseApplication); + + + int updataCaseApplication(CaseApplication caseApplication); + + int submitCaseApplication(CaseApplication caseApplication); + + int deletecaseApplication(CaseApplication caseApplication); + + CaseApplication selectCaseApplication(CaseApplication caseApplication); + + CaseApplication selectCaseApplicationConfirm(CaseApplication caseApplication); + + /** + * 查询最大编号 + * @param caseNum + * @param length + * @return + */ + Integer selectCaseNumLike(@Param("caseNum") String caseNum, @Param("length") int length); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachMapper.java new file mode 100644 index 0000000..0be609e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachMapper.java @@ -0,0 +1,17 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseAttach; + +import java.util.List; + +public interface CaseAttachMapper { + int save(CaseAttach caseAttach); + + List queryAnnexPathByCaseId(Long id); + + List queryCaseAttachList(CaseApplication caseApplication); + + + int updateCaseAttach(CaseAttach caseAttach); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseEvidenceMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseEvidenceMapper.java new file mode 100644 index 0000000..12a0459 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseEvidenceMapper.java @@ -0,0 +1,15 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.vo.CaseEvidenceVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface CaseEvidenceMapper { + List getCaseListByRespondent(@Param(value = "identityNum" ) String identityNum + , @Param(value = "caseStatusList") List caseStatusList + , @Param(value = "identityType" ) Integer identityType); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseLogRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseLogRecordMapper.java new file mode 100644 index 0000000..9dd368e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseLogRecordMapper.java @@ -0,0 +1,14 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; + +import java.util.List; + +public interface CaseLogRecordMapper { + + + List selectCaseLogRecordList(CaseLogRecord caseLogRecord); + + int insertCaseLogRecord(CaseLogRecord caseLogRecord); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CasePaymentRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CasePaymentRecordMapper.java new file mode 100644 index 0000000..596abf5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CasePaymentRecordMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord; + +public interface CasePaymentRecordMapper { + int saveRecord(CasePaymentRecord casePaymentRecord); + + CasePaymentRecord queryRecord(String orderNumber); + + void update(CasePaymentRecord casePaymentRecord); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/IdentityAuthenticationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/IdentityAuthenticationMapper.java new file mode 100644 index 0000000..4800038 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/IdentityAuthenticationMapper.java @@ -0,0 +1,13 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord; +import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication; + +public interface IdentityAuthenticationMapper { + int insertIdentityAuthentication(IdentityAuthentication identityAuthentication); + IdentityAuthentication selectIdentityAuthentication(IdentityAuthentication identityAuthentication); + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IAdjudicationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IAdjudicationService.java new file mode 100644 index 0000000..6d7f6a1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IAdjudicationService.java @@ -0,0 +1,25 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO; + +import java.util.List; + +public interface IAdjudicationService { + AjaxResult createDocument(CaseApplication caseApplication); + + AjaxResult sendDocumentByEmail(Long id,String appEmail,String resEmail ,String apptrackingNum,String restrackingNum); + + List getLogisticsInfo(CaseApplication caseApplication); + + AjaxResult signature(CaseApplication caseApplication); + + AjaxResult caseFile(CaseApplication caseApplication); + + AjaxResult service(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum); + + AjaxResult stamp(CaseApplication caseApplication); + + AjaxResult getArchivesDetail(Long id); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IArbitratorService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IArbitratorService.java new file mode 100644 index 0000000..ee7a8ab --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IArbitratorService.java @@ -0,0 +1,12 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.wisdomarbitrate.domain.Arbitrator; + +import java.util.List; + +public interface IArbitratorService { + List selectArbitratorList(Arbitrator arbitrator); + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java new file mode 100644 index 0000000..2bcd9a5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java @@ -0,0 +1,43 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO; + +import java.util.List; + +public interface ICaseApplicationService { + List selectCaseApplicationList(CaseApplication caseApplication); + + + int insertcaseApplication(CaseApplication caseApplication); + + int selectCaseApplicationCount(CaseApplication caseApplication); + + int editCaseApplication(CaseApplication caseApplication); + + int submitCaseApplication(CaseApplication caseApplication); + + int deletecaseApplicationByIds(CaseApplication caseApplication); + + CaseApplication selectCaseApplication(CaseApplication caseApplication); + + String importCaseApplication(List caseApplicationList, String operName); + + int pendTral(CaseApplication caseApplication); + + int pendingAppointArbotrar(CaseApplication caseApplication); + + int pendTralCheck(CaseApplication caseApplication); + + int pendTralSure(CaseApplication caseApplication); + + int verificationArbitrateRecord(CaseApplication caseApplication); + + int checkArbitrateRecord(CaseApplication caseApplication); + + int submitCaseApplicationCheck(CaseApplication caseApplication); + + CaseApplication selectCaseApplicationConfirm(CaseApplication caseApplication); + + String sendRoomNoMessage(SendRoomNoMessageVO messageVO); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseArbitrateService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseArbitrateService.java new file mode 100644 index 0000000..0e66a10 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseArbitrateService.java @@ -0,0 +1,13 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; + +public interface ICaseArbitrateService { + + + AjaxResult writtenHear(ArbitrateRecord arbitrateRecord); + + AjaxResult examineArbitrateMethod(CaseApplication caseApplication, Integer opinion); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseEvidenceService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseEvidenceService.java new file mode 100644 index 0000000..e601832 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseEvidenceService.java @@ -0,0 +1,23 @@ +package com.ruoyi.wisdomarbitrate.service; + + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.dto.CaseEvidenceDTO; +import com.ruoyi.wisdomarbitrate.domain.vo.CaseEvidenceVO; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +public interface ICaseEvidenceService { + + AjaxResult getCaseDetailsById(Long id,String userName); + + AjaxResult uploadEvidence(MultipartFile file, Integer annexType, Long id,String userName,Long userId); + + List getCaseListAll(String identityNum); + + AjaxResult evidenceConfirmation(CaseApplication caseApplication); + + AjaxResult caseCrossexamination(CaseEvidenceDTO caseEvidenceDTO); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseLogRecordService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseLogRecordService.java new file mode 100644 index 0000000..f4fcf77 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseLogRecordService.java @@ -0,0 +1,17 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; + +import java.util.List; + +public interface ICaseLogRecordService { + + + List selectCaseLogRecordList(CaseLogRecord caseLogRecord); + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java new file mode 100644 index 0000000..fc2e24a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java @@ -0,0 +1,15 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.dto.PayRequest; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; + +public interface ICasePaymentService { + /** + * 案件缴费 + */ + AjaxResult casePay(CasePayDTO casePayDTO); + + AjaxResult confirmPayment(CaseApplication caseApplication); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IdentityAuthenticationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IdentityAuthenticationService.java new file mode 100644 index 0000000..1ae0f29 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IdentityAuthenticationService.java @@ -0,0 +1,34 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication; + +public interface IdentityAuthenticationService { + + + IdentityAuthentication selectIdentityAuthentication(IdentityAuthentication identityAuthentication); + + /** + * 检查是否已经认证的用户 + * + * @param identityAuthentication + * @return + */ + String checkIsAuthentication(IdentityAuthentication identityAuthentication); + + /** + * 获取Eidtoken + * + * @return + */ + JSONObject selectIdentityAuthenticaEIDtoken(); + + /** + * 小程序人脸核身后查询身份认证结果 + * + * @param ientityAuthentication + * @return + */ + AjaxResult selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java new file mode 100644 index 0000000..1302bb7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java @@ -0,0 +1,419 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.common.utils.EmailOutUtil; +import com.ruoyi.common.utils.WordUtil; +import com.ruoyi.wisdomarbitrate.domain.*; +import com.ruoyi.wisdomarbitrate.domain.vo.ArchivesDetailVO; +import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO; +import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper; +import com.ruoyi.wisdomarbitrate.service.IAdjudicationService; +import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService; +import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mail.MailSendException; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.*; + +@Service +@Slf4j +public class AdjudicationServiceImpl implements IAdjudicationService { + private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index"; + + @Autowired + private CaseApplicationMapper caseApplicationMapper; + @Autowired + private CaseAffiliateMapper caseAffiliateMapper; + @Autowired + private ArbitrateRecordMapper arbitrateRecordMapper; + @Autowired + private CaseAttachMapper caseAttachMapper; + @Autowired + private EmailOutUtil emailOutUtil; + @Autowired + private ICaseApplicationService caseApplicationService; + @Autowired + private ICaseLogRecordService caseLogRecordService; + + @Override + public AjaxResult createDocument(CaseApplication caseApplication) { + try { + Map datas = new HashMap<>(); + Long id = caseApplication.getId(); + if (id == null) { + return null; + } + //获取案件详细信息 + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + //获取仲裁记录表里的相关信息 + ArbitrateRecord arbitrateRecord = new ArbitrateRecord(); + arbitrateRecord.setCaseAppliId(id); + ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord); + + //获取案件关联人信息 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(id); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + //获取身份类型 + int identityType = affiliate.getIdentityType(); + if (identityType == 1) { //申请人 + datas.put("appName", affiliate.getName()); + datas.put("appIDNo", affiliate.getIdentityNum()); + datas.put("appAddress", affiliate.getContactAddress()); + datas.put("appAgentName", affiliate.getNameAgent()); + datas.put("appAgentIDNo", affiliate.getIdentityNumAgent()); + } else if (identityType == 2) { //被申请人 + datas.put("resName", affiliate.getName()); + datas.put("resIDNo", affiliate.getIdentityNum()); + datas.put("resAddress", affiliate.getContactAddress()); + datas.put("resAgentName", affiliate.getNameAgent()); + datas.put("resAgentIDNo", affiliate.getIdentityNumAgent()); + } + } + } + String arbitratorName = caseApplication1.getArbitratorName(); + datas.put("caseName", caseApplication1.getCaseName()); + datas.put("arbitratorName", arbitratorName); + Date hearDate = caseApplication1.getHearDate(); + if (hearDate != null) { + LocalDate localDate = hearDate.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + datas.put("hearYear", localDate.getYear()); + datas.put("hearMonths", localDate.getMonthValue()); + datas.put("hearDay", localDate.getDayOfMonth()); + } else { + datas.put("hearYear", null); + datas.put("hearMonths", null); + datas.put("hearDay", null); + } + datas.put("appArbitrationClaims", caseApplication1.getArbitratClaims()); + if (arbitrateRecord1 != null) { + datas.put("evidenDetermi", arbitrateRecord1.getEvidenDetermi()); + datas.put("factDetermi", arbitrateRecord1.getFactDetermi()); + datas.put("caseSketch", arbitrateRecord1.getCaseSketch()); + datas.put("arbitrateThink", arbitrateRecord1.getArbitrateThink()); + datas.put("rulingFollows", arbitrateRecord1.getRulingFollows()); + } + datas.put("legalProvisions", "仲裁法"); + if (arbitratorName == null) { + datas.put("arbitratorName1", null); + datas.put("arbitratorName2", null); + } else if (arbitratorName.contains(",")) { + String[] nameArray = arbitratorName.split(","); + String firstName = nameArray[0]; + String secondName = nameArray[1]; + datas.put("arbitratorName1", firstName); + datas.put("arbitratorName2", secondName); + } else { + String secondName = ""; + datas.put("arbitratorName1", arbitratorName); + datas.put("arbitratorName2", secondName); + } + LocalDate now = LocalDate.now(); + String year = Integer.toString(now.getYear()); + String month = String.format("%02d", now.getMonthValue()); + String day = String.format("%02d", now.getDayOfMonth()); + datas.put("year", year); + datas.put("months", month); + datas.put("day", day); + String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx"; + //String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx"; + String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; + //String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth(); + String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx"; + String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + String resultFilePath = saveFolderPath + "/" + fileName; + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } + Path sourcePath = new File(modalFilePath).toPath(); + Path destinationPath = new File(resultFilePath).toPath(); + Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING); + String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath); + String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8); + //修改案件状态 + caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION); + caseApplicationMapper.submitCaseApplication(caseApplication1); + //将裁决书保存到附件表里 + CaseAttach caseAttach = CaseAttach.builder() + .caseAppliId(id) + .annexName(saveName) + .annexPath(savePath) + .annexType(3) + .build(); + int i = caseAttachMapper.save(caseAttach); + if (i > 0) { + if (arbitrateRecord1 != null) { + Integer annexId = caseAttach.getAnnexId(); + //将附件id保存到仲裁记录表里面 + arbitrateRecord1.setAnnexId(annexId); + arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1); + } + } + return AjaxResult.success("裁决书已生成"); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + @Override + @Transactional + public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) { + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(id); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 == null) { + return AjaxResult.error("未查询到相关案件"); + } + + //根据案件id查询裁决书 + try { + List fileList = new ArrayList<>(); + CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication); + List caseAttachList = caseApplication2.getCaseAttachList(); + if (caseAttachList != null && caseAttachList.size() > 0) { + for (CaseAttach caseAttach : caseAttachList) { + if (caseAttach.getAnnexType() == 3) { + String annexPath = caseAttach.getAnnexPath(); + //File file = new File("/home/ruoyi/" + annexPath); + String path = "/home/ruoyi/" + annexPath; + File file = new File(path); + System.out.println("文件是:" + file); + fileList.add(file); + } + } + } + if (fileList.size() < 1) { + return AjaxResult.error("未查询到裁决书"); + } + File file = fileList.get(0); + //电子邮件送达 + JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender(); + if (appEmail != null) { + emailOutUtil.sendMessageCarryFile(appEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", file + , "hjbjava@163.com", javaMailSender); + } + if (resEmail != null) { + emailOutUtil.sendMessageCarryFile(resEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", file + , "hjbjava@163.com", javaMailSender); + } + //修改案件状态 + caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING); + caseApplicationMapper.submitCaseApplication(caseApplication1); + //保存邮箱信息和快递单号到关联人表 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(id); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + if (affiliate.getIdentityType() == 1) { //申请人 + affiliate.setSendEmail(appEmail); + affiliate.setTrackNum(apptrackingNum); + caseAffiliateMapper.updataCaseAffiliate(affiliate); + } else { + affiliate.setSendEmail(resEmail); + affiliate.setTrackNum(restrackingNum); + caseAffiliateMapper.updataCaseAffiliate(affiliate); + } + } + } + return AjaxResult.success("仲裁文书送达成功"); + } catch (MailSendException e) { + return AjaxResult.error("发送失败,请检查文件路径"); + } + } + + @Override + public List getLogisticsInfo(CaseApplication caseApplication) { + try { + //快递单号查询 + String key = "729437f92468910aee6c12dbfeaee3c1"; + String com = "auto"; + //根据案件id查询单号信息 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication.getId()); + List logisticsInfoVOList = new ArrayList<>(); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + LogisticsInfoVO logisticsInfoVO = new LogisticsInfoVO(); + String trackNum = affiliate.getTrackNum(); + if (trackNum != null) { + // 构造查询字符串参数 + String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d", + URLEncoder.encode(key, "UTF-8"), + URLEncoder.encode(com, "UTF-8"), + URLEncoder.encode(trackNum, "UTF-8"), null); + // 拼接到API URL中 + String fullUrl = apiUrl + "?" + queryParameters; + URL url = new URL(fullUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + int responseCode = connection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder response = new StringBuilder(); + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + // 处理返回的响应数据\ + JSONObject jsonObject = JSON.parseObject(response.toString()); + // 提取 "data" 字段并转换为字符串 + String data = jsonObject.getString("data"); + if (data != null) { + logisticsInfoVO.setIdentityType(affiliate.getIdentityType()); + logisticsInfoVO.setLogisticsInfo(data); + logisticsInfoVOList.add(logisticsInfoVO); + } + } else { + // 请求失败 + return null; + } + } + } + return logisticsInfoVOList; + } + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + @Override + public AjaxResult signature(CaseApplication caseApplication) { + //更改案件状态(暂时) + caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL); + caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.ARBITRATED_SEAL,""); + + return AjaxResult.success("签名成功,案件状态已改为待仲裁文书用印"); + } + + @Override + public AjaxResult caseFile(CaseApplication caseApplication) { + //更改案件状态(暂时) + caseApplication.setCaseStatus(CaseApplicationConstants.CASE_ARCHIVED); + caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CASE_ARCHIVED,""); + + return AjaxResult.success("归档成功,案件状态已改为已归档"); + } + + @Override + public AjaxResult service(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) { + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(id); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 == null) { + return AjaxResult.error("未查询到相关案件"); + } + //修改案件状态 + caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING); + caseApplicationMapper.submitCaseApplication(caseApplication1); + //保存邮箱信息和快递单号到关联人表 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(id); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + if (affiliate.getIdentityType() == 1) { //申请人 + affiliate.setSendEmail(appEmail); + affiliate.setTrackNum(apptrackingNum); + caseAffiliateMapper.updataCaseAffiliate(affiliate); + } else { + affiliate.setSendEmail(resEmail); + affiliate.setTrackNum(restrackingNum); + caseAffiliateMapper.updataCaseAffiliate(affiliate); + } + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CASE_FILING,""); + + return AjaxResult.success("仲裁文书送达成功"); + } + + @Override + public AjaxResult stamp(CaseApplication caseApplication) { + //更改案件状态(暂时) + caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY); + caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.ARBITRATION_DELIVERY,""); + + return AjaxResult.success("用印成功,案件状态已改为待仲裁文书送达"); + } + + @Override + public AjaxResult getArchivesDetail(Long id) { + ArchivesDetailVO archivesDetailVO = new ArchivesDetailVO(); + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(id); + //查询案件信息 + CaseApplication caseApplication1 = caseApplicationService.selectCaseApplication(caseApplication); + if (caseApplication1 != null) { + archivesDetailVO.setCaseApplication(caseApplication1); + } + //查询案件日志信息 + CaseLogRecord caseLogRecord = new CaseLogRecord(); + caseLogRecord.setCaseAppliId(id); + List caseLogRecords = caseLogRecordService.selectCaseLogRecordList(caseLogRecord); + if (caseLogRecords != null && caseLogRecords.size() > 0) { + archivesDetailVO.setCaseLogRecordList(caseLogRecords); + } + //查询快递信息 + List logisticsInfo = this.getLogisticsInfo(caseApplication); + if (logisticsInfo != null && logisticsInfo.size() > 0) { + archivesDetailVO.setLogisticsInfoVOList(logisticsInfo); + } + return AjaxResult.success(archivesDetailVO); + } + + /*public static void main(String[] args) { + try { + List fileList = new ArrayList<>(); + fileList.add(new File("D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\b442880179844a848f1f8b08c29e3d0c.docx")); + File file = fileList.get(0); + //电子邮件送达 + EmailOutUtil emailOutUtil = new EmailOutUtil(); + JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender(); + if (javaMailSender != null) { + emailOutUtil.sendMessageCarryFile("1154956315@qq.com", "案件裁决书", "您的裁决书已送达,详情请查阅附件", file + , "hjbjava@163.com", javaMailSender); + } + } catch (MailSendException e) { + e.printStackTrace(); + } + }*/ + +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/ArbitratorServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/ArbitratorServiceImpl.java new file mode 100644 index 0000000..78f9e4b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/ArbitratorServiceImpl.java @@ -0,0 +1,28 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.ruoyi.wisdomarbitrate.domain.Arbitrator; +import com.ruoyi.wisdomarbitrate.mapper.ArbitratorMapper; +import com.ruoyi.wisdomarbitrate.service.IArbitratorService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class ArbitratorServiceImpl implements IArbitratorService { + @Autowired + private ArbitratorMapper arbitratorMapper; + + + @Override + public List selectArbitratorList(Arbitrator arbitrator) { + return arbitratorMapper.selectArbitratorList(arbitrator); + + } + + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CallBackHandleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CallBackHandleServiceImpl.java new file mode 100644 index 0000000..dfa8aca --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CallBackHandleServiceImpl.java @@ -0,0 +1,36 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.ruoyi.CallBackService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 业务回调处理 + */ +@Component +@Slf4j +public class CallBackHandleServiceImpl implements CallBackService { + @Autowired + private CasePaymentServiceImpl casePaymentService; + + @Override + public void successPay(String orderSn) { + casePaymentService.callback(orderSn); + } + + @Override + public void failPay(String orderSn) { + log.info("支付失败回调!"+orderSn); + } + + @Override + public void successRefund(String orderSn) { + log.info("退款成功回调!"+orderSn); + } + + @Override + public void failRefund(String orderSn) { + log.info("退款失败回调!"+orderSn); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java new file mode 100644 index 0000000..6e14b34 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java @@ -0,0 +1,987 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SmsUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.wisdomarbitrate.domain.*; +import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO; +import com.ruoyi.wisdomarbitrate.mapper.*; +import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.ruoyi.common.utils.SecurityUtils.getUsername; + + +@Service +public class CaseApplicationServiceImpl implements ICaseApplicationService { + @Autowired + private CaseApplicationMapper caseApplicationMapper; + + @Autowired + private CaseAffiliateMapper caseAffiliateMapper; + + @Autowired + private ArbitratorMapper arbitratorMapper; + @Autowired + private ArbitrateRecordMapper arbitrateRecordMapper; + + @Autowired + private CaseAttachMapper caseAttachMapper; + @Autowired + private SysDeptMapper sysDeptMapper; + // 手机号正则 + private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$"); + + + + @Override + public List selectCaseApplicationList(CaseApplication caseApplication) { + return caseApplicationMapper.selectCaseApplicationList(caseApplication); + + } + + @Override + @Transactional + public int insertcaseApplication(CaseApplication caseApplication) { + // 新增立案信息 + caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION); + //根据仲裁费用计费规则计算应缴费用 + //暂时设置计费比率为0.01 + BigDecimal feeRate = new BigDecimal(0.01); + BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, BigDecimal.ROUND_HALF_UP); + caseApplication.setFeePayable(feePayable); + // 获取自动编码 + String caseNum = generateCaseNum(); + caseApplication.setCaseNum(caseNum); + + int rows = caseApplicationMapper.insertCaseApplication(caseApplication); + List caseAffiliates = caseApplication.getCaseAffiliates(); + Map deptMap =new HashMap<>(); + if (caseAffiliates != null && caseAffiliates.size() > 0) { + // 查询所有的组织机构,组装成map + List deptList = sysDeptMapper.selectDeptList(new SysDept()); + if (CollectionUtil.isEmpty(deptList)) { + deptList = new ArrayList<>(); + } + deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId,(oldV,newV)->newV)); + + for (CaseAffiliate caseAffiliate : caseAffiliates) { + caseAffiliate.setCaseAppliId(caseApplication.getId()); + if(caseAffiliate.getIdentityType()==1&&StrUtil.isNotEmpty(caseAffiliate.getName())) { + // 将组织机构id设为申请人名称 + if (deptMap.containsKey(caseApplication.getName())) { + caseAffiliate.setName(String.valueOf(deptMap.get(caseAffiliate.getName()))); + } else { + // 如果不存在则新增 + SysDept dept = new SysDept(); + dept.setParentId(0L); + dept.setDeptName(caseAffiliate.getName()); + dept.setAncestors("0"); + dept.setOrderNum(1); + dept.setStatus("0"); + dept.setDelFlag("0"); + dept.setCreateBy(getUsername()); + dept.setUpdateBy(getUsername()); + sysDeptMapper.insertDept(dept); + deptMap.put(dept.getDeptName(), dept.getDeptId()); + caseAffiliate.setName(String.valueOf(dept.getDeptId())); + + } + } + } + + caseAffiliateMapper.batchCaseAffiliate(caseAffiliates); + } + + List caseAttachList = caseApplication.getCaseAttachList(); + if (caseAttachList != null && caseAttachList.size() > 0) { + for (CaseAttach caseAttach : caseAttachList) { + caseAttach.setCaseAppliId(caseApplication.getId()); + caseAttachMapper.updateCaseAttach(caseAttach); + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CASE_APPLICATION,""); + return rows; + } + + /** + * 获取自动编码 + * @return + */ + + private String generateCaseNum() { + // 自动编码格式 zc+yyyyMMdd+001 + String currentDay = DateUtils.dateTime(); + String caseNum = "zc"+ currentDay; + //查询出当天的案件编号的最大值 + Integer maxCaseNum = caseApplicationMapper.selectCaseNumLike(caseNum,caseNum.length()); + if(null == maxCaseNum){ + caseNum = caseNum + "001"; + }else { + caseNum = caseNum + String.format("%03d", maxCaseNum); + } + return caseNum; + + } + + @Override + public int selectCaseApplicationCount(CaseApplication caseApplication) { + return caseApplicationMapper.selectCaseApplicationCount(caseApplication); + } + + @Override + @Transactional + public int editCaseApplication(CaseApplication caseApplication) { + //根据仲裁费用计费规则计算应缴费用 + //暂时设置计费比率为0.01 + BigDecimal feeRate = new BigDecimal(0.01); + BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2,BigDecimal.ROUND_HALF_UP); + caseApplication.setFeePayable(feePayable); + + int rows = caseApplicationMapper.updataCaseApplication(caseApplication); + List caseAffiliates = caseApplication.getCaseAffiliates(); + if(caseAffiliates!=null&&caseAffiliates.size()>0){ + // 查询所有的组织机构,组装成map + List deptList = sysDeptMapper.selectDeptList(new SysDept()); + if (CollectionUtil.isEmpty(deptList)) { + deptList = new ArrayList<>(); + } + Map deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId,(oldV,newV)->newV)); + for (CaseAffiliate caseAffiliate : caseAffiliates){ + caseAffiliate.setCaseAppliId(caseApplication.getId()); + if(caseAffiliate.getIdentityType()==1&&StrUtil.isNotEmpty(caseAffiliate.getName())) { + // 将组织机构id设为申请人名称 + if (deptMap.containsKey(caseApplication.getName())) { + caseAffiliate.setName(String.valueOf(deptMap.get(caseAffiliate.getName()))); + } else { + // 如果不存在则新增 + SysDept dept = new SysDept(); + dept.setParentId(0L); + dept.setDeptName(caseAffiliate.getName()); + dept.setAncestors("0"); + dept.setOrderNum(1); + dept.setStatus("0"); + dept.setDelFlag("0"); + dept.setCreateBy(getUsername()); + dept.setUpdateBy(getUsername()); + sysDeptMapper.insertDept(dept); + deptMap.put(dept.getDeptName(), dept.getDeptId()); + caseAffiliate.setName(String.valueOf(dept.getDeptId())); + + } + } + caseAffiliateMapper.updataCaseAffiliate(caseAffiliate); + } + + } + List caseAttachList = caseApplication.getCaseAttachList(); + if(caseAttachList!=null&&caseAttachList.size()>0){ + for (CaseAttach caseAttach : caseAttachList){ + caseAttach.setCaseAppliId(caseApplication.getId()); + caseAttachMapper.updateCaseAttach(caseAttach); + } + + } + + return rows; + } + + @Override + @Transactional + public int submitCaseApplication(CaseApplication caseApplication) { + //提交立案申请 + caseApplication.setCaseStatus(CaseApplicationConstants.CASE_CHECK); + int rows = caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CASE_CHECK,""); + return rows; + } + + @Override + @Transactional + public int deletecaseApplicationByIds(CaseApplication caseApplication) { + + caseAffiliateMapper.deletecaseAffiliate(caseApplication); + return caseApplicationMapper.deletecaseApplication(caseApplication); + } + + @Override + public CaseApplication selectCaseApplication(CaseApplication caseApplication) { + CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication.getId()); + + ArbitrateRecord arbitrateRecord = new ArbitrateRecord(); + arbitrateRecord.setCaseAppliId(caseApplication.getId()); + ArbitrateRecord arbitrateRecordselect = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord); + +// CaseAttach caseAttachSelect = new CaseAttach(); +// caseAttachSelect.setCaseAppliId(caseApplication.getId()); +// caseAttachSelect.setAnnexType(2); + + List caseAttachList = caseAttachMapper.queryCaseAttachList(caseApplication); + if (caseAttachList != null && caseAttachList.size() > 0) { + for (CaseAttach caseAttach : caseAttachList) { + String annexName = caseAttach.getAnnexName(); + String prefix = "/profile"; + int startIndex = annexName.indexOf(prefix); + startIndex += prefix.length(); + String annexPath = "/uploadPath" + annexName.substring(startIndex); + caseAttach.setAnnexPath(annexPath); + int startIndexnew = annexName.lastIndexOf("/"); + if(startIndexnew!=-1){ + String annexNamenew = annexName.substring(startIndexnew+1); + caseAttach.setAnnexName(annexNamenew); + } + + + } + } + caseApplicationselect.setCaseAttachList(caseAttachList); + + List caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if(caseAffiliatListeselect!=null){ + // 查询组织机构 + List sysDepts = sysDeptMapper.selectDeptList(new SysDept()); + Map deptMap=new HashMap<>(); + if(CollectionUtil.isNotEmpty(sysDepts)){ + for (SysDept sysDept : sysDepts) { + deptMap.put(String.valueOf(sysDept.getDeptId()),sysDept.getDeptName()); + } + } + StringBuffer applicantName = new StringBuffer(); + StringBuffer respondentName = new StringBuffer(); + for (int i = 0; i < caseAffiliatListeselect.size(); i++){ + CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(i); + int identityType = caseAffiliateselect.getIdentityType(); + if(identityType==1){ + if(StrUtil.isNotEmpty(caseAffiliateselect.getName())&&deptMap.containsKey(caseAffiliateselect.getName())){ + caseAffiliateselect.setName(deptMap.get(caseAffiliateselect.getName())); + } + applicantName.append(caseAffiliateselect.getName()).append(",");; + }else if(identityType==2){ + respondentName.append(caseAffiliateselect.getName()).append(",");; + } + } + caseApplicationselect.setApplicantName(applicantName.toString()); + caseApplicationselect.setRespondentName(respondentName.toString()); + caseApplicationselect.setCaseAffiliates(caseAffiliatListeselect); + caseApplicationselect.setArbitrateRecord(arbitrateRecordselect); + } + return caseApplicationselect; + } + + @Override + @Transactional + public String importCaseApplication(List caseApplicationList, String operName) { + StringBuilder failureMsg = new StringBuilder(); + StringBuilder successMsg = new StringBuilder(); + int successNum = 0; + int failureNum = 0; + if(caseApplicationList!=null&&caseApplicationList.size()>0){ + // 1,查询所有的组织机构,组装成map + List deptList = sysDeptMapper.selectDeptList(new SysDept()); + Map deptMap =new HashMap<>(); + if(CollectionUtil.isNotEmpty(deptList)) { + deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId,(oldV,newV)->newV)); + } + List caseApplicationListinsert = new ArrayList<>(); + for (int i = 0; i < caseApplicationList.size(); i++){ + CaseApplication caseApplication = caseApplicationList.get(i); + + // 导入校验 + importValid(caseApplication); + // 校验成功的数据 + if(StrUtil.isEmpty(caseApplication.getErrorMsg())) { + //根据仲裁费用计费规则计算应缴费用 + //暂时设置计费比率为0.01 + BigDecimal feeRate = new BigDecimal(0.01); + BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, BigDecimal.ROUND_HALF_UP); + caseApplication.setFeePayable(feePayable); + + //赋值CaseApplication的案件关联人信息 + List caseAffiliatesnew = new ArrayList<>(); + // 组装案件关联人信息 + assignmentCaseAffiliates(caseApplication, caseAffiliatesnew, deptMap); + +// int caseApplicationCount = selectCaseApplicationCount(caseApplication); +// if(caseApplicationCount>0){ +// failureNum++; +// failureMsg.append("
" + failureNum + "、立案编号 " + caseApplication.getCaseNum() + " 已存在"); +// }else { +// caseApplicationListinsert.add(caseApplication); +// } + caseApplicationListinsert.add(caseApplication); + }else { + // 拼接错误信息 + failureMsg.append("
").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString()); + } + } + if(caseApplicationListinsert!=null&&caseApplicationListinsert.size()>0){ +// List caseApplicationListinsertDiffer = caseApplicationListinsert.stream().collect( +// collectingAndThen( +// toCollection(() -> new TreeSet<>(Comparator.comparing(CaseApplication::getCaseNum))), +// ArrayList::new)); + + + //对不重复的立案对象集合的立案对象重新组装对应的案件关联人信息 +// if(caseApplicationListinsertDiffer!=null&&caseApplicationListinsertDiffer.size()>0){ + List caseApplicationNewList = null; + for (int i = 0; i < caseApplicationListinsert.size(); i++){ + caseApplicationNewList = new ArrayList<>(); + CaseApplication caseApplicationinsertDiffer = caseApplicationListinsert.get(i); + // 设置自动编码 + caseApplicationinsertDiffer.setCaseNum(generateCaseNum()); + List caseAffiliatesnew = new ArrayList<>(); + CaseApplication caseApplicationNew = new CaseApplication(); + copyCaseApplication(caseApplicationinsertDiffer,caseApplicationNew); + if(caseApplicationListinsert!=null&&caseApplicationListinsert.size()>0){ + for (int j = 0; j < caseApplicationListinsert.size(); j++){ + CaseApplication caseApplicationinsert = caseApplicationListinsert.get(j); + + if(StringUtils.isNotEmpty(caseApplicationinsert.getCaseNum())&& + caseApplicationinsert.getCaseNum().equals(caseApplicationinsertDiffer.getCaseNum())){ + + caseAffiliatesnew.addAll(caseApplicationinsert.getCaseAffiliates()); + } + } + caseApplicationNew.setCaseAffiliates(caseAffiliatesnew); + caseApplicationNewList.add(caseApplicationNew); + } + + for (int k = 0; k < caseApplicationNewList.size(); k++){ + CaseApplication caseApplicationItera = caseApplicationNewList.get(k); + // 新增立案信息 + caseApplicationItera.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION); + + int rows = caseApplicationMapper.insertCaseApplication(caseApplicationItera); + List caseAffiliates = caseApplicationItera.getCaseAffiliates(); + if(caseAffiliates!=null&&caseAffiliates.size()>0){ + for (CaseAffiliate caseAffiliate : caseAffiliates){ + caseAffiliate.setCaseAppliId(caseApplicationItera.getId()); + } + caseAffiliateMapper.batchCaseAffiliate(caseAffiliates); + } + successNum++; + successMsg.append("
" + successNum + "、立案编号 " + caseApplicationItera.getCaseNum() + " 导入成功"); + } + +// } + + } + + } + + }else { + throw new ServiceException("导入立案申请数据不能为空!"); + } + return successMsg.append(failureMsg.toString()).toString(); + + } + + /** + * 导入校验 + * @param caseApplication + * @param + */ + private void importValid(CaseApplication caseApplication) { + StringBuilder failureMsg=new StringBuilder(); + caseApplication.setErrorMsg(failureMsg); + // 校验基本字段 + validBaseColumn(caseApplication,failureMsg); + // 校验申请人信息 + validApplicationColumn(caseApplication,failureMsg); + // 校验申请人代理信息 + validApplicationAgentColumn(caseApplication,failureMsg); + // 校验被申请人信息 + validDebtorApplicationColumn(caseApplication,failureMsg); + // 校验被申请人代理信息 + validDebtorApplicationAgentColumn(caseApplication,failureMsg); + } + + /** + * 校验被申请人代理信息 + * @param caseApplication + * @param failureMsg + */ + private void validDebtorApplicationAgentColumn(CaseApplication caseApplication, StringBuilder failureMsg) { + if( StrUtil.isEmpty(caseApplication.getDebtorNameAgent())){ + failureMsg.append("【被申请人主体信息-代理人姓名】字段不能为空;"); + }else if(caseApplication.getDebtorNameAgent().length()>50){ + failureMsg.append("【被申请人主体信息-代理人姓名】字段超出指定长度,最大长度为50;"); + } + if( StrUtil.isEmpty(caseApplication.getDebtorIdentityNumAgent())){ + failureMsg.append("【被申请人主体信息-代理人身份证号】字段不能为空;"); + }else if(caseApplication.getDebtorIdentityNumAgent().length()>50){ + failureMsg.append("【被申请人主体信息-代理人身份证号】字段超出指定长度,最大长度为50;"); + } + String debtorContactTelphoneAgent = caseApplication.getDebtorContactTelphoneAgent(); + if( StrUtil.isEmpty(debtorContactTelphoneAgent)){ + failureMsg.append("【被申请人主体信息-代理人联系电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(debtorContactTelphoneAgent).matches()){ + failureMsg.append("【被申请人主体信息-代理人联系电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getDebtorContactAddressAgent())){ + failureMsg.append("【被申请人主体信息-代理人联系地址】字段不能为空;"); + }else if(caseApplication.getDebtorContactAddressAgent().length()>50){ + failureMsg.append("【被申请人主体信息-代理人联系地址】字段超出指定长度,最大长度为50;"); + } + } + + /** + * 校验被申请人信息 + * @param caseApplication + * @param failureMsg + */ + private void validDebtorApplicationColumn(CaseApplication caseApplication, StringBuilder failureMsg) { + if( StrUtil.isEmpty(caseApplication.getDebtorName())){ + failureMsg.append("【被申请人主体信息-申请人姓名】字段不能为空;"); + }else if(caseApplication.getDebtorName().length()>50){ + failureMsg.append("【被申请人主体信息-申请人姓名】字段超出指定长度,最大长度为50;"); + } + if( StrUtil.isEmpty(caseApplication.getDebtorIdentityNum())){ + failureMsg.append("【被申请人主体信息-身份证号】字段不能为空;"); + }else if(caseApplication.getDebtorIdentityNum().length()>50){ + failureMsg.append("【被申请人主体信息-身份证号】字段超出指定长度,最大长度为50;"); + } + String debtorContactTelphone = caseApplication.getDebtorContactTelphone(); + if( StrUtil.isEmpty(debtorContactTelphone)){ + failureMsg.append("【被申请人主体信息-联系电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(debtorContactTelphone).matches()){ + failureMsg.append("【被申请人主体信息-联系电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getDebtorContactAddress())){ + failureMsg.append("【被申请人主体信息-联系地址】字段不能为空;"); + }else if(caseApplication.getDebtorContactAddress().length()>50){ + failureMsg.append("【被申请人主体信息-联系地址】字段超出指定长度,最大长度为50;"); + } + String debtorWorkTelphone = caseApplication.getDebtorWorkTelphone(); + if( StrUtil.isEmpty(debtorWorkTelphone)){ + failureMsg.append("【被申请人主体信息-单位电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(debtorWorkTelphone).matches()){ + failureMsg.append("【被申请人主体信息-单位电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getDebtorWorkAddress())){ + failureMsg.append("【被申请人主体信息-单位地址】字段不能为空;"); + }else if(caseApplication.getDebtorWorkAddress().length()>50){ + failureMsg.append("【被申请人主体信息-单位地址】字段超出指定长度,最大长度为50;"); + } + } + + /** + * 校验申请人代理信息 + * @param caseApplication + * @param failureMsg + */ + private void validApplicationAgentColumn(CaseApplication caseApplication, StringBuilder failureMsg) { + if( StrUtil.isEmpty(caseApplication.getNameAgent())){ + failureMsg.append("【申请人主体信息-代理人姓名】字段不能为空;"); + }else if(caseApplication.getNameAgent().length()>50){ + failureMsg.append("【申请人主体信息-代理人姓名】字段超出指定长度,最大长度为50;"); + } + if( StrUtil.isEmpty(caseApplication.getIdentityNumAgent())){ + failureMsg.append("【申请人主体信息-代理人身份证号】字段不能为空;"); + }else if(caseApplication.getIdentityNumAgent().length()>50){ + failureMsg.append("【申请人主体信息-代理人身份证号】字段超出指定长度,最大长度为50;"); + } + String contactTelphoneAgent = caseApplication.getContactTelphoneAgent(); + if( StrUtil.isEmpty(contactTelphoneAgent)){ + failureMsg.append("【申请人主体信息-代理人联系电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(contactTelphoneAgent).matches()){ + failureMsg.append("【申请人主体信息-代理人联系电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getContactAddressAgent())){ + failureMsg.append("【申请人主体信息-代理人联系地址】字段不能为空;"); + }else if(caseApplication.getContactAddressAgent().length()>50){ + failureMsg.append("【申请人主体信息-代理人联系地址】字段超出指定长度,最大长度为50;"); + } + } + + /** + * 校验申请人主题信息 + * @param caseApplication + * @param failureMsg + */ + private void validApplicationColumn(CaseApplication caseApplication, StringBuilder failureMsg) { + if( StrUtil.isEmpty(caseApplication.getName())){ + failureMsg.append("【申请人主体信息-申请人(机构)】字段不能为空;"); + }else if(caseApplication.getName().length()>20){ + failureMsg.append("【申请人主体信息-申请人(机构)】字段超出指定长度,最大长度为20;"); + } + if( StrUtil.isNotEmpty(caseApplication.getIdentityNum())&&caseApplication.getIdentityNum().length()>50){ + failureMsg.append("【申请人主体信息-代码】字段超出指定长度,最大长度为50;"); + } + String contactTelphone = caseApplication.getContactTelphone(); + if( StrUtil.isEmpty(contactTelphone)){ + failureMsg.append("【申请人主体信息-联系电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(contactTelphone).matches()){ + failureMsg.append("【申请人主体信息-联系电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getContactAddress())){ + failureMsg.append("【申请人主体信息-联系地址】字段不能为空;"); + }else if(caseApplication.getName().length()>50){ + failureMsg.append("【申请人主体信息-联系地址】字段超出指定长度,最大长度为50;"); + } + String workTelphone = caseApplication.getWorkTelphone(); + if( StrUtil.isEmpty(workTelphone)){ + failureMsg.append("【申请人主体信息-单位电话】字段不能为空;"); + }else if(!TELEPHONE_REGX.matcher(workTelphone).matches()){ + failureMsg.append("【申请人主体信息-单位电话】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getWorkAddress())){ + failureMsg.append("【申请人主体信息-单位地址】字段不能为空;"); + }else if(caseApplication.getWorkAddress().length()>50){ + failureMsg.append("【申请人主体信息-单位地址】字段超出指定长度,最大长度为50;"); + } + } + + /** + * 校验基本字段 + * @param caseApplication + * @param failureMsg + */ + private void validBaseColumn(CaseApplication caseApplication, StringBuilder failureMsg) { + BigDecimal caseSubjectAmount = caseApplication.getCaseSubjectAmount(); + if(null== caseSubjectAmount){ + failureMsg.append("【案件标的】字段不合法;"); + }else { + if(caseSubjectAmount.compareTo(new BigDecimal("0")) < 0 ||caseSubjectAmount.compareTo(new BigDecimal("99999999.99"))>0){ + failureMsg.append("【案件标的】字段超出范围,范围为[0,100000000);"); + } + if(caseSubjectAmount.scale()>2){ + failureMsg.append("【案件标的】字段超出指定精度(10^-2);"); + } + } + if( caseApplication.getLoanStartDate()== null){ + failureMsg.append("【借款开始日期】字段不合法;"); + } + if( caseApplication.getLoanEndDate()== null){ + failureMsg.append("【借款结束日期】字段不合法;"); + } + if( StrUtil.isEmpty(caseApplication.getContractNumber())){ + failureMsg.append("【合同编号】字段不能为空;"); + }else if(caseApplication.getContractNumber().length()>50){ + failureMsg.append("【合同编号】字段超出指定长度,最大长度为50;"); + } + BigDecimal claimPrinciOwed = caseApplication.getClaimPrinciOwed(); + if(null== claimPrinciOwed){ + failureMsg.append("【申请人主张欠本金】字段不合法;"); + }else { + if(claimPrinciOwed.compareTo(new BigDecimal("0")) < 0 ||claimPrinciOwed.compareTo(new BigDecimal("99999999.99"))>0){ + failureMsg.append("【申请人主张欠本金】字段超出范围,范围为[0,100000000);"); + } + if(claimPrinciOwed.scale()>2){ + failureMsg.append("【申请人主张欠本金】字段超出指定精度(10^-2);"); + } + } + BigDecimal claimInterestOwed = caseApplication.getClaimInterestOwed(); + if(null== claimInterestOwed){ + failureMsg.append("【申请人主张欠利息】字段不合法;"); + }else { + if(claimInterestOwed.compareTo(new BigDecimal("0")) < 0 ||claimInterestOwed.compareTo(new BigDecimal("99999999.99"))>0){ + failureMsg.append("【申请人主张欠利息】字段超出范围,范围为[0,100000000);"); + } + if(claimInterestOwed.scale()>2){ + failureMsg.append("【申请人主张欠利息】字段超出指定精度(10^-2);"); + } + } + BigDecimal claimLiquidDamag = caseApplication.getClaimLiquidDamag(); + if(null== claimLiquidDamag){ + failureMsg.append("【申请人主张违约金】字段不合法;"); + }else { + if(claimLiquidDamag.compareTo(new BigDecimal("0")) < 0 ||claimLiquidDamag.compareTo(new BigDecimal("99999999.99"))>0){ + failureMsg.append("【申请人主张违约金】字段超出范围,范围为[0,100000000);"); + } + if(claimLiquidDamag.scale()>2){ + failureMsg.append("【申请人主张违约金】字段超出指定精度(10^-2);"); + } + } + if( StrUtil.isEmpty(caseApplication.getArbitratClaims())){ + failureMsg.append("【申请人仲裁诉求】字段不能为空;"); + }else if(caseApplication.getArbitratClaims().length()>10000){ + failureMsg.append("【申请人仲裁诉求】字段超出指定长度,最大长度为10000;"); + } + } + + + @Override + @Transactional + public int pendTral(CaseApplication caseApplication) { + List arbitrators = caseApplication.getArbitrators(); + int rows = 0; + if(arbitrators!=null&&arbitrators.size()>0){ + List ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList()); + List arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList()); + String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(",")); + String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(",")); + caseApplication.setArbitratorId(idstr); + caseApplication.setArbitratorName(arbitratorNamestr); + caseApplication.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + } + + + return rows; + } + + @Override + @Transactional + public int pendTralCheck(CaseApplication caseApplication) { + Integer isAgreePendTral = caseApplication.getIsAgreePendTral(); + caseApplication.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL); + int rows = 0; + //同意组庭 + if(isAgreePendTral!=null&&isAgreePendTral==1){ + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + }else { + List arbitrators = caseApplication.getArbitrators(); + if(arbitrators!=null&&arbitrators.size()>0){ + List ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList()); + List arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList()); + String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(",")); + String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(",")); + caseApplication.setArbitratorId(idstr); + caseApplication.setArbitratorName(arbitratorNamestr); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL,""); + return rows; + } + + @Override + @Transactional + public int verificationArbitrateRecord(CaseApplication caseApplication) { + caseApplication.setCaseStatus(CaseApplicationConstants.CHECK_ARBITRATION); + int rows = caseApplicationMapper.submitCaseApplication(caseApplication); + ArbitrateRecord arbitrateRecord = caseApplication.getArbitrateRecord(); + arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CHECK_ARBITRATION,""); + return rows; + + } + + @Override + @Transactional + public int checkArbitrateRecord(CaseApplication caseApplication) { + int rows = 0; + ArbitrateRecord arbitrateRecord = caseApplication.getArbitrateRecord(); + arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord); + Integer agreeOrNotCheck = caseApplication.getAgreeOrNotCheck(); + if(agreeOrNotCheck.intValue()==1){//同意审核 + caseApplication.setCaseStatus(CaseApplicationConstants.SIGN_ARBITRATION); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.SIGN_ARBITRATION,""); + + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + }else if(agreeOrNotCheck.intValue()==2){//拒绝审核 + caseApplication.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.VERPRIF_ARBITRATION,""); + + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + } + + return rows; + } + + @Override + @Transactional + public int submitCaseApplicationCheck(CaseApplication caseApplication) { + //提交立案审查 + int rows = 0; + Integer agreeOrNotCheck = caseApplication.getAgreeOrNotCheck(); + if(agreeOrNotCheck.intValue()==1){//同意审核 + caseApplication.setCaseStatus(CaseApplicationConstants.PENDING_PAYMENT); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + }else if(agreeOrNotCheck.intValue()==2){//拒绝审核 + caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_PAYMENT,""); + + return rows; + } + + @Override + public CaseApplication selectCaseApplicationConfirm(CaseApplication caseApplication) { + CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplicationConfirm(caseApplication); + if(caseApplicationselect==null){ + return caseApplicationselect; + } + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication.getId()); + List caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if(caseAffiliatListeselect!=null){ + // 查询组织机构 + List sysDepts = sysDeptMapper.selectDeptList(new SysDept()); + Map deptMap=new HashMap<>(); + if(CollectionUtil.isNotEmpty(sysDepts)){ + for (SysDept sysDept : sysDepts) { + deptMap.put(String.valueOf(sysDept.getDeptId()),sysDept.getDeptName()); + } + } + StringBuffer applicantName = new StringBuffer(); + for (int i = 0; i < caseAffiliatListeselect.size(); i++){ + CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(i); + int identityType = caseAffiliateselect.getIdentityType(); + if(identityType==1){ + if(StrUtil.isNotEmpty(caseAffiliateselect.getName())&&deptMap.containsKey(caseAffiliateselect.getName())){ + caseAffiliateselect.setName(deptMap.get(caseAffiliateselect.getName())); + } + applicantName.append(caseAffiliateselect.getName()).append(",");; + } + } + caseApplicationselect.setApplicantName(applicantName.toString()); + + + } + return caseApplicationselect; + } + + /** + * 给被申请人发送房间号短信 + * @param messageVO + * @return + */ + @Override + public String sendRoomNoMessage(SendRoomNoMessageVO messageVO) { + CaseAffiliate caseAffiliate = caseAffiliateMapper.selectCaseAffiliateByIdentityType(messageVO.getId(), 2); + if(null==caseAffiliate){ + return "被申请人不存在"; + } + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(messageVO.getId()); + CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); + + //发送短信通知 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId("1948332"); + // 1948332 普通短信 开庭审理房间号通知 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请知晓,如非本人操作,请忽略本短信。 + request.setPhone(caseAffiliate.getContactTelphone()); + request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()}); + SmsUtils.sendSms(request); + + return "短信发送成功"; + } + + @Override + @Transactional + public int pendTralSure(CaseApplication caseApplication) { + caseApplication.setCaseStatus(CaseApplicationConstants.CHECK_ARBITRATION_METHOD); + int rows = caseApplicationMapper.submitCaseApplication(caseApplication); + + //发送短信通知 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId("1947342"); + + CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); + String caseNum = caseApplicationselect.getCaseNum(); + Date hearDate = caseApplicationselect.getHearDate(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String hearDatestr = dateFormat.format(hearDate); + + String arbitratorId = caseApplicationselect.getArbitratorId(); + List arbitratorList = new ArrayList<>(); + if(StringUtils.isNotEmpty(arbitratorId)){ + String[] idStrList = arbitratorId.split(","); + List idList = new ArrayList<>(); + for(int i = 0;i < idStrList.length;i ++ ){ + idList.add(Long.parseLong(idStrList[i])); + } + Arbitrator arbitrator = new Arbitrator(); + arbitrator.setIdList(idList); + arbitratorList = arbitratorMapper.selectArbitratorList(arbitrator); + if(arbitratorList!=null) { + for (int i = 0; i < arbitratorList.size(); i++) { + Arbitrator arbitratorselect = arbitratorList.get(i); + //给仲裁员发送短信通知 + request.setPhone(arbitratorselect.getTelephone()); + // 1947342 普通短信 开庭日期通知 尊敬的{1}用户,您的{2}仲裁案件,开庭日期已确定为{3},请知晓,如非本人操作,请忽略本短信。 + String name = arbitratorselect.getArbitratorName(); + request.setTemplateParamSet(new String[]{name, caseNum, hearDatestr}); + SmsUtils.sendSms(request); + } + } + } + + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication.getId()); + List caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + if(caseAffiliatListeselect!=null) { + // 查询组织机构 + List sysDepts = sysDeptMapper.selectDeptList(new SysDept()); + Map deptMap=new HashMap<>(); + if(CollectionUtil.isNotEmpty(sysDepts)){ + for (SysDept sysDept : sysDepts) { + deptMap.put(String.valueOf(sysDept.getDeptId()),sysDept.getDeptName()); + } + } + for (int j = 0; j < caseAffiliatListeselect.size(); j++) { + CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(j); + int identityType = caseAffiliateselect.getIdentityType(); + if(identityType==1){ + if(StrUtil.isNotEmpty(caseAffiliateselect.getName())&&deptMap.containsKey(caseAffiliateselect.getName())){ + caseAffiliateselect.setName(deptMap.get(caseAffiliateselect.getName())); + } + caseAffiliateselect.setName(caseAffiliateselect.getName());; + } + //给申请人、被申请人发送短信通知 + request.setPhone(caseAffiliateselect.getContactTelphone()); + // 1947342 普通短信 开庭日期通知 尊敬的{1}用户,您的{2}仲裁案件,开庭日期已确定为{3},请知晓,如非本人操作,请忽略本短信。 + String name = caseAffiliateselect.getName(); + request.setTemplateParamSet(new String[]{name, caseNum, hearDatestr}); + SmsUtils.sendSms(request); + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CHECK_ARBITRATION_METHOD,""); + + return rows; + + } + + + + @Override + @Transactional + public int pendingAppointArbotrar(CaseApplication caseApplication) { + int pendingAppointArbotrar = caseApplication.getPendingAppointArbotrar(); + List arbitrators = caseApplication.getArbitrators(); + int rows = 0; + if(pendingAppointArbotrar==1){ + if(arbitrators!=null&&arbitrators.size()>0){ + List ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList()); + List arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList()); + String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(",")); + String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(",")); + caseApplication.setArbitratorId(idstr); + caseApplication.setArbitratorName(arbitratorNamestr); + caseApplication.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL); + caseApplication.setPendingAppointArbotrar(1); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + } + + }else { + caseApplication.setCaseStatus(CaseApplicationConstants.PENDING_TRIAL); + caseApplication.setPendingAppointArbotrar(2); + rows = caseApplicationMapper.submitCaseApplication(caseApplication); + + } + + return rows; + + } + + + + private void assignmentCaseAffiliates(CaseApplication caseApplication, List caseAffiliatesnew, Map deptMap) { + // 申请人信息 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + +// BeanUtils.copyBeanProp(caseApplication,caseAffiliate); + BeanUtils.copyBeanProp(caseAffiliate,caseApplication); + caseAffiliate.setIdentityType(1); + // 申请人(机构),需要判断部门中是否存在,不存在则新增,当身份类型为1的时候,查询时需要根据名称查询组织机构 + if(StrUtil.isNotEmpty(caseApplication.getName())){ + setApplicantOrganization(caseAffiliate, caseApplication, deptMap); + } + caseAffiliatesnew.add(caseAffiliate); + + // 组装被申请人信息 + caseAffiliatesnew.add( buildDebtorInfo(caseApplication)); + caseApplication.setCaseAffiliates(caseAffiliatesnew); + } + + /** + * 设置申请人的组织机构 + * @param caseAffiliate + * @param caseApplication + */ + @DataScope(deptAlias = "d") + private void setApplicantOrganization(CaseAffiliate caseAffiliate, CaseApplication caseApplication, Map deptMap ) { + + + + // 将组织机构id设为申请人名称 + if(deptMap.containsKey(caseApplication.getName())){ + caseAffiliate.setName(String.valueOf(deptMap.get(caseApplication.getName()))); + }else { + // 如果不存在则新增 + SysDept dept = new SysDept(); + dept.setParentId(0L); + dept.setDeptName(caseApplication.getName()); + dept.setAncestors("0"); + dept.setOrderNum(1); + dept.setStatus("0"); + dept.setDelFlag("0"); + dept.setCreateBy(getUsername()); + dept.setUpdateBy(getUsername()); + sysDeptMapper.insertDept(dept); + deptMap.put(dept.getDeptName(),dept.getDeptId()); + caseAffiliate.setName(String.valueOf(dept.getDeptId())); + + } + + } + + /** + * 组装被申请人信息 + * @param caseApplication + * @return + */ + + private CaseAffiliate buildDebtorInfo(CaseApplication caseApplication) { + // 被申请人信息 + CaseAffiliate debtorCaseAffiliate = new CaseAffiliate(); + debtorCaseAffiliate.setCaseAppliId(caseApplication.getId()); + debtorCaseAffiliate.setIdentityType(2); + debtorCaseAffiliate.setName(caseApplication.getDebtorName()); + debtorCaseAffiliate.setIdentityNum(caseApplication.getDebtorIdentityNum()); + debtorCaseAffiliate.setContactTelphone(caseApplication.getDebtorContactTelphone()); + debtorCaseAffiliate.setContactAddress(caseApplication.getDebtorContactAddress()); + debtorCaseAffiliate.setWorkTelphone(caseApplication.getDebtorWorkTelphone()); + debtorCaseAffiliate.setWorkAddress(caseApplication.getDebtorWorkAddress()); + debtorCaseAffiliate.setNameAgent(caseApplication.getDebtorNameAgent()); + debtorCaseAffiliate.setIdentityNumAgent(caseApplication.getDebtorIdentityNumAgent()); + debtorCaseAffiliate.setContactTelphoneAgent(caseApplication.getDebtorContactTelphoneAgent()); + debtorCaseAffiliate.setContactAddressAgent(caseApplication.getDebtorContactAddressAgent()); + return debtorCaseAffiliate; + } + + private void copyCaseApplication(CaseApplication caseApplicationinsertDiffer, CaseApplication caseApplicationNew) { + caseApplicationNew.setArbitratClaims(caseApplicationinsertDiffer.getArbitratClaims()); + caseApplicationNew.setCaseNum(caseApplicationinsertDiffer.getCaseNum()); + caseApplicationNew.setCaseSubjectAmount(caseApplicationinsertDiffer.getCaseSubjectAmount()); + caseApplicationNew.setLoanStartDate(caseApplicationinsertDiffer.getLoanStartDate()); + caseApplicationNew.setLoanEndDate(caseApplicationinsertDiffer.getLoanEndDate()); + caseApplicationNew.setContractNumber(caseApplicationinsertDiffer.getContractNumber()); + caseApplicationNew.setClaimInterestOwed(caseApplicationinsertDiffer.getClaimInterestOwed()); + caseApplicationNew.setClaimPrinciOwed(caseApplicationinsertDiffer.getClaimPrinciOwed()); + caseApplicationNew.setClaimLiquidDamag(caseApplicationinsertDiffer.getClaimLiquidDamag()); + caseApplicationNew.setFeePayable(caseApplicationinsertDiffer.getFeePayable()); + } + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseArbitrateServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseArbitrateServiceImpl.java new file mode 100644 index 0000000..ee57a80 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseArbitrateServiceImpl.java @@ -0,0 +1,166 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.common.utils.SmsUtils; +import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord; +import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; +import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper; +import com.ruoyi.wisdomarbitrate.service.ICaseArbitrateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class CaseArbitrateServiceImpl implements ICaseArbitrateService { + @Autowired + private CaseApplicationMapper caseApplicationMapper; + @Autowired + private CaseAffiliateMapper caseAffiliateMapper; + @Autowired + private CaseLogRecordMapper caseLogRecordMapper; + @Autowired + private ArbitrateRecordMapper arbitrateRecordMapper; + + @Override + @Transactional + public AjaxResult examineArbitrateMethod(CaseApplication caseApplication, Integer opinion) { + //查询案件详细信息 + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 == null) { + return AjaxResult.error(); + } + int arbitratMethod = caseApplication1.getArbitratMethod(); + String caseNum = caseApplication1.getCaseNum(); + if (opinion==0){ //拒绝 + if (arbitratMethod == 2){ + caseApplication1.setArbitratMethod(1); // 更改仲裁方式 + //修改案件状态为待开庭审理 + caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_OPENCOURT_HEAR); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_OPENCOURT_HEAR,""); + + }else { + caseApplication1.setArbitratMethod(2); + //修改案件状态为待书面审理 + caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_WRIITEN_HEAR); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_WRIITEN_HEAR,""); + + } + }else { + if (arbitratMethod == 2){ + //修改案件状态为待书面审理 + caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_WRIITEN_HEAR); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_WRIITEN_HEAR,""); + + }else { + //修改案件状态为待开庭审理 + caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_OPENCOURT_HEAR); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_OPENCOURT_HEAR,""); + + } + } + int i = caseApplicationMapper.submitCaseApplication(caseApplication1); + if (i > 0) { + String arbitratMethodStr = caseApplication1.getArbitratMethod() == 1 ? "开庭审理" : "书面审理"; + //发送短信通知 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId("1931000"); + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication1.getId()); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); //获取案件关联人信息 + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + //获取身份类型 + int identityType = affiliate.getIdentityType(); + if (identityType == 1) { //申请人 + request.setPhone(affiliate.getContactTelphone()); + // 这个值,要看你的模板中是否预留了占位符,如果没有则不需要设置 + // 1931000 普通短信 确定仲裁方式通知 尊敬的{1}用户,您的{2}仲裁案件,仲裁方式已确定为{3},请知晓,如非本人操作,请忽略本短信。 + String name = affiliate.getName(); + request.setTemplateParamSet(new String[]{name, caseNum, arbitratMethodStr}); + SmsUtils.sendSms(request); + } else { //被申请人 + request.setPhone(affiliate.getContactTelphone()); + // 模板id1928006 普通短信 案件应诉通知 尊敬的{1}用户,您的{2}案件{3}已成功受理,请点击https://phmapp.xayunmei.com选择是否应诉。 + String name = affiliate.getName(); + request.setTemplateParamSet(new String[]{name, caseNum, arbitratMethodStr}); + SmsUtils.sendSms(request); + } + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_OPENCOURT_HEAR,""); + + return AjaxResult.success("审核成功"); + } + return AjaxResult.error(); + } + + @Override + public AjaxResult writtenHear(ArbitrateRecord arbitrateRecord) { + //查询案件详情 + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(arbitrateRecord.getCaseAppliId()); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + String createBy = caseApplication1.getCreateBy(); + if (createBy!=null){ + arbitrateRecord.setCreateBy(createBy); + } + //先判断案件是否已经提交过仲裁结果 + ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord); + if (arbitrateRecord1!=null){ + int i = arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord); + if (i>0){ + //案件日志表里添加数据 + CaseLogRecord caseLogRecord = new CaseLogRecord(); + caseLogRecord.setCaseAppliId(caseApplication1.getId()); + caseLogRecord.setCaseNode(caseApplication1.getCaseStatus()); + if (createBy!=null){ + caseLogRecord.setCreateBy(createBy); + } + caseLogRecordMapper.insertCaseLogRecord(caseLogRecord); + //修改案件状态 + caseApplication.setCaseStatus(CaseApplicationConstants.GENERATED_ARBITRATION); + caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.GENERATED_ARBITRATION,""); + + return AjaxResult.success("提交成功"); + } + }else { + //提交仲裁结果 + int i = arbitrateRecordMapper.insertArbitrateRecord(arbitrateRecord); + + if (i>0){ + //案件日志表里添加数据 + CaseLogRecord caseLogRecord = new CaseLogRecord(); + caseLogRecord.setCaseAppliId(caseApplication1.getId()); + caseLogRecord.setCaseNode(caseApplication1.getCaseStatus()); + if (createBy!=null){ + caseLogRecord.setCreateBy(createBy); + } + caseLogRecordMapper.insertCaseLogRecord(caseLogRecord); + //修改案件状态 + caseApplication.setCaseStatus(CaseApplicationConstants.GENERATED_ARBITRATION); + caseApplicationMapper.submitCaseApplication(caseApplication); + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.GENERATED_ARBITRATION,""); + + return AjaxResult.success("提交成功"); + } + } + return AjaxResult.error("暂无需要提交仲裁结果的案件"); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseEvidenceServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseEvidenceServiceImpl.java new file mode 100644 index 0000000..5a31a39 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseEvidenceServiceImpl.java @@ -0,0 +1,215 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.wisdomarbitrate.domain.*; +import com.ruoyi.wisdomarbitrate.domain.dto.CaseEvidenceDTO; +import com.ruoyi.wisdomarbitrate.domain.vo.CaseDetailVO; +import com.ruoyi.wisdomarbitrate.domain.vo.CaseEvidenceVO; +import com.ruoyi.wisdomarbitrate.mapper.*; +import com.ruoyi.wisdomarbitrate.service.ICaseEvidenceService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CaseEvidenceServiceImpl implements ICaseEvidenceService { + @Autowired + private CaseEvidenceMapper caseEvidenceMapper; + @Autowired + private CaseAffiliateMapper caseAffiliateMapper; + @Autowired + private CaseApplicationMapper caseApplicationMapper; + @Autowired + private CaseAttachMapper caseAttachMapper; + @Autowired + private CaseLogRecordMapper caseLogRecordMapper; + + @Override + @Transactional + public AjaxResult getCaseDetailsById(Long id, String userName) { + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(id); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 != null) { + CaseDetailVO caseDetailVO = new CaseDetailVO(); + BeanUtils.copyProperties(caseApplication1, caseDetailVO); + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(id); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + for (CaseAffiliate affiliate : caseAffiliates) { + if (affiliate.getName() != null) { + String name = affiliate.getName(); + //判断当前登录人和案件关联人姓名是否一致 + if (name.equals(userName)) { //一致,将案件关联人的身份类型赋给当前登录人 + caseDetailVO.setIdentityType(affiliate.getIdentityType()); + } + } + if (affiliate.getIdentityType() == 1) { //申请人 + caseDetailVO.setApplicantName(affiliate.getName()); + } else { + caseDetailVO.setRespondentName(affiliate.getName()); + } + //根据案件id查询案件证据材料 + List evidenceMaterialList = caseAttachMapper.queryAnnexPathByCaseId(id); + if (evidenceMaterialList != null && evidenceMaterialList.size() > 0) { + for (CaseAttach caseAttach : evidenceMaterialList) { + String path = caseAttach.getAnnexName(); + String prefix = "/profile"; + int startIndex = path.indexOf(prefix); + startIndex += prefix.length(); + String extractedPath = "/uploadPath" + path.substring(startIndex); + caseAttach.setAnnexPath(extractedPath); + } + } + caseDetailVO.setEvidenceMaterialList(evidenceMaterialList); + } + return AjaxResult.success(caseDetailVO); + } + return null; + } + + @Override + @Transactional + public AjaxResult uploadEvidence(MultipartFile file, Integer annexType, Long id, String userName, Long userId) { + + if (file.isEmpty()) { + return AjaxResult.error("请选择要上传的文件"); + } + try { + String filePath = RuoYiConfig.getUploadPath(); + // 上传 + String fileName = FileUploadUtils.upload(filePath, file); + CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id) + .annexName(fileName) + .annexPath(filePath) + .annexType(annexType) + .userId(userId) + .userName(userName) + .build(); + int count = caseAttachMapper.save(caseAttach); + if (count > 0) { + if(id!=null){ + //修改案件状态 + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(id); + caseApplication.setCaseStatus(4); + caseApplicationMapper.submitCaseApplication(caseApplication); + } + CaseAttach caseAttachselect = new CaseAttach(); + caseAttachselect.setAnnexId(caseAttach.getAnnexId()); + caseAttachselect.setAnnexName(caseAttach.getAnnexName()); + caseAttachselect.setAnnexType(caseAttach.getAnnexType()); + return AjaxResult.success("上传成功",caseAttachselect); + } + } catch (IOException e) { + e.printStackTrace(); + } + + return AjaxResult.error("上传失败"); + } +@Autowired +IdentityAuthenticationMapper identityAuthenticationMapper; + + @Override + public List getCaseListAll(String identityNum) { + if(StringUtils.isBlank(identityNum)){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + String username = loginUser.getUsername(); + IdentityAuthentication authentication=new IdentityAuthentication(); + authentication.setUserName(username); + IdentityAuthentication authentication1 = identityAuthenticationMapper.selectIdentityAuthentication(authentication); + if(authentication1!=null){ + identityNum = authentication1.getIdentityNo(); + } + } + List caseStatusList = Arrays.asList(CaseApplicationConstants.CASE_CROSSEXAMI); + return getCaseEvidenceVOList(identityNum, caseStatusList, null); + } + + @Override + public AjaxResult evidenceConfirmation(CaseApplication caseApplication) { + caseApplication.setCaseStatus(CaseApplicationConstants.PENDING_TRIAL); + int i = caseApplicationMapper.submitCaseApplication(caseApplication); + if (i > 0) { + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.PENDING_TRIAL,""); + + return AjaxResult.success("证据确认成功"); + } + return AjaxResult.error("暂无需要确认的证据"); + } + + @Override + public AjaxResult caseCrossexamination(CaseEvidenceDTO caseEvidenceDTO) { + //查询案件详细信息 + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(caseEvidenceDTO.getCaseId()); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 != null) { + int caseStatus = caseApplication1.getCaseStatus(); + caseApplication1.setObjectionAddEviden(caseEvidenceDTO.getObjectionAddEviden()); + caseApplication1.setOpenCourtHear(caseEvidenceDTO.getOpenCourtHear()); + caseApplication1.setPendingAppointArbotrar(caseEvidenceDTO.getPendingAppointArbotrar()); + List arbitrators = caseEvidenceDTO.getArbitrators(); + if (arbitrators != null && arbitrators.size() > 0) { + List ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList()); + List arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList()); + String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(",")); + String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(",")); + caseApplication1.setArbitratorId(idstr); + caseApplication1.setArbitratorName(arbitratorNamestr); + } + //修改案件状态 + caseApplication1.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL_SUBMMIT); + //选择仲裁方式 + if (caseEvidenceDTO.getOpenCourtHear()==1){ //开庭审理 + caseApplication1.setArbitratMethod(1); + }else { + caseApplication1.setArbitratMethod(2); //书面审理 + } + int i = caseApplicationMapper.submitCaseApplication(caseApplication1); + if (i > 0) { + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL_SUBMMIT,""); + + return AjaxResult.success("提交成功"); + } + } + return null; + } + + private List getCaseEvidenceVOList(String identityNum, List caseStatusList, Integer identityType) { + List caseListByRespondent = caseEvidenceMapper.getCaseListByRespondent(identityNum, caseStatusList, identityType); + if (caseListByRespondent != null && caseListByRespondent.size() > 0) { + for (CaseEvidenceVO caseEvidenceVO : caseListByRespondent) { + //根据案件id查询姓名 + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseEvidenceVO.getId()); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); + for (CaseAffiliate affiliate : caseAffiliates) { + if (affiliate.getIdentityType() == 1) { //申请人 + caseEvidenceVO.setApplicantName(affiliate.getName()); + } else { + caseEvidenceVO.setRespondentName(affiliate.getName()); + } + } + } + return caseListByRespondent; + } + return null; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseLogRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseLogRecordServiceImpl.java new file mode 100644 index 0000000..30356f2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseLogRecordServiceImpl.java @@ -0,0 +1,47 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; +import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper; +import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CaseLogRecordServiceImpl implements ICaseLogRecordService { + @Autowired + private CaseLogRecordMapper caseLogRecordMapper; + + + @Override + public List selectCaseLogRecordList(CaseLogRecord caseLogRecord) { + List records = caseLogRecordMapper.selectCaseLogRecordList(caseLogRecord); + if(CollectionUtil.isNotEmpty(records)){ + records.forEach(record->{ + StringBuilder contentBuilder = new StringBuilder(); + String caseNodeTime=""; + if(record.getCaseNodeTime()!=null){ + caseNodeTime= DateUtil.format(record.getCaseNodeTime(), DatePattern.NORM_DATETIME_FORMATTER); + } + + contentBuilder.append(record.getCreateNickName()).append("(").append(record.getCreateBy()).append(")").append("于").append(caseNodeTime); + if(StrUtil.isNotEmpty(record.getContent())){ + contentBuilder.append(record.getContent()); + } + record.setContent(contentBuilder.toString()); + + }); + } + return records; + } + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java new file mode 100644 index 0000000..3841ec8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java @@ -0,0 +1,138 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + + +import com.ruoyi.ElegentPay; +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.common.utils.SmsUtils; +import com.ruoyi.dto.PayRequest; +import com.ruoyi.dto.PayResponse; +import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.CasePaymentRecord; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; +import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper; +import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper; +import com.ruoyi.wisdomarbitrate.mapper.CasePaymentRecordMapper; +import com.ruoyi.wisdomarbitrate.service.ICasePaymentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +@Service +public class CasePaymentServiceImpl implements ICasePaymentService { + private final ElegentPay elegentPay; + private final CaseApplicationMapper caseApplicationMapper; + private final CasePaymentRecordMapper casePaymentRecordMapper; + private final CaseAffiliateMapper caseAffiliateMapper; + + @Autowired + public CasePaymentServiceImpl(ElegentPay elegentPay + , CaseApplicationMapper caseApplicationMapper + , CasePaymentRecordMapper casePaymentRecordMapper + , CaseAffiliateMapper caseAffiliateMapper) { + this.elegentPay = elegentPay; + this.caseApplicationMapper = caseApplicationMapper; + this.casePaymentRecordMapper = casePaymentRecordMapper; + this.caseAffiliateMapper = caseAffiliateMapper; + } + + @Override + @Transactional + public AjaxResult casePay(CasePayDTO casePayDTO) { + PayRequest payRequest = new PayRequest(); + payRequest.setBody("案件缴费"); + payRequest.setOrderSn(System.currentTimeMillis() + ""); + payRequest.setTotalFee(casePayDTO.getTotalFee()); + PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform()); + if (response.getCode_url() == null) { + return AjaxResult.error(); + } + //缴费记录表里新增数据 + CasePaymentRecord casePaymentRecord = new CasePaymentRecord(); + casePaymentRecord.setCaseId(casePayDTO.getCaseId()); + casePaymentRecord.setOrderNumber(payRequest.getOrderSn()); + casePaymentRecord.setPaymentStatus(0); + casePaymentRecord.setCreateTime(new Date()); + int count = casePaymentRecordMapper.saveRecord(casePaymentRecord); + if (count < 1) { + return AjaxResult.error("请检查参数是否有误"); + } + return AjaxResult.success(response); + } + + @Transactional + public AjaxResult callback(String orderNumber) { + //查询记录 + CasePaymentRecord casePaymentRecord = casePaymentRecordMapper.queryRecord(orderNumber); + if (casePaymentRecord == null) { + return AjaxResult.error("未查询到相关记录"); + } + Long caseId = casePaymentRecord.getCaseId(); + //更改记录表里的支付状态和支付时间 + casePaymentRecord.setPaymentStatus(1); + casePaymentRecord.setPaymentTime(new Date()); + casePaymentRecord.setUpdateTime(new Date()); + casePaymentRecordMapper.update(casePaymentRecord); + //根据案件id查询案件信息 + CaseApplication caseApplication = new CaseApplication(); + caseApplication.setId(caseId); + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + caseApplication1.setCaseStatus(CaseApplicationConstants.PENDING_PAYMENT_CONFIRM); + //修改案件状态 + caseApplicationMapper.submitCaseApplication(caseApplication1); + return AjaxResult.success("支付成功"); + } + + @Override + @Transactional + public AjaxResult confirmPayment(CaseApplication caseApplication) { + caseApplication.setCaseStatus(CaseApplicationConstants.CASE_CROSSEXAMI); + int i = caseApplicationMapper.submitCaseApplication(caseApplication); + if (i > 0) { + //发送短信通知 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + CaseAffiliate caseAffiliate = new CaseAffiliate(); + caseAffiliate.setCaseAppliId(caseApplication.getId()); + List caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); //获取案件关联人信息 + if (caseAffiliates != null && caseAffiliates.size() > 0) { + for (CaseAffiliate affiliate : caseAffiliates) { + //获取身份类型 + int identityType = affiliate.getIdentityType(); + //查询案件详细信息 + CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); + if (caseApplication1 == null) { + return AjaxResult.error(); + } + String caseName = "仲裁"; //这里案件名称表里未定义,暂时写死 + String caseNum = caseApplication1.getCaseNum(); + if (identityType == 1) { //申请人 + request.setPhone(affiliate.getContactTelphone()); + request.setTemplateId("1928003"); //传入申请人模板id + // 这个值,要看你的模板中是否预留了占位符,如果没有则不需要设置 + // 模板id:1928003 普通短信 案件受理通知 尊敬的{1}用户,您的{2}案件{3}已成功受理。 + String name = affiliate.getName(); + request.setTemplateParamSet(new String[]{name, caseName, caseNum}); + SmsUtils.sendSms(request); + } else { //被申请人 + request.setPhone(affiliate.getContactTelphone()); + request.setTemplateId("1928006"); + // 模板id1928006 普通短信 案件应诉通知 尊敬的{1}用户,您的{2}案件{3}已成功受理,请点击https://phmapp.xayunmei.com选择是否应诉。 + String name = affiliate.getName(); + request.setTemplateParamSet(new String[]{name, caseName, caseNum}); + SmsUtils.sendSms(request); + } + } + // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(),CaseApplicationConstants.CASE_CROSSEXAMI,""); + + return AjaxResult.success(); + } + } + return AjaxResult.error("暂无需要确认的缴费清单"); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/IdentityAuthenticationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/IdentityAuthenticationServiceImpl.java new file mode 100644 index 0000000..168a223 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/IdentityAuthenticationServiceImpl.java @@ -0,0 +1,221 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + + +import cn.hutool.core.codec.Base64; +import cn.hutool.crypto.SmUtil; +import cn.hutool.crypto.asymmetric.SM2; +import cn.hutool.crypto.symmetric.SymmetricCrypto; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication; +import com.ruoyi.wisdomarbitrate.mapper.IdentityAuthenticationMapper; +import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService; +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.faceid.v20180301.FaceidClient; +import com.tencentcloudapi.faceid.v20180301.models.GetEidResultRequest; +import com.tencentcloudapi.faceid.v20180301.models.GetEidResultResponse; +import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenRequest; +import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +@Service +public class IdentityAuthenticationServiceImpl implements IdentityAuthenticationService { + + @Value("${identityAuthentication.credentialSecretId}") + private String credentialSecretId; + @Value("${identityAuthentication.credentialSecretKey}") + private String credentialSecretKey; + @Value("${identityAuthentication.merchantId}") + private String merchantId; + @Value("${identityAuthentication.privateKeyHexDecodeinfo}") + private String privateKeyHexDecodeinfo; + + + @Autowired + private IdentityAuthenticationMapper identityAuthenticationMapper; + + private static final Logger log = LoggerFactory.getLogger(IdentityAuthenticationServiceImpl.class); + + + @Override + public IdentityAuthentication selectIdentityAuthentication(IdentityAuthentication identityAuthentication) { + IdentityAuthentication identityAuthenticationselect = identityAuthenticationMapper.selectIdentityAuthentication(identityAuthentication); + if (identityAuthenticationselect != null) { + identityAuthenticationselect.setCertificationStatusName("已身份认证"); + } else { + IdentityAuthentication identityAuthenticationselectnew = new IdentityAuthentication(); + identityAuthenticationselectnew.setCertificationStatusName("未身份认证"); + identityAuthenticationselectnew.setCertificationStatus(0); + return identityAuthenticationselectnew; + } + return identityAuthenticationselect; + + } + + /** + * 检查是否已经认证的用户 + * + * @param identityAuthentication + * @return + */ + @Override + public String checkIsAuthentication(IdentityAuthentication identityAuthentication) { + IdentityAuthentication identityAuthenticationselect = identityAuthenticationMapper.selectIdentityAuthentication(identityAuthentication); + if (identityAuthenticationselect != null) { + return "1"; + } else { + return "0"; + } + } + + /** + * 获取EIDtoken + * + * @return + */ + @Override + public JSONObject selectIdentityAuthenticaEIDtoken() { + JSONObject objJSON = new JSONObject(); + objJSON.put("EidToken", ""); + try { + Credential cred = new Credential(credentialSecretId, credentialSecretKey); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("faceid.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + FaceidClient client = new FaceidClient(cred, "", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + GetEidTokenRequest req = new GetEidTokenRequest(); + req.setMerchantId(merchantId); + // 返回的resp是一个GetEidTokenResponse的实例,与请求对象对应 + GetEidTokenResponse resp = client.GetEidToken(req); + // 输出json格式的字符串回包 + String respJSON = GetEidTokenResponse.toJsonString(resp); + objJSON = JSON.parseObject(respJSON); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + System.out.println("获取Eidtoken失败"); + } + return objJSON; + } + + /** + * 解密用户信息 + */ + public JSONObject DecodeUserInfo(String deskey, String userInfo) { + JSONObject parse = null; + try { + byte[] desKeyBytes = Base64.decode(deskey); + final SM2 sm2 = new SM2(privateKeyHexDecodeinfo, null, null); + sm2.usePlainEncoding(); + byte[] sm4KeyBytes = sm2.decrypt(desKeyBytes); + SymmetricCrypto sm4 = SmUtil.sm4(sm4KeyBytes); + byte[] plaintext = sm4.decrypt(Base64.decode(userInfo)); + if (plaintext != null && plaintext.length > 0) { + String s = new String(plaintext); + parse = JSON.parseObject(s); + } + } catch (Exception e) { + System.out.println(e.toString()); + } + return parse; + } + + /** + * 小程序人脸核身后查询身份认证结果 + * + * @param ientityAuthentication + * @return + */ + @Override + @Transactional + public AjaxResult selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication) { + String eidToken = ientityAuthentication.getEidToken(); + + try { + Credential cred = new Credential(credentialSecretId, credentialSecretKey); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("faceid.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + FaceidClient client = new FaceidClient(cred, "", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + GetEidResultRequest req = new GetEidResultRequest(); + req.setEidToken(eidToken); + // 返回的resp是一个GetEidResultResponse的实例,与请求对象对应 + GetEidResultResponse resp = client.GetEidResult(req); + // 输出json格式的字符串回包 + String s = GetEidResultResponse.toJsonString(resp); + JSONObject objJSON = JSON.parseObject(s); + //查看是否核验成功 + JSONObject text = objJSON.getJSONObject("Text"); + if (text != null) { + Integer comparestatus = text.getInteger("Comparestatus"); + if (comparestatus != null && comparestatus == 0) { + JSONObject eidInfo = objJSON.getJSONObject("EidInfo"); + if (eidInfo != null) { + String desKey = eidInfo.getString("DesKey"); + String userInfo = eidInfo.getString("UserInfo"); + //1.解密用户的信息 + JSONObject info = DecodeUserInfo(desKey, userInfo); + if (info != null) { + String idcardno = info.getString("idnum"); + String name = info.getString("name"); + //2.在用户认证表中插入用户认证记录 + LoginUser loginUser = SecurityUtils.getLoginUser(); + IdentityAuthentication authentication = new IdentityAuthentication(); + /** + * 用户名 + * 用户名id + * 姓名 + * 身份证号 + * 认证时间 + * 认证状态0表示成功 + * 请求id + */ + authentication.setUserName(loginUser.getUsername()); + authentication.setUserId(loginUser.getUserId()); + authentication.setName(name); + authentication.setIdentityNo(idcardno); + authentication.setCertificationTime(new Date()); + authentication.setCertificationStatus(0); + authentication.setCreateBy(loginUser.getUsername()); + try { + identityAuthenticationMapper.insertIdentityAuthentication(authentication); + } catch (Exception e) { + System.out.println("认证记录新增失败"); + } + + } + + } + } + } + return AjaxResult.success(); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + } + return null; + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java new file mode 100644 index 0000000..7781461 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java @@ -0,0 +1,42 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import cn.hutool.extra.spring.SpringUtil; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord; +import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * 案件记录日志文件 + * + * @author wangqiong + */ +public class CaseLogUtils +{ + private static CaseLogRecordMapper caseLogRecordMapper= SpringUtil.getBean(CaseLogRecordMapper.class); + + /** + * 新增案件日志 + * @param caseAppliId 案件id,不能为空 + * @param caseNode 案件节点,不能为空 + * @param notes 备注 + */ + public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode, String notes ){ + // 获取当前的用户 + LoginUser loginUser = SecurityUtils.getLoginUser(); + String nickName = loginUser.getUser().getNickName(); + CaseLogRecord operLog = new CaseLogRecord(); + operLog.setCreateBy(loginUser.getUsername()); + operLog.setCreateNickName(nickName); + operLog.setUpdateBy(loginUser.getUsername()); + operLog.setCaseAppliId(caseAppliId); + operLog.setCaseNode(caseNode); + operLog.setNotes(notes); + caseLogRecordMapper.insertCaseLogRecord(operLog); + } + + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index cf439f6..3e0f228 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -87,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 - + insert into sys_dept( dept_id, parent_id, @@ -112,7 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{createBy}, sysdate() - ) + ); diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitrateRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitrateRecordMapper.xml new file mode 100644 index 0000000..795e630 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitrateRecordMapper.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + insert into arbitrate_record( + case_appli_id, + eviden_determi, + fact_determi, + case_sketch, + ruling_follows, + verifica_opinion, + arbitrate_think, + + check_opinion, + create_by, + create_time + )values( + #{caseAppliId}, + #{evidenDetermi}, + #{factDetermi}, + #{caseSketch}, + #{rulingFollows}, + #{verificaOpinion}, + #{arbitrateThink}, + #{checkOpinion}, + #{createBy}, + sysdate() + ) + + + + + update arbitrate_record + + eviden_determi = #{evidenDetermi}, + fact_determi = #{factDetermi}, + case_sketch = #{caseSketch}, + arbitrate_think = #{arbitrateThink}, + ruling_follows = #{rulingFollows}, + verifica_opinion = #{verificaOpinion}, + check_opinion = #{checkOpinion}, + annex_id = #{annexId}, + update_by = #{updateBy}, + update_time = sysdate() + + where id = #{id} + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitratorMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitratorMapper.xml new file mode 100644 index 0000000..e394d00 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ArbitratorMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml new file mode 100644 index 0000000..90258bb --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into case_affiliate(case_appli_id, identity_type,name,identity_num,contact_telphone, + contact_address,work_address,work_telphone ,name_agent,identity_num_agent,contact_telphone_agent, + contact_address_agent ) values + + (#{item.caseAppliId},#{item.identityType},#{item.name},#{item.identityNum},#{item.contactTelphone}, + #{item.contactAddress},#{item.workAddress},#{item.workTelphone}, #{item.nameAgent},#{item.identityNumAgent}, + #{item.contactTelphoneAgent},#{item.contactAddressAgent}) + + + + + + + update case_affiliate + set + case_appli_id=#{caseAppliId}, + identity_type= #{identityType}, + name = #{name}, + identity_num = #{identityNum}, + contact_telphone = #{contactTelphone}, + contact_address = #{contactAddress}, + work_address = #{workAddress}, + work_telphone = #{workTelphone}, + + name_agent = #{nameAgent}, + identity_num_agent = #{identityNumAgent}, + contact_telphone_agent = #{contactTelphoneAgent}, + contact_address_agent = #{contactAddressAgent}, + send_email = #{sendEmail}, + track_num = #{trackNum} + + where id = #{id} + + + + + delete from case_affiliate where case_appli_id = #{id} + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml new file mode 100644 index 0000000..884805e --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into case_application( + + case_num, + case_subject_amount, + register_date, + arbitrat_method, + case_status, + hear_date, + arbitrat_claims, + loan_start_date, + loan_end_date, + claim_princi_owed, + + claim_interest_owed, + claim_liquid_damag, + fee_payable, + begin_video_date, + online_video_person, + + contract_number, + create_by, + create_time + )values( + #{caseNum}, + #{caseSubjectAmount}, + sysdate(), + #{arbitratMethod}, + #{caseStatus}, + #{hearDate}, + #{arbitratClaims}, + #{loanStartDate}, + #{loanEndDate}, + #{claimPrinciOwed}, + + #{claimInterestOwed}, + #{claimLiquidDamag}, + #{feePayable}, + #{beginVideoDate}, + #{onlineVideoPerson}, + + #{contractNumber}, + #{createBy}, + sysdate() + ) + + + + update case_application + + case_subject_amount = #{caseSubjectAmount}, + register_date = #{registerDate}, + arbitrat_method = #{arbitratMethod}, + hear_date = #{hearDate}, + arbitrat_claims = #{arbitratClaims}, + loan_start_date = #{loanStartDate}, + loan_end_date = #{loanEndDate}, + claim_princi_owed = #{claimPrinciOwed}, + claim_interest_owed = #{claimInterestOwed}, + claim_liquid_damag = #{claimLiquidDamag}, + fee_payable = #{feePayable}, + begin_video_date = #{beginVideoDate}, + online_video_person = #{onlineVideoPerson}, + + contract_number = #{contractNumber}, + + case_name = #{caseName}, + case_describe = #{caseDescribe}, + case_result = #{caseResult}, + case_status = #{caseStatus}, + + update_by = #{updateBy}, + case_num = #{caseNum}, + update_time = sysdate() + + where id = #{id} + + + + update case_application + + case_status = #{caseStatus}, + arbitrator_id = #{arbitratorId}, + arbitrator_name = #{arbitratorName}, + pending_appoint_arbotrar = #{pendingAppointArbotrar}, + arbitrat_method = #{arbitratMethod}, + case_name = #{caseName}, + case_describe = #{caseDescribe}, + case_result = #{caseResult}, + is_agree_pend_tral = #{isAgreePendTral}, + objection_add_eviden = #{objectionAddEviden}, + open_court_hear = #{openCourtHear}, + hear_date = #{hearDate}, + + where id = #{id} + + + + delete from case_application where id = #{id} + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachMapper.xml new file mode 100644 index 0000000..5b9b821 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + INSERT INTO case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account) + VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{userId},#{userName}) + + + + + + + update case_attach + set + case_appli_id= #{caseAppliId} + where annex_id = #{annexId} + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseEvidenceMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseEvidenceMapper.xml new file mode 100644 index 0000000..3d925a6 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseEvidenceMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseLogRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseLogRecordMapper.xml new file mode 100644 index 0000000..ae6f859 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseLogRecordMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + insert into case_log_record(case_appli_id, case_node,case_node_time,notes,create_by,create_nick_name,create_time,update_by,update_time ) values( + #{caseAppliId},#{caseNode},sysdate(),#{notes},#{createBy},#{createNickName},sysdate(),#{updateBy},sysdate() + ) + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CasePaymentRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CasePaymentRecordMapper.xml new file mode 100644 index 0000000..a50bb99 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CasePaymentRecordMapper.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + INSERT INTO case_payment_record (case_id, order_number, payment_status , create_time) + VALUES (#{caseId}, #{orderNumber}, #{paymentStatus},#{createTime}) + + + update case_payment_record + + case_id= #{caseId}, + order_number = #{orderNumber}, + payment_time = #{paymentTime}, + payment_status = #{paymentStatus}, + update_time = #{updateTime}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/IdentityAuthenticationMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/IdentityAuthenticationMapper.xml new file mode 100644 index 0000000..ebd2422 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/IdentityAuthenticationMapper.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + insert into identi_authenti( + user_id, + name, + identity_no, + certification_time, + certification_status, + user_name, + create_by, + create_time + )values( + #{userId}, + #{name}, + #{identityNo}, + sysdate(), + #{certificationStatus}, + #{userName}, + #{createBy}, + sysdate() + ) + + + + + + + + + + + + + + \ No newline at end of file