コード例 #1
0
        /// <summary>
        /// 修改一条数据
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > ModifyAsync(ErpInOutLog parm)
        {
            var res = new ApiResult <string>()
            {
                data = "1", statusCode = 200
            };

            try
            {
                //判断条形码是否存在
                var isExt = ErpGoodsSkuDb.IsAny(m => m.Guid == parm.GoodsGuid && !m.IsDel);
                if (!isExt)
                {
                    res.statusCode = (int)ApiEnum.ParameterError;
                    res.message    = "该条形码不存在~";
                }
                else
                {
                    var dbres = ErpInOutLogDb.Update(parm);
                    if (!dbres)
                    {
                        res.statusCode = (int)ApiEnum.Error;
                        res.message    = "修改数据失败~";
                    }
                }
            }
            catch (Exception ex)
            {
                res.statusCode = (int)ApiEnum.Error;
                res.message    = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }
コード例 #2
0
 public void OnGet(string guid, string packguid)
 {
     InoutModel = _inService.GetByGuidAsync(guid).Result.data;
     if (string.IsNullOrEmpty(InoutModel.Guid))
     {
         InoutModel.PackGuid  = packguid;
         InoutModel.GoodsSum  = 1;
         InoutModel.AdminGuid = @User.Identities.First(u => u.IsAuthenticated).FindFirst(ClaimTypes.Sid).Value;
     }
 }
コード例 #3
0
 public void OnGet(string packguid, string shopguid)
 {
     InoutModel = new ErpInOutLog()
     {
         PackGuid  = packguid,
         GoodsSum  = 1,
         Types     = 2,
         AdminGuid = @User.Identities.First(u => u.IsAuthenticated).FindFirst(ClaimTypes.Sid).Value,
         ShopGuid  = shopguid
     };
 }
コード例 #4
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > AddAsync(ErpInOutLog parm)
        {
            var res = new ApiResult <string>()
            {
                statusCode = 200
            };

            try
            {
                //判断条形码是否存在
                var skuModel = ErpGoodsSkuDb.GetSingle(m => m.Code == parm.GoodsSku && !m.IsDel);
                if (skuModel == null)
                {
                    res.statusCode = (int)ApiEnum.ParameterError;
                    res.message    = "该条形码不存在~";
                    return(await Task.Run(() => res));
                }
                if (parm.Types == 2)
                {
                    //出库  需要判断库存是否足够
                    if (skuModel.StockSum < parm.GoodsSum)
                    {
                        res.statusCode = (int)ApiEnum.ParameterError;
                        res.message    = "库存不足,只剩下" + skuModel.StockSum + "件~";
                        return(await Task.Run(() => res));
                    }
                }
                parm.Guid      = Guid.NewGuid().ToString();
                parm.GoodsGuid = skuModel.Guid;
                //开启事务
                Db.Ado.BeginTran();
                if (parm.Types == 1)
                {
                    //更新该条形码的库存
                    ErpGoodsSkuDb.Update(m => new ErpGoodsSku()
                    {
                        StockSum = m.StockSum + parm.GoodsSum
                    }, m => m.Guid == parm.GoodsGuid);
                }
                else
                {
                    //更新平台的库存,减少
                    ErpGoodsSkuDb.Update(m => new ErpGoodsSku()
                    {
                        StockSum = m.StockSum - parm.GoodsSum
                    }, m => m.Guid == parm.GoodsGuid);
                    //增加到店铺条形码表中
                    var shopSku = ErpShopSkuDb.GetSingle(m => m.ShopGuid == parm.ShopGuid && m.SkuGuid == parm.GoodsGuid);
                    if (shopSku != null)
                    {
                        //修改,增加库存
                        ErpShopSkuDb.Update(m => new ErpShopSku()
                        {
                            Stock = m.Stock + parm.GoodsSum, UpdateDate = DateTime.Now
                        }, m => m.ShopGuid == parm.ShopGuid && m.SkuGuid == parm.GoodsGuid);
                    }
                    else
                    {
                        //增加一条库存
                        var shopSkuModel = new ErpShopSku()
                        {
                            SkuGuid  = skuModel.Guid,
                            SkuCode  = skuModel.Code,
                            ShopGuid = parm.ShopGuid,
                            Stock    = parm.GoodsSum
                        };
                        ErpShopSkuDb.Insert(shopSkuModel);
                    }
                }
                ErpInOutLogDb.Insert(parm);
                Db.Ado.CommitTran();
            }
            catch (Exception ex)
            {
                Db.Ado.CommitTran();
                res.statusCode = (int)ApiEnum.Error;
                res.message    = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }
コード例 #5
0
ファイル: StockController.cs プロジェクト: xman086/SoaProJect
 public async Task <ApiResult <string> > AddInOutAsync(ErpInOutLog parm)
 {
     return(await _inOutLogService.AddAsync(parm));
 }
コード例 #6
0
ファイル: StockController.cs プロジェクト: xman086/SoaProJect
 public async Task <ApiResult <string> > EditIn(ErpInOutLog parm)
 {
     return(await _inOutLogService.ModifyAsync(parm));
 }