|
@@ -310,7 +310,8 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
instance = NewCustomer.objects.filter(id=pk).first()
|
|
|
-
|
|
|
+ if not instance:
|
|
|
+ raise CustomError('客户信息有误,请刷新重试!')
|
|
|
data = {
|
|
|
'customer': instance.id,
|
|
|
'store': instance.store.id,
|
|
@@ -340,14 +341,19 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
instance = NewCustomer.objects.filter(id=pk).first()
|
|
|
- NewCustomerRemind.objects.filter(customer=instance, remind_user_id=instance.track_user_id).delete()
|
|
|
+ if not instance:
|
|
|
+ raise CustomError('客户信息有误,请刷新重试!')
|
|
|
+ old_track_user = instance.track_user
|
|
|
+ if not instance.stage_progress.track_day:
|
|
|
+ raise CustomError('当前阶段,没有设置跟踪天数!')
|
|
|
next_time = (timezone.now() + datetime.timedelta(days=instance.stage_progress.track_day)).strftime('%Y-%m-%d')
|
|
|
|
|
|
- instance.track_user = User.objects.filter(id=track_user_id).first()
|
|
|
+ instance.track_user_id = track_user_id
|
|
|
instance.next_time = next_time
|
|
|
instance.save()
|
|
|
- NewCustomerRemind.objects.create(customer=instance, next_time=next_time,
|
|
|
- remind_user_id=instance.track_user_id)
|
|
|
+ # 把原跟踪人提醒更新为新的跟踪人
|
|
|
+ NewCustomerRemind.objects.filter(customer=instance, remind_user=old_track_user).update(
|
|
|
+ next_time=next_time,remind_user=track_user_id)
|
|
|
except CustomError as e:
|
|
|
return response_error(e.get_error_msg())
|
|
|
except Exception as e:
|