diff --git a/Dao/MyBatis/Maps/Lect.xml b/Dao/MyBatis/Maps/Lect.xml
index 5f70d71..532004b 100644
--- a/Dao/MyBatis/Maps/Lect.xml
+++ b/Dao/MyBatis/Maps/Lect.xml
@@ -1105,26 +1105,19 @@
,l.lectno longval,a.payno longval2
,c.cname strval,null strval2,null strval3
,c.rstime time,c.retime time2
- ,row_number() over(order by c.retime) rno
+ ,case when b.pstatus = 1 then 99 else b.pstatus end as sortpstatus
+ ,case when c.retime = '2099-12-31 23:59:59' then l.cdt else c.retime end as sortretime
+ ,row_number() over(order by sortpstatus, sortretime, b.payno,a.pino) rno
from payitem a
inner join pay b on b.payno=a.payno and b.pstatus in (1,21,22,51,55) and b.rstatus < 2
inner join cm c on c.cmno=a.itemno and c.rstime < and c.retime >
inner join lect l on l.cmno=c.cmno and (l.status < 5 or l.status = 6) and l.ischanged=0 and l.userno=b.userno
- inner join term d on d.tmno=c.tmno
- left outer join (
- select l.lectno
- ,count(li.cmino) cnt
- from payitem a
- inner join pay b on b.payno= a.payno and b.pstatus in (1,21,22,51,55) and b.rstatus < 2
- inner join cm c on c.cmno = a.itemno and c.rstime < and c.retime >
- inner join lect l on l.cmno = c.cmno and (l.status < 5 or l.status = 6) and l.ischanged =0 and l.userno = b.userno
- left outer join lectinning li on li.lectno = l.lectno and li.istatus is not null
- where a.ptype in (0,1,4) and a.userno=#userno# and a.pstatus in (1,21,22,51,55) and a.rstatus =0
- group by l.lectno
- )li on li.lectno = l.lectno
- left outer join payrfd e on e.payno=a.payno and e.payno=a.payno and e.rstatus=0
- where a.ptype in (0,1,4) and a.userno=#userno# and a.pstatus in (1,21,22,51,55) and a.rstatus=0 and li.cnt = 0
- order by rno
+ inner join term d on d.tmno=c.tmno
+ left outer join payrfd e on e.payno=a.payno and e.payno=a.payno and e.rstatus=0
+ where a.ptype in (0,1,4) and a.userno=#userno# and a.pstatus in (1,21,22,51,55) and a.rstatus=0
+ and 1 = case when c.retime = '2099-12-31 23:59:59' and l.stime is not null then 0 else 1 end
+ order by sortpstatus, sortretime, b.payno,a.pino
+ limit 3
) a
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8
diff --git a/Dao/MyBatis/Maps/Pay.xml b/Dao/MyBatis/Maps/Pay.xml
index 2544008..29bb308 100644
--- a/Dao/MyBatis/Maps/Pay.xml
+++ b/Dao/MyBatis/Maps/Pay.xml
@@ -542,6 +542,8 @@
,cmis.estart cmiestart,cmis.eend cmieend
,case when lect.sdate is null then c.sstime else lect.sdate end as sdate
,case when lect.edate is null then c.setime else lect.edate end as edate
+ ,case when b.pstatus = 1 then 99 else b.pstatus end as sortpstatus
+ ,case when c.retime = '2099-12-31 23:59:59' then lect.cdt else c.retime end as sortretime
from pay a
inner join payitem b on b.payno=a.payno and b.ptype in (0,1,4) and b.pstatus in (1,21,22,51,55)
inner join cm c on c.cmno=b.itemno and c.rstime < now() and c.retime > now()
@@ -555,6 +557,7 @@
left outer join lect lect on lect.pino=b.pino and lect.ischanged=0
left outer join cminningscd cmis on cmis.cmisno=lect.cmisno
where a.userno=#userno# and a.pstatus in (1,21,22,51,55) and lect.status < 8
+ and 1 = case when c.retime = '2099-12-31 23:59:59' and lect.stime is not null then 0 else 1 end
group by a.payno,a.isgroup,a.pstatus,a.rstatus
,b.pino,b.ptype,b.pcno,b.itemno,b.userno,b.pstatus,b.rstatus,b.isrebate
,c.cname,c.classno,c.rstime,c.retime,c.sstime,c.setime,c.cshape
@@ -566,7 +569,7 @@
,u.email
,lect.cmisno
,cmis.estart,cmis.eend
- order by c.retime,a.payno,b.pino
+ order by sortpstatus, sortretime, a.payno,b.pino
update pay set