package ink.wgink.module.wechat.remote.pay.v3;

import com.alibaba.fastjson.JSONObject;
import ink.wgink.annotation.rpc.rest.RemoteService;
import ink.wgink.annotation.rpc.rest.method.RemoteGetMethod;
import ink.wgink.annotation.rpc.rest.method.RemotePostMethod;
import ink.wgink.annotation.rpc.rest.params.*;
import ink.wgink.module.wechat.pojo.pay.v3.jsapi.pojo.PayPrepay;
import ink.wgink.module.wechat.pojo.pay.v3.order.OrderSearch;

/**
 * @ClassName: IOrderPayRemoteService
 * @Description: 订单远程调用
 * @Author: wanggeng
 * @Date: 2021/10/2 10:58 上午
 * @Version: 1.0
 */
@RemoteService
public interface IOrderPayRemoteService {

    /**
     * 下单
     *
     * @param server
     * @param authorization
     * @param serialNumber
     * @param payPlaceOrder
     * @return
     */
    @RemotePostMethod("/v3/pay/transactions/jsapi")
    PayPrepay placeOrderJsapi(@RemoteServerParams String server,
                              @RemoteHeaderParams(IPayRemoteService.HEADER_AUTHORIZATION) String authorization,
                              @RemoteHeaderParams(IPayRemoteService.HEADER_WECHATPAY_SERIAL) String serialNumber,
                              @RemoteJsonBodyParams JSONObject payPlaceOrder);

    /**
     * 关闭订单
     *
     * @param server
     * @param businessOrderId
     * @param authorization
     * @param serialNumber
     * @param orderClose
     */
    @RemotePostMethod("/v3/pay/transactions/out-trade-no/{businessOrderId}/close")
    void closePlaceOrder(@RemoteServerParams String server,
                         @RemotePathParams("businessOrderId") String businessOrderId,
                         @RemoteHeaderParams(IPayRemoteService.HEADER_AUTHORIZATION) String authorization,
                         @RemoteHeaderParams(IPayRemoteService.HEADER_WECHATPAY_SERIAL) String serialNumber,
                         @RemoteJsonBodyParams JSONObject orderClose);

    /**
     * 微信支付订单号查询
     *
     * @param server
     * @param transactionId
     * @param authorization
     * @param serialNumber
     * @param mchid
     * @return
     */
    @RemoteGetMethod("/v3/pay/transactions/id/{transactionId}")
    OrderSearch getOrder(@RemoteServerParams String server,
                         @RemotePathParams("transactionId") String transactionId,
                         @RemoteHeaderParams(IPayRemoteService.HEADER_AUTHORIZATION) String authorization,
                         @RemoteHeaderParams(IPayRemoteService.HEADER_WECHATPAY_SERIAL) String serialNumber,
                         @RemoteQueryParams("mchid") String mchid);

    /**
     * 商户订单号查询
     *
     * @param server
     * @param businessOrderId
     * @param authorization
     * @param serialNumber
     * @param mchid
     * @return
     */
    @RemoteGetMethod("/v3/pay/transactions/out-trade-no/{businessOrderId}")
    OrderSearch getBusinessOrder(@RemoteServerParams String server,
                                 @RemotePathParams("businessOrderId") String businessOrderId,
                                 @RemoteHeaderParams(IPayRemoteService.HEADER_AUTHORIZATION) String authorization,
                                 @RemoteHeaderParams(IPayRemoteService.HEADER_WECHATPAY_SERIAL) String serialNumber,
                                 @RemoteQueryParams("mchid") String mchid);

}
