public void UpdateProductsData(SkuList skuList, ProductsList productsList)
        {
            _skuUpdater.SkuCancellationTokenSource.Token.ThrowIfCancellationRequested();
            _skuUpdater.SkuProgress(SkuProgressStep.UpdateProductsData);

            foreach (var skuItem in skuList.List)
            {
                Func <ProductItem, bool> findProductPredicate =
                    product => product.Sku == skuItem.Sku && (skuItem.Price.HasValue || skuItem.Quantity.HasValue);
                var anyProduct = productsList.List.Any(findProductPredicate);
                if (!anyProduct)
                {
                    skuItem.Unused = true;
                    continue;
                }

                foreach (var product in productsList.List.Where(findProductPredicate))
                {
                    if (skuItem.Price.HasValue)
                    {
                        product.Price = skuItem.Price.Value;
                    }
                    if (skuItem.Quantity.HasValue)
                    {
                        product.Quantity = skuItem.Quantity.Value;
                    }
                    product.Updated = true;
                }
            }
        }
Beispiel #2
0
        public WeProduct(string productId, WeProductBase productBase, DeliveryInfo deliveryInfo,
                         ProductStatus status, params SkuListElement[] skuList)
            : this(productId, productBase, deliveryInfo, status)
        {
            TkDebug.AssertArgumentNull(skuList, "skuList", null);

            SkuList.AddRange(skuList);
        }
Beispiel #3
0
        public WeProduct(string productId, WeProductBase productBase, SkuListElement sku,
                         DeliveryInfo deliveryInfo, ProductStatus status)
            : this(productId, productBase, deliveryInfo, status)
        {
            TkDebug.AssertArgumentNull(sku, "sku", null);

            SkuList.Add(sku);
        }
Beispiel #4
0
        protected override Dictionary <Product, IEnumerable <string> > GetValues(List <Product> objs)
        {
            SkuList list     = null;
            var     skuLists = _session.QueryOver <ProductVariant>()
                               .SelectList(builder => builder
                                           .Select(variant => variant.SKU).WithAlias(() => list.SKU)
                                           .Select(variant => variant.Product.Id).WithAlias(() => list.ProductId)
                                           )
                               .TransformUsing(Transformers.AliasToBean <SkuList>())
                               .List <SkuList>();
            var groupedSkus = skuLists.GroupBy(skuList => skuList.ProductId)
                              .ToDictionary(lists => lists.Key, lists => lists.Select(skuList => skuList.SKU));

            return(objs.ToDictionary(product => product,
                                     product => groupedSkus.ContainsKey(product.Id) ? groupedSkus[product.Id] : Enumerable.Empty <string>()));
        }
Beispiel #5
0
        public void syncwelFareSKU()
        {
            var interfaceName      = "syncwelFareSKU";
            var loggingSessionInfo = BaseService.GetLoggingSession();
            var skuService         = new SkuService(loggingSessionInfo);

            var dsSkus = new DataSet();
            var skus   = new SkuList();

            skus.skulist = new List <Sku>();

            //更新接口同步表
            var queryList = UpdateInterfaceTimestamp(interfaceName, loggingSessionInfo);

            if (queryList != null && queryList.Length > 0)
            {
                //存在,根据日期条件查询
                dsSkus = skuService.GetSynWelfareSkuList(queryList.FirstOrDefault().LatestTime.ToString());
            }
            else
            {
                //不存在,查询所有数据
                dsSkus = skuService.GetSynWelfareSkuList(string.Empty);
            }

            if (dsSkus != null && dsSkus.Tables.Count > 0 && dsSkus.Tables[0].Rows.Count > 0)
            {
                skus.skulist = DataTableToObject.ConvertToList <Sku>(dsSkus.Tables[0]);

                //上传数据
                var content = skus.ToJSON();
                var result  = UploadData(interfaceName, skus.ToJSON());

                //写入接口日志
                var logEntity = new ZInterfaceLogEntity()
                {
                    LogId         = Utils.NewGuid(),
                    InterfaceName = interfaceName,
                    Params        = content,
                    ResultCode    = result.code,
                    ResultDesc    = result.description
                };

                InsertInterfaceLog(logEntity, loggingSessionInfo);
            }
        }
        public void UpdateSkuFile(SkuList skuList)
        {
            if (!skuList.List.Any(z => z.Unused))
            {
                return;
            }

            _skuUpdater.SkuCancellationTokenSource.Token.ThrowIfCancellationRequested();
            _skuUpdater.SkuProgress(SkuProgressStep.UpdateSkuFile);

            XSSFWorkbook workbook;

            using (var fileStream = new FileStream(_skuUpdater.SkuFilePath, FileMode.Open, FileAccess.Read))
                workbook = new XSSFWorkbook(fileStream);

            var       worksheet           = workbook.CreateSheet("Unused");
            var       rowIndex            = 0;
            const int skuColumnIndex      = 0;
            const int priceColumnIndex    = 1;
            const int quantityColumnIndex = 2;

            foreach (var product in skuList.List.Where(z => z.Unused))
            {
                var row = worksheet.GetRow(rowIndex) ?? worksheet.CreateRow(rowIndex);

                var skuCell = row.CreateCell(skuColumnIndex);
                skuCell.SetCellValue(product.Sku);

                var priceCell = row.CreateCell(priceColumnIndex);
                priceCell.SetCellValue(product.Price ?? -1);

                var quantityCell = row.CreateCell(quantityColumnIndex);
                quantityCell.SetCellValue(product.Quantity ?? -1);

                rowIndex++;
            }

            using (var fileStream = new FileStream(_skuUpdater.SkuFilePath, FileMode.Create, FileAccess.Write))
                workbook.Write(fileStream);

            workbook.Close();
        }
        private void BindSkus(Entry[] variants)
        {
            List <Entry> skus = new List <Entry>();

            foreach (var variant in variants)
            {
                var entry = CatalogContext.Current.GetCatalogEntry(
                    variant.CatalogEntryId,
                    new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Children));

                if (entry.Entries.Entry != null)
                {
                    foreach (var sku in entry.Entries.Entry)
                    {
                        skus.Add(sku);
                    }
                }
            }
            SkuList.DataSource = skus;
            SkuList.DataBind();
        }
Beispiel #8
0
 public int CountOfSku(string sku)
 {
     return(SkuList.Count(x => x.Equals(sku)));
 }