package com.xunwang.payment.service;

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Map;

public interface WxPayService {

    /**
     * 创建订单，调用jsapi下单接口
     * @param inviteId
     * @return
     * @throws IOException
     */
    Map<String,Object> jsapiPay(String inviteId) throws IOException;

    /**
     * 处理订单
     * @param bodyMap
     * @throws GeneralSecurityException
     */
    void processOrder(Map<String, Object> bodyMap) throws GeneralSecurityException;

    /**
     * 用户取消订单
     * @param orderNo
     * @throws IOException
     */
    void cancelOrder(String orderNo) throws IOException;

    /**
     * 查单接口调用
     * @param orderNo
     * @return
     * @throws IOException
     */
    String queryOrder(String orderNo) throws IOException;

    /**
     * 根据订单号查询微信支付查单接口，核实订单状态
     *      如果订单已支付，则更新商户端订单状态，并记录支付日志
     *      如果订单未支付，则调用关单接口关闭订单，并更新商户端订单状态
     * @param orderNo
     * @throws IOException
     */
    void checkOrderStatus(String orderNo) throws IOException;

    /**
     * 退款
     * @param orderNo
     * @param reason
     * @throws IOException
     */
    void refund(String orderNo, String reason) throws IOException;

    /**
     * 查询退款接口调用
     * @param refundNo
     * @return
     * @throws IOException
     */
    String queryRefund(String refundNo) throws IOException;

    /**
     * 根据退款单号核实退款单状态
     * @param refundNo
     * @throws IOException
     */
    void checkRefundStatus(String refundNo) throws IOException;

    /**
     * 处理退款单
     * @param bodyMap
     * @throws GeneralSecurityException
     */
    void processRefund(Map<String, Object> bodyMap) throws GeneralSecurityException;

}
