示例#1
0
        /// <summary>
        /// 盘点
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <DetailGoodsDto> Check(InOutGoodsDto input)
        {
            GoodsRecord record = input.MapTo <GoodsRecord>();
            Goods       result = await _goodsManager.CheckGoods(record);

            return(result.MapTo <DetailGoodsDto>());
        }
示例#2
0
        /// <summary>
        /// 出库
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <DetailGoodsDto> Out(InOutGoodsDto input)
        {
            Goods entity = Repository.FirstOrDefault(input.Id);

            if (entity != null)
            {
                entity.GoodsNum = entity.GoodsNum - input.GoodsNum;
            }
            GoodsRecord record = input.MapTo <GoodsRecord>();

            record.OperateType = GoodsOperateType.Out;
            string recordId = await _goodsRecordManager.OutRecord(record);

            entity = await Repository.UpdateAsync(entity);

            if (entity.GoodsNum <= MinNum)
            {
                EventBus.Trigger(new GoodsNumChangedEventData
                {
                    Id        = entity.Id,
                    GoodsName = entity.GoodsName,
                    GoodsNum  = entity.GoodsNum,
                    MinNum    = MinNum
                });

                ////注册事件
                //var goodsChangedEvent = EventBus.Register<GoodsNumChangedEventData>(data =>
                //{
                //    /*
                //     * To do
                //     **/
                //});
                ////取消注册事件
                //goodsChangedEvent.Dispose();


                //string message = string.Format("货品{0}当前库存为{1},低于最低允许库存{2},请及时采购补充!", entity.GoodsName, entity.GoodsNum, MinNum);
                //await _messageManager.BoradcastMessage(message);
            }

            DetailGoodsDto result = entity.MapTo <DetailGoodsDto>();

            return(await Task.FromResult(result));
        }
示例#3
0
        /// <summary>
        /// 入库
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <DetailGoodsDto> In(InOutGoodsDto input)
        {
            Goods entity = Repository.FirstOrDefault(input.Id);

            if (entity != null)
            {
                entity.GoodsNum = entity.GoodsNum + input.GoodsNum;
            }
            GoodsRecord record = input.MapTo <GoodsRecord>();

            record.OperateType = GoodsOperateType.In;
            string recordId = await _goodsRecordManager.InRecord(record);

            entity = await Repository.UpdateAsync(entity);

            DetailGoodsDto result = entity.MapTo <DetailGoodsDto>();

            return(await Task.FromResult(result));
        }