def CreateTransaction(self, type, data): tx = Transaction() tx.amount = data.actualAmount if type == 'pay': tx.fundIdIn = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.acc, currencyCode=data.payType).id tx.precoinrFee = tx.amount*float(data.precoinrFee)/10000 tx.exchangeAmount=data.requestAmount tx.exchangeCode=data.requestType tx.exchangeRate=data.exchangeRate elif type == 'fee': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id elif type == 'exchangeOUT': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id tx.exchangeAmount=data.actualExchangeAmount tx.exchangeCode=data.requestType tx.exchangeRate=data.exchangeRate elif type == 'exchangeIN': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.requestType).id tx.fundIdOut = AccountFund.objects.get(accountId=precoinrAcc.id, currencyCode=data.requestType).id tx.transactionType= type tx.timeStamp = data.timestamp tx.TxUUId = data.txUUId return tx
def CreateSystemOutTransaction(self, fund, amount, fee): tx = Transaction() tx.amount = amount precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdOut = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=fund.currencyCode).id tx.precoinrFee = fee tx.transactionType= 'systemOut' tx.timeStamp = datetime.utcnow().replace(tzinfo=utc) tx.TxUUId = uuid.uuid4().__str__() tx.ccTxId='' return tx
def CreateWithdrawTransaction(self, fund, amount, outAddress): tx = Transaction() tx.withdrawAddress = outAddress tx.amount = amount precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=fund.currencyCode).id tx.fundIdOut = fund.id tx.precoinrFee = amount*5/1000 tx.transactionType= 'withdraw' tx.timeStamp = datetime.utcnow().replace(tzinfo=utc) tx.TxUUId = uuid.uuid4().__str__() tx.ccTxId='' return tx