public WalletDrCrResponse InsertWalletTQDebit(string timestamp, long walletID, string coinName, decimal amount, long TrnRefNo, enServiceType serviceType, enWalletTrnType trnType, enWalletTranxOrderType enWalletTranx, enWalletLimitType enWalletLimit) { try { WalletMaster Walletobj; string remarks = ""; WalletTypeMaster walletTypeMaster; WalletTransactionQueue objTQ; //long walletTypeID; WalletDrCrResponse resp = new WalletDrCrResponse(); long owalletID, orgID; walletTypeMaster = _WalletTypeMasterRepository.GetSingle(e => e.WalletTypeName == coinName); if (walletTypeMaster == null) { return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidReq, ErrorCode = enErrorCode.InvalidCoinName }); } Walletobj = _commonRepository.GetById(walletID); //orgID = _walletRepository1.getOrgID(); //if (orgID == 0) //{ // return new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.OrgIDNotFound, ErrorCode = enErrorCode.OrgIDNotFound }; //} //Walletobj = _commonRepository.FindBy(e => e.WalletTypeID == Walletobj.WalletTypeID && e.UserID == orgID && e.IsDefaultWallet == 1 && e.Status == 1).FirstOrDefault(); //if (Walletobj == null) //{ // //tqObj = InsertIntoWalletTransactionQueue(Guid.NewGuid().ToString(), orderType, amount, TrnRefNo, UTC_To_IST(), null, dWalletobj.Id, coinName, userID, timestamp, 2, EnResponseMessage.InvalidWallet); // return new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidWallet, ErrorCode = enErrorCode.InvalidWallet }; //} if (Walletobj.Status != 1 || Walletobj.IsValid == false) { // insert with status=2 system failed objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.InvalidWallet, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidWallet, ErrorCode = enErrorCode.InvalidWallet, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } if (!CheckUserBalance(Walletobj.Id)) { objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.BalMismatch, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidWallet, ErrorCode = enErrorCode.SettedBalanceMismatch, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } if (TrnRefNo == 0) // sell 13-10-2018 { // insert with status=2 system failed objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.InvalidTradeRefNo, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidTradeRefNo, ErrorCode = enErrorCode.InvalidTradeRefNo, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } if (amount <= 0) { // insert with status=2 system failed objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.InvalidAmt, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidAmt, ErrorCode = enErrorCode.InvalidAmount, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } if (Walletobj.Balance < amount) { // insert with status=2 system failed objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.InsufficantBal, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InsufficantBal, ErrorCode = enErrorCode.InsufficantBal, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } // ntrivedi 03-11-2018 if (_commonWalletFunction.CheckShadowLimit(Walletobj.Id, amount) != enErrorCode.Success) { objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.ShadowLimitExceed, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.ShadowLimitExceed, ErrorCode = enErrorCode.ShadowBalanceExceed, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } //vsolanki 208-11-1 var charge = GetServiceLimitChargeValue(enTrnType.Deposit, coinName);//for deposit if (charge.MaxAmount < amount && charge.MinAmount > amount) { var msg1 = EnResponseMessage.ProcessTrn_AmountBetweenMinMaxMsg; msg1 = msg1.Replace("@MIN", charge.MinAmount.ToString()); msg1 = msg1.Replace("@MAX", charge.MaxAmount.ToString()); objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, msg1, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = msg1, ErrorCode = enErrorCode.ProcessTrn_AmountBetweenMinMax }); } int count = CheckTrnRefNo(TrnRefNo, enWalletTranx, trnType); if (count != 0) { // insert with status=2 system failed objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.AlredyExist, trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.AlredyExist, ErrorCode = enErrorCode.AlredyExist, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } // ntrivedi need to add condition for allowd wallet trntype // ntrivedi need to match transactionaccount // ntrivedi need to check limit (deposit , withdrawal , trading ) set by user objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Debit, amount, TrnRefNo, UTC_To_IST(), null, Walletobj.Id, coinName, Walletobj.UserID, timestamp, 0, "Inserted", trnType); objTQ = _walletRepository1.AddIntoWalletTransactionQueue(objTQ, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.SuccessDebit, ErrorCode = enErrorCode.Success, TrnNo = objTQ.TrnNo, Status = objTQ.Status, StatusMsg = objTQ.StatusMsg }); } catch (Exception ex) { //_log.LogError(ex, "Date: " + UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); throw ex; } }
public WalletLedger GetWalletLedgerObj(long WalletID, long toWalletID, decimal drAmount, decimal crAmount, enWalletTrnType trnType, enServiceType serviceType, long trnNo, string remarks, decimal currentBalance, byte status) { try { var walletLedger2 = new WalletLedger(); walletLedger2.ServiceTypeID = serviceType; walletLedger2.TrnType = trnType; walletLedger2.CrAmt = crAmount; walletLedger2.CreatedBy = WalletID; walletLedger2.CreatedDate = UTC_To_IST(); walletLedger2.DrAmt = drAmount; walletLedger2.TrnNo = trnNo; walletLedger2.Remarks = remarks; walletLedger2.Status = status; walletLedger2.TrnDate = UTC_To_IST(); walletLedger2.UpdatedBy = WalletID; walletLedger2.WalletId = WalletID; walletLedger2.ToWalletId = toWalletID; if (drAmount > 0) { walletLedger2.PreBal = currentBalance; walletLedger2.PostBal = currentBalance - drAmount; } else { walletLedger2.PreBal = currentBalance; walletLedger2.PostBal = currentBalance + crAmount; } return(walletLedger2); } catch (Exception ex) { //_log.LogError(ex, "Date: " + UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); throw ex; } }
protected WalletTransactionQueue InsertIntoWalletTransactionQueue(Guid Guid, enWalletTranxOrderType TrnType, decimal Amount, long TrnRefNo, DateTime TrnDate, DateTime?UpdatedDate, long WalletID, string WalletType, long MemberID, string TimeStamp, enTransactionStatus Status, string StatusMsg, enWalletTrnType enWalletTrnType) { WalletTransactionQueue walletTransactionQueue = new WalletTransactionQueue(); // walletTransactionQueue.TrnNo = TrnNo; walletTransactionQueue.Guid = Guid; walletTransactionQueue.TrnType = TrnType; walletTransactionQueue.Amount = Amount; walletTransactionQueue.TrnRefNo = TrnRefNo; walletTransactionQueue.TrnDate = TrnDate; walletTransactionQueue.UpdatedDate = UpdatedDate; walletTransactionQueue.WalletID = WalletID; walletTransactionQueue.WalletType = WalletType; walletTransactionQueue.MemberID = MemberID; walletTransactionQueue.TimeStamp = TimeStamp; walletTransactionQueue.Status = Status; walletTransactionQueue.StatusMsg = StatusMsg; walletTransactionQueue.WalletTrnType = enWalletTrnType; return(walletTransactionQueue); }
protected int CheckTrnRefNo(long TrnRefNo, enWalletTranxOrderType TrnType, enWalletTrnType wType) { var count = _walletRepository1.CheckTrnRefNo(TrnRefNo, TrnType, wType); return(count); }
public WalletDrCrResponse DepositionWalletOperation(string timestamp, string address, string coinName, decimal amount, long TrnRefNo, enServiceType serviceType, enWalletTrnType trnType, enWalletTranxOrderType enWalletTranx, enWalletLimitType enWalletLimit, enTrnType routeTrnType, string Token = "") { try { WalletMaster dWalletobj, cWalletObj; string DrRemarks = "", CrRemarks = ""; WalletTypeMaster walletTypeMaster; WalletTransactionQueue objTQDr, objTQCr; //long walletTypeID; WalletDrCrResponse resp = new WalletDrCrResponse(); long owalletID, orgID; WalletTransactionOrder woObj; HelperForLog.WriteLogIntoFile("DepositionWalletOperation", "WalletService", "timestamp:" + timestamp + "," + "coinName:" + coinName + ",TrnRefNo=" + TrnRefNo.ToString() + ",address=" + address + ",amount=" + amount.ToString() + ",Token=" + Token); // moved inside InsertWalletTQDebit //walletTypeMaster = _WalletTypeMasterRepository.GetSingle(e => e.WalletTypeName == coinName); //if (walletTypeMaster == null) //{ // return new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidReq, ErrorCode = enErrorCode.InvalidCoinName }; //} owalletID = GetWalletByAddress(address); if (owalletID == 0) { return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidAddress, ErrorCode = enErrorCode.InvalidAddress }); } cWalletObj = _commonRepository.GetById(owalletID); orgID = _walletRepository1.getOrgID(); if (orgID == 0) { return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.OrgIDNotFound, ErrorCode = enErrorCode.OrgIDNotFound }); } dWalletobj = _commonRepository.FindBy(e => e.WalletTypeID == cWalletObj.WalletTypeID && e.UserID == orgID && e.IsDefaultWallet == 1 && e.Status == 1).FirstOrDefault(); if (dWalletobj == null) { //tqObj = InsertIntoWalletTransactionQueue(Guid.NewGuid().ToString(), orderType, amount, TrnRefNo, UTC_To_IST(), null, dWalletobj.Id, coinName, userID, timestamp, 2, EnResponseMessage.InvalidWallet); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidWallet, ErrorCode = enErrorCode.InvalidWallet }); } //ntrivedi 03-11-2018 var charge = _commonWalletFunction.GetServiceLimitChargeValue(enTrnType.Deposit, coinName); if (charge.MaxAmount < amount && charge.MinAmount > amount) { return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.ProcessTrn_AmountBetweenMinMaxMsg, ErrorCode = enErrorCode.ProcessTrn_AmountBetweenMinMax }); } resp = InsertWalletTQDebit(timestamp, dWalletobj.Id, coinName, amount, TrnRefNo, serviceType, enWalletTrnType.Dr_Debit, enWalletTranx, enWalletLimit); if (resp.ReturnCode != 0 || resp.Status != enTransactionStatus.Initialize) { return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = resp.StatusMsg, ErrorCode = resp.ErrorCode }); } if (cWalletObj.Status != 1 || cWalletObj.IsValid == false) { // insert with status=2 system failed objTQCr = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Credit, amount, TrnRefNo, UTC_To_IST(), null, dWalletobj.Id, coinName, dWalletobj.UserID, timestamp, enTransactionStatus.SystemFail, EnResponseMessage.InvalidWallet, trnType); objTQCr = _walletRepository1.AddIntoWalletTransactionQueue(objTQCr, 1); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidWallet, ErrorCode = enErrorCode.InvalidWallet, TrnNo = objTQCr.TrnNo, Status = objTQCr.Status, StatusMsg = objTQCr.StatusMsg }); } objTQDr = _walletRepository1.GetTransactionQueue(resp.TrnNo); TrnAcBatch batchObj = _trnBatch.Add(new TrnAcBatch(UTC_To_IST())); DrRemarks = "Debit for Deposition TrnNo:" + TrnRefNo; WalletLedger walletLedgerDr = GetWalletLedgerObj(dWalletobj.Id, cWalletObj.Id, amount, 0, enWalletTrnType.Dr_Debit, serviceType, objTQDr.TrnNo, DrRemarks, dWalletobj.Balance, 1); TransactionAccount tranxAccounDrt = GetTransactionAccount(dWalletobj.Id, 1, batchObj.Id, amount, 0, objTQDr.TrnNo, DrRemarks, 1); dWalletobj.DebitBalance(amount); objTQDr.Status = enTransactionStatus.Success; objTQDr.StatusMsg = "Success"; DrRemarks = "Credit for Deposition TrnNo:" + TrnRefNo; objTQCr = InsertIntoWalletTransactionQueue(Guid.NewGuid(), enWalletTranxOrderType.Credit, amount, TrnRefNo, UTC_To_IST(), null, cWalletObj.Id, coinName, cWalletObj.UserID, timestamp, 0, "Inserted", trnType); objTQCr = _walletRepository1.AddIntoWalletTransactionQueue(objTQCr, 1); woObj = InsertIntoWalletTransactionOrder(null, UTC_To_IST(), cWalletObj.Id, dWalletobj.Id, amount, coinName, objTQCr.TrnNo, objTQDr.TrnNo, 0, "Inserted"); woObj = _walletRepository1.AddIntoWalletTransactionOrder(woObj, 1); WalletLedger walletLedgerCr = GetWalletLedgerObj(cWalletObj.Id, dWalletobj.Id, 0, amount, trnType, serviceType, objTQCr.TrnNo, DrRemarks, cWalletObj.Balance, 1); TransactionAccount tranxAccountCr = GetTransactionAccount(cWalletObj.Id, 1, batchObj.Id, 0, amount, objTQCr.TrnNo, DrRemarks, 1); cWalletObj.CreditBalance(amount); //var objTQ = InsertIntoWalletTransactionQueue(Guid.NewGuid(), orderType, TotalAmount, TrnRefNo, UTC_To_IST(), null, cWalletobj.Id, coinName, userID, timestamp, 1, "Updated"); objTQCr.Status = enTransactionStatus.Success; objTQCr.StatusMsg = "Success"; objTQCr.UpdatedDate = UTC_To_IST(); woObj.Status = enTransactionStatus.Success; woObj.StatusMsg = "Deposition success for RefNo :" + TrnRefNo; woObj.UpdatedDate = UTC_To_IST(); objTQDr.SettedAmt = amount; _walletRepository1.WalletCreditDebitwithTQ(walletLedgerDr, walletLedgerCr, tranxAccountCr, tranxAccounDrt, dWalletobj, cWalletObj, objTQCr, objTQDr, woObj); //ntrivedi temperory //vsolanki 2018-11-1---------------socket method -------------------------- WalletMasterResponse walletMasterObj = new WalletMasterResponse(); walletMasterObj.AccWalletID = cWalletObj.AccWalletID; walletMasterObj.Balance = cWalletObj.Balance; walletMasterObj.WalletName = cWalletObj.Walletname; walletMasterObj.PublicAddress = cWalletObj.PublicAddress; walletMasterObj.AccWalletID = cWalletObj.AccWalletID; walletMasterObj.CoinName = coinName; var msg = EnResponseMessage.CreditWalletMsg; msg = msg.Replace("#Coin#", coinName); msg = msg.Replace("#TrnType#", routeTrnType.ToString()); msg = msg.Replace("#TrnNo#", TrnRefNo.ToString()); try { _signalRService.OnWalletBalChange(walletMasterObj, coinName, cWalletObj.UserID.ToString(), 2); _signalRService.SendActivityNotification(msg, cWalletObj.UserID.ToString(), 2); } catch (Exception ex2) { HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex2); } // OnWalletBalChange(walletMasterObj, coinName, Token); //------------------------------- //vsolanki 2018-11-1---------------socket method -------------------------- //WalletMasterResponse walletMasterObj1 = new WalletMasterResponse(); //walletMasterObj.AccWalletID = cWalletObj.AccWalletID; //walletMasterObj.Balance = cWalletObj.Balance; //walletMasterObj.WalletName = cWalletObj.Walletname; //walletMasterObj.PublicAddress = cWalletObj.PublicAddress; //walletMasterObj.AccWalletID = cWalletObj.AccWalletID; //walletMasterObj.CoinName = coinName; //_signalRService.OnWalletBalChange(walletMasterObj1, coinName, Token); //OnWalletBalChange(walletMasterObj, coinName, Token); //------------------------------- //CreditWalletDrArryTrnID[] arryTrnID = new CreditWalletDrArryTrnID [1]; //arryTrnID[0].Amount = amount; //arryTrnID[0].DrTrnRefNo = TrnRefNo; //resp = GetWalletCreditNew(coinName, timestamp, trnType, amount, cWalletObj.UserID, cWalletObj.AccWalletID, arryTrnID, TrnRefNo,1,enWalletTranxOrderType.Credit,enServiceType.WalletService ); return(new WalletDrCrResponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.SuccessDebit, ErrorCode = enErrorCode.Success, TrnNo = resp.TrnNo, Status = resp.Status, StatusMsg = resp.StatusMsg }); } catch (Exception ex) { //_log.LogError(ex, "Date: " + UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); throw ex; } }