|
@@ -398,11 +398,13 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
new_project = new_customer.project.all()
|
|
|
new_projects.append(','.join(new_project.values_list('name', flat=True)))
|
|
|
|
|
|
-
|
|
|
+ add_projects = [] # 未添加项目
|
|
|
+ exist_projects = [] # 已存在项目
|
|
|
for project in projects:
|
|
|
# 重复项目跳出循环
|
|
|
option = Option.objects.filter(id=project).first()
|
|
|
if option.name in new_projects:
|
|
|
+ exist_projects.append(option.name)
|
|
|
continue
|
|
|
|
|
|
customer = NewCustomer.objects.create(report_customer=instance.report_customer, gender=instance.gender,
|
|
@@ -427,6 +429,13 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
for remind_user in remind_users:
|
|
|
NewCustomerRemind.objects.create(customer=customer, next_time=next_time, remind_user_id=remind_user,
|
|
|
is_employee=False, store=instance.store)
|
|
|
+
|
|
|
+ add_projects.append(option.name)
|
|
|
+
|
|
|
+ if exist_projects and add_projects == []:
|
|
|
+ raise CustomError(u'该客户{}项目已存在!'.format(exist_projects))
|
|
|
+ if add_projects:
|
|
|
+ return response_ok(u'该客户{}项目已添加成功!'.format(add_projects))
|
|
|
except CustomError as e:
|
|
|
return response_error(e.get_error_msg())
|
|
|
except Exception as e:
|