public void Create(CreateStorePurchaseOrder model)
        {
            var entity = new StorePurchaseOrder();

            entity = model.MapTo <StorePurchaseOrder>();
            entity.AddItems(model.ConvertJsonToItem());
            var reason       = "创建采购单";
            var billIdentity = BillIdentity.StorePurchaseOrder;

            if (entity.OrderType == OrderType.Refund)
            {
                reason       = "创建采购退单";
                billIdentity = BillIdentity.StorePurchaseRefundOrder;
            }

            var entitys = _service.SplitOrderItem(entity);

            foreach (var order in entitys)
            {
                entity.Code = _sequenceService.GenerateNewCode(billIdentity);
                entity.SetItems(order.Items.ToList());
                _db.Insert(entity);
                var history = new ProcessHistory(model.CreatedBy, model.CreatedByName, (int)entity.Status, entity.Id, billIdentity.ToString(), reason);
                _db.Command.AddExecute(history.CreateSql(entity.GetType().Name, entity.Code), history);
                _db.SaveChange();
            }
        }
Exemple #2
0
        public void Create(TransferOrderModel model)
        {
            TransferOrder entity = model.MapTo <TransferOrder>();

            entity.CreatedBy     = model.EditBy;
            entity.CreatedByName = model.EditByName;
            entity.UpdatedBy     = model.EditBy;
            entity.Code          = _sequenceService.GenerateNewCode(BillIdentity.TransferOrder);
            // 明细
            var items = JsonConvert.DeserializeObject <List <TransferOrderItem> >(model.ItemsJson);

            entity.Items = items;
            _db.Insert(entity);

            //跟踪记录
            var reason  = "创建调拨单";
            var history = new ProcessHistory(model.EditBy, model.EditByName, (int)entity.Status, entity.Id, BillIdentity.TransferOrder.ToString(), reason);

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

            _db.SaveChange();
            var modelEntity = _db.Table.Find <TransferOrder>(n => n.Code == entity.Code);

            model.Id         = modelEntity.Id;
            model.Code       = entity.Code;
            model.StatusName = entity.Status.Description();
            entity.Id        = modelEntity.Id;
        }
Exemple #3
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();
        }
Exemple #4
0
        public void Create(OutInOrderModel model)
        {
            OutInOrder entity = model.MapTo <OutInOrder>();

            entity.CreatedBy     = model.EditBy;
            entity.CreatedByName = model.EditByName;
            entity.UpdatedBy     = model.EditBy;
            entity.UpdatedByName = model.EditByName;
            // entity.Code = _sequenceService.GenerateNewCode(BillIdentity.OtherInOrder);
            // 明细
            var items = JsonConvert.DeserializeObject <List <OutInOrderItem> >(model.ItemsJson);

            entity.SetItems(items);
            var orderType = _db.Table.Find <OutInOrderType>(entity.OutInOrderTypeId);

            if (orderType == null)
            {
                throw new FriendlyException("业务类别为空");
            }

            var reason       = "创建其他入库单";
            var billIdentity = BillIdentity.OtherInOrder;

            if (orderType.OutInInventory == OutInInventoryType.Out)
            {
                reason       = "创建其他出库单";
                billIdentity = BillIdentity.OtherOutOrder;
            }

            var entitys = _service.SplitOrderItem(entity, orderType);

            foreach (var order in entitys)
            {
                entity.Code = _sequenceService.GenerateNewCode(billIdentity);
                entity.SetItems(order.Items.ToList());
                _db.Insert(entity);
                var history = new ProcessHistory(entity.CreatedBy, entity.CreatedByName, (int)entity.Status, entity.Id, billIdentity.ToString(), reason);
                _db.Command.AddExecute(history.CreateSql(entity.GetType().Name, entity.Code), history);
                _db.SaveChange();

                if (model.SaveAndSubmit)
                {
                    var modelEntity = _db.Table.Find <OutInOrder>(n => n.Code == entity.Code);
                    model.Id = modelEntity.Id;
                    Submit(model.Id, model.EditBy, model.EditByName);
                }
            }
        }