package com.njzscloud.supervisory.order.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njzscloud.supervisory.biz.pojo.entity.BizCompanyEntity;
import com.njzscloud.supervisory.biz.pojo.entity.BizTruckEntity;
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
import com.njzscloud.supervisory.order.pojo.result.OrderExportDetailResult;
import com.njzscloud.supervisory.order.pojo.result.OrderExportResult;
import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult;
import com.njzscloud.supervisory.order.pojo.result.PaymentContextResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 订单信息
 */
@Mapper
public interface OrderInfoMapper extends BaseMapper<OrderInfoEntity> {

    Page<OrderPagingResult> paging(Page<OrderPagingResult> page, @Param("ew") QueryWrapper<OrderPagingResult> ew);

    List<OrderExportResult> exportList(@Param("ew") QueryWrapper<OrderPagingResult> ew);

    List<OrderExportDetailResult> exportDetailList(@Param("ew") QueryWrapper<OrderPagingResult> ew);

    OrderPagingResult detail(@Param("ew") QueryWrapper<OrderPagingResult> ew);

    OrderPagingResult pendingOrder(@Param("ew") QueryWrapper<Object> ew);

    OrderPagingResult obtainWeighBill(@Param("orderId") Long orderId);

    Long getDriverId(@Param("userId") Long userId);

    void busyDriver(@Param("driverId") Long driverId, @Param("busy") Boolean busy);

    void busyTruck(@Param("truckId") Long truckId, @Param("busy") Boolean busy);

    PaymentContextResult paymentContext(@Param("orderId") Long orderId);

    BizTruckEntity getTruckInfo(@Param("truckId") Long truckId);

    BizCompanyEntity getTransInfo(@Param("transCompanyId") Long transCompanyId);

    DeviceLocalizerEntity gpsLastOnlineTime(@Param("gpsId") String gpsId);

    List<String> getRoute(@Param("id") Long id);

    @SuppressWarnings("MybatisXMapperMethodInspection")
    List<Map<String, Object>> statisticsByArea(@Param("ew") QueryWrapper<Object> ew);

    @SuppressWarnings("MybatisXMapperMethodInspection")
    List<Map<String, Object>> statisticsByAreaGoods(@Param("ew") QueryWrapper<Object> ew);

    Boolean driverIsBusy(@Param("driverId") Long driverId);

    Boolean truckIsBusy(@Param("truckId") Long truckId);

    Boolean hasInProgressOrder(@Param("driverId") Long driverId, @Param("orderStatuses") List<String> orderStatuses);
}
