Beispiel #1
0
def buyIt(request):
    buid = getBuid(request);
    addtime = datetime.datetime.now();
    IP = getRealIP(request);
    cartInfo = {};
    cartInfo['addr_id'] = request.REQUEST.get('addr_id',0);
    cartInfo['book_id'] = request.REQUEST.get('book_id',1);
    cartInfo['num'] = request.REQUEST.get('num',1);
    cartInfo['total'] = request.REQUEST.get('total',0);
    cartInfo['addip'] = IP;
    cartInfo['addtime'] = addtime;
    cartInfo['buid'] = buid;
    addrInfo = {};
    addrInfo['buid'] = buid;
    addrInfo['name'] = request.REQUEST.get('name',0);
    addrInfo['phone'] = request.REQUEST.get('phone',0);
    addrInfo['province']= request.REQUEST.get('province',0);
    addrInfo['city']= request.REQUEST.get('province',0);
    addrInfo['detail_addr']= request.REQUEST.get('detail_addr',0);
    addrInfo['addip']= IP;
    addrInfo['addtime'] = addtime;
    addrInfo['require']= request.REQUEST.get('require',0);
    addrInfo['postalcode']= request.REQUEST.get('postCode',0);
    addrInsert(addrInfo);
    status = cartInsert(cartInfo);
    if status is None:
        return HttpResponse(simplejson.dumps({'status': '0', 'message':'购买失败!','data':""},
                                  ensure_ascii=False), content_type='application/json');
    return HttpResponse(simplejson.dumps({'status': '1', 'message':'成功!','data':""},
                                  ensure_ascii=False), content_type='application/json');
Beispiel #2
0
def buynow(request, id):
    buid = getBuid(request)
    oneBook = getOneBook(id)
    addr = getUserAddr(buid)
    if len(addr) == 0:
        return render_to_response(
            'cart/buy.html', {
                'id': oneBook[0][0],
                'path': oneBook[0][4],
                'name': oneBook[0][1],
                'price': oneBook[0][2],
                'carriage': oneBook[0][3]
            })
    return render_to_response(
        'cart/buyaddr.html', {
            'id': oneBook[0][0],
            'path': oneBook[0][4],
            'name': oneBook[0][1],
            'price': oneBook[0][2],
            'carriage': oneBook[0][3],
            'addrid': addr[0][0],
            'username': addr[0][2],
            'phone': addr[0][3],
            'province': addr[0][4],
            'detail_addr': addr[0][6],
            'postalcode': addr[0][7],
            'require': addr[0][8]
        })
Beispiel #3
0
def payView(request):
    buid = getBuid(request);
    cart = getCart(buid);
    if cart is not None:
        return render_to_response('cart/pay.html',{'cart':{
           'cart_id':cart[0][0],'should_pay':cart[0][1],'num':cart[0][2],'price':cart[0][3],
           'freight':cart[0][5],'name':cart[0][7],'path':cart[0][8],'realname':cart[0][9],'phone':cart[0][11],
           'province':cart[0][12],'detail_addr':cart[0][13]
        }})
Beispiel #4
0
def cartList(request):
    buid = getBuid(request);
    bookCartList = cartDataList(buid);
    if bookCartList is not None:
        return HttpResponse(simplejson.dumps({'status': '1', 'message':'有未付款的购物','data':bookCartList},
                                      ensure_ascii=False), content_type='application/json');
    else:
        return HttpResponse(simplejson.dumps({'status': '0', 'message':'请您先去购物吧!','data':bookCartList},
                                  ensure_ascii=False), content_type='application/json');
Beispiel #5
0
def buynow(request, id):
    buid = getBuid(request);
    oneBook = getOneBook(id);
    addr = getUserAddr(buid)
    if len(addr)==0:
        return render_to_response('cart/buy.html',
                                  {'id': oneBook[0][0], 'path': oneBook[0][4], 'name': oneBook[0][1], 'price': oneBook[0][2],
                                   'carriage': oneBook[0][3]})
    return render_to_response('cart/buyaddr.html',
           {'id': oneBook[0][0], 'path': oneBook[0][4], 'name': oneBook[0][1], 'price': oneBook[0][2],
             'carriage': oneBook[0][3], 'addrid':addr[0][0],'username':addr[0][2],
             'phone':addr[0][3],'province':addr[0][4],'detail_addr':addr[0][6],
             'postalcode':addr[0][7],'require':addr[0][8]});
Beispiel #6
0
def buyWithAddrExist(request):
    cartInfo = {};
    cartInfo['addr_id'] = request.REQUEST.get('addr_id',0);
    cartInfo['book_id'] = request.REQUEST.get('book_id',1);
    cartInfo['num'] = request.REQUEST.get('num',1);
    cartInfo['total'] = request.REQUEST.get('total',0);
    cartInfo['addip'] = getRealIP(request);
    cartInfo['addtime'] = datetime.datetime.now();
    cartInfo['buid'] =  getBuid(request);
    id = cartInsert(cartInfo);
    if id is None:
        return HttpResponse(simplejson.dumps({'status': '0', 'message':'加入购物车失败!','data':""},
                                             ensure_ascii=False), content_type='application/json');
    else:
        return HttpResponse(simplejson.dumps({'status': '1', 'message':'修改成功!','data':id},
                                      ensure_ascii=False), content_type='application/json');
Beispiel #7
0
def editAddr(request):
    buid = getBuid(request);
    addr = {};
    addr['name'] = request.REQUEST.get('name','zmw');
    addr['phone'] = request.REQUEST.get('phone','15313306298');
    addr['province'] = request.REQUEST.get('province','北京');
    addr['detail_addr'] = request.REQUEST.get('detail_addr');
    addr['addip'] = getRealIP(request);
    addr['postcode'] = request.REQUEST.get('postCode','18888');
    addr['require'] = request.REQUEST.get('require','没有');
    addr['book_id'] = request.REQUEST.get('book_id',"1");
    addr['buid'] = buid;
    status = updateAddr(addr);
    if status :
        return HttpResponse(simplejson.dumps({'status': '1', 'message':'success','data':""},ensure_ascii=False), content_type='application/json');
    else :
        HttpResponse(simplejson.dumps({'status': '0', 'message':'修改失败!','data':""},ensure_ascii=False), content_type='application/json');
Beispiel #8
0
def payView(request):
    buid = getBuid(request)
    cart = getCart(buid)
    if cart is not None:
        return render_to_response(
            'cart/pay.html', {
                'cart': {
                    'cart_id': cart[0][0],
                    'should_pay': cart[0][1],
                    'num': cart[0][2],
                    'price': cart[0][3],
                    'freight': cart[0][5],
                    'name': cart[0][7],
                    'path': cart[0][8],
                    'realname': cart[0][9],
                    'phone': cart[0][11],
                    'province': cart[0][12],
                    'detail_addr': cart[0][13]
                }
            })