| | |
| | | using MailKit.Search; |
| | | using Autofac.Core; |
| | | using MailKit.Search; |
| | | using Microsoft.Extensions.Logging; |
| | | using SqlSugar; |
| | | using SqlSugar.Extensions; |
| | |
| | | { |
| | | 1 => await AddAllocateOrder(allocateOrder), |
| | | 2 => await UpdateAllocateOrder(allocateOrder), |
| | | 3 => DeleteAllocateOrder(allocateOrder), |
| | | 3 => await DeleteAllocateOrder(allocateOrder), |
| | | |
| | | _ => WebResponseContent.Instance.OK(), |
| | | }; |
| | |
| | | } |
| | | allocateOrder.OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.AllocateOrderCodeRule)); |
| | | Db.InsertNav(allocateOrder).Include(x => x.Details).ExecuteCommand(); |
| | | await AddInOutData(allocateOrder); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation("AllocateService AddAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private async Task AddInOutData(Dt_AllocateOrder allocateOrder) |
| | | { |
| | | if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType)) |
| | | { |
| | | if (businessType == BusinessTypeEnum.æºä»è°å¤é¨ä»åº) |
| | | { |
| | | allocateOrder.OrderType = InOrderTypeEnum.Allocat.ObjToInt(); |
| | | var inboundOrders = ConvertToInboundOrders(allocateOrder); |
| | | await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1); |
| | | } |
| | |
| | | throw new NotSupportedException($"䏿¯æçä¸å¡ç±»åæä¸¾å¼: {businessType}"); |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation("AllocateService AddAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public async Task<WebResponseContent> UpdateAllocateOrder(Dt_AllocateOrder model) |
| | | { |
| | | try |
| | |
| | | _allocateOrderDetailRepository.AddData(allocateOrderDetails); |
| | | |
| | | BaseDal.UpdateData(allocateOrder); |
| | | |
| | | DeleteInOutData(model.UpperOrderNo, allocateOrder); |
| | | await AddInOutData(allocateOrder); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent DeleteAllocateOrder(Dt_AllocateOrder model) |
| | | public async Task<WebResponseContent> DeleteAllocateOrder(Dt_AllocateOrder model) |
| | | { |
| | | try |
| | | { |
| | |
| | | _allocateOrderDetailRepository.DeleteData(item); |
| | | } |
| | | BaseDal.DeleteData(allocateOrder); |
| | | |
| | | DeleteInOutData(model.UpperOrderNo, allocateOrder); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _logger.LogInformation("AllocateService DeleteAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void DeleteInOutData(string upperOrderNo, Dt_AllocateOrder allocateOrder) |
| | | { |
| | | if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType)) |
| | | { |
| | | if (businessType == BusinessTypeEnum.æºä»è°å¤é¨ä»åº) |
| | | { |
| | | _inboundService.InbounOrderService.Db.Deleteable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand(); |
| | | |
| | | _inboundService.InboundOrderDetailService.Db.Deleteable<Dt_InboundOrderDetail>() |
| | | .Where(p => SqlFunc.Subqueryable<Dt_InboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand(); |
| | | } |
| | | else if (businessType == BusinessTypeEnum.å¤é¨ä»åºè°æºä» || businessType == BusinessTypeEnum.æºä»è°æºä») |
| | | { |
| | | _outboundService.OutboundOrderService.Db.Deleteable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand(); |
| | | _outboundService.OutboundOrderDetailService.Db.Deleteable<Dt_OutboundOrderDetail>() |
| | | .Where(p => SqlFunc.Subqueryable<Dt_OutboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | WarehouseId = allocateOrder.WarehouseId, |
| | | OrderNo = allocateOrder.OrderNo, |
| | | UpperOrderNo = allocateOrder.UpperOrderNo, |
| | | OrderType = OutOrderTypeEnum.Allocate.ObjToInt(), |
| | | OrderType = allocateOrder.OrderType, |
| | | OrderStatus = allocateOrder.OrderStatus, |
| | | CreateType = allocateOrder.CreateType, |
| | | BusinessType = allocateOrder.BusinessType, |