package com.jojubanking.boot.module.system.dal.mysql.reserve8;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import com.jojubanking.boot.framework.common.pojo.PageResult;
import com.jojubanking.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jojubanking.boot.framework.mybatis.core.mapper.BaseMapperX;
import com.jojubanking.boot.module.system.dal.dataobject.reserve8.Reserve8DO;
import org.apache.ibatis.annotations.Mapper;
import com.jojubanking.boot.module.system.controller.admin.reserve8.vo.*;

/**
 * 预约挂号 Mapper
 *
 * @author admin
 */
@Mapper
public interface Reserve8Mapper extends BaseMapperX<Reserve8DO> {

    default PageResult<Reserve8DO> selectPage(Reserve8PageReqVO reqVO) throws ParseException {
        DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = fmt.parse(reqVO.getStartDate());
        Date endDate = fmt.parse(reqVO.getEndDate());
        Date[] dateSection = new Date[2];
        dateSection[0] = startDate;
        dateSection[1] = endDate;

        return selectPage(reqVO, new LambdaQueryWrapperX<Reserve8DO>()
                .eqIfPresent(Reserve8DO::getUserId, reqVO.getUserId())
                .eqIfPresent(Reserve8DO::getCardId, reqVO.getCardId())
                .likeIfPresent(Reserve8DO::getName, reqVO.getName())
                .eqIfPresent(Reserve8DO::getKsmc, reqVO.getKsmc())
                .eqIfPresent(Reserve8DO::getYsmc, reqVO.getYsmc())
                .eqIfPresent(Reserve8DO::getSubHospitalID, reqVO.getSubHospitalID())
                .eqIfPresent(Reserve8DO::getReptNum, reqVO.getReptNum())
                .eqIfPresent(Reserve8DO::getLockType, reqVO.getLockType())
                .eqIfPresent(Reserve8DO::getHisOrderNO, reqVO.getHisOrderNO())
                .eqIfPresent(Reserve8DO::getScheduleId, reqVO.getScheduleId())
                .eqIfPresent(Reserve8DO::getDoctorCode, reqVO.getDoctorCode())
                .eqIfPresent(Reserve8DO::getDepartCode, reqVO.getDepartCode())
                .eqIfPresent(Reserve8DO::getParTimeId, reqVO.getParTimeId())
                .betweenIfPresent(Reserve8DO::getLockTime, reqVO.getLockTime())
                .eqIfPresent(Reserve8DO::getPatientId, reqVO.getPatientId())
                .eqIfPresent(Reserve8DO::getMobile, reqVO.getMobile())
                .eqIfPresent(Reserve8DO::getSerialNo, reqVO.getSerialNo())
                .eqIfPresent(Reserve8DO::getLocation, reqVO.getLocation())
                .eqIfPresent(Reserve8DO::getTicketNo, reqVO.getTicketNo())
                .eqIfPresent(Reserve8DO::getOrderNo, reqVO.getOrderNo())
                .eqIfPresent(Reserve8DO::getTimeInterval, reqVO.getTimeInterval())
                .betweenIfPresent(Reserve8DO::getRegisterdate, reqVO.getRegisterdate())
                .eqIfPresent(Reserve8DO::getClinicFee, reqVO.getClinicFee())
                .eqIfPresent(Reserve8DO::getRegistrationFee, reqVO.getRegistrationFee())
                .eqIfPresent(Reserve8DO::getPayNature, reqVO.getPayNature())
                .eqIfPresent(Reserve8DO::getPayType, reqVO.getPayType())
                .eqIfPresent(Reserve8DO::getPowerTranID, reqVO.getPowerTranID())
                .eqIfPresent(Reserve8DO::getPowerTranCARD, reqVO.getPowerTranCARD())
                .eqIfPresent(Reserve8DO::getTerminalId, reqVO.getTerminalId())
                .eqIfPresent(Reserve8DO::getZFAmount, reqVO.getZFAmount())
                .eqIfPresent(Reserve8DO::getYBZHAmount, reqVO.getYBZHAmount())
                .eqIfPresent(Reserve8DO::getYBTCAmount, reqVO.getYBTCAmount())
                .eqIfPresent(Reserve8DO::getYBOutMsg, reqVO.getYBOutMsg())
                .eqIfPresent(Reserve8DO::getHisOperNum, reqVO.getHisOperNum())
                .eqIfPresent(Reserve8DO::getReferNo, reqVO.getReferNo())
                .eqIfPresent(Reserve8DO::getToken, reqVO.getToken())
                .eqIfPresent(Reserve8DO::getAppFlag, reqVO.getAppFlag())
                .eqIfPresent(Reserve8DO::getAppStatus, reqVO.getAppStatus())
                .eqIfPresent(Reserve8DO::getAppType, reqVO.getAppType())
                .betweenIfPresent(Reserve8DO::getCtime, dateSection)
                .betweenIfPresent(Reserve8DO::getUtime, reqVO.getUtime())
                .orderByDesc(Reserve8DO::getId));
    }

    default List<Reserve8DO> selectList(Reserve8ExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<Reserve8DO>()
                .eqIfPresent(Reserve8DO::getUserId, reqVO.getUserId())
                .eqIfPresent(Reserve8DO::getCardId, reqVO.getCardId())
                .likeIfPresent(Reserve8DO::getName, reqVO.getName())
                .eqIfPresent(Reserve8DO::getKsmc, reqVO.getKsmc())
                .eqIfPresent(Reserve8DO::getYsmc, reqVO.getYsmc())
                .eqIfPresent(Reserve8DO::getSubHospitalID, reqVO.getSubHospitalID())
                .eqIfPresent(Reserve8DO::getReptNum, reqVO.getReptNum())
                .eqIfPresent(Reserve8DO::getLockType, reqVO.getLockType())
                .eqIfPresent(Reserve8DO::getHisOrderNO, reqVO.getHisOrderNO())
                .eqIfPresent(Reserve8DO::getScheduleId, reqVO.getScheduleId())
                .eqIfPresent(Reserve8DO::getDoctorCode, reqVO.getDoctorCode())
                .eqIfPresent(Reserve8DO::getDepartCode, reqVO.getDepartCode())
                .eqIfPresent(Reserve8DO::getParTimeId, reqVO.getParTimeId())
                .betweenIfPresent(Reserve8DO::getLockTime, reqVO.getLockTime())
                .eqIfPresent(Reserve8DO::getPatientId, reqVO.getPatientId())
                .eqIfPresent(Reserve8DO::getMobile, reqVO.getMobile())
                .eqIfPresent(Reserve8DO::getSerialNo, reqVO.getSerialNo())
                .eqIfPresent(Reserve8DO::getLocation, reqVO.getLocation())
                .eqIfPresent(Reserve8DO::getTicketNo, reqVO.getTicketNo())
                .eqIfPresent(Reserve8DO::getOrderNo, reqVO.getOrderNo())
                .eqIfPresent(Reserve8DO::getTimeInterval, reqVO.getTimeInterval())
                .betweenIfPresent(Reserve8DO::getRegisterdate, reqVO.getRegisterdate())
                .eqIfPresent(Reserve8DO::getClinicFee, reqVO.getClinicFee())
                .eqIfPresent(Reserve8DO::getRegistrationFee, reqVO.getRegistrationFee())
                .eqIfPresent(Reserve8DO::getPayNature, reqVO.getPayNature())
                .eqIfPresent(Reserve8DO::getPayType, reqVO.getPayType())
                .eqIfPresent(Reserve8DO::getPowerTranID, reqVO.getPowerTranID())
                .eqIfPresent(Reserve8DO::getPowerTranCARD, reqVO.getPowerTranCARD())
                .eqIfPresent(Reserve8DO::getTerminalId, reqVO.getTerminalId())
                .eqIfPresent(Reserve8DO::getZFAmount, reqVO.getZFAmount())
                .eqIfPresent(Reserve8DO::getYBZHAmount, reqVO.getYBZHAmount())
                .eqIfPresent(Reserve8DO::getYBTCAmount, reqVO.getYBTCAmount())
                .eqIfPresent(Reserve8DO::getYBOutMsg, reqVO.getYBOutMsg())
                .eqIfPresent(Reserve8DO::getHisOperNum, reqVO.getHisOperNum())
                .eqIfPresent(Reserve8DO::getReferNo, reqVO.getReferNo())
                .eqIfPresent(Reserve8DO::getToken, reqVO.getToken())
                .eqIfPresent(Reserve8DO::getAppFlag, reqVO.getAppFlag())
                .eqIfPresent(Reserve8DO::getAppStatus, reqVO.getAppStatus())
                .eqIfPresent(Reserve8DO::getAppType, reqVO.getAppType())
                .betweenIfPresent(Reserve8DO::getCtime, reqVO.getCtime())
                .betweenIfPresent(Reserve8DO::getUtime, reqVO.getUtime())
                .orderByDesc(Reserve8DO::getId));
    }

}
