package com.cool.store.service;

import com.cool.store.dto.wx.PreOrderDTO;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.model.Refund;
import org.springframework.http.ResponseEntity;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;

/**
 * 微信支付V3
 */
public interface WxPayService {
    /**
     * JSAPI下单
     *
     * @return
     */
    PrepayWithRequestPaymentResponse jsApiOrder(PreOrderDTO preOrderDTO);
    /**
     * 支付回调
     *
     * @param request
     * @return
     * @throws IOException
     */
    ResponseEntity payNotify(HttpServletRequest request) throws IOException;
    /**
     * 根据商户订单号查询订单
     *
     * @param outTradeNo
     * @return
     */
    Transaction queryOrderByOutTradeNo(String outTradeNo);

    /**
     * 根据支付订单号查询订单
     *
     * @param paymentNo
     * @return
     */
    Transaction queryOrderByPaymentNo(String paymentNo);

    /**
     * 申请退款
     * @param orderID
     * @param outRefundNo
     * @param backAmount
     */
    void applyRefund(String orderID, String outRefundNo, BigDecimal backAmount);

    ResponseEntity refundNotify(HttpServletRequest request) throws IOException;

    /**
     * 获取订单退款结果信息
     * @param outRefundNo
     * @return
     */
    Refund getRefundOrderInfo(String outRefundNo);
    /**
     * 关闭订单
     *
     * @return
     */
    void closePay(String outTradeNo);

}
