class SuperFormatter::Shopline::Order

Attributes

items_array[RW]
row[RW]
warehouse_items[RW]

Public Class Methods

new(row) click to toggle source
# File lib/super_formatter/shopline/order.rb, line 19
def initialize(row)
  self.row = row
  merge!(row)
end

Public Instance Methods

address() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 52
def address
  row.address.gsub("台灣", "")
end
cash_on_delivery?() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 60
def cash_on_delivery?
  if row.payment_method.include?('取貨付款')
    true
  else
    false
  end
end
destination() click to toggle source
# 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() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 76
def items
  items_array.join(" ")
end
merge!(row) click to toggle source
# 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?() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 68
def only_delivery?
  !cash_on_delivery?
end
order_created_at() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 56
def order_created_at
  row.order_created
end
order_id() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 15
def order_id
  row.order_id.gsub("#", '')
end
paid?() click to toggle source
provider() click to toggle source
# 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() click to toggle source
# File lib/super_formatter/shopline/order.rb, line 39
def ref_id
  order_id
end