From bcb2ca2a213b2ea5a6da70ef2f10247ab1a29f40 Mon Sep 17 00:00:00 2001 From: hodong13 Date: Thu, 26 Nov 2020 04:49:56 +0000 Subject: [PATCH] --- Base/Controller/BaseController.cs | 1 - Base/Controller/FCommonCRoom.cs | 26 ++++- Base/Controller/FCommonPay.cs | 88 ++++++++++++++++- Dao/MyBatis/Maps/Lect.xml | 8 ++ Dao/MyBatis/Maps/Pay.xml | 22 ++++- FO/Controllers/CourseController.cs | 137 +++++++++++++++------------ FO/Views/Account/IndexAssign.cshtml | 4 +- FO/Views/CRoom/Index.cshtml | 29 +++++- FO/Views/Course/ApplyComplete.cshtml | 4 +- FO/Views/Course/ApplyPay.cshtml | 3 +- FO/Views/My/Ready.cshtml | 2 +- Model/PPLog.cs | 1 + Model/VMPay.cs | 1 + 13 files changed, 247 insertions(+), 79 deletions(-) diff --git a/Base/Controller/BaseController.cs b/Base/Controller/BaseController.cs index 28b8c62..dc6bae2 100644 --- a/Base/Controller/BaseController.cs +++ b/Base/Controller/BaseController.cs @@ -32,7 +32,6 @@ namespace NP.Base //Response.Cache.SetExpires(DateTime.Now); //Response.Cache.SetMaxAge(new TimeSpan(0, 0, 30)); - ViewBag.IsHome = false; ViewBag.SSUserNo = 0; ViewBag.SSUserName = ""; diff --git a/Base/Controller/FCommonCRoom.cs b/Base/Controller/FCommonCRoom.cs index 93093f3..cc7aeba 100644 --- a/Base/Controller/FCommonCRoom.cs +++ b/Base/Controller/FCommonCRoom.cs @@ -158,7 +158,31 @@ namespace NP.Base.Controllers { return JsonOK(Dao.Save("cr.lectsdboardcmt.del", new Hashtable() { { "bcno", bcno }, { "cno", SUserInfo.UserNo }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } })); } - + [HttpPost] + public JsonResult AttCertCheck(int lectno) + { + var data = Dao.Get("lect.attcert.check", new Hashtable() { { "lectno", lectno } }).FirstOrDefault(); + if (data.intval2 == 1 || data.intval3 == 1) + { + return JsonBack(new JsonRtn() { code = 1000, obj = 1 }); + } + else + { + if (data.intval == 1) + { + return JsonBack(new JsonRtn() { code = 1000, obj = 2 }); + } + if (!string.IsNullOrEmpty(data.strval)) + { + return JsonBack(new JsonRtn() { code = 1000, obj = 3, msg = data.strval }); + } + else + { + return JsonBack(new JsonRtn() { code = -1 }); + } + } + } + } } \ No newline at end of file diff --git a/Base/Controller/FCommonPay.cs b/Base/Controller/FCommonPay.cs index 8208f42..95ab813 100644 --- a/Base/Controller/FCommonPay.cs +++ b/Base/Controller/FCommonPay.cs @@ -164,12 +164,90 @@ namespace NP.Base.Controllers public JsonResult PayStart(VMPay vm) { vm.PPLog = Dao.Get("pay.pplogs", new Hashtable() { { "pplno", vm.pplno }, { "userno", SUserInfo.UserNo } }).First(); - vm.PayItems = new List() { }; - foreach (var d in vm.items.Split(';')) + if (vm.payno > 0 && vm.PPLog.pstatus != 21) { - var dd = d.Split(':'); - vm.PayItems.Add(new PayItem() { ptype = GetInt(dd[0]), itemno = GetLong(dd[1]), pcnt = GetInt(dd[2]), userno = vm.isgroup == 0 || dd[0] == "2" ? SUserInfo.UserNo : GetInt(dd[3]), isrebate = GetInt(dd[4]), fgno = dd[5] == "0" ? (Int64?)null : GetLong(dd[5]), - rbank = vm.PPLog.rbankname, rbankaccnum = vm.PPLog.rbankacc, tbankuser = vm.PPLog.rbankowner }); + return JsonBack(new JsonRtn() { code = 1000, msg = "승인된 승인대기신청데이터가 아닙니다.", obj = 0 }); + } + vm.PayItems = new List() { }; + if (vm.payno > 0) + { + //대기신청 결제시작 + vm.Pay = new Pay() + { + payno = vm.payno, + ptype = vm.ptype, + uno = SUserInfo.UserNo, + uip = GetUserIP(), + ispg = 1, + userno = SUserInfo.UserNo, + orgamt = vm.PPLog.infee, + payamt = vm.PPLog.infee, + iscashrct = vm.ptype == 1 ? 0 : vm.iscashrct, + cashrcthp = vm.ptype == 1 ? null : vm.cashrcthp, + pplno = vm.pplno, + PIs = vm.PayItems + }; + vm.PayItems.Add(new PayItem() + { + ptype = 0, + itemno = vm.cmno, + pcnt = 1, + userno = SUserInfo.UserNo, + orgamt = vm.PPLog.infee, + payamt = vm.PPLog.infee, + isrebate = vm.PPLog.isrebate??0, + rbank = vm.PPLog.rbankname, + rbankaccnum = vm.PPLog.rbankacc, + tbankuser = vm.PPLog.rbankowner + }); + if (vm.Pay.ptype == 3 && vm.Pay.payamt > 0) + { + //0원 강좌는 제외 + //가상계좌 결제 시 ?일동안만 입금가능 / 수강신청중 빠른 것 + vm.Pay.paylimit = Convert.ToDateTime(DateTime.Now.AddDays(paylimitday).ToString("yyyy-MM-dd")).AddSeconds(-1); + //if (vm.PayItems.Where(w => w.retime != null && w.retime < vm.Pay.paylimit).Count() > 0) + //{ + // vm.Pay.paylimit = Convert.ToDateTime(vm.PayItems.Where(w => w.retime != null && w.retime < vm.Pay.paylimit).Min(m => m.retime).Value.AddDays(1).ToString("yyyy-MM-dd")).AddSeconds(-1); + //} + vm.Pay.acceptmethod = "vbank(" + vm.Pay.paylimit.Value.ToString("yyyyMMddHHmm") + ")"; + } + if (vm.Pay.payamt < 1) + { + vm.Pay.ptype = 6; + } + else if (vm.Pay.ptype == 6 && vm.Pay.payamt > 0) + { + vm.Pay.ptype = 1; + } + if (Dao.Save("pay.paycert.paystart", vm.Pay) > 0) + { + var pginfos = GetConfig("pginfo").Split('|'); + string timeTemp = "" + DateTime.UtcNow.Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; + vm.Pay.timestamp = timeTemp.Split('.')[0]; + System.Security.Cryptography.SHA256Managed sha256Managed = new System.Security.Cryptography.SHA256Managed(); + vm.Pay.signature = ComputeHash(string.Format("oid={0}&price={1}×tamp={2}", GetConfig("PAYMENT_CLASSIFICATION") + vm.Pay.payno, vm.Pay.payamt, vm.Pay.timestamp)); + vm.Pay.oid2 = GetConfig("PAYMENT_CLASSIFICATION"); + return JsonBack(new JsonRtn() { code = 1000, obj = vm.Pay }); + } + } + else + { + foreach (var d in vm.items.Split(';')) + { + var dd = d.Split(':'); + vm.PayItems.Add(new PayItem() + { + ptype = GetInt(dd[0]), + itemno = GetLong(dd[1]), + pcnt = GetInt(dd[2]), + userno = vm.isgroup == 0 || dd[0] == "2" ? SUserInfo.UserNo : GetInt(dd[3]), + isrebate = GetInt(dd[4]), + fgno = dd[5] == "0" ? (Int64?)null : GetLong(dd[5]), + rbank = vm.PPLog.rbankname, + rbankaccnum = vm.PPLog.rbankacc, + tbankuser = vm.PPLog.rbankowner + }); + } } if (vm.isgroup == 1) { diff --git a/Dao/MyBatis/Maps/Lect.xml b/Dao/MyBatis/Maps/Lect.xml index ab6fc45..d531411 100644 --- a/Dao/MyBatis/Maps/Lect.xml +++ b/Dao/MyBatis/Maps/Lect.xml @@ -1336,6 +1336,14 @@ ,completetime=#completetime# where lectno=#lectno# and iscomplete=1; + @@ -334,11 +338,12 @@ 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 - where a.payno=#payno# and a.ptype=0; + 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.ptype=4 and c.itemno=a.cmno and c.pstatus=b.pstatus + 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; @@ -863,7 +868,9 @@ + diff --git a/FO/Controllers/CourseController.cs b/FO/Controllers/CourseController.cs index 5ce0173..72b33cc 100644 --- a/FO/Controllers/CourseController.cs +++ b/FO/Controllers/CourseController.cs @@ -834,72 +834,87 @@ namespace NP.FO.Controllers public ActionResult ApplyPay(VMCourse vm) { - if (vm.pplno < 1) + if (vm.payno > 0) { - return Redirect("/"); - } - vm.PPLog = Dao.Get("pay.pplogs", new Hashtable() { { "pplno", vm.pplno }, { "userno", SUserInfo.UserNo } }).FirstOrDefault(); - if (vm.PPLog == null) - { - return Redirect("/"); - } - if (vm.PPLog.payno > 0 && vm.PPLog.pstatus > 0) - { - //새로고침? - return RedirectPermanent("/Course/ApplyComplete?payno=" + vm.PPLog.payno); - } - if (vm.PPLog.isready == 1) - { - //대기접수로 결제 및 신청데이터 생성 - var payitems = new List() { }; - var uip = GetUserIP(); - payitems.Add(new PayItem() + //신청대기 => 승인 => 결제진입 + //유효성 검증 + vm.PPLog = Dao.Get("pay.pplogs.bypay", new Hashtable() { { "payno", vm.payno }, { "userno", SUserInfo.UserNo } }).FirstOrDefault(); + if (vm.PPLog == null || vm.PPLog.pstatus != 21) { - itemno = vm.PPLog.cmno, - userno = SUserInfo.UserNo, - status = 6, - pstatus = 55, - pcnt = 1, - payamt = 0, - isrebate = vm.PPLog.isrebate ?? 0, - rbank = vm.PPLog.rbankname, - rbankaccnum = vm.PPLog.rbankacc, - tbankuser = vm.PPLog.rbankowner, - isready = 1, - cmisno = vm.PPLog.cmisno, - uno = SUserInfo.UserNo, - uip = uip - }); - //정가확인 - var cms = Dao.Get("cm.cms.forpay", new Hashtable() { { "userno", SUserInfo.UserNo }, { "cmno", vm.PPLog.cmno } }); - if (cms.First().lectnocheck > 0) - { - return RedirectPermanent("/?isalreadyreq=1"); + return Redirect("/"); } - var pi = payitems.First(); - pi.orgamt = cms.Where(w => w.cmno == pi.itemno).First().fee; - var pay = new Pay() + vm.pplno = vm.PPLog.pplno; + vm.cmno = vm.PPLog.cmno; + } + else + { + if (vm.pplno < 1) { - pplno = vm.pplno, - ptype = 0, - 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.PPLog = Dao.Get("pay.pplogs", new Hashtable() { { "pplno", vm.pplno }, { "userno", SUserInfo.UserNo } }).FirstOrDefault(); + if (vm.PPLog == null) + { + return Redirect("/"); + } + else if (vm.PPLog.payno > 0 && vm.PPLog.pstatus > 0) + { + //새로고침? + return RedirectPermanent("/Course/ApplyComplete?payno=" + vm.PPLog.payno); + } + if (vm.PPLog.isready == 1) + { + //대기접수로 결제 및 신청데이터 생성 + var payitems = new List() { }; + var uip = GetUserIP(); + payitems.Add(new PayItem() + { + itemno = vm.PPLog.cmno, + userno = SUserInfo.UserNo, + status = 6, + pstatus = 55, + pcnt = 1, + payamt = 0, + isrebate = vm.PPLog.isrebate ?? 0, + rbank = vm.PPLog.rbankname, + rbankaccnum = vm.PPLog.rbankacc, + tbankuser = vm.PPLog.rbankowner, + isready = 1, + cmisno = vm.PPLog.cmisno, + uno = SUserInfo.UserNo, + uip = uip + }); + //정가확인 + var cms = Dao.Get("cm.cms.forpay", new Hashtable() { { "userno", SUserInfo.UserNo }, { "cmno", vm.PPLog.cmno } }); + if (cms.First().lectnocheck > 0) + { + return RedirectPermanent("/?isalreadyreq=1"); + } + var pi = payitems.First(); + pi.orgamt = cms.Where(w => w.cmno == pi.itemno).First().fee; + var pay = new Pay() + { + pplno = vm.pplno, + ptype = 0, + 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("/"); } - return Redirect("/"); } vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.PPLog.cmno } }).First(); vm.User = Dao.Get("users.users", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo } }).First(); diff --git a/FO/Views/Account/IndexAssign.cshtml b/FO/Views/Account/IndexAssign.cshtml index a42f58f..c3770a5 100644 --- a/FO/Views/Account/IndexAssign.cshtml +++ b/FO/Views/Account/IndexAssign.cshtml @@ -94,7 +94,7 @@ 로그인 - + *@ diff --git a/FO/Views/CRoom/Index.cshtml b/FO/Views/CRoom/Index.cshtml index e541b1d..fa7345e 100644 --- a/FO/Views/CRoom/Index.cshtml +++ b/FO/Views/CRoom/Index.cshtml @@ -144,6 +144,7 @@ } @section scripts{ } \ No newline at end of file diff --git a/FO/Views/Course/ApplyComplete.cshtml b/FO/Views/Course/ApplyComplete.cshtml index c8c6539..8c33e74 100644 --- a/FO/Views/Course/ApplyComplete.cshtml +++ b/FO/Views/Course/ApplyComplete.cshtml @@ -44,11 +44,11 @@ else
- 총 결제@(Model.Pay.isready==1?"예상":"")금액 : @Model.CM.infee.ToString("#,0") 원 + 총 결제@(Model.Pay.isready==1 && Model.Pay.pstatus != 1 && Model.Pay.pstatus != 22 ?"예상":"")금액 : @Model.CM.infee.ToString("#,0")
- if (Model.Pay.isready == 0) + if (Model.Pay.isready == 0 || Model.Pay.pstatus == 1 || Model.Pay.pstatus == 22) {

결제정보

diff --git a/FO/Views/Course/ApplyPay.cshtml b/FO/Views/Course/ApplyPay.cshtml index 9e04d4f..b237bc3 100644 --- a/FO/Views/Course/ApplyPay.cshtml +++ b/FO/Views/Course/ApplyPay.cshtml @@ -1,5 +1,6 @@ @model NP.Model.VMCourse + @Html.HiddenFor(m=>m.payno) @*강좌번호*@ @*법정교육/기타교육*@ @*교육유형*@ @@ -30,7 +31,7 @@
- 결제금액 : @Model.CM.infee 원 + 결제금액 : @Model.CM.infee.ToString("#,0")
diff --git a/FO/Views/My/Ready.cshtml b/FO/Views/My/Ready.cshtml index 385f84c..76a2782 100644 --- a/FO/Views/My/Ready.cshtml +++ b/FO/Views/My/Ready.cshtml @@ -38,7 +38,7 @@ @Html.Raw(d.pstatus == 21 ? string.Format("교육비납부", d.payno) : "")
-
@(d.pstatus == 55 ? "대기신청" : d.pstatus == 51 ? "심사중" : d.pstatus == 21 ? "결제대기" : d.pstatus == 22 ? "입금대기" : d.pstatus == 1 && d.rfdstatus > 0 ? "환불요청" : d.pstatus == 1 ? "결제완료" : d.rstatus == 1 ? "부분환불" : d.rstatus == 2 ? "전액환불" : "-")
+
@(d.pstatus == 55 ? "승인대기" : d.pstatus == 51 ? "심사중" : d.pstatus == 21 ? "결제대기" : d.pstatus == 22 ? "입금대기" : d.pstatus == 1 && d.rfdstatus > 0 ? "환불요청" : d.pstatus == 1 ? "결제완료" : d.rstatus == 1 ? "부분환불" : d.rstatus == 2 ? "전액환불" : "-")
신청(교육)기간 : @d.rstime.Value.ToString("yy'/'MM'/'dd") ~ @d.retime.Value.ToString("yy'/'MM'/'dd") (@d.sstime.ToString("yy'/'MM'/'dd") ~ @d.setime.ToString("yy'/'MM'/'dd")) @if (d.cshape == 2) diff --git a/Model/PPLog.cs b/Model/PPLog.cs index 63517ea..1c13e04 100644 --- a/Model/PPLog.cs +++ b/Model/PPLog.cs @@ -53,5 +53,6 @@ namespace NP.Model public Int64 payno { get; set; } public int pstatus { get; set; } + public int infee { get; set; } } } diff --git a/Model/VMPay.cs b/Model/VMPay.cs index 4518537..f6926d3 100644 --- a/Model/VMPay.cs +++ b/Model/VMPay.cs @@ -8,6 +8,7 @@ namespace NP.Model { public class VMPay : VMBase { + public int cmno { get; set; } public int isgroup { get; set; } public int ptype { get; set; } public int isdvr { get; set; }