package com.ym.mec.biz.dal.dao;

import com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDetailDto;
import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
import com.ym.mec.biz.dal.dto.Mapper;
import com.ym.mec.biz.dal.dto.SysUserDto;
import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
import com.ym.mec.biz.dal.entity.CloudTeacherStudent;
import com.ym.mec.common.dal.BaseDAO;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface CloudTeacherOrderDao extends BaseDAO<Long, CloudTeacherOrder> {
	
	/**
	 * 根据studentPaymentOrder表id查询对象
	 * @param orderId
	 * @return
	 */
	CloudTeacherOrder queryByOrderId(Long orderId);

    /**
     * 获取未生效的云教练订单
     *
     * @return
     */
    List<CloudTeacherOrder> getNoStartCloudTeacherOrder(Integer tenantId);

    /**
     * 获取学生在有效期内的乐保数量
     *
     * @param studentIds
     * @param musicGroupId
     * @return
     */
    List<CloudTeacherOrder> getStudentCloudTeacherOrders(@Param("studentIds") List<Integer> studentIds, @Param("musicGroupId") String musicGroupId);

    /**
     * 获取乐团报名的云教练订单
     * @param studentId
     * @return
     */
    List<CloudTeacherOrder> getStudentCloudTeacherOrder(@Param("studentId") Integer studentId, @Param("musicGroupId") String musicGroupId);
    
    /**
     * 根据订单编号查询订单详情
     * @param orderId
     * @return
     */
    CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId);

    List<Map<Long, String>> queryNoStartByUserIds(@Param("userIds") Set<Integer> userIds, @Param("isMusicMember") Boolean isMusicMember);

    /**
     * 获取购买了云教练活动的学员列表
     * @param param
     * @return
     */
    int countCloudTeacherActiveDetail(Map<String, Object> param);

    /**
     * 获取购买了云教练活动的学员列表
     * @param param
     * @return
     */
    List<CloudTeacherActiveTargetDetailDto> queryCloudTeacherActiveDetail(Map<String, Object> param);

    /**
     * 获取学员购买的云教练活动订单
     * @param userId
     * @param activeRemark
     * @param remark
     * @return
     */
    String queryActiveOrderPage(@Param("userId") Integer userId,
                                                 @Param("activeRemark") Integer activeRemark,
                                                 @Param("remark") String remark);

    List<Integer> getStudentIds(Integer tenantId);

    /**
     * 获取学员云教练活动金额
     * @MapKey
     * @param studentIds
     * @return
     */
    List<Map<Long, BigDecimal>> queryActiveAmountMap(@Param("studentIds") List<Integer> studentIds);

    int findInactiveCount(Map<String, Object> params);

    List<CloudTeacherStudent> queryInactive(Map<String, Object> params);

    int updateOrderStatusOK(@Param("platformOrderId") Integer platformOrderId);

    int updateOrderId(@Param("cloudTeacherOrderId")Integer cloudTeacherOrderId,
                      @Param("amount") BigDecimal amount,
                      @Param("platformOrderId")Integer platformOrderId);

    int findRecordCount(Map<String, Object> params);

    List<CloudTeacherStudent> queryRecord(Map<String, Object> params);

    List<CloudTeacherOrder> findByPlatformOrderId(Integer id);

    int checkOrdered(@Param("cloudTeacherStudentIds")String join);
    
    List<CloudTeacherOrder> queryByUserIdAndStatus(@Param("userId")Integer userId, @Param("status")Integer status);

    List<Mapper> findUserNameByOrderId(@Param("platformOrderId")Integer platformOrderId);

    void batchInsert(@Param("bean") CloudTeacherOrder cloudTeacherOrder, @Param("userIds") List<Integer> userIds);
}