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


def get_trade_type(trade_type):
    return trade_type if trade_type != 'MINIAPP' else 'JSAPI'


def get_user_openid(user, trade_type):
    if trade_type == 'MINIAPP':
        openid = user.openid_miniapp
    elif trade_type == 'JSAPI':
        openid = user.openid_oauth
    elif trade_type == 'APP':
        openid = None
    else:
        openid = None
    return openid
