export async function getHostTeam(
  { sportdtLogo, match }: any) {
  if (match.Sportsdt) {
    sportdtLogo = `https://data.7m.com.cn/team_data/${match.Sportsdt.SportsdtHostTeamId}/logo_img/club_logo.jpg`
    if (match.LotteryId == 73) {
      sportdtLogo = `https://bdata.7m.com.cn/basketball_team_data/${match.Sportsdt.SportsdtHostTeamId}/logo_img/club_logo.jpg`
    }
    if (match.Sportsdt.SportsdtHostTeamId == null) {
      sportdtLogo = null
    }
  }
  let result:any={}
  result['SportsDtLogo'] = sportdtLogo
  result[`LogoFullPath`]= sportdtLogo
  result[`Logo`]= sportdtLogo

  return result
}

export async function getGuestTeam(
  { sportdtLogo, match }: any) {
  if (match.Sportsdt) {
    sportdtLogo = `https://data.7m.com.cn/team_data/${match.Sportsdt.SportsdtGuestTeamId}/logo_img/club_logo.jpg`
    if (match.LotteryId == 73) {
      sportdtLogo = `https://bdata.7m.com.cn/basketball_team_data/${match.Sportsdt.SportsdtGuestTeamId}/logo_img/club_logo.jpg`
    }
    if (match.Sportsdt.SportsdtGuestTeamId == null) {
      sportdtLogo = null
    }
  }
  let result:any={}
  result['SportsDtLogo'] = sportdtLogo
  result[`LogoFullPath`]= sportdtLogo
  result[`Logo`]= sportdtLogo

  return result
}

export async function getTeam(
  { lotteryId, id, InfoId, isUpdateCache, sportdtLogo, match, }: any) {
  if (match.Sportsdt&&id==match.GuestId) {
    sportdtLogo = `https://data.7m.com.cn/team_data/${match.Sportsdt.SportsdtGuestTeamId}/logo_img/club_logo.jpg`
    if (match.LotteryId == 73) {
      sportdtLogo = `https://bdata.7m.com.cn/basketball_team_data/${match.Sportsdt.SportsdtGuestTeamId}/logo_img/club_logo.jpg`
    }
    if (match.Sportsdt.SportsdtGuestTeamId == null) {
      sportdtLogo = null
    }
  }else if (match.Sportsdt&&id==match.HostId) {
    sportdtLogo = `https://data.7m.com.cn/team_data/${match.Sportsdt.SportsdtHostTeamId}/logo_img/club_logo.jpg`
    if (match.LotteryId == 73) {
      sportdtLogo = `https://bdata.7m.com.cn/basketball_team_data/${match.Sportsdt.SportsdtHostTeamId}/logo_img/club_logo.jpg`
    }
    if (match.Sportsdt.SportsdtHostTeamId == null) {
      sportdtLogo = null
    }
  }
  let result:any={}
  result['SportsDtLogo'] = sportdtLogo
  result[`LogoFullPath`]= sportdtLogo
  result[`Logo`]= sportdtLogo

  return result
  // let key = `${config.CachePrefix}match:match_getTeam:v2_${lotteryId}_${id}_${InfoId}`
  // let reply:any = await client.getAsync(key);
  // if (reply && !isUpdateCache) {
  //   reply = JSON.parse(reply)
  //   if (reply != null) {
  //     reply['SportsDtLogo'] = sportdtLogo
  //     // if(reply[`LogoFullPath`]==null){
  //     //   reply[`LogoFullPath`]= sportdtLogo
  //     // }
  //     reply[`LogoFullPath`]= sportdtLogo

  //     return reply
  //   }
  // }

  // let result: any = {}
  // if (id && lotteryId == 73) {
  //   let t = await Info.db.query(`SELECT
  //     c.*,b.\`ShortName\` as \`MatchTypeShortName\`, a.\`Id\` as \`Rank\`, a.\`Type\` as \`RankType\`
  //   FROM \`T_NBAMatch\` t
  //     join \`T_NBALeagueRank\` a on a.\`MatchSeason\`=t.\`MatchSeason\` and a.\`MatchTypeId\`=t.\`MatchTypeId\`
  //     JOIN \`T_NBAMatchType\` b ON a.\`MatchTypeId\`=b.\`Id\` AND b.\`ParentId\`=0 AND a.\`MatchSeason\`=t.\`MatchSeason\` and a.\`MatchTypeId\`=t.\`MatchTypeId\`
  //     JOIN \`T_NBATeam\` c ON a.\`TeamId\`=c.\`Id\` and c.\`Id\`=${id}
  //   where t.\`Id\`=${InfoId} and c.\`Id\`=${id}
  //   ORDER BY a.\`Type\`, a.\`Id\`
  //   `)
  //   if (t == null || t.length <= 0 || t[0].length <= 0)
  //     result = {}
  //   else {
  //     result = t[0][0];
  //   }
  // } else if (id && lotteryId != 73) {
  //   let t = await Info.db.query(`select t.*,m.\`ShortName\` as \`MatchTypeShortName\` from \`T_Team\` t left join \`T_MatchType\` m on t.\`MatchTypeId\`=m.\`Id\` where t.\`Id\`=${id}`)
  //   if (t == null || t.length <= 0 || t[0].length <= 0)
  //     result = {}
  //   else {
  //     result = t[0][0];
  //   }
  // }

  // if (result != null) {
  //   result['SportsDtLogo'] = sportdtLogo
  //   result[`LogoFullPath`]= sportdtLogo
  //   // if(result[`LogoFullPath`]==null){
  //   //   result[`LogoFullPath`]= sportdtLogo
  //   // }
  //   await client.setAsync(key, JSON.stringify(result))
  //   client.expire(key, 60 * 60 * 24)
  //   return result
  // }
};