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.

126 lines
4.6 KiB

1 year ago
  1. using Common;
  2. using Common.Helper;
  3. using Common.Model;
  4. using Common.Model.AutoRefund;
  5. using log4net;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. namespace Repository.AutoRefund
  10. {
  11. public class AutoRefundRepository : IAutoRefundRepository
  12. {
  13. private readonly Dao _dao;
  14. private static readonly ILog Log = LogManager.GetLogger(typeof(AutoRefundRepository));
  15. public AutoRefundRepository()
  16. {
  17. _dao = new Dao();
  18. }
  19. public JsonRxResponse SendAutoRefund(KwangjuAutoRefundModel model)
  20. {
  21. var dic = new Dictionary<string, string>
  22. {
  23. { "@pCustomerId", _dao.FilterString(model.CustomerId) },
  24. { "@pCustomerSummary", _dao.FilterString(model.CustomerSummary) },
  25. { "@pAmount", _dao.FilterString(model.Amount) },
  26. { "@pAction", _dao.FilterString(model.Action) },
  27. { "@pActionDate", _dao.FilterString(model.ActionDate) },
  28. { "@pActionBy", _dao.FilterString(model.ActionBy) },
  29. { "@pRowId", _dao.FilterString(model.RowId) },
  30. { "@pBankCode", _dao.FilterString(model.BankCode) },
  31. { "@pBankAccountNo", _dao.FilterString(model.BankAccountNo) },
  32. { "@pSource", _dao.FilterString("M") }
  33. };
  34. var sql = new Query("PROC_KJAUTOREFUND", model.Flag, dic).ToString();
  35. Log.Debug(sql);
  36. var dbRes = _dao.ParseDbResult(sql);
  37. return new JsonRxResponse { ErrorCode = dbRes.ResponseCode, Msg = dbRes.Msg, Id = dbRes.Id, Extra = dbRes.Extra, Extra2 = dbRes.Extra };
  38. }
  39. public CustomerInfo GetCustomerInfoForKwangju(string customerId)
  40. {
  41. var dic = new Dictionary<string, string>
  42. {
  43. { "@pCustomerId", _dao.FilterString(customerId) }
  44. };
  45. var sql = new Query("PROC_KJAUTOREFUND", "CUSTOMER-INFO", dic).ToString();
  46. Log.Debug(sql);
  47. var dt = _dao.ExecuteDataTable(sql);
  48. return Mapper.DataTableToClass<CustomerInfo>(dt)[0];
  49. }
  50. public RefundRequireResponseModel GetRefundRequirement(string username)
  51. {
  52. var dic = new Dictionary<string, string>
  53. {
  54. { "@Username", _dao.FilterString(username) }
  55. };
  56. var sql = new Query("PROC_MOBILE_REFUND", "requirement", dic).ToString();
  57. Log.Debug(sql);
  58. var dt = _dao.ExecuteDataTable(sql);
  59. return Mapper.DataTableToClass<RefundRequireResponseModel>(dt)[0];
  60. }
  61. public void LogFailTransactionForAutoDebit(string rowId, string errorCode, string errorMsg)
  62. {
  63. var dic = new Dictionary<string, string>
  64. {
  65. { "@rowId", _dao.FilterString(rowId) },
  66. { "@errorCode", _dao.FilterString(errorCode) },
  67. { "@errorMsg", _dao.FilterString(errorMsg) }
  68. };
  69. var sql = new Query("KFTC_LOG_CUSTOMER_INFO", "U-TRAN", dic).ToString();
  70. Log.Debug(sql);
  71. _dao.GetSingleResult(sql);
  72. }
  73. public DataTable GetAccountList(string customerId)
  74. {
  75. var dic = new Dictionary<string, string>
  76. {
  77. { "@customerId", _dao.FilterString(customerId) }
  78. };
  79. var sql = new Query("KFTC_LOG_CUSTOMER_INFO", "s", dic).ToString();
  80. Log.Debug(sql);
  81. return _dao.ExecuteDataTable(sql);
  82. }
  83. /* 2019.09 @Dana */
  84. public DbResult LogRequestKFTC(string user, string methodName, string requestXml, string processId = "")
  85. {
  86. if (requestXml == null)
  87. requestXml = "";
  88. var sql = string.Format("EXEC PROC_KFTC_LOGS @flag='i', @CUSTOMERID='{0}', @methodName='{1}',@requestXml=N'{2}',@processId='{3}'", user, methodName, requestXml.Replace("'", ""), processId);
  89. return _dao.ParseDbResult(sql);
  90. }
  91. public DbResult LogResponseKFTC(string rowId, string responseXml, string tpErrorCode, string tpErrorMsg)
  92. {
  93. try
  94. {
  95. if (string.IsNullOrEmpty(responseXml))
  96. responseXml = "";
  97. var sql =
  98. string.Format(
  99. "EXEC PROC_KFTC_LOGS @flag='u', @rowId='{0}',@responseXml=N'{1}', @errorCode='{2}', @errorMessage=N'{3}'",
  100. rowId, responseXml.Replace("'", ""), tpErrorCode, tpErrorMsg);
  101. return _dao.ParseDbResult(sql);
  102. }
  103. catch (Exception)
  104. {
  105. return new DbResult();
  106. }
  107. }
  108. }
  109. }