Beispiel #1
0
 public void CheckExists(AdjustStorePrice model)
 {
     if (_db.Table.Exists <AdjustStorePrice>(n => n.Code == model.Code))
     {
         throw new Exception("调价单号已经存在");
     }
 }
Beispiel #2
0
 public void Update(AdjustStorePrice model)
 {
     if (_db.Table.Exists <AdjustStorePriceItem>(n => n.AdjustStorePriceId == model.Id))
     {
         _db.Delete <AdjustStorePriceItem>(n => n.AdjustStorePriceId == model.Id);
     }
     _db.Insert <AdjustStorePriceItem>(model.Items.ToArray());
     _db.Update(model);
 }
Beispiel #3
0
        public AdjustStorePrice Create(Product product, decimal adjustPrice, string code, int editBy)
        {
            AdjustStorePrice model = new AdjustStorePrice();

            model.Code      = code;
            model.Status    = ValueObject.AdjustStorePriceStatus.Create;
            model.CreatedBy = editBy;
            model.UpdatedBy = editBy;
            model.AddItem(product, adjustPrice);
            return(model);
        }
Beispiel #4
0
        public void UpdateStoreSalePrice(AdjustStorePrice entity)
        {
            if (entity.Items.Count() == 0)
            {
                throw new FriendlyException("明细为空");
            }
            var    parma = entity.Items.Select(n => new { StoreId = entity.StoreId, ProductId = n.ProductId, AdjustPrice = n.AdjustPrice }).ToArray();
            string sql   = "update StoreInventory set StoreSalePrice =@AdjustPrice where StoreId=@StoreId and ProductId=@ProductId";

            _db.Command.AddExecute(sql, parma);
        }
Beispiel #5
0
        public void Create(AdjustStorePriceModel model)
        {
            var entity = new AdjustStorePrice();

            entity = model.MapTo <AdjustStorePrice>();
            entity.AddItems(model.ConvertJsonToItem());
            entity.CreatedBy = model.UpdatedBy;
            entity.Code      = _sequenceService.GenerateNewCode(BillIdentity.AdjustStorePrice);
            _db.Insert(entity);
            var reason  = "创建门店调价单";
            var history = new ProcessHistory(model.UpdatedBy, model.UpdatedByName, (int)entity.Status, entity.Id, BillIdentity.AdjustStorePrice.ToString(), reason);

            _db.Command.AddExecute(history.CreateSql(entity.GetType().Name, entity.Code), history);
            _db.SaveChange();
        }