def get(self, request):
    '提供订单结算页面'
    user = request.user
    try:
        addresses = Address.objects.filter(user=user, is_deleted=False)
    except Address.DoesNotExist:
        addresses = None
    redis_conn = get_redis_connection('carts')
    item_dict = redis_conn.hgetall(('carts_%s' % user.id))
    cart_selected = redis_conn.smembers(('selected_%s' % user.id))
    cart = {}
    for sku_id in cart_selected:
        cart[int(sku_id)] = int(item_dict[sku_id])
    total_count = 0
    total_amount = Decimal(0.0)
    skus = SKU.objects.filter(id__in=cart.keys())
    for sku in skus:
        sku.count = cart[sku.id]
        sku.amount = (sku.count * sku.price)
        total_count += sku.count
        total_amount += sku.amount
    freight = Decimal('10.00')
    context = {'addresses': addresses, 'skus': skus, 'total_count': total_count, 'total_amount': total_amount, 'freight': freight, 'payment_amount': (total_amount + freight)}
    return render(request, 'place_order.html', context)
提供订单结算页面
def get(self, request):
    
    user = request.user
    try:
        addresses = Address.objects.filter(user=user, is_deleted=False)
    except Address.DoesNotExist:
        addresses = None
    redis_conn = get_redis_connection('carts')
    item_dict = redis_conn.hgetall(('carts_%s' % user.id))
    cart_selected = redis_conn.smembers(('selected_%s' % user.id))
    cart = {}
    for sku_id in cart_selected:
        cart[int(sku_id)] = int(item_dict[sku_id])
    total_count = 0
    total_amount = Decimal(0.0)
    skus = SKU.objects.filter(id__in=cart.keys())
    for sku in skus:
        sku.count = cart[sku.id]
        sku.amount = (sku.count * sku.price)
        total_count += sku.count
        total_amount += sku.amount
    freight = Decimal('10.00')
    context = {'addresses': addresses, 'skus': skus, 'total_count': total_count, 'total_amount': total_amount, 'freight': freight, 'payment_amount': (total_amount + freight)}
    return render(request, 'place_order.html', context)