| @@ -88,12 +88,12 @@ public class WxRefundOrderController extends BaseController { | |||||
| try { | try { | ||||
| payOrder = wxPayOrderService.getByObj(payOrderQ); | payOrder = wxPayOrderService.getByObj(payOrderQ); | ||||
| } catch (Exception e) { | } 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) { | 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(); | WxRefundOrder refundOrderQ = new WxRefundOrder(); | ||||
| @@ -54,6 +54,9 @@ public class WxPayAccount implements Serializable { | |||||
| /*证书本地存放位置**/ | /*证书本地存放位置**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath") | @io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath") | ||||
| private String certPath; | private String certPath; | ||||
| /*证书密码**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="证书密码",name="certPass") | |||||
| private String certPass; | |||||
| public String getMchId() { | public String getMchId() { | ||||
| return mchId; | return mchId; | ||||
| } | } | ||||
| @@ -79,6 +82,14 @@ public class WxPayAccount implements Serializable { | |||||
| certPath = _certPath; | certPath = _certPath; | ||||
| } | } | ||||
| public String getCertPass() { | |||||
| return certPass; | |||||
| } | |||||
| public void setCertPass(String certPass) { | |||||
| this.certPass = certPass; | |||||
| } | |||||
| public String getPayNotifyUrl() { | public String getPayNotifyUrl() { | ||||
| return notifyUrl + "/pay"; | return notifyUrl + "/pay"; | ||||
| } | } | ||||
| @@ -92,10 +103,11 @@ public class WxPayAccount implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | 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; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -128,6 +140,8 @@ public class WxPayAccount implements Serializable { | |||||
| sb.append(","); | sb.append(","); | ||||
| sb.append(fields[k].toString()); | sb.append(fields[k].toString()); | ||||
| } | } | ||||
| this.sortColumns = sb.toString(); | |||||
| } | } | ||||
| @@ -261,7 +261,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | wxRefundOrderP.setAppid(appInfo.getAppId()); | ||||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | wxRefundOrderP.setMch_id(payAccount.getMchId()); | ||||
| wxRefundOrderP.setNonce_str(noncestr); | wxRefundOrderP.setNonce_str(noncestr); | ||||
| if (record.getTransactionId() == null) | |||||
| if (record.getTransactionId() != null) | |||||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | wxRefundOrderP.setTransaction_id(record.getTransactionId()); | ||||
| wxRefundOrderP.setOut_trade_no(record.getPayOrderNo()); | wxRefundOrderP.setOut_trade_no(record.getPayOrderNo()); | ||||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | wxRefundOrderP.setTotal_fee(record.getTotalFee()); | ||||
| @@ -272,13 +272,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| try { | try { | ||||
| signMap = BeanUtils.toStringMap(wxRefundOrderP); | signMap = BeanUtils.toStringMap(wxRefundOrderP); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("退款签名异常"); | |||||
| logger.error("退款命令生辰: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); | throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); | ||||
| } | } | ||||
| String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); | String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); | ||||
| signMap.put("sign", signAgent); | 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()); | logger.info("微信退款订单:" + wxRefundOrderP.toString() + ", response: " + response.toString()); | ||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String result_no = returnMap.get("result_code"); | String result_no = returnMap.get("result_code"); | ||||