package com.yihu.jw.order.dao;

import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;
import java.util.List;


public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrderDO, Integer>, JpaSpecificationExecutor<BusinessOrderDO>  {


    @Query("from BusinessOrderDO w where w.traceNo = ?1 and w.orderNo=?2")
    BusinessOrderDO selectByTraceNoAndorderNo(String traceNo,String orderNo);
    @Query("from BusinessOrderDO w where w.orderNo = ?1 ")
    BusinessOrderDO selectByOrderNo(String orderNo);


    @Query("from BusinessOrderDO w where w.relationCode = ?1 ")
    BusinessOrderDO selectByRelationCode(String relationCode);


    @Query("from BusinessOrderDO w where w.relationCode = ?1 order by createTime desc ")
    List<BusinessOrderDO> selectListByRelationCode(String relationCode);


    @Query("from BusinessOrderDO w where w.traceNo = ?1 ")
    BusinessOrderDO selectByTraceNo(String traceNo);

    @Query("from BusinessOrderDO w where w.status = ?1 and w.orderCategory <>4")
    List<BusinessOrderDO> selectByStatus(Integer status);

    @Query("from BusinessOrderDO w where w.patient = ?1 and w.status=?2  and w.orderCategory =?3")
    List<BusinessOrderDO> selectByPatientAndStatusAndOrderCategory(String patient,Integer status,String orderCategory);

    @Query("from BusinessOrderDO  w where w.status=0 and w.lastPayTime<=?1")
    List<BusinessOrderDO> selectByLastPayTime(Long lastPayTime);
}