|
@@ -25,6 +25,7 @@ class GetProcessView(APIView):
|
|
|
|
|
|
def get(self, request):
|
|
def get(self, request):
|
|
customer_id = request.query_params.get('customer_id')
|
|
customer_id = request.query_params.get('customer_id')
|
|
|
|
+ back = request.query_params.get('back') == '1' # 是否撤回进度
|
|
dispatch = request.query_params.get('dispatch') # 分配服务人员,
|
|
dispatch = request.query_params.get('dispatch') # 分配服务人员,
|
|
|
|
|
|
instance = NewCustomer.objects.filter(id=customer_id).first()
|
|
instance = NewCustomer.objects.filter(id=customer_id).first()
|
|
@@ -43,8 +44,14 @@ class GetProcessView(APIView):
|
|
}
|
|
}
|
|
return response_ok(data)
|
|
return response_ok(data)
|
|
|
|
|
|
- option = Option.objects.filter(type=instance.stage_progress.type, sort__gt=instance.stage_progress.sort,
|
|
|
|
- enable=True).order_by('sort').first()
|
|
|
|
|
|
+ option = Option.objects.filter(type=instance.stage_progress.type,
|
|
|
|
+ enable=True)
|
|
|
|
+ if back:
|
|
|
|
+ # 非撤回,查询下一个进度。
|
|
|
|
+ option = option.filter(sort__lt=instance.stage_progress.sort,).order_by('-sort')
|
|
|
|
+ else:
|
|
|
|
+ option = option.filter(sort__gt=instance.stage_progress.sort,).order_by('sort')
|
|
|
|
+ option = option.first()
|
|
if option:
|
|
if option:
|
|
data = {
|
|
data = {
|
|
'now_process_text': instance.stage_progress.name,
|
|
'now_process_text': instance.stage_progress.name,
|
|
@@ -118,18 +125,30 @@ class OrderViewSet(CustomModelViewSet):
|
|
@action(methods=['post'], detail=True)
|
|
@action(methods=['post'], detail=True)
|
|
def uncheck(self, request, pk):
|
|
def uncheck(self, request, pk):
|
|
# 撤销进度审核
|
|
# 撤销进度审核
|
|
|
|
+ stage_progress = request.POST.get('stage_progress')
|
|
|
|
+ reason = request.POST.get('reason')
|
|
try:
|
|
try:
|
|
- instance = Order.objects.filter(id=pk).first()
|
|
|
|
- if not instance:
|
|
|
|
- raise CustomError('订单不存在')
|
|
|
|
- instance.status = Order.NORMAL
|
|
|
|
- instance.save()
|
|
|
|
- stage_progress = Option.objects.filter(type=instance.stage_progress.type,
|
|
|
|
- sort__gt=instance.stage_progress.sort,
|
|
|
|
- enable=True).order_by('sort').first()
|
|
|
|
- user = request.user
|
|
|
|
- operation = u'撤销【{0}】进度审核。'.format(stage_progress.name)
|
|
|
|
- ProgressDetails.objects.create(order=instance, user=user, operation=operation)
|
|
|
|
|
|
+ with transaction.atomic():
|
|
|
|
+ stage_progress = Option.objects.filter(id=stage_progress, enable=True).first()
|
|
|
|
+ if not stage_progress:
|
|
|
|
+ raise CustomError('撤回进度不存在,请刷新重试!')
|
|
|
|
+ if stage_progress.sort == 1:
|
|
|
|
+ # 撤回的进度排序为1,把订单删除
|
|
|
|
+ instance = Order.objects.filter(id=pk).first()
|
|
|
|
+ # TODO 删除数据库钱,先删除图片文件
|
|
|
|
+ Upload.objects.filter(progress_details__order=instance).delete()
|
|
|
|
+ ProgressDetails.objects.filter(order=instance).delete()
|
|
|
|
+ instance.delete()
|
|
|
|
+ return response_ok()
|
|
|
|
+
|
|
|
|
+ instance = Order.objects.filter(id=pk).first()
|
|
|
|
+ if not instance:
|
|
|
|
+ raise CustomError('订单不存在')
|
|
|
|
+ instance.status = Order.NORMAL
|
|
|
|
+ instance.save()
|
|
|
|
+
|
|
|
|
+ operation = u'撤回进度为:{}。'.format(stage_progress.name)
|
|
|
|
+ ProgressDetails.objects.create(order=instance, user=request.user, operation=operation,notes=reason )
|
|
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:
|