item_builder_mwh 0.1.39 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item_builder_mwh/get_quantity_service.rb +4 -4
- data/lib/item_builder_mwh/modes/create/base.rb +21 -0
- data/lib/item_builder_mwh/modes/create/shopee_service.rb +44 -0
- data/lib/item_builder_mwh/modes/create_service.rb +48 -0
- data/lib/item_builder_mwh/modes/map_create/base.rb +17 -0
- data/lib/item_builder_mwh/modes/map_create/shopee_service.rb +55 -0
- data/lib/item_builder_mwh/modes/map_create_service.rb +185 -0
- data/lib/item_builder_mwh/modes/precondition_create/base.rb +17 -0
- data/lib/item_builder_mwh/modes/precondition_create/shopee_service.rb +28 -0
- data/lib/item_builder_mwh/modes/precondition_create_service.rb +38 -0
- data/lib/item_builder_mwh/modes.rb +4 -1
- data/lib/item_builder_mwh/version.rb +1 -1
- data/lib/item_builder_mwh.rb +58 -4
- metadata +16 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b78149b7676c619d18d00e438a4bba98447dc114a0809e551a60a4d762b1650f
|
4
|
+
data.tar.gz: 2d652671698ada813ff39946b9e98a0eefaa55a8de47f8933b1c226febb088ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a436d89e7b3998883ac6504ba67bb7735eed73eec7d21dc88b40df2f1766b7295fe8a16ce191538477f4042169962d36b534f3707675400e000373b1de8bc29
|
7
|
+
data.tar.gz: 16212f39a0ccf6d70ef64d5b677abffd8d6b7f5640d25c823a64c77b878c28d0580a247612cab43b424cbd6b6d94506f7ec33d49ebff145c3118a4229baefeac
|
@@ -49,8 +49,8 @@ class ItemBuilderMwh
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def allocated_start_end?
|
52
|
-
@stock_alloc.start_at
|
53
|
-
@stock_alloc.end_at
|
52
|
+
@stock_alloc.start_at <= Time.now &&
|
53
|
+
@stock_alloc.end_at >= Time.now
|
54
54
|
end
|
55
55
|
|
56
56
|
def allocated_stock
|
@@ -139,8 +139,8 @@ class ItemBuilderMwh
|
|
139
139
|
{
|
140
140
|
channel_id: allocated_stock.variant_listing.channel_id,
|
141
141
|
item_variant_id: allocated_stock.variant_listing.variant_id,
|
142
|
-
start_at: allocated_stock.start_at
|
143
|
-
end_at: allocated_stock.end_at
|
142
|
+
start_at: allocated_stock.start_at,
|
143
|
+
end_at: allocated_stock.end_at
|
144
144
|
}.to_query
|
145
145
|
end
|
146
146
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ItemBuilderMwh
|
4
|
+
module Modes
|
5
|
+
module Create
|
6
|
+
class Base
|
7
|
+
attr_reader :item_listing
|
8
|
+
attr_reader :shipping_providers
|
9
|
+
|
10
|
+
def initialize(item_listing, shipping_providers)
|
11
|
+
raise 'item listing is not set' if item_listing.nil?
|
12
|
+
|
13
|
+
raise 'shipping providers is not set' if shipping_providers.nil?
|
14
|
+
|
15
|
+
@item_listing = item_listing
|
16
|
+
@shipping_providers = shipping_providers
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes/create/base'
|
4
|
+
class ItemBuilderMwh
|
5
|
+
module Modes
|
6
|
+
module Create
|
7
|
+
class ShopeeService < Base
|
8
|
+
def perform
|
9
|
+
{
|
10
|
+
category: category,
|
11
|
+
brand: brand,
|
12
|
+
shipping_providers: map_shipping_providers
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def category
|
17
|
+
{
|
18
|
+
id: item_listing&.item_listing_category&.id,
|
19
|
+
local_id: item_listing&.item_listing_category&.shopee&.local_id,
|
20
|
+
name: item_listing&.item_listing_category&.shopee&.name
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def brand
|
25
|
+
{
|
26
|
+
id: item_listing&.item_listing_brand&.id,
|
27
|
+
local_id: item_listing&.item_listing_brand&.shopee&.local_id,
|
28
|
+
name: item_listing&.item_listing_brand&.shopee&.name
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def map_shipping_providers
|
33
|
+
shipping_providers.map do |shipping_provider|
|
34
|
+
{
|
35
|
+
local_id: shipping_provider.local_id,
|
36
|
+
name: shipping_provider.name,
|
37
|
+
enabled: shipping_provider.enabled
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes.rb'
|
4
|
+
require 'item_builder_mwh/modes/create/shopee_service'
|
5
|
+
class ItemBuilderMwh
|
6
|
+
module Modes
|
7
|
+
class CreateService
|
8
|
+
include Modes
|
9
|
+
|
10
|
+
CREATE_CHANNEL = {}.tap do |hash|
|
11
|
+
hash[12] = :Shopee
|
12
|
+
end.freeze
|
13
|
+
|
14
|
+
def perform
|
15
|
+
create.merge(create_channel)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
{
|
20
|
+
item: {
|
21
|
+
id: item_listing.id,
|
22
|
+
variations: ::ItemBuilderMwh.build(listings.map(&:id), :map_create)
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_channel
|
28
|
+
class_name = "ItemBuilderMwh::Modes::Create::#{channel_name}Service"
|
29
|
+
create_channel_service = class_name.constantize
|
30
|
+
create_channel_service.new(item_listing, shipping_providers).perform
|
31
|
+
end
|
32
|
+
|
33
|
+
def channel_name
|
34
|
+
CREATE_CHANNEL[listing.channel_id].to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def item_listing
|
38
|
+
@item_listing ||= listing.item_listing
|
39
|
+
end
|
40
|
+
|
41
|
+
def listings
|
42
|
+
@listings ||= item_listing.variant_listings.where(
|
43
|
+
profile_channel_association_id: listing.profile_channel_association_id
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ItemBuilderMwh
|
4
|
+
module Modes
|
5
|
+
module MapCreate
|
6
|
+
class Base
|
7
|
+
attr_reader :ilisting
|
8
|
+
|
9
|
+
def initialize(ilisting)
|
10
|
+
raise 'ilisting is not set' if ilisting.nil?
|
11
|
+
|
12
|
+
@ilisting = ilisting
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes/create/base'
|
4
|
+
class ItemBuilderMwh
|
5
|
+
module Modes
|
6
|
+
module MapCreate
|
7
|
+
class ShopeeService < Base
|
8
|
+
def perform
|
9
|
+
{
|
10
|
+
item_custom_fields: item_custom_fields,
|
11
|
+
variant_custom_fields: variant_custom_fields,
|
12
|
+
shipping_providers: shipping_providers
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def item_custom_fields
|
17
|
+
listing.item_listing_custom_fields.map do |item|
|
18
|
+
{
|
19
|
+
value: item.value,
|
20
|
+
local_id: item&.shopee&.local_id,
|
21
|
+
data_type: item&.shopee&.data_type,
|
22
|
+
input_type: item&.shopee&.input_type,
|
23
|
+
options: item&.shopee&.options.map do |option|
|
24
|
+
{
|
25
|
+
id: option.id,
|
26
|
+
name: option.name,
|
27
|
+
local_id: option.local_id
|
28
|
+
}
|
29
|
+
end
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def variant_custom_fields
|
35
|
+
listing.item_listing_variant_custom_fields.map do |variant|
|
36
|
+
{
|
37
|
+
value: variant.value,
|
38
|
+
local_id: variant&.shopee&.local_id,
|
39
|
+
data_type: variant&.shopee&.data_type,
|
40
|
+
input_type: variant&.shopee&.input_type
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def shipping_providers
|
46
|
+
listing.shopee_shipping_providers.map do |shipping_provider|
|
47
|
+
{
|
48
|
+
logistic_id: shipping_provider['logistic_id']
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes.rb'
|
4
|
+
require 'warehouse_models'
|
5
|
+
require 'item_builder_mwh/get_quantity_service'
|
6
|
+
require 'item_builder_mwh/modes/quantity/base'
|
7
|
+
require 'item_builder_mwh/modes/quantity/lazada_service'
|
8
|
+
require 'item_builder_mwh/modes/quantity/zalora_service'
|
9
|
+
require 'item_builder_mwh/modes/quantity/zilingo_service'
|
10
|
+
require 'item_builder_mwh/modes/price/base'
|
11
|
+
require 'item_builder_mwh/modes/price/blibli_service'
|
12
|
+
require 'item_builder_mwh/modes/price/bukalapak_service'
|
13
|
+
require 'item_builder_mwh/modes/price/zalora_service'
|
14
|
+
require 'item_builder_mwh/modes/price/shopify_service'
|
15
|
+
require 'item_builder_mwh/modes/price/sale_price_policy'
|
16
|
+
require 'item_builder_mwh/modes/price/jd_service'
|
17
|
+
class ItemBuilderMwh
|
18
|
+
module Modes
|
19
|
+
class MapCreateService
|
20
|
+
include Modes
|
21
|
+
|
22
|
+
MAP_CREATE_CHANNEL = {}.tap do |hash|
|
23
|
+
hash[12] = :Shopee
|
24
|
+
end.freeze
|
25
|
+
|
26
|
+
def perform
|
27
|
+
base.merge!(warehouse: warehouses).merge(map_create).merge(map_create_channel)
|
28
|
+
end
|
29
|
+
|
30
|
+
def map_create
|
31
|
+
{
|
32
|
+
name: listing.name,
|
33
|
+
description: listing.description,
|
34
|
+
weight: listing.package_weight,
|
35
|
+
length: listing.package_length,
|
36
|
+
width: listing.package_width,
|
37
|
+
height: listing.package_height,
|
38
|
+
condition: listing.new_condition,
|
39
|
+
option_name: listing.option_name,
|
40
|
+
option_value: listing.option_value,
|
41
|
+
option2_name: listing.option2_name,
|
42
|
+
option2_value: listing.option2_value,
|
43
|
+
internal_data: listing.internal_data,
|
44
|
+
images: images
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def images
|
49
|
+
listing.item_listing_variant_images.map do |img|
|
50
|
+
{
|
51
|
+
id: img.id,
|
52
|
+
local_id: img.local_id,
|
53
|
+
local_url: img.local_url,
|
54
|
+
url: img.image.image.url
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_h(warehouse_space)
|
60
|
+
{
|
61
|
+
quantity: warehouse_space.present? ? real_quantity(warehouse_space) : 0,
|
62
|
+
warehouse_id: warehouse_space.present? ? wh_mapping(
|
63
|
+
warehouse_space.warehouse_id
|
64
|
+
) : ''
|
65
|
+
}.merge(price)
|
66
|
+
end
|
67
|
+
|
68
|
+
def map_create_channel
|
69
|
+
class_name = "ItemBuilderMwh::Modes::MapCreate::#{channel_name}Service"
|
70
|
+
create_channel_service = class_name.constantize
|
71
|
+
create_channel_service.new(listing).perform
|
72
|
+
end
|
73
|
+
|
74
|
+
def channel_name
|
75
|
+
MAP_CREATE_CHANNEL[listing.channel_id].to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get Quantity Data
|
79
|
+
|
80
|
+
QUANTITY_CHANNEL = {}.tap do |hash|
|
81
|
+
hash[2] = :Shopify
|
82
|
+
hash[3] = :Lazada
|
83
|
+
hash[13] = :Zalora
|
84
|
+
hash[18] = :Zilingo
|
85
|
+
end.freeze
|
86
|
+
|
87
|
+
def real_quantity(warehouse_space)
|
88
|
+
if quantity_channel_name == 'Zilingo'
|
89
|
+
qty(warehouse_space)
|
90
|
+
else
|
91
|
+
[qty(warehouse_space), 0].sort[1]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def qty(warehouse_space)
|
96
|
+
if quantity_channel_name.empty? || quantity_channel_name == "Shopify"
|
97
|
+
available_quantity(warehouse_space)
|
98
|
+
else
|
99
|
+
qty_channel(warehouse_space)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def qty_channel(warehouse_space)
|
104
|
+
class_name = "ItemBuilderMwh::Modes::Quantity::#{quantity_channel_name}Service"
|
105
|
+
qty_channel_service = class_name.constantize
|
106
|
+
qty_channel_service.new(listing, available_quantity(warehouse_space), local_qty.to_i).perform
|
107
|
+
end
|
108
|
+
|
109
|
+
def quantity_channel_name
|
110
|
+
QUANTITY_CHANNEL[listing.channel_id].to_s
|
111
|
+
end
|
112
|
+
|
113
|
+
def local_qty
|
114
|
+
if quantity_channel_name == 'Zilingo'
|
115
|
+
return 0 if zilingo_quantity.blank?
|
116
|
+
|
117
|
+
zilingo_quantity[listing.local_id].to_i
|
118
|
+
elsif quantity_channel_name == 'Zalora'
|
119
|
+
return 0 if zalora_reserved_stock.blank?
|
120
|
+
|
121
|
+
zalora_reserved_stock[listing.local_id].to_i
|
122
|
+
else
|
123
|
+
return 0 if lazada_quantity.blank?
|
124
|
+
|
125
|
+
lazada_quantity[listing.local_id].to_i
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def credential
|
130
|
+
return shopify_inventory_location['credential'] if shopify_inventory_location['credential'].present?
|
131
|
+
|
132
|
+
nil
|
133
|
+
end
|
134
|
+
|
135
|
+
def wh_routing
|
136
|
+
return credential['warehouse_routing'] if credential.present? && credential['warehouse_routing'].present?
|
137
|
+
|
138
|
+
0
|
139
|
+
end
|
140
|
+
|
141
|
+
def available_quantity(warehouse_space)
|
142
|
+
ItemBuilderMwh::GetQuantityService.new(
|
143
|
+
listing: listing, stock_alloc: stock_alloc,
|
144
|
+
variant: variant, bundle_variants: bundle_variants,
|
145
|
+
existing_allocated_stock: existing_allocated_stock,
|
146
|
+
listing_wh_sp_quantity: warehouse_space.quantity, wh_routing: wh_routing,
|
147
|
+
selected_warehouse_space: warehouse_space
|
148
|
+
).perform
|
149
|
+
end
|
150
|
+
|
151
|
+
# Get Price
|
152
|
+
|
153
|
+
PRICE_CHANNEL = {}.tap do |hash|
|
154
|
+
hash[2] = :Shopify
|
155
|
+
hash[9] = :Blibli
|
156
|
+
hash[11] = :Bukalapak
|
157
|
+
hash[13] = :Zalora
|
158
|
+
hash[16] = :Jd
|
159
|
+
end.freeze
|
160
|
+
|
161
|
+
def price
|
162
|
+
if price_channel_name.empty?
|
163
|
+
{
|
164
|
+
price: listing.price,
|
165
|
+
sale_price: listing.sale_price,
|
166
|
+
sale_start_at: listing.sale_start_at,
|
167
|
+
sale_end_at: listing.sale_end_at
|
168
|
+
}
|
169
|
+
else
|
170
|
+
price_channel
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def price_channel
|
175
|
+
class_name = "ItemBuilderMwh::Modes::Price::#{price_channel_name}Service"
|
176
|
+
price_channel_service = class_name.constantize
|
177
|
+
price_channel_service.new(listing).perform
|
178
|
+
end
|
179
|
+
|
180
|
+
def price_channel_name
|
181
|
+
PRICE_CHANNEL[listing.channel_id].to_s
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ItemBuilderMwh
|
4
|
+
module Modes
|
5
|
+
module PreconditionCreate
|
6
|
+
class Base
|
7
|
+
attr_reader :ilisting
|
8
|
+
|
9
|
+
def initialize(ilisting)
|
10
|
+
raise 'ilisting is not set' if ilisting.nil?
|
11
|
+
|
12
|
+
@ilisting = ilisting
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes/precondition_create/base'
|
4
|
+
class ItemBuilderMwh
|
5
|
+
module Modes
|
6
|
+
module PreconditionCreate
|
7
|
+
class ShopeeService < Base
|
8
|
+
def perform
|
9
|
+
{
|
10
|
+
internal_data: listing.internal_data,
|
11
|
+
images: images
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def images
|
16
|
+
listing.item_listing_variant_images.map do |img|
|
17
|
+
{
|
18
|
+
id: img.id,
|
19
|
+
local_id: img.local_id,
|
20
|
+
local_url: img.local_url,
|
21
|
+
url: img.image.image.url
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'item_builder_mwh/modes.rb'
|
4
|
+
require 'item_builder_mwh/modes/precondition_create/shopee_service'
|
5
|
+
require 'warehouse_models'
|
6
|
+
class ItemBuilderMwh
|
7
|
+
module Modes
|
8
|
+
class PreconditionCreateService
|
9
|
+
include Modes
|
10
|
+
|
11
|
+
MAP_PRECONDITION_CREATE_CHANNEL = {}.tap do |hash|
|
12
|
+
hash[12] = :Shopee
|
13
|
+
end.freeze
|
14
|
+
|
15
|
+
def perform
|
16
|
+
base.merge!(warehouse: warehouses).merge(map_precondition_create)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_h(warehouse_space)
|
20
|
+
{
|
21
|
+
warehouse_id: warehouse_space.present? ? wh_mapping(
|
22
|
+
warehouse_space.warehouse_id
|
23
|
+
) : ''
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def map_precondition_create
|
28
|
+
class_name = "ItemBuilderMwh::Modes::PreconditionCreate::#{channel_name}Service"
|
29
|
+
create_channel_service = class_name.constantize
|
30
|
+
create_channel_service.new(listing).perform
|
31
|
+
end
|
32
|
+
|
33
|
+
def channel_name
|
34
|
+
MAP_PRECONDITION_CREATE_CHANNEL[listing.channel_id].to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -20,6 +20,7 @@ class ItemBuilderMwh
|
|
20
20
|
attr_reader :lazada_quantity
|
21
21
|
attr_reader :zalora_reserved_stock
|
22
22
|
attr_reader :shopify_inventory_location
|
23
|
+
attr_reader :shipping_providers
|
23
24
|
def initialize(args)
|
24
25
|
@listing = args.fetch(:listing)
|
25
26
|
@wh_spaces = args.fetch(:wh_spaces, [])
|
@@ -34,7 +35,9 @@ class ItemBuilderMwh
|
|
34
35
|
@lazada_quantity = args.fetch(:lazada_quantity, [])
|
35
36
|
@zalora_reserved_stock = args.fetch(:zalora_reserved_stock, [])
|
36
37
|
@shopify_inventory_location = args.fetch(:shopify_inventory_location, {})
|
37
|
-
|
38
|
+
mode = args.fetch(:mode, '')
|
39
|
+
@shipping_providers = args.fetch(:shipping_providers, [])
|
40
|
+
warehouse unless mode == :create
|
38
41
|
end
|
39
42
|
|
40
43
|
def base
|
data/lib/item_builder_mwh.rb
CHANGED
@@ -6,6 +6,9 @@ require 'item_builder_mwh/modes/base_service'
|
|
6
6
|
require 'item_builder_mwh/modes/price_service'
|
7
7
|
require 'item_builder_mwh/modes/quantity_service'
|
8
8
|
require 'item_builder_mwh/modes/simple_service'
|
9
|
+
require 'item_builder_mwh/modes/create_service'
|
10
|
+
require 'item_builder_mwh/modes/map_create_service'
|
11
|
+
require 'item_builder_mwh/modes/precondition_create_service'
|
9
12
|
require 'item_models'
|
10
13
|
require 'item_builder_mwh/zilingo_quantity_service'
|
11
14
|
require 'item_builder_mwh/lazada_quantity_service'
|
@@ -29,8 +32,10 @@ class ItemBuilderMwh
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def mode_check
|
32
|
-
if mode == :quantity || mode == :simple
|
35
|
+
if mode == :quantity || mode == :simple || mode == :map_create
|
33
36
|
quantity_simple_mode
|
37
|
+
elsif mode == :create || mode == :create_item
|
38
|
+
create_mode
|
34
39
|
else
|
35
40
|
default
|
36
41
|
end
|
@@ -61,7 +66,17 @@ class ItemBuilderMwh
|
|
61
66
|
end
|
62
67
|
|
63
68
|
def default
|
64
|
-
|
69
|
+
datas =
|
70
|
+
if mode == :precondition_create
|
71
|
+
VariantListing.where(
|
72
|
+
channel_association_id: channel_association_ids,
|
73
|
+
profile_channel_association_id: account_id
|
74
|
+
)
|
75
|
+
else
|
76
|
+
listings
|
77
|
+
end
|
78
|
+
|
79
|
+
datas.map do |listing|
|
65
80
|
if listing.local_id.present?
|
66
81
|
if listing.channel_id == 2 && mode == :active
|
67
82
|
modes[mode].new(qty_simple_params(listing)).perform
|
@@ -86,6 +101,19 @@ class ItemBuilderMwh
|
|
86
101
|
}
|
87
102
|
end
|
88
103
|
|
104
|
+
def create_mode
|
105
|
+
item_listings.map do |listing|
|
106
|
+
param =
|
107
|
+
if listing.channel_id == 12
|
108
|
+
qty_simple_params(listing)
|
109
|
+
.merge(shipping_providers: shipping_providers)
|
110
|
+
else
|
111
|
+
qty_simple_params(listing)
|
112
|
+
end
|
113
|
+
modes[mode].new(param.merge(mode: mode)).perform
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
89
117
|
def existing_alloc_stocks
|
90
118
|
@existing_alloc_stocks ||= VariantListingStockAllocation.where(
|
91
119
|
variant_association_id: vl_ids
|
@@ -136,6 +164,10 @@ class ItemBuilderMwh
|
|
136
164
|
@skus ||= listings.map(&:local_id).uniq
|
137
165
|
end
|
138
166
|
|
167
|
+
def channel_association_ids
|
168
|
+
@listing_item_ids ||= listings.map(&:channel_association_id).uniq
|
169
|
+
end
|
170
|
+
|
139
171
|
def zilingo_quantity
|
140
172
|
@zilingo_quantity ||= ItemBuilderMwh::ZilingoQuantityService.new(
|
141
173
|
listings: listings, skus: skus
|
@@ -164,7 +196,7 @@ class ItemBuilderMwh
|
|
164
196
|
end
|
165
197
|
|
166
198
|
def reserved_params
|
167
|
-
"account_id=#{
|
199
|
+
"account_id=#{account_id}
|
168
200
|
&item_variant_ids=#{variant_ids.join(',')}"
|
169
201
|
end
|
170
202
|
|
@@ -179,11 +211,33 @@ class ItemBuilderMwh
|
|
179
211
|
price: ItemBuilderMwh::Modes::PriceService,
|
180
212
|
quantity: ItemBuilderMwh::Modes::QuantityService,
|
181
213
|
simple: ItemBuilderMwh::Modes::SimpleService,
|
182
|
-
active: ItemBuilderMwh::Modes::ActiveService
|
214
|
+
active: ItemBuilderMwh::Modes::ActiveService,
|
215
|
+
create: ItemBuilderMwh::Modes::CreateService,
|
216
|
+
map_create: ItemBuilderMwh::Modes::MapCreateService,
|
217
|
+
precondition_create: ItemBuilderMwh::Modes::CreateService,
|
218
|
+
precondition_update: ItemBuilderMwh::Modes::CreateService,
|
219
|
+
item_create: ItemBuilderMwh::Modes::CreateService,
|
220
|
+
update: ItemBuilderMwh::Modes::CreateService,
|
183
221
|
}
|
184
222
|
end
|
185
223
|
|
186
224
|
def listings
|
187
225
|
@listings ||= VariantListing.joins(:variant).where(id: listing_ids)
|
188
226
|
end
|
227
|
+
|
228
|
+
def account_id
|
229
|
+
account_id ||= listings[0].profile_channel_association_id
|
230
|
+
end
|
231
|
+
|
232
|
+
def item_listings
|
233
|
+
@item_listings ||= VariantListing.joins(:variant).includes(:item_listing).where(
|
234
|
+
id: listing_ids
|
235
|
+
).group(:channel_association_id)
|
236
|
+
end
|
237
|
+
|
238
|
+
def shipping_providers
|
239
|
+
@shipping_providers ||= ShopeeShippingProvider.where(
|
240
|
+
enabled: true, mask_channel_id: 0, account_id: account_id
|
241
|
+
)
|
242
|
+
end
|
189
243
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_builder_mwh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Ivander
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,15 @@ files:
|
|
121
121
|
- lib/item_builder_mwh/modes.rb
|
122
122
|
- lib/item_builder_mwh/modes/active_service.rb
|
123
123
|
- lib/item_builder_mwh/modes/base_service.rb
|
124
|
+
- lib/item_builder_mwh/modes/create/base.rb
|
125
|
+
- lib/item_builder_mwh/modes/create/shopee_service.rb
|
126
|
+
- lib/item_builder_mwh/modes/create_service.rb
|
127
|
+
- lib/item_builder_mwh/modes/map_create/base.rb
|
128
|
+
- lib/item_builder_mwh/modes/map_create/shopee_service.rb
|
129
|
+
- lib/item_builder_mwh/modes/map_create_service.rb
|
130
|
+
- lib/item_builder_mwh/modes/precondition_create/base.rb
|
131
|
+
- lib/item_builder_mwh/modes/precondition_create/shopee_service.rb
|
132
|
+
- lib/item_builder_mwh/modes/precondition_create_service.rb
|
124
133
|
- lib/item_builder_mwh/modes/price/base.rb
|
125
134
|
- lib/item_builder_mwh/modes/price/blibli_service.rb
|
126
135
|
- lib/item_builder_mwh/modes/price/bukalapak_service.rb
|
@@ -148,10 +157,10 @@ files:
|
|
148
157
|
- lib/item_builder_mwh/version.rb
|
149
158
|
- lib/item_builder_mwh/zalora_quantity_service.rb
|
150
159
|
- lib/item_builder_mwh/zilingo_quantity_service.rb
|
151
|
-
homepage:
|
160
|
+
homepage:
|
152
161
|
licenses: []
|
153
162
|
metadata: {}
|
154
|
-
post_install_message:
|
163
|
+
post_install_message:
|
155
164
|
rdoc_options: []
|
156
165
|
require_paths:
|
157
166
|
- lib
|
@@ -166,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
175
|
- !ruby/object:Gem::Version
|
167
176
|
version: '0'
|
168
177
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
170
|
-
signing_key:
|
178
|
+
rubygems_version: 3.3.7
|
179
|
+
signing_key:
|
171
180
|
specification_version: 4
|
172
181
|
summary: Item Builder Multiwarehouse
|
173
182
|
test_files: []
|