class PlspayRefundService extends AbstractRefundService {

    @Override
    public String getIfCode() {
        return CS.IF_CODE.PLSPAY;
    }

    @Override
    public String preCheck(RefundOrderRQ bizRQ, RefundOrder refundOrder, PayOrder payOrder) {
        return null;
    }

    @Override
    public ChannelRetMsg refund(RefundOrderRQ bizRQ, RefundOrder refundOrder, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
        PlspayNormalMchParams normalMchParams = (PlspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.PLSPAY);
        RefundOrderCreateRequest request = new RefundOrderCreateRequest();
        RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
        model.setMchNo(normalMchParams.getMerchantNo());            // 商户号
        model.setAppId(normalMchParams.getAppId());                 // 应用ID
        model.setPayOrderId(payOrder.getChannelOrderNo());          // 支付订单号
        model.setMchRefundNo(refundOrder.getRefundOrderId());       // 商户退款单号
        model.setRefundAmount(refundOrder.getRefundAmount());       // 金额，单位分
        model.setCurrency(refundOrder.getCurrency());               // 币种，目前只支持cny
        model.setRefundReason(refundOrder.getRefundReason());       // 退款原因
        model.setClientIp(refundOrder.getClientIp());               // 发起退款请求客户端的IP地址
        model.setNotifyUrl(getNotifyUrl());                         // 异步通知地址
        request.setBizModel(model);
        // 构造函数响应数据
        ChannelRetMsg channelRetMsg = new ChannelRetMsg();
        try {
            // 发起退款
            RefundOrderCreateResponse response = new RefundOrderCreateResponse();
            if (normalMchParams.getSignType().equals(PlspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
                JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
                response = jeepayClient.execute(request);

            } else if (normalMchParams.getSignType().equals(PlspayConfig.SIGN_TYPE_RSA2)) {
                JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
                response = jeepayClient.executeByRSA2(request);
            }

            // 下单返回状态
            Boolean isSuccess = PlspayKit.checkPayResp(response, mchAppConfigContext);

            // 退款发送成功
            if (isSuccess) {
                if (PlspayConfig.REFUND_STATE_SUCCESS.equals(response.get().getState().toString())) {
                    channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
                }
                channelRetMsg.setChannelOrderId(response.get().getRefundOrderId());
            } else {
                channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
                channelRetMsg.setChannelErrCode(response.getCode().toString());
                channelRetMsg.setChannelErrMsg(response.getMsg());
            }
            channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
        } catch (JeepayException e) {
            channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
        }
        return channelRetMsg;
    }

    @Override
    public ChannelRetMsg query(RefundOrder refundOrder, MchAppConfigContext mchAppConfigContext) throws Exception {<FILL_FUNCTION_BODY>}
}

        RefundOrderQueryRequest request = new RefundOrderQueryRequest();
        RefundOrderQueryReqModel model = new RefundOrderQueryReqModel();
        try {
            PlspayNormalMchParams normalMchParams = (PlspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.PLSPAY);
            model.setMchNo(normalMchParams.getMerchantNo());            // 商户号
            model.setAppId(normalMchParams.getAppId());                 // 应用ID
            model.setRefundOrderId(refundOrder.getRefundOrderId());     // 退款订单号
            request.setBizModel(model);
            // 发起请求
            RefundOrderQueryResponse response = new RefundOrderQueryResponse();
            if (normalMchParams.getSignType().equals(PlspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
                JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
                response = jeepayClient.execute(request);
            } else if (normalMchParams.getSignType().equals(PlspayConfig.SIGN_TYPE_RSA2)) {
                JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
                response = jeepayClient.executeByRSA2(request);
            }

            // 下单返回状态
            Boolean isSuccess = PlspayKit.checkPayResp(response, mchAppConfigContext);

            // 请求响应状态
            if (isSuccess) {
                // 如果查询请求成功
                if (PlspayConfig.PAY_STATE_SUCCESS.equals(response.get().getState().toString())) {
                    return ChannelRetMsg.confirmSuccess(response.get().getRefundOrderId());
                } else if (PlspayConfig.PAY_STATE_FAIL.equals(response.get().getState().toString())) {
                    // 失败
                    return ChannelRetMsg.confirmFail();
                }
            }
            // 退款中
            return ChannelRetMsg.waiting();
        } catch (Exception e) {
            // 退款中
            return ChannelRetMsg.waiting();
        }
    
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean channelCertConfigKitBean,protected com.jeequan.jeepay.pay.service.ConfigContextQueryService configContextQueryService,protected com.jeequan.jeepay.service.impl.SysConfigService sysConfigService