|
@@ -607,21 +607,97 @@ public class OrderController : BaseController
|
|
|
|
|
|
#region 二次回访申请
|
|
|
|
|
|
+ [Permission(EPermission.ApplyOrderVisit)]
|
|
|
+ [HttpPost("visitapply/add")]
|
|
|
public async Task ApplyOrderVisit([FromBody]VisitStartFlowDto dto)
|
|
|
{
|
|
|
- var orderVisitApply = _mapper.Map<AddVisitApply>(dto.Data);
|
|
|
+ var orderVisitApply = _mapper.Map<OrderVisitApply>(dto.Data);
|
|
|
//验证是否可以申请二次回访
|
|
|
|
|
|
|
|
|
var isAny = await _orderVisitApplyRepository.AnyAsync(x => x.OrderId == orderVisitApply.OrderId && x.VisitApplyState != EVisitApplyState.NoPass,HttpContext.RequestAborted);
|
|
|
if (isAny)
|
|
|
- {
|
|
|
throw UserFriendlyException.SameMessage("当前状态不能申请二次回访");
|
|
|
- }
|
|
|
|
|
|
var orderModel = await _orderRepository.GetAsync(x => x.Id == orderVisitApply.OrderId, HttpContext.RequestAborted);
|
|
|
-
|
|
|
+ if (orderModel?.CounterSignType != null)
|
|
|
+ throw UserFriendlyException.SameMessage("会签件不能申请二次回访");
|
|
|
+
|
|
|
+ orderVisitApply.EmployeeId = _sessionContext.RequiredUserId;
|
|
|
+ var id = await _orderVisitApplyRepository.AddAsync(orderVisitApply, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var startDto = _mapper.Map<StartWorkflowDto>(dto.Workflow);
|
|
|
+ startDto.DefinitionModuleCode = WorkflowModuleConsts.VisitApply;
|
|
|
+ startDto.Title = orderVisitApply.VisitReason;
|
|
|
+ string workFlowId = await _workflowApplication.StartWorkflowAsync(startDto, id, cancellationToken: HttpContext.RequestAborted);
|
|
|
+ orderVisitApply.WorkflowId = workFlowId;
|
|
|
+ await _orderVisitApplyRepository.UpdateAsync(orderVisitApply, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _orderDelayRepository.RemoveAsync(id, false, HttpContext.RequestAborted);
|
|
|
+ throw new UserFriendlyException($"工单二次回访流程失败!, {ex.Message}", "工单二次回访流程失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询二次申请流程开启参数
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("visitapply/startflow")]
|
|
|
+ public async Task<NextStepsDto> GetVisitFlowStartOptions()
|
|
|
+ {
|
|
|
+ return await _workflowApplication.GetStartStepsAsync(WorkflowModuleConsts.VisitApply, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 二次回访申请列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.VisitApplyList)]
|
|
|
+ [HttpGet("visitapply/list")]
|
|
|
+ public async Task<PagedDto<VisitApplyDto>> VisitApplyList([FromQuery]VisitApplyListDto dto)
|
|
|
+ {
|
|
|
+ var (total,items) = await _orderVisitApplyRepository.Queryable()
|
|
|
+ .Includes(d=>d.Order)
|
|
|
+ .Includes(d=>d.Employee)
|
|
|
+ .WhereIF(dto.VisitApplyState != null, x => x.VisitApplyState == dto.VisitApplyState)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.OrderNo.Contains(dto.Keyword))
|
|
|
+ .OrderByDescending(x => x.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex,dto.PageSize,HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ return new PagedDto<VisitApplyDto>(total, _mapper.Map<IReadOnlyList<VisitApplyDto>>(items));
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 获取二次回访申请
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.VisitApplyEntity)]
|
|
|
+ [HttpGet("visitapply/{id}")]
|
|
|
+ public async Task<VisitApplyDto> VisitApplyEntity([FromQuery]string id)
|
|
|
+ {
|
|
|
+ var model = await _orderVisitApplyRepository.GetAsync(x => x.Id == id, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ return _mapper.Map<VisitApplyDto>(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 页面基础信息
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("visitapply/basedata")]
|
|
|
+ public async Task<object> VisitApplyBaseData()
|
|
|
+ {
|
|
|
+ var rsp = new
|
|
|
+ {
|
|
|
+ VisitApplyState = EnumExts.GetDescriptions<EVisitApplyState>()
|
|
|
+ };
|
|
|
+ return rsp;
|
|
|
}
|
|
|
|
|
|
#endregion
|