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.

154 lines
6.8 KiB

1 year ago
  1. using Common.Model;
  2. using Common.Model.AutoRefund;
  3. using log4net;
  4. using System.Data;
  5. namespace Repository.PowerCallRepository
  6. {
  7. public class PowerCallRepository : IPowerCallRepository
  8. {
  9. private readonly Dao _dao;
  10. private static readonly ILog Log = LogManager.GetLogger(typeof(PowerCallRepository));
  11. public PowerCallRepository()
  12. {
  13. _dao = new Dao();
  14. }
  15. public string GetFcmId(string customerId)
  16. {
  17. string sql = $@"SELECT deviceId FROM mobile_userRegistration(NOLOCK) WHERE customerId = {customerId}";
  18. Log.Debug(sql);
  19. return _dao.GetSingleResult(sql);
  20. }
  21. public string GetChargeInfo(string orderId)
  22. {
  23. string sql = "SELECT request FROM powercallHistory(NOLOCK)";
  24. sql += "WHERE orderId= " + _dao.FilterString(orderId);
  25. return _dao.GetSingleResult(sql);
  26. }
  27. public DbResult CheckWallet(KJAutoRefundModel model, string passWord)
  28. {
  29. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='checkWallet'";
  30. sql += ", @customerId=" + _dao.FilterString(model.customerId);
  31. sql += ", @bankCode=" + _dao.FilterString(model.bankCode);
  32. sql += ", @bankAccount=" + _dao.FilterString(model.bankAccountNo);
  33. sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
  34. sql += ", @action=" + _dao.FilterString(model.action);
  35. sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
  36. sql += ", @passWord=" + _dao.FilterString(passWord);
  37. var res = _dao.ParseDbResult(sql);
  38. return res;
  39. }
  40. public DbResult ResultWallet(KJAutoRefundModel model, string commision, string phoneNo)
  41. {
  42. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='resultWalletMoney'";
  43. sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
  44. sql += ", @customerId=" + _dao.FilterString(model.customerId);
  45. sql += ", @action=" + _dao.FilterString(model.action);
  46. sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
  47. sql += ", @commision=" + _dao.FilterString(commision);
  48. sql += ", @phoneNo=" + _dao.FilterString(phoneNo);
  49. var res = _dao.ParseDbResult(sql);
  50. return res;
  51. }
  52. public DbResult ReStoreWallet(KJAutoRefundModel model, string restoreMoney, string commision, string phoneNo)
  53. {
  54. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='restoreWalletMoney'";
  55. sql += ", @customerId=" + _dao.FilterString(model.customerId);
  56. sql += ", @action=" + _dao.FilterString(model.action);
  57. sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
  58. sql += ", @restoreMoney=" + _dao.FilterString(restoreMoney);
  59. sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
  60. sql += ", @commision=" + _dao.FilterString(commision);
  61. sql += ", @phoneNo=" + _dao.FilterString(phoneNo);
  62. var res = _dao.ParseDbResult(sql);
  63. return res;
  64. }
  65. public DbResult FailWallet(KJAutoRefundModel model)
  66. {
  67. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='TOPUP_FAIL'";
  68. sql += ", @customerId=" + _dao.FilterString(model.customerId);
  69. sql += ", @action=" + _dao.FilterString(model.action);
  70. sql += ", @restoreMoney=" + _dao.FilterString(model.amount);
  71. sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
  72. var res = _dao.ParseDbResult(sql);
  73. return res;
  74. }
  75. public DbResult Request(string customerId, string buyType, string ChargeType, string cardName, string ProductPrice, string phoneNo, string request, string methodName, string processId = "", string orderId = "")
  76. {
  77. if (request == null)
  78. {
  79. request = "";
  80. }
  81. var sql = string.Format("EXEC PROC_POWERCALLHISTORY @flag='i', @buyType ='{0}', @cardName=N'{1}', @chargeType = '{2}', @productPrice ='{3}', @phoneNo = '{4}', @methodName= '{5}', @customerId ='{6}',@request=N'{7}'", buyType, cardName, ChargeType, ProductPrice, phoneNo, methodName, customerId, request);
  82. return _dao.ParseDbResult(sql);
  83. }
  84. public DbResult PowercallLog(long rowId, string request)
  85. {
  86. var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='powerCallLog', @rowId='{0}',@requestPowerCall='{1}'",
  87. rowId, request);
  88. return _dao.ParseDbResult(sql);
  89. }
  90. public DbResult PowerCallHistory(long rowId, string errorcode, string errormsg, string response)
  91. {
  92. if (response == null)
  93. {
  94. response = "";
  95. }
  96. var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='powerCallHistroy', @rowId='{0}',@responsePowerCall='{1}',@errorCode='{2}', @errorMessage='{3}'",
  97. rowId, response, errorcode, errormsg);
  98. return _dao.ParseDbResult(sql);
  99. }
  100. public DbResult CallBackPowerCallHistory(string orderNo, string errorcode, string errormsg, string response)
  101. {
  102. if (response == null)
  103. {
  104. response = "";
  105. }
  106. var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='callBack', @orderId='{0}',@responsePowerCall='{1}',@errorCode='{2}', @errorMessage='{3}'",
  107. orderNo, response, errorcode, errormsg);
  108. return _dao.ParseDbResult(sql);
  109. }
  110. public DataRow GetPowerCallHistory(string customerId)
  111. {
  112. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='checkCharge'";
  113. sql += ", @customerId=" + _dao.FilterString(customerId);
  114. return _dao.ExecuteDataRow(sql);
  115. }
  116. public DataTable GetUserChageInfo(string customerId, string FromDate, string toDate)
  117. {
  118. var sql = "EXEC PROC_POWERCALL_NEW @FLAG='UserChargeInfo'";
  119. sql += ", @customerId=" + _dao.FilterString(customerId);
  120. sql += ", @fromDate=" + _dao.FilterString(FromDate);
  121. sql += ", @toDate=" + _dao.FilterString(toDate);
  122. return _dao.ExecuteDataTable(sql);
  123. }
  124. public string GetProcessId(string orderId)
  125. {
  126. string sql = "SELECT processId FROM powercallHistory(NOLOCK)";
  127. sql += "WHERE orderId= " + _dao.FilterString(orderId);
  128. return _dao.GetSingleResult(sql);
  129. }
  130. public string GetCommision(string mainCategory, string cardType)
  131. {
  132. string sql = "SELECT commision FROM productPowerCall(NOLOCK)";
  133. sql += "WHERE category= " + _dao.FilterString(mainCategory);
  134. sql += " AND cardType=" + _dao.FilterString(cardType);
  135. return _dao.GetSingleResult(sql);
  136. }
  137. }
  138. }