spree_cm_commissioner 2.3.2.pre.pre2 → 2.3.2
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/Gemfile.lock +1 -1
- data/app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb +3 -44
- data/app/models/spree_cm_commissioner/vendor_place.rb +0 -9
- data/app/queries/spree_cm_commissioner/trip_query.rb +17 -23
- data/app/services/spree_cm_commissioner/intercity_taxi_order/create.rb +6 -14
- data/app/services/spree_cm_commissioner/intercity_taxi_order/update.rb +63 -6
- data/config/routes.rb +1 -17
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +4 -11
- data/app/controllers/spree/api/v2/tenant/intercity_taxi/draft_orders_controller.rb +0 -81
- data/app/controllers/spree/api/v2/tenant/trip_places_controller.rb +0 -48
- data/app/controllers/spree/api/v2/tenant/trip_search_controller.rb +0 -103
- data/app/controllers/spree/api/v2/tenant/trips_controller.rb +0 -32
- data/app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_schema.rb +0 -10
- data/app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_update_schema.rb +0 -10
- data/db/migrate/20251119093000_add_tenant_id_to_cm_vendor_places.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f69009264c3f351003ddd4885f403db68bc0a589a9e28123188a26bdd382b3d6
|
|
4
|
+
data.tar.gz: fea37b83621c4eb39ee2936ae4d72c377ee6d0767fb240be01c2de82e63d4c83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8530a8855d325ffae9223d3ed705be0f445bd5ce01c2479ef809f783804af5d4b90cd716a5c10076cbad561f6d57c03becf4d8ccb2e7e33bd57144c29bd1ff5e
|
|
7
|
+
data.tar.gz: 9d2bada64c5ac4701bb9f18d233e8948e0e8b6b9cf6fd0e923157007bd06cde7ef79b13ffa0476aad2a3ec955a268e66249b3f49097fce93136a61dfa0856f4f
|
data/Gemfile.lock
CHANGED
|
@@ -4,16 +4,12 @@ module Spree
|
|
|
4
4
|
module Storefront
|
|
5
5
|
module IntercityTaxi
|
|
6
6
|
class DraftOrdersController < ::Spree::Api::V2::ResourceController
|
|
7
|
-
include Spree::Api::V2::Storefront::OrderConcern
|
|
8
|
-
include SpreeCmCommissioner::OrderConcern
|
|
9
|
-
|
|
10
|
-
before_action :ensure_order, only: :update
|
|
11
7
|
def create
|
|
12
8
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
|
|
13
9
|
trip_id: params[:trip_id],
|
|
14
10
|
from_date: params[:from_date],
|
|
15
11
|
to_date: params[:to_date],
|
|
16
|
-
|
|
12
|
+
user_id: params[:user_id],
|
|
17
13
|
quantity: params[:quantity]
|
|
18
14
|
)
|
|
19
15
|
|
|
@@ -24,8 +20,8 @@ module Spree
|
|
|
24
20
|
|
|
25
21
|
def update
|
|
26
22
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
order_number: params[:id],
|
|
24
|
+
params: params
|
|
29
25
|
)
|
|
30
26
|
|
|
31
27
|
render_serialized_payload { serialize_resource(order) }
|
|
@@ -33,43 +29,6 @@ module Spree
|
|
|
33
29
|
render_error_payload(e.message)
|
|
34
30
|
end
|
|
35
31
|
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def intercity_taxi_update_order_params
|
|
39
|
-
params.require(:order).permit(
|
|
40
|
-
line_items_attributes: %i[
|
|
41
|
-
id
|
|
42
|
-
pickup_place_name
|
|
43
|
-
drop_off_place_name
|
|
44
|
-
from_date
|
|
45
|
-
pickup_lat
|
|
46
|
-
pickup_lng
|
|
47
|
-
pickup_oob_confirmed
|
|
48
|
-
drop_off_lat
|
|
49
|
-
drop_off_lng
|
|
50
|
-
drop_off_oob_confirmed
|
|
51
|
-
distance_km
|
|
52
|
-
ordered_points
|
|
53
|
-
base_km
|
|
54
|
-
detour_pickup_km
|
|
55
|
-
detour_dropoff_km
|
|
56
|
-
extra_pickup_km
|
|
57
|
-
extra_dropoff_km
|
|
58
|
-
estimated_time_minutes
|
|
59
|
-
remark
|
|
60
|
-
passenger_count
|
|
61
|
-
]
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def required_schema
|
|
66
|
-
if action_name == 'create'
|
|
67
|
-
SpreeCmCommissioner::IntercityTaxiDraftOrderSchema
|
|
68
|
-
else
|
|
69
|
-
SpreeCmCommissioner::IntercityTaxiDraftOrderUpdateSchema
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
32
|
def resource_serializer
|
|
74
33
|
SpreeCmCommissioner::V2::Storefront::IntercityTaxiCartSerializer
|
|
75
34
|
end
|
|
@@ -3,7 +3,6 @@ module SpreeCmCommissioner
|
|
|
3
3
|
enum place_type: { venue: 0, branch: 1, stop: 2, location: 3 }
|
|
4
4
|
acts_as_list scope: :vendor
|
|
5
5
|
|
|
6
|
-
belongs_to :tenant, class_name: 'SpreeCmCommissioner::Tenant', optional: true
|
|
7
6
|
belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
|
|
8
7
|
belongs_to :place, class_name: 'SpreeCmCommissioner::Place', optional: false
|
|
9
8
|
belongs_to :location, class_name: 'SpreeCmCommissioner::VendorPlace', optional: true
|
|
@@ -17,8 +16,6 @@ module SpreeCmCommissioner
|
|
|
17
16
|
|
|
18
17
|
accepts_nested_attributes_for :place, allow_destroy: true
|
|
19
18
|
|
|
20
|
-
before_save :set_tenant_id
|
|
21
|
-
|
|
22
19
|
# include place when using these delegate to avoid N+1
|
|
23
20
|
def display_name
|
|
24
21
|
place&.name
|
|
@@ -31,11 +28,5 @@ module SpreeCmCommissioner
|
|
|
31
28
|
def selected
|
|
32
29
|
vendor.selected_place_references.include?(place&.reference)
|
|
33
30
|
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def set_tenant_id
|
|
38
|
-
self.tenant_id = vendor&.tenant_id
|
|
39
|
-
end
|
|
40
31
|
end
|
|
41
32
|
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
class TripQuery
|
|
3
|
-
attr_reader :origin_id, :destination_id, :date, :vendor_id, :
|
|
3
|
+
attr_reader :origin_id, :destination_id, :date, :vendor_id, :number_of_guests, :route_type, :params
|
|
4
4
|
|
|
5
|
-
def initialize(origin_id:, destination_id:, date:, route_type: nil, vendor_id: nil,
|
|
5
|
+
def initialize(origin_id:, destination_id:, date:, route_type: nil, vendor_id: nil, number_of_guests: nil, params: {}) # rubocop:disable Metrics/ParameterLists
|
|
6
6
|
@origin_id = origin_id
|
|
7
7
|
@destination_id = destination_id
|
|
8
8
|
@date = date.to_date == Time.zone.now.to_date ? Time.zone.now : Time.zone.parse(date.to_s)
|
|
9
9
|
@vendor_id = vendor_id
|
|
10
|
-
@tenant_id = tenant_id
|
|
11
10
|
@number_of_guests = number_of_guests || 1
|
|
12
11
|
@route_type = route_type
|
|
13
12
|
@params = params
|
|
@@ -37,9 +36,8 @@ module SpreeCmCommissioner
|
|
|
37
36
|
|
|
38
37
|
def direct_trips
|
|
39
38
|
result = trip_scope
|
|
40
|
-
result = result.where({ vendor_id: vendor_id }.compact)
|
|
39
|
+
result = result.where({ vendor_id: vendor_id }.compact)
|
|
41
40
|
result = result.where(route_type: route_type) if route_type.present?
|
|
42
|
-
result = result.where(spree_vendors: { tenant_id: tenant_id }) if tenant_id.present?
|
|
43
41
|
paginate(result)
|
|
44
42
|
end
|
|
45
43
|
|
|
@@ -58,24 +56,20 @@ module SpreeCmCommissioner
|
|
|
58
56
|
private
|
|
59
57
|
|
|
60
58
|
def trip_scope
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
scope = scope.joins(:vendor) if tenant_id.present?
|
|
77
|
-
|
|
78
|
-
scope
|
|
59
|
+
SpreeCmCommissioner::Trip
|
|
60
|
+
.select(<<~SQL.squish)
|
|
61
|
+
cm_trips.*,
|
|
62
|
+
boarding.departure_time AS boarding_departure_time,
|
|
63
|
+
boarding.stop_place_id AS boarding_stop_id, boarding.stop_name AS boarding_stop_name,
|
|
64
|
+
drop_off.stop_name AS drop_off_stop_name, drop_off.stop_place_id AS drop_off_stop_id,
|
|
65
|
+
drop_off.arrival_time AS drop_off_arrival_time,
|
|
66
|
+
COALESCE(iv.quantity_available, 0) AS quantity_available,
|
|
67
|
+
COALESCE(iv.max_capacity, 0) AS max_capacity,
|
|
68
|
+
origin_places.name AS origin_place_name, dest_places.name AS destination_place_name,
|
|
69
|
+
prices.amount AS amount, prices.compare_at_amount AS compare_at_amount,
|
|
70
|
+
prices.currency AS currency
|
|
71
|
+
SQL
|
|
72
|
+
.includes(vendor: :logo, vehicle: :option_values)
|
|
79
73
|
.joins(<<~SQL.squish)
|
|
80
74
|
INNER JOIN cm_trip_stops AS boarding ON boarding.trip_id = cm_trips.id AND boarding.stop_type = 0
|
|
81
75
|
INNER JOIN cm_trip_stops AS drop_off ON drop_off.trip_id = cm_trips.id AND drop_off.stop_type = 1
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module IntercityTaxiOrder
|
|
3
3
|
class Create
|
|
4
|
-
attr_reader :trip_id, :from_date, :to_date, :
|
|
4
|
+
attr_reader :trip_id, :from_date, :to_date, :user_id, :quantity
|
|
5
5
|
|
|
6
|
-
def self.call(trip_id:, from_date:, to_date:,
|
|
6
|
+
def self.call(trip_id:, from_date:, to_date:, user_id: nil, quantity: 1)
|
|
7
7
|
new(
|
|
8
8
|
trip_id: trip_id,
|
|
9
9
|
from_date: from_date,
|
|
10
10
|
to_date: to_date,
|
|
11
|
-
|
|
11
|
+
user_id: user_id,
|
|
12
12
|
quantity: quantity
|
|
13
13
|
).call
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def initialize(trip_id:, from_date:, to_date:,
|
|
16
|
+
def initialize(trip_id:, from_date:, to_date:, user_id:, quantity:)
|
|
17
17
|
@trip_id = trip_id
|
|
18
18
|
@from_date = from_date
|
|
19
19
|
@to_date = to_date
|
|
20
|
-
@
|
|
20
|
+
@user_id = user_id
|
|
21
21
|
@quantity = quantity.to_i <= 0 ? 1 : quantity.to_i
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ module SpreeCmCommissioner
|
|
|
29
29
|
variant = trip.product.variants.first
|
|
30
30
|
raise ArgumentError, 'No variant found for trip' if variant.blank?
|
|
31
31
|
|
|
32
|
-
order = Spree::Order.new(state: 'cart', use_billing: true,
|
|
32
|
+
order = Spree::Order.new(state: 'cart', use_billing: true, user_id: user_id)
|
|
33
33
|
|
|
34
34
|
line_item = order.line_items.new(
|
|
35
35
|
variant_id: variant.id,
|
|
@@ -42,7 +42,6 @@ module SpreeCmCommissioner
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
build_guests_for!(line_item, quantity)
|
|
45
|
-
assign_saved_guests_to_line_item(line_item)
|
|
46
45
|
|
|
47
46
|
order.save!
|
|
48
47
|
order.update_with_updater!
|
|
@@ -63,13 +62,6 @@ module SpreeCmCommissioner
|
|
|
63
62
|
def build_guests_for!(line_item, qty)
|
|
64
63
|
Array.new(qty) { line_item.guests.new }
|
|
65
64
|
end
|
|
66
|
-
|
|
67
|
-
def assign_saved_guests_to_line_item(line_item)
|
|
68
|
-
line_item.guests.each do |guest|
|
|
69
|
-
saved_guest = SpreeCmCommissioner::SavedGuest.new
|
|
70
|
-
guest.saved_guest = saved_guest
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
65
|
end
|
|
74
66
|
end
|
|
75
67
|
end
|
|
@@ -1,22 +1,79 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module IntercityTaxiOrder
|
|
3
3
|
class Update
|
|
4
|
-
attr_reader :
|
|
4
|
+
attr_reader :order_number, :params
|
|
5
5
|
|
|
6
|
-
def self.call(
|
|
7
|
-
new(
|
|
6
|
+
def self.call(order_number:, params:)
|
|
7
|
+
new(order_number: order_number, params: params).call
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def initialize(
|
|
11
|
-
@
|
|
12
|
-
@
|
|
10
|
+
def initialize(order_number:, params:)
|
|
11
|
+
@order_number = order_number
|
|
12
|
+
@params = ensure_parameters(params)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def call
|
|
16
|
+
order = Spree::Order.find_by!(number: order_number)
|
|
16
17
|
order.update!(order_params)
|
|
17
18
|
|
|
19
|
+
create_billing_address_if_missing(order)
|
|
20
|
+
|
|
18
21
|
order
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def ensure_parameters(params)
|
|
27
|
+
return params if params.is_a?(::ActionController::Parameters)
|
|
28
|
+
|
|
29
|
+
::ActionController::Parameters.new(params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def create_billing_address_if_missing(order)
|
|
33
|
+
return if order.bill_address.present?
|
|
34
|
+
|
|
35
|
+
SpreeCmCommissioner::BillingAddressCreator.call(order: order)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def order_params
|
|
39
|
+
params.require(:order).permit(
|
|
40
|
+
:intel_phone_number,
|
|
41
|
+
:email,
|
|
42
|
+
line_items_attributes: [
|
|
43
|
+
:id,
|
|
44
|
+
:pickup_place_name,
|
|
45
|
+
:drop_off_place_name,
|
|
46
|
+
:from_date,
|
|
47
|
+
:pickup_lat,
|
|
48
|
+
:pickup_lng,
|
|
49
|
+
:pickup_oob_confirmed,
|
|
50
|
+
:drop_off_lat,
|
|
51
|
+
:drop_off_lng,
|
|
52
|
+
:drop_off_oob_confirmed,
|
|
53
|
+
:distance_km,
|
|
54
|
+
:ordered_points,
|
|
55
|
+
:base_km,
|
|
56
|
+
:detour_pickup_km,
|
|
57
|
+
:detour_dropoff_km,
|
|
58
|
+
:extra_pickup_km,
|
|
59
|
+
:extra_dropoff_km,
|
|
60
|
+
:extra_pickup_charge_usd,
|
|
61
|
+
:extra_dropoff_charge_usd,
|
|
62
|
+
:estimated_time_minutes,
|
|
63
|
+
:remark,
|
|
64
|
+
:passenger_count,
|
|
65
|
+
{ guests_attributes: %i[
|
|
66
|
+
id
|
|
67
|
+
first_name
|
|
68
|
+
last_name
|
|
69
|
+
gender
|
|
70
|
+
nationality_id
|
|
71
|
+
age
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
)
|
|
76
|
+
end
|
|
20
77
|
end
|
|
21
78
|
end
|
|
22
79
|
end
|
data/config/routes.rb
CHANGED
|
@@ -550,18 +550,6 @@ Spree::Core::Engine.add_routes do
|
|
|
550
550
|
resources :guest_card_classes
|
|
551
551
|
resources :tickets, only: :index
|
|
552
552
|
|
|
553
|
-
resources :trip_places, only: :index
|
|
554
|
-
resources :trip_search, only: [:index]
|
|
555
|
-
resources :trips, only: %i[show]
|
|
556
|
-
|
|
557
|
-
namespace :intercity_taxi do
|
|
558
|
-
resources :draft_orders, only: [:create] do
|
|
559
|
-
collection do
|
|
560
|
-
patch :update
|
|
561
|
-
end
|
|
562
|
-
end
|
|
563
|
-
end
|
|
564
|
-
|
|
565
553
|
resource :reset_passwords, only: [:update]
|
|
566
554
|
resource :change_passwords, only: [:update]
|
|
567
555
|
resource :user_contacts, only: [:update]
|
|
@@ -701,11 +689,7 @@ Spree::Core::Engine.add_routes do
|
|
|
701
689
|
resources :draft_orders, only: %i[create]
|
|
702
690
|
end
|
|
703
691
|
namespace :intercity_taxi do
|
|
704
|
-
resources :draft_orders, only: [
|
|
705
|
-
collection do
|
|
706
|
-
patch :update
|
|
707
|
-
end
|
|
708
|
-
end
|
|
692
|
+
resources :draft_orders, only: %i[create update]
|
|
709
693
|
end
|
|
710
694
|
end
|
|
711
695
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_cm_commissioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.2
|
|
4
|
+
version: 2.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|
|
@@ -1013,7 +1013,6 @@ files:
|
|
|
1013
1013
|
- app/controllers/spree/api/v2/tenant/guests_controller.rb
|
|
1014
1014
|
- app/controllers/spree/api/v2/tenant/homepage_sections_controller.rb
|
|
1015
1015
|
- app/controllers/spree/api/v2/tenant/id_cards_controller.rb
|
|
1016
|
-
- app/controllers/spree/api/v2/tenant/intercity_taxi/draft_orders_controller.rb
|
|
1017
1016
|
- app/controllers/spree/api/v2/tenant/line_items_controller.rb
|
|
1018
1017
|
- app/controllers/spree/api/v2/tenant/notifications_controller.rb
|
|
1019
1018
|
- app/controllers/spree/api/v2/tenant/order_histories_controller.rb
|
|
@@ -1026,9 +1025,6 @@ files:
|
|
|
1026
1025
|
- app/controllers/spree/api/v2/tenant/s3_signed_urls_controller.rb
|
|
1027
1026
|
- app/controllers/spree/api/v2/tenant/taxons_controller.rb
|
|
1028
1027
|
- app/controllers/spree/api/v2/tenant/tickets_controller.rb
|
|
1029
|
-
- app/controllers/spree/api/v2/tenant/trip_places_controller.rb
|
|
1030
|
-
- app/controllers/spree/api/v2/tenant/trip_search_controller.rb
|
|
1031
|
-
- app/controllers/spree/api/v2/tenant/trips_controller.rb
|
|
1032
1028
|
- app/controllers/spree/api/v2/tenant/user_account_linkages_controller.rb
|
|
1033
1029
|
- app/controllers/spree/api/v2/tenant/user_contacts_controller.rb
|
|
1034
1030
|
- app/controllers/spree/api/v2/tenant/user_device_tokens_controller.rb
|
|
@@ -1753,8 +1749,6 @@ files:
|
|
|
1753
1749
|
- app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb
|
|
1754
1750
|
- app/request_schemas/spree_cm_commissioner/accommodation_request_schema.rb
|
|
1755
1751
|
- app/request_schemas/spree_cm_commissioner/application_request_schema.rb
|
|
1756
|
-
- app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_schema.rb
|
|
1757
|
-
- app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_update_schema.rb
|
|
1758
1752
|
- app/request_schemas/spree_cm_commissioner/inventory_item_schema.rb
|
|
1759
1753
|
- app/request_schemas/spree_cm_commissioner/profile_image_request_schema.rb
|
|
1760
1754
|
- app/request_schemas/spree_cm_commissioner/seat_layout_schema.rb
|
|
@@ -2858,7 +2852,6 @@ files:
|
|
|
2858
2852
|
- db/migrate/20251009073040_add_lock_version_to_cm_routes.rb
|
|
2859
2853
|
- db/migrate/20251009073929_add_lock_version_to_cm_vendor_routes.rb
|
|
2860
2854
|
- db/migrate/20251113081853_add_index_to_spree_orders_updated_at.rb
|
|
2861
|
-
- db/migrate/20251119093000_add_tenant_id_to_cm_vendor_places.rb
|
|
2862
2855
|
- docker-compose.yml
|
|
2863
2856
|
- docs/api/scoped-access-token-endpoints.md
|
|
2864
2857
|
- docs/option_types/attr_types.md
|
|
@@ -3023,9 +3016,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
3023
3016
|
version: '2.7'
|
|
3024
3017
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
3025
3018
|
requirements:
|
|
3026
|
-
- - "
|
|
3019
|
+
- - ">="
|
|
3027
3020
|
- !ruby/object:Gem::Version
|
|
3028
|
-
version:
|
|
3021
|
+
version: '0'
|
|
3029
3022
|
requirements:
|
|
3030
3023
|
- none
|
|
3031
3024
|
rubygems_version: 3.4.1
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Tenant
|
|
5
|
-
module IntercityTaxi
|
|
6
|
-
class DraftOrdersController < BaseController
|
|
7
|
-
include Spree::Api::V2::Storefront::OrderConcern
|
|
8
|
-
include SpreeCmCommissioner::OrderConcern
|
|
9
|
-
|
|
10
|
-
before_action :ensure_order, only: :update
|
|
11
|
-
def create
|
|
12
|
-
order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
|
|
13
|
-
trip_id: params[:trip_id],
|
|
14
|
-
from_date: params[:from_date],
|
|
15
|
-
to_date: params[:to_date],
|
|
16
|
-
quantity: params[:quantity],
|
|
17
|
-
user: spree_current_user
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
render_serialized_payload { serialize_resource(order) }
|
|
21
|
-
rescue StandardError => e
|
|
22
|
-
render_error_payload(e.message)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def update
|
|
26
|
-
order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
|
|
27
|
-
order: spree_current_order,
|
|
28
|
-
order_params: intercity_taxi_update_order_params
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
render_serialized_payload { serialize_resource(order) }
|
|
32
|
-
rescue StandardError => e
|
|
33
|
-
render_error_payload(e.message)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def intercity_taxi_update_order_params
|
|
39
|
-
params.require(:order).permit(
|
|
40
|
-
line_items_attributes: %i[
|
|
41
|
-
id
|
|
42
|
-
pickup_place_name
|
|
43
|
-
drop_off_place_name
|
|
44
|
-
from_date
|
|
45
|
-
pickup_lat
|
|
46
|
-
pickup_lng
|
|
47
|
-
pickup_oob_confirmed
|
|
48
|
-
drop_off_lat
|
|
49
|
-
drop_off_lng
|
|
50
|
-
drop_off_oob_confirmed
|
|
51
|
-
distance_km
|
|
52
|
-
ordered_points
|
|
53
|
-
base_km
|
|
54
|
-
detour_pickup_km
|
|
55
|
-
detour_dropoff_km
|
|
56
|
-
extra_pickup_km
|
|
57
|
-
extra_dropoff_km
|
|
58
|
-
estimated_time_minutes
|
|
59
|
-
remark
|
|
60
|
-
passenger_count
|
|
61
|
-
]
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def required_schema
|
|
66
|
-
if action_name == 'create'
|
|
67
|
-
SpreeCmCommissioner::IntercityTaxiDraftOrderSchema
|
|
68
|
-
else
|
|
69
|
-
SpreeCmCommissioner::IntercityTaxiDraftOrderUpdateSchema
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def resource_serializer
|
|
74
|
-
SpreeCmCommissioner::V2::Storefront::IntercityTaxiCartSerializer
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Tenant
|
|
5
|
-
class TripPlacesController < BaseController
|
|
6
|
-
def index
|
|
7
|
-
render_serialized_payload do
|
|
8
|
-
serialize_collection(paginated_collection)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def paginated_collection
|
|
15
|
-
collection.page(params[:page]).per(params[:per_page])
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def collection
|
|
19
|
-
@collection ||= begin
|
|
20
|
-
base_scope = scope
|
|
21
|
-
|
|
22
|
-
if params[:q].present?
|
|
23
|
-
@search = base_scope.ransack(params[:q])
|
|
24
|
-
@search.result
|
|
25
|
-
else
|
|
26
|
-
base_scope
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def scope
|
|
32
|
-
model_class.joins(:location_vendor_places)
|
|
33
|
-
.where(location_vendor_places: { tenant_id: @tenant.id })
|
|
34
|
-
.distinct
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def model_class
|
|
38
|
-
SpreeCmCommissioner::Place
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def collection_serializer
|
|
42
|
-
SpreeCmCommissioner::V2::Storefront::TripPlaceSerializer
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Tenant
|
|
5
|
-
class TripSearchController < BaseController
|
|
6
|
-
CACHE_EXPIRES_IN = 5.minutes
|
|
7
|
-
|
|
8
|
-
def index
|
|
9
|
-
render_serialized_payload do
|
|
10
|
-
Rails.cache.fetch(collection_cache_key, collection_cache_opts) do
|
|
11
|
-
trips = SpreeCmCommissioner::TripQuery.new(
|
|
12
|
-
origin_id: params[:origin_id],
|
|
13
|
-
destination_id: params[:destination_id],
|
|
14
|
-
date: params[:date],
|
|
15
|
-
route_type: params[:route_type],
|
|
16
|
-
number_of_guests: params[:number_of_guests],
|
|
17
|
-
tenant_id: @tenant.id,
|
|
18
|
-
params: params
|
|
19
|
-
).call
|
|
20
|
-
|
|
21
|
-
serialize_collection(trips)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
# override from ContentCacheable
|
|
29
|
-
def max_age
|
|
30
|
-
CACHE_EXPIRES_IN.to_i
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# override
|
|
34
|
-
def collection_cache_key
|
|
35
|
-
cache_key_parts = [
|
|
36
|
-
'trip_search',
|
|
37
|
-
@tenant.id,
|
|
38
|
-
params[:origin_id],
|
|
39
|
-
params[:destination_id],
|
|
40
|
-
params[:date],
|
|
41
|
-
params[:route_type],
|
|
42
|
-
params[:number_of_guests],
|
|
43
|
-
resource_includes&.sort&.join(','),
|
|
44
|
-
sparse_fields&.sort&.join(','),
|
|
45
|
-
serializer_params.to_json,
|
|
46
|
-
params[:page]&.to_s&.strip,
|
|
47
|
-
params[:per_page]&.to_s&.strip
|
|
48
|
-
].compact.join('-')
|
|
49
|
-
|
|
50
|
-
Digest::MD5.hexdigest(cache_key_parts)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# override
|
|
54
|
-
def collection_cache_opts
|
|
55
|
-
{
|
|
56
|
-
namespace: Spree::Api::Config[:api_v2_collection_cache_namespace],
|
|
57
|
-
expires_in: CACHE_EXPIRES_IN
|
|
58
|
-
}
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# override
|
|
62
|
-
def default_resource_includes
|
|
63
|
-
[
|
|
64
|
-
'trips.vendor',
|
|
65
|
-
'trips.vendor.logo',
|
|
66
|
-
'trips.vehicle',
|
|
67
|
-
'trips.vehicle.vehicle_photos',
|
|
68
|
-
'trips.amenities'
|
|
69
|
-
]
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def serialize_collection(collection)
|
|
73
|
-
serialized_data = SpreeCmCommissioner::V2::Storefront::TripQueryResultSerializer.new(
|
|
74
|
-
collection,
|
|
75
|
-
include: default_resource_includes,
|
|
76
|
-
params: serializer_params
|
|
77
|
-
).serializable_hash
|
|
78
|
-
serialized_data[:meta] = {
|
|
79
|
-
count: collection.size,
|
|
80
|
-
total_count: collection.respond_to?(:total_count) ? collection.total_count : collection.size,
|
|
81
|
-
current_page: collection.respond_to?(:current_page) ? collection.current_page : 1,
|
|
82
|
-
per_page: collection.respond_to?(:limit_value) ? collection.limit_value : collection.size,
|
|
83
|
-
pages: collection.respond_to?(:total_pages) ? collection.total_pages : 1,
|
|
84
|
-
next_page: collection.respond_to?(:next_page) ? collection.next_page : nil,
|
|
85
|
-
prev_page: collection.respond_to?(:prev_page) ? collection.prev_page : nil
|
|
86
|
-
}
|
|
87
|
-
serialized_data
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# override
|
|
91
|
-
def serializer_params
|
|
92
|
-
params.permit(:include).to_hash
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# override
|
|
96
|
-
def required_schema
|
|
97
|
-
SpreeCmCommissioner::TripSearchRequestSchema
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Tenant
|
|
5
|
-
class TripsController < BaseController
|
|
6
|
-
def show
|
|
7
|
-
resource = scope.find(params[:id])
|
|
8
|
-
|
|
9
|
-
render_serialized_payload do
|
|
10
|
-
serialize_resource(resource)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def scope
|
|
17
|
-
model_class.joins(:vendor)
|
|
18
|
-
.where(spree_vendors: { tenant_id: @tenant.id })
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def model_class
|
|
22
|
-
SpreeCmCommissioner::Trip
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def resource_serializer
|
|
26
|
-
SpreeCmCommissioner::V2::Storefront::TripSerializer
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module SpreeCmCommissioner
|
|
2
|
-
class IntercityTaxiDraftOrderSchema < ApplicationRequestSchema
|
|
3
|
-
params do
|
|
4
|
-
required(:trip_id).value(:integer)
|
|
5
|
-
required(:from_date).value(:date)
|
|
6
|
-
required(:to_date).value(:date)
|
|
7
|
-
required(:quantity).value(:integer)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module SpreeCmCommissioner
|
|
2
|
-
class IntercityTaxiDraftOrderUpdateSchema < ApplicationRequestSchema
|
|
3
|
-
params do
|
|
4
|
-
required(:order).hash do
|
|
5
|
-
# Rails nested attributes send line_items_attributes as hash with numeric string keys (e.g., "0", "1")
|
|
6
|
-
required(:line_items_attributes).hash
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
class AddTenantIdToCmVendorPlaces < ActiveRecord::Migration[7.0]
|
|
2
|
-
def change
|
|
3
|
-
add_column :cm_vendor_places, :tenant_id, :integer, if_not_exists: true
|
|
4
|
-
add_index :cm_vendor_places, :tenant_id, if_not_exists: true
|
|
5
|
-
add_index :cm_vendor_places, %i[tenant_id vendor_id], if_not_exists: true, name: 'index_cm_vendor_places_on_tenant_and_vendor'
|
|
6
|
-
end
|
|
7
|
-
end
|