Ejemplo n.º 1
0
        /// <summary>
        /// 给订单指派人
        /// </summary>
        /// <param name="handlers"></param>
        /// <returns></returns>
        public async Task <bool> Assign(long orderId, long userId)
        {
            var order = await _orderRepository.GetAsync(orderId);

            if (order.HandlerId.HasValue)
            {
                throw new UserFriendlyException("该任务已经派过人员");
            }
            order.HandlerId = userId;
            order.TStatus   = TStatus.Wait;

            //生成消息类容
            await _messageService.Create(new CreateMessageInput()
            {
                Title   = order.Category,
                Content = order.ItemName,
                UserId  = userId,
                //接单
                AppPage = order.OrderType.GetDescription(),
                SrcId   = orderId
            });

            //插入Handler记录
            await _handlerRepository.InsertAsync(new WOrder_Handler()
            {
                OrderId  = order.Id,
                HandleId = userId,
                OStatus  = OStatus.Init,
            });

            //如果消息没有设置未已阅的话,那么就在此处设置已阅读
            await _messageService.ReadMyMsg(orderId);

            //执行推送消息
            await _jpushHelper.PushToAlias($"有新任务来了", $"{order.Category}", new List <string>() { userId.ToString() });

            return(await Task.FromResult(true));
        }