示例#1
0
        //获取店铺促销信息
        private void GetOrderShopPromotion(string orderInformationDomain)
        {
            if (String.IsNullOrEmpty(orderInformationDomain))
            {
                auctionLog.Log("警告:未发现订单页面中的信息域");
                return;
            }


            //获取不同的检索号
            string promotionId = string.Empty, shopPromotionId = string.Empty;

            MatchCollection tempMatches;
            string          tempStr;

            Match tempMatch = Regex.Match(orderInformationDomain, "relation.*?cross_id\\s*\"\\s*:\\s*\\[\\s*\"(?<shopPromotionId>.*?)\"\\s*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (tempMatch.Success)
            {
                shopPromotionId  = tempMatch.Groups["shopPromotionId"].ToString();
                shopPromotion.Id = shopPromotionId;
            }

            tempMatch = Regex.Match(orderInformationDomain, "orders.*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (tempMatch.Success)
            {
                orderInformationDomain = tempMatch.Groups[0].ToString();
            }

            //获取店铺促销信息(这里其实和获取普通促销信息差不多,但出于淘宝将来升级的考虑,暂时都列在这里,分开来写)
            if (!String.IsNullOrEmpty(shopPromotionId))
            {
                tempMatch = Regex.Match(orderInformationDomain, ",\\s*\"\\s*" + shopPromotionId + "(?<shopPromotionInformationDomain>.*?)orderData", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (tempMatch.Success)
                {
                    string shopPromotionInfomationDomain = tempMatch.Groups["shopPromotionInformationDomain"].ToString();
                    tempMatch = Regex.Match(shopPromotionInfomationDomain, "buyerId(?<betweenContent>.*?)bundles", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    if (tempMatch.Success)
                    {
                        tempStr   = tempMatch.Groups["betweenContent"].ToString();
                        tempMatch = Regex.Match(tempStr, "bundle\\s*\"\\s*:\\s*\"(?<bundle>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                        if (tempMatch.Success)
                        {
                            //获取促销绑定信息
                            auctionLog.Log("通知:发现了店铺促销绑定信息");
                            shopPromotion.Bundle = tempMatch.Groups["bundle"].ToString();

                            tempMatch = Regex.Match(shopPromotionInfomationDomain, "bundles\\s*\"\\s*:\\s*\\{(?<shopBundlesString>(\\s*\".*?\"\\s*:\\s*\\{.*?\\})*\\s*).*?\\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                            if (tempMatch.Success)
                            {
                                auctionLog.Log("通知:发现了店铺促销列表");
                                string bundleString = tempMatch.Groups["shopBundlesString"].ToString();
                                tempMatches = Regex.Matches(bundleString, "\"(?<bundleId>.*?)\"\\s*:\\s*\\{(?<bundleContent>.*?)\\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                if (tempMatches.Count > 0)
                                {
                                    auctionLog.Log("通知:发现了单个店铺促销信息");
                                    foreach (Match match in tempMatches)
                                    {
                                        ShopPromotionBundle pb = new ShopPromotionBundle();
                                        pb.Id = match.Groups["bundleId"].ToString();
                                        string bundleContent = match.Groups["bundleContent"].ToString();

                                        tempMatch  = Regex.Match(bundleContent, "discount\\s*\"\\s*:\\s*\"(?<discount>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Discout = tempMatch.Groups["discount"].ToString();

                                        tempMatch       = Regex.Match(bundleContent, "freedelivery\\s*\"\\s*:\\s*(?<freedelivery>true|false)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.FreeDelivery = tempMatch.Groups["freedelivery"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "point\\s*\"\\s*:\\s*\"(?<point>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Point  = tempMatch.Groups["point"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "gift\\s*\"\\s*:\\s*\"(?<gift>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Gift   = tempMatch.Groups["gift"].ToString();

                                        shopPromotion.Bundles.Add(pb);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //获取店铺促销信息
        private void GetOrderShopPromotion(string orderInformationDomain)
        {
            if (String.IsNullOrEmpty(orderInformationDomain))
            {
                auctionLog.Log("警告:未发现订单页面中的信息域");
                return;
            }

            //获取不同的检索号
            string promotionId = string.Empty, shopPromotionId = string.Empty;

            MatchCollection tempMatches;
            string tempStr;

            Match tempMatch = Regex.Match(orderInformationDomain, "relation.*?cross_id\\s*\"\\s*:\\s*\\[\\s*\"(?<shopPromotionId>.*?)\"\\s*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (tempMatch.Success)
            {
                shopPromotionId = tempMatch.Groups["shopPromotionId"].ToString();
                shopPromotion.Id = shopPromotionId;
            }

            tempMatch = Regex.Match(orderInformationDomain, "orders.*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            if (tempMatch.Success)
            {
                orderInformationDomain = tempMatch.Groups[0].ToString();
            }

            //获取店铺促销信息(这里其实和获取普通促销信息差不多,但出于淘宝将来升级的考虑,暂时都列在这里,分开来写)
            if (!String.IsNullOrEmpty(shopPromotionId))
            {
                tempMatch = Regex.Match(orderInformationDomain, ",\\s*\"\\s*" + shopPromotionId + "(?<shopPromotionInformationDomain>.*?)orderData", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (tempMatch.Success)
                {
                    string shopPromotionInfomationDomain = tempMatch.Groups["shopPromotionInformationDomain"].ToString();
                    tempMatch = Regex.Match(shopPromotionInfomationDomain, "buyerId(?<betweenContent>.*?)bundles", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    if (tempMatch.Success)
                    {
                        tempStr = tempMatch.Groups["betweenContent"].ToString();
                        tempMatch = Regex.Match(tempStr, "bundle\\s*\"\\s*:\\s*\"(?<bundle>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                        if (tempMatch.Success)
                        {
                            //获取促销绑定信息
                            auctionLog.Log("通知:发现了店铺促销绑定信息");
                            shopPromotion.Bundle = tempMatch.Groups["bundle"].ToString();

                            tempMatch = Regex.Match(shopPromotionInfomationDomain, "bundles\\s*\"\\s*:\\s*\\{(?<shopBundlesString>(\\s*\".*?\"\\s*:\\s*\\{.*?\\})*\\s*).*?\\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                            if (tempMatch.Success)
                            {
                                auctionLog.Log("通知:发现了店铺促销列表");
                                string bundleString = tempMatch.Groups["shopBundlesString"].ToString();
                                tempMatches = Regex.Matches(bundleString, "\"(?<bundleId>.*?)\"\\s*:\\s*\\{(?<bundleContent>.*?)\\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                if (tempMatches.Count > 0)
                                {
                                    auctionLog.Log("通知:发现了单个店铺促销信息");
                                    foreach (Match match in tempMatches)
                                    {
                                        ShopPromotionBundle pb = new ShopPromotionBundle();
                                        pb.Id = match.Groups["bundleId"].ToString();
                                        string bundleContent = match.Groups["bundleContent"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "discount\\s*\"\\s*:\\s*\"(?<discount>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Discout = tempMatch.Groups["discount"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "freedelivery\\s*\"\\s*:\\s*(?<freedelivery>true|false)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.FreeDelivery = tempMatch.Groups["freedelivery"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "point\\s*\"\\s*:\\s*\"(?<point>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Point = tempMatch.Groups["point"].ToString();

                                        tempMatch = Regex.Match(bundleContent, "gift\\s*\"\\s*:\\s*\"(?<gift>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                                        pb.Gift = tempMatch.Groups["gift"].ToString();

                                        shopPromotion.Bundles.Add(pb);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }