Beispiel #1
0
 public async Task <ApiResult <string> > EditBarCode(ErpGoodsSku parm)
 {
     return(await _skuGoodsService.ModifyAsync(parm));
 }
Beispiel #2
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <returns></returns>
        public async Task <ApiResult <string> > AddAsync(ErpGoodsSku parm)
        {
            var res = new ApiResult <string>()
            {
                data = "1", statusCode = 200
            };

            try
            {
                //判断是否存在
                var isExt = ErpGoodsSkuDb.IsAny(m => m.Code == parm.Code);
                if (isExt)
                {
                    res.statusCode = (int)ApiEnum.ParameterError;
                    res.message    = "该条形码已存在~";
                }
                else
                {
                    //构建Code
                    var codeType = SysCodeTypeDb.GetList(m => m.ParentGuid == "8d3158d6-e179-4046-99e9-53eb8c04ddb1").Select(m => m.Guid).ToList();
                    var codeList = SysCodeDb.GetList(m => codeType.Contains(m.ParentGuid));
                    parm.Code = codeList.Find(m => m.Guid == parm.BrankGuid).CodeType
                                + codeList.Find(m => m.Guid == parm.YearGuid).CodeType
                                + codeList.Find(m => m.Guid == parm.SeasonGuid).CodeType
                                + codeList.Find(m => m.Guid == parm.StyleGuid).CodeType
                                + codeList.Find(m => m.Guid == parm.BatchGuid).CodeType
                                + codeList.Find(m => m.Guid == parm.SizeGuid).CodeType
                                + parm.SalePrice
                                + "-" + parm.DisPrice;

                    //构建商品标题
                    var brankName = codeList.Find(m => m.Guid == parm.BrankGuid).Name;
                    var styleName = codeList.Find(m => m.Guid == parm.StyleGuid).Name;
                    var goodsName = brankName + codeList.Find(m => m.Guid == parm.SeasonGuid).Name + styleName;

                    //构建商品信息
                    var goodsModel = new ErpGoods()
                    {
                        Guid  = Guid.NewGuid().ToString(),
                        Title = goodsName,
                        Brank = brankName,
                        Style = styleName
                    };

                    parm.GoodsGuid = goodsModel.Guid;
                    parm.Guid      = Guid.NewGuid().ToString();

                    //事务保证数据一致性
                    Db.Ado.BeginTran();
                    var goodsres = ErpGoodsDb.Insert(goodsModel);
                    if (goodsres)
                    {
                        var dbres = ErpGoodsSkuDb.Insert(parm);
                        if (!dbres)
                        {
                            res.statusCode = (int)ApiEnum.Error;
                            res.message    = "插入数据失败~";
                        }
                    }
                    Db.Ado.CommitTran();
                }
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                res.statusCode = (int)ApiEnum.Error;
                res.message    = ApiEnum.Error.GetEnumText() + ex.Message;
            }
            return(await Task.Run(() => res));
        }
Beispiel #3
0
 public async Task <ApiResult <string> > AddMenu(ErpGoodsSku parm)
 {
     return(await _skuGoodsService.AddAsync(parm));
 }