package com.sqx.modules.orders.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.modules.orders.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


@Mapper
public interface OrdersDao extends BaseMapper<Orders> {

    IPage<Orders> selectOrdersList(Page<Orders> page, Integer appointmentType, Integer appointmentNum, Integer status, String shipProvince,
                                   String shipCity, String shipDistrict, String shipAddress, String deliveryProvince, String deliveryCity,
                                   String deliveryDistrict, String deliveryAddress, String userName, String phone, String shipUserName, String shipUserPhone,
                                   String driverName, String driverPhone, Integer sort,String longitude,String latitude,Long driverId,String ordersNo,
                                   Integer orderType,Long driverUserId,Long driverRouteIds,Integer isFixedStroke);

    Double selectTeamMoney(Integer type,Long userId);

    Integer selectTakeOrdersCount(Long userId,String date);

    BigDecimal selectOrdersDriverMoney(Long userId);

    Integer selectOrdersDriverCount(Long userId);

    Integer selectMyOrdersCount(Long userId,String date);

    BigDecimal selectOrdersPingMoney(Integer flag, String time);

    Integer selectOrdersCount(Integer flag, String time);

    Integer selectOrderByStatus(Integer flag, String time,Integer status);

    IPage<Map<String,Object>> selectTeamUserList(Page<Map<String,Object>> page, @Param("invitationCode") String invitationCode, @Param("type") Integer type, @Param("userId") Long userId);

    Double selectOrdersMoneyCountByUserId(Long userId,Integer type);

    Integer selectUserCountByInvitationCode(String invitationCode,Integer type);

    BigDecimal sumOrdersPayMoneyByTime(@Param("dateType") String dateType, @Param("date") String date);

    BigDecimal sumOrdersDriveMoneyByTime(@Param("dateType") String dateType, @Param("date") String date);

    BigDecimal sumOrdersUserMoneyByTime(@Param("dateType") String dateType, @Param("date") String date, @Param("type") Integer type);

    BigDecimal sumOrdersPingMoneyByTime(@Param("dateType") String dateType, @Param("date") String date);

    List<Orders> selectOrdersByStartTime();

    Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status);

    IPage<Orders> selectOrdersListByInvoice(@Param("pages") Page<Orders> pages, @Param("userId") Long userId,
                                            @Param("ordersNo") String ordersNo, @Param("startTime") String startTime, @Param("endTime") String endTime);

}
