YNICTE/Dao/MyBatis/Maps/CRoom.xml

1260 lines
78 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<sqlMap xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/tr/xmlschema-1/" namespace="">
<alias>
</alias>
<cacheModels>
<cacheModel id="croomCache" implementation="LRU" >
<flushInterval hours="1" />
<property name="CacheSize" value="1000" />
</cacheModel>
</cacheModels>
<resultMaps></resultMaps>
<statements>
<select id="cr.main.mygrade" parameterClass="hashtable" resultClass="lect">
select b.isrebate,b.iscomplete,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when b.isrebate = 1 then d.attendcutrfd else d.attendcut end acut
,case when b.isrebate = 1 then d.midcutrfd else d.midcut end mcut
,case when b.isrebate = 1 then d.finalcutrfd else d.finalcut end fcut
,case when b.isrebate = 1 then d.subjectcutrfd else d.subjectcut end scut
,case when b.isrebate = 1 then d.discusscutrfd else d.discusscut end dcut
,case when b.isrebate = 1 then d.cutrfd else d.cut end cut
,case when b.isrebate = 1 then d.attendrfd else d.attend end attend
,case when b.isrebate = 1 then d.midrfd else d.mid end mid
,case when b.isrebate = 1 then d.finalrfd else d.final end final
,case when b.isrebate = 1 then d.subjectrfd else d.subject end subject
,case when b.isrebate = 1 then d.discussrfd else d.discuss end discuss
,case when b.isrebate = 1 then d.attendrfd else d.attend end aportion
,case when b.isrebate = 1 then d.midrfd else d.mid end mportion
,case when b.isrebate = 1 then d.finalrfd else d.final end fportion
,case when b.isrebate = 1 then d.subjectrfd else d.subject end sportion
,case when b.isrebate = 1 then d.discussrfd else d.discuss end dportion
from (
<include refid="grade.query"></include>
) a
inner join lect b on b.lectno=a.lectno
inner join users u on u.userno=b.userno
inner join cmev d on d.cmno=b.cmno
</select>
<select id="cr.main.boardalarm" parameterClass="hashtable" resultClass="data">
select a.*
from (
select a.*
from (
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3,a.strval4
,a.time,a.time2
,a.rno
from (
select 3 dtype
,2 intval,c.iseq intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7
,a.lectno longval
,b.cname strval,b.studyplace strval2,concat(date_format(c.idate,'%m/%d'),' ',left(c.ist,2),':',right(c.ist,2),' ~ ',left(c.iet,2),':',right(c.iet,2)) strval3,bc.cname strval4
,b.sstime time,b.setime time2
,row_number() over(partition by a.cmno order by c.iseq) rno2
,row_number() over(order by b.setime) rno
from lect a
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include> and b.cshape=1
left outer join comcode bc on bc.ccode=b.studyplace
inner join cminning c on c.cmno=b.cmno and c.isonline=0
<!--left outer join lectinning d on d.lectno=a.lectno and d.cmino=c.cmino and d.istatus=2-->
where a.lectno=#lectno# and a.userno=#userno# and a.status=1 and a.ischanged=0
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3,a.strval4
,a.time,a.time2
,a.rno
from (
select 3 dtype
,3 intval,0 intval2,b.classno intval3,c.extype intval4,0 intval5,0 intval6,a.cmno intval7
,a.lectno longval
,b.cname strval,b.studyplace strval2,null strval3,bc.cname strval4
,b.sstime time,b.setime time2
,row_number() over(partition by a.cmno order by c.extype,c.cdt) rno2
,row_number() over(order by b.setime) rno
from lect a
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmex c on c.cmno=b.cmno and c.isdel=0 and c.econdition &lt;= a.attrate
left outer join lectex d on d.lectno=a.lectno and d.exno=c.exno and d.eend is not null
where a.lectno=#lectno# and a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3,a.strval4
,a.time,a.time2
,a.rno
from (
select 3 dtype
,4 intval,0 intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7
,a.lectno longval
,b.cname strval,b.studyplace strval2,null strval3,bc.cname strval4
,b.sstime time,b.setime time2
,row_number() over(partition by a.cmno order by c.cdt) rno2
,row_number() over(order by b.setime) rno
from lect a
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmsd c on c.sdtype=0 and c.cmno=b.cmno and c.isdel=0 and c.sdcondition &lt;= a.attrate
left outer join lectsd d on d.lectno=a.lectno and d.sdno=c.sdno and d.submittime is not null
where a.lectno=#lectno# and a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3,a.strval4
,a.time,a.time2
,a.rno
from (
select 3 dtype
,5 intval,0 intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7
,a.lectno longval
,b.cname strval,b.studyplace strval2,null strval3,bc.cname strval4
,b.sstime time,b.setime time2
,row_number() over(partition by a.cmno order by c.cdt) rno2
,row_number() over(order by b.setime) rno
from lect a
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmsd c on c.sdtype=1 and c.cmno=b.cmno and c.isdel=0 and c.sdcondition &lt;= a.attrate
left outer join lectsdboard d on d.lectno=a.lectno and d.sdno=c.sdno and d.isdel=0
where a.lectno=#lectno# and a.userno=#userno# and a.status=1 and a.ischanged=0
group by b.classno,a.cmno,a.lectno,b.cname,b.studyplace,b.sstime,b.setime,c.cdt,bc.cname
having count(d.lectno) &lt; 1
) a
where a.rno2=1
) a
limit 3
) a
<isNotNull property="bmnos">
union all
select a.*
from (
select 100 dtype,a.bmno intval,0 intval2,0 intval3,0 intval4,0 intval5,0 intval6,0 intval7
,a.bno longval,0 longval2
,b.bmname strval,a.subject strval2,null strval3
,a.cdt time,null time2
,row_number() over(order by a.cdt desc) rno
from board a
inner join boardmaster b on b.bmno=a.bmno
where a.bmno in ($bmnos$) and a.isdel=0 and a.issecr=0 and a.isopen=1 and a.cmno=#cmno#
order by a.cdt desc
limit 3
) a
</isNotNull>
</select>
<select id="cr.cminnings" parameterClass="hashtable" resultClass="lectinning">
select a.lectno,a.cmno,a.isrebate
,a2.isseq,a2.sstime,a2.setime
,b.cmino,b.iseq,b.isonline,b.ititle,b.sttime,b.idate,b.ist,b.iet,b.icontent
,cp.istatus preistatus
,c.totstudy,c.istatus,c.stime
,case when b.isonline=1 then d.tfurl else null end tfurl
,case when b.isonline=1 then df.fileurl else df3.fileurl end fileurl
,case when b.isonline=1 then df.fileno else df3.fileno end fileno
<!--,concat('/', d.ccode, '/', e.srcp) tasteurl-->
,df2.fileurl tasteurl
from lect a
inner join cm a2 on a2.cmno=a.cmno
inner join cminning b on b.cmno=a2.cmno
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino
left outer join cminning bp on bp.cmno=b.cmno and bp.iseq=b.iseq-1
left outer join lectinning cp on cp.lectno=a.lectno and cp.cmino=bp.cmino
left outer join ct d on b.isonline = 1 and d.ctno=b.ctno <!--and d.ctype=0-->
left outer join fileinfo df2 on b.isonline=1 and df2.fgno=d.fgnothumb and df2.isdel=0
left outer join fileinfo df on b.isonline=1 and df.fgno=d.fgnotf and df.isdel=0
left outer join fileinfo df3 on b.isonline=0 and df3.fgno=b.fgnotf and df3.isdel=0
left outer join ctpage e on e.ctno=d.ctno and e.pseq=1
where a.lectno=#lectno# and a.userno=#userno#
<isNotNull property="notstudy">and ifnull(c.istatus,0) &lt; 2 and a2.sstime &lt; now() and a2.setime &gt; now()</isNotNull>
order by b.iseq
<isNotNull property="limit">limit $limit$</isNotNull>
</select>
<select id="cr.lectinnings" parameterClass="hashtable" resultClass="lectinning">
select a.lectno,a.cmino
from lectinning a
where a.lectno=#lectno# <isNotNull property="isfinishtoday">a.istatus=2 and a.finishtime is not null and date_format(a.finishtime, '%y%m%d')=date_format(now(), '%y%m%d')</isNotNull>
</select>
<insert id="cr.lectinningpage.in" parameterClass="lectinningpage">
update lectinning a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cminning cmi on cmi.cmino=a.cmino
inner join ctpage ctp on ctp.ctno=cmi.ctno and ctp.isdel=0
<isGreaterThan property="pseq" compareValue="0">and ctp.pseq=#pseq#</isGreaterThan>
<isGreaterThan property="cpno" compareValue="0">and ctp.cpno=#cpno#</isGreaterThan>
<isGreaterThan property="isrelay" compareValue="0">and ctp.pseq=a.pseq</isGreaterThan>
set a.etime=now(),a.eip=now(),a.ispce=#ispc#
,a.pseq=ctp.pseq
,a.psec=case when a.pseq=ctp.pseq then a.psec else 0 end
,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.lectno=#lectno# and a.cmino=#cmino#;
insert into lectinning (lectno,cmino,totstudy,stime,etime,istatus,finishtime,sip,eip,ispcs,ispce,pseq,psec,<include refid="sql.inc"></include>)
select #lectno#,a.cmino,0,now(),now(),case when a.atime=0 then 2 else 0 end,case when a.atime=0 then now() else null end,#uip#,#uip#,#ispc#,#ispc#,ctp.pseq,0,<include refid="sql.inv"></include>
from cminning a
inner join ctpage ctp on ctp.ctno=a.ctno and ctp.isdel=0
<isGreaterThan property="pseq" compareValue="0">and ctp.pseq=#pseq#</isGreaterThan>
<isGreaterThan property="cpno" compareValue="0">and ctp.cpno=#cpno#</isGreaterThan>
<isGreaterThan property="isrelay" compareValue="0">and ctp.pseq=1</isGreaterThan>
left outer join lectinning b on b.lectno=#lectno# and b.cmino=#cmino#
where a.cmino=#cmino# and b.lectno is null;
update lect a
inner join (
select a.lectno,truncate(count(c.lectno) / count(b.cmino) * 100, 0) attrate
from lect a
inner join cminning b on b.cmno=a.cmno
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus=2
where a.lectno=#lectno# and a.userno=#userno#
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.stime=case when a.stime is null then now() else a.stime end
,a.etime=now()
,a.sip=case when a.sip is null then #uip# else a.sip end
,a.eip=#uip#
,a.ispcs=case when a.ispcs is null then #ispc# else a.ispcs end
,a.ispce=#ispc#
,udt=now(),uno=#uno#,uip=#uip#
where a.lectno=#lectno# and a.userno=#userno#;
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into lectinningpage(lectno,cmino,cpno,totstudy,stime,etime,sip,eip,ispc,webkitinfo,<include refid="sql.inc"></include>)
select b.lectno,a.cmino,p.cpno,0,now(),now(),#uip#,#uip#,#ispc#,#webkitinfo#,<include refid="sql.inv"></include>
from cminning a
inner join lectinning li on li.lectno=#lectno# and li.cmino=a.cmino
inner join ct ct on ct.ctno=a.ctno
inner join ctpage p on p.ctno=ct.ctno and p.isdel=0
<isGreaterThan property="pseq" compareValue="0">and p.pseq=#pseq#</isGreaterThan>
<isGreaterThan property="cpno" compareValue="0">and p.cpno=#cpno#</isGreaterThan>
<isGreaterThan property="isrelay" compareValue="0">and p.pseq=li.pseq</isGreaterThan>
inner join lect b on b.lectno=#lectno# and b.userno=#userno# and b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
where a.cmino=#cmino#
<selectKey type="post" property="logno" resultClass="long">SELECT last_insert_id()</selectKey>
</insert>
<select id="cr.ctps" parameterClass="hashtable" resultClass="ctp">
select a.cmino,a.iseq,a.ititle,a.atime,a.mstime,a.metime
,a2.isokmid
,b.ctno,b.ctype,b.ccode,b.ismenu,b.isoversize
,c.cpno,c.pseq,c.cpname,c.srcp,c.srcm
,a2.pseq lastpseq,a2.psec
from cminning a
inner join lectinning a2 on a2.lectno=#lectno# and a2.cmino=a.cmino
inner join ct b on b.ctno=a.ctno and b.isdel=0
inner join ctpage c on c.ctno=b.ctno and c.isdel=0
where a.cmino=#cmino#
order by a.iseq
</select>
<update id="cr.studylog" parameterClass="hashtable">
update lectinningpage a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
set a.totstudy=TIMESTAMPDIFF(SECOND, a.stime, now()),a.etime=now(),a.eip=#uip#,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.logno=#logno#;
update lectinning a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cminning c on c.cmino=a.cmino
inner join (
select lectno,sum(totstudy) totstudy from lectinningpage where lectno=#lectno# and cmino=#cmino# group by lectno
) d on d.lectno=a.lectno
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.totstudy=d.totstudy
,a.etime=now()
,a.istatus=case when a.istatus &lt;&gt; 2 and c.atime * 60 &lt;= d.totstudy then 2 else a.istatus end
,a.finishtime=case when a.finishtime is null and c.atime * 60 &lt;= d.totstudy then now() else null end
,a.eip=#uip#,a.ispce=#ispc#
,a.psec=#psec#
where a.lectno=#lectno# and a.cmino=#cmino#;
update lect a
inner join (
select a.lectno,truncate(count(c.lectno) / count(b.cmino) * 100, 0) attrate
from lect a
inner join cminning b on b.cmno=a.cmno
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus=2
where a.lectno=#lectno# and a.userno=#userno#
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.etime=now()
,a.eip=#uip#
,a.ispce=#ispc#
,udt=now(),uno=#uno#,uip=#uip#
where a.lectno=#lectno# and a.userno=#userno#;
</update>
<select id="cr.inningchange.pre" parameterClass="hashtable" resultClass="lectinning">
select a.cmino,b.isseq,c.istatus,d.istatus preistatus,a.isrebate,a.iseq,a2.cmino precmino
from (
select a.lectno,a.cmno,a.isrebate,b.cmino,b.iseq,max(c.iseq) preiseq
from (
select a.lectno,b.cmno,b.isrebate,max(d.iseq) iseq
from lectinning a
inner join lect b on b.lectno=a.lectno
inner join cminning c on c.cmino=a.cmino
inner join cminning d on d.cmno=c.cmno and d.iseq &lt; c.iseq and d.isonline=1
where a.lectno=#lectno# and a.cmino=#cmino#
group by a.lectno,b.cmno,b.isrebate
) a
inner join cminning b on b.cmno=a.cmno and b.iseq=a.iseq
left outer join cminning c on c.cmno=b.cmno and c.iseq &lt; b.iseq and c.isonline=1
group by a.lectno,a.cmno,a.isrebate,b.cmino,b.iseq
) a
inner join cm b on b.cmno=a.cmno
left outer join cminning a2 on a2.cmno=b.cmno and a2.iseq=a.preiseq
left outer join lectinning c on c.lectno=a.lectno and c.cmino=a.cmino
left outer join lectinning d on d.lectno=a.lectno and d.cmino=a2.cmino
</select>
<select id="cr.inningchange.next" parameterClass="hashtable" resultClass="lectinning">
select a.cmino,b.isseq,c.istatus,d.istatus preistatus,a.isrebate,a.iseq,a2.cmino precmino
from (
select a.lectno,a.cmno,a.isrebate,b.cmino,b.iseq,min(c.iseq) preiseq
from (
select a.lectno,b.cmno,b.isrebate,min(d.iseq) iseq
from lectinning a
inner join lect b on b.lectno=a.lectno
inner join cminning c on c.cmino=a.cmino
inner join cminning d on d.cmno=c.cmno and d.iseq &gt; c.iseq and d.isonline=1
where a.lectno=#lectno# and a.cmino=#cmino#
group by a.lectno,b.cmno,b.isrebate
) a
inner join cminning b on b.cmno=a.cmno and b.iseq=a.iseq
left outer join cminning c on c.cmno=b.cmno and c.iseq &gt; b.iseq and c.isonline=1
group by a.lectno,a.cmno,a.isrebate,b.cmino,b.iseq
) a
inner join cm b on b.cmno=a.cmno
left outer join cminning a2 on a2.cmno=b.cmno and a2.iseq=a.preiseq
left outer join lectinning c on c.lectno=a.lectno and c.cmino=a.cmino
left outer join lectinning d on d.lectno=a.lectno and d.cmino=a2.cmino
</select>
<select id="cr.ctpage.iframe" parameterClass="hashtable" resultClass="string">
select $src$ from ctpage where cpno=#cpno#
</select>
<update id="cr.studymid" parameterClass="hashtable">
update lectinning set isokmid=1 where lectno=#lectno# and cmino=#cmino#
</update>
<select id="cr.mycmrs" parameterClass="hashtable" resultClass="cmrs">
select distinct a.lectno,a.attrate
,b.rsno,b.cmno,b.rscno,b.rstype,b.rsname,b.rscondition
,case when c.lectno is null then 0 else 1 end isrsok
from lect a
inner join cmrs b on b.cmno=a.cmno and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
where a.lectno=#lectno# and a.userno=#userno#
order by b.cdt
</select>
<select id="cr.mycmrsq" parameterClass="hashtable" resultClass="rscq">
select b.rscno,b.rscqno
,c.qno,c.atype,c.qtext,c.rightcount
from (
select distinct b.rscno
from lect a
inner join cmrs b on b.rsno=#rsno# and b.cmno=a.cmno and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
where a.lectno=#lectno# and a.userno=#userno# and c.lectno is null
) a
inner join rscq b on b.rscno=a.rscno
inner join question c on c.qno=b.qno
order by b.dseq
</select>
<select id="cr.mycmrsqi" parameterClass="hashtable" resultClass="rscq">
select b.rscqno
,c.qno
,d.qino,d.qitext
,e.fileurl
from (
select distinct b.rscno
from lect a
inner join cmrs b on b.rsno=#rsno# and b.cmno=a.cmno and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
where a.lectno=#lectno# and a.userno=#userno# and c.lectno is null
) a
inner join rscq b on b.rscno=a.rscno
inner join question c on c.qno=b.qno
inner join questionitem d on d.qno=c.qno and d.isdel=0
left outer join fileinfo e on e.fgno=d.fgno and e.isdel=0
order by b.dseq,d.qino
</select>
<update id="cr.lectrs.in" parameterClass="lectrs">
insert into lectrs(lectno,rsno,rscno,rscqno,qno,atext,<include refid="sql.inc"></include>)
select a.lectno,b.rsno,b.rscno,c.rscqno,c.qno,c.atext,<include refid="sql.inv"></include>
from lect a
inner join cmrs b on b.rsno=#rsno#
left outer join lectrs a0 on a0.lectno=a.lectno and a0.rsno=b.rsno
inner join (
<iterate property="Ds" open="" conjunction="union all" close=""> select a.rscqno,a.qno,#Ds[].atext# atext from rscq a where a.rscqno=#Ds[].rscqno# </iterate>
) c on c.rscqno is not null
where a.lectno=#lectno# and a.userno=#userno# and a0.lectno is null
</update>
<select id="cr.myestimation" parameterClass="hashtable" resultClass="data">
select a.*
from (
select 0 dtype
,null strval,0 intval10
,0 intval,0 intval2,0 intval3,0 intval4
,0 rno
from (select 1 col1) a
where a.col1=0
<isNotNull property="exam">
union all
select b.extype dtype
,b.exname strval,b.exno intval10
,case when a2.sstime &lt; now() and a2.setime &gt; now() then a.attrate else -1 end intval,b.econdition intval2
,case when c.eend is null then 0 else 1 end intval3,null intval4
,row_number() over (partition by b.extype order by b.extype, b.cdt) rno
from lect a
inner join cm a2 on a2.cmno=a.cmno
inner join cmex b on b.cmno=a.cmno and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
where a.lectno=#lectno# and a.userno=#userno#
</isNotNull>
<isNotNull property="subject">
union all
select 2 dtype
,b.sdname strval,b.sdno intval10
,case when a2.sstime &lt; now() and a2.setime &gt; now() then a.attrate else -1 end intval,b.sdcondition intval2,case when c.submittime is null then 0 else 1 end intval3,case when c.checktime is null then 0 else 1 end intval4
,row_number() over (order by b.cdt) rno
from lect a
inner join cm a2 on a2.cmno=a.cmno
inner join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
where a.lectno=#lectno# and a.userno=#userno#
</isNotNull>
<isNotNull property="discuss">
union all
select 3 dtype
,b.sdname strval,b.sdno intval10
,case when a2.sstime &lt; now() and a2.setime &gt; now() then a.attrate else -1 end intval,b.sdcondition intval2
,case when count(d.bno) &gt; 0 then 1 else 0 end intval3
,case when c.checktime is null then 0 else 1 end intval4
,row_number() over (order by b.cdt) rno
from lect a
inner join cm a2 on a2.cmno=a.cmno
inner join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
left outer join lectsdboard d on d.lectno=a.lectno and d.sdno=b.sdno and d.isdel=0
where a.lectno=#lectno# and a.userno=#userno#
group by b.sdname,b.sdno,a2.sstime,a2.setime,a.attrate,b.sdcondition,c.checktime,b.cdt
</isNotNull>
) a
order by a.dtype,a.rno
</select>
<select id="cr.lectex" parameterClass="hashtable" resultClass="lectex">
select a.lectno,a.attrate
,b.sstime,b.setime
,c.exno,c.exname,c.extype,c.edesc,c.econdition,c.etime,c.evtype,c.eqtype,c.israndq,c.israndqi,c.qcount,c.isblur,c.tpoint,ifnull(c.relaylimit,999) relaylimit,c.isusebackup,c.isseq,c.isresultopen
,d.lectno exlectno,d.estart,d.eend,d.tpoint,d.recount,d.rechecktime,ifnull(d.entercount,0) entercount,d.cblock
,case when a.etime = 0 then 99999999 else TIMESTAMPDIFF(MINUTE, now(), date_add(ifnull(d.estart, now()), interval c.etime MINUTE)) end rtime
,d.recount
from lect a
inner join cm b on b.cmno=a.cmno
inner join cmex c on c.exno=#exno#
left outer join lectex d on d.lectno=a.lectno and d.exno=c.exno
where a.lectno=#lectno# and a.userno=#userno#
</select>
<select id="cr.userexamdata.start" parameterClass="hashtable" resultClass="lectexq">
<include refid="lectexcreate"></include>
select case when a.etime = 0 then 99999999 else TIMESTAMPDIFF(MINUTE, now(), date_add(ifnull(b.estart, now()), interval a.etime MINUTE)) end etime
,a.qcount,a.evtype,a.israndqi,a.tpoint,a.isblur,a.isusebackup,a.isseq
,b.cblock
,c.atext,c.qseq
,d.eqno,d.rpoint
,e.atype,e.qtext,e.qno,e.rightcount,e.ispassspace,e.isignorecase
from cmex a
inner join cm a3 on a3.cmno=a.cmno
inner join lect a2 on a2.lectno=#lectno# and a2.userno=#userno#
inner join lectex b on b.lectno=a2.lectno and b.exno=a.exno and b.eend is null and (a.etime = 0 or date_add(ifnull(b.estart, now()), interval a.etime MINUTE) &gt; now())
and ifnull(b.entercount,0) &lt;= ifnull(a.relaylimit, 999)
inner join lectexq c on c.lectno=b.lectno and c.exno=b.exno
inner join cmexq d on d.eqno=c.eqno
inner join question e on e.qno=d.qno
where a.exno=#exno# and now() between a3.sstime and a3.setime
order by c.qseq;
update lectex a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join cmex b on b.exno=a.exno
set
a.estart=case when a.estart is null then now() else a.estart end
,a.entercount=ifnull(a.entercount,0)+1
,a.uno=#uno#
,a.uip=#uip#
,a.eip=#uip#
where a.lectno=#lectno# and a.exno=#exno# and a.eend is null and ifnull(a.entercount,0) &lt;= ifnull(b.relaylimit, 999)
</select>
<select id="cr.userexamquestionitem.get" parameterClass="hashtable" resultClass="questionitem">
select a.qno, a.qino, a.isright, a.qitext, b.fileno, b.fileurl
from questionitem a
left outer join fileinfo b on b.fgno=a.fgno and b.isdel=0
where a.qno in ($qnos$) and a.isdel=0
<isNotNull property="orderby">order by $orderby$</isNotNull>
</select>
<select id="cr.userexam.detailforexamforsubmit" parameterClass="hashtable" resultClass="cmex">
select a.exno,a.exname,a2.sstime,a2.setime,a.tpoint,a.etime,a.qcount,b.estart,a.edesc,TIMESTAMPDIFF(MINUTE, now(), date_add(ifnull(b.estart, now()), interval a.etime MINUTE)) rtime
from cmex a
inner join cm a2 on a2.cmno=a.cmno
inner join lectex b on b.lectno=#lectno# and b.exno=a.exno and b.eend is null and (a.etime = 0 or date_add(ifnull(b.estart, now()), interval (a.etime + 1) MINUTE) &gt; now())
inner join lect c on c.lectno=b.lectno and c.userno=#userno#
where a.exno=#exno#
</select>
<select id="cr.questionitem.listforcheck" parameterClass="string" resultClass="questionitem">
select a.qino,a.qitext,b.atype,a.qno
from questionitem a
inner join question b on b.qno=a.qno
where a.qno in ($qnos$) and a.isright=1 and a.isdel=0
order by a.qno, a.qino
</select>
<update id="cr.examsubmit" parameterClass="lectex">
update lectexq a
inner join lectex d on d.lectno=a.lectno and d.exno=a.exno and d.eend is null
inner join lect d2 on d2.lectno=d.lectno and d2.userno=#userno#
inner join cmex c on c.exno=a.exno
inner join (
<iterate property="UED" open="" conjunction="union all" close="">
select #exno# exno, #UED[].eqno# eqno, #UED[].atext# atext, #UED[].qinos# qinos, #UED[].iscorrect# iscorrect
</iterate>
) b on b.exno=a.exno and b.eqno=a.eqno
set a.atext=b.atext, a.qinos=b.qinos,a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.cpoint=case when b.iscorrect = 1 then a.dpoint else 0 end
,a.iscorrect=b.iscorrect
where a.lectno=#lectno# and a.exno=#exno#;
update lectex a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join (
select a.exno, sum(ifnull(a.cpoint, 0)) tpoint
from lectexq a
where a.lectno=#lectno# and a.exno=#exno#
group by a.exno
) b on b.exno=a.exno
inner join cmex c on c.exno=a.exno
set a.udt=now(),a.uno=#userno#,a.uip=#uip#
<isEqual property="issubmit" compareValue="1">,a.eend=now()</isEqual>
, a.tpoint=b.tpoint
<!--, a.overtime=case when #zstring20# is null then a.overtime else now() end-->
,a.cblock=#cblock#
where a.lectno=#lectno# and a.exno=#exno# and a.eend is null
</update>
<update id="cr.examsubmitbackup" parameterClass="lectex">
update lectexq a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join lectex d on d.lectno=a.lectno and d.exno=a.exno and d.eend is null
inner join cmex c on c.exno=a.exno
inner join (
<iterate property="UED" open="" conjunction="union all" close="">
select #exno# exno, #UED[].eqno# eqno, #UED[].atext# atext, #UED[].qinos# qinos, #UED[].iscorrect# iscorrect
</iterate>
) b on b.exno=a.exno and b.eqno=a.eqno
set a.atext=b.atext, a.qinos=b.qinos,a.udt=now(),a.uno=#uno#
,a.cpoint=case when b.iscorrect = 1 then a.dpoint else 0 end
,a.iscorrect=b.iscorrect
where a.lectno=#lectno# and a.exno=#exno#;
update lectex a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join (
select a.exno, sum(ifnull(a.cpoint, 0)) tpoint
from lectexq a
where a.exno=#exno# and a.lectno=#lectno#
group by a.exno
) b on b.exno=a.exno
inner join cmex c on c.exno=a.exno
set a.udt=now(),a.uno=#userno#
, a.tpoint=b.tpoint
<!--, a.overtime=case when #zstring20# is null then a.overtime else now() end-->
where a.lectno=#lectno# and a.exno=#exno# and a.eend is null
</update>
<select id="cr.lectsd" parameterClass="hashtable" resultClass="lectsd">
select a.lectno,a.attrate,a.cmno
,b.sdno,b.sdname,b.sddesc,b.fgno sdfgno,b.sdcondition
,c.sstime,c.setime
,d.checktime,d.cpoint,d.feedb,d.fgno,d.atext
from lect a
inner join cmsd b on b.cmno=a.cmno and b.sdno=#sdno#
inner join cm c on c.cmno=b.cmno
left outer join lectsd d on d.lectno=a.lectno and d.sdno=b.sdno
where a.lectno=#lectno# and a.userno=#userno#
</select>
<update id="cr.lectsd.save" parameterClass="lectsd">
update lectsd a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.fgno=#fgno#,a.atext=#atext#
,a.submittime=now(),submitip=#uip#
where a.lectno=#lectno# and a.sdno=#sdno# and a.checktime is null;
insert into lectsd (lectno,sdno,atext,fgno,iscopy,submittime,submitip,<include refid="sql.inc"></include>)
select a.lectno,a.sdno,#atext#,#fgno#,0,now(),#uip#,<include refid="sql.inv"></include>
from (select #lectno# lectno,#userno# userno,#sdno# sdno) a
inner join lect b on b.lectno=a.lectno and b.userno=a.userno
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
left outer join lectsd d on d.lectno=a.lectno and d.sdno=a.sdno
where d.lectno is null;
</update>
<select id="cr.lectsd2" parameterClass="hashtable" resultClass="lectsd">
select a.lectno,a.attrate
,b.sdno,b.sdname,b.sddesc,b.fgno sdfgno,b.sdcondition
,c.sstime,c.setime
,d.checktime,d.cpoint,d.feedb,d.fgno,d.atext
from lect a
inner join cmsd b on b.cmno=a.cmno and b.sdno=#sdno#
inner join cm c on c.cmno=b.cmno
left outer join lectsd d on d.lectno=a.lectno and d.sdno=b.sdno
where a.lectno=#lectno# and a.userno=#userno#
</select>
<select id="cr.lectsdboards" parameterClass="int" resultClass="lectsdboard">
select a.bno,a.subject,a.cdt,a.rcount
,u.username
,count(b.bcno) ccount
from lectsdboard a
inner join users u on u.userno=a.cno
left outer join lectsdboardcmt b on b.bno=a.bno and b.isdel=0
where a.sdno=#sdno# and a.isdel=0
group by a.bno,a.subject,a.cdt,a.rcount,u.username
order by a.cdt
</select>
<select id="cr.lectsdboard" parameterClass="long" resultClass="lectsdboard">
update lectsdboard set rcount=rcount+1 where bno=#bno# and cno&lt;&gt;#userno#;
select a.bno,a.subject,a.contents,a.cdt,a.fgno,a.cno
,b.sdname
,c.sstime,c.setime
,u.username,u.userno
,a2.checktime
from lectsdboard a
inner join lectsd a2 on a2.lectno=a.lectno and a2.sdno=a.sdno
inner join users u on u.userno=a.cno
inner join cmsd b on b.sdno=a.sdno
inner join cm c on c.cmno=b.cmno
where a.bno=#bno# and a.isdel=0
</select>
<update id="cr.lectsdboard.save" parameterClass="lectsdboard">
update lectsd a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.submittime=now(),submitip=#uip#
where a.lectno=#lectno# and a.sdno=#sdno# and a.checktime is null;
update lectsdboard a
inner join lectsd a2 on a2.lectno=a.lectno and a2.sdno=a.sdno and a2.checktime is null
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.subject=#subject#,contents=#contents#,a.fgno=#fgno#
where a.bno=#bno# and a.lectno=#lectno# and a.sdno=#sdno#;
</update>
<insert id="cr.lectsdboard.in" parameterClass="lectsdboard">
update lectsd a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.submittime=now(),submitip=#uip#
where a.lectno=#lectno# and a.sdno=#sdno# and a.checktime is null;
insert into lectsd (lectno,sdno,iscopy,submittime,submitip,<include refid="sql.inc"></include>)
select a.lectno,a.sdno,0,now(),#uip#,<include refid="sql.inv"></include>
from (select #lectno# lectno,#userno# userno,#sdno# sdno) a
inner join lect b on b.lectno=a.lectno and b.userno=a.userno
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now()
left outer join lectsd d on d.lectno=a.lectno and d.sdno=a.sdno
where d.lectno is null;
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into lectsdboard (lectno,sdno,subject,contents,fgno,rcount,cip,isdel,<include refid="sql.inc"></include>)
select a.lectno,a.sdno,#subject#,#contents#,#fgno#,0,#uip#,0,<include refid="sql.inv"></include>
from (select #lectno# lectno,#userno# userno,#sdno# sdno) a
inner join lect b on b.lectno=a.lectno and b.userno=a.userno
inner join cm c on c.cmno=b.cmno and c.sstime &lt; now() and c.setime &gt; now();
<selectKey type="post" property="bno" resultClass="long">SELECT last_insert_id()</selectKey>
</insert>
<select id="cr.lectsdboardcmt" parameterClass="long" resultClass="boardcmt">
select a.bno
,b.bcno,b.ctext,b.cno,b.cdt
,c.userno,c.username,c.usertype,c.username cnoname
from lectsdboard a
inner join lectsdboardcmt b on b.bno=a.bno and b.isdel=0
inner join users c on c.userno=b.cno
where a.bno=#bno#
order by b.cdt desc
</select>
<update id="cr.lectsdboard.del" parameterClass="hashtable">
update lectsd a
inner join lectsdboard b on b.bno=#bno# and b.cno=#userno# and b.isdel=0 and b.lectno=a.lectno and b.sdno=a.sdno
inner join lect a2 on a2.lectno=b.lectno and a2.userno=b.cno
inner join cm c on c.cmno=a2.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.submittime=null,a.submitip=null and a.checktime is null;
update lectsdboard a
inner join lectsd b on b.lectno=a.lectno and b.sdno=a.sdno and b.checktime is null
inner join lect a2 on a2.lectno=b.lectno and a2.userno=a.cno
inner join cm c on c.cmno=a2.cmno and c.sstime &lt; now() and c.setime &gt; now()
set a.uno=#uno#,a.udt=now(),a.uip=#uip#
,a.isdel=1
where a.bno=#bno# and a.cno=#userno# and a.isdel=0;
</update>
<insert id="cr.lectsdboardcmt.in" parameterClass="boardcmt">
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into lectsdboardcmt (bno,ctext,isdel,<include refid="sql.inc"></include>)
values (#bno#,#ctext#,0,<include refid="sql.inv"></include>);
<selectKey type="post" property="bcno" resultClass="long">SELECT LAST_INSERT_ID()</selectKey>
</insert>
<update id="cr.lectsdboardcmt.up" parameterClass="boardcmt">
update lectsdboardcmt set <include refid="sql.up"></include>
,ctext=#ctext#
where bcno=#bcno# <isGreaterThan property="cno" compareValue="0">and cno=#cno#</isGreaterThan>
</update>
<update id="cr.lectsdboardcmt.del" parameterClass="hashtable">
update lectsdboardcmt set <include refid="sql.up"></include>,isdel=1 where bcno=#bcno# <isGreaterThan property="cno" compareValue="0">and cno=#cno#</isGreaterThan>
</update>
<select id="cr.payitems" parameterClass="hashtable" resultClass="payitem">
select a.*
from (
select a.isexamready,a.ccount
,case when a.isexamready=1 then ue.exno else p.payno end payno
,case when a.isexamready=1 then 0 else p.ptype end pptype,p.payoktime,p.isgroup
,case when a.isexamready=1 then case when ua.isjoin=1 then uee.infee else uee.outfee end else p.payamt end payamt,p.refundamt,p.rstatus
,case when a.isexamready=1 then 21 else p.pstatus end pstatus
,case when a.isexamready=1 then ue.cdt else case pi.ptype when 3 then exu.cdt when 4 then le.oktime else p.cdt end end cdt
,case when a.isexamready=1 then ue.exno else pi.pino end pino,pi.isrebate
,case when a.isexamready=1 then 3 else pi.ptype end ptype
,case when a.isexamready=1 then 0 else p.isunpay end isunpay
,case when p.rstatus=0 and pr.rstatus = 0 and pri.rfdno is not null then 1 else 0 end isrefundcall
,u.userno,u.userid,u.username
,ua.asname,ua.isjoin
,cm.cshape,cm.sstime,cm.setime
,case when a.isexamready=1 then uee.exname else case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end end itemname
,row_number() over(order by case when pr.rstatus=0 and pri.rfdno is not null then 0 else 1 end, case when a.isexamready=1 then ue.cdt else p.cdt end desc) rno
,count(p.payno) over() pagetotalcount
from (
select 0 isexamready,p.payno,max(case when pi.ptype in (0,1,3,4) then pi.pino else 0 end) pi1,min(pi.pino) pi2,count(pi.pino) ccount
from pay p
inner join payitem pi on pi.payno=p.payno
<isNotNull property="piptype">and pi.ptype=#piptype#</isNotNull>
<isNotNull property="isrebates">and pi.ptype in (0, 4) and pi.isrebate in ($isrebates$)</isNotNull>
inner join users u on u.userno=p.userno
left outer join assign ua on ua.asno=u.asno
left outer join payrfditem pri on pri.pino=pi.pino
left outer join payrfd pr on pr.rfdno=pri.rfdno
left outer join cm cm on pi.ptype in (0,1,4) and cm.cmno=pi.itemno
left outer join cm cm2 on cm2.cmno=cm.pcmno
left outer join cg cg on cg.cgno=cm.cgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
where p.pstatus in (1,21,22,41,42,43) and (pri.rfdno is null or pr.rfdno is not null)
<isNotNull property="cdts">and p.cdt &gt;= #cdts#</isNotNull>
<isNotNull property="cdte">and p.cdt &lt;= #cdte#</isNotNull>
<!--<isNotNull property="pstatusin">and p.pstatus in ($pstatusin$)</isNotNull>-->
<isNotNull property="isrefundcall">and (p.rstatus =0 and pr.rstatus=0 and pri.rfdno is not null)</isNotNull>
<!--<isNotNull property="rstatusin">and pi.rstatus in ($rstatusin$)</isNotNull>-->
<isNotNull property="pstatusall">$pstatusall$</isNotNull>
<isNotNull property="ptypein">and p.ptype in ($ptypein$)</isNotNull>
<isNotNull property="isjoin">and ua.isjoin=#isjoin#</isNotNull>
<isNotNull property="asname">and ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="brno">and ua.brno=#brno#</isNotNull>
<isNotNull property="cshape">and cm.cshape=#cshape#</isNotNull>
<isNotNull property="pcgno">and cg.pcgno=#pcgno#</isNotNull>
<isNotNull property="username">and u.username=#username#</isNotNull>
<isNotNull property="userid">and u.userid=#userid#</isNotNull>
<isNotNull property="itemname">and (cm.cname like concat('%',#itemname#,'%') or bk.bkname like concat('%',#itemname#,'%') or ex.exname like concat('%',#itemname#,'%'))</isNotNull>
<isNotNull property="cname">and (cm2.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotNull property="usernameiditemname">and (u.username=#usernameiditemname# or u.userid=#usernameiditemname# or cm.cname like concat('%',#usernameiditemname#,'%') or bk.bkname like concat('%',#usernameiditemname#,'%') or ex.exname like concat('%',#usernameiditemname#,'%') or cm2.cname like concat('%',#usernameiditemname#,'%'))</isNotNull>
<isNotNull property="isgroup">and p.isgroup=1</isNotNull>
<isNotNull property="isunpay">and p.isunpay=#isunpay#</isNotNull>
group by p.payno
union all
select 1 isexamready,a.exno payno,a.userno pi1,a.userno pi2,1 ccount
from examuser a
inner join exam ex on ex.exno=a.exno <isNotNull property="itemname">and ex.exname like concat('%',#itemname#,'%')</isNotNull>
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
where a.status=1 and a.payno is null and a.pino is null and a.pstatus=4
<isNotNull property="piptype">and #piptype#=3</isNotNull>
<isNotNull property="isrebates">and a.exno=0</isNotNull>
<isNotNull property="rstatusin">and a.exno=0</isNotNull>
<isNotNull property="cdts">and a.cdt &gt;= #cdts#</isNotNull>
<isNotNull property="cdte">and a.cdt &lt;= #cdte#</isNotNull>
<isNotNull property="pstatusin">and concat(',',#pstatusin#,',') like '%,21,%'</isNotNull>
<isNotNull property="isrefundcall">and a.exno=0</isNotNull>
<isNotNull property="ptypein">and a.exno=0</isNotNull>
<isNotNull property="isjoin">and ua.isjoin=#isjoin#</isNotNull>
<isNotNull property="asname">and ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="brno">and ua.brno=#brno#</isNotNull>
<isNotNull property="cshape">and a.exno=0</isNotNull>
<isNotNull property="pcgno">and a.exno=0</isNotNull>
<isNotNull property="username">and u.username=#username#</isNotNull>
<isNotNull property="userid">and u.userid=#userid#</isNotNull>
<isNotNull property="usernameiditemname">and (u.username=#usernameiditemname# or u.userid=#usernameiditemname# or ex.exname like concat('%',#usernameiditemname#,'%'))</isNotNull>
<isNotNull property="isgroup">and a.exno=0</isNotNull>
) a
left outer join pay p on a.isexamready=0 and p.payno=a.payno
left outer join payitem pi on a.isexamready=0 and pi.pino=case when a.pi1=0 then a.pi2 else a.pi1 end
left outer join examuser ue on a.isexamready=1 and ue.exno=a.payno and ue.userno=a.pi1
left outer join exam uee on a.isexamready=1 and uee.exno=ue.exno
inner join users u on u.userno=case when a.isexamready=0 then p.userno else ue.userno end
left outer join assign ua on ua.asno=u.asno
left outer join payrfditem pri on a.isexamready=0 and pri.pino=pi.pino
left outer join payrfd pr on a.isexamready=0 and pr.rfdno=pri.rfdno
left outer join cm cm on a.isexamready=0 and pi.ptype in (0,1,4) and cm.cmno=pi.itemno
left outer join lect le on a.isexamready=0 and le.pino=pi.pino and le.ischanged=0
left outer join book bk on a.isexamready=0 and pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on a.isexamready=0 and ex.exno=pi.itemno
left outer join examuser exu on exu.exno=ex.exno and exu.userno=p.userno
where (pri.rfdno is null or pr.rfdno is not null)
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
<!--select a.*
from (
select p.payno,p.ptype pptype,p.payoktime
,case pi.ptype when 3 then exu.cdt when 4 then le.oktime else p.cdt end cdt
,pi.pino,pi.isrebate,pi.ptype,pi.payamt,pi.refundamt,pi.rstatus,pi.pstatus
,case when pri.rfdno is not null then 1 else 0 end isrefundcall
,u.userno,u.userid,u.username
,ua.asname,ua.isjoin
,cm.cshape
,case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname
,row_number() over(order by case when pr.rfdno is not null then 0 else 1 end, p.cdt desc) rno
,count(p.payno) over() pagetotalcount
from pay p
inner join payitem pi on pi.payno=p.payno
<isNotNull property="piptype">and pi.ptype=#piptype#</isNotNull>
<isNotNull property="isrebates">and pi.ptype in (0, 4) and pi.isrebate in ($isrebates$)</isNotNull>
<isNotNull property="rstatusin">and pi.rstatus in ($rstatusin$)</isNotNull>
inner join users u on u.userno=p.userno
left outer join assign ua on ua.asno=u.asno
left outer join payrfditem pri on pri.pino=pi.pino
left outer join payrfd pr on pr.rfdno=pri.rfdno and pr.rstatus=0
left outer join cm cm on pi.ptype in (0,1,4) and cm.cmno=pi.itemno
left outer join lect le on le.pino=pi.pino and le.ischanged=0
left outer join cg cg on cg.cgno=cm.cgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
left outer join examuser exu on exu.exno=ex.exno and exu.userno=p.userno
where p.pstatus in (1,21,22,41,42,43) and (pri.rfdno is null or pr.rfdno is not null)
<isNotNull property="cdts">and p.cdt &gt;= #cdts#</isNotNull>
<isNotNull property="cdte">and p.cdt &lt;= #cdte#</isNotNull>
<isNotNull property="pstatusin">and p.pstatus in ($pstatusin$)</isNotNull>
<isNotNull property="isrefundcall">and pr.rfdno is not null</isNotNull>
<isNotNull property="ptypein">and p.ptype in ($ptypein$)</isNotNull>
<isNotNull property="isjoin">and ua.isjoin=#isjoin#</isNotNull>
<isNotNull property="asname">and ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="brno">and ua.brno=#brno#</isNotNull>
<isNotNull property="cshape">and cm.cshape=#cshape#</isNotNull>
<isNotNull property="pcgno">and cg.pcgno=#pcgno#</isNotNull>
<isNotNull property="username">and u.username=#username#</isNotNull>
<isNotNull property="userid">and u.userid=#userid#</isNotNull>
<isNotNull property="itemname">and (cm.cname like concat('%',#itemname#,'%') or bk.bkname like concat('%',#itemname#,'%') or ex.exname like concat('%',#itemname#,'%'))</isNotNull>
<isNotNull property="usernameiditemname">and (u.username=#usernameiditemname# or u.userid=#usernameiditemname# or cm.cname like concat('%',#usernameiditemname#,'%') or bk.bkname like concat('%',#usernameiditemname#,'%') or ex.exname like concat('%',#usernameiditemname#,'%'))</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno-->
</select>
<select id="cr.pay1" parameterClass="long" resultClass="pay">
select p.payno,p.cdt,p.payamt,p.ptype,p.refundamt,p.ispg,p.isgroup,p.isexam,p.pstatus,p.rstatus,p.payoktime,p.pgkey,p.isdvr,p.deliamt,p.isunpay,p.paylimit
,u.username,u.post,u.address1,u.address2
,CAST(AES_DECRYPT(UNHEX(u.userpno), <include refid="sql.digest"></include>) AS char) userpno
,CAST(AES_DECRYPT(UNHEX(u.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email
,case pi.ptype when 3 then exu.cdt when 4 then le.oktime else p.cdt end oktime
,pd.dvrcode,pd.rcvname,pd.isdvr isdvr2,pd.codetime,pd.post post2,pd.address1 address12,pd.address2 address22,pd.dmemo
,CAST(AES_DECRYPT(UNHEX(pd.telno), <include refid="sql.digest"></include>) AS char) telno2
,CAST(AES_DECRYPT(UNHEX(pd.mobile), <include refid="sql.digest"></include>) AS char) mobile2
from pay p
inner join users u on u.userno=p.userno
left outer join payitem pi on pi.payno=p.payno and pi.ptype in (3,4)
left outer join lect le on pi.ptype=4 and le.pino=pi.pino and le.ischanged=0
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
left outer join examuser exu on exu.exno=ex.exno and exu.userno=p.userno
left outer join paydvr pd on pd.payno=p.payno
where p.payno=#payno#
</select>
<select id="cr.pay2" parameterClass="long" resultClass="payitem">
select pi.payno,pi.pino,pi.itemno,pi.pcno,pi.payamt,pi.pcnt,pi.ptype
,case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname
,u.username,u.userid,u.isassignuser,u.depart,u.kfcfyear
,cc.cname ccpositionname
,CAST(AES_DECRYPT(UNHEX(u.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,ua.asname
,cm.cshape
,cg.cgname
,pcg.cgname pcgname
from payitem pi
inner join pay p on p.payno=pi.payno
left outer join cm cm on pi.ptype in (0,1,4) and cm.cmno=pi.itemno
left outer join cg cg on pi.ptype in (0,1,4) and cg.cgno=cm.cgno
left outer join cg pcg on pcg.cgno=cg.pcgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
left outer join users u on p.isgroup=1 and u.userno=pi.userno
left outer join assign ua on ua.asno=u.asno
left outer join comcode cc on cc.ccode=u.ccposition
where pi.payno=#payno#
</select>
<select id="cr.payforexam1" parameterClass="hashtable" resultClass="pay">
select eu.exno payno, eu.userno,eu.cdt,case when ua.isjoin=1 then ex.infee else ex.outfee end payamt,0 ptype,0 ispg,0 isgroup,1 isexam,21 pstatus,0 rstatus,null payoktime,null pgkey,0 isdvr,0 deliamt
,u.username,u.post,u.address1,u.address2
,CAST(AES_DECRYPT(UNHEX(u.userpno), <include refid="sql.digest"></include>) AS char) userpno
,CAST(AES_DECRYPT(UNHEX(u.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email
,eu.cdt oktime
,null dvrcode,null rcvname,0 isdvr2,null codetime,null post2,null address12,null address22,null dmemo
,null telno2
,null mobile2
from examuser eu
inner join users u on u.userno=eu.userno
left outer join assign ua on ua.asno=u.asno
left outer join exam ex on ex.exno=eu.exno
where eu.exno=#exno# and eu.userno=#userno# and eu.status=1 and eu.payno is null and eu.pino is null and eu.pstatus=4
</select>
<select id="cr.payforexam2" parameterClass="hashtable" resultClass="payitem">
select eu.exno payno,eu.userno pino,eu.exno itemno,null pcno,case when ua.isjoin=1 then ex.infee else ex.outfee end payamt,1 pcnt,3 ptype
,ex.exname itemname
,u.username,u.userid,u.isassignuser,u.depart,u.kfcfyear
,cc.cname ccpositionname
,CAST(AES_DECRYPT(UNHEX(u.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,ua.asname
,0 cshape
,null cgname
,null pcgname
from examuser eu
left outer join exam ex on ex.exno=eu.exno
left outer join users u on u.userno=eu.userno
left outer join assign ua on ua.asno=u.asno
left outer join comcode cc on cc.ccode=u.ccposition
where eu.exno=#exno# and eu.userno=#userno#
</select>
<insert id="cr.examuserpayok" parameterClass="pay">
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into pay (ptype,ispg,isgroup,isexam,userno,username,pstatus,rstatus,rstatustime,cshrcancelnum,canceltime,cancelmsg,cancelcnt
,refunding,paylimit,payoktime,pgkey,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,isdvr,<include refid="sql.inc"></include>)
select #ptype#,0,0,1,u.userno,u.username,1,0,null,null,null,null,null
,0,null,#payoktime#,null
,a.outfee
,case when #ptype# = 6 then a.outfee else case when ua.isjoin=1 then a.outfee-a.infee else 0 end end
,0,0
,case when #ptype# = 6 then 0 else case when ua.isjoin=1 then a.infee else a.outfee end end
,0,0,<include refid="sql.inv"></include>
from exam a
inner join users u on u.userno=#userno#
left outer join assign ua on ua.asno=u.asno
where a.exno=#exno#
<selectKey type="post" property="payno" resultClass="long">SELECT last_insert_id()</selectKey>
</insert>
<insert id="cr.examuserpayok2" parameterClass="payitem">
SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0;
insert into payitem (payno,ptype,pcno,itemno,userno,pstatus,rstatus,pgkey,cancelcode,cancelmsg,canceltype,pcnt
,orgamt,discamt,payamt
,payamtcash,payamtcard
,refundamt,refundtime,refundtimereal,refundinfo,isrebate,fgno,cartno,<include refid="sql.inc"></include>)
select p.payno,3,null,#itemno#,#userno#,1,0,null,null,null,null,1
,a.outfee
,case when p.ptype=6 then a.outfee else case when ua.isjoin=1 then a.outfee-a.infee else 0 end end
,case when p.ptype=6 then 0 else case when ua.isjoin=1 then a.infee else a.outfee end end
,0,0
,0,null,null,null,0,null,null,<include refid="sql.inv"></include>
from exam a
inner join users u on u.userno=#userno#
inner join pay p on p.payno=#payno#
left outer join assign ua on ua.asno=u.asno
where a.exno=#itemno#
<selectKey type="post" property="pino" resultClass="long">SELECT last_insert_id()</selectKey>
</insert>
<update id="cr.examuserpayok3" parameterClass="payitem">
update examuser set <include refid="sql.up"></include>
,payno=#payno#,pino=#pino#,pstatus=1
where exno=#itemno# and userno=#userno# and status=1 and payno is null and pino is null and pstatus=4
</update>
<update id="cr.examuserpaycancel" parameterClass="hashtable">
update examuser set <include refid="sql.up"></include>
,pstatus=9
where exno=#exno# and userno=#userno# and status=1 and payno is null and pino is null and pstatus=4
</update>
<select id="cr.pay.forrfd" parameterClass="long" resultClass="pay">
select a.payno,a.ispg,a.pstatus,a.ptype,a.pgkey,a.isdvr,a.deliamt,a.isrefunddvr,a.payamt,a.refundamt,a.rstatus,a.isgroup,a.iscanceled
,b.isdvr isdvr2,b.dvrcode
,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email
from pay a
left outer join paydvr b on b.payno=a.payno
inner join users u on u.userno=a.userno
where a.payno=#payno# and a.pstatus=1
</select>
<select id="cr.payitem.forrfd" parameterClass="long" resultClass="payitem">
select pi.pino,pi.payno,pi.pcnt,pi.payamt,pi.refundamt,pi.refundtime,pi.refundinfo,pi.refundstatus,pi.rstatus,pi.ptype
,case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname
,pcg.cgname pcgname
,u.userid,u.username
from payitem pi
inner join pay p on p.payno=pi.payno and p.pstatus=1
inner join users u on u.userno=case when pi.ptype=3 then p.userno else pi.userno end
left outer join cm cm on pi.ptype in(0,1,4) and cm.cmno=pi.itemno
left outer join cg cg on cg.cgno=cm.cgno
left outer join cg pcg on pcg.cgno=cg.pcgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
where pi.payno=#payno#
</select>
<select id="cr.payrfditems" parameterClass="long" resultClass="payrfd">
select b.cdt,a.rfdno
,b.rtext,b.rstatus
,p.isgroup
,case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname
,pi.ptype
,u.username,u.userid
from pay p
inner join payitem pi on pi.payno=p.payno
inner join payrfditem a on a.pino=pi.pino
inner join payrfd b on b.rfdno=a.rfdno
inner join users u on u.userno=case when p.isgroup=1 and pi.ptype in (0,1,4) then pi.userno else p.userno end
left outer join cm cm on pi.ptype in(0,1,4) and cm.cmno=pi.itemno
left outer join cg cg on cg.cgno=cm.cgno
left outer join cg pcg on pcg.cgno=cg.pcgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
where p.payno=#payno#
order by a.rfdno desc
</select>
<select id="cr.payrfditems2" parameterClass="long" resultClass="payrfd">
select a.rfdno
,b.rtext,b.rstatus,b.cdt,b.isowner,b.ramt,b.bankname,b.bankowner
,CAST(AES_DECRYPT(UNHEX(b.bankno), <include refid="sql.digest"></include>) AS char) bankno
,p.isgroup
,pi.payamt
,case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname
,u.username,u.userid
,CAST(AES_DECRYPT(UNHEX(u.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,ua.asname
from payrfditem a
inner join payitem pi on pi.pino=a.pino
inner join pay p on p.payno=pi.payno
inner join users u on u.userno=case when p.isgroup=1 and pi.ptype in (0,1,4) then pi.userno else p.userno end
left outer join assign ua on ua.asno=u.asno
inner join payrfd b on b.rfdno=a.rfdno
left outer join cm cm on pi.ptype in(0,1,4) and cm.cmno=pi.itemno
left outer join cg cg on cg.cgno=cm.cgno
left outer join cg pcg on pcg.cgno=cg.pcgno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
where a.rfdno=#rfdno#
order by a.rfdno desc
</select>
<update id="cr.payrfd.save" parameterClass="hashtable">
update payrfd set <include refid="sql.up"></include>
,isowner=#isowner#,ramt=#ramt#,bankname=#bankname#,bankowner=#bankowner#,bankno=HEX(AES_ENCRYPT(#bankno#, <include refid="sql.digest"></include>))
,rstatus=#rstatus#,statustime=case when rstatus &lt;&gt; #rstatus# then now() else statustime end
where rfdno=#rfdno#
</update>
<select id="cr.payitems.forcheck" parameterClass="string" resultClass="payitem">
select a.pino,a.ptype
from payitem a
where a.pino in ($pinos$) and a.pstatus=1 and a.rstatus=0
</select>
<select id="cr.payitems.forcheck2" parameterClass="string" resultClass="payitem">
select a.pino,a.ptype
from payitem a
where a.pino in ($pinos$) and a.pstatus=1 and a.rstatus&lt;&gt;0
</select>
<update id="cr.paycancel" parameterClass="pay">
update pay set <include refid="sql.up"></include>
,rstatus=1,rstatustime=now(),cancelcnt=case when #cancelcnt# = 0 then cancelcnt else #cancelcnt# end
,isrefunddvr=case when isrefunddvr = 0 and #isrefunddvr# = 1 then 1 else isrefunddvr end
,refundamt = refundamt + #newrefundamt#
,iscanceled = #iscanceled#
where payno=#payno#;
update payitem a
inner join (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) b on b.pino=a.pino
set a.rstatus=1,a.pgkey=#cancelcode#,a.refundamt=b.refundamt,a.refundtime=b.refundtime,a.refundtimereal=now(),a.refundinfo=b.refundinfo,a.refundstatus=b.refundstatus
where a.payno=#payno# and a.rstatus=0;
<isNotNull property="pinosexamuser">
update examuser set udt=now(),uno=#uno#,uip=#uip#
,pstatus=8
where payno=#payno# and pino in ($pinosexamuser$);
</isNotNull>
<isNotNull property="pinoslect">
update lect set udt=now(),uno=#uno#,uip=#uip#
,status=8
where payno=#payno# and pino in ($pinoslect$) and ischanged=0;
</isNotNull>
<isNotNull property="pinosexamuser2">
update payitem a
inner join (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].rstatus# rstatus,#PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) b on b.pino=a.pino and b.rstatus &gt; 0
set a.refundstatus=b.refundstatus
where a.payno=#payno# and a.pino in ($pinosexamuser2$) and a.rstatus&gt;0;
update examuser a
inner join (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].rstatus# rstatus,#PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) b on b.pino=a.pino and b.rstatus &gt; 0
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.pstatus=case when b.refundstatus=1 then 8 else 1 end
where a.payno=#payno# and a.pino in ($pinosexamuser2$);
</isNotNull>
<isNotNull property="pinoslect2">
update payitem a
inner join (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].rstatus# rstatus,#PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) b on b.pino=a.pino and b.rstatus &gt; 0
set a.refundstatus=b.refundstatus
where a.payno=#payno# and a.pino in ($pinoslect2$) and a.rstatus&gt;0;
update lect a
inner join (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].rstatus# rstatus,#PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) b on b.pino=a.pino and b.rstatus &gt; 0
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.status=case when b.refundstatus=1 then 8 else 1 end
where a.payno=#payno# and a.pino in ($pinoslect2$);
</isNotNull>
insert into payrfdlog (payno,pino,refundamt,refunddate,dmemo,pistatus,<include refid="sql.inc"></include>)
select #payno#,a.pino,a.refundamt,a.refundtime,a.refundinfo,a.refundstatus,<include refid="sql.inv"></include>
from (
<iterate property="PIs" open="" conjunction="union all" close=""> select #PIs[].pino# pino,#PIs[].refundamt# refundamt,#PIs[].refundstatus# refundstatus,#PIs[].refundtime# refundtime,#PIs[].refundinfo# refundinfo </iterate>
) a;
<isGreaterThan property="isrefunddvr" compareValue="0">
insert into payrfdlog (payno,pino,refundamt,refunddate,dmemo,pistatus,<include refid="sql.inc"></include>)
values(#payno#,null,#deliamt#,now(),"택배비환불",0,<include refid="sql.inv"></include>);
</isGreaterThan>
</update>
<!--<update id="cr.lectchange" parameterClass="pay">
update payitem a
inner join (
<iterate property="PIs" open="" conjunction="union all" close="">
select a.pino, case when #PIs[].rstatus# = 1 then #PIs[].refundstatus# else a.refundstatus end refundstatus
from payitem a
where a.pino=#PIs[].pino#
</iterate>
) b on b.pino=a.pino
set a.refundstatus=b.refundstatus
where a.payno=#payno# and a.pino=b.pino;
update lect a
inner join (
<iterate property="PIs" open="" conjunction="union all" close="">
select a.pino,case when (case when #PIs[].rstatus# = 1 then #PIs[].refundstatus# else ifnull(a.refundstatus,0) end) = 0 then 1 else 8 end status
from payitem a
where a.pino = #PIs[].pino#
</iterate>
) b on b.pino=a.pino
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.status=b.status
where a.payno=#payno# and a.pino=b.pino and a.ischanged=0;
</update>-->
<select id="cr.paytaxes" parameterClass="hashtable" resultClass="paytax">
select a.*
from (
select a.taxno,ifnull(a.cname, ifnull(a.exname, a.bkname)) itemname,a.asaddr,a.pcnt,a.ccount,b.iscancel
,b.payno,b.asname,b.taxamt,b.cdt,b.taxdate,b.ceoname,b.brno,b.grno,b.btype,b.bkind,b.manname,b.fgno,b.taxinfo,b.isreceipt
,CAST(AES_DECRYPT(UNHEX(b.telno), <include refid="sql.digest"></include>) AS char) telno
,CAST(AES_DECRYPT(UNHEX(b.email), <include refid="sql.digest"></include>) AS char) email
,u.userno cno,u.username,u.userid
,ua.isjoin
,row_number() over(order by b.cdt desc) rno
,count(a.taxno) over() pagetotalcount
from (
select a.taxno,max(cm.cname) cname,a.asaddr,max(bk.bkname) bkname,max(ex.exname) exname,sum(pi.pcnt) pcnt,count(pi.pino) ccount
from paytax a
inner join paytaxitem b on b.taxno=a.taxno
inner join payitem pi on pi.pino=b.pino
left outer join cm cm on pi.ptype in (0,1,4) and cm.cmno=pi.itemno
inner join cm cm2 on cm2.cmno=cm.pcmno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
inner join users u on u.userno=a.cno
<dynamic prepend="where">
<isNotNull property="payno" prepend="and">a.payno = #payno#</isNotNull>
<isNotNull property="cno" prepend="and">a.cno = #cno#</isNotNull>
<isNotNull property="nottaxno" prepend="and">a.taxno &lt;&gt; #nottaxno#</isNotNull>
<isNotNull property="taxno" prepend="and">a.taxno=#taxno#</isNotNull>
<isNotNull property="iscancel" prepend="and">ifnull(a.iscancel,0)=#iscancel#</isNotNull>
<isNotNull property="cdts" prepend="and">a.cdt &gt;= #cdts#</isNotNull>
<isNotNull property="cdte" prepend="and">a.cdt &lt;= #cdte#</isNotNull>
<isNotNull property="tstatus0" prepend="and">a.taxdate is null</isNotNull>
<isNotNull property="tstatus1" prepend="and">a.taxdate is not null</isNotNull>
<isNotNull property="tstatus1" prepend="and">a.taxdate is not null</isNotNull>
<isNotNull property="username" prepend="and">u.username like concat('%',#username#,'%')</isNotNull>
<isNotNull property="userid" prepend="and">u.userid like concat('%',#userid#,'%')</isNotNull>
<isNotNull property="manname" prepend="and">a.manname like concat('%',#manname#,'%')</isNotNull>
<isNotNull property="itemname" prepend="and">(cm.cname like concat('%', #itemname#, '%') or bk.bkname like concat('%', #itemname#, '%') or ex.exname like concat('%', #itemname#, '%'))</isNotNull>
<isNotNull property="cname" prepend="and">cm2.cname like concat('%', #cname#, '%')</isNotNull>
<isNotNull property="nimp" prepend="and">
(u.username=#nimp# or u.userid=#nimp# or a.manname=#nimp# or cm.cname like concat('%', #nimp#, '%') or bk.bkname like concat('%', #nimp#, '%') or ex.exname like concat('%', #nimp#, '%') or cm2.cname like concat('%', #nimp#, '%'))
</isNotNull>
</dynamic>
group by a.taxno
) a
inner join paytax b on b.taxno=a.taxno
inner join users u on u.userno=b.cno
left outer join assign ua on ua.asno=u.asno
) a
<include refid="sql.pagedynamic"></include>
order by rno
</select>
<select id="cr.paytaxitem" parameterClass="long" resultClass="payitem">
select case pi.ptype when 2 then bk.bkname when 3 then ex.exname else cm.cname end itemname,pi.payamt,pi.pcnt,pi.ptype
,p.isgroup,p.payamt ppayamt,p.payoktime,p.ptype pptype
from paytax a
inner join paytaxitem b on b.taxno=a.taxno
inner join payitem pi on pi.pino=b.pino
inner join pay p on p.payno=pi.payno
left outer join cm cm on pi.ptype in (0,1,4) and cm.cmno=pi.itemno
left outer join book bk on pi.ptype=2 and bk.bkno=pi.itemno
left outer join exam ex on pi.ptype=3 and ex.exno=pi.itemno
where a.taxno=#taxno#
</select>
<select id="cr.paytaxes2" parameterClass="long" resultClass="paytax">
select a.taxno,a.taxamt,a.taxdate
from paytax a
where a.payno=#payno#
</select>
<update id="cr.paytax.save" parameterClass="paytax">
update paytax
set <include refid="sql.up"></include>
,asname=#asname#
,ceoname=#ceoname#
,brno=#brno#
,grno=#grno#
,btype=#btype#
,bkind=#bkind#
,manname=#manname#
,telno=HEX(AES_ENCRYPT(#telno#, <include refid="sql.digest"></include>))
,email=HEX(AES_ENCRYPT(#email#, <include refid="sql.digest"></include>))
,taxdate=#taxdate#
,taxinfo=#taxinfo#
,iscancel=#iscancel#
where taxno=#taxno#
</update>
</statements>
</sqlMap>