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.
 
 
 

155 lines
6.8 KiB

using Common.Model;
using Common.Model.AutoRefund;
using log4net;
using System.Data;
namespace Repository.PowerCallRepository
{
public class PowerCallRepository : IPowerCallRepository
{
private readonly Dao _dao;
private static readonly ILog Log = LogManager.GetLogger(typeof(PowerCallRepository));
public PowerCallRepository()
{
_dao = new Dao();
}
public string GetFcmId(string customerId)
{
string sql = $@"SELECT deviceId FROM mobile_userRegistration(NOLOCK) WHERE customerId = {customerId}";
Log.Debug(sql);
return _dao.GetSingleResult(sql);
}
public string GetChargeInfo(string orderId)
{
string sql = "SELECT request FROM powercallHistory(NOLOCK)";
sql += "WHERE orderId= " + _dao.FilterString(orderId);
return _dao.GetSingleResult(sql);
}
public DbResult CheckWallet(KJAutoRefundModel model, string passWord)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='checkWallet'";
sql += ", @customerId=" + _dao.FilterString(model.customerId);
sql += ", @bankCode=" + _dao.FilterString(model.bankCode);
sql += ", @bankAccount=" + _dao.FilterString(model.bankAccountNo);
sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
sql += ", @action=" + _dao.FilterString(model.action);
sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
sql += ", @passWord=" + _dao.FilterString(passWord);
var res = _dao.ParseDbResult(sql);
return res;
}
public DbResult ResultWallet(KJAutoRefundModel model, string commision, string phoneNo)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='resultWalletMoney'";
sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
sql += ", @customerId=" + _dao.FilterString(model.customerId);
sql += ", @action=" + _dao.FilterString(model.action);
sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
sql += ", @commision=" + _dao.FilterString(commision);
sql += ", @phoneNo=" + _dao.FilterString(phoneNo);
var res = _dao.ParseDbResult(sql);
return res;
}
public DbResult ReStoreWallet(KJAutoRefundModel model, string restoreMoney, string commision, string phoneNo)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='restoreWalletMoney'";
sql += ", @customerId=" + _dao.FilterString(model.customerId);
sql += ", @action=" + _dao.FilterString(model.action);
sql += ", @useWalletMoney=" + _dao.FilterString(model.amount);
sql += ", @restoreMoney=" + _dao.FilterString(restoreMoney);
sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
sql += ", @commision=" + _dao.FilterString(commision);
sql += ", @phoneNo=" + _dao.FilterString(phoneNo);
var res = _dao.ParseDbResult(sql);
return res;
}
public DbResult FailWallet(KJAutoRefundModel model)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='TOPUP_FAIL'";
sql += ", @customerId=" + _dao.FilterString(model.customerId);
sql += ", @action=" + _dao.FilterString(model.action);
sql += ", @restoreMoney=" + _dao.FilterString(model.amount);
sql += ", @customerSummary=" + _dao.FilterString(model.customerSummary);
var res = _dao.ParseDbResult(sql);
return res;
}
public DbResult Request(string customerId, string buyType, string ChargeType, string cardName, string ProductPrice, string phoneNo, string request, string methodName, string processId = "", string orderId = "")
{
if (request == null)
{
request = "";
}
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);
return _dao.ParseDbResult(sql);
}
public DbResult PowercallLog(long rowId, string request)
{
var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='powerCallLog', @rowId='{0}',@requestPowerCall='{1}'",
rowId, request);
return _dao.ParseDbResult(sql);
}
public DbResult PowerCallHistory(long rowId, string errorcode, string errormsg, string response)
{
if (response == null)
{
response = "";
}
var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='powerCallHistroy', @rowId='{0}',@responsePowerCall='{1}',@errorCode='{2}', @errorMessage='{3}'",
rowId, response, errorcode, errormsg);
return _dao.ParseDbResult(sql);
}
public DbResult CallBackPowerCallHistory(string orderNo, string errorcode, string errormsg, string response)
{
if (response == null)
{
response = "";
}
var sql = string.Format("EXEC PROC_POWERCALLHISTORY @FLAG='callBack', @orderId='{0}',@responsePowerCall='{1}',@errorCode='{2}', @errorMessage='{3}'",
orderNo, response, errorcode, errormsg);
return _dao.ParseDbResult(sql);
}
public DataRow GetPowerCallHistory(string customerId)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='checkCharge'";
sql += ", @customerId=" + _dao.FilterString(customerId);
return _dao.ExecuteDataRow(sql);
}
public DataTable GetUserChageInfo(string customerId, string FromDate, string toDate)
{
var sql = "EXEC PROC_POWERCALL_NEW @FLAG='UserChargeInfo'";
sql += ", @customerId=" + _dao.FilterString(customerId);
sql += ", @fromDate=" + _dao.FilterString(FromDate);
sql += ", @toDate=" + _dao.FilterString(toDate);
return _dao.ExecuteDataTable(sql);
}
public string GetProcessId(string orderId)
{
string sql = "SELECT processId FROM powercallHistory(NOLOCK)";
sql += "WHERE orderId= " + _dao.FilterString(orderId);
return _dao.GetSingleResult(sql);
}
public string GetCommision(string mainCategory, string cardType)
{
string sql = "SELECT commision FROM productPowerCall(NOLOCK)";
sql += "WHERE category= " + _dao.FilterString(mainCategory);
sql += " AND cardType=" + _dao.FilterString(cardType);
return _dao.GetSingleResult(sql);
}
}
}