Exemplo n.º 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');
Exemplo n.º 2
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');