//获取促销信息 private void GetOrderPromotion(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(); tempMatch = Regex.Match(orderInformationDomain, shopPromotionId + "\\s*\"\\s*:\\s*\\[\\s*\"(?<promotionId>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { promotionId = tempMatch.Groups["promotionId"].ToString(); promotion.Id = promotionId; } } tempMatch = Regex.Match(orderInformationDomain, "orders.*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { orderInformationDomain = tempMatch.Groups[0].ToString(); } //获取促销信息 if (!String.IsNullOrEmpty(promotionId)) { tempMatch = Regex.Match(orderInformationDomain, ",\\s*\"\\s*" + promotionId + "(?<promotionInformationDomain>.*?)orderData", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { string promotionInfomationDomain = tempMatch.Groups["promotionInformationDomain"].ToString(); tempMatch = Regex.Match(promotionInfomationDomain, "itemId(?<betweenContent>.*?)bundles", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { tempStr = tempMatch.Groups["betweenContent"].ToString(); //读取价格信息 tempMatch = Regex.Match(tempStr, "price\\s*\"\\s*:\\s*\"(?<price>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { auctionLog.Log("通知:发现了价格信息"); promotion.Price = tempMatch.Groups["price"].ToString(); } tempMatch = Regex.Match(tempStr, "bundle\\s*\"\\s*:\\s*\"(?<bundle>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { //获取促销绑定信息 auctionLog.Log("通知:发现了促销绑定信息"); promotion.Bundle = tempMatch.Groups["bundle"].ToString(); tempMatch = Regex.Match(tempStr, "averageSum\\s*\"\\s*:\\s*\"(?<averageSum>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { promotion.AverageSum = tempMatch.Groups["averageSum"].ToString(); } tempMatch = Regex.Match(promotionInfomationDomain, "bundles\\s*\"\\s*:\\s*\\{(?<bundlesString>(\\s*\".*?\"\\s*:\\s*\\{.*?\\})*\\s*).*?\\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { auctionLog.Log("通知:发现了促销信息列表"); string bundleString = tempMatch.Groups["bundlesString"].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) { PromotionBundle pb = new PromotionBundle(); 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(); promotion.Bundles.Add(pb); } } } } } } } }