Example #1
0
def make_order(request):

    cartlist = request.GET.get("cartlist")

    cart_list = cartlist.split("#")

    order = Order()

    user_id = request.session.get('user_id')

    order.o_user_id = user_id

    order.o_total_price = get_total_price(user_id)

    order.save()

    for cart_id in cart_list:

        ordergoods = OrderGoods()

        cart_obj = Cart.objects.get(pk=cart_id)

        ordergoods.o_goods_num = cart_obj.c_goods_num

        ordergoods.o_order_id = order.id

        ordergoods.o_goods_id = cart_obj.c_goods_id

        ordergoods.save()

        cart_obj.delete()

    data = {
        "msg": "ok",
        "orderid": order.id,
        "status": "200",
    }

    return JsonResponse(data)
Example #2
0
def make_order(request):
    cartlist = request.GET.get('cartlist')
    cart_list = cartlist.split('#')
    order = Order()
    user_id = request.session.get('user_id')
    order.o_user_id = user_id
    order.o_total_price = get_total_price(user_id)
    order.save()

    for cart_id in cart_list:
        ordergoods = OrderGoods()
        cart_obj = Cart.objects.get(pk=cart_id)
        ordergoods.o_goods_num = cart_obj.c_goods_num
        ordergoods.o_order_id = order.id
        ordergoods.o_goods_id = cart_obj.c_goods_id
        ordergoods.save()
        cart_obj.delete()

    data = {
        'msg': 'ok',
        'orderid': order.id,
        'status': '200',
    }
    return JsonResponse(data)