# -*- coding: utf-8 -*-

from utils.redis.connect import r
from utils.redis.rkeys import LENSMAN_PHOTO_PRICE_FIXED


def set_lensman_price_fixed(user_id):
    """ 设置摄影师价格设定 """
    from account.models import LensmanInfo
    try:
        lensman = LensmanInfo.objects.get(lensman_id=user_id)
    except LensmanInfo.DoesNotExist:
        lensman = None

    price_fixed = {
        'nomark': (lensman and lensman.nomark) or 299,
        'origin': (lensman and lensman.origin) or 999,
    }

    r.setjson(LENSMAN_PHOTO_PRICE_FIXED % user_id, price_fixed)

    return price_fixed


def get_lensman_price_fixed(user_id):
    """ 获取摄影师价格设定 """
    return r.getjson(LENSMAN_PHOTO_PRICE_FIXED % user_id) or set_lensman_price_fixed(user_id)
