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

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.mzjf.MzjfDO;
import org.apache.ibatis.annotations.Mapper;
import com.jojubanking.boot.module.system.controller.admin.mzjf.vo.*;

/**
 * 门诊缴费 Mapper
 *
 * @author admin
 */
@Mapper
public interface MzjfMapper extends BaseMapperX<MzjfDO> {

    default PageResult<MzjfDO> selectPage(MzjfPageReqVO 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<MzjfDO>()
                .eqIfPresent(MzjfDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MzjfDO::getCardId, reqVO.getCardId())
                .eqIfPresent(MzjfDO::getPatientid, reqVO.getPatientid())
                .eqIfPresent(MzjfDO::getIdtype, reqVO.getIdtype())
                .eqIfPresent(MzjfDO::getLocktype, reqVO.getLocktype())
                .likeIfPresent(MzjfDO::getCreatitemname, reqVO.getCreatitemname())
                .betweenIfPresent(MzjfDO::getAppointmenttime, reqVO.getAppointmenttime())
                .betweenIfPresent(MzjfDO::getCreatdate, reqVO.getCreatdate())
                .eqIfPresent(MzjfDO::getQuerytype, reqVO.getQuerytype())
                .eqIfPresent(MzjfDO::getOrderno, reqVO.getOrderno())
                .eqIfPresent(MzjfDO::getFlowno, reqVO.getFlowno())
                .eqIfPresent(MzjfDO::getSetdepartcode, reqVO.getSetdepartcode())
                .likeIfPresent(MzjfDO::getSetdepartname, reqVO.getSetdepartname())
                .eqIfPresent(MzjfDO::getDodepartcode, reqVO.getDodepartcode())
                .likeIfPresent(MzjfDO::getDodepartname, reqVO.getDodepartname())
                .eqIfPresent(MzjfDO::getBilltype, reqVO.getBilltype())
                .likeIfPresent(MzjfDO::getBillname, reqVO.getBillname())
                .eqIfPresent(MzjfDO::getBilldes, reqVO.getBilldes())
                .betweenIfPresent(MzjfDO::getBilltime, reqVO.getBilltime())
                .eqIfPresent(MzjfDO::getBillmoney, reqVO.getBillmoney())
                .eqIfPresent(MzjfDO::getDoctorcode, reqVO.getDoctorcode())
                .likeIfPresent(MzjfDO::getDoctorname, reqVO.getDoctorname())
                .eqIfPresent(MzjfDO::getSincemoney, reqVO.getSincemoney())
                .eqIfPresent(MzjfDO::getFairmoney, reqVO.getFairmoney())
                .eqIfPresent(MzjfDO::getSerialno, reqVO.getSerialno())
                .eqIfPresent(MzjfDO::getAppointno, reqVO.getAppointno())
                .eqIfPresent(MzjfDO::getSerialflowno, reqVO.getSerialflowno())
                .eqIfPresent(MzjfDO::getJzlb, reqVO.getJzlb())
                .eqIfPresent(MzjfDO::getBzdm, reqVO.getBzdm())
                .betweenIfPresent(MzjfDO::getUpdatedate, reqVO.getUpdatedate())
                .eqIfPresent(MzjfDO::getBillsmsg, reqVO.getBillsmsg())
                .eqIfPresent(MzjfDO::getPaynature, reqVO.getPaynature())
                .eqIfPresent(MzjfDO::getPaytype, reqVO.getPaytype())
                .eqIfPresent(MzjfDO::getPowertranid, reqVO.getPowertranid())
                .eqIfPresent(MzjfDO::getPowertrancard, reqVO.getPowertrancard())
                .eqIfPresent(MzjfDO::getTerminalid, reqVO.getTerminalid())
                .eqIfPresent(MzjfDO::getReferno, reqVO.getReferno())
                .eqIfPresent(MzjfDO::getZfamount, reqVO.getZfamount())
                .eqIfPresent(MzjfDO::getYbzhamount, reqVO.getYbzhamount())
                .eqIfPresent(MzjfDO::getYbtcamount, reqVO.getYbtcamount())
                .eqIfPresent(MzjfDO::getYboutmsg, reqVO.getYboutmsg())
                .eqIfPresent(MzjfDO::getHisopernum, reqVO.getHisopernum())
                .eqIfPresent(MzjfDO::getIcbcorderid, reqVO.getIcbcorderid())
                .betweenIfPresent(MzjfDO::getIcbcpaytime, reqVO.getIcbcpaytime())
                .eqIfPresent(MzjfDO::getAppFlag, reqVO.getAppFlag())
                .eqIfPresent(MzjfDO::getAppStatus, reqVO.getAppStatus())
                .betweenIfPresent(MzjfDO::getCtime, dateSection)
                .betweenIfPresent(MzjfDO::getUtime, reqVO.getUtime())
                .orderByDesc(MzjfDO::getId));
    }

    default List<MzjfDO> selectList(MzjfExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MzjfDO>()
                .eqIfPresent(MzjfDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MzjfDO::getCardId, reqVO.getCardId())
                .eqIfPresent(MzjfDO::getPatientid, reqVO.getPatientid())
                .eqIfPresent(MzjfDO::getIdtype, reqVO.getIdtype())
                .eqIfPresent(MzjfDO::getLocktype, reqVO.getLocktype())
                .likeIfPresent(MzjfDO::getCreatitemname, reqVO.getCreatitemname())
                .betweenIfPresent(MzjfDO::getAppointmenttime, reqVO.getAppointmenttime())
                .betweenIfPresent(MzjfDO::getCreatdate, reqVO.getCreatdate())
                .eqIfPresent(MzjfDO::getQuerytype, reqVO.getQuerytype())
                .eqIfPresent(MzjfDO::getOrderno, reqVO.getOrderno())
                .eqIfPresent(MzjfDO::getFlowno, reqVO.getFlowno())
                .eqIfPresent(MzjfDO::getSetdepartcode, reqVO.getSetdepartcode())
                .likeIfPresent(MzjfDO::getSetdepartname, reqVO.getSetdepartname())
                .eqIfPresent(MzjfDO::getDodepartcode, reqVO.getDodepartcode())
                .likeIfPresent(MzjfDO::getDodepartname, reqVO.getDodepartname())
                .eqIfPresent(MzjfDO::getBilltype, reqVO.getBilltype())
                .likeIfPresent(MzjfDO::getBillname, reqVO.getBillname())
                .eqIfPresent(MzjfDO::getBilldes, reqVO.getBilldes())
                .betweenIfPresent(MzjfDO::getBilltime, reqVO.getBilltime())
                .eqIfPresent(MzjfDO::getBillmoney, reqVO.getBillmoney())
                .eqIfPresent(MzjfDO::getDoctorcode, reqVO.getDoctorcode())
                .likeIfPresent(MzjfDO::getDoctorname, reqVO.getDoctorname())
                .eqIfPresent(MzjfDO::getSincemoney, reqVO.getSincemoney())
                .eqIfPresent(MzjfDO::getFairmoney, reqVO.getFairmoney())
                .eqIfPresent(MzjfDO::getSerialno, reqVO.getSerialno())
                .eqIfPresent(MzjfDO::getAppointno, reqVO.getAppointno())
                .eqIfPresent(MzjfDO::getSerialflowno, reqVO.getSerialflowno())
                .eqIfPresent(MzjfDO::getJzlb, reqVO.getJzlb())
                .eqIfPresent(MzjfDO::getBzdm, reqVO.getBzdm())
                .betweenIfPresent(MzjfDO::getUpdatedate, reqVO.getUpdatedate())
                .eqIfPresent(MzjfDO::getBillsmsg, reqVO.getBillsmsg())
                .eqIfPresent(MzjfDO::getPaynature, reqVO.getPaynature())
                .eqIfPresent(MzjfDO::getPaytype, reqVO.getPaytype())
                .eqIfPresent(MzjfDO::getPowertranid, reqVO.getPowertranid())
                .eqIfPresent(MzjfDO::getPowertrancard, reqVO.getPowertrancard())
                .eqIfPresent(MzjfDO::getTerminalid, reqVO.getTerminalid())
                .eqIfPresent(MzjfDO::getReferno, reqVO.getReferno())
                .eqIfPresent(MzjfDO::getZfamount, reqVO.getZfamount())
                .eqIfPresent(MzjfDO::getYbzhamount, reqVO.getYbzhamount())
                .eqIfPresent(MzjfDO::getYbtcamount, reqVO.getYbtcamount())
                .eqIfPresent(MzjfDO::getYboutmsg, reqVO.getYboutmsg())
                .eqIfPresent(MzjfDO::getHisopernum, reqVO.getHisopernum())
                .eqIfPresent(MzjfDO::getIcbcorderid, reqVO.getIcbcorderid())
                .betweenIfPresent(MzjfDO::getIcbcpaytime, reqVO.getIcbcpaytime())
                .eqIfPresent(MzjfDO::getAppFlag, reqVO.getAppFlag())
                .eqIfPresent(MzjfDO::getAppStatus, reqVO.getAppStatus())
                .betweenIfPresent(MzjfDO::getCtime, reqVO.getCtime())
                .betweenIfPresent(MzjfDO::getUtime, reqVO.getUtime())
                .orderByDesc(MzjfDO::getId));
    }

}
