insert into pay(ptype,ispg,isgroup,userno,username,isexam,pstatus,rstatus,refunding,paylimit,payoktime,pgkey
,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,pplno,isbill,iscashrct,)
values (#ptype#,#ispg#,#isgroup#,#userno#,#username#,0,#pstatus#,#rstatus#,#refunding#,#paylimit#,case when #isinmoney# is not null then else #payoktime# end,#pgkey#
,#orgamt#,#discamt#,#deliamt#,#isrefunddvr#,#payamt#,#refundamt#,#pplno#,#isbill#,#iscashrct#,);
SELECT LAST_INSERT_ID()
insert into payitem (payno,ptype,pcno,itemno,userno,pstatus,rstatus,pcnt,orgamt,discamt,payamt,payamtcash,payamtcard,refundamt,refundtime,refundtimereal,refundinfo,isrebate,rbank,rbankaccnum,tbankuser,)
values(#payno#,#ptype#,#pcno#,#itemno#,#userno#,#pstatus#,#rstatus#,#pcnt#,#orgamt#,#discamt#,#payamt#,#payamtcash#,#payamtcard#,#refundamt#,#refundtime#,#refundtimereal#,#refundinfo#,#isrebate#,#rbank#,#rbankaccnum#,#tbankuser#,);
SELECT LAST_INSERT_ID()
insert into lect (cmno,payno,pino,userno,status,isready,iscomplete,orgcmno,attrate,isrebate,ispc,pcno,isjoin,fgno,ischanged,cmisno,)
values(#itemno#,#payno#,#pino#,#userno#,#status#,#isready#,null,null,0,#isrebate#,#ispc#,#pcno#,#isjoin#,null,0,#cmisno#,);
SELECT LAST_INSERT_ID()
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno = #payno#;
update paydvr set
,dvrcode=#dvrcode#,codetime=
where payno=#payno#
insert into paycart(isgroup,ptype,itemno,isrefund,cmno,userno,pcnt,status,fgno,)
select 0,#ptype#,#itemno#,#isrefund#,#cmno#,#userno#,#pcnt#,#status#,#fgno#,
from (select 1 col1) a
left outer join paycart b on b.ptype=#ptype# and b.itemno=#itemno# and b.userno=#userno# and b.status=1
where b.pcno is null;
insert into paycart(isgroup,ptype,itemno,isrefund,cmno,userno,pcnt,status,fgno,)
select #isgroup#,9,a.itemno,#isrefund#,#itemno#,#userno#,a.pcnt,#status#,null,
from (
select #Ds[].itemno# itemno,#Ds[].pcnt# pcnt
) a
insert into pay(ptype,ispg,isgroup,isexam,userno,username,pstatus,rstatus
,refunding,paylimit,payoktime,pgkey,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,isdvr,iscashrct,cashrcthp,pplno,isbill,)
select #ptype#,#ispg#,#isgroup#,#isexam#,a.userno,a.username,case when #ptype# = 6 then 1 else 0 end,0
,#refunding#,#paylimit#,case when #ptype# = 6 then now() else #payoktime# end,#pgkey#,#orgamt#,#discamt#,#deliamt#,#isrefunddvr#,#payamt#,#refundamt#,#isdvr#,#iscashrct#,HEX(AES_ENCRYPT(#cashrcthp#, )),#pplno#,#isbill#,
from users a
where a.userno=#userno#
SELECT LAST_INSERT_ID()
insert into payitem (payno,ptype,pcno,itemno,userno,pstatus,rstatus
,pcnt,orgamt,discamt,payamt,payamtcash,payamtcard,refundamt,refundtime,refundtimereal,refundinfo,isrebate,rbank,rbankaccnum,tbankuser,fgno,)
select #payno#,a.ptype,null,a.itemno,a.userno,case when #ptype# = 6 then 1 else 0 end,0
,a.pcnt,a.orgamt,a.discamt,a.payamt,0,0,0,null,null,null,a.isrebate,a.rbank,HEX(AES_ENCRYPT(a.rbankaccnum, )),a.tbankuser,ifnull(b.fgno,a.fgno),
from (
select #PIs[].ptype# ptype,#PIs[].itemno# itemno,#PIs[].userno# userno,#PIs[].pcnt# pcnt,#PIs[].orgamt# orgamt,#PIs[].discamt# discamt,#PIs[].payamt# payamt,#PIs[].isrebate# isrebate,#PIs[].rbank# rbank,#PIs[].rbankaccnum# rbankaccnum,#PIs[].tbankuser# tbankuser,#PIs[].fgno# fgno
) a
left outer join paycart b on #isexam# = 2 and a.ptype=0 and b.ptype=0 and b.itemno=a.itemno and b.userno=#userno# and b.status=1 and b.ispay=1
delete from paydvr where payno=#payno#;
insert into paydvr (payno,dvrcode,codetime,isdvr,rcvname,telno,mobile,email,post,address1,address2,dmemo,)
values (#payno#,#dvrcode#,#codetime#,#isdvr#,#rcvname#
,HEX(AES_ENCRYPT(#telno#, ))
,HEX(AES_ENCRYPT(#mobile#, ))
,HEX(AES_ENCRYPT(#email#, ))
,#post#,#address1#,#address2#,#dmemo#,)
insert into lect (cmno,payno,pino,userno,status,attrate,isrebate,ispc,isjoin,ischanged,fgno2,cmisno,)
select b.itemno,a.payno,b.pino,case when a.isgroup=1 then b.userno else a.userno end,1,0,b.isrebate,0,case when ua.isjoin=1 then 1 else 0 end,0,b.fgno,l.cmisno,
from pay a
inner join payitem b on b.payno=a.payno and b.ptype=0
inner join users u on u.userno=a.userno
inner join pplog l on a.pplno = l.pplno
left outer join assign ua on ua.asno=u.asno
where a.payno=#payno#;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on a.cmisno = d.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
where a.payno = #payno#;
update paydvr set
,dvrcode=#dvrcode#,rcvname=#rcvname#,post=#post#,address1=#address1#,address2=#address2#,dmemo=#dmemo#
,codetime=case when codetime is null and #dvrcode# is not null then now() else codetime end
,telno=HEX(AES_ENCRYPT(#telno#, ))
,mobile=HEX(AES_ENCRYPT(#mobile#, ))
where payno=#payno#
update pay a
inner join users b on b.userno=a.userno
set a.ptype=#ptype#,a.paylimit=#paylimit#,a.orgamt=#orgamt#,a.payamt=#payamt#,a.isbill=#isbill#
,a.pstatus = case when #ptype# = 6 then 1 else a.pstatus end
,a.payoktime = case when #ptype# = 6 then now() else a.payoktime end
where a.payno=#payno# and a.userno=#userno# and a.pstatus=21;
update payitem a
inner join users b on b.userno=a.userno
set a.orgamt=#orgamt#,a.payamt=#payamt#
,a.pstatus = case when #ptype# = 6 then 1 else a.pstatus end
,a.rstatus = 0
where a.payno=#payno# and a.userno=#userno# and a.pstatus=21;
update lect a
inner join users b on b.userno = a.userno
set a.status = case when #ptype# = 6 then 1 else a.status end
where a.payno=#payno# and a.userno = #userno#;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
where a.payno = #payno#;
update pay set
,pstatus=case when ptype=3 then 22 else 1 end
,payoktime=case when ptype=3 then null else end
,pgkey=#pgkey#
where payno=#payno#;
insert into paydata(payno,payresult,payresultmsg,vactnum,vactbankcode,vactbankname,vactname,vactinname,cshrrcode,cshrtype,cshrauthno,cardquota,cardquotatype,cardeventcode,cardnum,iscardpoint,cardcode,cardbankcode,cardprtccode,checkflag,ocbnum,ocbappno,ocbprice,gsnum,gsremain,gsprice,unum,upoint,uprice,)
values (#payno#,#payresult#,#payresultmsg#,HEX(AES_ENCRYPT(#vactnum#, )),#vactbankcode#,#vactbankname#,#vactname#,#vactinname#,#cshrrcode#,#cshrtype#,#cshrauthno#,#cardquota#,#cardquotatype#,#cardeventcode#,HEX(AES_ENCRYPT(#cardnum#, )),#iscardpoint#,#cardcode#,#cardbankcode#,#cardprtccode#,#checkflag#,#ocbnum#,#ocbappno#,#ocbprice#,#gsnum#,#gsremain#,#gsprice#,#unum#,#upoint#,#uprice#,);
update payitem a
inner join pay b on b.payno=a.payno
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.pstatus=case when b.ptype=3 then 22 else 1 end
where a.payno=#payno#;
insert into lect (cmno,payno,pino,userno
,status,iscomplete,orgcmno,attrate,isrebate
,ispc,isjoin,fgno,apoint,mpoint
,fpoint,spoint,dpoint,tpoint,ischanged
,stime,etime,sip,eip,ispcs
,ispce,fgno2,cmisno,)
select a.itemno,a.payno,a.pino,case when b.isgroup=1 then a.userno else b.userno end
,case when b.ptype=3 then 2 else 1 end,null,null,0,a.isrebate
,0,ifnull(d.isjoin, 0),null,null,null
,null,null,null,null,0
,null,null,null,null,null
,null,a.fgno,e.cmisno,
from payitem a
inner join pay b on b.payno=a.payno
inner join users c on c.userno=b.userno
left outer join assign d on d.asno=c.asno
left outer join pplog e on e.pplno=b.pplno
left outer join lect f on f.payno=a.payno and f.pino=a.pino and f.status=4 and f.isready=1
where a.payno=#payno# and a.ptype=0 and f.lectno is null;
update lect a
inner join pay b on b.payno=a.payno and b.pstatus in (22,1)
inner join payitem c on c.payno=b.payno and c.itemno=a.cmno and c.pstatus=b.pstatus
set a.status=case when b.pstatus=22 then 2 else 1 end,a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.status=4;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 23:59:59')
where a.payno = #payno#;
update pay set pstatus=#pstatus# where payno=#payno# and pstatus != 1 and pstatus != 22;
insert into paydata(payno,payresult,payresultmsg,vactnum,vactbankcode,vactbankname,vactname,vactinname,cshrrcode,cshrtype,cshrauthno,cardquota,cardquotatype,cardeventcode,cardnum,iscardpoint,cardcode,cardbankcode,cardprtccode,checkflag,ocbnum,ocbappno,ocbprice,gsnum,gsremain,gsprice,unum,upoint,uprice,)
values (#payno#,#payresult#,#payresultmsg#,HEX(AES_ENCRYPT(#vactnum#, )),#vactbankcode#,#vactbankname#,#vactname#,#vactinname#,#cshrrcode#,#cshrtype#,#cshrauthno#,#cardquota#,#cardquotatype#,#cardeventcode#,#cardnum#,#iscardpoint#,HEX(AES_ENCRYPT(#cardnum#, )),#cardbankcode#,#cardprtccode#,#checkflag#,#ocbnum#,#ocbappno#,#ocbprice#,#gsnum#,#gsremain#,#gsprice#,#unum#,#upoint#,#uprice#,);
insert into payvbankin (payno,pgkey,inbankcode,indeal,inymd,inhms,msgseq,transseq,vacct,inamt,checkamt,isclose,typemsg,frombank,fromname,fromymd,calcymd,tranymd,transcode,korcode,cshrymd,cshrhms,cshrcode,cshrpgkey,cshramt,)
values (#payno#,#pgkey#,#inbankcode#,#indeal#,#inymd#,#inhms#,#msgseq#,#transseq#,#vacct#,#inamt#,#checkamt#,#isclose#,#typemsg#,#frombank#,#fromname#,#fromymd#,#calcymd#,#tranymd#,#transcode#,#korcode#,#cshrymd#,#cshrhms#,#cshrcode#,#cshrpgkey#,#cshramt#,);
update pay set
,pstatus=1
,payoktime=
where payno=#payno# and pstatus=22 ;
update payitem a
inner join pay b on b.payno=a.payno
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.pstatus=1
where a.payno=#payno# and a.pstatus=22;
update lect a
inner join pay b on b.isexam <> 1 and b.payno=a.payno and b.pstatus=1
set a.udt=now(),a.uno=#uno#,a.uip=#uip#
,a.status=1
where a.payno=#payno#;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 23:59:59')
where a.payno = #payno#;
insert into pay(ptype,ispg,isgroup,userno,pstatus,rstatus,refunding,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,isdvr,isexam,)
values (0,1,0,#userno#,51,0,0,0,0,0,0,0,0,0,0,)
SELECT LAST_INSERT_ID()
insert into payitem (payno,ptype,itemno,userno,pstatus,rstatus,pcnt
,orgamt,discamt,payamt,payamtcash,payamtcard,refundamt,isrebate,fgno,)
values (#payno#,4,#cmno#,#userno#,51,0,1
,0,0,0,0,0,0,#isrebate#,#fgno#,);
insert into lect(cmno,payno,pino,userno,status,attrate,isrebate,ispc,isjoin,fgno,ischanged,fgno2,)
select #cmno#,#payno#,LAST_INSERT_ID(),a.userno,3,0,#isrebate#,0,b.isjoin,#fgno2#,0,#fgno#,
from users a
left outer join assign b on b.asno=a.asno
where a.userno=#userno#;
insert into payitem (payno,ptype,itemno,userno,pstatus,rstatus,pcnt,orgamt,discamt,payamt,payamtcash,payamtcard,refundamt,isrebate,fgno,)
select #payno#,2,#PIs[].itemno#,#userno#,50,0,#PIs[].pcnt#,0,0,0,0,0,0,0,null,now(),#uno#,now(),#uno#,#uip#
update pay set
,pstatus=case when pstatus=22 then 43 else 41 end
where payno=#payno# and userno=#userno# and pstatus in (51,55,21,22);
update payitem a
inner join pay b on b.payno=a.payno and b.userno=#userno# and b.pstatus in (41,43)
set a.pstatus=b.pstatus,a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.pstatus in (21,22);
update lect a
inner join pay b on b.payno=a.payno and b.userno=#userno# and b.pstatus in (41,43)
set a.status=9
where a.payno=#payno#;
update examuser a
inner join pay b on b.payno=a.payno and b.userno=a.userno and b.pstatus in (41,43)
set a.pstatus=9
where a.payno=#payno# and a.userno=#userno#
update paycart set status=2,udt=now(),uno=#uno#,uip=#uip# where userno=#userno# and status=1 and date_add(cdt, interval 7 day) < now();
update paycart a
inner join cm b on b.cmno=a.itemno and b.udt > a.cdt
set a.status=2,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.userno=#userno# and a.status=1 and a.ptype=0;
update paycart a
inner join book b on b.bkno=a.itemno and b.udt > a.cdt
set a.status=2,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.userno=#userno# and a.status=1 and a.ptype in (2,9);
update paycart a
left outer join cm b on b.cmno=a.itemno and b.rstime < now() and b.retime > now()
set a.status=2,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.userno=#userno# and a.status=1 and a.ptype=0 and b.cmno is null;
update paycart a
left outer join paycart b on b.ptype =0 and b.userno=#userno# and b.status=1 and b.itemno=a.cmno
set a.status=2,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.userno=#userno# and a.status=1 and a.ptype=9 and b.pcno is null
update paycart a
set a.status=0,
where a.userno=#userno# and a.status <>0
and a.pcno=#pcno#and a.pcno in ($pcnos$)
update paycart set ispay=0 where userno=#userno#;
update paycart a
set a.ispay=1
where a.userno=#userno# and a.status=1
and a.pcno=#pcno#and a.pcno in ($pcnos$)
insert into paytax(payno,taxamt,pcnt,asname,ceoname,brno,grno,btype,bkind,manname,telno,email,fgno,taxinfo,asaddr,isreceipt,taxdatereq,)
select a.payno
,sum(b.payamt)
,sum(b.pcnt)
,#asname#,#ceoname#
,#brno#
,#grno#
,#btype#,#bkind#,#manname#
,HEX(AES_ENCRYPT(#telno#, ))
,HEX(AES_ENCRYPT(#email#, ))
,#fgno#,#taxinfo#,#asaddr#,#isreceipt#,#taxdatereq#,
from pay a
inner join payitem b on b.payno=a.payno and b.pino in ($pinos$) and (a.pstatus=1 or a.pstatus=22) and a.rstatus=0
where a.payno=#payno# and a.userno=#uno# and (a.pstatus=1 or a.pstatus=22) and a.rstatus < 2
group by a.payno;
SELECT LAST_INSERT_ID()
insert into paytaxitem (taxno,pino,)
select #taxno#,b.pino,
from pay a
inner join payitem b on b.payno=a.payno and b.pino in ($pinos$) and (a.pstatus=1 or a.pstatus=22) and a.rstatus=0
where a.payno=#payno# and a.userno=#uno# and (a.pstatus=1 or a.pstatus=22) and a.rstatus < 2
delete from payrfditem
where rfdno in (select rfdno from payrfd where payno =#payno#);
delete from payrfd where payno=#payno#;
insert into payrfd(payno,rtext,bankname,bankno,bankowner,isowner,rstatus,ruser,rphone,rreason,fgnor,fgnob,ramt,)
select distinct #payno#,#rtext#,#bankname#
,HEX(AES_ENCRYPT(#bankno#, ))
,#bankowner#,#isowner#,#rstatus#,#ruser#
,HEX(AES_ENCRYPT(#rphone#, ))
,#rreason#,#fgnor#,#fgnob#,#ramt#,
from pay a
inner join payitem b on b.payno=a.payno and b.pino in ($pinos$) and a.pstatus=1 and a.rstatus=0
left outer join cm c0 on b.ptype in (0,4) and c0.cmno=b.itemno
left outer join book c2 on b.ptype=2 and c2.bkno=b.itemno
left outer join exam c3 on b.ptype=3 and c3.exno=b.itemno and c3.retime > now()
where a.payno=#payno# and a.userno=#uno# and a.pstatus=1 and a.rstatus < 2 and (b.ptype=2 or c0.cmno is not null or c3.exno is not null);
SELECT LAST_INSERT_ID()
insert into payrfditem (rfdno,pino,)
select #rfdno#,b.pino,
from pay a
inner join payitem b on b.payno=a.payno and b.pino in ($pinos$) and a.pstatus=1 and a.rstatus=0
left outer join cm c0 on b.ptype in (0,4) and c0.cmno=b.itemno
left outer join book c2 on b.ptype=2 and c2.bkno=b.itemno
left outer join exam c3 on b.ptype=3 and c3.exno=b.itemno and c3.retime > now()
where a.payno=#payno# and a.userno=#uno# and a.pstatus=1 and a.rstatus < 2 and (b.ptype=2 or c0.cmno is not null or c3.exno is not null)
update payrfd
set fgnor=#fgnor#,fgnob=#fgnob#,udt=now(),uno=#uno#,uip=#uip#
where rfdno=#rfdno# and payno=#payno#
delete from payrfditem where rfdno=#rfdno#;
update payrfd
set rstatus=#rstatus#,udt=now(),uno=#uno#,uip=#uip#
where rfdno=#rfdno# and payno=#payno#
update examuser a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null and b.userno=a.userno
inner join payitem c on c.payno=b.payno and c.ptype=3 and c.itemno=a.exno and c.pino=a.pino
set a.pstatus=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.pstatus=2;
update lect a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null
inner join payitem c on c.payno=b.payno and c.ptype in(0,4) and c.itemno=a.cmno and c.userno=a.userno and c.pino=a.pino
set a.status=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.status=2 and a.ischanged=0;
update payitem a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null
set a.pstatus=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno#;
update pay
set pstatus=1,isunpay=1,udt=now(),uno=#uno#,uip=#uip#
where payno=#payno# and pstatus=22 and ptype=3 and ispg=1 and isunpay is null;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
where a.payno = #payno#;
update examuser a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null and b.userno=a.userno
inner join payitem c on c.payno=b.payno and c.ptype=3 and c.itemno=a.exno and c.pino=a.pino
set a.pstatus=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.pstatus=2;
update lect a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null
inner join payitem c on c.payno=b.payno and c.ptype in(0,4) and c.itemno=a.cmno and c.userno=a.userno and c.pino=a.pino
set a.status=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno# and a.status=2 and a.ischanged=0;
update payitem a
inner join pay b on b.payno=a.payno and b.pstatus=22 and b.ptype=3 and b.ispg=1 and b.isunpay is null
set a.pstatus=1,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.payno=#payno#;
update pay
set ptype=#ptype#,payoktime=now(),pstatus=1,isunpay=3,udt=now(),uno=#uno#,uip=#uip#
where payno=#payno# and pstatus=22 and ptype=3 and ispg=1 and isunpay is null;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
where a.payno = #payno#;
update pay
set isunpay=2,payoktime=#payoktime#,udt=now(),uno=#uno#,uip=#uip#
where payno=#payno# and isunpay=1;
update lect a
inner join cm b on a.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno
set
a.sdate =
case
when b.cshape = 1 then date_format(d.estart,'%Y-%m-%d 00:00:00')
else date_format(a.cdt,'%Y-%m-%d 00:00:00')
end
, a.edate = date_format(d.eend,'%Y-%m-%d 00:00:00')
where a.payno = #payno#;
update pplog
set
typeman = #typeman#
,typejob = #typejob#
,typeedu = #typeedu#
,typegrade = #typegrade#
,typejobitem = #typejobitem#
where pplno = #pplno#
update pplog
set ,mgtkey=#mgtkey#,isreceipt=#isreceipt#,taxdatereq=#taxdatereq#
where pplno = #pplno# and userno=#userno#
insert into untaxlog (payno,logtime,) values(#payno#,,);
update pay
set iscashrct = null
where payno = #payno#;
insert into pay(ptype,ispg,isgroup,userno,username,isexam,pstatus,rstatus,refunding,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,pplno,isbill,iscashrct,)
values (#ptype#,0,0,#userno#,#username#,0,21,0,0,0,0,0,0,0,0,#pplno#,0,0,);
SELECT LAST_INSERT_ID()
insert into payitem (payno,ptype,itemno,userno,pstatus,rstatus,pcnt
,orgamt,discamt,payamt,payamtcash,payamtcard,refundamt,isrebate,)
values(#payno#,0,#cmno#,#userno#,21,0,1
,0,0,0,0,0,0,#isrebate#,);
insert into lect(cmno,payno,pino,userno,status,attrate,isrebate,ispc,isjoin,ischanged,isready,cmisno,)
select #cmno#,#payno#,LAST_INSERT_ID(),a.userno,4,0,#isrebate#,0,ifnull(b.isjoin,0),0,1,#cmisno#,
from users a
left outer join assign b on b.asno=a.asno
where a.userno=#userno#;