package com.winsun.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.winsun.bean.HhrUser;

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

/**
 * 合伙人用户表的Mapper
 */
@Mapper
@Component
public interface HhrUserMapper extends BaseMapper<HhrUser> {
    @Select("select u.area ,u.name ,u.school,u.phone_num " +
            "from hhr_user u " +
            "left join hhr_user_school us on u.id = us.user_id " +
            "where u.id=#{partner}")
    List<Map<String, Object>> findPartnerById2(@Param("partner") String partner);

    @Select("select uuu.name ddname,sch.lzgh " +
            "from hhr_user u " +
            "left join hhr_user_school us on u.id = us.user_id  " +
            "left join hhr_school sch on sch.id = us.school_id  " +
            "left join hhr_supervisor_school ss on us.school_id = ss.school  " +
            "left join hhr_user uuu on uuu.id = ss.user_id " +
            "where u.id=#{partner}")
    List<Map<String, Object>> findSupervisorByPartnerId(@Param("partner") String partner);

    /**
     * 统计所有订单数
     * @param userIds
     * @param today
     * @param toWeekStart
     * @param toWeekEnd
     * @param toMonthStart
     * @param toMonthEnd
     * @param isComplete
     * @return
     */
    Map<String, Object> statisticAllOrderNum(@Param("userIds") List<Integer> userIds, @Param("today") String today,
                                             @Param("toWeekStart")String toWeekStart, @Param("toWeekEnd")String toWeekEnd,
                                             @Param("toMonthStart")String toMonthStart, @Param("toMonthEnd")String toMonthEnd,
                                             @Param("isComplete") boolean isComplete);

    /**
     * 根据合伙人获取产品id
     * @param hehuorenId
     * @return
     */
    Map<String, Object> getProductByUserId(@Param("hehuorenId") String hehuorenId);

    /**
     * 查询督导姓名、揽装工号
     * @param hehuorenId
     * @return
     */
    List<Map<String, Object>> selectSupervisor(@Param("hehuorenId") String hehuorenId);

    /**
     * 查询合伙人信息
     * @param hehuorenId
     * @return
     */
    Map<String, Object> selectHehuorenInfo(@Param("hehuorenId") String hehuorenId);
}
