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


import com.alibaba.fastjson2.JSON;
import com.tmerclub.cloud.api.vo.EsPageVO;
import com.tmerclub.cloud.common.order.vo.EsOrderRefundVO;
import com.tmerclub.cloud.common.util.Json;
import com.tmerclub.cloud.order.dto.multishop.OrderRefundDTO;
import com.tmerclub.cloud.order.vo.OrderRefundVO;
import com.moyuer.cloud.systemtest.constants.Constant;
import com.moyuer.cloud.systemtest.util.HttpUtil;
import com.moyuer.cloud.systemtest.util.UrlEnum;

import java.util.List;


/**
 * @author Tu
 */
public class ShopOrderRefundApi {
    /**
     * 商家查询退款详情
     */
    public static OrderRefundVO infoByRefundSn(Long refundId) {
        String url = Constant.API_URL+"/tmerclub_order/m/order_refund/info/"+refundId;
        return HttpUtil.get(url,OrderRefundVO.class, UrlEnum.SHOP);
    }

    /**
     * 商家处理退款订单
     */
    public static void processRefundOrder(OrderRefundDTO orderRefundParam){
        String url = Constant.API_URL+"/tmerclub_order/m/order_refund/return_and_refund_audit";
        HttpUtil.put(url,orderRefundParam,UrlEnum.SHOP);
    }
    /**
     * 商家处理退货退款订单
     */
    public static void returnMoney(OrderRefundDTO orderRefundParam){
        String url = Constant.API_URL+"/tmerclub_order/m/order_refund/return_money";
        HttpUtil.put(url, orderRefundParam, UrlEnum.SHOP);

    }

    /**
     * 根据订单号查询退款记录
     */
    public static List<EsOrderRefundVO> getEsOrderRefundVO(Long orderId) {
        String url = Constant.API_URL +  "/tmerclub_search/mp/search/orderRefund/page?pageSize=10&pageNum=1&orderId=" + orderId + "&returnMoneySts=&refundId=&orderType=&applyType=&refundType=&beginTime=&endTime=";
        return JSON.parseArray(JSON.toJSONString(Json.parseObject(JSON.toJSONString(HttpUtil.get(url, EsPageVO.class, UrlEnum.SHOP)), EsPageVO.class).getList()), EsOrderRefundVO.class);
    }
}
