ly-zizhuyou 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ly/zizhuyou/version.rb +1 -1
- data/lib/ly/zizhuyou.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96a8f1fb50548b9a8aea7b77879ec39fba5d7647
|
4
|
+
data.tar.gz: 03e25283b72e27bf01fccc2e43e3bdaec7f8b2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9bafe5aad272564715c696259d595f37f7a37cf0db47762efb186bdb013d7303ece7d45bd6b1a660e176e9930bc9468d053e53a3ad87f81f8663a7481502bdb
|
7
|
+
data.tar.gz: '09c8176a5a5c280dadabb009ba2bfacf62bcfbb7844303dc74f79957404ed071646c179570b1392d849b6a0a0d787eb4e74a5a5db4c6d1a5909260f1bb7a48a5'
|
data/lib/ly/zizhuyou/version.rb
CHANGED
data/lib/ly/zizhuyou.rb
CHANGED
@@ -3,6 +3,7 @@ require 'net/http'
|
|
3
3
|
require 'uri'
|
4
4
|
require 'digest/md5'
|
5
5
|
require 'json'
|
6
|
+
require 'time'
|
6
7
|
|
7
8
|
module Ly
|
8
9
|
module Zizhuyou
|
@@ -105,7 +106,7 @@ module Ly
|
|
105
106
|
next if r['Products'].empty? # 跳过无政策房型
|
106
107
|
room = {'policies' => []}
|
107
108
|
room['room_id'] = r['ProId']
|
108
|
-
|
109
|
+
unless r['ProductInfo'].nil?
|
109
110
|
room['room_name'] = r['ProductInfo']['ResProName']
|
110
111
|
room['room_info'] = r['ProductInfo']['ResProProps']
|
111
112
|
else
|
@@ -113,9 +114,10 @@ module Ly
|
|
113
114
|
end
|
114
115
|
room['image'] = ''
|
115
116
|
r['Products'].each do |_, p|
|
117
|
+
next unless [1, 2].include?(p['PaymentType'])
|
116
118
|
policy = {'daily_prices' => []}
|
117
119
|
policy['policy_id'] = p['ProductUniqueId']
|
118
|
-
|
120
|
+
unless p['ProductInfo'].nil?
|
119
121
|
policy['policy_name'] = p['ProductInfo']['SupPriceName']
|
120
122
|
policy['bed_type'] = p['ProductInfo']['BedTypeName']
|
121
123
|
else
|
@@ -128,6 +130,10 @@ module Ly
|
|
128
130
|
|
129
131
|
guarantee_arrival_time = nil
|
130
132
|
|
133
|
+
remainders = []
|
134
|
+
instant_confirmations = []
|
135
|
+
reserve_time = Time.strptime("#{arrival_date.strftime('%Y-%m-%d')} #{p['ReserveTime']} +0800", '%Y-%m-%d %H:%M:%S %z')
|
136
|
+
|
131
137
|
p['ProSaleInfoDetails'].each do |d, s|
|
132
138
|
prices << s['DistributionSalePrice'] unless s.nil?
|
133
139
|
breakfast = s['BreakfastName'] if breakfast.nil?
|
@@ -143,6 +149,10 @@ module Ly
|
|
143
149
|
guarantee_hold_time = Time.strptime("1970-01-01 #{s['GuaranteeHoldTime']} UTC", '%Y-%m-%d %H:%M:%S %Z')
|
144
150
|
guarantee_arrival_time = guarantee_hold_time if guarantee_arrival_time.nil? || (guarantee_hold_time > guarantee_arrival_time)
|
145
151
|
end
|
152
|
+
remainders << s['InventoryRemainder'] if s['InventoryStats'] == 0 || s['InventoryRemainder'] > 0
|
153
|
+
instant_confirmations << (s['InventoryStats'] == 0)
|
154
|
+
last_reserve_time = Time.strptime(s['LastReserveTime'].gsub(%r(\d{3}\+), '.\0'), '/Date(%s.%L%z)/')
|
155
|
+
reserve_time = last_reserve_time if reserve_time.nil? || (reserve_time > last_reserve_time)
|
146
156
|
end
|
147
157
|
|
148
158
|
next if prices.empty?
|
@@ -151,11 +161,17 @@ module Ly
|
|
151
161
|
policy['breakfast'] = breakfast
|
152
162
|
policy['status'] = !statuses.include?(false)
|
153
163
|
|
154
|
-
policy['payment'] =
|
164
|
+
policy['payment'] = p['PaymentType']
|
155
165
|
policy['total_price'] = prices.sum
|
156
166
|
|
157
167
|
policy['guarantee_arrival_time'] = ((guarantee_arrival_time - Time.at(0).utc) / 3600).to_i unless guarantee_arrival_time.nil?
|
158
168
|
|
169
|
+
|
170
|
+
policy['advance_days'] = p['BeforehandBookingDay']
|
171
|
+
policy['reserve_time'] = reserve_time.strftime('%H:%M')
|
172
|
+
policy['remainder'] = remainders.min
|
173
|
+
policy['instant_confirmation'] = !instant_confirmations.include?(false)
|
174
|
+
|
159
175
|
room['policies'] << policy
|
160
176
|
end
|
161
177
|
ret_val << room unless room['policies'].empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ly-zizhuyou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiao Jie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|