Skip to content

Commit acdc6b3

Browse files
committed
1.银联 订单金额精度丢失问题 2.版本升级,日志部分放至父类声明
1 parent 353ecf3 commit acdc6b3

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

pay-java-union/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>pay-java-parent</artifactId>
77
<groupId>com.egzosn</groupId>
8-
<version>2.11.3</version>
8+
<version>2.12.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

pay-java-union/src/main/java/com/egzosn/pay/union/api/UnionPayService.java

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import com.egzosn.pay.common.util.sign.encrypt.RSA2;
1616
import com.egzosn.pay.union.bean.UnionTransactionType;
1717
import com.egzosn.pay.union.bean.SDKConstants;
18-
import org.apache.commons.logging.Log;
19-
import org.apache.commons.logging.LogFactory;
2018

2119
import java.awt.image.BufferedImage;
2220
import java.io.ByteArrayInputStream;
@@ -35,7 +33,6 @@
3533
* </pre>
3634
*/
3735
public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
38-
private static final Log log = LogFactory.getLog(UnionPayService.class);
3936
/**
4037
* 测试域名
4138
*/
@@ -54,8 +51,8 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
5451
private static final String FILE_TRANS_URL= "https://filedownload.%s/";
5552
private static final String APP_TRANS_URL= "https://gateway.%s/gateway/api/appTransReq.do";
5653
private static final String CARD_TRANS_URL= "https://gateway.%s/gateway/api/cardTransReq.do";
57-
public final static DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
58-
{
54+
public static final DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
55+
static {
5956
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
6057
}
6158

@@ -158,7 +155,7 @@ private Map<String, Object> getCommonParam() {
158155
public boolean verify(Map<String, Object> result) {
159156

160157
if (null == result || result.get(SDKConstants.param_signature) == null) {
161-
log.debug("银联支付验签异常:params:" + result);
158+
LOG.debug("银联支付验签异常:params:" + result);
162159
return false;
163160
}
164161
return this.signVerify(result, (String) result.get(SDKConstants.param_signature));
@@ -282,11 +279,11 @@ private Map<String, Object> setSign(Map<String, Object> parameters){
282279
case SM3:
283280
String key = payConfigStorage.getKeyPrivate();
284281
signStr = SignUtils.parameterText(parameters, "&", "signature");
285-
key = signUtils.createSign(key,"",payConfigStorage.getInputCharset()) + "&";
282+
key = signUtils.createSign(key,"",payConfigStorage.getInputCharset()) + "&";
286283
parameters.put(SDKConstants.param_signature, signUtils.createSign(signStr, key, payConfigStorage.getInputCharset()));
287284
break;
288285
default:
289-
throw new PayErrorException(new PayException("sign fail", "未找到的签名类型"));
286+
throw new PayErrorException(new PayException("sign fail", "未找到的签名类型"));
290287
}
291288

292289

@@ -327,17 +324,16 @@ private X509Certificate verifyCertificate (X509Certificate cert) {
327324
CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
328325

329326
@SuppressWarnings("unused")
330-
PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder
331-
.build(pkixParams);
327+
PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder.build(pkixParams);
332328
return cert;
333329
} catch (java.security.cert.CertPathBuilderException e) {
334-
log.error("verify certificate chain fail.", e);
330+
LOG.error("verify certificate chain fail.", e);
335331
} catch (CertificateExpiredException e) {
336-
log.error(e);
332+
LOG.error(e);
337333
} catch (CertificateNotYetValidException e) {
338-
log.error(e);
334+
LOG.error(e);
339335
} catch (Exception e) {
340-
log.error(e);
336+
LOG.error(e);
341337
}
342338
return null;
343339
}
@@ -358,11 +354,11 @@ public BufferedImage genQrPay (PayOrder order) {
358354
if(this.verify(response)){
359355
if(SDKConstants.OK_RESP_CODE.equals(response.get(SDKConstants.param_respCode))){
360356
//成功,获取tn号
361-
return MatrixToImageWriter.writeInfoToJpgBuff((String)response.get(SDKConstants.param_qrCode));
357+
return MatrixToImageWriter.writeInfoToJpgBuff((String)response.get(SDKConstants.param_qrCode));
362358
}
363-
throw new PayErrorException(new PayException((String)response.get(SDKConstants.param_respCode), (String)response.get(SDKConstants.param_respMsg), responseStr));
359+
throw new PayErrorException(new PayException((String)response.get(SDKConstants.param_respCode), (String)response.get(SDKConstants.param_respMsg), responseStr));
364360
}
365-
throw new PayErrorException(new PayException("failure", "验证签名失败", responseStr));
361+
throw new PayErrorException(new PayException("failure", "验证签名失败", responseStr));
366362
}
367363

368364
/**
@@ -393,7 +389,7 @@ public static X509Certificate genCertificateByStr(String x509CertString) {
393389
x509CertString.getBytes("ISO-8859-1"));
394390
x509Cert = (X509Certificate) cf.generateCertificate(tIn);
395391
} catch (Exception e) {
396-
log.error("gen certificate error", e);
392+
throw new PayErrorException(new PayException("证书加载失败", "gen certificate error:"+e.getLocalizedMessage() ));
397393
}
398394
return x509Cert;
399395
}
@@ -519,7 +515,7 @@ public Map<String, Object> unionRefundOrConsumeUndo (RefundOrder refundOrder,Uni
519515
JSONObject response = UriVariables.getParametersToMap(responseStr);
520516
if(this.verify(response)){
521517
if(SDKConstants.OK_RESP_CODE.equals(response.getString(SDKConstants.param_respCode))){
522-
String origRespCode = response.getString(SDKConstants.param_origRespCode);
518+
// String origRespCode = response.getString(SDKConstants.param_origRespCode);
523519
//交易成功,更新商户订单状态
524520
//TODO
525521
return response;
@@ -538,7 +534,7 @@ public Map<String, Object> unionRefundOrConsumeUndo (RefundOrder refundOrder,Uni
538534
*/
539535
@Override
540536
public Map<String, Object> close (String tradeNo, String outTradeNo) {
541-
return Collections.emptyMap();
537+
return Collections.emptyMap();
542538
}
543539

544540
/**
@@ -574,7 +570,7 @@ public Map<String, Object> refund(RefundOrder refundOrder) {
574570
*/
575571
@Override
576572
public Map<String, Object> refundquery (String tradeNo, String outTradeNo) {
577-
return Collections.emptyMap();
573+
return Collections.emptyMap();
578574
}
579575

580576

@@ -631,7 +627,7 @@ public Map<String, Object> downloadbill (Date billDate, String billType) {
631627
*/
632628
@Override
633629
public Map<String, Object> secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType) {
634-
return Collections.emptyMap();
630+
return Collections.emptyMap();
635631
}
636632

637633
/**

0 commit comments

Comments
 (0)