from recommend import *

def online_intent_cid3(uuid='-999999',gid='-999999'):
    '''
    :param uuid:
    :param gid:
    :return: 用户实时cid3
    '''
    recommend_user_intent_change_sql=recommend_user_intent_sql.format(uuid,gid)
    df=execmysl('89',recommend_user_intent_change_sql)
    if df.empty:
        return []
    return df['intent_cid3'].to_list()

def offine_intent_cid3(uuid='-999999',gid='-999999'):
    cold_start_user_history_cid3_intentions_change_sql=cold_start_user_history_cid3_intentions_sql.format(uuid,gid)
    df=execmysl('89',cold_start_user_history_cid3_intentions_change_sql)
    if df.empty:
        return []
    return df['cid3'].to_list()[:3]


def dapan():
    ##大盘补足
    timestamp=getRedisValue('89',cold_start_cid3_heat_intentions_timestamp_redis)
    if not timestamp:
        return []
    dapan_redis=cold_start_cid3_heat_intentions_redis.format(timestamp.get(cold_start_cid3_heat_intentions_timestamp_redis))
    dapan_cid3=getRedisValue('89',dapan_redis)
    return dapan_cid3.get(dapan_redis)[:3]

def main(uuid='-999999',gid='-999999'):
    online_cid3=online_intent_cid3(uuid,gid)
    offline_cid3=offine_intent_cid3(uuid,gid)
    dapan_cid3=dapan()
    cid3s=removeRepeat(online_cid3+offline_cid3+dapan_cid3)[:3]
    skus_df=concatSql(skuinfo_sql,**{"cid3":cid3s})
    return skus_df['sku_no'].to_list()


if __name__ == '__main__':
    uuid='6b4fe2b4-a851-40fe-b569-506bb93e6407'
    #print(online_intent_cid3(uuid))
    print(dapan())

