diff --git a/Base/Controller/FCommon.cs b/Base/Controller/FCommon.cs index 358bf3a..b67d697 100644 --- a/Base/Controller/FCommon.cs +++ b/Base/Controller/FCommon.cs @@ -255,7 +255,7 @@ namespace NP.Base.Controllers PPLog ppllog = new PPLog(); ppllog.uno = SUserInfo.UserNo; ppllog.uip = GetUserIP(); - + ppllog.cmno = vm.cmno; ppllog.userno = vm.User.userno; ppllog.asno = vm.Assign.asno; ppllog.isready = Request["applicableCM"].ToString() == "정상접수" ? 0 : 1; diff --git a/Dao/DB/DB1.Scheme.txt b/Dao/DB/DB1.Scheme.txt index d6d9652..c296075 100644 --- a/Dao/DB/DB1.Scheme.txt +++ b/Dao/DB/DB1.Scheme.txt @@ -689,6 +689,7 @@ create table paycartgroup ( create table pplog ( pplno bigint auto_increment not null ,userno int not null + ,cmno int not null ,isready tinyint ,cgcode varchar (20) ,cshape tinyint @@ -767,20 +768,7 @@ create table pay ( ,iscanceled tinyint not null default 0 ,iscashrct tinyint null ,cashrcthp varbinary (200) null - - ,iscashrct tinyint - ,cashrcthp varbinary (200) - ,cgcode varchar (20) - ,cshape tinyint - ,typeman smallint - ,typeedu smallint - ,typegrade smallint - ,typejob smallint - ,cmisno bigint - ,isrebate tinyint - ,rbankname varchar (50) - ,rbankacc varbinary (200) - ,rbankowner varchar (20) + ,pplno bigint null ,pplno bigint(20) ,cdt datetime not null,cno bigint not NULL,udt datetime not null,uno bigint not NULL,uip varchar(50) not NULL ,primary key(payno)); diff --git a/Dao/DB/DB1.SchemeFK.txt b/Dao/DB/DB1.SchemeFK.txt index adb267d..b5435e8 100644 --- a/Dao/DB/DB1.SchemeFK.txt +++ b/Dao/DB/DB1.SchemeFK.txt @@ -97,6 +97,7 @@ alter table paycartgroup add constraint foreign key fkpaycartgrouppaycart (pcno) alter table paycartgroup add constraint foreign key fkpaycartgroupu(userno) references users(userno); alter table pplog add constraint foreign key fkpplu(userno) references users(userno); +alter table pplog add constraint foreign key fkpplcm(cmno) references cm(cmno); alter table pplog add constraint foreign key fkppltypeman(typeman) references comcode(ccode); alter table pplog add constraint foreign key fkppltypeedu(typeedu) references comcode(ccode); alter table pplog add constraint foreign key fkppltypegrade(typegrade) references comcode(ccode); diff --git a/Dao/MyBatis/Maps/CM.xml b/Dao/MyBatis/Maps/CM.xml index d6a58df..1b209c5 100644 --- a/Dao/MyBatis/Maps/CM.xml +++ b/Dao/MyBatis/Maps/CM.xml @@ -22,6 +22,7 @@ + @@ -1839,10 +1840,10 @@ SELECT * FROM (SELECT LAST_INSERT_ID(0) col1) a WHERE col1 > 0; insert into pplog ( - userno,isready,cgcode,cshape,typeman,typeedu,typegrade,typejob,cgno,cmisno,isrebate,rbankname,rbankacc,rbankowner,asname,brno,ceoname,post,address1,address2,btype,bkind,eino,mname + userno,cmno,isready,cgcode,cshape,typeman,typeedu,typegrade,typejob,cgno,cmisno,isrebate,rbankname,rbankacc,rbankowner,asname,brno,ceoname,post,address1,address2,btype,bkind,eino,mname ,mphone,taxemail,userpno,mobile,email,upost,uaddress1,uaddress2,isassignuser,uduty,slevel,) values ( - #userno#,#isready#,#cgcode#,#cshape#,#typeman#,#typeedu#,#typegrade#,#typejob#,#cgno#,#cmisno#,#isrebate#,#rbankname#,#rbankacc#,#rbankowner#,#asname#,#brno#,#ceoname#,#post#,#address1# + #userno#,#cmno#,#isready#,#cgcode#,#cshape#,#typeman#,#typeedu#,#typegrade#,#typejob#,#cgno#,#cmisno#,#isrebate#,#rbankname#,#rbankacc#,#rbankowner#,#asname#,#brno#,#ceoname#,#post#,#address1# ,#address2#,#btype#,#bkind#,#eino#,#mname# ,HEX(AES_ENCRYPT(#mphone#, )) ,HEX(AES_ENCRYPT(#taxemail#, )) diff --git a/Dao/MyBatis/Maps/Pay.xml b/Dao/MyBatis/Maps/Pay.xml index 1cd9fc8..466d8a2 100644 --- a/Dao/MyBatis/Maps/Pay.xml +++ b/Dao/MyBatis/Maps/Pay.xml @@ -28,9 +28,9 @@ insert into pay(ptype,ispg,isgroup,userno,isexam,pstatus,rstatus,refunding,paylimit,payoktime,pgkey - ,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,) + ,orgamt,discamt,deliamt,isrefunddvr,payamt,refundamt,pplno,) values (#ptype#,#ispg#,#isgroup#,#userno#,0,#pstatus#,#rstatus#,#refunding#,#paylimit#,case when #isinmoney# is not null then else #payoktime# end,#pgkey# - ,#orgamt#,#discamt#,#deliamt#,#isrefunddvr#,#payamt#,#refundamt#,); + ,#orgamt#,#discamt#,#deliamt#,#isrefunddvr#,#payamt#,#refundamt#,#pplno#,); SELECT LAST_INSERT_ID() @@ -39,8 +39,8 @@ SELECT LAST_INSERT_ID() - insert into lect (cmno,payno,pino,userno,status,iscomplete,orgcmno,attrate,isrebate,ispc,pcno,isjoin,fgno,ischanged,) - values(#itemno#,#payno#,#pino#,#userno#,#status#,null,null,0,0,#ispc#,#pcno#,#isjoin#,null,0,); + 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,0,#ispc#,#pcno#,#isjoin#,null,0,#cmisno#,); SELECT LAST_INSERT_ID() + select a.pplno,a.isready,a.cmno,a.cmisno + ,b.payno + from pplog a + left outer join pay b on b.pplno=a.pplno + + a.pplno=#pplno# + a.userno=#userno# + + + diff --git a/FO/Controllers/CourseController.cs b/FO/Controllers/CourseController.cs index 97940bf..3169f7d 100644 --- a/FO/Controllers/CourseController.cs +++ b/FO/Controllers/CourseController.cs @@ -830,15 +830,80 @@ namespace NP.FO.Controllers return View(vm); } - public ActionResult Applycomplete(VMCourse vm) + public ActionResult ApplyPay(VMCourse vm) { - vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.cmno } }).FirstOrDefault(); - if (vm.CM.lectcnt != null) + if (vm.pplno < 1) { - int? standbyPerson = vm.CM.quota - vm.CM.lectcnt; - vm.CM.applicableCM = (standbyPerson <= 0) ? "대기접수" : "정상접수"; - vm.CM.standbyPerson = standbyPerson; + return Redirect("/"); } + var ppl = Dao.Get("pay.pplogs", new Hashtable() { { "pplno", vm.pplno }, { "userno", SUserInfo.UserNo } }).FirstOrDefault(); + if (ppl == null) + { + return Redirect("/"); + } + if (ppl.payno > 0) + { + //새로고침? + return RedirectPermanent("/Course/ApplyComplete?payno=" + ppl.payno); + } + if (ppl.isready == 1) + { + //대기접수로 결제 및 신청데이터 생성 + var payitems = new List() { }; + var uip = GetUserIP(); + payitems.Add(new PayItem() + { + itemno = vm.cmno, + userno = SUserInfo.UserNo, + status = 6, + pstatus = 55, + pcnt = 1, + payamt = 0, + isready = 1, + cmisno = ppl.cmisno, + uno = SUserInfo.UserNo, + uip = uip + }); + //정가확인 + var cms = Dao.Get("cm.cms.forpay", new Hashtable() { { "userno", SUserInfo.UserNo }, { "cmno", ppl.cmno } }); + var pi = payitems.First(); + pi.orgamt = cms.Where(w => w.cmno == pi.itemno).First().fee; + var pay = new Pay() + { + pplno = vm.pplno, + ptype = 7, + userno = SUserInfo.UserNo, + pstatus = 55, + rstatus = 0, + refunding = 0, + orgamt = cms.Sum(s => s.fee), + //isinmoney = 1, + payamt = payitems.Sum(s => s.payamt), + PIs = payitems, + cmnos = string.Join(",", payitems.Select(s => s.itemno)), + uno = SUserInfo.UserNo, + uip = GetUserIP() + }; + Dao.SavePay(pay, true); + if (pay.payno > 0) + { + return RedirectPermanent("/Course/ApplyComplete?payno=" + pay.payno); + } + return Redirect("/"); + } + vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", ppl.cmno } }).First(); + return View(vm); + } + + public ActionResult ApplyComplete(VMCourse vm) + { + if (vm.payno < 1) + { + return Redirect("/"); + } + vm.PayItem = Dao.Get("pay.payresult", new Hashtable() { { "payno", vm.payno }, { "userno", SUserInfo.UserNo } }).First(); + vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.PayItem.itemno } }).FirstOrDefault(); + //여기해보자 return View(vm); } diff --git a/FO/Views/Course/ApplyEdu.cshtml b/FO/Views/Course/ApplyEdu.cshtml index cb88956..1b9d4ae 100644 --- a/FO/Views/Course/ApplyEdu.cshtml +++ b/FO/Views/Course/ApplyEdu.cshtml @@ -378,7 +378,8 @@ } function saveResult() { if (capResult.code == 1000 && capResult.obj > 0) { - alert("저장되었습니다. pplno : " + capResult.obj); + //alert("저장되었습니다. pplno : " + capResult.obj); + location.href = "/Course/ApplyPay?pplno=" + capResult.obj; } else { alert("저장을 실패하였습니다."); } diff --git a/Model/PPLog.cs b/Model/PPLog.cs index bc302fe..935a47d 100644 --- a/Model/PPLog.cs +++ b/Model/PPLog.cs @@ -11,6 +11,7 @@ namespace NP.Model { public Int64 pplno { get; set; } public int userno { get; set; } + public int cmno { get; set; } public int? isready { get; set; } public String cgcode { get; set; } public int? cshape { get; set; } @@ -50,5 +51,7 @@ namespace NP.Model public String uduty { get; set; } public int? slevel { get; set; } + public Int64 payno { get; set; } + } } diff --git a/Model/Pay.cs b/Model/Pay.cs index 83501d8..6f55401 100644 --- a/Model/Pay.cs +++ b/Model/Pay.cs @@ -14,7 +14,11 @@ namespace NP.Model /// public Int64 payno { get; set; } /// - /// 결제방식 1:신용카드,2:계좌이체,3:가상계좌,4:현금,5:현금+카드,6:무료,9:위탁계약 + /// 사용자사이트 수강신청 검색루트를 통한 신청일 경우 pplog 정보 연결 + /// + public Int64? pplno { get; set; } + /// + /// 결제방식 1:신용카드,2:계좌이체,3:가상계좌,4:현금,5:현금+카드,6:무료,7:대기신청,9:위탁계약 /// public int ptype { get; set; } public String ptypecode @@ -61,7 +65,7 @@ namespace NP.Model public String username { get; set; } public String userpno { get; set; } /// - /// 결제상태 0:결제시도, 1:결제완료, 21:결제대기(승인심사),22:입금대기, 41:결제취소,42:가상계좌입금대기만료,43:가상계좌입금전취소" lect, examuser 등의 결제상태 sync + /// 결제상태 0:결제시도, 1:결제완료, 21:결제대기(승인심사),22:입금대기, 41:결제취소,42:가상계좌입금대기만료,43:가상계좌입금전취소,55:대기신청" lect, examuser 등의 결제상태 sync /// public int pstatus { get; set; } public String pstatusname @@ -293,6 +297,14 @@ namespace NP.Model public int payamt {get;set;} public int payamt2 { get; set; } /// + /// 0:정상, 1:대기신청 + /// + public int isready { get; set; } + /// + /// 혼합교육 교육일정 cminningscd.cmisno + /// + public Int64? cmisno { get; set; } + /// /// 현금결제액 현금+카드로 결제 시 /// public int payamtcash {get;set;} diff --git a/Model/VMCourse.cs b/Model/VMCourse.cs index 2f668ed..4208144 100644 --- a/Model/VMCourse.cs +++ b/Model/VMCourse.cs @@ -46,5 +46,8 @@ namespace NP.Model public Book Book { get; set; } public int bkno { get; set; } public int pcnt { get; set; } + public Int64 pplno { get; set; } + public Int64 payno { get; set; } + public PayItem PayItem { get; set; } } }