Exemplo n.º 1
0
def checkIfSellApp(*args, **kwargs):
    """
        The task will be done every hour.
        When service stop, if bidding price is more than max price, seller has 7 days to trade now. Then seller did not
        trade app in 7 days, seller's credit points will be decreased.
    """
    transactions = txnModels.Transaction.objects.filter(
        status=1,
        end_time__isnull=False,
        end_time__lte=datetime.datetime.now()).exclude(buy_type=1)
    massEmailThread = email.MassEmailThread()
    points = common.getSystemParam(key='cp_buyer_unpaid', default=50)
    log.info("----")
    for transaction in transactions:
        log.info(transaction.id)
        #Decrease seller's credit points
        creditViews.decreaseCreditPoint(user=transaction.seller,
                                        point=string.atoi(points),
                                        type=1,
                                        ref_id=transaction.id)
        templates = notificationModels.NotificationTemplate.objects.filter(
            name='unsold_end_inform_seller')
        if templates:
            subject = templates[0].subject
            message = templates[0].template.replace(
                '{param1}',
                transaction.seller.username).replace('{param2}', points)
            massEmailThread.addEmailData(
                subject=subject,
                message=message,
                recipient_list=[transaction.seller.email])
    massEmailThread.start()
    return None
Exemplo n.º 2
0
def taskForBuyUnpaid(*args, **kwargs):
    """
        The task will be done in at schedule time, such as: every hour.
        Do something, if buy still unpaid after 7 days of paid_expiry_date set in system-param table.
        1. Change transaction is_active from True to False.
        2. Buyer will be subtracted 50 credit point, and put into blacklist.
        3. Buyer's all bidding status is changed from approved to rejected.(Note: All bidding for this buyer.)
        4. Send email to buyer.(The email: 1.Subtract his 50 credit point; 2.Put him into blacklist.)
        5. Send email to seller.(The email: 1.Seller may choice the buyer bidding with second max price to trade again;
                                            2.The unpaid buyer has been put into blacklist.)
        6. Send email to new buyer bidding with second max price. (The email: 1. He is the max bidding one now;
                                            2. Seller will trade with you later.)
    """
    points = string.atoi(common.getSystemParam(key='cp_no_closed_trade', default=50))
    templates_buyer = notificationModels.NotificationTemplate.objects.filter(name='buyer_unpaid_inform_buyer')
    templates_seller = notificationModels.NotificationTemplate.objects.filter(name='buyer_unpaid_inform_seller')
    templates_second_buyer = notificationModels.NotificationTemplate.objects.filter(name='buyer_unpaid_inform_second_buyer')
    templates_seller_no_bidding = notificationModels.NotificationTemplate.objects.filter(name='buyer_unpaid_inform_seller_no_bidding')

    transactions = txnModels.Transaction.objects.filter(is_active=True, status=2, end_time__lte=datetime.datetime.now())
    massEmailThread = email.MassEmailThread()
    for transaction in transactions:
        transaction.is_active = False
        transaction.save()
        creditViews.decreaseCreditPoint(user=transaction.buyer, point=points, type=1, ref_id=transaction.id)
        bidModels.Bidding.objects.filter(app_id=transaction.app.id, buyer_id=transaction.buyer.id).update(status=False)
        if templates_buyer:
            subject = templates_buyer[0].subject
            message = templates_buyer[0].template.replace('{param1}', transaction.buyer.username)
            massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[transaction.buyer.email])
        bidding = bidModels.Bidding.objects.filter(app_id=transaction.app.id, status=1).order_by('-price')
        if bidding:
            if templates_seller:
                subject = templates_seller[0].subject
                message = templates_seller[0].template.replace('{param1}', transaction.seller.username).replace('{param2}', transaction.buyer.username)
                massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[transaction.seller.email])
            if templates_second_buyer:
                subject = templates_second_buyer[0].subject
                message = templates_second_buyer[0].template.replace('{param1}', bidding[0].buyer.username).replace('{param2}', transaction.app.app_name)
                massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[bidding[0].buyer.email])
        else:
            if templates_seller_no_bidding:
                subject = templates_seller_no_bidding[0].subject
                message = templates_seller_no_bidding[0].template.replace('{param1}', transaction.seller.username)
                massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[transaction.seller.email])
    massEmailThread.start()

    return None
Exemplo n.º 3
0
def checkIfSellApp(*args, **kwargs):
    """
        The task will be done every hour.
        When service stop, if bidding price is more than max price, seller has 7 days to trade now. Then seller did not
        trade app in 7 days, seller's credit points will be decreased.
    """
    transactions = txnModels.Transaction.objects.filter(status=1, end_time__isnull=False, end_time__lte=datetime.datetime.now()).exclude(buy_type=1)
    massEmailThread = email.MassEmailThread()
    points = common.getSystemParam(key='cp_buyer_unpaid', default=50)
    log.info("----")
    for transaction in transactions:
        log.info(transaction.id)
        #Decrease seller's credit points
        creditViews.decreaseCreditPoint(user=transaction.seller, point=string.atoi(points), type=1, ref_id=transaction.id)
        templates = notificationModels.NotificationTemplate.objects.filter(name='unsold_end_inform_seller')
        if templates:
            subject = templates[0].subject
            message = templates[0].template.replace('{param1}', transaction.seller.username).replace('{param2}', points)
            massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[transaction.seller.email])
    massEmailThread.start()
    return None
Exemplo n.º 4
0
def taskForBuyUnpaid(*args, **kwargs):
    """
        The task will be done in at schedule time, such as: every hour.
        Do something, if buy still unpaid after 7 days of paid_expiry_date set in system-param table.
        1. Change transaction is_active from True to False.
        2. Buyer will be subtracted 50 credit point, and put into blacklist.
        3. Buyer's all bidding status is changed from approved to rejected.(Note: All bidding for this buyer.)
        4. Send email to buyer.(The email: 1.Subtract his 50 credit point; 2.Put him into blacklist.)
        5. Send email to seller.(The email: 1.Seller may choice the buyer bidding with second max price to trade again;
                                            2.The unpaid buyer has been put into blacklist.)
        6. Send email to new buyer bidding with second max price. (The email: 1. He is the max bidding one now;
                                            2. Seller will trade with you later.)
    """
    points = string.atoi(
        common.getSystemParam(key='cp_no_closed_trade', default=50))
    templates_buyer = notificationModels.NotificationTemplate.objects.filter(
        name='buyer_unpaid_inform_buyer')
    templates_seller = notificationModels.NotificationTemplate.objects.filter(
        name='buyer_unpaid_inform_seller')
    templates_second_buyer = notificationModels.NotificationTemplate.objects.filter(
        name='buyer_unpaid_inform_second_buyer')
    templates_seller_no_bidding = notificationModels.NotificationTemplate.objects.filter(
        name='buyer_unpaid_inform_seller_no_bidding')

    transactions = txnModels.Transaction.objects.filter(
        is_active=True, status=2, end_time__lte=datetime.datetime.now())
    massEmailThread = email.MassEmailThread()
    for transaction in transactions:
        transaction.is_active = False
        transaction.save()
        creditViews.decreaseCreditPoint(user=transaction.buyer,
                                        point=points,
                                        type=1,
                                        ref_id=transaction.id)
        bidModels.Bidding.objects.filter(
            app_id=transaction.app.id,
            buyer_id=transaction.buyer.id).update(status=False)
        if templates_buyer:
            subject = templates_buyer[0].subject
            message = templates_buyer[0].template.replace(
                '{param1}', transaction.buyer.username)
            massEmailThread.addEmailData(
                subject=subject,
                message=message,
                recipient_list=[transaction.buyer.email])
        bidding = bidModels.Bidding.objects.filter(app_id=transaction.app.id,
                                                   status=1).order_by('-price')
        if bidding:
            if templates_seller:
                subject = templates_seller[0].subject
                message = templates_seller[0].template.replace(
                    '{param1}', transaction.seller.username).replace(
                        '{param2}', transaction.buyer.username)
                massEmailThread.addEmailData(
                    subject=subject,
                    message=message,
                    recipient_list=[transaction.seller.email])
            if templates_second_buyer:
                subject = templates_second_buyer[0].subject
                message = templates_second_buyer[0].template.replace(
                    '{param1}', bidding[0].buyer.username).replace(
                        '{param2}', transaction.app.app_name)
                massEmailThread.addEmailData(
                    subject=subject,
                    message=message,
                    recipient_list=[bidding[0].buyer.email])
        else:
            if templates_seller_no_bidding:
                subject = templates_seller_no_bidding[0].subject
                message = templates_seller_no_bidding[0].template.replace(
                    '{param1}', transaction.seller.username)
                massEmailThread.addEmailData(
                    subject=subject,
                    message=message,
                    recipient_list=[transaction.seller.email])
    massEmailThread.start()

    return None