|
@@ -313,19 +313,20 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
is_copy = request.POST.get('is_copy') == '1'
|
|
|
|
|
|
try:
|
|
|
- instance = NewCustomer.objects.filter(id=pk).first()
|
|
|
+ with transaction.atomic():
|
|
|
+ instance = NewCustomer.objects.filter(id=pk).first()
|
|
|
|
|
|
- data = {
|
|
|
- 'customer': instance.id,
|
|
|
- 'store': instance.store.id,
|
|
|
- 'create_user': request.user.id,
|
|
|
- 'description': description,
|
|
|
- 'is_copy': is_copy,
|
|
|
- }
|
|
|
- serializer = ReviewSerializer(data=data)
|
|
|
- if serializer.is_valid(raise_exception=True):
|
|
|
- serializer.save()
|
|
|
- NewCustomerRemind.objects.filter(customer=instance, remind_user=request.user).update(next_time=next_time)
|
|
|
+ data = {
|
|
|
+ 'customer': instance.id,
|
|
|
+ 'store': instance.store.id,
|
|
|
+ 'create_user': request.user.id,
|
|
|
+ 'description': description,
|
|
|
+ 'is_copy': is_copy,
|
|
|
+ }
|
|
|
+ serializer = ReviewSerializer(data=data)
|
|
|
+ if serializer.is_valid(raise_exception=True):
|
|
|
+ serializer.save()
|
|
|
+ NewCustomerRemind.objects.filter(customer=instance, remind_user=request.user).update(next_time=next_time)
|
|
|
|
|
|
except ValidationError as e:
|
|
|
traceback.print_exc()
|
|
@@ -407,25 +408,26 @@ class ReviewViewSet(CustomModelViewSet):
|
|
|
check_comment = request.POST.get('check_comment')
|
|
|
next_time = request.POST.get('next_time')
|
|
|
try:
|
|
|
- instance = Review.objects.filter(id=pk).first()
|
|
|
- if int(check_status) == Review.KEEPUP:
|
|
|
- instance.check_user = request.user
|
|
|
- instance.check_status = check_status
|
|
|
- instance.check_comment = check_comment
|
|
|
- instance.check_time = timezone.now()
|
|
|
- instance.save()
|
|
|
- if int(check_status) == Review.ABANDON:
|
|
|
- instance.check_user = request.user
|
|
|
- instance.check_status = check_status
|
|
|
- instance.check_comment = check_comment
|
|
|
- instance.check_time = timezone.now()
|
|
|
- instance.save()
|
|
|
- instance.customer.status = NewCustomer.ABANDONED
|
|
|
- # 如果客户已下单,把工单状态改成放弃
|
|
|
- Order.objects.filter(customer=instance.customer).update(status=Order.ABANDONED)
|
|
|
- instance.customer.next_time = next_time
|
|
|
- instance.customer.save()
|
|
|
- NewCustomerRemind.objects.filter(customer=instance.customer, remind_user=instance.customer.track_user).update(next_time=next_time)
|
|
|
+ with transaction.atomic():
|
|
|
+ instance = Review.objects.filter(id=pk).first()
|
|
|
+ if int(check_status) == Review.KEEPUP:
|
|
|
+ instance.check_user = request.user
|
|
|
+ instance.check_status = check_status
|
|
|
+ instance.check_comment = check_comment
|
|
|
+ instance.check_time = timezone.now()
|
|
|
+ instance.save()
|
|
|
+ if int(check_status) == Review.ABANDON:
|
|
|
+ instance.check_user = request.user
|
|
|
+ instance.check_status = check_status
|
|
|
+ instance.check_comment = check_comment
|
|
|
+ instance.check_time = timezone.now()
|
|
|
+ instance.save()
|
|
|
+ instance.customer.status = NewCustomer.ABANDONED
|
|
|
+ # 如果客户已下单,把工单状态改成放弃
|
|
|
+ Order.objects.filter(customer=instance.customer).update(status=Order.ABANDONED)
|
|
|
+ instance.customer.next_time = next_time
|
|
|
+ instance.customer.save()
|
|
|
+ NewCustomerRemind.objects.filter(customer=instance.customer, remind_user=instance.customer.track_user).update(next_time=next_time)
|
|
|
except CustomError as e:
|
|
|
return response_error(e.get_error_msg())
|
|
|
except Exception as e:
|