package org.springblade.common.upyzt.model;

import org.springblade.common.upyzt.exception.UpyztException;
import org.springblade.common.upyzt.net.APIResource;
import org.springblade.common.upyzt.resp.LargePaymentResp;
import org.springblade.common.upyzt.resp.TransferRefundResp;
import java.util.Map;
import lombok.experimental.Accessors;

/**
 * 大额订单
 */
@Accessors(chain = true)
public class LargePayment extends APIResource {

    /**
     * 大额订单号请求
     *
     * @param params 请求参数
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static LargePaymentResp create(Map<String, Object> params) throws UpyztException {
        return APIResource
            .request(RequestMethod.POST,
                classURL(LargePayment.class), params,
                LargePaymentResp.class, null);
    }

    /**
     * 大额订单查询（系统订单号）
     *
     * @param largePaymentNo 系统订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static LargePaymentResp retrieveById(String largePaymentNo) throws UpyztException {
        return APIResource
            .request(RequestMethod.GET,
                instanceURL(LargePayment.class, "_by_no",largePaymentNo), null,
                LargePaymentResp.class, null);
    }

    /**
     * 消费订单查询（平台订单号）
     *
     * @param outOrderNo 平台订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static LargePaymentResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
        return APIResource
            .request(APIResource.RequestMethod.GET,
                instanceURL(LargePayment.class, "_by_out_order_no", outOrderNo), null,
                LargePaymentResp.class, null);
    }

    /**
     * 大额订单号注销
     *
     * @param largePaymentNo 系统订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static LargePaymentResp cancel(String largePaymentNo) throws UpyztException {
        return APIResource
            .request(RequestMethod.PUT,
                instanceURL(LargePayment.class, "/" + largePaymentNo, "cancel"), null,
                LargePaymentResp.class, null);
    }
}
