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

import com.tmerclub.cloud.api.delivery.dto.DeliveryOrderDTO;
import com.tmerclub.cloud.api.delivery.vo.DeliveryOrderFeignVO;
import com.tmerclub.cloud.common.order.dto.OrderSelfStationDTO;
import com.tmerclub.cloud.common.order.dto.OrderVirtualInfoDTO;
import com.tmerclub.cloud.common.order.vo.OrderAddrVO;
import com.tmerclub.cloud.common.order.vo.OrderSelfStationVO;
import com.tmerclub.cloud.common.order.vo.OrderVO;
import com.tmerclub.cloud.order.dto.OrderAddrDTO;
import com.tmerclub.cloud.order.dto.multishop.OrderAdminDTO;
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 OrderApi {
    public static OrderVO getOrderItemAndAddress(Long orderNumber){
        String url = Constant.API_URL+"/tmerclub_order/mp/order/order_item_and_address/"+orderNumber;
        return HttpUtil.get(url, OrderVO.class,UrlEnum.SHOP);
    }

    public static void delivery(DeliveryOrderDTO deliveryOrderParam){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/delivery";
        HttpUtil.post(url,deliveryOrderParam,UrlEnum.SHOP);
    }

    public static OrderVO infoOrder(Long orderNumber){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/order_info/"+orderNumber;
        return HttpUtil.get(url, OrderVO.class,UrlEnum.SHOP);
    }
    public static void changeOrderAmount(OrderAdminDTO orderAdminDTO){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/change_amount";
        HttpUtil.put(url, orderAdminDTO, UrlEnum.SHOP);
    }
    public static OrderAddrVO infoOrderAddr(Long orderNumber){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/order_addr/"+orderNumber;
        return HttpUtil.get(url,OrderAddrVO.class,UrlEnum.SHOP);
    }

    public static void changeOrderAddrCheck(Long orderNumber){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/get_change_amount?orderId="+orderNumber+"&areaId=130203";
        HttpUtil.get(url,UrlEnum.SHOP);
    }
    public static void changeOrderAddr(OrderAddrDTO orderAddrDTO){
        String url = Constant.API_URL + "/tmerclub_order/mp/order/change_user_addr";
        HttpUtil.put(url,orderAddrDTO,UrlEnum.SHOP);
    }

    public static List<DeliveryOrderFeignVO> infoOrderDelivery(Long orderNumber){
        String url = Constant.API_URL+"/tmerclub_order/mp/orderDelivery/info?orderId="+orderNumber;
        List<DeliveryOrderFeignVO> deliveryOrderFeignVos = HttpUtil.get(url, List.class,UrlEnum.SHOP);
        return deliveryOrderFeignVos;
    }

    public static void updateOrderDelivery(List<DeliveryOrderDTO> list){
        String url = Constant.API_URL + "/tmerclub_order/mp/orderDelivery/update";
        HttpUtil.put(url,list,UrlEnum.SHOP);
    }

    /**
     * 自提订单商家端提货
     */
    public static void changeStatusAndOrderStation(OrderSelfStationDTO orderSelfStationDTO){
        String url = Constant.API_URL + "/tmerclub_order/m/order_self_station/change_status_and_order_station";
        HttpUtil.put(url, orderSelfStationDTO, UrlEnum.SHOP);
    }

    /**
     * 订单自提信息详情
     */
    public static OrderSelfStationVO getOrderItemAndStationInfo(Long orderId) {
        String url = Constant.API_URL + "/tmerclub_order/m/order_self_station/get_order_item_and_station_info?orderId=" + orderId;
        return HttpUtil.get(url, OrderSelfStationVO.class, UrlEnum.SHOP);
    }

    /**
     * 根据订单ID和核销码核销虚拟订单
     */
    public static void orderWriteOffByOrderId(OrderVirtualInfoDTO orderVirtualInfoDTO) {
        String url = Constant.API_URL + "/tmerclub_order/m/order_virtual_info/orderWriteOffByOrderId";
        HttpUtil.put(url, orderVirtualInfoDTO, UrlEnum.SHOP);
    }

    /**
     * 根据订单ID采购订单
     * */
    public static void sourcingOrder(OrderAdminDTO orderDTO) {
        String url = Constant.API_URL + "/tmerclub_order/mp/order/sourcing_order";
        HttpUtil.put(url, orderDTO, UrlEnum.SHOP);
    }
}
