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

import com.alibaba.fastjson2.JSON;
import com.tmerclub.cloud.api.delivery.vo.StationVO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.order.dto.OrderVirtualInfoDTO;
import com.tmerclub.cloud.common.order.vo.OrderVO;
import com.tmerclub.cloud.common.util.Json;
import com.moyuer.cloud.delivery.vo.StationDetailVO;
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 StationApi {
    public static List<StationDetailVO> getStationList(Long shopId){
        String url = Constant.API_URL+"/tmerclub_order/station/userStation?pageNum=1&pageSize=7&lat=22.943953938872706&lng=113.39070900424778&stationName=&shopId="+shopId;
        return JSON.parseArray(JSON.toJSONString(Json.parseObject(JSON.toJSONString(HttpUtil.get(url, PageVO.class, UrlEnum.API)), PageVO.class).getList()), StationDetailVO.class);
    }

    /**
     * 获取门店首页数据
     */
    public static StationVO getStationIndexInfo() {
        String url = Constant.API_URL + "/tmerclub_order/station/getStationIndexInfo";
        return HttpUtil.get(url, StationVO.class, UrlEnum.STATION);
    }

    /**
     * 在门店端查询订单信息
     * */
    public static OrderVO getStationOrderByCode(String code){
        String url = Constant.API_URL+"/tmerclub_order/station/getStationOrderByCode?code="+code;
        return HttpUtil.get(url,OrderVO.class, UrlEnum.STATION);
    }

    /**
     * 在门店端核销自提订单
     * */
    public static void orderStationById(String orderIds) {
        String url = Constant.API_URL + "/tmerclub_order/station/orderStationByOrderId";
        HttpUtil.put(url, orderIds, UrlEnum.STATION);
    }
    /**
     * 在门店端核销虚拟商品订单
     * */
    public static void  orderWriteOffByOrderNumber(OrderVirtualInfoDTO orderVirtualInfoDTO){
        String url = Constant.API_URL + "/tmerclub_order/station/orderWriteOffByOrderId";
        HttpUtil.put(url, orderVirtualInfoDTO, UrlEnum.STATION);
    }
}
