package com.tmerclub.cloud.systemtest.api.amount;


import com.tmerclub.cloud.payment.dto.PayInfoDTO;
import com.moyuer.cloud.systemtest.constants.Constant;
import com.moyuer.cloud.systemtest.data.order.PayParamData;
import com.moyuer.cloud.systemtest.util.HttpUtil;
import com.moyuer.cloud.systemtest.util.UrlEnum;

import java.util.List;

/**
 * @author Tu
 */
public class PayApi {
    public static Long pay(PayInfoDTO payParam){
        String uri = Constant.API_URL+"/tmerclub_payment/pay/order";
        Long payId = HttpUtil.post(uri,payParam, UrlEnum.API,Long.class);
        return payId;
    }

    public static void balancePay(Long payId){
        String uri = Constant.API_URL+"/tmerclub_user/userBalance/balancePay";
        HttpUtil.post(uri,payId, UrlEnum.API);
    }

    public static void orderPay(Long orderNum){
        balancePay(pay(PayParamData.getPayParamData(orderNum)));
    }

    public static void orderPay(List<Long> orderNums) {
        balancePay(pay(PayParamData.getPayParamData(orderNums)));
    }

    public static Long payBalance(PayInfoDTO payParam){
        String uri = Constant.API_URL+"/tmerclub_payment/pay/payBalance";
        Long payId = HttpUtil.post(uri,payParam, UrlEnum.API,Long.class);
        return payId;
    }

    public static void orderPayBalance(Long orderNum){
        balancePay(payBalance(PayParamData.getPayParamData(orderNum)));
    }


}
