zhanglin8526
2023-08-26 ee57cf6a52011ac167216cf2420149e783bbdfa9
支付调整
1个文件已修改
20 ■■■■■ 已修改文件
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
@@ -88,7 +88,7 @@
                    || WxPayNotifyEventTypeEnum.REFUND_ABNORMAL.getCode().equals(eventType)
                    || WxPayNotifyEventTypeEnum.REFUND_CLOSED.getCode().equals(eventType)) {
                RefundNotifyResult result = wxService.getEcommerceService().parseRefundNotifyResult(notifyData, signatureHeader);
                RefundNotifyResult result = this.parseRefundNotifyResult(notifyData, signatureHeader);
                orderService.orderRefundBack(result);
                resultType = 2;
                resultMessage = GSON.toJson(result);
@@ -165,6 +165,24 @@
        }
    }
    private RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
        NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class);
        NotifyResponse.Resource resource = response.getResource();
        String cipherText = resource.getCiphertext();
        String associatedData = resource.getAssociatedData();
        String nonce = resource.getNonce();
        String apiV3Key = this.wxService.getConfig().getApiV3Key();
        try {
            String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
            RefundNotifyResult notifyResult = GSON.fromJson(result, RefundNotifyResult.class);
            notifyResult.setRawData(response);
            return notifyResult;
        } catch (GeneralSecurityException | IOException e) {
            throw new WxPayException("解析报文异常!", e);
        }
    }
    private boolean verifyNotifySign(SignatureHeader header, String data) throws WxPayException {
        String beforeSign = String.format("%s\n%s\n%s\n",
                header.getTimeStamp(),