Ejemplo n.º 1
0
        /// <summary>
        /// 适用门店名称
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static string GetStoreTitleList(string storeId)
        {
            string storeTitleList = "", storeTitle = "";

            string[] arr = storeId.Split(',');
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[0] == "")
                {
                    storeTitleList = "全部";
                    break;
                }
                else
                {
                    if (!string.IsNullOrEmpty(arr[i]))
                    {
                        var sId = arr[i];
                        storeTitle = WarehouseService.Find(o => o.CompanyId == CommonService.CompanyId && o.StoreId == sId).Title;
                    }
                    storeTitleList += i > 0 ? ("、" + storeTitle) : storeTitle;
                }
            }
            return(storeTitleList);
        }
Ejemplo n.º 2
0
        public static OpResult OutboundImport(ImportSet obj, System.Web.HttpFileCollectionBase httpFiles, string fieldName, string columnName)
        {
            var op    = new OpResult();
            var errLs = new List <string>();
            int count = 0;
            var list  = new List <OutboundList>();

            try
            {
                Dictionary <string, char> fieldCols = null;
                DataTable dt = null;
                op = ImportSetService.ImportSet(obj, httpFiles, fieldName, columnName, ref fieldCols, ref dt);
                if (!op.Successed)
                {
                    return(op);
                }
                var storeId  = System.Web.HttpContext.Current.Request["StoreId"];
                var products = new List <VwProduct>();
                if (!storeId.IsNullOrEmpty())
                {
                    var ware = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
                    if (ware != null)
                    {
                        var categorySNs = ware.CategorySN.Split(',').Select(o => int.Parse(o)).ToList();
                        var childs      = ProductCategoryService.GetChildSNs(categorySNs);
                        var pros        = BaseService <VwProduct> .FindList(o => o.CompanyId == CommonService.CompanyId && childs.Contains(o.CategorySN));

                        products.AddRange(pros);
                    }
                }
                var barcodeIdx  = fieldCols.GetValue("Barcode").ToType <int>() - 65;
                var outPriceIdx = fieldCols.GetValue("OutPrice").ToType <int>() - 65;
                var numberIdx   = fieldCols.GetValue("OutboundNumber").ToType <int>() - 65;
                var memoIdx     = fieldCols.GetValue("Memo").ToType <int>() - 65;
                count = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var pos     = i + obj.MinRow;
                    var dr      = dt.Rows[i];
                    var barcode = dr.GetValue(barcodeIdx).ToString().Trim();
                    if (barcode.IsNullOrEmpty())
                    {
                        errLs.Add("行号[" + pos + "]条码为空!");
                        continue;
                    }
                    var pro = products.FirstOrDefault(o => o.Barcode == barcode || ("," + o.Barcodes + ",").Contains("," + barcode + ","));
                    if (pro == null)
                    {
                        errLs.Add("行号[" + pos + "]该门店下无此条码!");
                        continue;
                    }
                    var outPrice = dr.GetValue(outPriceIdx).ToType <decimal?>();
                    if (!outPrice.HasValue && outPriceIdx >= 0)
                    {
                        errLs.Add("行号[" + pos + "]该条码价格为空!");
                        continue;
                    }
                    var number = dr.GetValue(numberIdx).ToType <decimal?>();
                    if (!number.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码出库数量为空!");
                        continue;
                    }

                    list.Add(new OutboundList()
                    {
                        Barcode        = barcode,
                        ProductTitle   = pro.Title,
                        BuyPrice       = pro.BuyPrice,
                        OutboundNumber = number.Value,
                        Unit           = pro.SubUnit,
                        SysPrice       = pro.SysPrice,
                        OutPrice       = outPrice ?? pro.SysPrice,
                        Memo           = dr.GetValue(memoIdx).ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                op.Message   = ex.Message;
                op.Successed = false;
                Log.WriteError(ex);
                errLs.Add("导入出现异常!");
            }
            return(CommonService.GenerateImportHtml(errLs, count, data: list, isSuccess: false));
        }
Ejemplo n.º 3
0
        public static OpResult SaveOrUpdate(MemberIntegralSet obj)
        {
            if (!obj.EndDate.HasValue)
            {
                obj.EndDate = DateTime.Now.AddYears(20);
            }
            var Inserted     = HttpContext.Current.Request["Inserted"];
            var InsertedType = HttpContext.Current.Request["Inserted2"];
            var Deleted      = HttpContext.Current.Request["Deleted"];
            var DeletedType  = HttpContext.Current.Request["Deleted2"];
            var Updated      = HttpContext.Current.Request["Updated"];
            var UpdatedType  = HttpContext.Current.Request["Updated2"];

            obj.CustomerObj = HttpContext.Current.Request["CustomerObj"];
            var insertList = new List <MemberIntegralSetList>();
            var deleteList = new List <MemberIntegralSetList>();
            var updateList = new List <MemberIntegralSetList>();

            if (!Inserted.IsNullOrEmpty())
            {
                var list = Inserted.ToObject <List <MemberIntegralSetList> >();
                list.Each(o => { o.SetType = 1; });
                insertList.AddRange(list);
            }
            if (!InsertedType.IsNullOrEmpty())
            {
                var list = InsertedType.ToObject <List <MemberIntegralSetList> >();
                list.Each(o => { o.SetType = 2; });
                insertList.AddRange(list);
            }
            if (!Updated.IsNullOrEmpty())
            {
                updateList.AddRange(Updated.ToObject <List <MemberIntegralSetList> >());
            }
            if (!UpdatedType.IsNullOrEmpty())
            {
                updateList.AddRange(UpdatedType.ToObject <List <MemberIntegralSetList> >());
            }
            if (!Deleted.IsNullOrEmpty())
            {
                deleteList.AddRange(Deleted.ToObject <List <MemberIntegralSetList> >());
            }
            if (!DeletedType.IsNullOrEmpty())
            {
                deleteList.AddRange(DeletedType.ToObject <List <MemberIntegralSetList> >());
            }
            obj.OperatorUID  = Sys.CurrentUser.UID;
            obj.OperatorTime = DateTime.Now;
            obj.CompanyId    = CommonService.CompanyId;
            var op = new OpResult();

            if (obj.Id == 0)
            {
                obj.ProductList = insertList;
                #region 操作日志
                var msg = Sys.LogEngine.CompareModelToLog <MemberIntegralSet>(Sys.LogModule.消费积分, obj);
                new Sys.LogEngine().WriteInsert(msg, Sys.LogModule.消费积分);
                #endregion
                op = Add(obj);
            }
            else
            {
                var res = CurrentRepository.QueryEntity.Include(o => o.ProductList).FirstOrDefault(o => o.Id == obj.Id);
                obj.ToCopyProperty(res);
                updateList.Each(o =>
                {
                    var pro = res.ProductList.FirstOrDefault(i => i.Id == o.Id);
                    if (pro != null)
                    {
                        o.ToCopyProperty(pro);
                    }
                });
                deleteList.Each(o =>
                {
                    var pro = res.ProductList.FirstOrDefault(i => i.Id == o.Id);
                    if (pro != null)
                    {
                        BaseService <MemberIntegralSetList> .CurrentRepository.Remove(pro, false);
                    }
                });
                res.ProductList.AddRange(insertList);
                op = Update(res);
            }
            if (op.Successed)
            {
                var stores = string.Join(",", WarehouseService.GetList().Select(o => o.StoreId));
                Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged()
                {
                    CompanyId = Sys.SysCommonRules.CompanyId, StoreId = stores, Target = "MemberIntegralSetPackage"
                });
            }
            return(op);
        }
Ejemplo n.º 4
0
        public static OpResult InboundImport(ImportSet obj, System.Web.HttpFileCollectionBase httpFiles, string fieldName, string columnName)
        {
            var op    = new OpResult();
            var errLs = new List <string>();
            int count = 0;
            var list  = new List <InboundList>();

            try
            {
                Dictionary <string, char> fieldCols = null;
                DataTable dt = null;
                op = ImportSetService.ImportSet(obj, httpFiles, fieldName, columnName, ref fieldCols, ref dt);
                if (!op.Successed)
                {
                    return(op);
                }
                var supplierId       = System.Web.HttpContext.Current.Request["SupplierID"];
                var storeId          = System.Web.HttpContext.Current.Request["StoreId"];
                var supplierBarcodes = new List <string>();
                var storeBarcodes    = new List <string>();
                var products         = new List <VwProduct>();
                if (!supplierId.IsNullOrEmpty())
                {
                    var bars = BaseService <ProductMultSupplier> .FindList(o => o.SupplierId == supplierId).Select(o => o.Barcode).Distinct().ToList();

                    var pros = BaseService <VwProduct> .FindList(o => o.SupplierId == supplierId || bars.Contains(o.Barcode));

                    products.AddRange(pros);
                    supplierBarcodes = pros.Select(o => o.Barcode).ToList();
                    supplierBarcodes.AddRange(pros.Where(o => !o.Barcodes.IsNullOrEmpty()).SelectMany(o => o.Barcodes.Split(',')));
                }
                if (!storeId.IsNullOrEmpty())
                {
                    var ware = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
                    if (ware != null)
                    {
                        var categorySNs = ware.CategorySN.Split(',').Select(o => int.Parse(o)).ToList();
                        var childs      = ProductCategoryService.GetChildSNs(categorySNs);
                        var pros        = BaseService <VwProduct> .FindList(o => o.CompanyId == CommonService.CompanyId && childs.Contains(o.CategorySN));

                        storeBarcodes = pros.Select(o => o.Barcode).ToList();
                        storeBarcodes.AddRange(pros.Where(o => !o.Barcodes.IsNullOrEmpty()).SelectMany(o => o.Barcodes.Split(',')));
                        products.AddRange(pros);
                    }
                }
                var barcodeIdx  = fieldCols.GetValue("Barcode").ToType <int>() - 65;
                var buyPriceIdx = fieldCols.GetValue("BuyPrice").ToType <int>() - 65;
                var numberIdx   = fieldCols.GetValue("InboundNumber").ToType <int>() - 65;
                var proDateIdx  = fieldCols.GetValue("ProducedDate").ToType <int>() - 65;
                var giftIdx     = fieldCols.GetValue("IsGift").ToType <int>() - 65;
                var memoIdx     = fieldCols.GetValue("Memo").ToType <int>() - 65;
                count = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var pos     = i + obj.MinRow;
                    var dr      = dt.Rows[i];
                    var barcode = dr.GetValue(barcodeIdx).ToString().Trim();
                    if (barcode.IsNullOrEmpty())
                    {
                        errLs.Add("行号[" + pos + "]条码为空!");
                        continue;
                    }
                    if (!supplierBarcodes.Any(o => o == barcode))
                    {
                        errLs.Add("行号[" + pos + "]该供应单位下无此条码!");
                        continue;
                    }
                    if (!storeBarcodes.Any(o => o == barcode))
                    {
                        errLs.Add("行号[" + pos + "]该门店下无此条码!");
                        continue;
                    }
                    var buyPrice = dr.GetValue(buyPriceIdx).ToType <decimal?>();
                    if (!buyPrice.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码进价为空!");
                        continue;
                    }
                    var number = dr.GetValue(numberIdx).ToType <decimal?>();
                    if (!number.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码入库数量为空!");
                        continue;
                    }
                    var      gift    = dr.GetValue(giftIdx).ToString();
                    var      proDate = dr.GetValue(proDateIdx).ToString().Trim();
                    DateTime t       = DateTime.Now;
                    if (!proDate.IsNullOrEmpty() && DateTime.TryParse(proDate, out t))
                    {
                        proDate = t.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        proDate = string.Empty;
                    }
                    var pro = products.FirstOrDefault(o => o.Barcode == barcode || ("," + o.Barcodes + ",").Contains("," + barcode + ","));
                    list.Add(new InboundList()
                    {
                        Barcode       = barcode,
                        ProductTitle  = pro.Title,
                        BuyPrice      = buyPrice.Value,
                        InboundNumber = number.Value,
                        Unit          = pro.SubUnit,
                        ProducedDate  = proDate,
                        SysPrice      = pro.SysPrice,
                        Memo          = dr.GetValue(memoIdx).ToString(),
                        IsGift        = (short)(gift == "赠品"?1:0)
                    });
                }
            }
            catch (Exception ex)
            {
                op.Message   = ex.Message;
                op.Successed = false;
                Log.WriteError(ex);
                errLs.Add("导入出现异常!");
            }
            return(CommonService.GenerateImportHtml(errLs, count, data: list, isSuccess: false));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 集合促销(即 满元、组合)
        /// </summary>
        /// <param name="collections"></param>
        /// <returns></returns>
        private List <KeyValuePair <MarketingTimelinessLimit, MarketingRule> > GetCollectionPromotionForMarketing(List <KeyValuePair <MarketingTimelinessLimit, MarketingRule> > collections)
        {
            var today         = DateTime.Now.Date;
            var discountQuery = (from a in PromotionBlendService.CurrentRepository.Entities
                                 from b in CommodityPromotionService.CurrentRepository.Entities
                                 where
                                 a.CommodityId == b.Id &&
                                 b.State != 2 &&
                                 b.EndDate >= today &&
                                 (("," + b.StoreId + ",").Contains("," + StoreId + ",") || ("," + b.StoreId + ",").Contains(",-1,")) &&
                                 (b.PromotionType == 3 || b.PromotionType == 5) && a.CompanyId == CompanyId && b.CompanyId == CompanyId
                                 select new { a, b }).ToList();

            foreach (var item in discountQuery)
            {
                try
                {
                    var marketingTimelinessLimit = GetMarketingTimelinessLimit(item.b);
                    var marketingRules           = GetMarketingRule(item.b);
                    marketingRules.IsRepeatMarketing = Convert.ToBoolean(item.a.AllowedAccumulate);
                    marketingRules.Type = item.a.RuleType == 1 ? MarketingType.Zuhe : MarketingType.Manyuan;
                    var promotionBlendList  = PromotionBlendListService.CurrentRepository.Entities.Where(o => o.CommodityId == item.a.CommodityId).ToList();
                    var barcodeRanges       = new List <string>();
                    var giftRanges          = new List <KeyValuePair <string, decimal> >();
                    var ignoreBarcodeRanges = new List <string>();
                    foreach (var child in promotionBlendList)
                    {
                        switch (child.BlendType)
                        {
                        case 1:
                            barcodeRanges.Add(child.BarcodeOrCategorySN);
                            break;

                        case 2:
                            if (child.BrandSN != 0)
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3, child.BrandSN);
                                barcodeRanges.AddRange(productList);
                            }
                            else
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3);
                                barcodeRanges.AddRange(productList);
                            }
                            break;

                        case 3:
                            giftRanges.Add(new KeyValuePair <string, decimal>(child.BarcodeOrCategorySN, child.Number ?? 1));
                            break;

                        case 4:
                            if (child.BrandSN != 0)
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3, child.BrandSN);
                                giftRanges.AddRange(productList.Select(o => new KeyValuePair <string, decimal>(o, child.Number ?? 1)).ToList());
                            }
                            else
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3);
                                giftRanges.AddRange(productList.Select(o => new KeyValuePair <string, decimal>(o, child.Number ?? 1)).ToList());
                            }
                            break;

                        case 5:
                            ignoreBarcodeRanges.Add(child.BarcodeOrCategorySN);
                            break;

                        case 6:
                            if (child.BrandSN != 0)
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3, child.BrandSN);
                                ignoreBarcodeRanges.AddRange(productList);
                            }
                            else
                            {
                                var productList = GetProductRanges(Convert.ToInt32(child.BarcodeOrCategorySN), child.CategoryGrade ?? 3);
                                ignoreBarcodeRanges.AddRange(productList);
                            }
                            break;
                        }
                    }
                    marketingRules.BarcodeRange       = barcodeRanges;
                    marketingRules.IgnoreBarcodeRange = ignoreBarcodeRanges;
                    marketingRules.RuleNumber         = item.a.FullNumber;
                    marketingRules.MarketingAction    = new MarketingAction()
                    {
                        AddMoney              = 0m,
                        Discount              = 0m,
                        MarketingActionMode   = MarketingActionMode.Gift,
                        DiscountAmount        = 0m,
                        MarketingActionNumber = 0m,
                        Repeatable            = Convert.ToBoolean(item.a.AllowedAccumulate)
                    };
                    switch (item.a.PromotionType)
                    {
                    case 1:
                        marketingRules.MarketingAction.MarketingActionMode = MarketingActionMode.NowCash;
                        marketingRules.MarketingAction.Amount = item.a.DiscountOrPrice;

                        break;

                    case 2:
                        marketingRules.MarketingAction.MarketingActionMode = MarketingActionMode.CashCoupon;
                        marketingRules.MarketingAction.Amount = item.a.DiscountOrPrice;
                        break;

                    case 3:
                        marketingRules.MarketingAction.MarketingActionMode = MarketingActionMode.Discount;
                        marketingRules.MarketingAction.Discount            = item.a.DiscountOrPrice;
                        break;

                    case 4:
                        if (item.a.DiscountOrPrice > 0)
                        {
                            marketingRules.MarketingAction.MarketingActionMode = MarketingActionMode.AddMoneyToGive;
                        }
                        marketingRules.MarketingAction.AddMoney = item.a.DiscountOrPrice;
                        marketingRules.MarketingAction.Gifts    = giftRanges;
                        break;

                    case 5:
                        if (item.a.DiscountOrPrice > 0)
                        {
                            marketingRules.MarketingAction.MarketingActionMode = MarketingActionMode.AddMoneyToGive;
                        }
                        marketingRules.MarketingAction.AddMoney = item.a.DiscountOrPrice;
                        var products = WarehouseService.CheckedPrice(StoreId, CompanyId, null, 0, item.a.PriceRange);
                        var ranges   = products.Select(o => o.Barcode).Distinct().Select(o => new KeyValuePair <string, decimal>(o, 1)).ToList();
                        marketingRules.MarketingAction.Gifts = ranges;
                        break;
                    }



                    switch (item.a.RuleType)
                    {
                    case 1:
                        marketingRules.MeteringMode = MeteringMode.QiGouLiang;
                        break;

                    case 2:
                        marketingRules.MeteringMode = MeteringMode.ManYuan;
                        break;
                    }


                    collections.Add(new KeyValuePair <MarketingTimelinessLimit, MarketingRule>(marketingTimelinessLimit, marketingRules));
                }
                catch (Exception ex)
                {
                    goto Continue;
                }
Continue:
                continue;
            }
            return(collections);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 库存查询列表
        /// </summary>
        /// <param name="nvl"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public static DataTable QueryInventoryPageList(NameValueCollection nvl, out int recordCount, ref object footer)
        {
            var nl = new NameValueCollection()
            {
                nvl
            };
            DataTable dt = null;

            if (Sys.CurrentUser.IsStore)
            {
                nl["store"] = Sys.CurrentUser.StoreId;
                var store  = WarehouseService.Find(o => o.CompanyId == CommonService.CompanyId && o.StoreId == Sys.CurrentUser.StoreId);
                var childs = ProductCategoryService.GetChildSNs(store.CategorySN.Split(',').Select(o => int.Parse(o)).ToList(), true);
                if (!nl["parentType"].IsNullOrEmpty())
                {
                    var childs2 = ProductCategoryService.GetChildSNs(new List <int>()
                    {
                        int.Parse(nl["parentType"])
                    }, true);
                    childs = childs.Where(o => childs2.Contains(o)).ToList();
                }
                nl["parentType"] = childs.Any() ? string.Join(",", childs) : "";
                //dt = dal.QueryStoreInventorys(nl, out recordCount);
                dt = dal.QueryInventorys(nl);
            }
            else
            {
                if (!nl["store"].IsNullOrEmpty())
                {
                    var storeId = nl["store"];
                    var store   = WarehouseService.Find(o => o.CompanyId == CommonService.CompanyId && o.StoreId == storeId);
                    var childs  = ProductCategoryService.GetChildSNs(store.CategorySN.Split(',').Select(o => int.Parse(o)).ToList(), true);
                    if (!nl["parentType"].IsNullOrEmpty())
                    {
                        var childs2 = ProductCategoryService.GetChildSNs(new List <int>()
                        {
                            int.Parse(nl["parentType"])
                        }, true);
                        childs = childs.Where(o => childs2.Contains(o)).ToList();
                    }
                    nl["parentType"] = childs.Any() ? string.Join(",", childs) : "0";
                }
                else if (!nl["parentType"].IsNullOrEmpty())
                {
                    var childs = ProductCategoryService.GetChildSNs(new List <int>()
                    {
                        int.Parse(nl["parentType"])
                    }, true);
                    nl["parentType"] = string.Join(",", childs);
                }
                dt = dal.QueryInventorys(nl);
            }
            recordCount = 0;
            if (nl["ispage"] != "0")//分页
            {
                if (dt.Rows.Count > 0)
                {
                    recordCount = Convert.ToInt32(dt.Rows[0]["RecordTotal"]);
                }
            }
            decimal stockNumbers = 0, saleAmounts = 0, stockAmounts = 0;

            if (dt.Rows.Count > 0)
            {
                var dr = dt.Rows[0];
                stockNumbers += Convert.ToDecimal(dr["StockNumbers"]);
                saleAmounts  += Convert.ToDecimal(dr["SaleAmounts"]);
                stockAmounts += Convert.ToDecimal(dr["StockAmounts"]);
            }
            footer = new List <object>()
            {
                new { StockNumber = stockNumbers, SaleAmount = saleAmounts, StockAmount = stockAmounts, Title = "合计:" }
            };
            ProductService.SetSysPrice(nl["store"], dt);
            return(dt);
        }
Ejemplo n.º 7
0
        public static OpResult AddStockLock(TreasuryLocks obj)
        {
            var op = new OpResult();

            try
            {
                obj.LockStoreID.IsNullThrow();
                var xh = obj.CheckBatch.Substring(obj.CheckBatch.Length - 2);
                if (int.Parse(xh) > 20)
                {
                    op.Message = "每月最多只能锁定20次"; return(op);
                }
                var selectBarcodes = HttpContext.Current.Request["selectBarcodes"];
                var barcodes       = new string[] { };
                if (selectBarcodes.IsNullOrEmpty())
                {
                    List <int> childsns = null;
                    if (!obj.LockCategorySN.IsNullOrEmpty())
                    {
                        var parsns = obj.LockCategorySN.Split(',').Select(o => int.Parse(o)).ToList();
                        childsns = ProductCategoryService.GetChildSNs(parsns, true);
                    }
                    else
                    {
                        var ware   = WarehouseService.Find(o => o.StoreId == obj.LockStoreID && o.CompanyId == CommonService.CompanyId);
                        var parsns = ware.CategorySN.Split(',').Where(o => !o.IsNullOrEmpty()).Select(o => int.Parse(o)).ToList();
                        childsns = ProductCategoryService.GetChildSNs(parsns);
                    }
                    barcodes = ProductService.FindList(o => childsns.Contains(o.CategorySN) && o.CompanyId == CommonService.CompanyId).Select(o => o.Barcode).Distinct().ToArray();
                }
                else
                {
                    barcodes = selectBarcodes.Split(',');
                }

                var dt = dal.GetInventoryBalanceLast(CommonService.CompanyId, obj.LockStoreID, string.Join(",", barcodes));
                if (dt == null || dt.Rows.Count <= 0)
                {
                    op.Message = "该门店暂无库存信息";
                }
                else
                {
                    obj.LockDate  = DateTime.Now;
                    obj.LockUID   = Sys.CurrentUser.UID;
                    obj.CompanyId = CommonService.CompanyId;
                    var stocks = new List <StockTaking>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (stocks.Any(o => o.Barcode == dr["Barcode"].ToString()))
                        {
                            continue;
                        }
                        stocks.Add(new StockTaking()
                        {
                            Barcode    = dr["Barcode"].ToString(),
                            LockNumber = dr["Number"].ToType <decimal>(),
                            CheckBatch = obj.CheckBatch,
                            CreateDT   = obj.LockDate,
                            CreateUID  = obj.LockUID,
                            CompanyId  = obj.CompanyId
                        });
                    }
                    BaseService <TreasuryLocks> .Add(obj, false);

                    op = AddRange(stocks);
                }
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                Log.WriteError(ex);
            }
            return(op);
        }