Ejemplo n.º 1
0
def sendcoin_subowner_bch_comment(sender_id, amount, commentid, recieverid):

    try:

        type_transaction_recieve_post = 10

        recieverwallet = BchWallet.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
        bch_cash_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:
        db.session.rollback()
Ejemplo n.º 2
0
def sendcoin_to_poster_bch_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 = BchWallet.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
        bch_cash_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()
Ejemplo n.º 3
0
def take_coin_from_tipper_bch_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 = BchWallet.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
        bch_cash_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:
        db.session.rollback()
Ejemplo n.º 4
0
def sendcointosite_post_promotion_bch(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:
    :return:
    """
    try:
        type_transaction_tip_comment = 8
        type_transaction_recieve_comment = 9

        senderwallet = BchWallet.query.filter_by(user_id=sender_id).first()
        recieverwallet = BchWallet.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
        bch_cash_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
        bch_cash_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()
Ejemplo n.º 5
0
def sendcoin_user_daily_bch(user_id, amount):
    """
    :param user_id:
    :param amount:
    :return:
    """

    type_transaction_send_daily = 15
    type_transaction_recieve_daily = 16

    sender_wallet = BchWallet.query.filter_by(user_id=1).first()
    recieve_wallet = BchWallet.query.filter(
        BchWallet.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
    bch_cash_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
    bch_cash_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()
def send_coin_to_site_purchase(sender_id, amount, roomid):

    type_transaction_buy_room = 20
    type_transaction_user_purchased_room = 21

    senderwallet = BchWallet.query.filter_by(user_id=sender_id).first()
    recieverwallet = BchWallet.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
    bch_cash_addtransaction(category=type_transaction_buy_room,
                            amount=amount,
                            user_id=sender_id,
                            senderid=1,
                            comment=roomid,
                            orderid=0,
                            balance=newbalance_sender)
    # add transaction to sites wallet
    bch_cash_addtransaction(category=type_transaction_user_purchased_room,
                            amount=amount,
                            user_id=1,
                            senderid=sender_id,
                            comment=roomid,
                            orderid=0,
                            balance=newbalance_reciever)