Beispiel #1
0
 def get(self, request):
     serializer = OrderSerializer(data=request.query_params)
     serializer.is_valid(raise_exception=True)
     instance = OrderService.getOrderDetail(
         order_id=serializer.data.get('order_id'))
     serializer = OrderSerializer(instance)
     return Response(serializer.data)
Beispiel #2
0
 def get(self, request):
     qurey_params = request.query_params.copy()
     min_amount = qurey_params.get('min_amount')
     max_amount = qurey_params.get('max_amount')
     qurey_params.pop('min_amount')
     qurey_params.pop('max_amount')
     serializer = OrderSerializer(data=qurey_params)
     serializer.is_valid(raise_exception=True)
     query_criteria = serializer.data
     delete_null(query_criteria)
     query_criteria.update({
         'amount__gte': min_amount,
         'amount__lte': max_amount
     })
     if query_criteria.order_type == 0:
         query_set = OrderService.listBoughtOrder(
             query_criteria.get('user_id'))
     else:
         query_set = OrderService.listSoldOrder(
             query_criteria.get('user_id'))
     serializer = OrderSerializer(query_set, many=True)
     return Response(serializer.data)
Beispiel #3
0
 def post(self, request):
     serializer = OrderSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     OrderService.insertOrder(serializer.data)
     return Response(serializer.data)
Beispiel #4
0
 def post(self, request):
     serializer = PaymentRecordSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     OrderService.payOrder(serializer.data.order_id)
     OrderService.insertPaymentRecord(serializer.data)
     return Response(serializer.data)
Beispiel #5
0
 def put(self, request):
     serializer = OrderSerializer(request.data)
     serializer.is_valid(raise_exception=True)
     OrderService.updateOrderState(serializer.data.order_id)
     return Response(serializer.data)
Beispiel #6
0
 def post(self, request):
     serializer = SellerReviewSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     OrderService.insertSellerReview(validated_data=serializer.data)
     return Response(serializer.data)
Beispiel #7
0
 def get(self, request, seller):
     instance = OrderService.listSoldOrder(seller=seller)
     serializer = OrderSerializer(instance)
     return Response(serializer.data)
Beispiel #8
0
 def get(self, request, buyer):
     instance = OrderService.listBoughtOrder(buyer=buyer)
     serializer = OrderSerializer(instance)
     return Response(serializer.data)
Beispiel #9
0
 def get(self, request, order_id):
     instance = OrderService.getOrderDetail(order_id=order_id)
     serializer = OrderSerializer(instance)
     return Response(serializer.data)