def update_keysback(): """ Get back voice call's keys which restaurant inputs """ ElemeOrderConst = thirdparty_svc.eos.ElemeOrderConst OrderRecordConst = thirdparty_svc.eos.OrderRecordConst args = request.args if request.method == 'GET' else request.form log.info('Keysback args: %s' % args.items()) order_id = to_int(args.get('orderId')) key_pressed = to_int(args.get('press')) call_id = to_int(args.get('userField'), silence=False) voice_order = VoiceOrder.get_by_order_id(order_id) if key_pressed == KEY_AFFIRM: status_to = ElemeOrderConst.STATUS_PROCESSED_AND_VALID with thrift_client('eos') as eos: eos.eleme_process_order(order_id, status_to, OrderRecordConst.PROCESSED_BY_MACHINE, OrderRecordConst.PROCESS_GROUP_ADMIN, '', 0) voice_order.status_code = status_to log.info('update eleme order to status: %d.' % status_to) elif key_pressed == KEY_BAN_TODAY: restaurant_id = VoiceCall.get(call_id).restaurant_id VoicecallBan.add(restaurant_id, VoicecallBan.BAN_TYPE_TODAY) log.info('add voice call ban for restaurant {}'.format(restaurant_id)) voice_order.key_pressed = key_pressed return {'result': 'success'}
def update_keysback(): """ Get back voice call's keys which restaurant inputs """ ElemeOrderConst = thirdparty_svc.eos.ElemeOrderConst OrderRecordConst = thirdparty_svc.eos.OrderRecordConst args = request.args if request.method == 'GET' else request.form log.info('Keysback args: %s' % args.items()) order_id = to_int(args.get('orderId')) key_pressed = to_int(args.get('press')) call_id = to_int(args.get('userField'), silence=False) voice_order = VoiceOrder.get_by_order_id(order_id) if key_pressed == KEY_AFFIRM: status_to = ElemeOrderConst.STATUS_PROCESSED_AND_VALID with thrift_client('eos') as eos: eos.eleme_process_order( order_id, status_to, OrderRecordConst.PROCESSED_BY_MACHINE, OrderRecordConst.PROCESS_GROUP_ADMIN, '', 0) voice_order.status_code = status_to log.info('update eleme order to status: %d.' % status_to) elif key_pressed == KEY_BAN_TODAY: restaurant_id = VoiceCall.get(call_id).restaurant_id VoicecallBan.add(restaurant_id, VoicecallBan.BAN_TYPE_TODAY) log.info('add voice call ban for restaurant {}'.format( restaurant_id)) voice_order.key_pressed = key_pressed return {'result': 'success'}
def _filter_calls(calls): """ filter calls by banned restaurant ids """ banned_restaurants = VoicecallBan.mget_by_restaurant_ids( [c.restaurant_id for c in calls]) if not banned_restaurants: return calls banned_restaurant_ids = [b.restaurant_id for b in banned_restaurants] call_results = [] for call in calls: if call.restaurant_id in banned_restaurant_ids: call.update(VoiceCall.STATUS_BANNED) else: call_results.append(call) return call_results
def voicecall_ban_daily_clean_job(): """ clean voicecall banned restaurant info in middle night """ log.info('cleaning voicecall restaurant ban.') VoicecallBan.clean_today_ban()