|
@@ -332,6 +332,27 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
return response_error(str(e))
|
|
|
return response_ok()
|
|
|
|
|
|
+ @action(methods=['post'], detail=True)
|
|
|
+ def again_dispatch(self, request, pk):
|
|
|
+ #重新分配
|
|
|
+ check_permission(request, 'customer.again_dispatch')
|
|
|
+ user_id = request.POST.get('user')
|
|
|
+ try:
|
|
|
+ with transaction.atomic():
|
|
|
+ instance = NewCustomer.objects.filter(id=pk).first()
|
|
|
+ NewCustomerRemind.objects.filter(customer=instance, remind_user_id=instance.track_user_id).delete()
|
|
|
+ next_time = (timezone.now() + datetime.timedelta(days=instance.stage_progress.track_day)).strftime('%Y-%m-%d')
|
|
|
+
|
|
|
+ instance.track_user = User.objects.filter(id=user_id).first()
|
|
|
+ instance.next_time = next_time
|
|
|
+ instance.save()
|
|
|
+ NewCustomerRemind.objects.create(customer=instance, next_time=next_time,
|
|
|
+ remind_user_id=instance.track_user_id)
|
|
|
+ except CustomError as e:
|
|
|
+ return response_error(e.get_error_msg())
|
|
|
+ except Exception as e:
|
|
|
+ return response_error(str(e))
|
|
|
+ return response_ok()
|
|
|
|
|
|
class StageCountView(APIView):
|
|
|
permission_classes = [isLogin]
|