From 69d05d3f50599d119c20dcc7e3a1081f4d016b4e Mon Sep 17 00:00:00 2001 From: 18923810322 <1666941798@qq.com> Date: Mon, 19 May 2025 17:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BarCode.Web.Domain/Entitys/Box.cs | 49 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/BarCode.Web.Domain/Entitys/Box.cs b/src/BarCode.Web.Domain/Entitys/Box.cs index 12fa763..80da7c2 100644 --- a/src/BarCode.Web.Domain/Entitys/Box.cs +++ b/src/BarCode.Web.Domain/Entitys/Box.cs @@ -124,30 +124,41 @@ namespace BarCode.Web.Domain.Entitys /// /// 是否不计数 public Result UnSerialNumber(string serialNumber, string materialNumber,string isNotCount) { + + var detail = this.Details.FirstOrDefault(f => f.MaterialNumber.Equals(materialNumber)); - if (detail == null) - return Result.ReFailure(ResultCodes.BoxMaterialNoDataError); - var serial = detail.SerialNumbers.FirstOrDefault(f => f.Equals(serialNumber)); - if (serial == null && isNotCount!="1") - return Result.ReFailure(ResultCodes.BoxSerialNumberNoDataError); + + if (isNotCount != "1") + { + if (detail == null) + return Result.ReFailure(ResultCodes.BoxMaterialNoDataError); + var serial = detail.SerialNumbers.FirstOrDefault(f => f.Equals(serialNumber)); + if (serial == null) + return Result.ReFailure(ResultCodes.BoxSerialNumberNoDataError); + } + if(detail!=null) + { detail.SerialNumbers.Remove(serialNumber); + if (isNotCount == "1") + { + + } + else + { + detail.Qty = detail.Qty - 1; + } + //如果数量为0了就删除这条明细 + if (detail.Qty <= 0) + this.Details.Remove(detail); + //如果没有明细了 就把状态改成未使用 + if (detail.Qty <= 0) + this.Status = BoxStatus.NoUse; + + } // detail.Qty = detail.SerialNumbers.Count(); - if(isNotCount=="1") - { - - } - else - { - detail.Qty = detail.Qty - 1; - } - //如果数量为0了就删除这条明细 - if (detail.Qty <= 0) - this.Details.Remove(detail); - //如果没有明细了 就把状态改成未使用 - if (detail.Qty <= 0) - this.Status = BoxStatus.NoUse; + ////如果数量为0了就删除这条明细 //if (detail.SerialNumbers.Count() <= 0)