From ff9f5a16a70331b51cfc7a27d30fa0e3dbd69363 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Sun, 2 Sep 2018 20:25:06 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=80=80=E6=AC=BE][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxRefundOrderController.java | 8 +++---- .../com/simple/domain/po/WxPayAccount.java | 22 +++++++++++++++---- .../impl/WxRefundOrderServiceImpl.java | 12 +++++++--- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java b/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java index 89239c4db..fc9b9f350 100644 --- a/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java +++ b/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java @@ -88,12 +88,12 @@ public class WxRefundOrderController extends BaseController { try { payOrder = wxPayOrderService.getByObj(payOrderQ); } catch (Exception e) { - logger.error("payOrder不存在"); - return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND.getCode(), "支付订单不存在,无法退款"); + logger.error("支付订单不存在(payOrder不存在)"); + return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); } if (payOrder == null) { - logger.error("payOrder不存在"); - return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND.getCode(), "支付订单不存在,无法退款"); + logger.error("支付订单不存在(payOrder不存在)"); + return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); } WxRefundOrder refundOrderQ = new WxRefundOrder(); diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/simple/domain/po/WxPayAccount.java index 7da35bddd..1124cea4a 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxPayAccount.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxPayAccount.java @@ -54,6 +54,9 @@ public class WxPayAccount implements Serializable { /*证书本地存放位置**/ @io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath") private String certPath; + /*证书密码**/ + @io.swagger.annotations.ApiModelProperty(value="证书密码",name="certPass") + private String certPass; public String getMchId() { return mchId; } @@ -79,6 +82,14 @@ public class WxPayAccount implements Serializable { certPath = _certPath; } + public String getCertPass() { + return certPass; + } + + public void setCertPass(String certPass) { + this.certPass = certPass; + } + public String getPayNotifyUrl() { return notifyUrl + "/pay"; } @@ -92,10 +103,11 @@ public class WxPayAccount implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,MchId_ASC("`mchId` ASC"),MchId_DESC("`mchId` DESC") - ,ApiKey_ASC("`apiKey` ASC"),ApiKey_DESC("`apiKey` DESC") - ,NotifyUrl_ASC("`notifyUrl` ASC"),NotifyUrl_DESC("`notifyUrl` DESC") - ,CertPath_ASC("`certPath` ASC"),CertPath_DESC("`certPath` DESC") + ,MchId_ASC("`mch_id` ASC"),MchId_DESC("`mch_id` DESC") + ,ApiKey_ASC("`api_key` ASC"),ApiKey_DESC("`api_key` DESC") + ,NotifyUrl_ASC("`notify_url` ASC"),NotifyUrl_DESC("`notify_url` DESC") + ,CertPath_ASC("`cert_path` ASC"),CertPath_DESC("`cert_path` DESC") + ,CertPass_ASC("`cert_pass` ASC"),CertPass_DESC("`cert_pass` DESC") ; private String value; Field(String value){ @@ -128,6 +140,8 @@ public class WxPayAccount implements Serializable { sb.append(","); sb.append(fields[k].toString()); } + + this.sortColumns = sb.toString(); } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java index 053739db5..ad4adf796 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java @@ -261,7 +261,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { wxRefundOrderP.setAppid(appInfo.getAppId()); wxRefundOrderP.setMch_id(payAccount.getMchId()); wxRefundOrderP.setNonce_str(noncestr); - if (record.getTransactionId() == null) + if (record.getTransactionId() != null) wxRefundOrderP.setTransaction_id(record.getTransactionId()); wxRefundOrderP.setOut_trade_no(record.getPayOrderNo()); wxRefundOrderP.setTotal_fee(record.getTotalFee()); @@ -272,13 +272,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { try { signMap = BeanUtils.toStringMap(wxRefundOrderP); } catch (Exception e) { - logger.error("退款签名异常"); + logger.error("退款命令生辰: " + e.getMessage()); throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); } String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); signMap.put("sign", signAgent); - String response = WxPay.orderRefund(signMap, payAccount.getCertPath(), payAccount.getApiKey()); + String response = null; + try { + response = WxPay.orderRefund(signMap, payAccount.getCertPath(), payAccount.getCertPass()); + } catch (Exception e) { + logger.error("退款异常: " + e.getMessage()); + throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), "退款异常"); + } logger.info("微信退款订单:" + wxRefundOrderP.toString() + ", response: " + response.toString()); Map returnMap = WxPayment.xmlToMap(response); String result_no = returnMap.get("result_code");