Beispiel #1
0
def check_order(request, pk):
    ''' 订单审核 '''
    user_id = request.user['id']
    token = request.user['token']
    order = OrderService().order_check(user_id=user_id, order_id=pk)
    orders = OrderService().route_order(user_id=user_id,
                                        order_id=order.id,
                                        token=token)
    serializer = OrderSerializer(orders, many=True)
    return JsonResponse(serializer.data, status=status.HTTP_200_OK)
Beispiel #2
0
def lock_order(request, pk):
    ''' 订单锁定 '''
    user_id = request.user['id']
    lock_reanson = request.data.get('lock_reanson')
    order = OrderService().\
        lock_order(user_id=user_id, order_id=pk, lock_reanson=lock_reanson)
    serializer = OrderSerializer(order)
    return JsonResponse(data=serializer.data, status=status.HTTP_200_OK)
Beispiel #3
0
def create_or_list(request):
    ''' 订单创建或获取列表 '''
    user_id = request.user['id']
    user_name = request.user['nickname']
    if request.method == 'POST':
        order = OrderService().\
            create(user_id=user_id, data=request.data, user_name=user_name)
        serializer = OrderSerializer(order)
        return JsonResponse(serializer.data, status=status.HTTP_201_CREATED)
    elif request.method == 'GET':
        data = request.GET
        page = int(data.get('page_index', 1))
        paginator = OrderService().\
            list(user_id=user_id, kwargs=data)
        paginator.current_page = page
        paginator.serializer = OrderSerializer
        return JsonResponse(paginator, status=status.HTTP_200_OK)
Beispiel #4
0
def get_or_update(request, pk):
    ''' 订单获取详情或更新 '''
    user_id = request.user['id']
    if request.method == 'GET':
        order = OrderService().get(user_id=user_id, order_id=pk)
        serializer = OrderSerializer(order)
        return JsonResponse(serializer.data, status=status.HTTP_200_OK)
    elif request.method == 'POST':
        result = OrderService().\
            update(user_id=user_id, order_id=pk, data=request.data)
        if result:
            serializer = OrderSerializer(result)
            return JsonResponse(serializer.data, status=status.HTTP_200_OK)
        else:
            data = None
            return JsonResponse(data, msg='failed', status=status.HTTP_200_OK)
    elif request.method == 'PATCH':
        print("patch")
        order = OrderService().patch_update(order_id=pk, data=request.data)
        serializer = OrderSerializer(order)
        return JsonResponse(data=serializer.data, status=status.HTTP_200_OK)
Beispiel #5
0
def withdraw_order(request, pk):
    ''' 订单撤回 '''
    user_id = request.user['id']
    order = OrderService().withdraw_order(user_id=user_id, order_id=pk)
    serializer = OrderSerializer(order)
    return JsonResponse(data=serializer.data, status=status.HTTP_200_OK)
Beispiel #6
0
def get_order_details(request):
    ''' 获取订单详情(废弃) '''
    order_id = 1
    order_details = OrderService().get_sku_infoes(order_id=order_id)
    serializer = OrderDetailSerializer(order_details, many=True)
    return JsonResponse(serializer.data, status=status.HTTP_200_OK)
Beispiel #7
0
def delete_order(request, pk):
    ''' 删除订单 '''
    user_id = request.user['id']
    order = OrderService().delete_order(user_id=user_id, order_id=pk)
    serializer = OrderSerializer(order)
    return JsonResponse(data=serializer.data, status=status.HTTP_200_OK)