def sendcoin_to_poster_btc_comment(sender_id, amount, commentid, recieverid): """ # From user wallet to user wallet # happens during a tip to comment user_id0 transfers to user_id1 :param sender_id: :param amount: :param commentid: :param recieverid: :return: """ try: type_transaction_recieve_comment = 5 recieverwallet = BtcWallet.query.filter_by(user_id=recieverid).first() # add amount to commenter curbal_reciever = Decimal(recieverwallet.currentbalance) amounttomod = Decimal(amount) newbalance_reciever = curbal_reciever + amounttomod recieverwallet.currentbalance = newbalance_reciever db.session.add(recieverwallet) # add transaction for senders wallet addtransaction(category=type_transaction_recieve_comment, amount=amount, user_id=recieverid, senderid=sender_id, comment='', orderid=commentid, balance=newbalance_reciever) # add transaction for comments wallet except Exception as e: db.session.rollback()
def sendcoin_subowner_btc_comment(sender_id, amount, commentid, recieverid): try: type_transaction_recieve_post = 10 recieverwallet = BtcWallet.query.filter_by(user_id=recieverid).first() # add amount to commenter curbal_reciever = Decimal(recieverwallet.currentbalance) amounttomod = Decimal(amount) newbalance_reciever = curbal_reciever + amounttomod recieverwallet.currentbalance = newbalance_reciever db.session.add(recieverwallet) # add transaction for recievers wallet addtransaction(category=type_transaction_recieve_post, amount=amount, user_id=recieverid, senderid=sender_id, comment=commentid, orderid='', balance=newbalance_reciever) # add transaction for comments wallet except Exception as e: db.session.rollback()
def take_coin_from_tipper_btc_post(sender_id, amount, postid, recieverid): """ # From user wallet to user wallet # happens during a tip to post user_id0 transfers to user_id1 :param sender_id: :param amount: :param postid: :param recieverid: :return: """ try: type_transaction_tip_post = 6 senderwallet = BtcWallet.query.filter_by(user_id=sender_id).first() # remove amount from sender curbal_sender = Decimal(senderwallet.currentbalance) amounttomod = Decimal(amount) newbalance_sender = curbal_sender - amounttomod senderwallet.currentbalance = newbalance_sender db.session.add(senderwallet) # add transaction for senders wallet addtransaction(category=type_transaction_tip_post, amount=amount, user_id=sender_id, senderid=recieverid, comment='', orderid=postid, balance=newbalance_sender) # add transaction for comments wallet except Exception as e: db.session.rollback()
def sendcointosite_post_promotion_btc(sender_id, amount, postid, room): """ # From user wallet to user wallet # happens during a tip to comment user_id0 transfers to user_id1 :param sender_id: :param amount: :param postid: :param room: :return: """ try: type_transaction_tip_comment = 8 type_transaction_recieve_comment = 9 senderwallet = BtcWallet.query.filter_by(user_id=sender_id).first() recieverwallet = BtcWallet.query.filter_by(user_id=1).first() # remove amount from sender curbal_sender = Decimal(senderwallet.currentbalance) amounttomod = Decimal(amount) newbalance_sender = curbal_sender - amounttomod senderwallet.currentbalance = newbalance_sender db.session.add(senderwallet) # add amount to commenter curbal_reciever = Decimal(recieverwallet.currentbalance) amounttomod = Decimal(amount) newbalance_reciever = curbal_reciever + amounttomod recieverwallet.currentbalance = newbalance_reciever db.session.add(recieverwallet) # add transaction for senders wallet addtransaction(category=type_transaction_tip_comment, amount=amount, user_id=sender_id, senderid=1, comment=room, orderid=postid, balance=newbalance_sender) # add transaction to sites wallet addtransaction(category=type_transaction_recieve_comment, amount=amount, user_id=1, senderid=sender_id, comment=room, orderid=postid, balance=newbalance_reciever) # add transaction for comments wallet except Exception as e: db.session.rollback()
def sendcoin_user_daily_btc(user_id, amount): """ :param user_id: :param amount: :return: """ type_transaction_send_daily = 17 type_transaction_recieve_daily = 18 sender_wallet = BtcWallet.query.filter_by(user_id=1).first() recieve_wallet = BtcWallet.query.filter( BtcWallet.user_id == user_id).first() # remove amount from tipvote wallet curbal_sender = Decimal(sender_wallet.currentbalance) amount_sent_modified_decimal = Decimal(amount) newbalance_sender = curbal_sender - amount_sent_modified_decimal sender_wallet.currentbalance = newbalance_sender # add amount to user current_balance_reciever = Decimal(recieve_wallet.currentbalance) amount_recieve_modified_decimal = Decimal(amount) newbalance_reciever = current_balance_reciever + amount_recieve_modified_decimal recieve_wallet.currentbalance = newbalance_reciever # add transaction for tipvote wallet addtransaction(category=type_transaction_send_daily, amount=amount, user_id=1, senderid=user_id, comment='daily reward', orderid=0, balance=newbalance_sender) # add transaction to reciver wallet addtransaction(category=type_transaction_recieve_daily, amount=amount, user_id=user_id, senderid=1, comment='daily reward', orderid=0, balance=newbalance_reciever) db.session.add(sender_wallet) db.session.add(recieve_wallet) db.session.commit()