Esempio n. 1
0
        /// <summary>
        /// 修改一条数据
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > ModifyAsync(ErpSkuLoss parm)
        {
            var res = new ApiResult <string>()
            {
                data = "1", statusCode = (int)ApiEnum.Error
            };

            try
            {
                //根据条形码,查询条形码信息
                var skuModel = ErpGoodsSkuDb.GetSingle(m => m.Code == parm.SkuGuid);
                if (skuModel == null)
                {
                    res.message = "条形码不存在~";
                    return(await Task.Run(() => res));
                }
                var oldLoss = ErpSkuLossDb.GetSingle(m => m.Guid == parm.Guid);
                if (oldLoss == null)
                {
                    res.message = "报损信息不存在~";
                    return(await Task.Run(() => res));
                }
                //判断库存数量是否满足报损数量
                if (oldLoss.Counts < parm.Counts)
                {
                    res.message = "数量不能大于原报损数量~";
                    return(await Task.Run(() => res));
                }
                //修改原报损数量
                oldLoss.Counts -= parm.Counts;
                //减少库存
                skuModel.StockSum += parm.Counts;
                //事务,保证数据一致性
                var result = Db.Ado.UseTran(() =>
                {
                    //执行添加报损信息
                    Db.Updateable(oldLoss).ExecuteCommand();
                    //修改条形码库存
                    Db.Updateable(skuModel).ExecuteCommand();
                });
                res.statusCode = (int)ApiEnum.Status;
                if (!result.IsSuccess)
                {
                    res.message = result.ErrorMessage;
                }
            }
            catch (Exception ex)
            {
                res.message = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }
Esempio n. 2
0
 public async Task <ApiResult <string> > ModifyLoss(ErpSkuLoss parm)
 {
     return(await _lossService.ModifyAsync(parm));
 }
Esempio n. 3
0
 public async Task <ApiResult <string> > AddLoss(ErpSkuLoss parm)
 {
     return(await _lossService.AddAsync(parm));
 }