From 74a6cc733941e861142e13da185d6e9062d316e5 Mon Sep 17 00:00:00 2001 From: egzosn Date: Wed, 24 Oct 2018 12:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=81=94=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../egzosn/pay/union/api/UnionPayService.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/pay-java-union/src/main/java/com/egzosn/pay/union/api/UnionPayService.java b/pay-java-union/src/main/java/com/egzosn/pay/union/api/UnionPayService.java index 599caff..7b3d62b 100644 --- a/pay-java-union/src/main/java/com/egzosn/pay/union/api/UnionPayService.java +++ b/pay-java-union/src/main/java/com/egzosn/pay/union/api/UnionPayService.java @@ -227,7 +227,7 @@ public class UnionPayService extends BasePayService { case WAP: case WEB: case B2B: - params.put(SDKConstants.param_txnAmt, order.getPrice().multiply(new BigDecimal(100))); + params.put(SDKConstants.param_txnAmt,conversion(order.getPrice())); params.put("orderDesc", order.getSubject()); // 订单超时时间。 // 超过此时间后,除网银交易外,其他交易银联系统会拒绝受理,提示超时。 跳转银行网银交易如果超时后交易成功,会自动退款,大约5个工作日金额返还到持卡人账户。 @@ -241,7 +241,7 @@ public class UnionPayService extends BasePayService { params.put(SDKConstants.param_frontUrl, payConfigStorage.getReturnUrl()); break; case CONSUME: - params.put(SDKConstants.param_txnAmt, order.getPrice().multiply(new BigDecimal(100))); + params.put(SDKConstants.param_txnAmt,conversion(order.getPrice())); params.put(SDKConstants.param_qrNo, order.getAuthCode()); break; default: @@ -282,11 +282,11 @@ public class UnionPayService extends BasePayService { case SM3: String key = payConfigStorage.getKeyPrivate(); signStr = SignUtils.parameterText(parameters, "&", "signature"); - key = signUtils.createSign(key,"",payConfigStorage.getInputCharset()) + "&"; + key = signUtils.createSign(key,"",payConfigStorage.getInputCharset()) + "&"; parameters.put(SDKConstants.param_signature, signUtils.createSign(signStr, key, payConfigStorage.getInputCharset())); break; default: - throw new PayErrorException(new PayException("sign fail", "未找到的签名类型")); + throw new PayErrorException(new PayException("sign fail", "未找到的签名类型")); } @@ -358,11 +358,11 @@ public class UnionPayService extends BasePayService { if(this.verify(response)){ if(SDKConstants.OK_RESP_CODE.equals(response.get(SDKConstants.param_respCode))){ //成功,获取tn号 - return MatrixToImageWriter.writeInfoToJpgBuff((String)response.get(SDKConstants.param_qrCode)); + return MatrixToImageWriter.writeInfoToJpgBuff((String)response.get(SDKConstants.param_qrCode)); } - throw new PayErrorException(new PayException((String)response.get(SDKConstants.param_respCode), (String)response.get(SDKConstants.param_respMsg), responseStr)); + throw new PayErrorException(new PayException((String)response.get(SDKConstants.param_respCode), (String)response.get(SDKConstants.param_respMsg), responseStr)); } - throw new PayErrorException(new PayException("failure", "验证签名失败", responseStr)); + throw new PayErrorException(new PayException("failure", "验证签名失败", responseStr)); } /** @@ -538,7 +538,7 @@ public class UnionPayService extends BasePayService { */ @Override public Map close (String tradeNo, String outTradeNo) { - return Collections.emptyMap(); + return Collections.emptyMap(); } /** @@ -574,7 +574,7 @@ public class UnionPayService extends BasePayService { */ @Override public Map refundquery (String tradeNo, String outTradeNo) { - return Collections.emptyMap(); + return Collections.emptyMap(); } @@ -631,9 +631,15 @@ public class UnionPayService extends BasePayService { */ @Override public Map secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType) { - return Collections.emptyMap(); + return Collections.emptyMap(); } - - + /** + * 元转分 + * @param amount 元的金额 + * @return 分的金额 + */ + public int conversion(BigDecimal amount){ + return amount.multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + } }