Class: SuperFormatter::Shopline::Order
- Inherits:
-
Object
- Object
- SuperFormatter::Shopline::Order
- Defined in:
- lib/super_formatter/shopline/order.rb
Instance Attribute Summary collapse
-
#items_array ⇒ Object
Returns the value of attribute items_array.
-
#row ⇒ Object
Returns the value of attribute row.
-
#warehouse_items ⇒ Object
Returns the value of attribute warehouse_items.
Instance Method Summary collapse
- #address ⇒ Object
- #cash_on_delivery? ⇒ Boolean
- #destination ⇒ Object
-
#initialize(row) ⇒ Order
constructor
A new instance of Order.
- #items ⇒ Object
- #merge!(row) ⇒ Object
- #only_delivery? ⇒ Boolean
- #order_created_at ⇒ Object
- #order_id ⇒ Object
- #paid? ⇒ Boolean
- #provider ⇒ Object
- #ref_id ⇒ Object
Constructor Details
#initialize(row) ⇒ Order
Returns a new instance of Order.
19 20 21 22 |
# File 'lib/super_formatter/shopline/order.rb', line 19 def initialize(row) self.row = row merge!(row) end |
Instance Attribute Details
#items_array ⇒ Object
Returns the value of attribute items_array.
6 7 8 |
# File 'lib/super_formatter/shopline/order.rb', line 6 def items_array @items_array end |
#row ⇒ Object
Returns the value of attribute row.
5 6 7 |
# File 'lib/super_formatter/shopline/order.rb', line 5 def row @row end |
#warehouse_items ⇒ Object
Returns the value of attribute warehouse_items.
6 7 8 |
# File 'lib/super_formatter/shopline/order.rb', line 6 def warehouse_items @warehouse_items end |
Instance Method Details
#address ⇒ Object
52 53 54 |
# File 'lib/super_formatter/shopline/order.rb', line 52 def address row.address.gsub("台灣", "") end |
#cash_on_delivery? ⇒ Boolean
60 61 62 63 64 65 66 |
# File 'lib/super_formatter/shopline/order.rb', line 60 def cash_on_delivery? if row.payment_method.include?('取貨付款') true else false end end |
#destination ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/super_formatter/shopline/order.rb', line 43 def destination @destination ||= case provider when :UNIMART, :FAMI store_id when :HCT, :TCAT address end end |
#items ⇒ Object
76 77 78 |
# File 'lib/super_formatter/shopline/order.rb', line 76 def items items_array.join(" ") end |
#merge!(row) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/super_formatter/shopline/order.rb', line 80 def merge!(row) self.items_array ||= [] self.warehouse_items ||= Warehouse::List.new self.items_array << "#{row.item_title}-#{row.item_option}*#{row.item_qty}" self.warehouse_items += Warehouse::Item::Code.new(row.item_code, row.item_code, row.item_qty) end |
#only_delivery? ⇒ Boolean
68 69 70 |
# File 'lib/super_formatter/shopline/order.rb', line 68 def only_delivery? !cash_on_delivery? end |
#order_created_at ⇒ Object
56 57 58 |
# File 'lib/super_formatter/shopline/order.rb', line 56 def order_created_at row.order_created end |
#order_id ⇒ Object
15 16 17 |
# File 'lib/super_formatter/shopline/order.rb', line 15 def order_id row.order_id.gsub("#", '') end |
#paid? ⇒ Boolean
72 73 74 |
# File 'lib/super_formatter/shopline/order.rb', line 72 def paid? row.payment_status == '已付款' end |
#provider ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/super_formatter/shopline/order.rb', line 24 def provider @provider ||= case when row.shipping_method.include?('7-11') :UNIMART when row.shipping_method.include?('全家') :FAMI when row.shipping_method.include?('新竹') :HCT when row.shipping_method.include?('黑貓') :TCAT else nil end end |
#ref_id ⇒ Object
39 40 41 |
# File 'lib/super_formatter/shopline/order.rb', line 39 def ref_id order_id end |