package com.yidian.shenghuoquan.bmanagercenter.manager

import com.orhanobut.hawk.Hawk
import com.yidian.bcommon.constant.HawkConfig
import com.yidian.shenghuoquan.bmanagercenter.constant.Constant

/**
 * author: yinjiacheng
 * date: 8/5/21 6:40 PM
 * description: 生活号管理
 */
object LifeAccountManager {

  /**
   * 获取生活号类型 by tag
   * e.g. 未认证、个人认证、个体工商户认证、普通企业认证、认证审核、认证驳回
   */
  fun getLifeAccountTag(tagKey: Int?): LifeAccountTag {
    return when (tagKey) {
      Constant.LIFE_ACCOUNT_TAG_COMMON_ENTERPRISE_AUTH -> LifeAccountTag.LIFE_ACCOUNT_TAG_COMMON_ENTERPRISE_AUTH
      Constant.LIFE_ACCOUNT_TAG_INDIVIDUAL_BUSINESS_AUTH -> LifeAccountTag.LIFE_ACCOUNT_TAG_INDIVIDUAL_BUSINESS_AUTH
      Constant.LIFE_ACCOUNT_TAG_PERSONAL_AUTH -> LifeAccountTag.LIFE_ACCOUNT_TAG_PERSONAL_AUTH
      Constant.LIFE_ACCOUNT_TAG_NOT_AUTH -> LifeAccountTag.LIFE_ACCOUNT_TAG_NOT_AUTH
      Constant.LIFE_ACCOUNT_TAG_AUDIT_UNDER -> LifeAccountTag.LIFE_ACCOUNT_TAG_AUDIT_UNDER
      Constant.LIFE_ACCOUNT_TAG_AUTH_REJECT -> LifeAccountTag.LIFE_ACCOUNT_TAG_AUTH_REJECT
      else -> LifeAccountTag.LIFE_ACCOUNT_TAG_DEFAULT
    }
  }

  /**
   * 获取生活号id
   */
  fun getLifeAccountId(): String? {
    return Hawk.get(HawkConfig.LifeAccountId, null)
  }

  /**
   * 保存生活号id
   */
  fun saveLifeAccountId(lifeAccountId: String?) {
    Hawk.put(HawkConfig.LifeAccountId, lifeAccountId ?: "")
  }

  /**
   * 删除生活号id
   */
  fun deleteLifeAccountId() {
    Hawk.delete(HawkConfig.LifeAccountId)
  }

  /**
   * 生活号Tag
   * @param tagKey 唯一标识
   * @param tagText 名称
   */
  enum class LifeAccountTag(private val tagKey: Int, private val tagText: String) {
    LIFE_ACCOUNT_TAG_DEFAULT(-1, ""),
    LIFE_ACCOUNT_TAG_COMMON_ENTERPRISE_AUTH(1, "普通企业"),
    LIFE_ACCOUNT_TAG_INDIVIDUAL_BUSINESS_AUTH(2, "个体工商户"),
    LIFE_ACCOUNT_TAG_PERSONAL_AUTH(3, "个人认证"),
    LIFE_ACCOUNT_TAG_NOT_AUTH(4, "未认证"),
    LIFE_ACCOUNT_TAG_AUDIT_UNDER(5, "审核中"),
    LIFE_ACCOUNT_TAG_AUTH_REJECT(6, "认证驳回")
  }
}
