예제 #1
0
def add_cart(request):
    '''
    description:添加到购物车
    params:
    return:
    '''
    if request.method == 'POST':
        bm = BillsManager()
        user = request.user
        goods_id = request.POST.get('goods_id')
        conf = {}
        vender_user = bm.authtovender(user)
        try:
            goods = Goods.objects.get(id=goods_id)
            vg = Vender_Goods.objects.filter(goods=goods,
                                             vender=vender_user).exists()
            if (vg):
                v_g = Vender_Goods.objects.filter(goods=goods,
                                                  vender=vender_user).update(
                                                      is_cart=True,
                                                      cart_time=bm.now_time())
            else:
                vender_goods = Vender_Goods(goods=goods,
                                            vender=vender_user,
                                            is_cart=True,
                                            cart_time=bm.now_time())
                vender_goods.save()
            conf = {'status': 'SUCCESS'}
        except Exception as e:
            conf = {'status': 'FAILURE'}
        return HttpResponse(json.dumps(conf))
    else:
        raise Http404
예제 #2
0
def add_cart(request):
    '''
    description:添加到购物车
    params:
    return:
    '''
    if request.method == 'POST':
        bm = BillsManager()
        user = request.user
        goods_id = request.POST.get('goods_id')
        conf = {}
        vender_user = bm.authtovender(user)
        try:
            goods = Goods.objects.get(id=goods_id)
            vg = Vender_Goods.objects.filter(goods=goods,vender=vender_user).exists()
            if (vg):
                v_g = Vender_Goods.objects.filter(goods=goods,vender=vender_user).update(is_cart=True,cart_time=bm.now_time())
            else:
                vender_goods = Vender_Goods(goods=goods,
                        vender=vender_user,
                        is_cart=True,
                        cart_time=bm.now_time())
                vender_goods.save()
            conf = {'status':'SUCCESS'}
        except Exception as e:
            conf = {'status':'FAILURE'}
        return HttpResponse(json.dumps(conf))
    else:
        raise Http404
예제 #3
0
def pay_detail_return(bills):
    '''
    description:返回商品详情页
    params:
    return:
    '''
    bm = BillsManager()
    vender_user = bills.vender
    goods_bills = Goods_Bills.objects.filter(bills=bills)
    for gb in goods_bills:
        goods = gb.goods
        vg = Vender_Goods.objects.filter(goods=goods,vender=vender_user).exists()
        if(vg):
            v_g = Vender_Goods.objects.filter(goods=goods,vender=vender_user).update(is_buy=True,buy_time=bm.now_time())
        else:
            vender_goods = Vender_Goods(goods=goods,
                vender=vender_user,
                is_buy=True,
                buy_time=bm.now_time())
            vender_goods.save()        
    return goods
예제 #4
0
def pay_detail_return(bills):
    '''
    description:返回商品详情页
    params:
    return:
    '''
    bm = BillsManager()
    vender_user = bills.vender
    goods_bills = Goods_Bills.objects.filter(bills=bills)
    for gb in goods_bills:
        goods = gb.goods
        vg = Vender_Goods.objects.filter(goods=goods,
                                         vender=vender_user).exists()
        if (vg):
            v_g = Vender_Goods.objects.filter(
                goods=goods, vender=vender_user).update(is_buy=True,
                                                        buy_time=bm.now_time())
        else:
            vender_goods = Vender_Goods(goods=goods,
                                        vender=vender_user,
                                        is_buy=True,
                                        buy_time=bm.now_time())
            vender_goods.save()
    return goods