YNICTE/FO/Controllers/AccountController.cs

439 lines
22 KiB
C#
Raw Normal View History

2020-10-12 14:39:23 +09:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NP.Model;
using System.Security.Claims;
using System.Collections;
using System.Text;
namespace NP.FO.Controllers
{
public class AccountController : FOOpenBaseController
{
public ActionResult FindMe(VMUser vm)
{
vm.User = new Users() { };
if (vm.userno > 0)
{
//인증링크 클릭 확인
vm.User = Dao.Get<Users>("users.pwuser", new Hashtable() { { "userno", vm.userno }, { "pwcallno", vm.pwcallno } }).FirstOrDefault();
if (vm.User == null || vm.User.pwcallno == null)
{
vm.User = new Users() { };
vm.userno = -1;
}
}
return View(vm);
}
public ActionResult Index(VMUser vm){
if (Request.IsAjaxRequest()){
return JsonError<String>(Base.ENUM.JSONCode.Error, "403:" + Request.Url.AbsolutePath, "0112");
}
else
{
//ViewBag.gossl = 0;
//if ("Y".Equals(GetConfig("usessl")) && !Request.IsSecureConnection)
//{
// //return Redirect("https://" + Request.Url.Host + Request.Url.PathAndQuery);
// ViewBag.gossl = 1;
//}
vm.Assign = new Assign();
//서브도메인 확인 하여 고객사 설정
var sd = Request.Url.Host.Split('.')[0];
2020-10-15 14:07:58 +09:00
if (GetConfig("isdevtest") != "1" && Request.Url.Host != "222.122.63.91" && Request.Url.Host != "ynicte.nptc.kr" && Request.Url.Host != "phd.nptc.kr" && MainSubDomain.ToUpper() != sd.ToUpper())
2020-10-12 14:39:23 +09:00
{
ViewBag.Files = vm.Files;
ViewBag.Assign = vm.Assign = Dao.Get<Assign>("users.assignsite", new Hashtable() { { "subdomain", sd } }).First();
ViewBag.SiteTitle = vm.Assign.asname;
}
ViewBag.SavedId = CookieGet("savedid", "");
return View(vm);
}
}
private ActionResult RedirectToLocal(string returnUrl){
if (Url.IsLocalUrl(returnUrl)){return Redirect(returnUrl);}
else {return RedirectToAction(nameof(HomeController.Index), "Home");}
}
public ActionResult Join()
{
//if ("Y".Equals(GetConfig("usessl")) && !Request.IsSecureConnection)
//{
// return Redirect("https://" + Request.Url.Host + Request.Url.PathAndQuery);
//}
//else
//{
ViewBag.JoinOK = false;
if (GetInt(Request["intval"]) == 1)
{
ViewBag.JoinOK = true;
}
return View();
//}
}
public ActionResult CallOrder(){return View();}
public ActionResult Logout(){
CookieClear(null, true);
return Redirect("/Account/Index");
}
public ActionResult Error(NP.Model.JsonRtn vm)
{
vm.err = (string)TempData["err"] ?? "";
vm.msg = vm.msg ?? "503";
Exception exception = Server.GetLastError();
Response.Clear();
ViewBag.ErrorMsg = "";
HttpException httpException = exception as HttpException;
if (httpException != null)
{
NP.Base.Logger.Error("ApplicationError" + vm.msg, exception);
}
Server.ClearError();
if (Request.IsAjaxRequest())
{
//public static bool IsAjaxRequest(this HttpRequest request)
//{
// if (request == null)
// {
// throw new ArgumentNullException("request");
// }
//
// return (request["X-Requested-With"] == "XMLHttpRequest") || ((request.Headers != null) && (request.Headers["X-Requested-With"] == "XMLHttpRequest"));
//}
return JsonError<Exception>(Base.ENUM.JSONCode.Error, vm.msg + ":" + Request.Url.AbsolutePath + (exception ?? new Exception()).Message, exception);
}
return View("Error", vm);
}
[AllowAnonymous]
public ActionResult BanEmail(VMUser vm, int et, int no = 0)
{
try
{
switch (et)
{
case 0:
//뉴스레터수신거부
if (no != 0)
{
Dao.Save("common.emailban", new Hashtable() { { "SendNo", no }, { "Email", vm.em }, { "uno", 1 }, { "uip", GetUserIP() } });
}
else
{
Dao.Save("common.emailban", new Hashtable() { { "Email", vm.em }, { "uno", 1 }, { "uip", GetUserIP() } });
}
break;
default:
break;
}
}
catch (Exception ex)
{
SetError("/account/banemail:" + vm.em + ":" + ex.Message + ex.StackTrace);
}
return View(vm);
}
public ActionResult Error403(NP.Model.JsonRtn vm){vm.msg = "403";return Error(vm);}
public ActionResult Error404(NP.Model.JsonRtn vm){vm.msg = "404" + (Request.IsLocal ? Request.Url.Query : "");return Error(vm);}
public ActionResult Error500(NP.Model.JsonRtn vm){vm.msg = "500";return Error(vm);}
//public JsonResult JsonError<T>(NP.Base.ENUM.JSONCode cd, String m, T t){return Json(new NP.Model.JsonRtn() { Code = (int)cd, Msg = m, Obj = t }, JsonRequestBehavior.AllowGet);}
/// <summary>
/// pc가상계좌입금통보
/// </summary>
/// <returns></returns>
public String PayVBankMoney()
{
try
{
String TEMP_IP = GetUserIP();
String PG_IP = TEMP_IP.Substring(0, 10);
if (PG_IP == "203.238.37" || PG_IP == "39.115.212" || PG_IP == "183.109.71" )//PG에서 보냈는지 IP로 체크
{
String NO_TID = Request["NO_TID"];//거래번호
String NO_OID = Request["NO_OID"];//상점 주문번호
String ID_MERCHANT = Request["ID_MERCHANT"]; //상점 아이디
String CD_BANK = Request["CD_BANK"]; //거래 발생 기관 코드
String CD_DEAL = Request["CD_DEAL"]; //취급 기관 코드
String DT_TRANS = Request["DT_TRANS"]; //거래 일자
String TM_TRANS = Request["TM_TRANS"]; //거래 시간
String NO_MSGSEQ = Request["NO_MSGSEQ"]; //전문 일련 번호
String CD_JOINORG = Request["CD_JOINORG"]; //제휴 기관 코드
String NO_TRANSEQ = Request["NO_TRANSEQ"]; //거래 일련 번호
String NO_VACCT = Request["NO_VACCT"]; //가상계좌번호
String AMT_INPUT = Request["AMT_INPUT"]; //입금금액
String AMT_CHECK = Request["AMT_CHECK"]; //미결제 타점권 금액
String CL_CLOSE = Request["CL_CLOSE"]; //마감 구분코드
String TYPE_MSG = Request["TYPE_MSG"]; //거래 구분 코드
String NM_INPUTBANK = Request["NM_INPUTBANK"]; //입금 금융기관명
String NM_INPUT = Request["NM_INPUT"]; //입금 의뢰인
String DT_INPUTSTD = Request["DT_INPUTSTD"]; //입금 기준 일자
String DT_CALCULSTD = Request["DT_CALCULSTD"]; //정산 기준 일자
String DT_TRANSBASE = Request["DT_TRANSBASE"]; //거래 기준 일자
String CL_KOR = Request["CL_KOR"]; //한글 구분 코드
String NO_MSGMANAGE = Request["NO_MSGMANAGE"]; //전문 관리 번호
String FLG_CLOSE = Request["FLG_CLOSE"]; //마감 전화
String DT_CSHR = Request["DT_CSHR"]; //현금영수증 발급일자 // 가상계좌채번시 현금영수증 자동발급신청시에만 전달
String TM_CSHR = Request["TM_CSHR"]; //현금영수증 발급시간
String NO_CSHR_APPL = Request["NO_CSHR_APPL"]; //현금영수증 발급번호
String NO_CSHR_TID = Request["NO_CSHR_TID"]; //현금영수증 발급TID
System.Text.Encoding encKr = System.Text.Encoding.GetEncoding("euc-kr");
System.Text.EncodingInfo[] encods = System.Text.Encoding.GetEncodings();
System.Text.Encoding destEnc = System.Text.Encoding.UTF8;
try
{
String path = GetConfig("pgroot") + @"\log\result.log";
if (!System.IO.File.Exists(path))
{
System.IO.File.Create(path);
}
using (System.IO.StreamWriter sw = System.IO.File.AppendText(path))
{
sw.WriteLine("************************************************");
sw.WriteLine("ID_MERCHANT : " + ID_MERCHANT);
sw.WriteLine("NO_TID : " + NO_TID);
sw.WriteLine("NO_OID : " + NO_OID);
sw.WriteLine("NO_VACCT : " + NO_VACCT);
sw.WriteLine("AMT_INPUT : " + AMT_INPUT);
sw.WriteLine("NM_INPUTBANK : " + NM_INPUTBANK);
sw.WriteLine("NM_INPUT : " + NM_INPUT);
byte[] requestBuffer;
try
{
requestBuffer = Request.BinaryRead(Request.TotalBytes);
String rp = HttpUtility.UrlDecode(requestBuffer, System.Text.Encoding.GetEncoding("euc-kr"));
sw.WriteLine("****************2");
sw.WriteLine("decodestring: " + rp);
sw.WriteLine("****************2");
String[] rps = rp.Split('&');
NM_INPUTBANK = rps.Where(w => w.Split('=')[0].ToLower() == "nm_inputbank").First().Split('=')[1];
NM_INPUT = rps.Where(w => w.Split('=')[0].ToLower() == "nm_input").First().Split('=')[1];
requestBuffer = null;
}
catch (Exception ex)
{
requestBuffer = null;
sw.WriteLine(ex.Message + ex.StackTrace);
}
//sw.WriteLine("NM_INPUTBANK : " + Encoding.UTF8.GetString(Encoding.Convert(Encoding.GetEncoding("euc-kr"), Encoding.UTF8, Encoding.GetEncoding("euc-kr").GetBytes(NM_INPUTBANK))));
//sw.WriteLine("NM_INPUT : " + Encoding.UTF8.GetString(Encoding.Convert(Encoding.GetEncoding("euc-kr"),Encoding.UTF8,Encoding.GetEncoding("euc-kr").GetBytes(NM_INPUT))));
sw.WriteLine("PAYTIEM : " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
sw.WriteLine("************************************************");
sw.WriteLine("");
sw.Flush();
}
}
catch (Exception ex)
{
SetError(ex.StackTrace);
}
var payvbankin = new PayVBankIn()
{
payno = GetLong(NO_OID.Substring(2)),
uno = 1,
uip = GetUserIP(),
pgkey = NO_TID,
inbankcode = CD_BANK,
indeal = CD_DEAL,
inymd = DT_TRANS,
inhms = TM_TRANS,
msgseq = NO_MSGSEQ,
transseq = NO_TRANSEQ,
vacct = NO_VACCT,
inamt = GetInt(AMT_INPUT),
checkamt = GetInt(AMT_CHECK),
isclose = CL_CLOSE,
typemsg = TYPE_MSG,
frombank = NM_INPUTBANK,
fromname = NM_INPUT,
//frombank = Encoding.UTF8.GetString(Encoding.Convert(Encoding.GetEncoding("euc-kr"), Encoding.UTF8, Encoding.GetEncoding("euc-kr").GetBytes(NM_INPUTBANK))),
//fromname = Encoding.UTF8.GetString(Encoding.Convert(Encoding.GetEncoding("euc-kr"), Encoding.UTF8, Encoding.GetEncoding("euc-kr").GetBytes(NM_INPUT))),
fromymd = DT_INPUTSTD,
calcymd = DT_CALCULSTD,
tranymd = DT_TRANSBASE,
//transcode = AAAA,
korcode = CL_KOR,
cshrymd = DT_CSHR,
cshrhms = TM_CSHR,
cshrcode = NO_CSHR_APPL,
cshrpgkey = NO_CSHR_TID
};
if (Dao.Save("pay.paylect.vbankin", payvbankin) < 3)
{
//상품구매완료 처리 (최소 3건 업데이트 (payvbankin, pay)
return "FAIL";
}
return "OK";
}
}
catch (Exception ex)
{
SetError("가상계좌입금오류: " + ex.Message + ex.StackTrace);
}
return "FAIL";
}
/// <summary>
/// 모바일가상계좌입금통보
/// </summary>
/// <returns></returns>
public String PayVBankMoneyMobile()
{
try
{
String TEMP_IP = GetUserIP();
//String PG_IP = TEMP_IP.Substring(0, 10);
if ((TEMP_IP == "118.129.210.25" || TEMP_IP == "203.238.37.15" || TEMP_IP == "183.109.71.153") && Request["P_TYPE"] == "VBANK" && Request["P_STATUS"] == "02")//PG에서 보냈는지 IP로 체크
{
//P_TID=INIMX_VBNKINIpayTest20190821162423335068
//P_MID =INIpayTest
//P_AUTH_DT=20190821163218
//P_STATUS=02
//P_TYPE=VBANK
//P_OID=te230
//P_FN_CD1=03
//P_FN_CD2=
//P_FN_NM=기업은행
//P_AMT=100
//P_UNAME=npuser1name
//P_RMESG1=P_VACCT_NO=07502280297143|P_EXP_DT=20190827
//P_RMESG2=
//P_NOTI=MOBILE|/OffDetail?cmno=87|230
//P_AUTH_NO=
//P_CSHR_AMT=
//P_CSHR_SUP_AMT=
//P_CSHR_TAX=
//P_CSHR_SRVC_AMT=
//P_CSHR_TYPE=
//P_CSHR_DT=20190821163218
//P_CSHR_AUTH_NO=266477600
//P_HASH=diUGxXN1CUumXZX1GBcB5sS7SNQOqAq1BfGIALI82qmMLLHAkq0y18MTuuS18rqVJQhhWLHEDAcifsXZ3U9urQ==Jakarta Commons - HttpClient / 3.0.1
String NO_TID = Request["P_TID"];//거래번호
String NO_OID = Request["P_OID"];//상점 주문번호
String ID_MERCHANT = Request["P_MID"]; //상점 아이디
String CD_BANK = Request["P_FN_CD1"]; //거래 발생 기관 코드
String P_FN_NM = Request["P_FN_NM"]; //금융사명
String CD_DEAL = "";// Request["aaaaaaaaCD_DEAL"]; //취급 기관 코드
String DT_TRANS = "";//Request["aaaaaaaaDT_TRANS"]; //거래 일자
String TM_TRANS = "";//equest["aaaaaaaaTM_TRANS"]; //거래 시간
String NO_MSGSEQ = "";// Request["aaaaaaaaNO_MSGSEQ"]; //전문 일련 번호
String CD_JOINORG = "";// Request["aaaaaaaaCD_JOINORG"]; //제휴 기관 코드
String NO_TRANSEQ = "";// Request["aaaaaaaaNO_TRANSEQ"]; //거래 일련 번호
String NO_VACCT = "";// Request["aaaaaaaaNO_VACCT"]; //가상계좌번호
String AMT_INPUT = Request["P_AMT"]; //입금금액
String AMT_CHECK = "";// Request["aaaaaaaaAMT_CHECK"]; //미결제 타점권 금액
String CL_CLOSE = "";// Request["aaaaaaaaCL_CLOSE"]; //마감 구분코드
String TYPE_MSG = "";// Request["aaaaaaaaTYPE_MSG"]; //거래 구분 코드
String NM_INPUTBANK = Request["P_FN_NM"]; //입금 금융기관명
String NM_INPUT = Request["P_UNAME"]; //입금 의뢰인
String DT_INPUTSTD = "";//Request["aaaaaaaaDT_INPUTSTD"]; //입금 기준 일자
String DT_CALCULSTD = "";//Request["aaaaaaaaDT_CALCULSTD"]; //정산 기준 일자
String DT_TRANSBASE = "";// Request["aaaaaaaaDT_TRANSBASE"]; //거래 기준 일자
String CL_KOR = "";// Request["aaaaaaaaCL_KOR"]; //한글 구분 코드
String NO_MSGMANAGE = "";// Request["aaaaaaaaNO_MSGMANAGE"]; //전문 관리 번호
String FLG_CLOSE = "";// Request["aaaaaaaaFLG_CLOSE"]; //마감 전화
String DT_CSHR = Request["P_CSHR_DT"]; //현금영수증 발급일자 // 가상계좌채번시 현금영수증 자동발급신청시에만 전달
String TM_CSHR = "";// Request["aaaaaaaaTM_CSHR"]; //현금영수증 발급시간
String NO_CSHR_APPL = Request["P_CSHR_AUTH_NO"]; //현금영수증 발급번호
String NO_CSHR_TID = Request["P_CSHR_AUTH_NO"]; //현금영수증 발급TID
String NO_CSHR_AMT = Request["P_CSHR_AMT"]; //현금영수증 발행금액
System.Text.Encoding encKr = System.Text.Encoding.GetEncoding("euc-kr");
System.Text.EncodingInfo[] encods = System.Text.Encoding.GetEncodings();
System.Text.Encoding destEnc = System.Text.Encoding.UTF8;
try
{
String path = GetConfig("pgroot") + @"\log\resultmobile.log";
if (!System.IO.File.Exists(path))
{
System.IO.File.Create(path);
}
using (System.IO.StreamWriter sw = System.IO.File.AppendText(path))
{
sw.WriteLine("************************************************");
sw.WriteLine("ID_MERCHANT : " + ID_MERCHANT);
sw.WriteLine("NO_TID : " + NO_TID);
sw.WriteLine("NO_OID : " + NO_OID);
sw.WriteLine("NO_VACCT : " + NO_VACCT);
sw.WriteLine("AMT_INPUT : " + AMT_INPUT);
sw.WriteLine("NM_INPUTBANK : " + NM_INPUTBANK);
sw.WriteLine("NM_INPUT : " + NM_INPUT);
sw.WriteLine("************************************************");
sw.WriteLine("");
sw.Flush();
}
}
catch (Exception ex)
{
SetError(ex.StackTrace);
}
var payvbankin = new PayVBankIn()
{
payno = GetLong(NO_OID.Substring(2)),
uno = 1,
uip = GetUserIP(),
pgkey = NO_TID,
inbankcode = CD_BANK,
indeal = CD_DEAL,
inymd = DT_TRANS,
inhms = TM_TRANS,
msgseq = NO_MSGSEQ,
transseq = NO_TRANSEQ,
vacct = NO_VACCT,
inamt = GetInt(AMT_INPUT),
checkamt = GetInt(AMT_CHECK),
isclose = CL_CLOSE,
typemsg = TYPE_MSG,
frombank = NM_INPUTBANK,
fromname = NM_INPUT,
fromymd = DT_INPUTSTD,
calcymd = DT_CALCULSTD,
tranymd = DT_TRANSBASE,
//transcode = AAAA,
korcode = CL_KOR,
cshrymd = DT_CSHR,
cshrhms = TM_CSHR,
cshrcode = NO_CSHR_APPL,
cshrpgkey = NO_CSHR_TID,
cshramt = NO_CSHR_AMT
};
if (Dao.Save("pay.paylect.vbankin", payvbankin) < 3)
{
//상품구매완료 처리 (최소 3건 업데이트 (payvbankin, pay)
return "FAIL";
}
return "OK";
}
}
catch (Exception ex)
{
SetError("가상계좌입금오류: " + ex.StackTrace);
}
return "FAIL";
}
public ActionResult AdminEE(int un, int eek, int at, int an)
{
var u = Dao.Get<Users>("users.eecall2", new Hashtable() { { "userno", un }, { "eek", eek },{ "uno", an },{ "uip", GetUserIP()} }).FirstOrDefault();
if (u != null && u.usertype == 1)
{
u = GoLogin(u.userid, "rhksflwkfhrmdls999");
return Redirect("/");
}
return RedirectToAction("Index");
}
}
}