def perform_create(self, serializer):
        # 保存后会返回OrderInfo订单的实例对象
        order_info = serializer.save()

        # 查找当前用户下购物车所有的商品
        shopping_carts = ShoppingCart.objects.filter(
            user=self.request.user)  # 列表

        for shopping_cart in shopping_carts:
            # 订单详情商品
            order_goods = OrderGoods()

            # 订单
            order_goods.order = order_info

            # 先要保存到OrderGoods,取出购物车的商品
            goods = shopping_cart.goods
            # 保存到订单对应的商品model
            order_goods.goods = goods

            # 订单商品详情的数量
            order_goods.goods_num = shopping_cart.nums

            # 保存OrderGoods
            order_goods.save()

            # 把购物车里面的所有的商品删除,在删除之前,
            shopping_cart.delete()