Exemple #1
0
def gen_order(request):
    cartids = request.GET.get('cartids')
    cartids = cartids.split('=')
    print(cartids)

    order = Order()
    username = request.session.get('username')
    user = User.objects.get(u_name=username)

    order.o_user = user
    order.o_status = 1
    order.save()

    # 修改商品属于哪张表
    for cartid in cartids:
        car = Cart.objects.get(pk=cartid)
        car.c_belong = True
        car.c_order = order
        car.save()

    return JsonResponse({'msg': 'ok', 'orderid': order.id})
Exemple #2
0
def genorder(request):
    cartids = request.GET.get('cartids')
    # 列表拆分
    cartids = cartids.split('#')
    # print(cartids)

    # 生成订单  将要购买的商品转换到订单表中,生成订单信息,将购买的商品的订单信息关联
    order = Order()
    username = request.session.get('username')
    user = User.objects.get(u_name=username)
    #
    order.o_user = user
    # 定义状态 0,默认生成状态 , 1 ,已下单未付款 , 2 已付款  ,3 已付款并已发货....
    order.o_status = 1
    order.save()
    # order 在存储之后就有id了
    for item in cartids:
        car = Cart.objects.get(pk=item)
        #  修改属于那张表
        car.c_belong = True
        car.c_order = order
        car.save()

    return JsonResponse({'msg': 'ok', 'orderid': order.id})