| | |
| | | var result = await StockInfoDetailService.Repository.UpdateDataAsync(detailEntities); |
| | | if (!result) return content.Error("换盘失败"); |
| | | |
| | | // 检查源托盘是否还有剩余库存明细,若无则删除源托盘库存头 |
| | | var remainingSourceDetails = StockInfoDetailService.Repository.QueryData(d => d.StockId == sourceStock.Id); |
| | | if (!remainingSourceDetails.Any()) |
| | | { |
| | | if (await StockInfoService.Repository.Db.Deleteable<Dt_StockInfo>().Where(s => s.Id == sourceStock.Id).ExecuteCommandAsync() <= 0) |
| | | return content.Error("删除源托盘库存失败"); |
| | | } |
| | | |
| | | return content.OK("换盘成功"); |
| | | }); |
| | | } |
| | |
| | | if (await StockInfo_HtyService.Repository.AddDataAsync(CreateStockHistory(new[] { sourceStock }, "拆盘")) <= 0) |
| | | return content.Error("拆盘历史记录保存失败"); |
| | | |
| | | // 删除已拆出的库存明细 |
| | | var detailIds = detailEntities.Select(d => d.Id).ToList(); |
| | | if (await StockInfoDetailService.Repository.Db.Deleteable<Dt_StockInfoDetail>().In(detailIds).ExecuteCommandAsync() <= 0) |
| | | return content.Error("删除库存明细失败"); |
| | | |
| | | // 检查源托盘是否还有剩余库存明细,若无则删除源托盘库存头 |
| | | var remainingSourceDetails = StockInfoDetailService.Repository.QueryData(d => d.StockId == sourceStock.Id); |
| | | if (!remainingSourceDetails.Any()) |
| | | { |
| | | if (await StockInfoService.Repository.Db.Deleteable<Dt_StockInfo>().Where(s => s.Id == sourceStock.Id).ExecuteCommandAsync() <= 0) |
| | | return content.Error("删除源托盘库存失败"); |
| | | } |
| | | |
| | | return content.OK("拆盘成功"); |
| | | }); |
| | | } |