Exemplo n.º 1
0
def accepted_order(request):
    result = {'code': 100, 'log': 'order accepted success'}
    re_data = None
    try:
        data = Checker.request(request, ['orderID', 'phone', 'distance'])
        format_time = time.strftime('%Y.%m.%d;%H:%M', time.localtime(time.time()))
        order = OrderProxy(int(data['orderID']))
        if order.accepted:
            raise OrderHasAccepted
        order = order.update(bar_phone=data['phone'], time_=format_time, accepted=True).get_dict()
        barber = BarberProxy(data['phone'])
        order['distance'], order['shop'], order['address'] = data['distance'], barber.shop, barber.address
        notify_cus_order_accepted(order)
    except JianyueError as e:
        result = e.info
    finally:
        result['data'] = re_data
        return HttpResponse(encode(result))
Exemplo n.º 2
0
def accepted_order(request):
    result = {'code': 100, 'log': 'Order has been accepted successfully.'}
    re_data = None
    try:
        #result = {'code': 100, 'log': 'Order has been accepted successfully.'}
        data = Checker.request(request, ['orderID', 'phone', 'distance'])
        time_ = current_time()
        order = OrderProxy(int(data['orderID']))
        if order.accepted:
            raise OrderHasAccepted
        order = order.update(bar_phone=data['phone'], time_=time_, accepted=True).get_dict()
        barber = BarberProxy(data['phone'])
        order['distance'], order['shop'], order['address'] = data['distance'], barber.shop, barber.address
        notify_cus_order_accepted(order)
    except JianyueError as e:
        result = e.info
    finally:
        result['data'] = re_data
        return HttpResponse(encode(result))