item_builder_mwh 0.1.40 → 0.1.43
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 +2 -2
- 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 +186 -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 +65 -3
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f8b46a34f49c60b4335a965e621aae4e0593859f826adbbd2ca6b0d1d15df6
|
4
|
+
data.tar.gz: befcdc3fa0e9ce2318cbab0ee2bba497623e04cfbaa99e7b84b839ec2de899de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25b8df1a064d7b9bd5bc305f1eb47e51dff49a724d309298af2970c6664f87b87aa35b2c14a2289ef4663a650a2b7a0a2899f55a91129d901801224f5177d0de
|
7
|
+
data.tar.gz: d05fc096a6c505674130ab078a33bb7b69f25a040b357b79426b802c591627883dbfdde88b5554c584fa7b86a789515541c8f65d848dadf8a84227ae4295fe8b
|
@@ -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 :listing
|
8
|
+
|
9
|
+
def initialize(listing)
|
10
|
+
raise 'ilisting is not set' if listing.nil?
|
11
|
+
|
12
|
+
@listing = listing
|
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/map_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,186 @@
|
|
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/map_create/shopee_service'
|
7
|
+
require 'item_builder_mwh/modes/quantity/base'
|
8
|
+
require 'item_builder_mwh/modes/quantity/lazada_service'
|
9
|
+
require 'item_builder_mwh/modes/quantity/zalora_service'
|
10
|
+
require 'item_builder_mwh/modes/quantity/zilingo_service'
|
11
|
+
require 'item_builder_mwh/modes/price/base'
|
12
|
+
require 'item_builder_mwh/modes/price/blibli_service'
|
13
|
+
require 'item_builder_mwh/modes/price/bukalapak_service'
|
14
|
+
require 'item_builder_mwh/modes/price/zalora_service'
|
15
|
+
require 'item_builder_mwh/modes/price/shopify_service'
|
16
|
+
require 'item_builder_mwh/modes/price/sale_price_policy'
|
17
|
+
require 'item_builder_mwh/modes/price/jd_service'
|
18
|
+
class ItemBuilderMwh
|
19
|
+
module Modes
|
20
|
+
class MapCreateService
|
21
|
+
include Modes
|
22
|
+
|
23
|
+
MAP_CREATE_CHANNEL = {}.tap do |hash|
|
24
|
+
hash[12] = :Shopee
|
25
|
+
end.freeze
|
26
|
+
|
27
|
+
def perform
|
28
|
+
base.merge!(warehouse: warehouses).merge(map_create).merge(map_create_channel)
|
29
|
+
end
|
30
|
+
|
31
|
+
def map_create
|
32
|
+
{
|
33
|
+
name: listing.name,
|
34
|
+
description: listing.description,
|
35
|
+
weight: listing.package_weight,
|
36
|
+
length: listing.package_length,
|
37
|
+
width: listing.package_width,
|
38
|
+
height: listing.package_height,
|
39
|
+
condition: listing.new_condition,
|
40
|
+
option_name: listing.option_name,
|
41
|
+
option_value: listing.option_value,
|
42
|
+
option2_name: listing.option2_name,
|
43
|
+
option2_value: listing.option2_value,
|
44
|
+
internal_data: listing.internal_data,
|
45
|
+
images: images
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def images
|
50
|
+
listing.item_listing_variant_images.map do |img|
|
51
|
+
{
|
52
|
+
id: img.id,
|
53
|
+
local_id: img.local_id,
|
54
|
+
local_url: img.local_url,
|
55
|
+
url: img.image.image.url
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_h(warehouse_space)
|
61
|
+
{
|
62
|
+
quantity: warehouse_space.present? ? real_quantity(warehouse_space) : 0,
|
63
|
+
warehouse_id: warehouse_space.present? ? wh_mapping(
|
64
|
+
warehouse_space.warehouse_id
|
65
|
+
) : ''
|
66
|
+
}.merge(price)
|
67
|
+
end
|
68
|
+
|
69
|
+
def map_create_channel
|
70
|
+
class_name = "ItemBuilderMwh::Modes::MapCreate::#{channel_name}Service"
|
71
|
+
create_channel_service = class_name.constantize
|
72
|
+
create_channel_service.new(listing).perform
|
73
|
+
end
|
74
|
+
|
75
|
+
def channel_name
|
76
|
+
MAP_CREATE_CHANNEL[listing.channel_id].to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get Quantity Data
|
80
|
+
|
81
|
+
QUANTITY_CHANNEL = {}.tap do |hash|
|
82
|
+
hash[2] = :Shopify
|
83
|
+
hash[3] = :Lazada
|
84
|
+
hash[13] = :Zalora
|
85
|
+
hash[18] = :Zilingo
|
86
|
+
end.freeze
|
87
|
+
|
88
|
+
def real_quantity(warehouse_space)
|
89
|
+
if quantity_channel_name == 'Zilingo'
|
90
|
+
qty(warehouse_space)
|
91
|
+
else
|
92
|
+
[qty(warehouse_space), 0].sort[1]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def qty(warehouse_space)
|
97
|
+
if quantity_channel_name.empty? || quantity_channel_name == "Shopify"
|
98
|
+
available_quantity(warehouse_space)
|
99
|
+
else
|
100
|
+
qty_channel(warehouse_space)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def qty_channel(warehouse_space)
|
105
|
+
class_name = "ItemBuilderMwh::Modes::Quantity::#{quantity_channel_name}Service"
|
106
|
+
qty_channel_service = class_name.constantize
|
107
|
+
qty_channel_service.new(listing, available_quantity(warehouse_space), local_qty.to_i).perform
|
108
|
+
end
|
109
|
+
|
110
|
+
def quantity_channel_name
|
111
|
+
QUANTITY_CHANNEL[listing.channel_id].to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
def local_qty
|
115
|
+
if quantity_channel_name == 'Zilingo'
|
116
|
+
return 0 if zilingo_quantity.blank?
|
117
|
+
|
118
|
+
zilingo_quantity[listing.local_id].to_i
|
119
|
+
elsif quantity_channel_name == 'Zalora'
|
120
|
+
return 0 if zalora_reserved_stock.blank?
|
121
|
+
|
122
|
+
zalora_reserved_stock[listing.local_id].to_i
|
123
|
+
else
|
124
|
+
return 0 if lazada_quantity.blank?
|
125
|
+
|
126
|
+
lazada_quantity[listing.local_id].to_i
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def credential
|
131
|
+
return shopify_inventory_location['credential'] if shopify_inventory_location['credential'].present?
|
132
|
+
|
133
|
+
nil
|
134
|
+
end
|
135
|
+
|
136
|
+
def wh_routing
|
137
|
+
return credential['warehouse_routing'] if credential.present? && credential['warehouse_routing'].present?
|
138
|
+
|
139
|
+
0
|
140
|
+
end
|
141
|
+
|
142
|
+
def available_quantity(warehouse_space)
|
143
|
+
ItemBuilderMwh::GetQuantityService.new(
|
144
|
+
listing: listing, stock_alloc: stock_alloc,
|
145
|
+
variant: variant, bundle_variants: bundle_variants,
|
146
|
+
existing_allocated_stock: existing_allocated_stock,
|
147
|
+
listing_wh_sp_quantity: warehouse_space.quantity, wh_routing: wh_routing,
|
148
|
+
selected_warehouse_space: warehouse_space
|
149
|
+
).perform
|
150
|
+
end
|
151
|
+
|
152
|
+
# Get Price
|
153
|
+
|
154
|
+
PRICE_CHANNEL = {}.tap do |hash|
|
155
|
+
hash[2] = :Shopify
|
156
|
+
hash[9] = :Blibli
|
157
|
+
hash[11] = :Bukalapak
|
158
|
+
hash[13] = :Zalora
|
159
|
+
hash[16] = :Jd
|
160
|
+
end.freeze
|
161
|
+
|
162
|
+
def price
|
163
|
+
if price_channel_name.empty?
|
164
|
+
{
|
165
|
+
price: listing.price,
|
166
|
+
sale_price: listing.sale_price,
|
167
|
+
sale_start_at: listing.sale_start_at,
|
168
|
+
sale_end_at: listing.sale_end_at
|
169
|
+
}
|
170
|
+
else
|
171
|
+
price_channel
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def price_channel
|
176
|
+
class_name = "ItemBuilderMwh::Modes::Price::#{price_channel_name}Service"
|
177
|
+
price_channel_service = class_name.constantize
|
178
|
+
price_channel_service.new(listing).perform
|
179
|
+
end
|
180
|
+
|
181
|
+
def price_channel_name
|
182
|
+
PRICE_CHANNEL[listing.channel_id].to_s
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
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 || mode == :item_create || mode == :precondition_create || mode == :precondition_update
|
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'
|
@@ -31,6 +34,10 @@ class ItemBuilderMwh
|
|
31
34
|
def mode_check
|
32
35
|
if mode == :quantity || mode == :simple
|
33
36
|
quantity_simple_mode
|
37
|
+
elsif mode == :create || mode == :item_create || mode == :precondition_create || mode == :precondition_update
|
38
|
+
create_mode
|
39
|
+
elsif mode == :map_create
|
40
|
+
map_create_mode
|
34
41
|
else
|
35
42
|
default
|
36
43
|
end
|
@@ -61,7 +68,17 @@ class ItemBuilderMwh
|
|
61
68
|
end
|
62
69
|
|
63
70
|
def default
|
64
|
-
|
71
|
+
datas =
|
72
|
+
if mode == :precondition_create
|
73
|
+
VariantListing.where(
|
74
|
+
channel_association_id: channel_association_ids,
|
75
|
+
profile_channel_association_id: account_id
|
76
|
+
)
|
77
|
+
else
|
78
|
+
listings
|
79
|
+
end
|
80
|
+
|
81
|
+
datas.map do |listing|
|
65
82
|
if listing.local_id.present?
|
66
83
|
if listing.channel_id == 2 && mode == :active
|
67
84
|
modes[mode].new(qty_simple_params(listing)).perform
|
@@ -86,6 +103,25 @@ class ItemBuilderMwh
|
|
86
103
|
}
|
87
104
|
end
|
88
105
|
|
106
|
+
def create_mode
|
107
|
+
item_listings.map do |listing|
|
108
|
+
param =
|
109
|
+
if listing.channel_id == 12
|
110
|
+
qty_simple_params(listing)
|
111
|
+
.merge(shipping_providers: shipping_providers)
|
112
|
+
else
|
113
|
+
qty_simple_params(listing)
|
114
|
+
end
|
115
|
+
modes[mode].new(param.merge(mode: mode)).perform
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def map_create_mode
|
120
|
+
listings.map do |listing|
|
121
|
+
modes[mode].new(qty_simple_params(listing)).perform
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
89
125
|
def existing_alloc_stocks
|
90
126
|
@existing_alloc_stocks ||= VariantListingStockAllocation.where(
|
91
127
|
variant_association_id: vl_ids
|
@@ -136,6 +172,10 @@ class ItemBuilderMwh
|
|
136
172
|
@skus ||= listings.map(&:local_id).uniq
|
137
173
|
end
|
138
174
|
|
175
|
+
def channel_association_ids
|
176
|
+
@listing_item_ids ||= listings.map(&:channel_association_id).uniq
|
177
|
+
end
|
178
|
+
|
139
179
|
def zilingo_quantity
|
140
180
|
@zilingo_quantity ||= ItemBuilderMwh::ZilingoQuantityService.new(
|
141
181
|
listings: listings, skus: skus
|
@@ -164,7 +204,7 @@ class ItemBuilderMwh
|
|
164
204
|
end
|
165
205
|
|
166
206
|
def reserved_params
|
167
|
-
"account_id=#{
|
207
|
+
"account_id=#{account_id}
|
168
208
|
&item_variant_ids=#{variant_ids.join(',')}"
|
169
209
|
end
|
170
210
|
|
@@ -179,11 +219,33 @@ class ItemBuilderMwh
|
|
179
219
|
price: ItemBuilderMwh::Modes::PriceService,
|
180
220
|
quantity: ItemBuilderMwh::Modes::QuantityService,
|
181
221
|
simple: ItemBuilderMwh::Modes::SimpleService,
|
182
|
-
active: ItemBuilderMwh::Modes::ActiveService
|
222
|
+
active: ItemBuilderMwh::Modes::ActiveService,
|
223
|
+
create: ItemBuilderMwh::Modes::CreateService,
|
224
|
+
map_create: ItemBuilderMwh::Modes::MapCreateService,
|
225
|
+
precondition_create: ItemBuilderMwh::Modes::CreateService,
|
226
|
+
precondition_update: ItemBuilderMwh::Modes::CreateService,
|
227
|
+
item_create: ItemBuilderMwh::Modes::CreateService,
|
228
|
+
update: ItemBuilderMwh::Modes::CreateService,
|
183
229
|
}
|
184
230
|
end
|
185
231
|
|
186
232
|
def listings
|
187
233
|
@listings ||= VariantListing.joins(:variant).where(id: listing_ids)
|
188
234
|
end
|
235
|
+
|
236
|
+
def account_id
|
237
|
+
account_id ||= listings[0].profile_channel_association_id
|
238
|
+
end
|
239
|
+
|
240
|
+
def item_listings
|
241
|
+
@item_listings ||= VariantListing.joins(:variant).includes(:item_listing).where(
|
242
|
+
id: listing_ids
|
243
|
+
).group(:channel_association_id)
|
244
|
+
end
|
245
|
+
|
246
|
+
def shipping_providers
|
247
|
+
@shipping_providers ||= ShopeeShippingProvider.where(
|
248
|
+
enabled: true, mask_channel_id: 0, account_id: account_id
|
249
|
+
)
|
250
|
+
end
|
189
251
|
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.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Ivander
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-09 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
|
@@ -166,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
175
|
- !ruby/object:Gem::Version
|
167
176
|
version: '0'
|
168
177
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
178
|
+
rubygems_version: 3.3.7
|
170
179
|
signing_key:
|
171
180
|
specification_version: 4
|
172
181
|
summary: Item Builder Multiwarehouse
|