package com.sqx.modules.artificer.dao;


import cn.hutool.core.date.DateTime;
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.artificer.entity.Orders;
import com.sqx.modules.artificer.vo.HomeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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


@Mapper
public interface OrdersDao extends BaseMapper<Orders> {

    int insertOrders(Orders orders);

    IPage<Orders> selectOrdersList(Page<Orders> page,@Param("userId") Long userId,@Param("status") Integer status,
                                   @Param("city") String city,@Param("userName") String userName,@Param("phone") String phone,
                                   @Param("artificerId") Long artificerId,@Param("parentId") Long parentId,@Param("startTime") String startTime,
                                   @Param("endTime") String endTime,@Param("isAdd") Integer isAdd,String ordersNo,String artificerName,
                                   String oneUserName,String oneArtificerUserName,
                                   String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId,String shopName,Integer warning,
                                   String title,String classifyId,@Param("userPackageId")Long userPackageId);

    IPage<Orders> selectAppOrdersList(Page<Orders> page,@Param("userId") Long userId,@Param("status") Integer status,@Param("userPackageId") Long userPackageId);

    List<Orders> excelOrdersList(@Param("userId") Long userId,@Param("status") Integer status,
                                 @Param("city") String city,@Param("userName") String userName,@Param("phone") String phone,
                                 @Param("artificerId") Long artificerId,@Param("parentId") Long parentId,@Param("startTime") String startTime,
                                 @Param("endTime") String endTime,@Param("isAdd") Integer isAdd,String ordersNo,String artificerName,
                                 String oneUserName,String oneArtificerUserName,
                                 String startServeTime,String endServeTime,Integer overTimeOrders,Long shopId,String shopName,Integer warning,
                                 String title,String classifyId);

    BigDecimal selectOrdersMoney(String time, Integer type,Integer status);

    BigDecimal selectSumOrdersMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime);

    BigDecimal selectSumMoneyMonth(Long userId,@Param("time") String time);

    BigDecimal selectEstimationSumMoneyBy(Long userId,@Param("time") String time,@Param("type") Integer type);

    int selectCountOrderNum(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime);

    int selectCountOrders(String time, Integer type,Integer status);

    int selectCountOrder(Long userId,@Param("status") Integer status,@Param("startTime") String startTime,@Param("endTime") String endTime);

    int selectCountOrderByUserId(Long userId,Integer status,String time);

    IPage<Orders> selectTodayOrder(Page<Orders> pages,@Param("artificerId") Long artificerId,@Param("type") Integer type,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("minutes") Integer minutes);

    IPage<Orders> selectDividedIntoDetails(Page<Orders> pages,@Param("artificerId") Long artificerId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("isSfwc") Integer isSfwc);

    IPage<Orders> selectArtificerOrder(Page<Orders> pages, Long userId, Integer status);

    int selectOrdersCountByUnderway(@Param("artificerId") Long artificerId);


    Double selectOrdersMoneyCountByUserId(Long userId,Integer type,String time);

    Integer selectUserCountByInvitationCode(String invitationCode,Integer type);

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

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

    List<Orders> selectOrdersByEndTime(String minute);

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

    IPage<Orders> selectArtificerOrdersList(Page<Orders> page,@Param("artificerName") String artificerName,@Param("artificerPhone") String artificerPhone,
                                            @Param("userName") String userName,@Param("phone") String phone,@Param("warning")Integer warning,
                                            @Param("overTimeOrders") Integer overTimeOrders);

    int updateOrdersWarning(String time);

    List<Orders> selectOrdersStatusByTime(String time);

    IPage<Map<String,Object>> selectShopMoney(Page<Orders> page,String userName,String phone,String flag,String time);

    IPage<Map<String,Object>> selectOneUserMoney(Page<Orders> page,String userName,String phone,String flag,String time);

    IPage<Map<String,Object>> selectOneArtificerMoney(Page<Orders> page,String userName,String phone,String flag,String time);

    IPage<Map<String,Object>> selectArtificerMoney(Page<Orders> page,String userName,String phone,String flag,String time);

    IPage<Map<String,Object>> selectNewUserOrdersCount(Page<Orders> page,String userName,String phone);

    Double selectNewUserOrdersRate();

    Integer selectOrdersArtificerIntegralAchievement(Long artificerId, String endDate, String startDate);

    BigDecimal selectOrdersArtificerIntegralEarnings(Long artificerId, String endDate, String startDate);

    BigDecimal selectOrdersArtificerIntegralProjectEarnings(Long artificerId, String endDate, String startDate);

    String selectOrdersArtificerIntegral(Long artificerId, String endDate, String startDate);

    String selectOrdersArtificerIntegraladdNum(Long artificerId, String endDate, String startDate);

    String selectOrdersCurrentPeriodRechargeSum(Long artificerId, String endDate, String startDate,@Param("isSfwc") Integer isSfwc);

    String selectOrdersStoredValueIntegral(Long artificerId, String endDate, String startDate);

    String selectOnlineCredits(Long artificerId, String endDate, String startDate);

    String selectTaxiMoney(Long artificerId, String endDate, String startDate);

    String earnings(Long artificerId, String endDate, String startDate);

    /**
     * 统计技师price价格
     *  startTime 开始时间
     *  endTime 结束时间
     *  artificerId 技师id
     *  ordersQueryWrapper
     * @return
     */
    String selectTjpriceList(Orders ordersQueryWrapper);

    IPage<Orders> getDangqiList(Page<Orders> pages, Long userId, Integer isSfwc, String startTime, String endTime);

    IPage<Orders> getJiazhongList(Page<Orders> pages, Long userId, Integer isSfwc, String startTime, String endTime);

    IPage<Orders> getChongzhiList(Page<Orders> pages, Long artificerId, Integer isSfwc, String startTime, String endTime);

    String selectOrdersZxscNum(Long artificerId, String startTime, String endTime);

    List<Orders> getYjjfList(Long userId, String startTime, String endTime);

    List<Orders> getCzjfList(Long userId, String startTime, String endTime);

    List<Orders> getDdczList(Long userId, String startTime, String endTime);

    List<Orders> getZxscList(Long userId, String startTime, String endTime);

    List<Orders> getParentOrders(Long parentId);

    List<Orders> getNewOrdersByOld(Long ordersId);

    BigDecimal selectSumRefund(Long artificerId, @Param("startTime") String startTime, @Param("endTime") String endTime);

}