local this = class("cellProduceItemInfo", G_UIModuleBase)

function this.bind()
  return {
    leftTime = "",
    produceNum = "",
    progressBar = 0,
    itemIcon = ""
  }
end

function this.methods()
  return {}
end

function this:setInfo(product, buildingGuid)
  local itemData = L_ProductManager:getProductRewardItemData(product.product_id)
  local item = L_ItemManager:parseItem(itemData.itemType, itemData.itemId)
  self.bind.itemIcon = item.icon
  if L_SatietyStore:isBuildingPause(buildingGuid) then
    self.bind.leftTime = L_WordsTpl:getValue("notice_cellProduceItemInfo")
    self.bind.produceNum = "--/--"
    self.bind.progressBar = 0
    return
  end
  local onceTime = L_ProductManager:getProduceOnceTime(buildingGuid, product.product_id)
  local endTime = product.start_time + product.total_count * onceTime
  local nowTime = L_TimeUtil.getServerTime()
  local leftTime = endTime - nowTime
  local finishNum, total, amount = L_ProductManager:getProductProduceInfo(buildingGuid, product)
  if product.start_time > L_TimeUtil.getServerTime() then
    self.bind.progressBar = 0
    leftTime = onceTime * product.total_count
    self.bind.leftTime = L_TimeUtil.secondToLangString(leftTime)
    self.bind.produceNum = L_WordsTpl:getValue("ui_product_produce_number", {
      [0] = 0,
      [1] = total
    })
  else
    if leftTime < 0 then
      leftTime = 0
    end
    self.bind.progressBar = amount
    self.bind.leftTime = L_TimeUtil.secondToLangString(leftTime)
    self.bind.produceNum = L_WordsTpl:getValue("ui_product_produce_number", {
      [0] = finishNum,
      [1] = total
    })
  end
end

return this
