Exemplo n.º 1
0
        //private bool ContainsBondedProducts(List<Order> orders)
        //{
        //    if (null == orders || orders.Count <= 0)
        //        return false;

        //    foreach (Order o in orders)
        //    {
        //        if (o.Items.Contains("保税区"))
        //            return true;
        //    }
        //    return false;
        //}

        // 从多个订单中提取产品信息, 相同产品合并计数.
        private List <SoldProductInfo> GetProducts(List <Order> orders, out int cMustSendFromDe, out int cBonded)
        {
            cMustSendFromDe = 0;
            cBonded         = 0;
            SortedList <string, SoldProductInfo> sortedProducts = new SortedList <string, SoldProductInfo>();

            foreach (Order o in orders)
            {
                string   allItems = o.Items;
                string[] items    = allItems.Split('★');
                for (int i = 0; i < items.Length; i++)
                {
                    string   item  = items[i];
                    string[] infos = item.Split('☆');
                    if (infos.Length < 3)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(infos[0]))
                    {
                        Trace.WriteLine("null product found!!!");
                    }

                    string productTitle = infos[0];
                    int    count        = int.Parse(infos[2]);

                    ProductInfo pi = ProductInfo.Match(productTitle, o.Remark);
                    if (null == pi)
                    {
                        continue;
                    }

                    for (int c = 16; c > 0; c--)
                    {
                        if (productTitle.Contains(string.Format("{0}盒装", c)) || productTitle.Contains(string.Format("{0}罐装", c)))
                        {
                            count *= c;
                            break;
                        }
                    }

                    //// 双11链接, 1+12盒链接, 1+4盒链接, 2+12盒链接, 2+4盒链接, 3段4罐链接
                    //if (productTitle.Contains("12盒包邮包税") || productTitle.Contains("直邮12盒"))
                    //    count *= 12;
                    //if (productTitle.Contains("直邮9罐"))
                    //    count *= 9;
                    //if (productTitle.Contains("现货4盒"))
                    //    count *= 4;
                    //if (productTitle.Contains("现货4罐"))
                    //    count *= 4;
                    //if (productTitle.Contains("3罐"))
                    //    count *= 3;
                    //if (pi.Id.Equals("001-0005") && productTitle.Contains("12盒包邮包税"))
                    //    count *= 12;
                    //if (pi.Id.Equals("001-0005") && productTitle.Contains("4盒"))
                    //    count *= 4;
                    //if (pi.Id.Equals("001-0006") && productTitle.Contains("12盒包邮包税"))
                    //    count *= 12;
                    //if (pi.Id.Equals("001-0006") && productTitle.Contains("4盒"))
                    //    count *= 4;
                    //if (pi.Id.Equals("001-0004") && productTitle.Contains("4罐"))
                    //    count *= 4;

                    Order.OrderStatus status = (Order.OrderStatus)Enum.Parse(typeof(Order.OrderStatus), infos[3]);
                    bool succeeded           = false;
                    bool cancelled           = false;
                    bool sent = false;
                    if (infos.Length >= 4)
                    {
                        succeeded = (status == Order.OrderStatus.Succeeded);
                        cancelled = (status == Order.OrderStatus.Closed);
                        sent      = (status == Order.OrderStatus.Sent);
                    }
                    if (succeeded || cancelled || sent)
                    {
                        continue;
                    }

                    string code = string.Empty;
                    if (infos.Length >= 5)
                    {
                        code = infos[4];
                    }
                    if (code.ToLower().StartsWith("d-"))
                    {
                        cMustSendFromDe++;
                        continue;
                    }
                    // Removed by KK on 2015/09/18.
                    // 保税区不再设单独链接, 可以/可能跟其他链接共用.
                    // 同时, cBonded不再准确.
                    //if (!code.ToLower().StartsWith("b-") && !productTitle.Contains("保税区"))
                    //    continue;
                    cBonded++;

                    bool bingo = false;
                    foreach (SoldProductInfo spi in sortedProducts.Values)
                    {
                        if (spi.Id.Equals(pi.Id))
                        {
                            bingo = true;
                            spi.AddCount(count);
                            break;
                        }
                    }

                    if (!bingo)
                    {
                        sortedProducts.Add(pi.Id, new SoldProductInfo(pi.Id, pi.BrandId, pi.SkuCode, pi.NingboId, pi.DangdangCode, pi.Name, pi.Price, pi.Specification, pi.ShortName, pi.Keywords, pi.Conflict, count, status, code));
                    }
                    //products.Add(new SoldProductInfo(pi.Id, pi.BrandId, pi.Name, pi.Price, pi.Specification, pi.ShortName, pi.Keywords, count, status));
                }
            }

            List <SoldProductInfo> products = new List <SoldProductInfo>();

            foreach (SoldProductInfo p in sortedProducts.Values)
            {
                products.Add(p);
            }
            return(products);
        }
Exemplo n.º 2
0
 public ProductInfoItem(ProductInfo pi)
 {
     _pi = pi;
 }