Ejemplo n.º 1
0
        /// <summary>
        /// 创建调价单就立即生效
        /// </summary>
        /// <param name="model"></param>
        public void Create(AdjustSalePriceModel model)
        {
            // 创建调价单
            var entity = new AdjustSalePrice();

            entity = model.MapTo <AdjustSalePrice>();
            var items = model.ConvertJsonToItem();

            entity.AddItems(items);
            entity.CreatedBy = model.UpdatedBy;
            entity.Code      = _sequenceService.GenerateNewCode(BillIdentity.AdjustSalePrice);
            _service.Create(entity);
            // 修改商品价格
            Dictionary <int, decimal> productSalePriceDic = new Dictionary <int, decimal>();

            items.ToList().ForEach(n => productSalePriceDic.Add(n.ProductId, n.AdjustPrice));
            _productService.UpdateSalePrice(productSalePriceDic);
            // 修改单据状态
            entity.Submit();

            _db.SaveChange();
            var reason = "创建商品调价单";

            entity = _db.Table.Find <AdjustSalePrice>(n => n.Code == entity.Code);
            _processHistoryService.Track(model.UpdatedBy, model.UpdatedByName, (int)entity.Status, entity.Id, BillIdentity.AdjustSalePrice.ToString(), reason);
            _db.SaveChange();
        }
Ejemplo n.º 2
0
        public void Create(ProductModel model)
        {
            Product entity = model.MapTo <Product>();

            entity.BarCode = entity.BarCode.Trim();
            _productService.ValidateBarCode(entity.BarCode);
            entity.CreatedBy = model.UpdatedBy;
            entity.Code      = _productService.GenerateNewCode(entity.CategoryId);
            _db.Insert(entity);
            // 有变价,记录变价
            if (entity.SalePrice > 0)
            {
                var newCode      = _sequenceService.GenerateNewCode(BillIdentity.AdjustSalePrice);
                var adjustEntity = _adjustSalePriceService.Create(entity, model.SalePrice, newCode, model.UpdatedBy);
                _db.Insert(adjustEntity);
            }
            _db.SaveChange();
        }
Ejemplo n.º 3
0
        public void Create(AdjustSalePriceModel model)
        {
            var entity = new AdjustSalePrice();

            entity = model.MapTo <AdjustSalePrice>();
            entity.AddItems(model.ConvertJsonToItem());
            entity.CreatedBy = model.UpdatedBy;
            entity.Code      = _sequenceService.GenerateNewCode(BillIdentity.AdjustSalePrice);
            _service.Create(entity);
            _db.SaveChange();
            var reason = "创建商品调价单";

            entity = _db.Table.Find <AdjustSalePrice>(n => n.Code == entity.Code);
            _processHistoryService.Track(model.UpdatedBy, model.UpdatedByName, (int)entity.Status, entity.Id, BillIdentity.AdjustSalePrice.ToString(), reason);
            _db.SaveChange();
        }