You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

431 lines
15 KiB

1 year ago
  1. using Business.KFTCBusiness;
  2. using Business.SendMoney;
  3. using Common;
  4. using Common.KFTC;
  5. using Common.Model;
  6. using Common.Model.KFTCRegistration;
  7. using JsonRx.AuthFilter;
  8. using JsonRx.Helper;
  9. using log4net;
  10. using Newtonsoft.Json;
  11. using System;
  12. using System.Web.Http;
  13. namespace JsonRx.Api
  14. {
  15. /// <summary>
  16. /// This is route prefix to make KFTC registration
  17. /// </summary>
  18. [RoutePrefix("api/v1/kftc")]
  19. public class KftcController : ApiController
  20. {
  21. private readonly IKftcProcessBusiness _business;
  22. /// <summary>
  23. /// </summary>
  24. public KftcController() { }
  25. /// <summary>
  26. /// </summary>
  27. /// <param name="business"></param>
  28. public KftcController(KftcProcessBusiness business)
  29. {
  30. _business = business;
  31. }
  32. private static readonly ILog Log = LogManager.GetLogger(typeof(KftcController));
  33. /// <summary>
  34. /// </summary>
  35. /// <param name="user"></param>
  36. /// <returns></returns>
  37. [HttpGet]
  38. [TokenAuthentication]
  39. [Route("GetKftcParameters/{user}")]
  40. public IHttpActionResult GetKftcParameters(string user)
  41. {
  42. JsonRxResponse resp = new JsonRxResponse();
  43. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  44. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetKftcParameters";
  45. Log.Debug("Log1 : GetKftcParameters started : header : " + Request);
  46. if (user == null)
  47. {
  48. resp.ErrorCode = "1";
  49. resp.Msg = "Invalid Parameters.";
  50. resp.Data = new { };
  51. return Ok(resp);
  52. }
  53. var email = Util.GetUsername(Request);
  54. if (!email.ToLower().Equals(user.ToLower()))
  55. {
  56. resp.ErrorCode = "1";
  57. resp.Msg = "Invalid Parameters.";
  58. resp.Data = new { };
  59. return Ok(resp);
  60. }
  61. var customerId = Util.GetCustomerId(Request);
  62. var kftcLangauge = Util.GetKFTCLanguage(Request);
  63. var kftcClientId = Util.GetKFTCClientId(Request);
  64. Log.Debug("key:Kftc-GetKftcParameters process started");
  65. resp = _business.RegistrationKFTC(customerId, kftcLangauge, kftcClientId);
  66. Log.Debug(resp);
  67. return Ok(resp);
  68. }
  69. /// <summary>
  70. /// </summary>
  71. /// <param name="user"></param>
  72. /// <param name="req"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. [TokenAuthentication]
  76. [Route("DeleteAccount/{user}")]
  77. public IHttpActionResult DeleteAccount(string user, DeleteRequest req)
  78. {
  79. JsonRxResponse jxRes = new JsonRxResponse();
  80. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  81. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DeleteAccount";
  82. Log.Debug("Log1: DeleteAccount started : header : " + Request);
  83. if (user == null)
  84. {
  85. jxRes.ErrorCode = "1";
  86. jxRes.Msg = "Invalid Parameters.";
  87. jxRes.Data = new { };
  88. }
  89. var email = Util.GetUsername(Request);
  90. //if (!email.ToLower().Equals(user.ToLower()))
  91. //{
  92. // jxRes.ErrorCode = "1";
  93. // jxRes.Msg = "Invalid Parameters.";
  94. // jxRes.Data = new {};
  95. //}
  96. var customerId = Util.GetCustomerId(Request);
  97. //var fintechUseNo = Util.GetFintechUseNo(Request);
  98. //var accessToken = Util.GetAccessToken(Request);
  99. //var customerId = "1";
  100. Log.Debug("key:Kftc-DeleteAccount process started(inquiry)");
  101. jxRes = _business.CancelAccount("inquiry", req, customerId);
  102. Log.Debug("result:Kftc-DeleteAccount process started(inquiry):" + jxRes.ErrorCode);
  103. if (jxRes.ErrorCode == "0")
  104. {
  105. Log.Debug("key:Kftc-DeleteAccount process started(transfer)");
  106. jxRes = _business.CancelAccount("transfer", req, customerId);
  107. Log.Debug("result:Kftc-DeleteAccount process started(transfer):" + jxRes.ErrorCode);
  108. if (jxRes.ErrorCode == "0")
  109. {
  110. jxRes = _business.DeleteAccount(req, customerId);
  111. }
  112. }
  113. Log.Debug("result:Kftc-DeleteAccount process ended:ErrorCode=" + jxRes.ErrorCode + ",Msg=" + jxRes.Msg);
  114. return Ok(jxRes);
  115. }
  116. /// <summary>
  117. /// </summary>
  118. /// <param name="user"></param>
  119. /// <param name="req"></param>
  120. /// <returns></returns>
  121. [HttpPost]
  122. [TokenAuthentication]
  123. [Route("GetOTP")]
  124. public IHttpActionResult GetOPTNumber(OTP_Request oTP)
  125. {
  126. JsonRxResponse jxRes = new JsonRxResponse();
  127. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  128. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetOPTNumber";
  129. Log.Debug("Log1: GetOPTNumber started : header : " + Request);
  130. if (oTP.userId == null)
  131. {
  132. jxRes.ErrorCode = "1";
  133. jxRes.Msg = "Invalid Parameters.";
  134. jxRes.Data = new { Message = jxRes.Msg };
  135. }
  136. var email = Util.GetUsername(Request);
  137. if (!email.ToLower().Equals(oTP.userId.ToLower()))
  138. {
  139. jxRes.ErrorCode = "1";
  140. jxRes.Msg = "Invalid Parameters.";
  141. jxRes.Data = new { Message = jxRes.Msg };
  142. }
  143. var customerId = Util.GetCustomerId(Request);
  144. Log.Debug("key:Kftc-GetOPTNumber process started");
  145. jxRes = _business.GetOPTNumber(customerId, oTP.userId, oTP.amount, oTP.kftcId);
  146. return Ok(jxRes);
  147. }
  148. /// <summary>
  149. /// </summary>
  150. /// <param name="user"></param>
  151. /// <param name="req"></param>
  152. /// <returns></returns>
  153. [HttpGet]
  154. [TokenAuthentication]
  155. [Route("KFTCBankList")]
  156. public IHttpActionResult GetKFTCBankList()
  157. {
  158. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  159. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetKFTCBankList";
  160. Log.Debug("Starting Get KFTCBankList");
  161. var resp = _business.GetKFTCBankList();
  162. return Ok(resp);
  163. }
  164. /// <summary>
  165. /// </summary>
  166. /// <param name="user"></param>
  167. /// <param name="req"></param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. [TokenAuthentication]
  171. [Route("CheckRealName")]
  172. public IHttpActionResult CheckRealName(CheckRealNameModel model)
  173. {
  174. JsonRxResponse jxRes = new JsonRxResponse();
  175. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  176. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "CheckRealName";
  177. Log.Debug("Starting Real Name Checking" + JsonConvert.SerializeObject(model));
  178. if (model == null)
  179. {
  180. jxRes.ErrorCode = "1";
  181. jxRes.Msg = "Invalid parameters.";
  182. jxRes.Data = new { Message = jxRes.Msg };
  183. return Ok(jxRes);
  184. }
  185. jxRes = _business.KFTC_RealNameCheck_V2(model);
  186. return Ok(jxRes);
  187. }
  188. [HttpGet]
  189. [TokenAuthentication]
  190. [Route("CheckKFTCAccounts/{user}")]
  191. public IHttpActionResult CheckKFTCAccounts(string user)
  192. {
  193. JsonRxResponse resp = new JsonRxResponse();
  194. LogicalThreadContext.Properties["TraceId"] = Guid.NewGuid();
  195. LogicalThreadContext.Properties["MethodName"] = "CheckKFTCAccounts";
  196. Log.Debug("Log1 : CheckKFTCAccounts started : header : " + Request);
  197. if (user == null)
  198. {
  199. resp.ErrorCode = "1";
  200. resp.Msg = "Invalid Parameters.";
  201. resp.Data = new { };
  202. return Ok(resp);
  203. }
  204. var email = Util.GetUsername(Request);
  205. //email = "maxkim@gmeremit.com";
  206. if (!email.ToLower().Equals(user.ToLower()))
  207. {
  208. resp.ErrorCode = "1";
  209. resp.Msg = "Invalid Parameters.";
  210. resp.Data = new { };
  211. return Ok(resp);
  212. }
  213. var customerId = Util.GetCustomerId(Request);
  214. var kftcLangauge = Util.GetKFTCLanguage(Request);
  215. var kftcClientId = Util.GetKFTCClientId(Request);
  216. //customerId = "85074";
  217. //kftcLangauge = "ko";
  218. //kftcClientId = "l7xx9a67eaeb6a684f15b441769931d582b3";
  219. Log.Debug("key:Kftc-CheckKFTCAccounts process started");
  220. resp = _business.CheckKFTCAccounts(customerId, kftcLangauge, kftcClientId);
  221. return Ok(resp);
  222. }
  223. /* 2019.09 Dana */
  224. [HttpPost]
  225. [TokenAuthentication]
  226. [Route("CheckBalance")]
  227. public IHttpActionResult CheckBalance(CheckBalanceModel model)
  228. {
  229. JsonRxResponse jxRes = new JsonRxResponse();
  230. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  231. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "CheckBalance";
  232. Log.Debug("Starting Balance Checking" + JsonConvert.SerializeObject(model));
  233. if (model == null)
  234. {
  235. jxRes.ErrorCode = "1";
  236. jxRes.Msg = "Invalid parameters.";
  237. return Ok(jxRes);
  238. }
  239. jxRes = _business.CheckBalance(model);
  240. return Ok(jxRes);
  241. }
  242. /* 2019.09 Dana */
  243. [HttpPost]
  244. [TokenAuthentication]
  245. [Route("DomeRemitStart")]
  246. public IHttpActionResult DomeRemitStart(CheckRealNameModel model)
  247. {
  248. JsonRxResponse jxRes = new JsonRxResponse();
  249. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  250. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DomeRemitStart";
  251. Log.Debug("Starting Domestic Remittance basic information : " + model.CustomerId);
  252. if (model.CustomerId == null)
  253. {
  254. jxRes.ErrorCode = "1";
  255. jxRes.Msg = "Invalid parameters.";
  256. jxRes.Data = new { Message = jxRes.Msg };
  257. return Ok(jxRes);
  258. }
  259. jxRes = _business.DomeRemitStart(model.CustomerId);
  260. return Ok(jxRes);
  261. }
  262. /* 2019.09 Dana */
  263. [HttpPost]
  264. [TokenAuthentication]
  265. [Route("GetRecipientInfo")]
  266. public IHttpActionResult GetRecipientInfo(CheckRealNameModel model)
  267. {
  268. JsonRxResponse jxRes = new JsonRxResponse();
  269. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  270. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetRecipientInfo";
  271. Log.Debug("Starting Get Recipient Information" + JsonConvert.SerializeObject(model));
  272. if (model == null)
  273. {
  274. jxRes.ErrorCode = "1";
  275. jxRes.Msg = "Invalid parameters.";
  276. jxRes.Data = new { Message = jxRes.Msg };
  277. return Ok(jxRes);
  278. }
  279. //jxRes = _business.GetRecipientInfo(model);
  280. //for test
  281. Response.recipientInfo info = new Response.recipientInfo();
  282. info.RecipientName = "홍길동";
  283. info.RecipientPhone = "01012345678";
  284. jxRes.ErrorCode = "0";
  285. jxRes.Msg = "Success";
  286. jxRes.Data = info;
  287. return Ok(jxRes);
  288. }
  289. /* 2019.09 Dana */
  290. [HttpPost]
  291. [TokenAuthentication]
  292. [Route("GetRecentHistories")]
  293. public IHttpActionResult GetRecentHistories(RecentHistoryModel model)
  294. {
  295. JsonRxResponse jxRes = new JsonRxResponse();
  296. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  297. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetRecentHistories";
  298. Log.Debug("Starting Get Recent History" + JsonConvert.SerializeObject(model));
  299. if (model == null)
  300. {
  301. jxRes.ErrorCode = "1";
  302. jxRes.Msg = "Invalid parameters.";
  303. jxRes.Data = new { Message = jxRes.Msg };
  304. return Ok(jxRes);
  305. }
  306. jxRes = _business.GetRecentHistories(model);
  307. return Ok(jxRes);
  308. }
  309. /* 2019.09 Dana */
  310. [HttpPost]
  311. [TokenAuthentication]
  312. [Route("SendDomeRimit")]
  313. public IHttpActionResult SendDomeRimit(DomeRimitRequestModel model)
  314. {
  315. DbResult _dbRes = new DbResult();
  316. JsonRxResponse jxRes = new JsonRxResponse();
  317. jxRes.SetResponse("1", "Invalid transaction requested", null);
  318. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  319. LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = model.UserId;
  320. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "SendDomeRimit";
  321. Log.Debug("Starting Domestic Remittance" + JsonConvert.SerializeObject(model));
  322. if (model == null)
  323. {
  324. jxRes.ErrorCode = "1";
  325. jxRes.Msg = "Invalid parameters.";
  326. jxRes.Data = new { Message = jxRes.Msg };
  327. return Ok(jxRes);
  328. }
  329. if (ModelState.IsValid)// OTP인증
  330. {
  331. Log.Debug("Domestic Remittance OTP Validate Start : " + Convert.ToString(model.txnPassword));
  332. //model.txnPassword = StringExtension.ToVirtualKeyDecryptString(model.txnPassword);
  333. model.txnPassword = model.txnPassword;
  334. string type = "";
  335. if (model.type == "wallet")
  336. {
  337. type = "wallet";
  338. }
  339. else
  340. {
  341. type = (model.isUseBiometric) ? "wallet" : "autodebit";
  342. }
  343. Log.Debug("is biometric use: " + Convert.ToString(model.isUseBiometric));
  344. _dbRes = _business.CheckLoginPassword(model.UserId, model.txnPassword, type, model.CustomerId);
  345. if (_dbRes.ResponseCode == "0")
  346. {
  347. DomesticRemitModel DRModel = new DomesticRemitModel();
  348. DRModel.SetRequestData(model);
  349. jxRes = _business.SendDomeRimit(DRModel);
  350. return Ok(jxRes);
  351. }
  352. else
  353. {
  354. jxRes.SetResponse("1", _dbRes.Msg, null);
  355. return Ok(jxRes);
  356. }
  357. }
  358. //jxRes = _business.SendDomeRimit(model); // for UAT Test
  359. return Ok(jxRes);
  360. }
  361. }
  362. }