Authored by LUOXC

一个证书之使用一个HTTPCLIENT

@@ -17,13 +17,13 @@ public class WeixinPayConfig { @@ -17,13 +17,13 @@ public class WeixinPayConfig {
17 17
18 /**微信支付UFO商户号正式**/ 18 /**微信支付UFO商户号正式**/
19 public static final String APP_ID_UFO_REAL = "wx75b18b98bdd92bbc"; 19 public static final String APP_ID_UFO_REAL = "wx75b18b98bdd92bbc";
20 - public static final String PARTNER_ID = "1516774631";  
21 - public static final String WECHAT_PAY_UFOREAL_APP_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12"; 20 + public static final String UFO_PARTNER_ID = "1516774631";
  21 + public static final String UFO_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12";
22 22
23 public interface Miniapp{ 23 public interface Miniapp{
24 String APP_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12"; 24 String APP_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12";
25 String APPID = "wxc677c88385762287"; 25 String APPID = "wxc677c88385762287";
26 - String MALL_ID = PARTNER_ID; 26 + String MALL_ID = UFO_PARTNER_ID;
27 } 27 }
28 28
29 //查询微信支付订单前缀 29 //查询微信支付订单前缀
@@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletResponse; @@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletResponse;
11 import com.yohobuy.ufo.model.order.bo.PaymentData; 11 import com.yohobuy.ufo.model.order.bo.PaymentData;
12 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService; 12 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
13 import com.yohoufo.order.service.pay.alipay.AbstractAlipayService; 13 import com.yohoufo.order.service.pay.alipay.AbstractAlipayService;
14 -import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;  
15 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse; 14 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse;
16 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService; 15 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
17 import org.apache.commons.lang.StringUtils; 16 import org.apache.commons.lang.StringUtils;
@@ -38,7 +37,7 @@ import com.yohoufo.order.model.response.PaymentConfirmRsp; @@ -38,7 +37,7 @@ import com.yohoufo.order.model.response.PaymentConfirmRsp;
38 import com.yohoufo.order.model.response.PrepayResponse; 37 import com.yohoufo.order.model.response.PrepayResponse;
39 import com.yohoufo.order.service.IPaymentService; 38 import com.yohoufo.order.service.IPaymentService;
40 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService; 39 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
41 -import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService; 40 +import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
42 41
43 @RestController 42 @RestController
44 @RequestMapping(value = "/payment") 43 @RequestMapping(value = "/payment")
@@ -59,7 +58,7 @@ public class PaymentController { @@ -59,7 +58,7 @@ public class PaymentController {
59 IPaymentService paymentService; 58 IPaymentService paymentService;
60 59
61 @Autowired 60 @Autowired
62 - WeixinPayUFORealAppService weixinPayAppService; 61 + UfoAppWeixinPayService ufoAppWeixinPayService;
63 62
64 @Autowired 63 @Autowired
65 AlipayOuyinService alipayService; 64 AlipayOuyinService alipayService;
@@ -201,7 +200,7 @@ public class PaymentController { @@ -201,7 +200,7 @@ public class PaymentController {
201 wechatLogger.info("[{}] notification received", out_trade_no); 200 wechatLogger.info("[{}] notification received", out_trade_no);
202 201
203 //回调验证 202 //回调验证
204 - if(!weixinPayAppService.notifyVerify(params)) { 203 + if(!ufoAppWeixinPayService.notifyVerify(params)) {
205 notifyResponse.setNotifyResult(NotifyResponse.PAYMENT_NOTIFY_RESULT_VERFAIL); 204 notifyResponse.setNotifyResult(NotifyResponse.PAYMENT_NOTIFY_RESULT_VERFAIL);
206 wechatLogger.error("[{}] notification verify failed", out_trade_no); 205 wechatLogger.error("[{}] notification verify failed", out_trade_no);
207 return ; 206 return ;
@@ -209,7 +208,7 @@ public class PaymentController { @@ -209,7 +208,7 @@ public class PaymentController {
209 208
210 PaymentData paymentData = null; 209 PaymentData paymentData = null;
211 try { 210 try {
212 - paymentData = weixinPayAppService.getPaymentData(params); 211 + paymentData = ufoAppWeixinPayService.getPaymentData(params);
213 212
214 // 支付回调,业务处理 213 // 支付回调,业务处理
215 paymentService.paySuccess(paymentData); 214 paymentService.paySuccess(paymentData);
@@ -9,8 +9,8 @@ import com.yohoufo.order.service.pay.alipay.AlipayOuyinService; @@ -9,8 +9,8 @@ import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
9 import com.yohoufo.order.service.pay.alipay.AlipayOuyinWapService; 9 import com.yohoufo.order.service.pay.alipay.AlipayOuyinWapService;
10 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService; 10 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
11 import com.yohoufo.order.service.pay.wallet.WalletPayService; 11 import com.yohoufo.order.service.pay.wallet.WalletPayService;
12 -import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;  
13 -import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService; 12 +import com.yohoufo.order.service.pay.weixin.MiniappWeixinPayService;
  13 +import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
14 import lombok.extern.slf4j.Slf4j; 14 import lombok.extern.slf4j.Slf4j;
15 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Component; 16 import org.springframework.stereotype.Component;
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component; @@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
20 public class PayServiceFactory { 20 public class PayServiceFactory {
21 21
22 @Autowired 22 @Autowired
23 - WeixinPayUFORealAppService weixinPayAppService; 23 + UfoAppWeixinPayService ufoAppWeixinPayService;
24 24
25 @Autowired 25 @Autowired
26 AlipayOuyinService alipayService; 26 AlipayOuyinService alipayService;
@@ -29,7 +29,7 @@ public class PayServiceFactory { @@ -29,7 +29,7 @@ public class PayServiceFactory {
29 AlipayCrossBorderService alipayCrossBorderService; 29 AlipayCrossBorderService alipayCrossBorderService;
30 30
31 @Autowired 31 @Autowired
32 - WeixinMiniappPayService weixinMiniappPayService; 32 + MiniappWeixinPayService miniappWeixinPayService;
33 33
34 @Autowired 34 @Autowired
35 WalletPayService walletPayService; 35 WalletPayService walletPayService;
@@ -57,11 +57,11 @@ public class PayServiceFactory { @@ -57,11 +57,11 @@ public class PayServiceFactory {
57 AbstractPayService payService = null; 57 AbstractPayService payService = null;
58 58
59 if (payment == Payment.WECHAT) { 59 if (payment == Payment.WECHAT) {
60 - payService = weixinPayAppService; 60 + payService = ufoAppWeixinPayService;
61 } else if (payment == Payment.ALIPAY || payment == Payment.ALIPAY_HB || payment == Payment.ALIPAY_HBFQ) { 61 } else if (payment == Payment.ALIPAY || payment == Payment.ALIPAY_HB || payment == Payment.ALIPAY_HBFQ) {
62 payService = alipayService; 62 payService = alipayService;
63 } else if (payment == Payment.MINIAPP) { 63 } else if (payment == Payment.MINIAPP) {
64 - payService = weixinMiniappPayService; 64 + payService = miniappWeixinPayService;
65 } else if (payment == Payment.WALLET) { 65 } else if (payment == Payment.WALLET) {
66 payService = walletPayService; 66 payService = walletPayService;
67 } else if(payment == Payment.UNION_PAY){ 67 } else if(payment == Payment.UNION_PAY){
@@ -28,7 +28,6 @@ import com.yohoufo.order.common.BillTradeStatus; @@ -28,7 +28,6 @@ import com.yohoufo.order.common.BillTradeStatus;
28 import com.yohoufo.order.common.HbfqEnum; 28 import com.yohoufo.order.common.HbfqEnum;
29 import com.yohoufo.order.common.TradeType; 29 import com.yohoufo.order.common.TradeType;
30 import com.yohoufo.order.common.TransferCase; 30 import com.yohoufo.order.common.TransferCase;
31 -import com.yohoufo.order.constants.ClearanceFailType;  
32 import com.yohoufo.order.constants.RefundContant; 31 import com.yohoufo.order.constants.RefundContant;
33 import com.yohoufo.order.model.PayQueryBo; 32 import com.yohoufo.order.model.PayQueryBo;
34 import com.yohoufo.order.model.PayRefundBo; 33 import com.yohoufo.order.model.PayRefundBo;
@@ -50,19 +49,15 @@ import com.yohoufo.order.service.handler.transfer.TransferChancelSelector; @@ -50,19 +49,15 @@ import com.yohoufo.order.service.handler.transfer.TransferChancelSelector;
50 import com.yohoufo.order.service.pay.AbstractPayService; 49 import com.yohoufo.order.service.pay.AbstractPayService;
51 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService; 50 import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
52 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService; 51 import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
53 -import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;  
54 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse; 52 import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse;
55 -import com.yohoufo.order.service.pay.alipay.bean.CustomsErrorMsg;  
56 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService; 53 import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
57 import com.yohoufo.order.service.pay.wallet.WalletPayService; 54 import com.yohoufo.order.service.pay.wallet.WalletPayService;
58 -import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;  
59 -import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService; 55 +import com.yohoufo.order.service.pay.weixin.MiniappWeixinPayService;
  56 +import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
60 import com.yohoufo.order.service.proxy.WalletTransferService; 57 import com.yohoufo.order.service.proxy.WalletTransferService;
61 -import com.yohoufo.order.service.support.CustomsSupportService;  
62 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 58 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
63 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 59 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
64 import com.yohoufo.order.service.transfer.TransferResult; 60 import com.yohoufo.order.service.transfer.TransferResult;
65 -import com.yohoufo.order.utils.LoggerUtils;  
66 import com.yohoufo.order.utils.PaymentHelper; 61 import com.yohoufo.order.utils.PaymentHelper;
67 import org.apache.commons.lang3.StringUtils; 62 import org.apache.commons.lang3.StringUtils;
68 import org.slf4j.Logger; 63 import org.slf4j.Logger;
@@ -110,7 +105,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -110,7 +105,7 @@ public class PaymentServiceImpl implements IPaymentService {
110 MerchantOrderPaymentService merchantOrderPaymentService; 105 MerchantOrderPaymentService merchantOrderPaymentService;
111 106
112 @Autowired 107 @Autowired
113 - WeixinPayUFORealAppService weixinPayAppService; 108 + UfoAppWeixinPayService ufoAppWeixinPayService;
114 109
115 @Autowired 110 @Autowired
116 AlipayOuyinService alipayService; 111 AlipayOuyinService alipayService;
@@ -137,7 +132,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -137,7 +132,7 @@ public class PaymentServiceImpl implements IPaymentService {
137 OrdersPayTransferMapper ordersPayTransferMapper; 132 OrdersPayTransferMapper ordersPayTransferMapper;
138 133
139 @Autowired 134 @Autowired
140 - WeixinMiniappPayService weixinMiniappPayService; 135 + MiniappWeixinPayService miniappWeixinPayService;
141 136
142 @Autowired 137 @Autowired
143 WalletPayService walletPayService; 138 WalletPayService walletPayService;
@@ -2,7 +2,7 @@ package com.yohoufo.order.service.pay.weixin; @@ -2,7 +2,7 @@ package com.yohoufo.order.service.pay.weixin;
2 2
3 import com.yohoufo.common.utils.HttpClient; 3 import com.yohoufo.common.utils.HttpClient;
4 import com.yohoufo.order.config.WeixinPayConfig; 4 import com.yohoufo.order.config.WeixinPayConfig;
5 -import com.yohoufo.order.service.pay.weixin.ssl.WxMiniappHttpSslClient; 5 +import com.yohoufo.order.service.pay.weixin.ssl.WxUfoHttpSslClient;
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
8 8
@@ -10,10 +10,10 @@ import org.springframework.stereotype.Service; @@ -10,10 +10,10 @@ import org.springframework.stereotype.Service;
10 * Created by chao.chen on 2018/11/9. 10 * Created by chao.chen on 2018/11/9.
11 */ 11 */
12 @Service 12 @Service
13 -public class WeixinMiniappPayService extends AbstractWeixinPayService { 13 +public class MiniappWeixinPayService extends AbstractWeixinPayService {
14 14
15 @Autowired 15 @Autowired
16 - private WxMiniappHttpSslClient wxMiniappHttpSslClient; 16 + private WxUfoHttpSslClient httpSslClient;
17 17
18 @Override 18 @Override
19 protected String getMchId() { 19 protected String getMchId() {
@@ -34,6 +34,6 @@ public class WeixinMiniappPayService extends AbstractWeixinPayService { @@ -34,6 +34,6 @@ public class WeixinMiniappPayService extends AbstractWeixinPayService {
34 34
35 @Override 35 @Override
36 protected HttpClient getSslHttpClient() { 36 protected HttpClient getSslHttpClient() {
37 - return wxMiniappHttpSslClient; 37 + return httpSslClient;
38 } 38 }
39 } 39 }
@@ -5,17 +5,17 @@ import org.springframework.stereotype.Service; @@ -5,17 +5,17 @@ import org.springframework.stereotype.Service;
5 5
6 import com.yohoufo.common.utils.HttpClient; 6 import com.yohoufo.common.utils.HttpClient;
7 import com.yohoufo.order.config.WeixinPayConfig; 7 import com.yohoufo.order.config.WeixinPayConfig;
8 -import com.yohoufo.order.service.pay.weixin.ssl.WxUFORealAppHttpSslClient; 8 +import com.yohoufo.order.service.pay.weixin.ssl.WxUfoHttpSslClient;
9 9
10 @Service 10 @Service
11 -public class WeixinPayUFORealAppService extends AbstractWeixinPayService { 11 +public class UfoAppWeixinPayService extends AbstractWeixinPayService {
12 12
13 @Autowired 13 @Autowired
14 - private WxUFORealAppHttpSslClient httpSslClient; 14 + private WxUfoHttpSslClient httpSslClient;
15 15
16 @Override 16 @Override
17 protected String getMchId() { 17 protected String getMchId() {
18 - return WeixinPayConfig.PARTNER_ID; 18 + return WeixinPayConfig.UFO_PARTNER_ID;
19 } 19 }
20 20
21 21
@@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 import javax.net.ssl.HostnameVerifier; 18 import javax.net.ssl.HostnameVerifier;
19 import javax.net.ssl.SSLContext; 19 import javax.net.ssl.SSLContext;
20 20
21 -public abstract class HttpSslClientAbstract extends HttpClient { 21 +public abstract class AbstractHttpSslClient extends HttpClient {
22 22
23 //最大总数 23 //最大总数
24 private final int sslMaxTotal = 10; 24 private final int sslMaxTotal = 10;
1 -package com.yohoufo.order.service.pay.weixin.ssl;  
2 -  
3 -import com.yohoufo.order.config.WeixinPayConfig;  
4 -import org.springframework.stereotype.Component;  
5 -  
6 -/**  
7 - * Created by chao.chen on 2018/11/9.  
8 - */  
9 -@Component  
10 -public class WxMiniappHttpSslClient extends HttpSslClientAbstract {  
11 - @Override  
12 - protected String getMchId() {  
13 - return WeixinPayConfig.Miniapp.MALL_ID;  
14 - }  
15 -  
16 - @Override  
17 - protected String getMchCertPath() {  
18 - return WeixinPayConfig.Miniapp.APP_PARTNER_CERT;  
19 - }  
20 -  
21 -}  
@@ -4,16 +4,16 @@ import com.yohoufo.order.config.WeixinPayConfig; @@ -4,16 +4,16 @@ import com.yohoufo.order.config.WeixinPayConfig;
4 import org.springframework.stereotype.Component; 4 import org.springframework.stereotype.Component;
5 5
6 @Component 6 @Component
7 -public class WxUFORealAppHttpSslClient extends HttpSslClientAbstract { 7 +public class WxUfoHttpSslClient extends AbstractHttpSslClient {
8 8
9 @Override 9 @Override
10 protected String getMchId() { 10 protected String getMchId() {
11 - return WeixinPayConfig.PARTNER_ID; 11 + return WeixinPayConfig.UFO_PARTNER_ID;
12 } 12 }
13 13
14 @Override 14 @Override
15 protected String getMchCertPath() { 15 protected String getMchCertPath() {
16 - return WeixinPayConfig.WECHAT_PAY_UFOREAL_APP_PARTNER_CERT; 16 + return WeixinPayConfig.UFO_PARTNER_CERT;
17 } 17 }
18 18
19 } 19 }