예제 #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();
        }
예제 #2
0
 public void Create(AdjustSalePrice model)
 {
     if (_db.Table.Exists <AdjustSalePrice>(n => n.Code == model.Code))
     {
         throw new Exception("调价单号已经存在");
     }
     _db.Insert(model);
 }
예제 #3
0
        public AdjustSalePrice Create(Product product, decimal adjustPrice, string code, int editBy)
        {
            AdjustSalePrice model = new AdjustSalePrice();

            model.Code      = code;
            model.Status    = ValueObject.AdjustSalePriceStatus.Valid;
            model.CreatedBy = editBy;
            model.UpdatedBy = editBy;
            model.AddItem(product, adjustPrice);
            return(model);
        }
예제 #4
0
 public void Update(AdjustSalePrice model)
 {
     if (_db.Table.Exists <AdjustSalePrice>(n => n.Code == model.Code && n.Id != model.Id))
     {
         throw new Exception("调价单号不能重复!");
     }
     if (_db.Table.Exists <AdjustSalePriceItem>(n => n.AdjustSalePriceId == model.Id))
     {
         _db.Delete <AdjustSalePriceItem>(n => n.AdjustSalePriceId == model.Id);
     }
     _db.Insert <AdjustSalePriceItem>(model.Items.ToArray());
     _db.Update(model);
 }
예제 #5
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();
        }