Example #1
0
        public void DoProduct(Guid productId, Guid customerId, int stepCode, Dictionary <Guid, float> dicSl)
        {
            var slpBll = new StockLocationProduct();

            foreach (KeyValuePair <Guid, float> kvp in dicSl)
            {
                DoProduct(productId, customerId, kvp.Key, stepCode, kvp.Value, 0, 0);
                slpBll.DoProduct(kvp.Key, productId, true, kvp.Value, 0);
            }
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
0
        public void DoOrderPickProduct(string itemAppend)
        {
            var items = itemAppend.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);

            var orderPickId = Guid.Parse(items[0]);
            var orderId     = Guid.Parse(items[1]);
            var productId   = Guid.Parse(items[2]);
            var customerId  = Guid.Parse(items[3]);

            var oBll  = new OrderPicked();
            var oInfo = oBll.GetModel(orderPickId);

            if (oInfo == null)
            {
                throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, "拣货单ID“" + orderPickId + "”"));
            }

            var osBll     = new OrderSend();
            var orderInfo = osBll.GetModel(orderId);

            if (orderInfo == null)
            {
                throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, orderId.ToString()));
            }
            var ospBll  = new OrderSendProduct();
            var ospInfo = ospBll.GetModel(orderId, productId, customerId);

            if (ospInfo == null)
            {
                throw new ArgumentException(MC.M_RuleInvalidError);
            }

            var pBll        = new Product();
            var productInfo = pBll.GetModel(productId);
            var minVolume   = productInfo.OutPackVolume == 0 ? 1 : productInfo.OutPackVolume;

            var slItems  = items[4].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            var dicSl    = new Dictionary <Guid, float>();
            var totalQty = 0f;
            var currTime = DateTime.Now;

            foreach (var item in slItems)
            {
                var subItems = item.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var qty      = float.Parse(subItems[1]);
                dicSl.Add(Guid.Parse(subItems[0]), qty);

                totalQty += qty;
            }

            var slBll  = new StockLocation();
            var slpBll = new StockLocationProduct();
            var oppBll = new OrderPickProduct();
            int effect = 0;

            var oppInfo = oppBll.GetModel(orderPickId, orderId, productId, customerId);

            oppInfo.Qty            += totalQty;
            oppInfo.StockLocations  = slBll.GetStockLocationTextInIds(string.Join(",", dicSl.Select(m => m.Key)));
            oppInfo.LastUpdatedDate = currTime;
            effect = oppBll.Update(oppInfo);

            new StockProduct().DoProduct(productId, customerId, (int)EnumData.EnumStep.拣货, false, dicSl);

            oBll.SetTotalProduct(orderPickId.ToString());

            ospInfo.PickQty += totalQty;
            ospBll.Update(ospInfo);
            osBll.SetStatus(orderId.ToString());
        }