Пример #1
0
def voiceorder_job():
    """ query all unprocessed orders from now

    """

    now = time.time()
    ORDER_CONST = thirdparty_svc.eos.ElemeOrderConst
    order_trigger_time = int(now - settings.send_vc_deadline)

    order_query = thirdparty_svc.eos.TOrderQuery()
    order_query.from_datetime = order_trigger_time
    order_query.statuses = (ORDER_CONST.STATUS_PROCESSING,)
    order_query.order_modes = (ORDER_CONST.ORDER_MODE_ELEME,)
    order_query.limit = 1000
    with thrift_client('eos') as eos:
        orders = _filter_orders(eos.query_order(order_query))

    log.info('total {} unprocessed sms orders.'.format(len(orders)))
    if _trigger_voicecall(
            orders,
            order_trigger_time,
            order_trigger_time + settings.voice_order_interval - 1):

        log.info('triggered voicecall with orders {}'.format(orders))
        enqueue(BSTALK_TUBES['tube_vo'], voice_order_handler, orders)
Пример #2
0
def process_order():
    """ get unprocessed order, put into beanstalk handlers """
    # 短信订单 & 第三方配送订单
    order_modes = (thirdparty_svc.eos.ElemeOrderConst.ORDER_MODE_ELEME,
                   thirdparty_svc.eos.ElemeOrderConst.ORDER_MODE_TPD_ELEME)
    with thrift_client('eos') as eos:
        order_ids = eos.get_unprocessed_order_ids(order_modes)

    if not order_ids:
        return

    for order_id in order_ids:
        enqueue(BSTALK_TUBES['tube_order_auto_proc'], auto_process_order,
                order_id)
Пример #3
0
def process_order():
    """ get unprocessed order, put into beanstalk handlers """
    # 短信订单 & 第三方配送订单
    order_modes = (thirdparty_svc.eos.ElemeOrderConst.ORDER_MODE_ELEME,
                   thirdparty_svc.eos.ElemeOrderConst.ORDER_MODE_TPD_ELEME)
    with thrift_client('eos') as eos:
        order_ids = eos.get_unprocessed_order_ids(order_modes)

    if not order_ids:
        return

    for order_id in order_ids:
        enqueue(
            BSTALK_TUBES['tube_order_auto_proc'],
            auto_process_order,
            order_id
        )
Пример #4
0
def voicecall_job():
    """ get calls from database, and send call request

    """
    not_dialed_calls = VoiceCall.get_by_status(VoiceCall.STATUS_NOT_DIAL)
    if not not_dialed_calls:
        return

    calls = _filter_calls(not_dialed_calls)
    if not calls:
        return

    for call in calls:
        # lock voice call
        if not lock(get_call_lock_key(call.id), time_out=30):
            continue

        # lock restaurant's line
        if lock(get_rst_lock_key(call.restaurant_id)):
            enqueue(BSTALK_TUBES['tube_vo'], voice_call_handler, call.id)
        else:
            unlock(get_call_lock_key(call.id))
Пример #5
0
def voicecall_job():
    """ get calls from database, and send call request

    """
    not_dialed_calls = VoiceCall.get_by_status(VoiceCall.STATUS_NOT_DIAL)
    if not not_dialed_calls:
        return

    calls = _filter_calls(not_dialed_calls)
    if not calls:
        return

    for call in calls:
        # lock voice call
        if not lock(get_call_lock_key(call.id), time_out=30):
            continue

        # lock restaurant's line
        if lock(get_rst_lock_key(call.restaurant_id)):
            enqueue(BSTALK_TUBES['tube_vo'], voice_call_handler, call.id)
        else:
            unlock(get_call_lock_key(call.id))
Пример #6
0
def voiceorder_job():
    """ query all unprocessed orders from now

    """

    now = time.time()
    ORDER_CONST = thirdparty_svc.eos.ElemeOrderConst
    order_trigger_time = int(now - settings.send_vc_deadline)

    order_query = thirdparty_svc.eos.TOrderQuery()
    order_query.from_datetime = order_trigger_time
    order_query.statuses = (ORDER_CONST.STATUS_PROCESSING, )
    order_query.order_modes = (ORDER_CONST.ORDER_MODE_ELEME, )
    order_query.limit = 1000
    with thrift_client('eos') as eos:
        orders = _filter_orders(eos.query_order(order_query))

    log.info('total {} unprocessed sms orders.'.format(len(orders)))
    if _trigger_voicecall(
            orders, order_trigger_time,
            order_trigger_time + settings.voice_order_interval - 1):

        log.info('triggered voicecall with orders {}'.format(orders))
        enqueue(BSTALK_TUBES['tube_vo'], voice_order_handler, orders)