|
@@ -64,6 +64,7 @@ class ReportCustomerViewSet(CustomModelViewSet):
|
|
if not instance:
|
|
if not instance:
|
|
raise CustomError('当前客户报备信息有误,请刷新重试!')
|
|
raise CustomError('当前客户报备信息有误,请刷新重试!')
|
|
instance.check_user = self.request.user
|
|
instance.check_user = self.request.user
|
|
|
|
+
|
|
instance.report_status = ReportCustomer.CHECKED
|
|
instance.report_status = ReportCustomer.CHECKED
|
|
instance.check_time = timezone.now()
|
|
instance.check_time = timezone.now()
|
|
instance.save()
|
|
instance.save()
|
|
@@ -75,10 +76,16 @@ class ReportCustomerViewSet(CustomModelViewSet):
|
|
if not potential_level.track_day:
|
|
if not potential_level.track_day:
|
|
raise CustomError('当前潜客级别,没有可用跟踪天数!')
|
|
raise CustomError('当前潜客级别,没有可用跟踪天数!')
|
|
next_time = (timezone.now() + datetime.timedelta(days=potential_level.track_day)).strftime('%Y-%m-%d')
|
|
next_time = (timezone.now() + datetime.timedelta(days=potential_level.track_day)).strftime('%Y-%m-%d')
|
|
- NewCustomer.objects.create(report_customer=instance, potential_level=potential_level,
|
|
|
|
|
|
+
|
|
|
|
+ customer = NewCustomer.objects.create(report_customer=instance, potential_level=potential_level,
|
|
track_user_id=user_id, next_time=next_time, stage_progress=stage_progress,
|
|
track_user_id=user_id, next_time=next_time, stage_progress=stage_progress,
|
|
create_user=instance.create_user,
|
|
create_user=instance.create_user,
|
|
|
|
+ name=instance.name,tel=instance.tel,village=instance.village,
|
|
|
|
+ address=instance.address,source=instance.source,
|
|
)
|
|
)
|
|
|
|
+ projects = instance.project.all()
|
|
|
|
+ for project in projects:
|
|
|
|
+ customer.project.add(project.id)
|
|
except CustomError as e:
|
|
except CustomError as e:
|
|
return response_error(e.get_error_msg())
|
|
return response_error(e.get_error_msg())
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -132,6 +139,7 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
|
|
|
@action(methods=['post'], detail=True)
|
|
@action(methods=['post'], detail=True)
|
|
def add_review(self, request, pk):
|
|
def add_review(self, request, pk):
|
|
|
|
+ # 添加跟踪报告
|
|
check_permission(request, 'customer.add_review')
|
|
check_permission(request, 'customer.add_review')
|
|
description = request.POST.get('description')
|
|
description = request.POST.get('description')
|
|
instruction = request.POST.get('instruction')
|
|
instruction = request.POST.get('instruction')
|
|
@@ -139,6 +147,7 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
is_giveup = request.POST.get('is_giveup') == '1'
|
|
is_giveup = request.POST.get('is_giveup') == '1'
|
|
potential_level = request.POST.get('potential_level')
|
|
potential_level = request.POST.get('potential_level')
|
|
next_time = request.POST.get('next_time')
|
|
next_time = request.POST.get('next_time')
|
|
|
|
+
|
|
try:
|
|
try:
|
|
instance =NewCustomer.objects.filter(id=pk).first()
|
|
instance =NewCustomer.objects.filter(id=pk).first()
|
|
if not instance:
|
|
if not instance:
|
|
@@ -156,8 +165,18 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
if serializer.is_valid(raise_exception=True):
|
|
if serializer.is_valid(raise_exception=True):
|
|
serializer.save()
|
|
serializer.save()
|
|
|
|
|
|
|
|
+ sort = 1
|
|
|
|
+ track_day = 1
|
|
|
|
+ try:
|
|
|
|
+ sort = int(instance.stage_progress.sort)
|
|
|
|
+ track_day = int(instance.stage_progress.track_day)
|
|
|
|
+ except:
|
|
|
|
+ pass
|
|
|
|
+ # 预定客户,提交跟踪报告此字段为空
|
|
|
|
+ if sort > 1 or not next_time:
|
|
|
|
+ next_time = (timezone.now() + datetime.timedelta(days=track_day)).strftime('%Y-%m-%d')
|
|
data = {
|
|
data = {
|
|
- 'potential_level':potential_level,
|
|
|
|
|
|
+ 'potential_level':potential_level or None, #预定客户,无客户等级
|
|
'next_time':next_time,
|
|
'next_time':next_time,
|
|
'end_time':timezone.now(),
|
|
'end_time':timezone.now(),
|
|
'stage_progress':instance.stage_progress.id,
|
|
'stage_progress':instance.stage_progress.id,
|