Exemple #1
0
 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;
     }
 }
Exemple #2
0
        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;
            }
        }