Пример #1
0
 public async Task <DefaultEventHandlerResponse> RecordTradeLogByLogisticsDeliverSucc(EventHandleRequest <CreateLogisticsSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(RecordTradeLogByOrderPay), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var log = await logisticsRepository.GetAsync(eventData.LogisticsId);
         if (log == null)
         {
             throw new ApplicationServiceException($"没有找到物流单");
         }
         var tradeLog = new TradeLog();
         tradeLog.CreateTradeLog(TradeLogState.DeliverGoods, eventData.OrderId, order.OrderNo, log.Id, log.LogisticsNo, eventData.UserId, eventData.UserName);
         tradeLogRepository.Add(tradeLog);
         await unitofWork.CommitAsync();
     }));
 }
        public async Task <ApiResult> Receive(LogisticsReceiveDto input)
        {
            var logistics = await repository.GetAsync(input.LogisticsId);

            if (logistics == null)
            {
                throw new ApplicationServiceException("物流单无效!");
            }
            logistics.Receive(HttpContextExt.Current.User.Id, input.ReceiveTime);
            repository.Update(logistics);
            await unitofWork.CommitAsync();

            await eventBus.SendEvent(EventTopicDictionary.Logistics.LogisticsReceiveSucc, new OperateLogisticsSuccessEvent(logistics, HttpContextExt.Current.User.LoginName));

            return(ApiResult.Ok());
        }