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.

2738 lines
119 KiB

1 year ago
  1. using Common;
  2. using Common.Helper;
  3. using Common.KFTC;
  4. using Common.Model;
  5. using Common.Model.AutoRefund;
  6. using Common.Model.KFTCRegistration;
  7. using Common.Model.KftcSendMoney;
  8. using Common.Model.SendMoney;
  9. using log4net;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Linq;
  12. using Repository.AutoRefund;
  13. using Repository.Coupon;
  14. using Repository.KFTCRepository;
  15. using Repository.Mobile;
  16. using Repository.SendMoney;
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Data;
  20. using System.Linq;
  21. using System.Threading;
  22. using System.Web;
  23. namespace Business.KFTCBusiness
  24. {
  25. public class KftcProcessBusiness : IKftcProcessBusiness
  26. {
  27. private readonly IKftcProcessRepository _repo;
  28. private readonly IMobileServicesRepo _mobilerepo;
  29. private readonly ISendMoneyRepository _sendrepo;
  30. private readonly IAutoRefundRepository _autorepo;
  31. private readonly ICouponRepository icouponrepo;
  32. private static readonly ILog Log = LogManager.GetLogger(typeof(KftcProcessBusiness));
  33. public KftcProcessBusiness(KftcProcessRepository repo, CouponRepository icouponrepo, MobileServicesRepo mobilerepo, SendMoneyRepository sendrepo, AutoRefundRepository autorepo)
  34. {
  35. _repo = repo;
  36. this.icouponrepo = icouponrepo;
  37. _mobilerepo = mobilerepo;
  38. _sendrepo = sendrepo;
  39. _autorepo = autorepo;
  40. }
  41. #region AUTO DEBIT ACCOUNT REGISTRATION
  42. public JsonRxResponse RegistrationKFTC(string customerId, string lang, string client_id)
  43. {
  44. JsonRxResponse res = new JsonRxResponse();
  45. try
  46. {
  47. string URL = GetKftcUrl(customerId, lang, client_id);
  48. List<AccountDetails> AccountList = GetAccountList(customerId);
  49. AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
  50. List<Header> ListLangauge = GetKftcLanguage(customerId);
  51. List<Header> ListHeader = GetKftcHeader(customerId);
  52. KftcCommonResponse Response = new KftcCommonResponse()
  53. {
  54. AccountList = AccountList,
  55. Header = ListHeader,
  56. URL = URL,
  57. Language = ListLangauge
  58. };
  59. res.ErrorCode = "0";
  60. res.Msg = "Success";
  61. res.Data = Response;
  62. return res;
  63. }
  64. catch (Exception ex)
  65. {
  66. Log.Error("Exception tracked : " + ex.Message, ex);
  67. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  68. res.Data = new { };
  69. return res;
  70. }
  71. }
  72. private List<Header> GetKftcLanguage(string customerId)
  73. {
  74. DataTable dt = _repo.GetKftcLanguage(customerId);
  75. List<Header> ListLanguage = new List<Header>();
  76. if (dt == null || dt.Rows.Count <= 0)
  77. {
  78. return ListLanguage;
  79. }
  80. foreach (DataRow row in dt.Rows)
  81. {
  82. Header language = new Header();
  83. language.Key = row["key"].ToString();
  84. language.Value = row["value"].ToString();
  85. ListLanguage.Add(language);
  86. };
  87. return ListLanguage;
  88. }
  89. private string GetKftcUrl(string customerId, string lang, string client_id)
  90. {
  91. var custId = "mobile_" + customerId;
  92. //for test
  93. //client_id = "B41lT2TeaECwRA4ITjGsbHOGAnm5gPBojPC1zTRq";
  94. Guid g = Guid.NewGuid();
  95. string stateValue = g.ToString().Replace("-", "");
  96. var auth = new Common.KFTC.Request.Authorize();
  97. auth.response_type = "code";
  98. auth.client_id = client_id;
  99. auth.redirect_uri = KFTC_GME.callback_url;
  100. auth.scope = "login inquiry transfer";
  101. auth.client_info = custId;
  102. auth.state = stateValue;
  103. auth.auth_type = "1";
  104. auth.bg_color = "#F4F8FB";
  105. auth.txt_color = "#000000";
  106. auth.btn1_color = "#EF343B";
  107. auth.btn2_color = "#22246B";
  108. //auth.lang = lang;
  109. auth.edit_option = "off";
  110. string _URL = @"oauth/2.0/authorize?@query";
  111. var jObj = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(auth));
  112. var query = String.Join("&", jObj.Children().Cast<JProperty>().Select(jp => jp.Name.Equals("redirect_uri") ? jp.Name +
  113. "=" + (jp.Value.ToString()) : jp.Name + "=" + HttpUtility.UrlEncode(jp.Value.ToString())));
  114. return ApplicationConfig.ReadWebConfig("KFTC_HOST_NAME", "") + _URL.Replace("@query", query);
  115. }
  116. private List<Header> GetKftcHeader(string customerId)
  117. {
  118. DataRow dr = _repo.GetCustomerData(customerId);
  119. List<Header> listKftcHeader = new List<Header>();
  120. string[] param = new string[] { "Kftc-Bfop-UserSeqNo", "Kftc-Bfop-UserCI", "Kftc-Bfop-UserName" ,
  121. "Kftc-Bfop-UserInfo","Kftc-Bfop-UserCellNo","Kftc-Bfop-PhoneCarrier","Kftc-Bfop-UserEmail"};
  122. if (dr == null)
  123. {
  124. //KftcHeader.Add("Kftc-Bfop-UserSeqNo", "");
  125. //KftcHeader.Add("Kftc-Bfop-UserCI", "");
  126. //KftcHeader.Add("Kftc-Bfop-UserName", "");
  127. //KftcHeader.Add("Kftc-Bfop-UserInfo", "");
  128. //KftcHeader.Add("Kftc-Bfop-UserCellNo", "");
  129. //KftcHeader.Add("Kftc-Bfop-PhoneCarrier", "");
  130. //KftcHeader.Add("Kftc-Bfop-UserEmail", "");
  131. foreach (var item in param)
  132. {
  133. Header KftcHeader = new Header();
  134. KftcHeader.Key = item;
  135. KftcHeader.Value = "";
  136. listKftcHeader.Add(KftcHeader);
  137. }
  138. }
  139. else
  140. {
  141. Header KftcHeader1 = new Header();
  142. KftcHeader1.Key = "Kftc-Bfop-UserSeqNo";
  143. KftcHeader1.Value = string.IsNullOrEmpty(dr["userSeqNo"].ToString()) ? "" : dr["userSeqNo"].ToString();
  144. listKftcHeader.Add(KftcHeader1);
  145. Header KftcHeader2 = new Header();
  146. KftcHeader2.Key = "Kftc-Bfop-UserCI";
  147. KftcHeader2.Value = string.IsNullOrEmpty(dr["userCi"].ToString()) ? "" : dr["userCi"].ToString();
  148. listKftcHeader.Add(KftcHeader2);
  149. Header KftcHeader3 = new Header();
  150. KftcHeader3.Key = "Kftc-Bfop-UserName";
  151. KftcHeader3.Value = string.IsNullOrEmpty(dr["userName"].ToString()) ? "" : dr["userName"].ToString();
  152. listKftcHeader.Add(KftcHeader3);
  153. Header KftcHeader4 = new Header();
  154. KftcHeader4.Key = "Kftc-Bfop-UserInfo";
  155. KftcHeader4.Value = string.IsNullOrEmpty(dr["userInfo"].ToString()) ? "" : dr["userInfo"].ToString();
  156. listKftcHeader.Add(KftcHeader4);
  157. Header KftcHeader5 = new Header();
  158. KftcHeader5.Key = "Kftc-Bfop-UserCellNo";
  159. KftcHeader5.Value = string.IsNullOrEmpty(dr["UserCellNo"].ToString()) ? "" : dr["UserCellNo"].ToString();
  160. listKftcHeader.Add(KftcHeader5);
  161. Header KftcHeader6 = new Header();
  162. KftcHeader6.Key = "Kftc-Bfop-PhoneCarrier";
  163. KftcHeader6.Value = "";
  164. listKftcHeader.Add(KftcHeader6);
  165. Header KftcHeader7 = new Header();
  166. KftcHeader7.Key = "Kftc-Bfop-UserEmail";
  167. KftcHeader7.Value = string.IsNullOrEmpty(dr["UserEmail"].ToString()) ? "" : dr["UserEmail"].ToString();
  168. listKftcHeader.Add(KftcHeader7);
  169. }
  170. return listKftcHeader;
  171. }
  172. /*
  173. * KFTC_CUSTOMER_SUB .
  174. * */
  175. private List<AccountDetails> GetAccountList(string customerId)
  176. {
  177. var accessToken = ""; //see again
  178. List<AccountDetails> _accountDetails = new List<AccountDetails>();
  179. List<AccountDetails> _delAccountList = new List<AccountDetails>();
  180. AccountDetails _accDetail = new AccountDetails();
  181. DataTable dt = _repo.GetAccountList(customerId);
  182. if (dt == null || dt.Rows.Count <= 0)
  183. {
  184. return _accountDetails;
  185. }
  186. string IsSyncAccList = dt.Rows[0]["IsSyncAccList"].ToString();
  187. List<Response.acoount_unit> _accList = new List<Response.acoount_unit>();
  188. if (IsSyncAccList == "Y")
  189. {
  190. DataRow customer = _repo.GetCustomerData(customerId);
  191. if (customer != null)
  192. {
  193. string userSeqNo = customer["userSeqNo"].ToString(); //how??
  194. Response.account_list _accountList = AccountListAPI(userSeqNo, accessToken, customerId);
  195. _accList = _accountList.res_list;
  196. }
  197. }
  198. foreach (DataRow item in dt.Rows)
  199. {
  200. AccountDetails _account = new AccountDetails();
  201. _account.KftcAccountId = item["RowId"].ToString();
  202. _account.BankCode = item["BankCode"].ToString();
  203. _account.BankCodeStd = item["BankCode"].ToString();
  204. _account.IsInboundPennyTestRequested = Convert.ToBoolean(item["IsInboundPennyTestRequested"]);
  205. // _account.AccessToken = item["access_token"].ToString();
  206. //_account.TokenType = item["tokenType"].ToString();
  207. //_account.Scope = item["scope"].ToString();
  208. //_account.UserCi = item["userCi"].ToString();
  209. //_account.CustomerId = item["customerId"].ToString();
  210. //_account.UserSeqNo = item["userSeqNo"].ToString();
  211. //_account.FintechUseNo = item["fintechUseNo"].ToString();
  212. //_account.BankCodeStd = item["bankCodeStd"].ToString();
  213. _account.BankName = item["bankName"].ToString();
  214. //_account.AccountNum = item["accountNum"].ToString();
  215. _account.AccountNumMasked = item["accountNumMasked"].ToString();
  216. //_account.AccountName = item["accountName"].ToString();
  217. _account.IsShowRefresh = item["IsShowRefresh"].ToString();
  218. if (IsSyncAccList == "Y")
  219. {
  220. if (_accList.Count > 0)
  221. {
  222. bool bSearch = false;
  223. foreach (var acc in _accList)
  224. {
  225. if ((_account.AccountNum == acc.account_num)
  226. && (acc.transfer_agree_yn == "Y"))
  227. {
  228. bSearch = true;
  229. _accountDetails.Add(_account);
  230. break;
  231. }
  232. }
  233. if (!bSearch)
  234. {
  235. _delAccountList.Add(_account);
  236. }
  237. }
  238. }
  239. else
  240. {
  241. _accountDetails.Add(_account);
  242. }
  243. }
  244. if (_delAccountList.Count > 0)
  245. {
  246. foreach (var account in _delAccountList)
  247. {
  248. _repo.DeleteAccount(account);
  249. }
  250. }
  251. return _accountDetails;
  252. }
  253. /*
  254. * API
  255. * */
  256. private Response.account_list AccountListAPI(string userSeqNo, string accessToken, string customerId)
  257. {
  258. Response.account_list _accountList = new Response.account_list();
  259. DbResult _logResp = new DbResult();
  260. string _acclistURL = @"v2.0/account/list?user_seq_no=@user_seq_no&include_cancel_yn=@include_cancel_yn&sort_order=@sort_order";
  261. try
  262. {
  263. Request.list req = new Request.list();
  264. req.user_seq_no = userSeqNo; // user_seq_no;
  265. req.sort_order = "D"; // Descending, A:Ascending
  266. req.include_cancel_yn = "N"; // 해지계좌 불포함, Y:해지계좌 포함
  267. _logResp = _repo.LogRequestKFTC(customerId, "Account/List", "URL: " + _acclistURL + " RequestData: " + JsonConvert.SerializeObject(req), "");
  268. Log.Debug("[KFTC-API-REQ] account/list : [customerId]:" + customerId + " [REQ URL]:" + _acclistURL + " [REQ DATA]:" + JsonConvert.SerializeObject(req));
  269. KFTCPostGet kftcRequest = new KFTCPostGet();
  270. var acclistResult = kftcRequest.GetFromKFTC(_acclistURL.Replace("@user_seq_no", req.user_seq_no)
  271. .Replace("@include_cancel_yn", req.include_cancel_yn)
  272. .Replace("@sort_order", req.sort_order),
  273. accessToken);
  274. if (string.IsNullOrEmpty(acclistResult))
  275. {
  276. _accountList.rsp_code = "0101";
  277. _accountList.rsp_message = "FAILED TO KFTC OPEN-FLATFORM (ACCOUNT/LIST) QUERY!";
  278. _repo.LogResponseKFTC(_logResp.Id, null, _accountList.rsp_code, _accountList.rsp_message);
  279. return _accountList;
  280. }
  281. _accountList = JsonConvert.DeserializeObject<Response.account_list>(acclistResult);
  282. Log.Debug("[KFTC-API-RES] account/list : " + acclistResult);
  283. _repo.LogResponseKFTC(_logResp.Id, acclistResult, _accountList.rsp_code, _accountList.rsp_message);
  284. }
  285. catch (Exception ex)
  286. {
  287. _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message);
  288. _accountList.rsp_code = "0101";
  289. _accountList.rsp_message = ex.Message;
  290. Log.Debug("[KFTC-API-EXCEPTION] account/list :" + ex.Message);
  291. }
  292. return _accountList;
  293. }
  294. #endregion AUTO DEBIT ACCOUNT REGISTRATION
  295. /* ---------------------------------------------------------------------
  296. * API
  297. * ---------------------------------------------------------------------
  298. */
  299. public JsonRxResponse CancelAccount(string cancelType, DeleteRequest req, string customerId)
  300. {
  301. DbResult _dbRes = new DbResult();
  302. DbResult _logResp = new DbResult();
  303. JsonRxResponse res = new JsonRxResponse();
  304. KFTCPostGet kftcRequest = new KFTCPostGet();
  305. var kftcLogId = Crypto.Decrypt(req.KftcLogId, Utilities.ReadWebConfig("ktft_client_info_salt", ""));
  306. try
  307. {
  308. var request = _repo.GetAccountKFTCInfo(customerId, kftcLogId); /* 2019.10.10 KFTC 계좌 서비스승인 정보조회 Dana*/
  309. var fintechUseNo = request["FintechUseNo"].ToString();
  310. var accessToken = request["AccessToken"].ToString();
  311. string inquiryAgreeYn = request["inquiryAgreeYn"].ToString();
  312. string transferAgreeYn = request["transferAgreeYn"].ToString();
  313. string _cancelURL = @"v2.0/account/cancel";
  314. if (null == request)
  315. {
  316. res.ErrorCode = "1";
  317. res.Msg = "Error:Invalid auto debit account";
  318. return res;
  319. }
  320. if (cancelType == "inquiry" && inquiryAgreeYn != "Y")
  321. {
  322. res.SetResponse("0", "This account has already been deleted.", null);
  323. }
  324. if (cancelType == "transfer" && transferAgreeYn != "Y")
  325. {
  326. res.SetResponse("0", "This account has already been deleted.", null);
  327. }
  328. Request.account_cancel reqObj = new Request.account_cancel();
  329. reqObj.scope = cancelType;
  330. reqObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호
  331. reqObj.fintech_use_num = fintechUseNo;
  332. string reqData = JsonConvert.SerializeObject(reqObj);
  333. _logResp = _repo.LogRequestKFTC(customerId, "AccountCancel", reqData);
  334. Log.Debug("[KFTC-API-REQ] account/cancel : [customerId]:" + customerId + " [REQ Data]:" + reqData);
  335. /*계좌해지요청* */
  336. var resp = kftcRequest.PostToKFTC(_cancelURL, accessToken, reqData);
  337. /** 사용자 계좌해지요청 실패!!! * */
  338. if (string.IsNullOrEmpty(resp))
  339. {
  340. res.ErrorCode = "999";
  341. res.Msg = "FAILED TO KFTC OPEN-FLATFORM (ACCOUNT/CANCEL)!";
  342. _repo.LogResponseKFTC(_logResp.Id, null, res.ErrorCode, res.Msg);
  343. return res;
  344. }
  345. var respObj = JsonConvert.DeserializeObject<Response.cancel>(resp);
  346. _repo.LogResponseKFTC(_logResp.Id, resp, respObj.rsp_code, respObj.rsp_message);
  347. string processId = _logResp.Extra;
  348. Log.Debug("[KFTC-API-RES] account/cancel : " + resp);
  349. if (respObj.rsp_code == "A0000")
  350. {
  351. res.ErrorCode = "0";
  352. res.Msg = "Account deleted successfully!";
  353. res.Data = new { };
  354. }
  355. else
  356. {
  357. res.ErrorCode = "1";
  358. res.Msg = respObj.rsp_message;
  359. res.Data = new { };
  360. }
  361. return res;
  362. }
  363. catch (Exception ex)
  364. {
  365. res.ErrorCode = "1";
  366. res.Msg = "Error:Invalid auto debit account";
  367. return res;
  368. }
  369. }
  370. public JsonRxResponse GetOPTNumber(string customerId, string user, string amount, string kftcId)
  371. {
  372. JsonRxResponse res = new JsonRxResponse();
  373. DbResult dbResult = new DbResult();
  374. try
  375. {
  376. kftcId = Crypto.Decrypt(kftcId, Utilities.ReadWebConfig("ktft_client_info_salt", ""));
  377. dbResult = _repo.GetOPTNumber(customerId, user, amount, kftcId);
  378. res.SetResponse(dbResult.ResponseCode, dbResult.Msg, "");
  379. return res;
  380. }
  381. catch (Exception ex)
  382. {
  383. Log.Error("Exception tracked : " + ex.Message, ex);
  384. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  385. return res;
  386. }
  387. }
  388. public DbResult SendAutoDebit(string CustomerId, string KftcCustRegdId, string CollAmt, string schemaId, string serviceCharge)
  389. {
  390. DbResult _dbRes = new DbResult();
  391. KftcSendMoneyRequest request = _repo.GetCustomerKFTCInfo(CustomerId, KftcCustRegdId);
  392. if (null == request)
  393. {
  394. _dbRes.SetError("1", "Error:Invalid auto debit account", null);
  395. return _dbRes;
  396. }
  397. request.CollAmt = CollAmt.Split('.')[0];
  398. DbResult _logResp = new DbResult();
  399. /*
  400. * empty check
  401. * */
  402. if (string.IsNullOrWhiteSpace(request.CustomerId)
  403. || string.IsNullOrWhiteSpace(request.AccessToken)
  404. || string.IsNullOrWhiteSpace(request.FintechUseNo)
  405. || string.IsNullOrWhiteSpace(CollAmt)
  406. || string.IsNullOrWhiteSpace(request.AccountName)
  407. || string.IsNullOrWhiteSpace(request.BankCode)
  408. || string.IsNullOrWhiteSpace(request.AccountNum)
  409. || string.IsNullOrWhiteSpace(request.AccHolderInfoType)
  410. || string.IsNullOrWhiteSpace(request.AccHolderInfo))
  411. {
  412. _dbRes.ResponseCode = "999";
  413. _dbRes.Msg = "Oops! Something went wrong please re-login and try again.";
  414. return _dbRes;
  415. }
  416. request.processId = DateTime.Now.Ticks + request.CustomerId;
  417. /*
  418. *
  419. * @Max:2018.09
  420. * */
  421. //_dbRes = CheckBankStatus(request);
  422. //if (_dbRes.ResponseCode != "A0000")
  423. //{
  424. // return _dbRes;
  425. //}
  426. /*
  427. *
  428. * @Max:2018.09.
  429. * */
  430. //if (String.IsNullOrEmpty(request.AccHolderInfoType) == true)
  431. //{
  432. // _dbRes.ResponseCode = "999";
  433. // _dbRes.Msg = "[FAIL] Customer's real name number type is null ";
  434. // return _dbRes;
  435. //}
  436. //if (String.IsNullOrEmpty(request.AccHolderInfo) == true)
  437. //{
  438. // _dbRes.ResponseCode = "999";
  439. // _dbRes.Msg = "[FAIL] Customer's real name number is null ";
  440. // return _dbRes;
  441. //}
  442. //if (String.IsNullOrEmpty(request.AccountNum) == true)
  443. //{
  444. // _dbRes.ResponseCode = "999";
  445. // _dbRes.Msg = "[FAIL] Customer's real number is null ";
  446. // return _dbRes;
  447. //}
  448. //var accountHolderInfoType = request.AccHolderInfoType;
  449. //var accountHolderInfo = request.AccHolderInfo.Replace("-", "").Trim();
  450. //request.AccHolderInfo = accountHolderInfo;
  451. /*
  452. * : Ver 1
  453. */
  454. //_dbRes = CheckRealName(request);
  455. ///* 계좌실명조회가 실패하면... */
  456. //if (_dbRes.ResponseCode != "A0000")
  457. //{
  458. // return _dbRes;
  459. //}
  460. /*
  461. * : Ver 2
  462. */
  463. CheckRealNameModel model = new CheckRealNameModel()
  464. {
  465. CustomerId = CustomerId,
  466. BankCode = request.BankCode,
  467. AccountNumber = request.AccountNum
  468. };
  469. var jsonRx = KFTC_RealNameCheck_V2(model);
  470. if (jsonRx.ErrorCode != "0")
  471. {
  472. _dbRes.SetError("1", jsonRx.Msg, null);
  473. return _dbRes;
  474. }
  475. /*
  476. *
  477. *
  478. * */
  479. // 쿠폰 아이디가 있으면 쿠폰 할인 금액을 구한다.
  480. string discountvalue = "0";
  481. if (!string.IsNullOrWhiteSpace(schemaId))
  482. {
  483. Log.Debug("coupon started" + schemaId.ToString() + " charge" + serviceCharge.ToString());
  484. discountvalue = icouponrepo.GetCouponDiscountValue(schemaId, serviceCharge);
  485. }
  486. var req = new Common.KFTC.Request.withdraw();
  487. req.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호
  488. req.cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", "");
  489. req.cntr_account_num = ApplicationConfig.ReadWebConfig("GME_WITHDRAW_ACCNO", "");
  490. req.dps_print_content = request.AccountName; //입금계좌내역
  491. req.fintech_use_num = request.FintechUseNo; //산업은행-1234567890
  492. req.tran_amt = (Convert.ToDouble(request.CollAmt) - Convert.ToDouble(discountvalue)).ToString(); //거래금액
  493. req.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); //요청일시
  494. req.req_client_name = request.AccountName;
  495. req.req_client_bank_code = request.BankCode;
  496. req.req_client_account_num = request.AccountNum;
  497. req.req_client_num = request.CustomerId;
  498. req.transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "");
  499. string tranDtime = req.tran_dtime;
  500. //string tranDtime_1 = DateTime.Now.AddSeconds(-1).ToString("yyyyMMddHHmmss");
  501. string _URL = ApplicationConfig.ReadWebConfig("TRANSFER_WITHDRAW", ""); //@"transfer/withdraw";
  502. var access_token = request.AccessToken;
  503. string postData = JsonConvert.SerializeObject(req);
  504. //log request
  505. _logResp = _repo.LogRequestKFTC(request.CustomerId, "DebitAccount", "access_token :" + access_token + "req :" + postData);
  506. Log.Debug("[KFTC-API-REQ] transfer/Withdraw : [customerId]:" + request.CustomerId + " [REQ URL]:" + _URL + " [REQ DATA]:" + postData);
  507. KFTCPostGet kftcRequest = new KFTCPostGet();
  508. try
  509. {
  510. /*
  511. *
  512. * */
  513. var resp = kftcRequest.PostToKFTC(_URL, access_token, postData);
  514. /*
  515. * !!!
  516. * */
  517. if (string.IsNullOrEmpty(resp))
  518. {
  519. _dbRes.ResponseCode = "999";
  520. _dbRes.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/WITHDRAW)!";
  521. //log response
  522. _repo.LogResponseKFTC(_logResp.Id, resp, _dbRes.ResponseCode, _dbRes.Msg);
  523. return _dbRes;
  524. }
  525. var respObj = JsonConvert.DeserializeObject<Response.withdraw>(resp);
  526. Log.Debug("[KFTC-API-RES] transfer/Withdraw : " + resp);
  527. //log response
  528. _repo.LogResponseKFTC(_logResp.Id, resp, respObj.rsp_code, (respObj.rsp_code == "A0000") ? "Success!" : respObj.rsp_message);
  529. if (respObj.rsp_code == "A0001" ||
  530. respObj.rsp_code == "A0003" ||
  531. respObj.rsp_code == "A0007" ||
  532. respObj.bank_rsp_code == "400")
  533. {
  534. Thread.Sleep(1 * 60 * 1000);
  535. /*
  536. * */
  537. respObj = CheckWithdrawResult(ref respObj, request.CustomerId, "1");
  538. if (respObj.rsp_code == "A0001" ||
  539. respObj.rsp_code == "A0003" ||
  540. respObj.rsp_code == "A0007" ||
  541. respObj.bank_rsp_code == "400")
  542. {
  543. Thread.Sleep(2 * 60 * 1000);
  544. /*
  545. * */
  546. respObj = CheckWithdrawResult(ref respObj, request.CustomerId, "2");
  547. if (respObj.rsp_code == "A0001" ||
  548. respObj.rsp_code == "A0003" ||
  549. respObj.rsp_code == "A0007" ||
  550. respObj.bank_rsp_code == "400")
  551. {
  552. _dbRes.ResponseCode = respObj.rsp_code;
  553. _dbRes.Msg = respObj.rsp_message;
  554. _dbRes.Id = respObj.api_tran_id;
  555. _dbRes.Extra = respObj.api_tran_dtm;
  556. return _dbRes;
  557. }
  558. }
  559. }
  560. DbResult _saveKFTCData = new DbResult();
  561. if (respObj.rsp_code == "A0000")
  562. {
  563. /*
  564. * COPIED FROM ONLINE
  565. *
  566. * @PRALHAD-2019.01.08
  567. * */
  568. //string fromTime = respObj.api_tran_dtm.Substring(0, 14);
  569. //max-20180615
  570. //_dbRes = CheckRemittant(fromTime, customerId, accountNum, accountName, processId);
  571. //respObj.remittance_check = (_dbRes.ErrorCode == "A0000") ? "Y" : "N";
  572. respObj.remittance_check = "Y";
  573. _saveKFTCData = _repo.SaveKFTCTranData(respObj, request.CustomerId);
  574. //if (_dbRes.ErrorCode != "A0000")
  575. //{
  576. // return _dbRes;
  577. //}
  578. }
  579. _dbRes.ResponseCode = respObj.rsp_code;
  580. _dbRes.Msg = respObj.rsp_message;
  581. _dbRes.Id = _saveKFTCData.Id;
  582. // USED FOR AUTO DEBIT REFURN
  583. _dbRes.Extra = request.AccountNum;
  584. _dbRes.Extra2 = request.BankCode;
  585. return _dbRes;
  586. }
  587. catch (Exception ex)
  588. {
  589. //log response
  590. _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message);
  591. _dbRes.SetError("999", ex.Message, null);
  592. return _dbRes;
  593. }
  594. }
  595. // check GME bank status and customer bank Status
  596. private DbResult CheckBankStatus(KftcSendMoneyRequest request)
  597. {
  598. DbResult dbRes = new DbResult();
  599. DbResult logRes = new DbResult();
  600. KFTCPostGet kftcRequest = new KFTCPostGet();
  601. //string _URL = @"bank/status";
  602. //string httpUrl = ApplicationConfig.ReadWebConfig("BANK_STATUS", ""); //using Open banking 2019.10 @Dana disable
  603. //using Open banking 2019.10 @Dana
  604. string httpUrl = @"v2.0/bank/status";
  605. string access_token = request.GmeAccessToken;
  606. string gmeBankCode = request.GmeBankCode;
  607. string processId = request.processId;
  608. //log request
  609. logRes = _repo.LogRequestKFTC(request.CustomerId, "CheckBankStatus", "_URL :" + httpUrl + " access_token :" + access_token, processId);
  610. try
  611. {
  612. /*
  613. * !!!
  614. * */
  615. var resBankStatusStr = kftcRequest.GetFromKFTC(httpUrl, access_token);
  616. /*
  617. * !!!
  618. * */
  619. if (string.IsNullOrEmpty(resBankStatusStr))
  620. {
  621. dbRes.ResponseCode = "999";
  622. dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM (BANK/STATUS)!";
  623. //log response
  624. _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg);
  625. return dbRes;
  626. }
  627. var resBankStatusObj = JsonConvert.DeserializeObject<Response.bank_status>(resBankStatusStr);
  628. //log response
  629. //_utility.LogResponseKFTC(_logResp.Id, resp, bankList.rsp_code, bankList.rsp_message);
  630. //정상응답이 아닌경우...
  631. if (resBankStatusObj.rsp_code != "A0000")
  632. {
  633. dbRes.SetError("999", resBankStatusObj.rsp_message, null);
  634. //log response
  635. _repo.LogResponseKFTC(logRes.Id, null, resBankStatusObj.rsp_code, dbRes.Msg);
  636. return dbRes;
  637. }
  638. List<Response.bank_unit> bankUnit = resBankStatusObj.res_list;
  639. //dbRes.Extra = logRes.Extra;
  640. //dbRes.Id = "";
  641. //고객은행과 GME은행이 정상이면 "YY"
  642. string bankStatus = "N";
  643. foreach (var item in bankUnit)
  644. {
  645. //customer bank
  646. if (item.bank_code_std == request.BankCode)
  647. {
  648. bankStatus = item.bank_status;
  649. }
  650. }
  651. if (bankStatus != "Y")
  652. {
  653. dbRes.ResponseCode = "999";
  654. dbRes.Msg = String.Format("[FAIL] This bank{0} service is not available right now, please try again later !!", request.BankCode);
  655. //log response
  656. _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg);
  657. return dbRes;
  658. }
  659. bankStatus = "N";
  660. foreach (var item in bankUnit)
  661. {
  662. //GME bank
  663. if (item.bank_code_std == gmeBankCode)
  664. {
  665. bankStatus = item.bank_status;
  666. }
  667. }
  668. if (bankStatus != "Y")
  669. {
  670. dbRes.ResponseCode = "999";
  671. dbRes.Msg = String.Format("[FAIL] This bank {0} service is not available right now, please try again later !!", gmeBankCode);
  672. //log response
  673. _repo.LogResponseKFTC(logRes.Id, null, dbRes.ResponseCode, dbRes.Msg);
  674. return dbRes;
  675. }
  676. //성공
  677. dbRes.SetError("A0000", "", null);
  678. return dbRes;
  679. }
  680. catch (Exception ex)
  681. {
  682. dbRes.SetError("999", ex.Message, null);
  683. //log response
  684. _repo.LogResponseKFTC(logRes.Id, "Exception occured", "999", ex.Message);
  685. return dbRes;
  686. }
  687. }
  688. // CUSTOMER ACCOUNT DETAIL VERIFICATION
  689. public DbResult CheckRealName(KftcSendMoneyRequest request)
  690. {
  691. DbResult _dbRes = new DbResult();
  692. DbResult _logResp = new DbResult();
  693. KFTCPostGet kftcRequest = new KFTCPostGet();
  694. string httpUrl = ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name";
  695. string oob_access_token = request.GmeAccessToken;
  696. string processId = request.processId;
  697. //주민등록번호 Resident registration number
  698. if (request.AccHolderInfoType == "8008")
  699. {
  700. request.AccHolderInfoType = "1";
  701. }
  702. //외국인등록번호 Foreigner registration number
  703. else if (request.AccHolderInfoType == "1302")
  704. {
  705. request.AccHolderInfoType = "2";
  706. }
  707. //여권번호이면 조합주민번호로 조회 Passport with Combination no
  708. else if (request.AccHolderInfoType == "10997")
  709. {
  710. request.AccHolderInfoType = "5";
  711. }
  712. //사업자등록번호 Company Registration Number
  713. else if (request.AccHolderInfoType == "10988")
  714. {
  715. request.AccHolderInfoType = "6";
  716. }
  717. var reqRealNameObj = new Common.KFTC.Request.real_name();
  718. reqRealNameObj.bank_code_std = request.BankCode;
  719. reqRealNameObj.account_num = request.AccountNum;
  720. reqRealNameObj.account_holder_info_type = request.AccHolderInfoType;
  721. reqRealNameObj.account_holder_info = request.AccHolderInfo;
  722. reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
  723. try
  724. {
  725. string reqRealNameStr = JsonConvert.SerializeObject(reqRealNameObj);
  726. //로그-요청로그
  727. _logResp = _repo.LogRequestKFTC(request.CustomerId, httpUrl, reqRealNameStr, processId);
  728. var resRealNameStr = kftcRequest.PostToKFTC(httpUrl, oob_access_token, reqRealNameStr);
  729. /*
  730. * !!!
  731. * */
  732. if (string.IsNullOrEmpty(resRealNameStr))
  733. {
  734. _dbRes.ResponseCode = "999";
  735. _dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name)";
  736. //로그-결과로그(실패)
  737. _repo.LogResponseKFTC(_logResp.Id, null, _dbRes.ResponseCode, _dbRes.Msg);
  738. return _dbRes;
  739. }
  740. var resRealNameObj = JsonConvert.DeserializeObject<Response.real_name>(resRealNameStr);
  741. //응답메시지가 성공일때...
  742. if (resRealNameObj.rsp_code == "A0000" && resRealNameObj.bank_rsp_code == "000")
  743. {
  744. _dbRes.ResponseCode = "A0000";
  745. _dbRes.Msg = "[SUCCESS] KFTC OPEN-FLATFORM INQUIRY";
  746. }
  747. //응답메시지가 성공이 아닐때..
  748. else if (resRealNameObj.rsp_code != "A0000")
  749. {
  750. _dbRes.ResponseCode = resRealNameObj.rsp_code;
  751. _dbRes.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM INQUIRY rsp_message:{0}",
  752. resRealNameObj.rsp_message);
  753. //_dbRes.Msg = String.Format("[FAIL] inquiry/real_name : rsp_message={0}, req_type={1}, req_num={2}, res_type={3}, res_num={4}",
  754. // resRealNameObj.rsp_message,
  755. // accountHolderInfoType,
  756. // accountHolderInfo,
  757. // resRealNameObj.account_holder_info_type,
  758. // resRealNameObj.account_holder_info);
  759. }
  760. else if (resRealNameObj.bank_rsp_code != "000")
  761. {
  762. _dbRes.ResponseCode = resRealNameObj.bank_rsp_code;
  763. _dbRes.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM INQUIRY bank_rsp_message:{0}",
  764. resRealNameObj.bank_rsp_message);
  765. //_dbRes.Msg = String.Format("[FAIL] inquiry/real_name : rsp_message={0}, req_type={1}, req_num={2}, res_type={3}, res_num={4}",
  766. // resRealNameObj.bank_rsp_message,
  767. // accountHolderInfoType,
  768. // accountHolderInfo,
  769. // resRealNameObj.account_holder_info_type,
  770. // resRealNameObj.account_holder_info);
  771. }
  772. else
  773. {
  774. _dbRes.ResponseCode = resRealNameObj.rsp_code;
  775. _dbRes.Msg = "[FAIL] KFTC OPEN-FLATFORM INQUIRY";
  776. }
  777. // 로그-응답로그
  778. _repo.LogResponseKFTC(_logResp.Id, resRealNameStr, _dbRes.ResponseCode, _dbRes.Msg);
  779. _dbRes.SetError(_dbRes.ResponseCode, _dbRes.Msg, null);
  780. return _dbRes;
  781. }
  782. catch (Exception ex)
  783. {
  784. //로그-응답로그
  785. _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message);
  786. _dbRes.SetError("999", ex.Message, null);
  787. return _dbRes;
  788. }
  789. }
  790. /*
  791. * KFTC
  792. * */
  793. private Response.withdraw CheckWithdrawResult(ref Response.withdraw withdrawObj, string customerId, string tryCount)
  794. {
  795. string url = @"v2.0/transfer/result";
  796. var reqObj = new Request.result();
  797. reqObj.check_type = "1"; //1:출금이체, 2:입금이체
  798. reqObj.req_cnt = "1"; //요청건수
  799. reqObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); ; //요청일시
  800. reqObj.req_list = new List<Request.result_unit>();
  801. var reqUnitObj = new Request.result_unit();
  802. reqUnitObj.tran_no = "1"; // 거래순번
  803. reqUnitObj.org_bank_tran_id = withdrawObj.bank_tran_id; ; // "12345678901234567890"; //원거래 고유번호
  804. reqUnitObj.org_bank_tran_date = withdrawObj.bank_tran_date; // "20180101"; //원거래 일자
  805. reqUnitObj.org_tran_amt = withdrawObj.tran_amt; // "1000"; //원거래금액
  806. reqObj.req_list.Add(reqUnitObj);
  807. string reqData = JsonConvert.SerializeObject(reqObj);
  808. //log request
  809. DbResult _logResp = _repo.LogRequestKFTC(customerId, "DebitAccount:Retry:" + tryCount, JsonConvert.SerializeObject(reqObj));
  810. Log.Debug("[KFTC-API-REQ] transfer/result : [customerId]:" + customerId + " [REQ DATA]:" + JsonConvert.SerializeObject(reqObj));
  811. Response.withdraw resObj = new Response.withdraw();
  812. var gme = _repo.GetGMEMaster();
  813. if (gme == null)
  814. {
  815. resObj.rsp_code = "999";
  816. resObj.rsp_message = "[transfer/result] Failed to bring GME token";
  817. _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message);
  818. return resObj;
  819. }
  820. var gmeAccessToken = gme["accessToken"].ToString();
  821. KFTCPostGet kftcRequest = new KFTCPostGet();
  822. var resData = kftcRequest.PostToKFTC(url, gmeAccessToken, reqData);
  823. if (string.IsNullOrEmpty(resData))
  824. {
  825. resObj.rsp_code = "999";
  826. resObj.rsp_message = "[transfer/result] Failed to Open-banking transfer/result";
  827. _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message);
  828. return resObj;
  829. }
  830. resObj = JsonConvert.DeserializeObject<Response.withdraw>(resData);
  831. //log response
  832. _repo.LogResponseKFTC(_logResp.Id, resData, resObj.rsp_code, resObj.rsp_message);
  833. Log.Debug("[KFTC-API-RES] transfer/result : " + resData);
  834. return resObj;
  835. }
  836. /* ------------------------------------
  837. *
  838. * ------------------------------------
  839. * */
  840. // refund of auto debit failed transaction
  841. public DbResult RefundAutoDebit(AutoDebitRefund refundInfo, AccountTransferToBank withdrawalInfo)
  842. {
  843. //UPDATE FAIL LOG FOR AUTO DEBIT TRANSACTION
  844. var resp1 = _repo.LogFailTransactionForAutoDebit(refundInfo.rowId, refundInfo.ErrorCode, refundInfo.ErrorMsg, withdrawalInfo.amount);
  845. if (resp1.ResponseCode == "1")
  846. {
  847. return resp1;
  848. }
  849. DbResult dbResult = new DbResult()
  850. {
  851. ResponseCode = "1",
  852. Msg = "Failed!"
  853. };
  854. try
  855. {
  856. KJAutoRefundModel kj = new KJAutoRefundModel()
  857. {
  858. flag = "Autodebit_REQ",
  859. customerId = refundInfo.CustomerId,
  860. customerSummary = "",
  861. amount = withdrawalInfo.amount,
  862. action = "REQ",
  863. actionDate = "",
  864. actionBy = refundInfo.CustomerId,
  865. bankCode = withdrawalInfo.receiveInstitution,
  866. bankAccountNo = withdrawalInfo.receiveAccountNo,
  867. };
  868. dbResult = _repo.SendAutoRefund(kj);
  869. kj.rowId = dbResult.Id;
  870. /* KJ
  871. * */
  872. var body = JsonConvert.SerializeObject(withdrawalInfo);
  873. var resp = KwangjuBankApi.TransferAmount(body);
  874. var dbApiRes = JsonConvert.DeserializeObject<JsonRxResponse>(resp);
  875. if (dbApiRes.ErrorCode != "0")
  876. {
  877. kj.flag = "Autodebit_FAIL";
  878. kj.action = "FAIL";
  879. }
  880. else
  881. {
  882. kj.flag = "SUCCESS";
  883. kj.action = "SUCCESS";
  884. }
  885. dbResult = _repo.SendAutoRefund(kj);
  886. }
  887. catch (Exception e)
  888. {
  889. dbResult.ResponseCode = "1";
  890. dbResult.Msg = e.Message;
  891. }
  892. return dbResult;
  893. }
  894. /* * ------------------------------------
  895. * API
  896. * ------------------------------------
  897. * */
  898. // Response.deposit으로 return하기 위한 함수
  899. private Response.deposit CheckDepositResult(ref Response.deposit depositObj, string customerId, string tryCount)
  900. {
  901. string url = @"v2.0/transfer/result";
  902. var reqObj = new Request.result();
  903. reqObj.check_type = "2"; //1:출금이체, 2:입금이체
  904. reqObj.req_cnt = "1"; //요청건수
  905. reqObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); ; //요청일시
  906. reqObj.req_list = new List<Request.result_unit>();
  907. var reqUnitObj = new Request.result_unit();
  908. reqUnitObj.tran_no = depositObj.res_list[0].tran_no;
  909. reqUnitObj.org_bank_tran_id = depositObj.res_list[0].bank_tran_id;
  910. reqUnitObj.org_bank_tran_date = depositObj.res_list[0].bank_tran_date; //거래일자
  911. reqUnitObj.org_tran_amt = depositObj.res_list[0].tran_amt; //거래금액
  912. reqObj.req_list.Add(reqUnitObj);
  913. string reqData = JsonConvert.SerializeObject(reqObj);
  914. //log request
  915. DbResult _logResp = _repo.LogRequestKFTC(customerId, "DebitAccount:Retry:" + tryCount, JsonConvert.SerializeObject(reqObj));
  916. Log.Debug("[KFTC-API-REQ] transfer/result : [customerId]:" + customerId + " [REQ DATA]:" + JsonConvert.SerializeObject(reqObj));
  917. Response.deposit resObj = new Response.deposit();
  918. var gme = _repo.GetGMEMaster();
  919. if (gme == null)
  920. {
  921. resObj.rsp_code = "999";
  922. resObj.rsp_message = "[transfer/result] Failed to bring GME token";
  923. _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message);
  924. return resObj;
  925. }
  926. var gmeAccessToken = gme["accessToken"].ToString();
  927. KFTCPostGet kftcRequest = new KFTCPostGet();
  928. var resData = kftcRequest.PostToKFTC(url, gmeAccessToken, reqData);
  929. if (string.IsNullOrEmpty(resData))
  930. {
  931. resObj.rsp_code = "999";
  932. resObj.rsp_message = "[transfer/result] Failed to Open-banking transfer/result";
  933. _repo.LogResponseKFTC(_logResp.Id, null, resObj.rsp_code, resObj.rsp_message);
  934. return resObj;
  935. }
  936. resObj = JsonConvert.DeserializeObject<Response.deposit>(resData);
  937. //log response
  938. _repo.LogResponseKFTC(_logResp.Id, resData, resObj.rsp_code, resObj.rsp_message);
  939. Log.Debug("[KFTC-API-RES] transfer/result : " + resData);
  940. return resObj;
  941. }
  942. public JsonRxResponse GetKFTCBankList()
  943. {
  944. JsonRxResponse jsonRx = new JsonRxResponse();
  945. List<BankInformation> listBank = new List<BankInformation>();
  946. try
  947. {
  948. Log.DebugFormat("GetKFTCBankList | Calling GetKFTCBankList");
  949. var dt = _repo.GetKftcBankList();
  950. if (dt == null || dt.Rows.Count <= 0)
  951. {
  952. Log.Debug("GetKFTCBankList | Returning null while calling the GetKFTCBankList.");
  953. jsonRx.SetResponse("1", "Could not fetch the exrate data.");
  954. return jsonRx;
  955. }
  956. foreach (DataRow row in dt.Rows)
  957. {
  958. BankInformation bank = new BankInformation();
  959. bank.RowId = row["rowId"].ToString();
  960. bank.BankCode = row["bankCode"].ToString();
  961. bank.BankName = row["bankName"].ToString();
  962. listBank.Add(bank);
  963. }
  964. jsonRx.SetResponse("0", "Success");
  965. jsonRx.Data = listBank;
  966. Log.Debug("GetKFTCBankList | Calling GetKFTCBankList Success...");
  967. return jsonRx;
  968. }
  969. catch (Exception ex)
  970. {
  971. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  972. jsonRx.SetResponse("1", "Could not fetch the GetKFTCBankList details.");
  973. return jsonRx;
  974. }
  975. }
  976. public JsonRxResponse KFTC_RealNameCheck_V2(CheckRealNameModel model)
  977. {
  978. JsonRxResponse jsonRx = new JsonRxResponse();
  979. DbResult _dbRes = new DbResult();
  980. DbResult _logResp = new DbResult();
  981. KFTCPostGet kftcRequest = new KFTCPostGet();
  982. bool isSuccess = false;
  983. string saveIdNumber = "";
  984. var reqRealNameObj = new Common.KFTC.Request.real_name();
  985. // KFTC Open Banking 2019.10 @Dana // Disable string httpUrl =
  986. // ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name";
  987. var gme = _repo.GetGMEMaster();
  988. if (gme == null)
  989. {
  990. jsonRx.SetResponse("1", "Failed to bring GME token.", null);
  991. return jsonRx;
  992. }
  993. var gmeAccessToken = gme["accessToken"].ToString();
  994. var customer = _repo.GetCustomerMaster(model.CustomerId);
  995. if (customer == null)
  996. {
  997. jsonRx.SetResponse("1", "Failed to bring customer information.", null);
  998. return jsonRx;
  999. }
  1000. var kcm = _repo.GetRealNameCheck(model.CustomerId);
  1001. if (kcm != null)
  1002. {
  1003. // 은행거래 고유번호
  1004. //reqRealNameObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff");
  1005. reqRealNameObj.bank_tran_id = getBankTranId();
  1006. reqRealNameObj.account_holder_info_type = kcm["accHolderInfoType"].ToString();
  1007. reqRealNameObj.account_holder_info = kcm["accHolderInfo"].ToString().Replace("-", "");
  1008. reqRealNameObj.bank_code_std = model.BankCode;
  1009. reqRealNameObj.account_num = model.AccountNumber;
  1010. reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
  1011. isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, gmeAccessToken, model.CustomerId);
  1012. }
  1013. if (isSuccess == false)
  1014. {
  1015. var idType = customer["idType"].ToString();
  1016. var idNumber = customer["idNumber"].ToString().Replace("-", "");
  1017. var dob = customer["dob"].ToString();
  1018. var gender = customer["gender"].ToString();
  1019. var country = customer["country"].ToString();
  1020. var processId = DateTime.Now.Ticks + model.CustomerId;
  1021. int pos = 0;
  1022. for (int j = idNumber.Length - 1; j > 0; j--)
  1023. {
  1024. char ch = idNumber[j];
  1025. if (ch >= 0x30 && ch <= 0x39)
  1026. {
  1027. pos = j;
  1028. break;
  1029. }
  1030. }
  1031. var combNumber = idNumber.Substring(pos - 4, 5);
  1032. string[] idTypes = { "1", "2", "3", "4", "5", "6", "E",
  1033. "1", "2", "3", "4", "5", "6", "E" };
  1034. for (int i = 0; i < 14; i++)
  1035. {
  1036. // 은행거래 고유번호
  1037. //reqRealNameObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff");
  1038. reqRealNameObj.bank_tran_id = getBankTranId();
  1039. reqRealNameObj.bank_code_std = model.BankCode;
  1040. reqRealNameObj.account_num = model.AccountNumber;
  1041. reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
  1042. reqRealNameObj.account_holder_info_type = idTypes[i];
  1043. if (i < 7)
  1044. {
  1045. reqRealNameObj.account_holder_info = idNumber;
  1046. }
  1047. else
  1048. {
  1049. reqRealNameObj.account_holder_info = String.Format("{0}{1}{2}{3}",
  1050. dob,
  1051. gender,
  1052. country,
  1053. combNumber);
  1054. }
  1055. saveIdNumber = reqRealNameObj.account_holder_info.Insert(6, "-");
  1056. isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, gmeAccessToken, model.CustomerId);
  1057. if (isSuccess == true)
  1058. {
  1059. _repo.SetRealNameData(model.CustomerId, reqRealNameObj.account_holder_info_type, saveIdNumber);
  1060. break;
  1061. }
  1062. } // endof for (int i = 0; i < 14; i++)
  1063. }
  1064. if (isSuccess == true)
  1065. {
  1066. jsonRx.SetResponse("0", "Code:A0000, Msg:Success to check the real name of the account.", null);
  1067. }
  1068. else
  1069. {
  1070. jsonRx.SetResponse("1", "Failed to check the real name of the account.", null);
  1071. }
  1072. return jsonRx;
  1073. }
  1074. public bool KFTC_RealNameCheck_Common(Common.KFTC.Request.real_name requestObj, string gmeAccessToken, string customerId)
  1075. {
  1076. KFTCPostGet kftcRequest = new KFTCPostGet();
  1077. DbResult dbResult = new DbResult();
  1078. DbResult logResult = new DbResult();
  1079. var httpUrl = ApplicationConfig.ReadWebConfig("INQUIRY_REALNAME", ""); //@"inquiry/real_name";
  1080. var processId = DateTime.Now.Ticks + customerId;
  1081. bool bRet = false;
  1082. try
  1083. {
  1084. string requestStr = JsonConvert.SerializeObject(requestObj);
  1085. //로그-요청로그(TBL_KFTC_LOG)
  1086. logResult = _repo.LogRequestKFTC(customerId, httpUrl, requestStr, processId);
  1087. Log.Debug("[KFTC-API-REQ] inquiry/real_name : [customerId]:" + customerId + " [REQ DATA]:" + requestStr);
  1088. var responseStr = kftcRequest.PostToKFTC(httpUrl, gmeAccessToken, requestStr);
  1089. /*
  1090. * !!!
  1091. * */
  1092. if (string.IsNullOrEmpty(responseStr))
  1093. {
  1094. dbResult.ResponseCode = "999";
  1095. dbResult.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) RESPONSE IS NULL";
  1096. //로그-결과로그(실 패)
  1097. _repo.LogResponseKFTC(logResult.Id, null, dbResult.ResponseCode, dbResult.Msg);
  1098. return false;
  1099. }
  1100. var responseObj = JsonConvert.DeserializeObject<Response.real_name>(responseStr);
  1101. Log.Debug("[KFTC-API-RES] inquiry/real_name : " + responseStr);
  1102. //응답메시지가 성공일때...
  1103. if (responseObj.rsp_code == "A0000" && responseObj.bank_rsp_code == "000")
  1104. {
  1105. bRet = true;
  1106. dbResult.ResponseCode = "A0000";
  1107. dbResult.Msg = "[SUCCESS] KFTC OPEN-FLATFORM (inquiry/real_name)";
  1108. _repo.LogResponseKFTC(logResult.Id, responseStr, dbResult.ResponseCode, dbResult.Msg);
  1109. }
  1110. else
  1111. {
  1112. if (responseObj.rsp_code != "A0000")
  1113. {
  1114. dbResult.ResponseCode = responseObj.rsp_code;
  1115. dbResult.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) rsp_message:{0}",
  1116. responseObj.rsp_message);
  1117. }
  1118. else if (responseObj.bank_rsp_code != "000")
  1119. {
  1120. dbResult.ResponseCode = responseObj.bank_rsp_code;
  1121. dbResult.Msg = String.Format("[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name) bank_rsp_message:{0}",
  1122. responseObj.bank_rsp_message);
  1123. }
  1124. else
  1125. {
  1126. dbResult.ResponseCode = responseObj.rsp_code;
  1127. dbResult.Msg = "[FAIL] KFTC OPEN-FLATFORM (inquiry/real_name)";
  1128. }
  1129. // 로그-응답로그
  1130. _repo.LogResponseKFTC(logResult.Id, responseStr, dbResult.ResponseCode, dbResult.Msg);
  1131. }
  1132. }
  1133. catch (Exception ex)
  1134. {
  1135. //로그-응답로그
  1136. _repo.LogResponseKFTC(logResult.Id, "Exception Error", "999", ex.Message);
  1137. return false;
  1138. }
  1139. return bRet;
  1140. }
  1141. /*
  1142. * Manual token refresh
  1143. * */
  1144. public JsonRxResponse CheckKFTCAccounts(string customerId, string lang, string client_id)
  1145. {
  1146. JsonRxResponse res = new JsonRxResponse();
  1147. try
  1148. {
  1149. string URL = GetUrl_AuthorizeAccounts(customerId, lang, client_id);
  1150. List<AccountDetails> AccountList = GetAccountList(customerId);
  1151. AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
  1152. List<Header> ListLangauge = GetKftcLanguage(customerId);
  1153. List<Header> ListHeader = GetKftcHeader(customerId);
  1154. KftcCommonResponse Response = new KftcCommonResponse()
  1155. {
  1156. AccountList = AccountList,
  1157. Header = ListHeader,
  1158. URL = URL,
  1159. Language = ListLangauge
  1160. };
  1161. res.ErrorCode = "0";
  1162. res.Msg = "Success";
  1163. res.Data = Response;
  1164. return res;
  1165. }
  1166. catch (Exception ex)
  1167. {
  1168. Log.Error("Exception tracked : " + ex.Message, ex);
  1169. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  1170. res.Data = new { };
  1171. return res;
  1172. }
  1173. }
  1174. /* Open Banking 2019.10 Dana */
  1175. private string GetUrl_AuthorizeAccounts(string customerId, string lang, string client_id)
  1176. {
  1177. var custId = "mobile_" + customerId;
  1178. Guid g = Guid.NewGuid();
  1179. string stateValue = g.ToString().Replace("-", "");
  1180. var auth = new Common.KFTC.Request.authorize_account();
  1181. auth.response_type = "code";
  1182. auth.client_id = client_id;
  1183. auth.redirect_uri = KFTC_GME.callback_url;
  1184. auth.scope = "login inquiry transfer";
  1185. auth.client_info = custId;
  1186. auth.state = stateValue; //using Open banking 2019.10 @Dana
  1187. auth.auth_type = "1";
  1188. auth.bg_color = "#F4F8FB";
  1189. auth.txt_color = "#000000";
  1190. auth.btn1_color = "#EF343B";
  1191. auth.btn2_color = "#22246B";
  1192. //auth.lang = lang;
  1193. auth.edit_option = "off";
  1194. auth.invoke_type = "ajax";
  1195. string _URL = @"oauth/2.0/authorize_account?@query"; //using Open banking 2019.10 @Dana
  1196. var jObj = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(auth));
  1197. var query = String.Join("&", jObj.Children().Cast<JProperty>().Select(jp => jp.Name.Equals("redirect_uri") ? jp.Name +
  1198. "=" + (jp.Value.ToString()) : jp.Name + "=" + HttpUtility.UrlEncode(jp.Value.ToString())));
  1199. return ApplicationConfig.ReadWebConfig("KFTC_HOST_NAME", "") + _URL.Replace("@query", query);
  1200. }
  1201. /* 2019.09 Dana */
  1202. public JsonRxResponse CheckBalance(CheckBalanceModel model) // CustomerId Type FintechUseNo
  1203. {
  1204. JsonRxResponse res = new JsonRxResponse();
  1205. DbResult _logResp = new DbResult();
  1206. if (model.Type == "wallet") // wallet일때
  1207. {
  1208. DbResult _resp = new DbResult();
  1209. _resp = _repo.GetUserEmail(model.CustomerId);
  1210. if (_resp.Id == null)
  1211. {
  1212. res.ErrorCode = "1";
  1213. res.Msg = "FAILED TO Load UserId";
  1214. return res;
  1215. }
  1216. var bal = _sendrepo.GetCurrentBalance(_resp.Id);
  1217. if (bal != null)
  1218. {
  1219. Response.balance walletBalance = new Response.balance();
  1220. walletBalance.balance_amt = bal;
  1221. res.ErrorCode = "0";
  1222. res.Msg = "Success";
  1223. res.Data = walletBalance;
  1224. return res;
  1225. }
  1226. else
  1227. {
  1228. res.ErrorCode = "1";
  1229. res.Msg = "FAILED TO Load Wallet Balance";
  1230. return res;
  1231. }
  1232. }
  1233. else //은행계좌라면 API호출해서 잔액조회
  1234. {
  1235. var customerDetail = _repo.GetAccountList(model.CustomerId);
  1236. var accessToken = customerDetail.Rows[0]["access_token"].ToString();
  1237. //accessToken = "b37d092c-6912-42d8-9876-d13eb23e55ad";
  1238. string url = @"v2.0/account/balance/fin_num?bank_tran_id=@bankId&fintech_use_num=@finnum&tran_dtime=@time";
  1239. string bankId = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호
  1240. string requestTime = DateTime.Now.ToString("yyyyMMddHHmmss");
  1241. try
  1242. {
  1243. KFTCPostGet kftcRequest = new KFTCPostGet();
  1244. url = url.Replace("@bankId", bankId).Replace("@finnum", model.FintechUseNo).Replace("@time", requestTime);
  1245. var balanceResult = kftcRequest.GetFromKFTC(url, accessToken);
  1246. _logResp = _repo.LogRequestKFTC(model.CustomerId, "account/balance", "URL: " + url + "access_token: " + accessToken, "");
  1247. Log.Debug("[KFTC-API-REQ] account/balance : [customerId]:" + model.CustomerId + " [REQ URL]:" + url);
  1248. /* 잔액조회 실패 Check Balance fail */
  1249. if (string.IsNullOrEmpty(balanceResult))
  1250. {
  1251. res.ErrorCode = "1";
  1252. res.Msg = "FAILED TO KFTC OPEN-FLATFORM (Account/Balance) QUERY!";
  1253. _repo.LogResponseKFTC(_logResp.Id, null, res.ErrorCode, res.Msg);
  1254. return res;
  1255. }
  1256. var respObj = JsonConvert.DeserializeObject<Response.balance>(balanceResult);
  1257. Log.Debug("[KFTC-API-RES] account/balance : " + balanceResult);
  1258. if (respObj.rsp_code == "A0000")
  1259. {
  1260. res.ErrorCode = "0";
  1261. res.Msg = "Success";
  1262. res.Data = JsonConvert.DeserializeObject(balanceResult);
  1263. _repo.LogResponseKFTC(_logResp.Id, balanceResult, respObj.rsp_code, respObj.rsp_message);
  1264. return res;
  1265. }
  1266. else
  1267. {
  1268. res.ErrorCode = "1";
  1269. res.Msg = respObj.rsp_message;
  1270. _repo.LogResponseKFTC(_logResp.Id, balanceResult, respObj.rsp_code, respObj.rsp_message);
  1271. return res;
  1272. }
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. Log.Error("Exception tracked : " + ex.Message, ex);
  1277. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  1278. _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message);
  1279. return res;
  1280. }
  1281. }
  1282. }
  1283. /* 2019.09 Dana */
  1284. public JsonRxResponse DomeRemitStart(string customerId)
  1285. {
  1286. JsonRxResponse res = new JsonRxResponse();
  1287. DbResult _resp = new DbResult();
  1288. _resp = _repo.GetKFTCServiceFee("DomesticRemittance", "KFTC"); //KFTC service fee
  1289. if (_resp.Id == null)
  1290. {
  1291. res.ErrorCode = "1";
  1292. res.Msg = "FAILED TO Load Service Fee.";
  1293. return res;
  1294. }
  1295. DbResult _resp2 = new DbResult();
  1296. _resp2 = _repo.GetKFTCServiceFee("DomesticRemittance", "KJWallet"); //Wallet service fee
  1297. if (_resp2.Id == null)
  1298. {
  1299. res.ErrorCode = "1";
  1300. res.Msg = "FAILED TO Load Service Fee.";
  1301. return res;
  1302. }
  1303. List<AccountDetails> accountsData = _repo.GetWalletAccountList(customerId);
  1304. if (accountsData == null) // Account가 없으면 Fail
  1305. {
  1306. res.ErrorCode = "1";
  1307. res.Msg = "FAILED TO Load Account List.";
  1308. return res;
  1309. }
  1310. accountsData.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
  1311. List<BankInformation> bankData = new List<BankInformation>();
  1312. var dt = _repo.GetKftcBankList();
  1313. if (dt == null || dt.Rows.Count <= 0) //BankList가 없으면 Fail
  1314. {
  1315. res.ErrorCode = "1";
  1316. res.Msg = "FAILED TO KFTC Bank List.";
  1317. return res;
  1318. }
  1319. foreach (DataRow row in dt.Rows)
  1320. {
  1321. BankInformation bank = new BankInformation();
  1322. bank.RowId = row["rowId"].ToString();
  1323. bank.BankCode = row["bankCode"].ToString();
  1324. bank.BankName = row["bankName"].ToString();
  1325. bankData.Add(bank);
  1326. }
  1327. Response.dome_default body = new Response.dome_default()
  1328. {
  1329. accounts = accountsData,
  1330. banks = bankData,
  1331. servicefee = _resp.Id,
  1332. servicefee_wallet = _resp2.Id
  1333. };
  1334. res.ErrorCode = "0";
  1335. res.Msg = "Success";
  1336. res.Data = body;
  1337. return res;
  1338. }
  1339. public JsonRxResponse GetRecentHistories(RecentHistoryModel model)
  1340. {
  1341. JsonRxResponse res = new JsonRxResponse();
  1342. List<Response.RecentHistory> historyData = new List<Response.RecentHistory>();
  1343. var dt = _repo.GetRecentHistories(model);
  1344. if (dt == null || dt.Rows.Count <= 0) //Recent History가 없는 경우
  1345. {
  1346. res.ErrorCode = "0";
  1347. res.Msg = "0 Recent Histories txn.";
  1348. res.Data = historyData;
  1349. return res;
  1350. }
  1351. foreach (DataRow row in dt.Rows)
  1352. {
  1353. Response.RecentHistory hisData = new Response.RecentHistory();
  1354. BankInformation bankDate = new BankInformation();
  1355. bankDate.RowId = row["rowId"].ToString();
  1356. bankDate.BankCode = row["bankCode"].ToString();
  1357. bankDate.BankName = row["bankName"].ToString();
  1358. hisData.bank = bankDate;
  1359. hisData.recipient_account = row["recipient_account"].ToString();
  1360. hisData.recipient_name = row["recipient_name"].ToString();
  1361. historyData.Add(hisData);
  1362. }
  1363. res.ErrorCode = "0";
  1364. res.Msg = "Success";
  1365. res.Data = historyData;
  1366. return res;
  1367. }
  1368. /* 2019.09 Dana */
  1369. public JsonRxResponse GetRecipientInfo(CheckRealNameModel model) // customerId BankCode AccountNumber
  1370. {
  1371. JsonRxResponse res = new JsonRxResponse();
  1372. Response.recipientInfo info = new Response.recipientInfo();
  1373. DbResult _resp = new DbResult();
  1374. var resp = KwangjuBankApi.BankAccountName(model.BankCode, model.AccountNumber); //광주은행 API를 이용하여 계좌주명 추출
  1375. if (resp == null)
  1376. {
  1377. res.ErrorCode = "1";
  1378. res.Msg = "Please Check Recipient Bank Account.";
  1379. return res;
  1380. }
  1381. var dbApiRes = JsonConvert.DeserializeObject<JsonRxResponse>(resp);
  1382. if (dbApiRes.ErrorCode != "0")
  1383. {
  1384. res.ErrorCode = "1";
  1385. res.Msg = "Please Check Recipient Bank Account.";
  1386. return res;
  1387. }
  1388. else
  1389. {
  1390. info.RecipientName = dbApiRes.Msg;
  1391. _resp = _repo.GetRecipientMobileNo(model); //Recipient MobileNo 추출
  1392. info.RecipientPhone = _resp.Id;
  1393. res.ErrorCode = "0";
  1394. res.Msg = "Success";
  1395. res.Data = info;
  1396. return res;
  1397. }
  1398. }
  1399. /* * ------------------------------------
  1400. * Domestic Remittance 2019.09 Dana
  1401. * ------------------------------------
  1402. * */
  1403. public JsonRxResponse SendDomeRimit(DomesticRemitModel model)
  1404. {
  1405. JsonRxResponse JsonRx = new JsonRxResponse
  1406. {
  1407. ErrorCode = "1",
  1408. Msg = "Domestic Remittance Request cannot proceed further. Please contact GME head office."
  1409. };
  1410. DbResult _resp = new DbResult();
  1411. DbResult _serviceResp = new DbResult();
  1412. Response.domesticTran domeTran = new Response.domesticTran();
  1413. //model.RecipientName = "(주)글로벌머니익스프레스입니다.";
  1414. string customerName = "";
  1415. string customerBankCode = "034";
  1416. string customerAccountNo = "";
  1417. if (model.type == "wallet")
  1418. {
  1419. _serviceResp = _repo.GetKFTCServiceFee("DomesticRemittance", "KJWallet"); //service fee
  1420. if (_serviceResp.Id == null)
  1421. {
  1422. JsonRx.ErrorCode = "1";
  1423. JsonRx.Msg = "FAILED TO Load Service Fee.";
  1424. return JsonRx;
  1425. }
  1426. model.ServiceFee = _serviceResp.Id;
  1427. var customerDetail = _repo.GetGMECustomerList(model.CustomerId);
  1428. customerName = customerDetail.Rows[0]["fullName"].ToString();
  1429. customerAccountNo = customerDetail.Rows[0]["walletAccountNo"].ToString();
  1430. model.SetSenderData(customerName, customerBankCode, customerAccountNo);
  1431. //var processId = "";
  1432. // Domestic request log
  1433. //DomesticHistoryModel historyModel = new DomesticHistoryModel();
  1434. //historyModel.SetWalletHistoryData(model);
  1435. //_resp = _repo.requestKFTCDomesticHistory(historyModel);
  1436. //processId = _resp.Id;
  1437. JsonRxResponse wallet_result = SendDomeRimit_wallet_withdraw(model);
  1438. if (wallet_result.ErrorCode == "0")
  1439. {
  1440. domeTran.CustomerId = model.CustomerId;
  1441. domeTran.TranNo = wallet_result.Id;
  1442. //성공메세지
  1443. JsonRx.ErrorCode = "0";
  1444. JsonRx.Msg = "Success";
  1445. JsonRx.Data = domeTran;
  1446. return JsonRx;
  1447. }
  1448. else
  1449. {
  1450. JsonRx.ErrorCode = "1";
  1451. JsonRx.Msg = wallet_result.Msg;
  1452. return JsonRx;
  1453. }
  1454. }
  1455. else if (model.type == "autodebit")
  1456. {
  1457. _serviceResp = _repo.GetKFTCServiceFee("DomesticRemittance", "KFTC"); //service fee
  1458. if (_serviceResp.Id == null)
  1459. {
  1460. JsonRx.ErrorCode = "1";
  1461. JsonRx.Msg = "FAILED TO Load Service Fee.";
  1462. return JsonRx;
  1463. }
  1464. model.ServiceFee = _serviceResp.Id; // service fee
  1465. var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo);
  1466. if (customerDetail == null)
  1467. {
  1468. JsonRx.ErrorCode = "1";
  1469. JsonRx.Msg = "FAILED TO Sender's Account Information.";
  1470. return JsonRx;
  1471. }
  1472. customerName = customerDetail["accountName"].ToString();
  1473. customerBankCode = customerDetail["bankCodeStd"].ToString();
  1474. customerAccountNo = customerDetail["accountNum"].ToString();
  1475. model.SetSenderData(customerName, customerBankCode, customerAccountNo);
  1476. //출금이체
  1477. var withdraw_result = SendDomeRimit_withdraw(model);
  1478. if (withdraw_result.ErrorCode == "0") // 출금 성공 -> 입금시도 withdraw success -> deposit
  1479. {
  1480. //입금이체
  1481. var deposit_result = SendDomeRimit_deposit(model);
  1482. if (deposit_result.ErrorCode == "0")
  1483. {
  1484. //voucher already splited
  1485. //국내이체에 전체성공하면 core table에 데이터생성하는 프로시저 실행
  1486. //_repo.startPushFromDomestit(model.processId);
  1487. domeTran.CustomerId = model.CustomerId;
  1488. domeTran.TranNo = model.processId;
  1489. //성공메세지
  1490. JsonRx.ErrorCode = "0";
  1491. JsonRx.Msg = "Success";
  1492. JsonRx.Data = domeTran;
  1493. return JsonRx;
  1494. }
  1495. //else
  1496. //{
  1497. // //출금 원복
  1498. // //request log
  1499. // //_resp = _repo.requestKFTCDomesticHistory(model, processId, "refund");
  1500. // JsonRx.ErrorCode = "1"; // refund 성공여부와 관계없이 무조건 에러표시(입금이체가 실패했으므로) var
  1501. // rejec_result = SendDomeRimit_refund(model); if (rejec_result.ErrorCode ==
  1502. // "0") JsonRx.Msg = deposit_result.Msg;//입금에러메세지 else JsonRx.Msg =
  1503. // rejec_result.Msg; //만약 원복도 실패하면 원복실패 에러메세지를 보여줌
  1504. // return JsonRx;
  1505. //}
  1506. }
  1507. else// 출금 실패 withdraw success fail
  1508. {
  1509. JsonRx = withdraw_result;
  1510. return JsonRx;
  1511. }
  1512. }
  1513. return JsonRx;
  1514. }
  1515. /* * ------------------------------------------------------------------------
  1516. * Domestic Remittance autobebit API호출 2019.09 Dana
  1517. * ------------------------------------------------------------------------
  1518. * */
  1519. public JsonRxResponse SendDomeRimit_withdraw(DomesticRemitModel model)
  1520. {
  1521. DbResult _logResp = new DbResult();
  1522. JsonRxResponse jsonResponse = new JsonRxResponse();
  1523. DbResult _resp = new DbResult();
  1524. //1.KFTC_DOMESTIC_HISTORY insert (실계좌-withdraw)
  1525. DomesticHistoryModel withdrawModel = new DomesticHistoryModel();
  1526. withdrawModel.SetWithdrawData(model);
  1527. _resp = _repo.requestKFTCDomesticHistory(withdrawModel);
  1528. model.processId = _resp.Id;
  1529. model.transferType = "withdraw";
  1530. //2.KFTC 출금이체 API 실행
  1531. jsonResponse = KftcTransferWithdraw(model);
  1532. jsonResponse.Id = model.processId;
  1533. if (jsonResponse.ErrorCode == "0")
  1534. {
  1535. //3.KFTC_DOMESTIC_HISTORY update(실계좌-withdraw)
  1536. var respObj_withdraw = JsonConvert.DeserializeObject<Response.withdraw>(jsonResponse.Extra);
  1537. _repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, model);
  1538. }
  1539. else
  1540. {
  1541. //3.KFTC_DOMESTIC_HISTORY update(실계좌-withdraw)
  1542. if (string.IsNullOrEmpty(jsonResponse.Extra) == true)
  1543. {
  1544. _repo.responseKFTCDomesticHistory_withdraw(null, model);
  1545. }
  1546. else
  1547. {
  1548. var respObj_withdraw = JsonConvert.DeserializeObject<Response.withdraw>(jsonResponse.Extra);
  1549. _repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, model);
  1550. }
  1551. }
  1552. return jsonResponse;
  1553. }
  1554. public JsonRxResponse KftcTransferWithdraw(DomesticRemitModel model)
  1555. {
  1556. JsonRxResponse jsonResponse = new JsonRxResponse();
  1557. DbResult logResult = new DbResult();
  1558. KFTCPostGet kftcRequest_withdraw = new KFTCPostGet();
  1559. //var gme = _repo.GetGMEMaster();
  1560. //if (gme == null)
  1561. //{
  1562. // jsonResponse.SetResponse("1", "Failed to bring GME token.", null);
  1563. // return jsonResponse;
  1564. //}
  1565. //var gmeAccessToken = gme["accessToken"].ToString();
  1566. var accessTokenTemplate = _repo.GetAccountList(model.CustomerId);
  1567. var accessToken = accessTokenTemplate.Rows[0]["access_token"].ToString();
  1568. var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo);
  1569. if (customerDetail == null)
  1570. {
  1571. jsonResponse.SetResponse("1", "Failed to bring customer account number.", null);
  1572. return jsonResponse;
  1573. }
  1574. var amt = (Convert.ToDecimal(model.SentAmount) + Convert.ToDecimal(model.ServiceFee)).ToString();
  1575. var withdrawObj = new Common.KFTC.Request.withdraw();
  1576. withdrawObj.bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"); // 은행거래 고유번호
  1577. withdrawObj.cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", "");
  1578. withdrawObj.cntr_account_num = ApplicationConfig.ReadWebConfig("GME_WITHDRAW_ACCNO", "");
  1579. //withdrawObj.dps_print_content = lengSubstring(10, "D_" + model.RecipientName); //입금계좌 인자내역
  1580. withdrawObj.dps_print_content = lengSubstring(10, "D_" + model.senderName); //입금계좌 인자내역
  1581. withdrawObj.fintech_use_num = model.FintechUseNo; //출금계좌 핀테크번호
  1582. withdrawObj.tran_amt = amt; //거래금액
  1583. withdrawObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"); //요청일시
  1584. withdrawObj.req_client_name = customerDetail["accountName"].ToString();
  1585. withdrawObj.req_client_bank_code = customerDetail["bankCodeStd"].ToString();
  1586. withdrawObj.req_client_account_num = customerDetail["accountNum"].ToString();
  1587. withdrawObj.req_client_num = model.CustomerId;
  1588. withdrawObj.transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "");
  1589. string withdraw_url = ApplicationConfig.ReadWebConfig("TRANSFER_WITHDRAW", "");
  1590. string withdrawData = JsonConvert.SerializeObject(withdrawObj);
  1591. logResult = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/withdraw", "access_token :" + accessToken + "req :" + withdrawData);
  1592. Log.Debug("[KFTC-API-REQ] transfer/withdraw : [customerId]:" + model.CustomerId + " [REQ DATA]:" + withdrawData);
  1593. var result_withdraw = kftcRequest_withdraw.PostToKFTC(withdraw_url, accessToken, withdrawData);
  1594. /* 출금 실패 withdraw fail */
  1595. if (string.IsNullOrEmpty(result_withdraw))
  1596. {
  1597. jsonResponse.ErrorCode = "1";
  1598. jsonResponse.Msg = "FAILED TO KFTC OPEN-FLATFORM (transfer/withdraw) QUERY!";
  1599. _repo.LogResponseKFTC(logResult.Id, null, jsonResponse.ErrorCode, jsonResponse.Msg);
  1600. return jsonResponse;
  1601. }
  1602. var respObj_withdraw = JsonConvert.DeserializeObject<Response.withdraw>(result_withdraw);
  1603. Log.Debug("[KFTC-API-RES] transfer/withdraw : " + result_withdraw);
  1604. if (respObj_withdraw.rsp_code == "A0001" ||
  1605. respObj_withdraw.rsp_code == "A0003" ||
  1606. respObj_withdraw.rsp_code == "A0007" ||
  1607. respObj_withdraw.bank_rsp_code == "400")
  1608. {
  1609. Thread.Sleep(1 * 60 * 1000);
  1610. /* 이체결과확인 */
  1611. respObj_withdraw = CheckWithdrawResult(ref respObj_withdraw, model.CustomerId, "1");
  1612. //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId);
  1613. if (respObj_withdraw.rsp_code == "A0001" ||
  1614. respObj_withdraw.rsp_code == "A0003" ||
  1615. respObj_withdraw.rsp_code == "A0007" ||
  1616. respObj_withdraw.bank_rsp_code == "400")
  1617. {
  1618. Thread.Sleep(2 * 60 * 1000);
  1619. /* 이체결과확인 */
  1620. respObj_withdraw = CheckWithdrawResult(ref respObj_withdraw, model.CustomerId, "2");
  1621. //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId);
  1622. if (respObj_withdraw.rsp_code == "A0001" ||
  1623. respObj_withdraw.rsp_code == "A0003" ||
  1624. respObj_withdraw.rsp_code == "A0007" ||
  1625. respObj_withdraw.bank_rsp_code == "400")
  1626. {
  1627. jsonResponse.ErrorCode = "1";
  1628. jsonResponse.Msg = respObj_withdraw.rsp_message;
  1629. jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw);
  1630. _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message);
  1631. //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log
  1632. return jsonResponse;
  1633. }
  1634. }
  1635. }
  1636. if (respObj_withdraw.rsp_code == "A0000")
  1637. {
  1638. jsonResponse.ErrorCode = "0";
  1639. jsonResponse.Msg = "Success";
  1640. jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw);
  1641. _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message);
  1642. //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log
  1643. return jsonResponse;
  1644. }
  1645. else
  1646. {
  1647. jsonResponse.ErrorCode = "1";
  1648. jsonResponse.Msg = respObj_withdraw.rsp_message;
  1649. jsonResponse.Extra = JsonConvert.SerializeObject(respObj_withdraw);
  1650. _repo.LogResponseKFTC(logResult.Id, result_withdraw, respObj_withdraw.rsp_code, respObj_withdraw.rsp_message);
  1651. //_repo.responseKFTCDomesticHistory_withdraw(respObj_withdraw, processId, model.CustomerId); // Domestic 출금이체 response log
  1652. return jsonResponse;
  1653. }
  1654. }
  1655. /* * ------------------------------------------------------------------------
  1656. * Domestic Remittance autobebit API호출 2019.09 Dana
  1657. * ------------------------------------------------------------------------
  1658. * */
  1659. public JsonRxResponse SendDomeRimit_deposit(DomesticRemitModel model)
  1660. {
  1661. JsonRxResponse jsonResponse = new JsonRxResponse();
  1662. DbResult _resp = new DbResult();
  1663. //1.KFTC_DOMESTIC_HISTORY insert (실계좌-withdraw)
  1664. DomesticHistoryModel depositModel = new DomesticHistoryModel();
  1665. depositModel.SetDepositData(model);
  1666. _resp = _repo.requestKFTCDomesticHistory(depositModel);
  1667. //2.KFTC 입금이체 API실행
  1668. model.transferType = "deposit";
  1669. jsonResponse = KftcTransferDeposit(model);
  1670. jsonResponse.Id = model.processId;
  1671. if (jsonResponse.ErrorCode == "0")
  1672. {
  1673. //3.KJ_AUTO_REFUND update
  1674. KJAutoRefundModel kjModel = new KJAutoRefundModel();
  1675. kjModel.SetDepositData("Domestic", "SUCCESS", model);
  1676. _resp = _repo.SendAutoRefund(kjModel);
  1677. //4.KFTC_DOMESTIC_HISTORY update(실계좌-deposit)
  1678. var depositObj = JsonConvert.DeserializeObject<Response.deposit>(jsonResponse.Extra);
  1679. _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model);
  1680. }
  1681. else
  1682. {
  1683. //3.KJ_AUTO_REFUND update
  1684. KJAutoRefundModel kjModel = new KJAutoRefundModel();
  1685. kjModel.SetDepositData("Domestic", "FAIL", model);
  1686. _resp = _repo.SendAutoRefund(kjModel);
  1687. //4.KFTC_DOMESTIC_HISTORY update(실계좌-depoit)
  1688. if (string.IsNullOrEmpty(jsonResponse.Extra) == true)
  1689. {
  1690. _repo.responseKFTCDomesticHistory_DepositRefund(null, model);
  1691. }
  1692. else
  1693. {
  1694. var depositObj = JsonConvert.DeserializeObject<Response.deposit>(jsonResponse.Extra);
  1695. _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model);
  1696. }
  1697. }
  1698. return jsonResponse;
  1699. }
  1700. public JsonRxResponse KftcTransferDeposit(DomesticRemitModel model)
  1701. {
  1702. JsonRxResponse jsonResponse = new JsonRxResponse();
  1703. DbResult logResult = new DbResult();
  1704. KFTCPostGet kftcRequest = new KFTCPostGet();
  1705. var gme = _repo.GetGMEMaster();
  1706. if (gme == null)
  1707. {
  1708. jsonResponse.SetResponse("1", "Failed to bring GME token.", null);
  1709. return jsonResponse;
  1710. }
  1711. var gmeAccessToken = gme["accessToken"].ToString();
  1712. //string customerName = "";
  1713. //string customerBankCode = "034";
  1714. //string customerAccountNo = "";
  1715. //if(model.type=="wallet")
  1716. //{
  1717. // var customerDetail = _repo.GetGMECustomerList(model.CustomerId);
  1718. // customerName = customerDetail.Rows[0]["fullName"].ToString();
  1719. // customerAccountNo = customerDetail.Rows[0]["walletAccountNo"].ToString();
  1720. //}
  1721. //else if(model.type=="autodebit")
  1722. //{
  1723. // var customerDetail = _repo.GetKFTCAccountInfo(model.CustomerId, model.FintechUseNo);
  1724. // if (customerDetail == null)
  1725. // {
  1726. // jsonResponse.SetResponse("1", "Failed to bring customer account number.", null);
  1727. // return jsonResponse;
  1728. // }
  1729. // customerName = customerDetail["accountName"].ToString();
  1730. // customerBankCode = customerDetail["bankCodeStd"].ToString();
  1731. // customerAccountNo = customerDetail["accountNum"].ToString();
  1732. //}
  1733. Request.deposit deposit_req = new Request.deposit()
  1734. {
  1735. cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""),
  1736. cntr_account_num = ApplicationConfig.ReadWebConfig("GME_DEPOSIT_ACCNO", ""),
  1737. wd_pass_phrase = ApplicationConfig.ReadWebConfig("pass_phrase", ""), // "입금이체용 암호문구";
  1738. wd_print_content = lengSubstring(10, "D_" + model.senderName),//출금계좌인자내역(GME통장내역)
  1739. name_check_option = "off",
  1740. req_cnt = "1",
  1741. tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"),
  1742. req_list = new List<Request.bank_account>()
  1743. };
  1744. var tranAmt = (model.transferType == "refund") ? (Convert.ToDecimal(model.SentAmount) + Convert.ToDecimal(model.ServiceFee)).ToString() : model.SentAmount;
  1745. Request.bank_account bank = new Request.bank_account()
  1746. {
  1747. bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"), // 은행거래 고유번호
  1748. tran_no = "1",
  1749. bank_code_std = model.RecipientBankCode,//입금은행코드
  1750. account_num = model.RecipientAccountNo,//입금계좌번호
  1751. account_holder_name = lengSubstring(10, model.RecipientName),//입금계좌 예금주명
  1752. print_content = lengSubstring(10, model.senderName),//입금계좌인자내역
  1753. tran_amt = tranAmt, //입금금액
  1754. req_client_name = lengSubstring(10, model.senderName),
  1755. req_client_bank_code = model.senderBankCode,
  1756. req_client_account_num = model.senderAccountNo,
  1757. req_client_num = model.CustomerId,
  1758. transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "")
  1759. };
  1760. deposit_req.req_list.Add(bank);
  1761. var deposit_body = JsonConvert.SerializeObject(deposit_req);
  1762. /* KFTC 입금 API 호출 TRANSFER/DEPOSIT start */
  1763. try
  1764. {
  1765. string deposit_url = @"v2.0/transfer/deposit/acnt_num";
  1766. logResult = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/deposit", "access_token :" + gmeAccessToken + "req :" + deposit_body);
  1767. Log.Debug("[KFTC-API-REQ] transfer/deposit : [customerId]:" + model.CustomerId + " [REQ DATA]:" + deposit_body);
  1768. var deposit_result = kftcRequest.PostToKFTC(deposit_url, gmeAccessToken, deposit_body);
  1769. /* 입금이체 요청 실패 TRANSFER/DEPOSIT fail */
  1770. if (string.IsNullOrEmpty(deposit_result))
  1771. {
  1772. jsonResponse.ErrorCode = "1";
  1773. jsonResponse.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/DEPOSIT)!";
  1774. _repo.LogResponseKFTC(logResult.Id, deposit_result, jsonResponse.ErrorCode, jsonResponse.Msg);
  1775. return jsonResponse;
  1776. }
  1777. /* 입금이체 API 결과처리 TRANSFER/DEPOSIT result */
  1778. var objDepositRst = JsonConvert.DeserializeObject<Response.deposit>(deposit_result);
  1779. Log.Debug("[KFTC-API-RES] transfer/deposit : " + deposit_result);
  1780. /* 처리중으로 나오면 결과 재확인 result re-check */
  1781. if (objDepositRst.rsp_code == "A0001" ||
  1782. objDepositRst.rsp_code == "A0003" ||
  1783. objDepositRst.rsp_code == "A0007" ||
  1784. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  1785. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  1786. objDepositRst.res_list[0].bank_rsp_code == "804")
  1787. {
  1788. Thread.Sleep(1 * 60 * 1000);
  1789. /* 이체결과 조회 */
  1790. objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "1");
  1791. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, flag);
  1792. if (objDepositRst.rsp_code == "A0001" ||
  1793. objDepositRst.rsp_code == "A0003" ||
  1794. objDepositRst.rsp_code == "A0007" ||
  1795. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  1796. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  1797. objDepositRst.res_list[0].bank_rsp_code == "804")
  1798. {
  1799. Thread.Sleep(2 * 60 * 1000);
  1800. objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "2");
  1801. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, flag);
  1802. if (objDepositRst.rsp_code == "A0001" ||
  1803. objDepositRst.rsp_code == "A0003" ||
  1804. objDepositRst.rsp_code == "A0007" ||
  1805. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  1806. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  1807. objDepositRst.res_list[0].bank_rsp_code == "804")
  1808. {
  1809. //실패로그 남기기
  1810. jsonResponse.ErrorCode = "1";
  1811. jsonResponse.Msg = objDepositRst.rsp_message;
  1812. jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst);
  1813. _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  1814. return jsonResponse;
  1815. }
  1816. }
  1817. }
  1818. if (objDepositRst.rsp_code == "A0000")
  1819. {
  1820. jsonResponse.ErrorCode = "0";
  1821. jsonResponse.Msg = "Success";
  1822. jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst);
  1823. //jsonResponse.Data = objDepositRst;
  1824. _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  1825. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, flag); // Domestic 입금이체 response log
  1826. //kjModel.action = "SUCCESS";
  1827. //_repo.SendAutoRefund(kjModel);
  1828. return jsonResponse;
  1829. }
  1830. else
  1831. {
  1832. jsonResponse.ErrorCode = "1";
  1833. jsonResponse.Msg = objDepositRst.rsp_message;
  1834. jsonResponse.Extra = JsonConvert.SerializeObject(objDepositRst);
  1835. _repo.LogResponseKFTC(logResult.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  1836. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, flag); // Domestic 입금이체 response log
  1837. //kjModel.action = "FAIL";
  1838. //_repo.SendAutoRefund(kjModel);
  1839. return jsonResponse;
  1840. }
  1841. }
  1842. catch (Exception ex)
  1843. {
  1844. Log.Error("Exception tracked : " + ex.Message, ex);
  1845. jsonResponse.SetResponse("1", "Exception tracked : " + ex.Message, null);
  1846. _repo.LogResponseKFTC(logResult.Id, "Exception occured!", "999", ex.Message);
  1847. //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, flag);
  1848. //kjModel.action = "FAIL";
  1849. //_repo.SendAutoRefund(kjModel);
  1850. return jsonResponse;
  1851. }
  1852. }
  1853. /* * ------------------------------------------------------------------------
  1854. * Domestic Remittance autobebit ()API호출 2019.09 Dana
  1855. * ------------------------------------------------------------------------
  1856. * */
  1857. public JsonRxResponse SendDomeRimit_refund(DomesticRemitModel model)
  1858. {
  1859. JsonRxResponse jsonResponse = new JsonRxResponse();
  1860. DbResult _resp = new DbResult();
  1861. //1.KFTC_DOMESTIC_HISTORY insert (실계좌-refund)
  1862. DomesticHistoryModel refundModel = new DomesticHistoryModel();
  1863. refundModel.SetRefundData(model);
  1864. _resp = _repo.requestKFTCDomesticHistory(refundModel);
  1865. //2.KFTC 입금이체 API실행
  1866. model.transferType = "refund";
  1867. jsonResponse = KftcTransferDeposit(model);
  1868. jsonResponse.Id = model.processId;
  1869. if (jsonResponse.ErrorCode == "0")
  1870. {
  1871. //3.KJ_AUTO_REFUND insert
  1872. KJAutoRefundModel kjModel = new KJAutoRefundModel();
  1873. kjModel.SetRefundData("Domestic", "SUCCESS", model);
  1874. _resp = _repo.SendAutoRefund(kjModel);
  1875. //4.KFTC_DOMESTIC_HISTORY update(실계좌-refund)
  1876. var depositObj = JsonConvert.DeserializeObject<Response.deposit>(jsonResponse.Extra);
  1877. _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model);
  1878. }
  1879. else
  1880. {
  1881. //3.KJ_AUTO_REFUND update
  1882. KJAutoRefundModel kjModel = new KJAutoRefundModel();
  1883. kjModel.SetRefundData("Domestic", "FAIL", model);
  1884. _resp = _repo.SendAutoRefund(kjModel);
  1885. //4.KFTC_DOMESTIC_HISTORY update(실계좌-refund)
  1886. if (string.IsNullOrEmpty(jsonResponse.Extra) == true)
  1887. {
  1888. _repo.responseKFTCDomesticHistory_DepositRefund(null, model);
  1889. }
  1890. else
  1891. {
  1892. var depositObj = JsonConvert.DeserializeObject<Response.deposit>(jsonResponse.Extra);
  1893. _repo.responseKFTCDomesticHistory_DepositRefund(depositObj, model);
  1894. }
  1895. }
  1896. return jsonResponse;
  1897. }
  1898. public Common.Model.DbResult CheckLoginPassword(string user, string txnPassword, string paymentType, string customerId)
  1899. {
  1900. return _repo.CheckLoginPassword(user, txnPassword, paymentType, customerId);
  1901. }
  1902. /* * ------------------------------------------------------------------------
  1903. * Domestic Remittance wallet ( ) 2019.09 Dana
  1904. * ------------------------------------------------------------------------
  1905. * */
  1906. public JsonRxResponse SendDomeRimit_wallet_withdraw(DomesticRemitModel model)
  1907. {
  1908. JsonRxResponse JsonRx = new JsonRxResponse
  1909. {
  1910. ErrorCode = "1",
  1911. Msg = "Domestic Remittance(wallet) Request cannot proceed further. Please contact GME head office."
  1912. };
  1913. DbResult _resp = new DbResult();
  1914. //1.KFTC_DOMESTIC_HISTORY insert (가상계좌-walletwithdraw)
  1915. DomesticHistoryModel historyModel = new DomesticHistoryModel();
  1916. historyModel.SetWalletHistoryData(model);
  1917. _resp = _repo.requestKFTCDomesticHistory(historyModel);
  1918. JsonRx.Id = model.processId = _resp.Id;
  1919. ////2. KFTC_DOMESTIC_HISTORY update(가상계좌-walletwithdraw)
  1920. //Response.withdraw response = new Response.withdraw();//log에 응답 성공 message넣기
  1921. //response.rsp_code = "A0000";
  1922. //_repo.responseKFTCDomesticHistory_withdraw(response, model); // Domestic 출금 response log(API호출이 없으므로 무조건 성공으로)
  1923. //3. KJ_AUTO_REFUND insert (REQ)
  1924. KJAutoRefundModel kjModel = new KJAutoRefundModel();
  1925. kjModel.SetDepositData("DomesticWallet", "REQ", model);
  1926. _resp = _repo.SendAutoRefund(kjModel);
  1927. if (_resp.ResponseCode != "0")
  1928. {
  1929. JsonRx.ErrorCode = "1";
  1930. JsonRx.Msg = "FAIL.Check your Wallet and Wallet Balance.";
  1931. return JsonRx;
  1932. }
  1933. kjModel.rowId = _resp.Id;
  1934. //4. KFTC_DOMESTIC_HISTORY insert(가상계좌-deposit)
  1935. //var GMEcustomerDetail = _repo.GetGMECustomerList(model.CustomerId);
  1936. DomesticHistoryModel depositModel = new DomesticHistoryModel();
  1937. depositModel.SetDepositData(model);
  1938. _repo.requestKFTCDomesticHistory(depositModel);// Domestic 입금이체 request log
  1939. //5. KFTC 입금이체 API 이용 (deposit)
  1940. JsonRxResponse depositResult = new JsonRxResponse();
  1941. model.transferType = "deposit";
  1942. depositResult = KftcTransferDeposit(model);
  1943. //6. KFTC_DOMESTIC_HISTORY update(가상계좌-deposit)
  1944. if (string.IsNullOrEmpty(depositResult.Extra) == true)
  1945. {
  1946. _repo.responseKFTCDomesticHistory_DepositRefund(null, model);
  1947. }
  1948. else
  1949. {
  1950. var respObj = JsonConvert.DeserializeObject<Response.deposit>(depositResult.Extra);
  1951. _repo.responseKFTCDomesticHistory_DepositRefund(respObj, model);
  1952. }
  1953. if (depositResult.ErrorCode != "0")
  1954. {
  1955. //7. KJ_AUTO_REFUND update (FAIL)
  1956. kjModel.SetRefundData("DomesticWallet_FAIL", "FAIL", model);
  1957. _resp = _repo.SendAutoRefund(kjModel);
  1958. //8. KFTC_DOMESTIC_HISTORY Insert(가상계좌-refund)
  1959. DomesticHistoryModel refundModel = new DomesticHistoryModel();
  1960. refundModel.SetRefundData(model);
  1961. _repo.requestKFTCDomesticHistory(refundModel);
  1962. //이건 필요없을것 같다.....
  1963. //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "refund");
  1964. JsonRx.ErrorCode = "1";
  1965. JsonRx.Msg = depositResult.Msg;
  1966. return JsonRx;
  1967. }
  1968. else
  1969. {
  1970. //7. KJ_AUTO_REFUND update (SUCCESS)
  1971. kjModel.SetDepositData("DomesticWallet_SUCC", "SUCCESS", model);
  1972. _resp = _repo.SendAutoRefund(kjModel);
  1973. JsonRx.ErrorCode = "0";
  1974. JsonRx.Msg = "Success";
  1975. return JsonRx;
  1976. }
  1977. }
  1978. /* * ------------------------------------------------------------------------
  1979. * Domestic Remittance wallet (Using KFTC) 2019.09 Dana
  1980. * ------------------------------------------------------------------------
  1981. * */
  1982. public JsonRxResponse SendDomeRimit_wallet_Deposit(DomesticRemitModel model)
  1983. {
  1984. JsonRxResponse res = new JsonRxResponse();
  1985. DbResult _logResp = new DbResult();
  1986. DbResult _resp = new DbResult();
  1987. var gme = _repo.GetGMEMaster();
  1988. if (gme == null)
  1989. {
  1990. res.SetResponse("1", "Failed to bring GME token.", null);
  1991. return res;
  1992. }
  1993. var gmeAccessToken = gme["accessToken"].ToString(); // 입금시에는 GME AccessToken 사용
  1994. /* @Max 수정 */
  1995. //고객의 이름, 가상계좌번호
  1996. var customerDetail = _repo.GetGMECustomerList(model.CustomerId);
  1997. //var customerDetail = _repo.GetAccountList(model.CustomerId);
  1998. Request.deposit deposit_req = new Request.deposit()
  1999. {
  2000. cntr_account_type = ApplicationConfig.ReadWebConfig("CNTR_ACCOUNT_TYPE", ""),
  2001. cntr_account_num = ApplicationConfig.ReadWebConfig("GME_DEPOSIT_ACCNO", ""),
  2002. wd_pass_phrase = ApplicationConfig.ReadWebConfig("pass_phrase", ""), // "입금이체용 암호문구";
  2003. wd_print_content = lengSubstring(10, "D_" + model.RecipientName), //출금계좌인자내역
  2004. name_check_option = "off",
  2005. req_cnt = "1",
  2006. tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss"),
  2007. req_list = new List<Request.bank_account>()
  2008. };
  2009. Request.bank_account bank = new Request.bank_account()
  2010. {
  2011. bank_tran_id = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmssfff"), // 은행거래 고유번호
  2012. tran_no = "1",
  2013. bank_code_std = model.RecipientBankCode,//입금은행코드
  2014. account_num = model.RecipientAccountNo,//입금계좌번호
  2015. account_holder_name = lengSubstring(10, model.RecipientName),//입금계좌 예금주명
  2016. print_content = lengSubstring(10, model.RecipientName),//입금계좌인자내역
  2017. tran_amt = Convert.ToDecimal(model.SentAmount).ToString(), //입금금액
  2018. req_client_name = customerDetail.Rows[0]["fullName"].ToString(),
  2019. req_client_bank_code = "034", //가상은행코드
  2020. req_client_account_num = customerDetail.Rows[0]["walletAccountNo"].ToString(),
  2021. req_client_num = model.CustomerId,
  2022. transfer_purpose = ApplicationConfig.ReadWebConfig("WITHDRAW_TRANSFER_PURPOSE", "") // transfer
  2023. };
  2024. deposit_req.req_list.Add(bank);
  2025. var deposit_body = JsonConvert.SerializeObject(deposit_req);
  2026. /* KFTC 입금 API 호출 TRANSFER/DEPOSIT start */
  2027. try
  2028. {
  2029. KFTCPostGet kftcRequest = new KFTCPostGet();
  2030. string deposit_url = @"v2.0/transfer/deposit/acnt_num";
  2031. var deposit_result = kftcRequest.PostToKFTC(deposit_url, gmeAccessToken, deposit_body);
  2032. _logResp = _repo.LogRequestKFTC(model.CustomerId, "Domestic Remittance/deposit", "access_token :" + gmeAccessToken + "req :" + deposit_body);
  2033. /* 입금이체 요청 실패 TRANSFER/DEPOSIT fail */
  2034. if (string.IsNullOrEmpty(deposit_result))
  2035. {
  2036. res.ErrorCode = "1";
  2037. res.Msg = "FAILED TO KFTC OPEN-FLATFORM (TRANSFER/DEPOSIT)!";
  2038. _repo.LogResponseKFTC(_logResp.Id, deposit_result, res.ErrorCode, res.Msg);
  2039. //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "deposit");
  2040. return res;
  2041. }
  2042. /* 입금이체 API 결과처리 TRANSFER/DEPOSIT result */
  2043. var objDepositRst = JsonConvert.DeserializeObject<Response.deposit>(deposit_result);
  2044. _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, (objDepositRst.rsp_code == "A0000") ? "Success!" : objDepositRst.rsp_message);
  2045. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log
  2046. /* 처리중으로 나오면 결과 재확인 result re-check */
  2047. if (objDepositRst.rsp_code == "A0001" ||
  2048. objDepositRst.rsp_code == "A0003" ||
  2049. objDepositRst.rsp_code == "A0007" ||
  2050. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  2051. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  2052. objDepositRst.res_list[0].bank_rsp_code == "804")
  2053. {
  2054. Thread.Sleep(1 * 60 * 1000);
  2055. /* 이체결과 조회 */
  2056. objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "1");
  2057. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit");
  2058. if (objDepositRst.rsp_code == "A0001" ||
  2059. objDepositRst.rsp_code == "A0003" ||
  2060. objDepositRst.rsp_code == "A0007" ||
  2061. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  2062. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  2063. objDepositRst.res_list[0].bank_rsp_code == "804")
  2064. {
  2065. Thread.Sleep(2 * 60 * 1000);
  2066. objDepositRst = CheckDepositResult(ref objDepositRst, model.CustomerId, "2");
  2067. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit");
  2068. if (objDepositRst.rsp_code == "A0001" ||
  2069. objDepositRst.rsp_code == "A0003" ||
  2070. objDepositRst.rsp_code == "A0007" ||
  2071. objDepositRst.res_list[0].bank_rsp_code == "400" ||
  2072. objDepositRst.res_list[0].bank_rsp_code == "803" ||
  2073. objDepositRst.res_list[0].bank_rsp_code == "804")
  2074. {
  2075. //실패로그 남기기
  2076. res.ErrorCode = "1";
  2077. res.Msg = objDepositRst.rsp_message;
  2078. res.Id = objDepositRst.api_tran_id;
  2079. res.Extra = objDepositRst.api_tran_dtm;
  2080. _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  2081. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRstTemp, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log
  2082. return res;
  2083. }
  2084. }
  2085. }
  2086. if (objDepositRst.rsp_code == "A0000")
  2087. {
  2088. res.ErrorCode = "0";
  2089. res.Msg = "Success";
  2090. res.Extra = JsonConvert.SerializeObject(objDepositRst);
  2091. _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  2092. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log
  2093. return res;
  2094. }
  2095. else
  2096. {
  2097. res.ErrorCode = "1";
  2098. res.Msg = objDepositRst.rsp_message;
  2099. _repo.LogResponseKFTC(_logResp.Id, deposit_result, objDepositRst.rsp_code, objDepositRst.rsp_message);
  2100. //_repo.responseKFTCDomesticHistory_DepositRefund(objDepositRst, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log
  2101. return res;
  2102. }
  2103. }
  2104. catch (Exception ex)
  2105. {
  2106. Log.Error("Exception tracked : " + ex.Message, ex);
  2107. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  2108. _repo.LogResponseKFTC(_logResp.Id, "Exception occured!", "999", ex.Message);
  2109. //_repo.responseKFTCDomesticHistory_DepositRefund(null, processId, model.CustomerId, "deposit"); // Domestic 입금이체 response log
  2110. return res;
  2111. }
  2112. }
  2113. /* 입금이체 시 사용. substring하기 위한 함수 @Dana */
  2114. public string lengSubstring(int subLength, string str)
  2115. {
  2116. string result = "";
  2117. if (str.Length >= subLength)
  2118. result = str.Substring(0, subLength);
  2119. else
  2120. result = str;
  2121. return result;
  2122. }
  2123. public JsonRxResponse DeleteAccount(DeleteRequest req, string customerId)
  2124. {
  2125. JsonRxResponse res = new JsonRxResponse();
  2126. KftcSendMoneyRequest request;
  2127. try
  2128. {
  2129. var kftcLogId = Crypto.Decrypt(req.KftcLogId, Utilities.ReadWebConfig("ktft_client_info_salt", ""));
  2130. request = _repo.GetCustomerKFTCInfo(customerId, kftcLogId);
  2131. if (null == request)
  2132. {
  2133. res.ErrorCode = "1";
  2134. res.Msg = "Error:Invalid auto debit account";
  2135. return res;
  2136. }
  2137. DbResult dbResult = new DbResult();
  2138. DbResult logResult = new DbResult();
  2139. var fintechUseNo = request.FintechUseNo;
  2140. logResult = _repo.LogRequestKFTC(customerId, "DBDelete", "CustomerId :" + customerId + " fintechUseNo :" + fintechUseNo);
  2141. dbResult = _repo.DeleteAccount(customerId, fintechUseNo);
  2142. _repo.LogResponseKFTC(logResult.Id, JsonConvert.SerializeObject(dbResult), dbResult.ResponseCode, dbResult.Msg);
  2143. res.ErrorCode = dbResult.ResponseCode;
  2144. res.Msg = dbResult.Msg;
  2145. res.Data = new { Message = dbResult.Msg };
  2146. return res;
  2147. }
  2148. catch (Exception ex)
  2149. {
  2150. res.ErrorCode = "1";
  2151. res.Msg = "Error:Invalid auto debit account";
  2152. return res;
  2153. }
  2154. }
  2155. private string getBankTranId()
  2156. {
  2157. //f3aa2cd1-1e9b-41fd-80f1-fd518cac9b81
  2158. Guid guid = Guid.NewGuid();
  2159. string guidSub = guid.ToString().Replace("-", "");
  2160. Random rndNum = new Random();
  2161. int rNum = rndNum.Next(0, 29);
  2162. string unique = guidSub.Substring(rNum, 3);
  2163. string bankTranId = ApplicationConfig.ReadWebConfig("GME_TRAN_CODE", "") + "U" + DateTime.Now.ToString("HHmmss") + unique;
  2164. return bankTranId.ToUpper();
  2165. }
  2166. public JsonRxResponse RegistrationKFTC_V4(string email, string lang, string client_id)
  2167. {
  2168. JsonRxResponse res = new JsonRxResponse();
  2169. var customerId = "";
  2170. try
  2171. {
  2172. var dbResult = _repo.GetCustomerIdEmail(email);
  2173. if (dbResult != null)
  2174. {
  2175. customerId = dbResult.Msg;
  2176. string URL = GetKftcUrl(customerId, lang, client_id);
  2177. //List<AccountDetails> AccountList = GetAccountList(customerId);
  2178. //AccountList.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
  2179. List<Header> ListLangauge = GetKftcLanguage(customerId);
  2180. List<Header> ListHeader = GetKftcHeader_V4(customerId);
  2181. KftcCommonResponse Response = new KftcCommonResponse()
  2182. {
  2183. Header = ListHeader,
  2184. URL = URL,
  2185. Language = ListLangauge
  2186. };
  2187. res.ErrorCode = "0";
  2188. res.Msg = "Success";
  2189. res.Data = Response;
  2190. return res;
  2191. }
  2192. else
  2193. {
  2194. res.ErrorCode = "1";
  2195. res.Msg = "failed";
  2196. res.Data = null;
  2197. return res;
  2198. }
  2199. }
  2200. catch (Exception ex)
  2201. {
  2202. Log.Error("Exception tracked : " + ex.Message, ex);
  2203. res.SetResponse("1", "Exception tracked : " + ex.Message, null);
  2204. res.Data = new { };
  2205. return res;
  2206. }
  2207. }
  2208. private List<Header> GetKftcHeader_V4(string customerId)
  2209. {
  2210. DataRow dr = _repo.GetCustomerData_V4(customerId);
  2211. List<Header> listKftcHeader = new List<Header>();
  2212. string[] param = new string[] { "Kftc-Bfop-UserSeqNo", "Kftc-Bfop-UserCI", "Kftc-Bfop-UserName" ,
  2213. "Kftc-Bfop-UserInfo","Kftc-Bfop-UserCellNo","Kftc-Bfop-PhoneCarrier","Kftc-Bfop-UserEmail"};
  2214. if (dr == null)
  2215. {
  2216. //KftcHeader.Add("Kftc-Bfop-UserSeqNo", "");
  2217. //KftcHeader.Add("Kftc-Bfop-UserCI", "");
  2218. //KftcHeader.Add("Kftc-Bfop-UserName", "");
  2219. //KftcHeader.Add("Kftc-Bfop-UserInfo", "");
  2220. //KftcHeader.Add("Kftc-Bfop-UserCellNo", "");
  2221. //KftcHeader.Add("Kftc-Bfop-PhoneCarrier", "");
  2222. //KftcHeader.Add("Kftc-Bfop-UserEmail", "");
  2223. foreach (var item in param)
  2224. {
  2225. Header KftcHeader = new Header();
  2226. KftcHeader.Key = item;
  2227. KftcHeader.Value = "";
  2228. listKftcHeader.Add(KftcHeader);
  2229. }
  2230. }
  2231. else
  2232. {
  2233. Header KftcHeader1 = new Header();
  2234. KftcHeader1.Key = "Kftc-Bfop-UserSeqNo";
  2235. KftcHeader1.Value = string.IsNullOrEmpty(dr["userSeqNo"].ToString()) ? "" : dr["userSeqNo"].ToString();
  2236. listKftcHeader.Add(KftcHeader1);
  2237. Header KftcHeader2 = new Header();
  2238. KftcHeader2.Key = "Kftc-Bfop-UserCI";
  2239. KftcHeader2.Value = string.IsNullOrEmpty(dr["userCi"].ToString()) ? "" : dr["userCi"].ToString();
  2240. listKftcHeader.Add(KftcHeader2);
  2241. Header KftcHeader3 = new Header();
  2242. KftcHeader3.Key = "Kftc-Bfop-UserName";
  2243. KftcHeader3.Value = string.IsNullOrEmpty(dr["userName"].ToString()) ? "" : dr["userName"].ToString();
  2244. listKftcHeader.Add(KftcHeader3);
  2245. Header KftcHeader4 = new Header();
  2246. KftcHeader4.Key = "Kftc-Bfop-UserInfo";
  2247. KftcHeader4.Value = string.IsNullOrEmpty(dr["userInfo"].ToString()) ? "" : dr["userInfo"].ToString();
  2248. listKftcHeader.Add(KftcHeader4);
  2249. Header KftcHeader5 = new Header();
  2250. KftcHeader5.Key = "Kftc-Bfop-UserCellNo";
  2251. KftcHeader5.Value = string.IsNullOrEmpty(dr["UserCellNo"].ToString()) ? "" : dr["UserCellNo"].ToString();
  2252. listKftcHeader.Add(KftcHeader5);
  2253. Header KftcHeader6 = new Header();
  2254. KftcHeader6.Key = "Kftc-Bfop-PhoneCarrier";
  2255. KftcHeader6.Value = "";
  2256. listKftcHeader.Add(KftcHeader6);
  2257. Header KftcHeader7 = new Header();
  2258. KftcHeader7.Key = "Kftc-Bfop-UserEmail";
  2259. KftcHeader7.Value = string.IsNullOrEmpty(dr["UserEmail"].ToString()) ? "" : dr["UserEmail"].ToString();
  2260. listKftcHeader.Add(KftcHeader7);
  2261. Header KftcHeader8 = new Header();
  2262. KftcHeader8.Key = "Kftc-Bfop-AccountNum";
  2263. KftcHeader8.Value = string.IsNullOrEmpty(dr["AccountNum"].ToString()) ? "" : dr["AccountNum"].ToString();
  2264. listKftcHeader.Add(KftcHeader8);
  2265. Header KftcHeader9 = new Header();
  2266. KftcHeader9.Key = "Kftc-Bfop-BankCodeStd";
  2267. KftcHeader9.Value = string.IsNullOrEmpty(dr["BankCodeStd"].ToString()) ? "" : dr["BankCodeStd"].ToString();
  2268. listKftcHeader.Add(KftcHeader9);
  2269. }
  2270. return listKftcHeader;
  2271. }
  2272. public bool SetRealNameDataIdWise(RealNameCheckDetails realNameCheckDetails)
  2273. {
  2274. var idNumber = realNameCheckDetails.idNumber.ToString().Replace("-", "");
  2275. var reqRealNameObj = new Common.KFTC.Request.real_name();
  2276. var processId = DateTime.Now.Ticks + realNameCheckDetails.customerId;
  2277. bool isSuccess = false;
  2278. string saveIdNumber = "";
  2279. //string[] idTypes = { "2", "5", "4", "1", "4" };
  2280. string[] idTypes = { "2", "1", "4", "5", "6", "3", "E", "4" };
  2281. for (int i = 0; i < 8; i++)
  2282. {
  2283. reqRealNameObj.bank_code_std = realNameCheckDetails.BankCode;
  2284. reqRealNameObj.account_num = realNameCheckDetails.AccountNumber;
  2285. reqRealNameObj.tran_dtime = DateTime.Now.ToString("yyyyMMddHHmmss");
  2286. //조합주민번호를 만들어서 체크
  2287. if (i == 7)
  2288. {
  2289. int pos = 0;
  2290. for (int j = idNumber.Length - 1; j > 0; j--)
  2291. {
  2292. char ch = idNumber[j];
  2293. if (ch >= 0x30 && ch <= 0x39)
  2294. {
  2295. pos = j;
  2296. break;
  2297. }
  2298. }
  2299. reqRealNameObj.account_holder_info_type = idTypes[i];
  2300. reqRealNameObj.account_holder_info = String.Format("{0}{1}{2}{3}",
  2301. realNameCheckDetails.dob,
  2302. realNameCheckDetails.gender,
  2303. realNameCheckDetails.country,
  2304. realNameCheckDetails.idNumber.Substring(pos - 4, 5));
  2305. }
  2306. else
  2307. {
  2308. reqRealNameObj.account_holder_info_type = idTypes[i];
  2309. reqRealNameObj.account_holder_info = idNumber;
  2310. }
  2311. saveIdNumber = reqRealNameObj.account_holder_info.Insert(6, "-");
  2312. isSuccess = KFTC_RealNameCheck_Common(reqRealNameObj, realNameCheckDetails.gmeAccessToken, realNameCheckDetails.customerId);
  2313. if (isSuccess == true)
  2314. {
  2315. _repo.SetRealNameData(realNameCheckDetails.customerId, reqRealNameObj.account_holder_info_type, saveIdNumber);
  2316. break;
  2317. }
  2318. }
  2319. return isSuccess;
  2320. }
  2321. }
  2322. }