Commit 9cc7a8e0 authored by 黄奎's avatar 黄奎

页面修改

parent dbda263b
......@@ -363,6 +363,11 @@ namespace DotnetSpider.Spiders.Model
/// </summary>
public string KeyInfo { get; set; }
/// <summary>
/// 直客价
/// </summary>
public decimal B2CPrice { get; set; }
/// <summary>
/// 行程特色
/// </summary>
......
......@@ -125,6 +125,32 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
};
productRequest.Content = MessagePackSerializer.Typeless.Serialize(new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(productParam), "application/json", "UTF-8"));
requests.Add(productRequest);
var priceRequest= new Request(SouthEastRequest.URL)
{
Method = "POST"
};
priceRequest.SetHeader("prodNo", _prodNo);
priceRequest.SetHeader("origin", SouthEastRequest.Origin);
var priceData = new
{
prodNo = _prodNo,
portType = "B2C",
companyNo = "",
hotelGroupNo = "",
hotelRoomNo="",
isB2C=true,
month="202007",
grupNo = "",
};
var priceParam = new
{
operationname = "getDtGrupDate",
query = @"query getDtGrupDate($prodNo: String!, $portType: String!, $month: String!, $hotelGroupNo: String, $hotelRoomNo: String, $companyNo: String, $isB2C: Boolean!) { getDtGrupDate(prodNo: $prodNo, portType: $portType, month: $month, hotelGroupNo: $hotelGroupNo, hotelRoomNo: $hotelRoomNo, companyNo: $companyNo) { error { msgCode msgDesc __typename } data { date grupNo isHoliday mktInfo price { b2cPrice b2bPrice @skip(if: $isB2C) __typename } charge { bookingAmt chargeText __typename } grupTypeCode grupTypeName qty orgQty __typename } __typename }}",
variables = priceData
};
priceRequest.Content = MessagePackSerializer.Typeless.Serialize(new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(priceParam), "application/json", "UTF-8"));
requests.Add(priceRequest);
}
}
......@@ -157,13 +183,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
var dataArray = JArray.Parse(getDtProduct["data"].ToString());
TripParsing(context.Request.Headers["prodNo"].ToString(), dataArray);
}
//团期数据解析
//配置数据解析
else if (rootData.ContainsKey("getDtProduct"))
{
var getDtProduct = JObject.Parse(rootData["getDtProduct"].ToString());
var data = JObject.Parse(getDtProduct["data"].ToString());
ConfigParsing(data);
}
//团期数据解析
else if (rootData.ContainsKey("getDtGrupDate"))
{
var getDtGrupDate = JObject.Parse(rootData["getDtGrupDate"].ToString());
var data = JArray.Parse(getDtGrupDate["data"].ToString());
PriceParing(context.Request.Headers["prodNo"].ToString(),data);
}
}
return Task.CompletedTask;
}
......@@ -175,7 +208,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
if (jArray != null && jArray.Count > 0)
{
SouthEastServicer.TRAVEL_CONFIGS.ForEach(x =>
foreach (var x in SouthEastServicer.TRAVEL_CONFIGS)
{
var keys = JObject.Parse(x.KeyInfo);
string prodNo = keys["code"].ToString();
......@@ -188,7 +221,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
x.JourneyHotels = new List<RB_Journey_Hotel>();
x.JourneyDinners = new List<RB_Journey_Dinner>();
x.JourneyTitles = new List<RB_Journey_Title>();
jArray.ToList().ForEach(item =>
foreach(var item in jArray.ToList())
{
Int32.TryParse(item["daySeq"].ToString(), out int DayNum);
x.JourneyDinners.Add(new RB_Journey_Dinner
......@@ -196,24 +229,106 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
DayNum = DayNum,
UseDinnerType = "1",
DinnerName = item["breakfast"].ToString(),
AgentId = x.AgentId,
BreakfastUseType = 0,
CityId = 0,
CityName = string.Empty,
ConfigId = 0,
Description = string.Empty,
DinnerId = 0,
DinnerImg = string.Empty,
ID = 0,
MD5Sign = string.Empty,
MealId = 0,
MealName = string.Empty,
QCity = string.Empty,
Rank = 2,
Status = 0,
TimeStr = string.Empty,
TimeType = 0,
UseTimeHour = 0,
UseTimeMinutes = 0,
});
x.JourneyDinners.Add(new RB_Journey_Dinner
{
DayNum = DayNum,
UseDinnerType = "2",
DinnerName = item["lunch"].ToString(),
AgentId = x.AgentId,
BreakfastUseType = 0,
CityId = 0,
CityName = string.Empty,
ConfigId = 0,
Description = string.Empty,
DinnerId = 0,
DinnerImg = string.Empty,
ID = 0,
MD5Sign = string.Empty,
MealId = 0,
MealName = string.Empty,
QCity = string.Empty,
Rank = 2,
Status = 0,
TimeStr = string.Empty,
TimeType = 0,
UseTimeHour = 0,
UseTimeMinutes = 0,
});
x.JourneyDinners.Add(new RB_Journey_Dinner
{
DayNum = DayNum,
UseDinnerType = "3",
DinnerName = item["dinner"].ToString(),
AgentId = x.AgentId,
BreakfastUseType = 0,
CityId = 0,
CityName = string.Empty,
ConfigId = 0,
Description = string.Empty,
DinnerId = 0,
DinnerImg = string.Empty,
ID = 0,
MD5Sign = string.Empty,
MealId = 0,
MealName = string.Empty,
QCity = string.Empty,
Rank = 2,
Status = 0,
TimeStr = string.Empty,
TimeType = 0,
UseTimeHour = 0,
UseTimeMinutes = 0,
});
x.JourneyHotels.Add(new RB_Journey_Hotel()
{
DayNum = DayNum,
HotelName = item["htl"].ToString(),
CityId = 0,
CityName = string.Empty,
ConfigId = 0,
AgentId = x.AgentId,
Description = string.Empty,
HotelId = 0,
HotelImg = string.Empty,
HotelProductId = 0,
HotelProductName = string.Empty,
HotelProvideType = 2,
HotelType = 1,
ID = 0,
IsSameLevel = 1,
IsUseDinner = 0,
MD5Sign = string.Empty,
QCity = string.Empty,
Rank =0,
Status = 1,
TimeStr = string.Empty,
TimeType = 0,
UseDinnerType = string.Empty
});
x.JourneyScenics.Add(new RB_Journey_Scenic()
......@@ -221,15 +336,43 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
DayNum = DayNum,
CouponsName = item["tourBrief"].ToString(),
Description = item["tourContent"].ToString(),
AgentId = x.AgentId,
CityId = 0,
CityName = string.Empty,
ConfigId = 0,
CouponsId = 0,
CouponsTicketId = 0,
CouponsTicketName = string.Empty,
MD5Sign = string.Empty,
NewScenicImg = string.Empty,
PlayTimeHour = 0,
PlayTimeMinutes = 0,
QCity = string.Empty,
Rank =1 ,
ScenicImg = "["+ SouthEastServicer.RequestConfig.Origin+item["imageUrl"] +"]",
ScenicJsonStr = string.Empty,
Status = 0,
TimeStr = string.Empty,
TimeType = 1,
TrafficContent = string.Empty,
TrafficImage = string.Empty,
TrafficType = 4
});
x.JourneyTitles.Add(new RB_Journey_Title()
{
DayNum = DayNum,
Description= item["tourBrief"].ToString(),
});
Description = item["tourBrief"].ToString(),
ConfigId = 0,
Title = item["tourBrief"].ToString(),
ID = 0,
Rank = 0,
AgentId = x.AgentId
});
}
});
}
}
}
}
......@@ -268,6 +411,91 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
});
}
/// <summary>
/// 团期数据解析
/// </summary>
/// <param name="jArray"></param>
private void PriceParing(string prodNo,JArray jArray)
{
foreach (var item in SouthEastServicer.TRAVEL_CONFIGS)
{
if (item.Prices == null)
{
item.Prices = new List<RB_Travel_Price>();
}
var keys = JObject.Parse(item.KeyInfo);
string _prodNo = keys["code"].ToString();
if (prodNo == _prodNo)
{
if (jArray != null && jArray.Count > 0)
{
foreach (var jItem in jArray)
{
var pItem = jItem.ToObject<JObject>();
string dateStr= pItem["date"].ToString();
string newDateStr= dateStr.Substring(0,4)+"-" + dateStr.Substring(4, 2)+"-"+dateStr.Substring(6, 2);
decimal.TryParse(pItem["b2cPrice"].ToString(), out decimal b2cPrice);
if (b2cPrice <= 0)
{
b2cPrice = item.B2CPrice;
}
var price = new RB_Travel_Price()
{
AirportService = string.Empty,
B2CPrice = b2cPrice,
BabyChargePrice = 0,
BabyPrice = 0,
ChildNeedPrice = 0,
ChildNoNeedPrice = 0,
ClearOrderHour = 72,
ConfigID = 0,
AgentId = item.AgentId,
CreateBy = 0,
CreateDate = DateTime.Now,
CSeat = 0,
DiscountPrice = 0,
DMCNum = prodNo,
FSeat = 0,
GatherTag = string.Empty,
Inventory = 0,
IsB2B = 1,
IsB2C = 1,
IsOrder = 1,
IsSetOut = 1,
IsSubstitution = 1,
IsSupportChildren = 1,
OldManChargePrice = 0,
OPUpdateBy = 0,
OPUpdateDate = null,
OtherPrice = 0,
RebatePrice = 0,
SalePlat = "1,2,3,4,5",
SingleDMCPrice = 0,
SingleRoomPrice = 0,
StartDate = Convert.ToDateTime(newDateStr),
Status = 1,
SurplusCSeat = 0,
SurplusFSeat = 0,
SurplusYSeat = 0,
Id = 0,
TCNUM ="",
TCSaleState = 1,
TCState = 3,
TeamType = 0,
UpdateBy = 0,
UpdateDate = DateTime.Now,
UseFlightType = 1,
VisaPrice = 0,
WordPath = string.Empty,
YSeat = 0
};
item.Prices.Add(price);
}
}
}
}
}
}
}
}
......@@ -155,7 +155,9 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
keyInfo.Add("code", x["prodNo"].ToString());
keyInfo.Add("travelCode", x["travelCode"].ToString());
keyInfo.Add("travelName", x["travelName"].ToString());
SouthEastServicer.TRAVEL_CONFIGS.Add(new RB_Travel_Config
var price = x["price"].ToObject<JObject>();
decimal.TryParse(price["b2cPrice"].ToString(), out decimal b2cPrice);
var config = new RB_Travel_Config
{
RealLink = string.Format("https://trip.settour.com.tw/taiwan/product/{0}", x["prodNo"].ToString()),
KeyInfo = keyInfo.ToString(),
......@@ -187,8 +189,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
TravelState = 1,
UpdateBy = 0,
VideoStr = string.Empty,
YSeat = 20
});
YSeat = 20,
B2CPrice=b2cPrice
};
SouthEastServicer.TRAVEL_CONFIGS.Add(config);
}
}
}
......
......@@ -22,7 +22,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
URL = "https://gql.settour.com.tw/graphql",
StartDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"),
EndDate = DateTime.Now.AddDays(2).ToString("yyyyMMdd"),
EndDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"),
TotalPage = 1,
Origin= "https://trip.settour.com.tw"
};
......@@ -46,12 +46,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
//await SouthEastProdHtmlDetailsSpider.RunAsync();
Console.WriteLine("COnfig:" + Newtonsoft.Json.JsonConvert.SerializeObject(TRAVEL_CONFIGS));
Console.WriteLine("********* SouthEastService_End ************");
//保存数据
await SouthEastStorageSpider.RunAsync();
Console.WriteLine("********* SouthEastService_End ************");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment