示例#1
0
        public void DoProduct(Guid productId, Guid customerId, int stepCode, bool isIncrease, double qty, double unQty, double freezeQty)
        {
            var spBll  = new StockProduct();
            var slpBll = new StockLocationProduct();
            var spInfo = spBll.GetModel(productId, customerId);

            if (spInfo == null)
            {
                return;
            }

            var pslList = JsonConvert.DeserializeObject <List <ProductStockLocationAttrInfo> >(spInfo.StockLocations);

            if ((int)EnumData.EnumStep.发货 == stepCode)
            {
                if (!isIncrease)
                {
                    var qpslInfo = pslList.FirstOrDefault(m => m.FreezeQty >= freezeQty);
                    if (qpslInfo == null)
                    {
                        throw new ArgumentException(MC.M_QtyInvalidError);
                    }
                    qpslInfo.FreezeQty -= freezeQty;
                    spInfo.FreezeQty   -= freezeQty;
                    qpslInfo.Qty       += freezeQty;
                    spInfo.Qty         += freezeQty;
                    if (qpslInfo.Qty == 0 && qpslInfo.FreezeQty == 0)
                    {
                        pslList.Remove(qpslInfo);
                    }

                    var slpInfo = slpBll.GetModel(qpslInfo.StockLocationId);
                    var slpList = JsonConvert.DeserializeObject <List <StockLocationProductAttrInfo> >(slpInfo.ProductAttr);
                    var slpItem = slpList.First(m => m.ProductId.Equals(productId));
                    slpItem.FreezeQty -= freezeQty;
                    if (slpItem.FreezeQty < 0)
                    {
                        slpItem.FreezeQty = 0;
                    }
                    if (slpItem.Qty == 0 && slpItem.FreezeQty == 0)
                    {
                        slpList.Remove(slpItem);
                    }
                    slpInfo.ProductAttr = JsonConvert.SerializeObject(slpList);
                    slpInfo.MaxVolume  -= freezeQty;
                    slpBll.Update(slpInfo);
                }
            }
            spInfo.StockLocations = JsonConvert.SerializeObject(pslList);
            spBll.Update(spInfo);
        }
示例#2
0
        public void DoProduct(Guid productId, Guid customerId, int stepCode, bool isIncrease, Dictionary <Guid, float> dicSl)
        {
            var spBll  = new StockProduct();
            var spInfo = spBll.GetModel(productId, customerId);

            if (spInfo == null)
            {
                throw new ArgumentException(MC.M_StockProductInvalidError);
            }
            var pslList = JsonConvert.DeserializeObject <List <ProductStockLocationAttrInfo> >(spInfo.StockLocations);
            var slpBll  = new StockLocationProduct();

            if ((int)EnumData.EnumStep.拣货 == stepCode)
            {
                if (!isIncrease)
                {
                    foreach (KeyValuePair <Guid, float> kvp in dicSl)
                    {
                        var pslItem = pslList.FirstOrDefault(m => m.StockLocationId.Equals(kvp.Key));
                        if (pslItem == null)
                        {
                            throw new ArgumentException(MC.M_StockProductInvalidError);
                        }
                        pslItem.FreezeQty -= kvp.Value;
                        if (pslItem.FreezeQty < 0)
                        {
                            pslItem.FreezeQty = 0;
                        }
                        if (pslItem.Qty == 0 && pslItem.FreezeQty == 0)
                        {
                            pslList.Remove(pslItem);
                        }
                        spInfo.FreezeQty -= kvp.Value;

                        var slpInfo = slpBll.GetModel(kvp.Key);
                        var slpList = JsonConvert.DeserializeObject <List <StockLocationProductAttrInfo> >(slpInfo.ProductAttr);
                        var slpItem = slpList.FirstOrDefault(m => m.ProductId.Equals(productId));
                        if (slpItem == null)
                        {
                            throw new ArgumentException(MC.M_StockProductInvalidError);
                        }
                        slpItem.FreezeQty -= kvp.Value;
                        if (slpItem.FreezeQty < 0)
                        {
                            slpItem.FreezeQty = 0;
                        }
                        slpItem.Qty -= kvp.Value;
                        if (slpItem.Qty < 0)
                        {
                            slpItem.Qty = 0;
                        }
                        if (slpItem.Qty == 0 && slpItem.FreezeQty == 0)
                        {
                            slpList.Remove(slpItem);
                        }
                        slpInfo.MaxVolume  += kvp.Value;
                        slpInfo.ProductAttr = JsonConvert.SerializeObject(slpList);
                        slpBll.Update(slpInfo);
                    }
                }
            }

            spInfo.StepCode       = Common.GetStepCode(spInfo.StepCode, stepCode.ToString(), false);
            spInfo.LastStepName   = Enum.GetName(typeof(EnumData.EnumStep), stepCode);
            spInfo.StockLocations = JsonConvert.SerializeObject(pslList);
            spBll.Update(spInfo);
        }