示例#1
0
def main():
    time_now = datetime.datetime.now()
    end_time = time_now - datetime.timedelta(minutes=15)
    start_time = time_now - datetime.timedelta(minutes=30)

    # Orders that are only in cart state or buy later and not booked by an agent (if booked by agent a response already exists)
    cod_verifications = CodOrderVerification.objects.select_related(
        'order').filter(created_on__range=(start_time, end_time),
                        is_verified=False)

    for x in cod_verifications:
        order = x.order
        if order.support_state == 'booked':  # still its a pending order
            try:
                phones = Phone.objects.filter(phone=x.mobile_no)
                if phones:  # Phone number entered by user for COD verification
                    phone = phones[0]

                campaign = None
                response = None
                ''' FB COD verification Campaign id is xx '''
                campaign = Campaign.objects.get(id=38)

                if campaign and phone:
                    response = get_or_create_response(campaign=campaign,
                                                      phone=phone,
                                                      type='outbound',
                                                      medium=order.medium)
                    if response:
                        response.orders.add(order)
                        response.save()
                        # add interaction for detail information
                        notes = "order id: %s." % (order.reference_order_id)
                        if order.user != phone.user:
                            notes = notes + " Call using eyebeam directly. Response phone number does not belong to the user placing this order."
                        interaction = Interaction(response=response,
                                                  communication_mode='call',
                                                  notes=notes)
                        interaction.save()
                    else:
                        log.info(
                            "===COD Verification===  Cannot create response: %s"
                            % phone)
            except Exception as e:
                log.info("===COD verification=== %s" % e)
示例#2
0
def main():
    time_now = datetime.datetime.now()
    end_time = time_now - datetime.timedelta(minutes=15)
    start_time = time_now -  datetime.timedelta(minutes=30)

    # Orders that are only in cart state or buy later and not booked by an agent (if booked by agent a response already exists)
    cod_verifications = CodOrderVerification.objects.select_related('order').filter(
            created_on__range = (start_time,
            end_time),is_verified=False)

    for x in cod_verifications:
        order = x.order
        if order.support_state == 'booked':     # still its a pending order
            try:
                phones = Phone.objects.filter(phone=x.mobile_no)
                if phones:      # Phone number entered by user for COD verification
                    phone = phones[0]
                    
                campaign = None
                response = None
                ''' FB COD verification Campaign id is xx '''
                campaign = Campaign.objects.get(id=38)

                if campaign and phone:
                    response = get_or_create_response(campaign=campaign, phone=phone, type='outbound', medium=order.medium)
                    if response:
                        response.orders.add(order)
                        response.save()
                        # add interaction for detail information
                        notes = "order id: %s." %(order.reference_order_id)
                        if order.user != phone.user:
                            notes = notes + " Call using eyebeam directly. Response phone number does not belong to the user placing this order."
                        interaction = Interaction(response = response, communication_mode = 'call', notes = notes)
                        interaction.save()
                    else:
                        log.info("===COD Verification===  Cannot create response: %s" % phone)
            except Exception as e:
                log.info("===COD verification=== %s" %e)
示例#3
0
def main():
    time_now = datetime.datetime.now()
    end_time = time_now - datetime.timedelta(minutes=15)
    start_time = time_now - datetime.timedelta(minutes=30)

    """ Payment Attempts that are in pending """
    pa = (
        PaymentAttempt.objects.select_related("order,order__user,order__user__user")
        .filter(
            status__in=("pending realization", "rejected"),
            created_on__range=(start_time, end_time),
            order__support_state="booked",
            order__booking_agent__isnull=True,
            order__confirming_agent__isnull=True,
            order__agent__isnull=True,
        )
        .exclude(payment_mode__in=utils.DEFERRED_PAYMENT_MODES)
    )
    for attempt in pa:
        try:
            """ Getting the 1st phone number if exists """
            phones = Phone.objects.filter(user=attempt.order.user_id)[:1]
            if phones:
                phone = phones[0]

                campaign = None
                response = None

                """ Select campaign as per client """
                if attempt.order.client.id == 5:
                    """ Abandon Payment Campaign id is 22 """
                    campaign = Campaign.objects.get(id=22)

                elif attempt.order.client.id == 6:
                    """ Holii Abandoned Payment campaign id is 29 """
                    campaign = Campaign.objects.get(id=29)

                elif attempt.order.client.id == 1:
                    """ Chaupaati Abandoned Payment campaign id is 28 """
                    campaign = Campaign.objects.get(id=28)

                if campaign and phone:
                    response = get_or_create_response(
                        campaign=campaign, phone=phone, type="outbound", medium=attempt.order.medium
                    )
                    if response:
                        response.orders.add(attempt.order)
                        response.save()
                        notes = "order id: %s Order Amount: %s Login: %s Payment_mode: %s" % (
                            attempt.order.reference_order_id,
                            attempt.order.total,
                            attempt.order.user.user.username,
                            attempt.payment_mode,
                        )
                        interaction = Interaction(response=response, communication_mode="call", notes=notes)
                        interaction.save()
                        # TODO add interaction for providing details to agent
                    else:
                        log.info("===ABANDONED PAYMENT=== Unable to create response : %s " % phone)
                        # TODO Send an email
            else:
                log.info("===ABANDONED PAYMENT=== Unable to create response as no phone attached to user ")
                # TODO Send an email

        except Exception, e:
            log.info("===ABANDONED PAYMENT=== Exception %s" % repr(e))
示例#4
0
def main():
    time_now = datetime.datetime.now()
    end_time = time_now - datetime.timedelta(minutes=15)
    start_time = time_now - datetime.timedelta(minutes=30)
    ''' Payment Attempts that are in pending '''
    pa = PaymentAttempt.objects.select_related(
        'order,order__user,order__user__user').filter(
            status__in=('pending realization', 'rejected'),
            created_on__range=(start_time, end_time),
            order__support_state='booked',
            order__booking_agent__isnull=True,
            order__confirming_agent__isnull=True,
            order__agent__isnull=True).exclude(
                payment_mode__in=utils.DEFERRED_PAYMENT_MODES)
    for attempt in pa:
        try:
            ''' Getting the 1st phone number if exists '''
            phones = Phone.objects.filter(user=attempt.order.user_id)[:1]
            if phones:
                phone = phones[0]

                campaign = None
                response = None
                ''' Select campaign as per client '''
                if (attempt.order.client.id == 5):
                    ''' Abandon Payment Campaign id is 22 '''
                    campaign = Campaign.objects.get(id=22)

                elif (attempt.order.client.id == 6):
                    ''' Holii Abandoned Payment campaign id is 29 '''
                    campaign = Campaign.objects.get(id=29)

                elif (attempt.order.client.id == 1):
                    ''' Chaupaati Abandoned Payment campaign id is 28 '''
                    campaign = Campaign.objects.get(id=28)

                if campaign and phone:
                    response = get_or_create_response(
                        campaign=campaign,
                        phone=phone,
                        type='outbound',
                        medium=attempt.order.medium)
                    if response:
                        response.orders.add(attempt.order)
                        response.save()
                        notes = "order id: %s Order Amount: %s Login: %s Payment_mode: %s" % (
                            attempt.order.reference_order_id,
                            attempt.order.total,
                            attempt.order.user.user.username,
                            attempt.payment_mode)
                        interaction = Interaction(response=response,
                                                  communication_mode='call',
                                                  notes=notes)
                        interaction.save()
                        # TODO add interaction for providing details to agent
                    else:
                        log.info(
                            "===ABANDONED PAYMENT=== Unable to create response : %s "
                            % phone)
                        # TODO Send an email
            else:
                log.info(
                    "===ABANDONED PAYMENT=== Unable to create response as no phone attached to user "
                )
                # TODO Send an email

        except Exception, e:
            log.info("===ABANDONED PAYMENT=== Exception %s" % repr(e))