public async Task <List <ShipmentDto> > GetOrderShipments(long orderId) { List <ShipmentDto> shipmentDtoList = new List <ShipmentDto>(); var shipments = _shipmentManager.FindByOrderId(orderId); if (shipments.IsNullOrEmpty()) { return(shipmentDtoList); } foreach (var shipment in shipments) { var shipmentDto = ObjectMapper.Map <ShipmentDto>(shipment); shipmentDto.Items = new List <ShipmentItemDto>(); var order = await _orderManager.GetByIdAsync(shipment.OrderId); shipmentDto.DeliveryOn = shipment.CreationTime; shipmentDto.ShippingName = order.ShippingName; shipmentDto.ShippingPhoneNumber = order.ShippingPhoneNumber; shipmentDto.ShippingAddress = order.GetFullShippingAddress(); shipmentDto.StatusString = shipment.Status.GetLocalizedEnum(_localizationManager); if (shipment.LogisticsId.HasValue) { var tenantLogistics = await _logisticsManager.FindTenantLogisticsByLogisticsIdAsync(shipment.LogisticsId.Value); if (tenantLogistics == null) { tenantLogistics = new TenantLogistics() { LogisticsId = shipment.LogisticsId.Value, Name = shipment.LogisticsName, }; await _logisticsManager.CreateTenantLogisticsAsync(tenantLogistics); await CurrentUnitOfWork.SaveChangesAsync(); } shipmentDto.LogisticsId = tenantLogistics.Id; } foreach (var item in shipment.Items) { shipmentDto.Items.Add(await PrepareShipmentItemDto(item)); } shipmentDtoList.Add(shipmentDto); } return(shipmentDtoList); }
public async Task <EntityDto <long> > CreateOrUpdateTenantLogistics(CreateOrUpdateTenantLogisticsInput input) { TenantLogistics tenantLogistics = null; if (input.Id > 0) { tenantLogistics = await UpdateTenantLogisticsAsync(input); } else { tenantLogistics = await CreateTenantLogisticsAsync(input); } await CurrentUnitOfWork.SaveChangesAsync(); return(new EntityDto <long> { Id = tenantLogistics.Id }); }
protected virtual async Task <TenantLogistics> CreateTenantLogisticsAsync(CreateOrUpdateTenantLogisticsInput input) { TenantLogistics tenantLogistic = await _logisticsManager.FindTenantLogisticsByLogisticsIdAsync(input.LogisticsId); var logistic = await _logisticsManager.FindByIdAsync(input.LogisticsId); if (tenantLogistic != null) { tenantLogistic.LogisticsId = logistic.Id; tenantLogistic.Name = logistic.Name; tenantLogistic.DisplayOrder = input.DisplayOrder; await _logisticsManager.UpdateTenantLogisticsAsync(tenantLogistic); } else { tenantLogistic = new TenantLogistics(); tenantLogistic.LogisticsId = logistic.Id; tenantLogistic.Name = logistic.Name; tenantLogistic.DisplayOrder = input.DisplayOrder; await _logisticsManager.CreateTenantLogisticsAsync(tenantLogistic); } return(tenantLogistic); }
/// <summary> /// 删除自选物流 /// </summary> /// <param name="tenantLogistics"></param> public virtual async Task DeleteTenantLogisticsAsync(TenantLogistics tenantLogistics) { await TenantLogisticsRepository.DeleteAsync(tenantLogistics); }
/// <summary> /// 添加自选物流 /// </summary> /// <param name="tenantLogistics"></param> public virtual async Task CreateTenantLogisticsAsync(TenantLogistics tenantLogistics) { await TenantLogisticsRepository.InsertAsync(tenantLogistics); }