# coding=utf-8
__author__ = 'cheng'

from base import *

ALLOWED_HOSTS = []

SECRET_KEY = USE_YOUR_OWN_CONFIG

# Database
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', #设置为mysql数据库
        'NAME': USE_YOUR_OWN_CONFIG,
        'USER': USE_YOUR_OWN_CONFIG,
        'PASSWORD': USE_YOUR_OWN_CONFIG,
        'HOST': USE_YOUR_OWN_CONFIG,
        'PORT': USE_YOUR_OWN_CONFIG,
        'OPTIONS': {
            "init_command": "SET foreign_key_checks = 0;",
            "charset": "utf8mb4",  # 为了支持emoji表情
        },
    },
    'postgres': {
        'NAME': USE_YOUR_OWN_CONFIG,
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': USE_YOUR_OWN_CONFIG,
        'PASSWORD': USE_YOUR_OWN_CONFIG,
        'HOST': USE_YOUR_OWN_CONFIG,
        'PORT': USE_YOUR_OWN_CONFIG,
    },
}


API_HOST = USE_YOUR_OWN_CONFIG

# Redis
BROKER_URL = USE_YOUR_OWN_CONFIG
BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': USE_YOUR_OWN_CONFIG} # 3days. Make sure that colleagues have knew that
REDIS = {
    'doctor': {'host': USE_YOUR_OWN_CONFIG, 'port': USE_YOUR_OWN_CONFIG, 'db': USE_YOUR_OWN_CONFIG},
    'hospital': {'host': USE_YOUR_OWN_CONFIG, 'port': USE_YOUR_OWN_CONFIG, 'db': USE_YOUR_OWN_CONFIG},
    'view': {'host': USE_YOUR_OWN_CONFIG, 'port': USE_YOUR_OWN_CONFIG, 'db': USE_YOUR_OWN_CONFIG},
    'user_cache': {'host': USE_YOUR_OWN_CONFIG, 'port': USE_YOUR_OWN_CONFIG, 'db': USE_YOUR_OWN_CONFIG},
    'tag_cache':{'host': USE_YOUR_OWN_CONFIG, 'port': USE_YOUR_OWN_CONFIG, 'db': USE_YOUR_OWN_CONFIG},
}


# 支付宝网关
ALIPAY_GATEWAY = USE_YOUR_OWN_CONFIG
# 合作身份者ID，以2088开头的16位纯数字
ALIPAY_PARTNER = USE_YOUR_OWN_CONFIG
# 请求参数格式
ALIPAY_FORMAT = USE_YOUR_OWN_CONFIG
# 支付宝接口版本号
ALIPAY_VERSION = USE_YOUR_OWN_CONFIG
# 签约支付宝账号或卖家支付宝帐户
ALIPAY_SELLER_EMAIL = USE_YOUR_OWN_CONFIG
# 交易过程中服务器通知的页面 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
# ALIPAY_NOTIFY_URL = USE_YOUR_OWN_CONFIG
# ALIPAY_NOTIFY_URL = USE_YOUR_OWN_CONFIG
ALIPAY_NOTIFY_URL = USE_YOUR_OWN_CONFIG
# 付完款后跳转的页面 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
# return_url的域名不能写成http://localhost/js_php_utf8/return_url.php ，否则会导致return_url执行无效
ALIPAY_CALLBACK_URL = USE_YOUR_OWN_CONFIG
# 网站商品的展示地址，不允许加?id=123这类自定义参数
ALIPAY_SHOW_URL = USE_YOUR_OWN_CONFIG
# 签名方式 不需修改
ALIPAY_SIGN_TYPE = USE_YOUR_OWN_CONFIG
# 字符编码格式 目前支持 GBK 或 utf-8
ALIPAY_INPUT_CHARSET = USE_YOUR_OWN_CONFIG
# 访问模式,根据自己的服务器是否支持ssl访问，若支持请选择https；若不支持请选择http
ALIPAY_TRANSPORT = USE_YOUR_OWN_CONFIG
# MD5 密钥
ALIPAY_MD5_KEY = USE_YOUR_OWN_CONFIG
ALIPAY_SERVICE_DIRECT_TRADE_CREATE = USE_YOUR_OWN_CONFIG
ALIPAY_SERVICE_AUTH_EXECUTE = USE_YOUR_OWN_CONFIG


#===ALIPAY_APP_CONFIG===START
# https://doc.open.alipay.com/doc2/detail.htm?treeId=204&articleId=105465&docType=1
ALIPAY_APP_APP_ID = USE_YOUR_OWN_CONFIG
ALIPAY_APP_SELLER_USER_ID = ALIPAY_SELLER_USER_ID
ALIPAY_APP_NOTIFY_URL = USE_YOUR_OWN_CONFIG
ALIPAY_APP_TIMEOUT_EXPRESS = '30m'  # "30m" "12h" "3d" "1c" (???)
# 商家的私钥
ALIPAY_APP_MY_PRIVATE_KEY = """-----BEGIN PRIVATE KEY-----
USE_YOUR_OWN_CONFIG
-----END PRIVATE KEY-----"""
# 支付宝针对商家的公钥
ALIPAY_APP_ALI_PUBLIC_KEY = """-----BEGIN PUBLIC KEY-----
USE_YOUR_OWN_CONFIG
-----END PUBLIC KEY-----"""

# 旧的回调地址
ALIPAY_APP_OLD_NOTIFY_URL = USE_YOUR_OWN_CONFIG
# 旧的商家的私钥，在原有接口被废弃在之后可以删除相关的代码和这里的配置
ALIPAY_APP_OLD_MY_PRIVATE_KEY = """-----BEGIN PRIVATE KEY-----
USE_YOUR_OWN_CONFIG
-----END PRIVATE KEY-----"""
# 旧的支付宝针对商家的公钥，在原有接口被废弃在之后可以删除相关的代码和这里的配置
ALIPAY_APP_OLD_ALI_PUBLIC_KEY = """-----BEGIN PUBLIC KEY-----
USE_YOUR_OWN_CONFIG
-----END PUBLIC KEY-----"""

#===ALIPAY_APP_CONFIG===END

# 买单的支付通知URL前缀，请保证最后一个字符是"/"
MAIDAN_PAY_NOTIFY_URL_BASE = USE_YOUR_OWN_CONFIG


# document for ``doc'' app
USE_DOC = DEBUG
if USE_DOC:
    INSTALLED_APPS += (
        'doc',
    )

    TEMPLATES += [
        {
            'BACKEND': 'django.template.backends.jinja2.Jinja2',
            'APP_DIRS': True,
        },
    ]


# 极光推送
JPUSH_APP_KEY = USE_YOUR_OWN_CONFIG
JPUSH_MASTER_SECRET = USE_YOUR_OWN_CONFIG
JPUSH_IOS_OPTIONS = {
    "apns_production":USE_YOUR_OWN_CONFIG
}
IPHONE_SANDBOX_APN_PUSH_CERT = USE_YOUR_OWN_CONFIG
IPHONE_LIVE_APN_PUSH_CERT = USE_YOUR_OWN_CONFIG
IPHONE_USE_SANDBOX = USE_YOUR_OWN_CONFIG

EMAIL_HOST='smtp.exmail.qq.com'
EMAIL_PORT = 25
HERA_EMAIL_USER = ''
HERA_EMAIL_PSWD = ''

# Elasticsearch配置
# Es的索引名
ES_READ_INDEX = 'gm_read'
ES_WRITE_INDEX = 'gm_write'
# Es的机器地址
ES_HOSTS = [
    {'host':'ip1','port':'port1'},
    {'host':'ip2','port':'port2'},
]
# Es 私信集群的机器地址
ES_MSG_HOSTS = [{'host':'10.170.244.207','port':'9200'}]
ES_MSG_READ_INDEX = 'gm_msg_read'
ES_MSG_WRITE_INDEX = 'gm_msg_write'

# 搜索中用到的一些常量
ES_CONSTS = {
    'TAG_ID_DIRECTOR_RECOMMEND':1142, # "所长精选" tag id
    'TAG_ID_POPULAR_RECOMMEND':1203, # "热门推荐" tag id
    'TAG_ID_POPULAR':1143, # "热门关注" tag id
    'TAG_ID_DIARY_WITH_SERVICE':1144, # "美购日记" tag id
}

DIARY_VIEW = {
    "min":1,
    "max":3
}

TOPIC_VIEW = {
    "min":1,
    "max":3
}

DATA_SYNC = {
    'redis_url': 'redis://host:port/db',
    'prefix': 'gaia:data-sync',
    'enqueue_table_event': True,
#   'table_event_process_delay_list'': [5.0, 60.0],
#   'fetch_chunk_size': 100,
}

ASYNC_QUEUE = {
    'redis_url': 'redis://host:port/db',
    'redis_prefix': 'gaia:async-queue',
    'logger_name': 'async_queue',
    'check_period_seconds': 30,
    'watchdog_min_timeout': 60,
    'watchdog_max_timeout': 30*60,
}

from datetime import timedelta
from celery.schedules import crontab

CELERYBEAT_SCHEDULE = {
    'sms_service': {
        'task': 'api.tasks.period_task.sms_service',
        'schedule': timedelta(seconds=1200),
        'args': ()
    },
    'link_doctor': {
        'task': 'api.tasks.period_task.link_doctor',
        'schedule': timedelta(minutes=6),
        'args': ()
    },
    'hospital_body_sub_items': {
        'task': 'api.tasks.period_task.hospital_body_sub_items',
        'schedule': timedelta(days=1),
        'args': ()
    },
    'update_diary_last_modified': {
        'task': 'api.tasks.period_task.update_diary_last_modified',
        'schedule': timedelta(minutes=60),
        'args': ()
    },
    'remind_doctor_reservation': {
        'task': 'api.tasks.period_task.remind_doctor_reservation',
        'schedule': crontab(hour=20, minute=0),
        'args': (),
    },
    'query_and_set_order_stage_status': {
        'task': 'api.tasks.period_task.query_and_set_order_stage_status',
        'schedule': timedelta(minutes=30),
        'args': ()
    },
}

PUSH_IN_FEED_TOPIC_VOTE_THRESHOLD = 40
PUSH_IN_FEED_TOPIC_COUNT = 30 # push how many topics with tag xxx into user's feed

TOPIC_VOTE_AMPLIFY_THRESHOLD = 20

PUSH_NOTIFICATION_AFTER_FOLLOW_USER = False

# 分期付款
JIKE_URL = "http://test.geexfinance.com/merchant/service"
JIKE_SERVICE_ID = "gengmei"
JIKE_SERVICE_HASH = "3710f84987aaa4f455a10f8bbb5c55e1"
JIKE_USERID = '12369'

# 用于非必须登录接口的特殊匿名用户ID
ANONYMOUS_USER_ID = 12345

#
# BEGIN OPTIONAL
#

INTERNAL_EMAIL = {
    'address':  'x@wanmeizhensuo.com',
    'host':     'smtp.exmail.qq.com',
    'username': 'x',
    'password': 'x',
}

TEST_EMAIL_LIST = [
    'a@wanmeizhensuo.com',
    'b@wanmeizhensuo.com',
    'c@wanmeizhensuo.com',
]

TEST_PHONE_EMAIL_MAP = [
    '11122223333': 'd@wanmeizhensuo.com',
    '11133334444': ['e@wanmeizhensuo.com', 'f@wanmeizhensuo.com'],
]

POINTS_PER_YUAN = 100

#
# END OPTIONAL
#

# 更美客服对应的唯一一个person_id
KEFU_PERSION_ID = 'a3c1087a1bdd11e682b70242c0a8020b'
