#pragma once #include #include #include #include #include #include #include typedef enum _ProjectType{ Early, Today, RollBall }ProjectType; typedef enum _MarketChange { MARKET_IMPROVED, // 变好(对投注者更有利) MARKET_WORSENED, // 变差(对投注者更不利) MARKET_UNCHANGED, // 没变 MARKET_INVALID // 无效输入 }MarketChange; class Utils { private: Utils(); ~Utils(); public: static Utils& instance(); public: // 取选择队伍 QString findSuffix(const QString& str1, const QString& str2); // ABC_0 去除后缀 QString convertToBase(const QString& input); // 转换为客户端 QMap toClient(QMap); // 转换为今日 QMap toToday(QMap); // 转换为滚球 QMap toLive(QMap); // 转换为反跟 QMap toContra(QMap); // 获取类型代号 QMap type(QString projcet, QString type); // 获取错误信息 QString error(QString errorCode); QString formatGold(QString gold); // 反向映射 rtype:从标准格式转回原始格式 static QString reverse_map_rtype(const QString &rtypeIn) { QString r = rtypeIn.trimmed().toUpper(); // 反向映射表:标准 → 原始 static const QMap reverseHash = { // 标准 → 简写(优先返回简写) {"EOO", "ODD"}, {"EOE", "EVEN"}, {"HEOO", "HODD"}, {"HEOE", "HEVEN"}, {"REOO", "RODD"}, {"REOE", "REVEN"}, {"HREOO","HRODD"}, {"HREOE","HREVEN"} }; return reverseHash.contains(r) ? reverseHash.value(r) : r; } // 反向映射 wtype:从标准格式转回原始格式 static QString reverse_map_wtype(const QString &wtypeIn) { QString w = wtypeIn.trimmed().toUpper(); // 反向映射表:标准 → 原始 static const QMap reverseHash = { {"EO", "T"}, {"REO", "RT"}, {"HEO", "HT"}, {"HREO", "HRT"} }; // 如果是单双类型,进行反向映射 if (reverseHash.contains(w)) { return reverseHash.value(w); } // 非单双类型,保持原样 return w; } QString get_chose_team(QString rtype) { // 让球 if (rtype == "REH" || rtype == "RH" || rtype == "HREH" || rtype == "HRH") { return "H"; } // 受让 if (rtype == "REC" || rtype == "RC" || rtype == "HREC" || rtype == "HRC") { return "C"; } // 大 if (rtype == "ROUC" || rtype == "OUC" || rtype == "HROUC" || rtype == "HOUC") { return "C"; } // 小 if (rtype == "ROUH" || rtype == "OUH" || rtype == "HROUH" || rtype == "HOUH") { return "H"; } // 独赢主 if (rtype == "RMH" || rtype == "MH" || rtype == "HRMH" || rtype == "HMH") { return "H"; } // 独赢客 if (rtype == "RMC" || rtype == "MC" || rtype == "HRMC" || rtype == "HMC") { return "C"; } // 独赢和 if (rtype == "RMN" || rtype == "MN" || rtype == "HRMN" || rtype == "HMN") { return "N"; } //// 单 //if (rtype == "REOO" || rtype == "EOO" || rtype == "HREOO" || rtype == "HEOO") //{ // return rtype; //} //// 双 //if (rtype == "REOE" || rtype == "EOE" || rtype == "HREOE" || rtype == "HEOE") //{ // return rtype; //} // 改 //// 单 //if (rtype == "RODD" || rtype == "ODD" || rtype == "HRODD" || rtype == "HODD") //{ // return "单"; //} //// 双 //if (rtype == "REVEN" || rtype == "EVEN" || rtype == "HREVEN" || rtype == "HEVEN") //{ // return "双"; //} // 主队大 if (rtype == "ROUHO" || rtype == "OUHO" || rtype == "HROUHO" || rtype == "HOUHO") { return "O"; } // 主队小 if (rtype == "ROUHU" || rtype == "OUHU" || rtype == "HROUHU" || rtype == "HOUHU") { return "U"; } // 客队大 if (rtype == "ROUCO" || rtype == "OUCO" || rtype == "HROUCO" || rtype == "HOUCO") { return "O"; } // 客队小 if (rtype == "ROUCU" || rtype == "OUCU" || rtype == "HROUCU" || rtype == "HOUCU") { return "U"; } return rtype; } // 检查是否为滚球 static bool is_roll_ball(const QString wtype) { static const QStringList wtypeRB = { "RE", "ROU", "HRE", "HROU", "RM", "HRM", "ARE", "BRE", "CRE", "DRE", "ERE", "FRE", "AROU", "BROU", "CROU", "DROU", "EROU", "FROU", "ARM", "BRM", "CRM", "DRM", "ERM", "FRM", "ROUH", "ROUC", "HRUH", "HRUC", "RPD", "RPD3", "RPD5", "RPD7", "HRPD", "RDT", "RT", "HRT", "REO", "HREO", "RF", "RHG", "RMG", "ARG", "BRG", "CRG", "DRG", "ERG", "FRG", "GRG", "HRG", "IRG", "JRG", "RWM", "RDC", "RCS", "RWN", "RTS", "RWB", "RWE", "RSB", "RT1G", "RT3G" }; return wtypeRB.contains(wtype.toUpper()); } // 获取游戏类型 QString get_wagers_wtype_name(QString wtype); MarketChange checkOverUnderChange(const std::string& marketType, const std::string& oldMarket, const std::string& newMarket); MarketChange checkHandicapChange(const std::string& marketType, const std::string& oldMarket, const std::string& newMarket); int get_number_of_application_name(); // static QString gtype_map(const QString >ype) { QString w = gtype.trimmed().toUpper(); // 游戏类型映射表:代码 -> 中文名称 static const QMap gtypeToChinese = { {"FT", "足球"}, // Football {"BK", "篮球"}, // Basketball {"ES", "电竞"}, // E-Sports {"BS", "棒球"}, // Baseball {"BM", "羽毛球"}, // Badminton {"OP", "其他"}, // Other {"SK", "斯诺克"}, // Snooker {"TT", "乒乓球"}, // Table Tennis {"TN", "网球"}, // Tennis {"VB", "排球"} // Volleyball }; // 中文名称映射表:中文名称 -> 代码 static const QMap chineseToGtype = { {"足球", "FT"}, // Football {"篮球 / 美式足球", "BK"}, // Basketball {"篮球", "BK"}, // Basketball {"电竞", "ES"}, // E-Sports {"棒球", "BS"}, // Baseball {"羽毛球", "BM"}, // Badminton {"其他", "OP"}, // Other {"斯诺克", "SK"}, // Snooker {"乒乓球", "TT"}, // Table Tennis {"网球", "TN"}, // Tennis {"排球", "VB"} // Volleyball }; // 检查是否为游戏类型代码 if (gtypeToChinese.contains(w)) { return gtypeToChinese.value(w); } // 检查是否为中文游戏类型名称 if (chineseToGtype.contains(w)) { return chineseToGtype.value(w); } // 如果都不匹配,保持原样 return w; } static QString showtype_map(const QString &showtype) { QString w = showtype.trimmed().toLower(); // 显示类型映射表:代码 -> 中文名称 static const QMap showtypeToChinese = { {"live", "滚球"}, // Live - 正在进行中的比赛 {"today", "今日"}, // Today - 今天进行的比赛 {"early", "早盘"}, // Early - 未来进行的比赛 {"mygame", "我的游戏"}, // My Game - 用户收藏的比赛 {"parlay", "串关"}, // Parlay - 组合投注 {"hot", "热门"}, // Hot - 热门比赛 {"soon", "即将开始"} // Soon - 即将开始的比赛 }; // 中文名称映射表:中文名称 -> 代码 static const QMap chineseToShowtype = { {"滚球", "live"}, // Live {"今日", "today"}, // Today {"早盘", "early"}, // Early {"我的游戏", "mygame"}, // My Game {"串关", "parlay"}, // Parlay {"热门", "hot"}, // Hot {"即将开始", "soon"} // Soon }; // 检查是否为显示类型代码 if (showtypeToChinese.contains(w)) { return showtypeToChinese.value(w); } // 检查是否为中文显示类型名称 if (chineseToShowtype.contains(w)) { return chineseToShowtype.value(w); } // 如果都不匹配,保持原样 return w; } static QString format_wagers_type(QMap& order) { QString wt = order.value("WAGERS_TYPE"); QString teamH = order.value("TEAM_H"); QString teamC = order.value("TEAM_C"); auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; wt.replace(QRegularExpression("\\s*/\\s*"), "/"); auto cleanTeam = [](QString s)->QString { s.replace(QRegularExpression("", QRegularExpression::CaseInsensitiveOption), ""); s.remove(' '); return s.trimmed(); }; teamH = cleanTeam(teamH); teamC = cleanTeam(teamC); // 让分/让球 if (reHas(wt, "(让球|让分)")) return "让球"; // 大/小(含大小分、球队总分) if (reHas(wt, "(大/小|大小|大小分)")) { const bool refHome = (!teamH.isEmpty() && wt.contains(teamH, Qt::CaseInsensitive)) || reHas(wt, "主队"); const bool refAway = (!teamC.isEmpty() && wt.contains(teamC, Qt::CaseInsensitive)) || reHas(wt, "客队"); if (refHome) return "主大小"; if (refAway) return "客大小"; return "大小"; } // 独赢/胜负 if (reHas(wt, "(独赢|胜负|money\\s*line|moneyline)")) return "独赢"; // 单双 if (reHas(wt, "(单/双|单双)")) return "单双"; // 双方进球 if (reHas(wt, "(双方球队进球|Both\\s*Teams\\s*To\\s*Score|BTTS)")) return "双方进球"; // 下个进球 / 首个进球 / 最后进球 if (reHas(wt, "(下个进球|下一个进球|Next\\s*Goal)")) return "下个进球"; if (reHas(wt, "(首个进球|第一球|First\\s*Goal|First\\s*Team\\s*To\\s*Score)")) return "首个进球"; if (reHas(wt, "(最后进球|最后一球|Last\\s*Goal)")) return "最后进球"; // 角球/罚牌/晋级/冠军/点球/加时 if (reHas(wt, "角球")) return "角球"; if (reHas(wt, "(罚牌|红牌|黄牌|卡牌|cards?)")) return "罚牌"; if (reHas(wt, "(晋级|To\\s*Qualify|Qualify)")) return "晋级"; if (reHas(wt, "(冠军|Outright|Futures)")) return "冠军"; if (reHas(wt, "(点球大战|点球|PK\\b|Penalty)")) return "点球"; if (reHas(wt, "(加时|OT\\b|ET\\b|Over\\s*Time|Extra\\s*Time)")) return "加时"; return wt; } static QString format_order_type(QMap& order) { QString wt = order.value("WAGERS_TYPE"); QString otype = order.value("ORDER_TYPE"); QString teamH = order.value("TEAM_H"); QString teamC = order.value("TEAM_C"); auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; wt.replace(QRegularExpression("\\s*/\\s*"), "/"); // 让分/让球 if (reHas(wt, "(让球|让分)")) { return (otype == teamH) ? "让球" : "受让"; } //// 大/小(含大小分、球队总分) //if (reHas(wt, "(大/小|大小|大小分)")) { // const bool refHome = (!teamH.isEmpty() && wt.contains(teamH, Qt::CaseInsensitive)) || reHas(wt, "主队"); // const bool refAway = (!teamC.isEmpty() && wt.contains(teamC, Qt::CaseInsensitive)) || reHas(wt, "客队"); // if (refHome) return "主大小"; // if (refAway) return "客大小"; // return "大小"; //} // 大/小(含大小分、球队总分) if (reHas(wt, "(大/小|大小|大小分)")) { const bool refHome = (!teamH.isEmpty() && wt.contains(teamH, Qt::CaseInsensitive)) || reHas(wt, "主队"); const bool refAway = (!teamC.isEmpty() && wt.contains(teamC, Qt::CaseInsensitive)) || reHas(wt, "客队"); if (reHas(otype, "大")) { if (refHome) return "主队大"; if (refAway) return "客队大"; return "大"; // 全场大 } if (reHas(otype, "小")) { if (refHome) return "主队小"; if (refAway) return "客队小"; return "小"; // 全场小 } return otype; // 保持原样 } //// 球队大小分(主队大/小、客队大/小) //// 必须优先匹配队伍大小 //if (reHas(wt, "(主队大/小|主队大小|主队大小分)")) { // if (reHas(otype, "大")) return "主队大"; // if (reHas(otype, "小")) return "主队小"; // return otype; //} //if (reHas(wt, "(客队大/小|客队大小|客队大小分)")) { // if (reHas(otype, "大")) return "客队大"; // if (reHas(otype, "小")) return "客队小"; // return otype; //} //// 大小/大小分(全场) //if (reHas(wt, "(大/小|大小|大小分)")) { // return otype; // 大 / 小 //} // 独赢/胜负 if (reHas(wt, "(独赢|胜负|money\\s*line|moneyline)")) { if (otype == teamH) return "独赢主"; if (otype == teamC) return "独赢客"; return "独赢和"; } // 单双 if (reHas(wt, "(单/双|单双)")) return otype; // 单 / 双 // 双方进球:是/否 if (reHas(wt, "(双方球队进球|Both\\s*Teams\\s*To\\s*Score|BTTS)")) { if (reHas(otype, "(是|YES)")) return "双方进球-是"; if (reHas(otype, "(否|NO)")) return "双方进球-否"; return otype; } // 下个进球 / 首个进球 / 最后进球:主/客/无进球 if (reHas(wt, "(下个进球|下一个进球|Next\\s*Goal)")) { if (otype == teamH) return "下个进球-主队"; if (otype == teamC) return "下个进球-客队"; if (reHas(otype, "(无进球|No\\s*Goal)")) return "下个进球-无进球"; return otype; } if (reHas(wt, "(首个进球|第一球|First\\s*Goal|First\\s*Team\\s*To\\s*Score)")) { if (otype == teamH) return "首个进球-主队"; if (otype == teamC) return "首个进球-客队"; if (reHas(otype, "(无进球|No\\s*Goal)")) return "首个进球-无进球"; return otype; } if (reHas(wt, "(最后进球|最后一球|Last\\s*Goal)")) { if (otype == teamH) return "最后进球-主队"; if (otype == teamC) return "最后进球-客队"; if (reHas(otype, "(无进球|No\\s*Goal)")) return "最后进球-无进球"; return otype; } // 其他玩法保持原样(角球/罚牌/晋级/冠军/点球/加时等) return otype; } // 场次格式化 QString format_stage(QMap& order) { if (order["WARGES_TYPE"].contains("全场")) { return "全场"; } if (order["WARGES_TYPE"].contains("上半场")) { return "上半场"; } if (order["WARGES_TYPE"].contains("下半场")) { return "下半场"; } if (order["WARGES_TYPE"].contains("第一节")) { return "第一节"; } if (order["WARGES_TYPE"].contains("第二节")) { return "第二节"; } if (order["WARGES_TYPE"].contains("第三节")) { return "第三节"; } if (order["WARGES_TYPE"].contains("第四节")) { return "第四节"; } if (order["WARGES_TYPE"].contains("加时")) { return "加时"; } if (order["WARGES_TYPE"].contains("角球")) { return "角球"; } if (order["WARGES_TYPE"].contains("罚牌")) { return "罚牌"; } if (order["WARGES_TYPE"].contains("晋级")) { return "晋级"; } if (order["WARGES_TYPE"].contains("冠军")) { return "冠军"; } if (order["WARGES_TYPE"].contains("点球")) { return "点球"; } return ""; } // 赛段/时段判断:返回 "全场" / "上半场" / "下半场" / "分节" // - 覆盖关键字:全场/上半场/下半场/半场/第一节/第x节/第x局/第x盘/Q1~Q4/第一盘等 static QString get_stage_tag(const QString& wt) { QString w = wt; auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; // 明确全场 if (reHas(w, "(全场|FT\\b|Full\\s*Time)")) return "全场"; // 半场(优先识别上下半) if (reHas(w, "(上半场|上半)")) return "上半场"; if (reHas(w, "(下半场|下半)")) return "下半场"; if (reHas(w, "(半场|HT\\b|1H\\b|2H\\b)")) return "上半场"; // 未指明上下,按 HTML 常见处理归为“半场”→"上半场" // 分节(Q1~Q4、第一节/第二节/…;或者 局/盘) if (reHas(w, "(Q[1-4]\\b|第\\s*一\\s*节|第\\s*二\\s*节|第\\s*三\\s*节|第\\s*四\\s*节|第\\s*\\d+\\s*节|第\\s*\\d+\\s*局|第\\s*\\d+\\s*盘)")) return "分节"; // 网球/乒乓/斯诺克等常见“盘/局”也视作分节 if (reHas(w, "(第一盘|第二盘|第三盘|第一局|第二局|第三局)")) return "分节"; // 默认当全场处理 return "全场"; } // 玩法子类标签:命中则放入返回列表(可能多标签并存) // 覆盖:加时/角球/罚牌/晋级/点球/冠军(可扩展) // - 加时:加时/加时赛/含加时/OT/ET // - 角球:角球/角球数/角球大小/角球让球 // - 罚牌:罚牌/红牌/黄牌/牌数/卡牌 // - 晋级:晋级/To Qualify/Qualify // - 点球:点球/点球大战/PK/Penalty // - 冠军:冠军/优胜/Outright/Futures/联赛赢家/赛季冠军 static QStringList get_market_tags(const QString& wt) { QStringList tags; auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; if (reHas(wt, "(加时|加时赛|含加时|OT\\b|ET\\b|Over\\s*Time|Extra\\s*Time)")) tags << "加时"; if (reHas(wt, "(角球|角球数|角球大小|角球让球|Corner)")) tags << "角球"; if (reHas(wt, "(罚牌|红牌|黄牌|牌数|卡牌|Cards?)")) tags << "罚牌"; if (reHas(wt, "(晋级|To\\s*Qualify|Qualify)")) tags << "晋级"; if (reHas(wt, "(点球大战|点球|罚点球|PK\\b|Penalty|Pen\\.?\\b)")) tags << "点球"; if (reHas(wt, "(冠军|优胜|联赛赢家|赛季冠军|联赛冠军|夺冠|Outright|Futures)")) tags << "冠军"; // 需要更多类型时,继续追加: // if (reHas(wt, "(界外球|任意球|球门球|Goal\\s*Kicks|Throw\\s*In)")) tags << "边球类"; // if (reHas(wt, "(射正|射门|Shots\\s*On|Shots)")) tags << "射门"; return tags; } static QString get_market(const QString& wt) { auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; if (reHas(wt, "(加时|加时赛|含加时|OT\\b|ET\\b|Over\\s*Time|Extra\\s*Time)")) { return "(加时)"; } if (reHas(wt, "(角球|角球数|角球大小|角球让球|Corner)")) { return "(角球)"; } if (reHas(wt, "(罚牌|红牌|黄牌|牌数|卡牌|Cards?)")) { return "(罚牌)"; } if (reHas(wt, "(晋级|To\\s*Qualify|Qualify)")) { return "(晋级)"; } if (reHas(wt, "(点球大战|点球|罚点球|PK\\b|Penalty|Pen\\.?\\b)")) { return "(点球)"; } if (reHas(wt, "(冠军|优胜|联赛赢家|赛季冠军|联赛冠军|夺冠|Outright|Futures)")) { return "(冠军)"; } // 需要更多类型时,继续追加: // if (reHas(wt, "(界外球|任意球|球门球|Goal\\s*Kicks|Throw\\s*In)")) tags << "边球类"; // if (reHas(wt, "(射正|射门|Shots\\s*On|Shots)")) tags << "射门"; return ""; } static QString get_wtype_code(QMap& order) { QString wt = order.value("WAGERS_TYPE"); QString session = order.value("SESSION"); QString teamH = order.value("TEAM_H"); QString teamC = order.value("TEAM_C"); auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; bool isRB = reHas(wt, "滚球"); bool isHalf = reHas(wt, "(上半场|半场)"); // 是否为“球队总分大小”(主/客队) bool isHomeTotal = (!teamH.isEmpty() && wt.contains(teamH, Qt::CaseInsensitive)) || reHas(wt, "主队"); bool isAwayTotal = (!teamC.isEmpty() && wt.contains(teamC, Qt::CaseInsensitive)) || reHas(wt, "客队"); // 1) 基础盘口类型 → base // R 让球; OU 大小; OUH/OUC 主/客队总分大小; M 独赢; EO 单双 // 可选扩展:G 下个进球;TS 双方球队进球 QString base; if (reHas(wt, "让球")) { base = "R"; } else if (reHas(wt, "大\\s*/\\s*小|大小|大 / 小")) { if (isHomeTotal) base = "OUH"; // 主队总分大小 else if (isAwayTotal) base = "OUC"; // 客队总分大小 else base = "OU"; // 全场大小 } else if (reHas(wt, "独赢")) { base = "M"; } else if (reHas(wt, "单\\s*/\\s*双|单双|单 / 双")) { base = "EO"; } else if (reHas(wt, "下个进球")) { base = "G"; } else if (reHas(wt, "双方球队进球")) { base = "TS"; } else { return QString(); } // 2) 滚球替换(与 html 一致) auto applyRb = [&](const QString& b)->QString { if (!isRB) return b; if (b == "R") return "RE"; if (b == "OU") return "ROU"; if (b == "OUH") return "ROUH"; if (b == "OUC") return "ROUC"; if (b == "M") return "RM"; if (b == "EO") return "REO"; if (b == "G") return "RG"; if (b == "TS") return "RTS"; return b; }; // 3) 半场前缀(与 html 一致,半场在最前加 H) auto applyHalf = [&](const QString& p)->QString { if (!isHalf) return p; if (p == "R") return "HR"; if (p == "RE") return "HRE"; if (p == "OU") return "HOU"; if (p == "ROU") return "HROU"; if (p == "OUH") return "HOUH"; if (p == "ROUH") return "HROUH"; if (p == "OUC") return "HOUC"; if (p == "ROUC") return "HROUC"; if (p == "M") return "HM"; if (p == "RM") return "HRM"; if (p == "EO") return "HEO"; if (p == "REO") return "HREO"; if (p == "G") return "HG"; if (p == "RG") return "HRG"; if (p == "TS") return "HTS"; if (p == "RTS") return "HRTS"; return p; }; QString wtype = applyRb(base); if (!order["GT"].contains("篮球")) { //qDebug() << "半场替换?"; wtype = applyHalf(wtype); } return wtype; } // 获取游戏列表用 static QString get_rtype_code_for_request(const QMap& order) { QString session = order.value("SESSION"); QString show = order.value("showtype"); QString gtRaw = order.value("GT"); QString wt = order.value("WAGERS_TYPE"); auto norm = [](QString s)->QString { s.replace(QRegularExpression("\\s+"), " ").trimmed(); s.replace(QRegularExpression("\\s*/\\s*"), "/"); return s; }; wt = norm(wt); auto has = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.match(s).hasMatch(); }; QString gtype = Utils::gtype_map(gtRaw).toLower(); // ft/bk/... // 1) 滚球优先 const bool isRB = (session == "滚球") || (show == "live") || has(wt, "滚球"); if (isRB) { if (gtype == "ft" && has(wt, "(角球|corner)")) return "rrnou"; return "rb"; } // 2) 专题类(今日/早盘) if (has(wt, "(冠军|Outright|Futures)")) return "outr"; if (gtype == "ft" && has(wt, "(角球|corner)")) return "rnou"; if (has(wt, "(单双|单/双)")) return "eo"; if (has(wt, "(波胆|正确比分)")) return "pd"; if (has(wt, "(双方球队进球|Both\\s*Teams\\s*To\\s*Score|BTTS)")) return "ts"; if (has(wt, "(下个进球|下一个进球|首个进球|第一球|最后进球|Next\\s*Goal|First\\s*Goal|Last\\s*Goal)")) return "g"; if (has(wt, "(点球大战|点球|Penalty|PK\\b)")) return "pen"; if (has(wt, "(加时|OT\\b|ET\\b|Over\\s*Time|Extra\\s*Time)")) return "ot"; if (has(wt, "(晋级|To\\s*Qualify|Qualify)")) return "q"; // 3) 主盘集合(让球/让分 或 大小/大小分 或 独赢/胜负)→ moua if (has(wt, "(让球|让分)") || has(wt, "(大小分|大/小|大小)") || has(wt, "(独赢|胜负|money\\s*line|moneyline)")) return "moua"; // 4) 兜底:未知归总入口 return "moua"; } static QString get_rtype_code(QMap& order) { const QString wt = order.value("WAGERS_TYPE"); const QString session = order.value("SESSION"); const QString teamH = order.value("TEAM_H"); const QString teamC = order.value("TEAM_C"); const QString otype = order.value("ORDER_TYPE"); auto reHas = [](const QString& s, const QString& pat)->bool { QRegularExpression re(pat, QRegularExpression::CaseInsensitiveOption); return re.isValid() ? re.match(s).hasMatch() : s.contains(pat, Qt::CaseInsensitive); }; const bool isRB = reHas(wt, "滚球"); const bool isHalf = reHas(wt, "(上半场|半场)"); // 1) 基础盘别(按 html 的关键字正则) auto baseOf = [&]() -> QString { if (reHas(wt, "让球")) return "R"; if (reHas(wt, "大\\s*/\\s*小|大小|大 / 小")) return "OU"; if (reHas(wt, "独赢")) return "M"; if (reHas(wt, "单\\s*/\\s*双|单双|单 / 双")) return "EO"; return ""; }; // 2) 滚球替换 auto addRb = [&](const QString& b)->QString { if (!isRB) return b; if (b == "R") return "RE"; if (b == "OU") return "ROU"; if (b == "M") return "RM"; if (b == "EO") return "REO"; return b; }; // 3) 半场前缀 auto addHalf = [&](const QString& p)->QString { if (!isHalf) return p; if (p == "R") return "HR"; if (p == "RE") return "HRE"; if (p == "OU") return "HOU"; if (p == "ROU") return "HROU"; if (p == "M") return "HM"; if (p == "RM") return "HRM"; if (p == "EO") return "HEO"; if (p == "REO") return "HREO"; return p; }; // 4) 后缀(侧别/结果),严格按 html 语义 auto suffix = [&](const QString& p)->QString { // 让球:主 H / 客 C if (p == "R" || p == "RE" || p == "HR" || p == "HRE") { return (otype == teamH) ? "H" : "C"; } // 大小:全场 C=大 / H=小;若指向主/客队总分,用 HO/HU/CO/CU if (p == "OU" || p == "ROU" || p == "HOU" || p == "HROU") { const bool refHome = (!teamH.isEmpty() && wt.contains(teamH, Qt::CaseInsensitive)) || reHas(wt, "主队"); const bool refAway = (!teamC.isEmpty() && wt.contains(teamC, Qt::CaseInsensitive)) || reHas(wt, "客队"); const bool isBig = reHas(otype, "大"); if (refHome) return isBig ? "HO" : "HU"; if (refAway) return isBig ? "CO" : "CU"; return isBig ? "C" : "H"; } // 独赢:主 H / 客 C / 和 N if (p == "M" || p == "RM" || p == "HM" || p == "HRM") { if (otype == teamH) return "H"; if (otype == teamC) return "C"; return "N"; } // 单双:单 O / 双 E if (p == "EO" || p == "REO" || p == "HEO" || p == "HREO") { return reHas(otype, "单") ? "O" : "E"; } return ""; }; QString b = baseOf(); // R / OU / M / EO if (b.isEmpty()) return QString(); b = addRb(b); // → RE/ROU/RM/REO if (!order["GT"].contains("篮球")) { b = addHalf(b); // → HRE/HROU/HRM/HREO(若半场) } const QString suf = suffix(b); // H/C/N/O/E/HO/HU/CO/CU if (suf.isEmpty()) return QString(); return b + suf; } // 基于开赛时间 G_TIME 判定会话:滚球/今日/早盘(按“皇冠时间=本地 -12h”) // 支持 "yyyy-MM-dd HH:mm:ss" 与 "MM-dd-yyyy HH:mm:ss" static QString get_session_by_gtime(const QMap& order) { QString gtime = order.value("G_TIME"); QDateTime gdt = QDateTime::fromString(gtime, "yyyy-MM-dd HH:mm:ss"); if (!gdt.isValid()) gdt = QDateTime::fromString(gtime, "MM-dd-yyyy HH:mm:ss"); if (!gdt.isValid()) return QString(); // 皇冠当前时间 QDateTime crownNow = QDateTime::currentDateTime().addSecs(-12 * 3600); QDate crownToday = crownNow.date(); // 已开赛 → 滚球 if (crownNow >= gdt) return "滚球"; // 未开赛:同日 → 今日;未来日期 → 早盘 if (gdt.date() == crownToday) return "今日"; if (gdt.date() > crownToday) return "早盘"; // 理论到不了这里,兜底按今日 return "今日"; } // 根据开赛时间自动切换会话类型:早盘->今日->滚球 static QString get_auto_session(const QMap& order) { QString gtime = order.value("G_TIME"); if (gtime.isEmpty()) { return "早盘"; // 默认早盘 } // 解析开赛时间 QDateTime gameTime = QDateTime::fromString(gtime, "yyyy-MM-dd HH:mm:ss"); if (!gameTime.isValid()) { gameTime = QDateTime::fromString(gtime, "MM-dd-yyyy HH:mm:ss"); } if (!gameTime.isValid()) { return "早盘"; // 解析失败,默认早盘 } // 皇冠当前时间(本地-12小时) QDateTime crownNow = QDateTime::currentDateTime().addSecs(-12 * 3600); QDate crownToday = crownNow.date(); QDate gameDate = gameTime.date(); // 判断会话类型 if (gameDate > crownToday) { return "早盘"; // 未来日期 -> 早盘 } else if (gameDate == crownToday) { // 同一天,判断是否已开赛 if (crownNow >= gameTime) { return "滚球"; // 已开赛 -> 滚球 } else { return "今日"; // 未开赛 -> 今日 } } else { return "滚球"; // 过去日期 -> 滚球 } } // 根据会话类型自动获取对应的 wtype 和 rtype static QMap get_auto_wtype_rtype(QMap& order) { QMap result; // 自动切换会话 QString session = get_auto_session(order); result["SESSION"] = session; // 如果变成滚球,在 WAGERS_TYPE 前边加上 "(滚球)" if (session == "滚球") { QString wagersType = order.value("WAGERS_TYPE"); if (!wagersType.startsWith("(滚球)")) { order["WAGERS_TYPE"] = "(滚球) " + wagersType; } } // 根据会话类型获取 wtype QString wtype = get_wtype_code(order); result["wtype"] = wtype; // 根据会话类型获取 rtype QString rtype = get_rtype_code(order); result["rtype"] = rtype; // 根据会话类型设置 showtype QString showtype; if (session == "滚球") { showtype = "live"; } else if (session == "今日") { showtype = "today"; } else { showtype = "early"; } result["showtype"] = showtype; return result; } // 完整的自动切换函数,包含所有必要字段 static QMap auto_switch_session(QMap order) { // 获取自动切换的结果 QMap autoResult = get_auto_wtype_rtype(order); // 更新订单数据 order["SESSION"] = autoResult["SESSION"]; order["showtype"] = autoResult["showtype"]; order["wtype"] = autoResult["wtype"]; order["rtype"] = autoResult["rtype"]; // 根据会话类型设置其他相关字段 QString session = autoResult["SESSION"]; QString wtype = autoResult["wtype"]; // 设置 STAGE(全场/上半场) QString stage = "全场"; if (wtype.contains("H", Qt::CaseInsensitive) && (wtype.startsWith("H") || wtype.contains("HRE") || wtype.contains("HOU"))) { stage = "上半场"; } order["STAGE"] = stage; // 设置 G_TIME(如果为空) if (order["G_TIME"].isEmpty()) { order["G_TIME"] = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); } return order; } // 使用示例 void example_usage() { QMap order; order["GT"] = "足球"; order["WAGERS_TYPE"] = "让球"; order["ORDER_TYPE"] = "让球"; order["TEAM_H"] = "主队"; order["TEAM_C"] = "客队"; order["G_TIME"] = "2025-09-23 21:00:00"; // 开赛时间 // 自动切换会话 QMap result = auto_switch_session(order); qDebug() << "自动切换结果:"; qDebug() << " SESSION:" << result["SESSION"]; qDebug() << " showtype:" << result["showtype"]; qDebug() << " wtype:" << result["wtype"]; qDebug() << " rtype:" << result["rtype"]; qDebug() << " STAGE:" << result["STAGE"]; } static QString getCountFieldName(const QString& orderType) { // 让球/受让 if (orderType == "让球" || orderType == "受让") { return "R_COUNT"; } // 大小(全场) if (orderType == "大" || orderType == "小") { return "OU_COUNT"; } // 独赢 if (orderType == "独赢主" || orderType == "独赢客" || orderType == "独赢和") { return "M_COUNT"; } // 单双 if (orderType == "单" || orderType == "双") { return "EO_COUNT"; } // 角球相关 if (orderType.contains("角球")) { if (orderType.contains("让球")) { return "RN_COUNT"; // 角球让球 } else if (orderType.contains("大") || orderType.contains("小")) { return "CN_COUNT"; // 角球大小 } else if (orderType.contains("独赢")) { return "MN_COUNT"; // 角球独赢 } else if (orderType.contains("单") || orderType.contains("双")) { return "EON_COUNT"; // 角球单双 } else { return "CN_COUNT"; // 默认角球盘 } } // 波胆(正确比分) if (orderType.contains("波胆") || orderType.contains("正确比分")) { return "PD_COUNT"; } // 总进球 if (orderType.contains("总进球") || orderType.contains("进球数")) { return "TQ_COUNT"; } // 加时相关 if (orderType.contains("加时")) { if (orderType.contains("让球")) { return "RET_COUNT"; // 加时让球 } else if (orderType.contains("大") || orderType.contains("小")) { return "OUET_COUNT"; // 加时大小 } else if (orderType.contains("独赢")) { return "MET_COUNT"; // 加时独赢 } else { return "ET_COUNT"; // 默认加时盘 } } // 点球相关 if (orderType.contains("点球")) { if (orderType.contains("让球")) { return "RPK_COUNT"; // 点球让球 } else if (orderType.contains("大") || orderType.contains("小")) { return "OUPK_COUNT"; // 点球大小 } else if (orderType.contains("独赢")) { return "MPK_COUNT"; // 点球独赢 } else { return "PK_COUNT"; // 默认点球盘 } } // 特殊功能 if (orderType.contains("特殊") || orderType.contains("特殊功能")) { return "SFS_COUNT"; } // 其他特殊玩法 if (orderType.contains("双方进球")) { return "TS_COUNT"; } if (orderType.contains("下个进球") || orderType.contains("首个进球") || orderType.contains("最后进球")) { return "G_COUNT"; } if (orderType.contains("主队大") || orderType.contains("主队小")) { return "OUH_COUNT"; } if (orderType.contains("客队大") || orderType.contains("客队小")) { return "OUC_COUNT"; } if (orderType.contains("罚牌") || orderType.contains("卡牌")) { return "CARD_COUNT"; } if (orderType.contains("晋级") || orderType.contains("资格")) { return "QUALIFY_COUNT"; } if (orderType.contains("冠军")) { return "CHAMPION_COUNT"; } // 上半场相关 if (orderType.contains("上半场")) { if (orderType.contains("让球")) { return "HR_COUNT"; } else if (orderType.contains("大") || orderType.contains("小")) { return "HOU_COUNT"; } else if (orderType.contains("独赢")) { return "HM_COUNT"; } else if (orderType.contains("单") || orderType.contains("双")) { return "HEO_COUNT"; } else { return "H_COUNT"; // 默认上半场 } } // 下半场相关 if (orderType.contains("下半场")) { if (orderType.contains("让球")) { return "SR_COUNT"; } else if (orderType.contains("大") || orderType.contains("小")) { return "SOU_COUNT"; } else if (orderType.contains("独赢")) { return "SM_COUNT"; } else if (orderType.contains("单") || orderType.contains("双")) { return "SEO_COUNT"; } else { return "S_COUNT"; // 默认下半场 } } // 滚球相关 if (orderType.contains("滚球")) { if (orderType.contains("让球")) { return "RE_COUNT"; } else if (orderType.contains("大") || orderType.contains("小")) { return "ROU_COUNT"; } else if (orderType.contains("独赢")) { return "RM_COUNT"; } else if (orderType.contains("单") || orderType.contains("双")) { return "REO_COUNT"; } else { return "R_COUNT"; // 默认滚球 } } qDebug() << "[警告] 未知的盘口类型:" << orderType; return ""; } static QString getModelForOrderType(const QString& orderType) { // 让球/受让 if (orderType == "让球" || orderType == "受让") { return "R"; } // 大小 else if (orderType == "大" || orderType == "小") { return "OU"; } // 独赢 else if (orderType == "独赢主" || orderType == "独赢客" || orderType == "独赢和") { return "M"; } // 单双 else if (orderType == "单" || orderType == "双") { return "EO"; } // 角球相关 else if (orderType.contains("角球")) { if (orderType.contains("让球")) { return "RN"; // 角球让球 } else if (orderType.contains("大") || orderType.contains("小")) { return "CN"; // 角球大小 } else if (orderType.contains("独赢")) { return "CM"; // 角球独赢 } else if (orderType.contains("单") || orderType.contains("双")) { return "CEO"; // 角球单双 } else { return "CN"; // 默认角球盘 } } // 波胆 else if (orderType.contains("波胆") || orderType.contains("正确比分")) { return "PD"; } // 总进球 else if (orderType.contains("总进球") || orderType.contains("进球数")) { return "TQ"; } // 加时 else if (orderType.contains("加时")) { if (orderType.contains("让球")) return "RET"; else if (orderType.contains("大小")) return "OUET"; else if (orderType.contains("独赢")) return "MET"; else if (orderType.contains("单双")) return "EOET"; else return "ET"; } // 点球 else if (orderType.contains("点球")) { if (orderType.contains("让球")) return "RPK"; else if (orderType.contains("大小")) return "OUPK"; else if (orderType.contains("独赢")) return "MPK"; else if (orderType.contains("单双")) return "EOPK"; else return "PK"; } // 球队大小 else if (orderType == "主队大" || orderType == "主队小" || orderType == "客队大" || orderType == "客队小") { return "OU"; // 球队大小归类到OU } // 双方进球 else if (orderType.contains("双方进球") || orderType.contains("双方球队进球")) { return "TS"; } // 下个进球/首个进球/最后进球 else if (orderType.contains("下个进球") || orderType.contains("首个进球") || orderType.contains("最后进球") || orderType.contains("进球")) { return "RG"; } // 罚牌相关 else if (orderType.contains("罚牌") || orderType.contains("红牌") || orderType.contains("黄牌") || orderType.contains("卡牌")) { return "CARD"; } // 晋级相关 else if (orderType.contains("晋级") || orderType.contains("资格")) { return "QUALIFY"; } // 冠军相关 else if (orderType.contains("冠军") || orderType.contains("夺冠")) { return "CHAMPION"; } // 特殊玩法 else if (orderType.contains("特殊") || orderType.contains("其他")) { return "SFS"; } // 上半场相关 else if (orderType.contains("上半场")) { if (orderType.contains("让球")) return "HR"; else if (orderType.contains("大小")) return "HOU"; else if (orderType.contains("独赢")) return "HM"; else if (orderType.contains("单双")) return "HEO"; else if (orderType.contains("角球")) { if (orderType.contains("让球")) return "HRN"; else if (orderType.contains("大小")) return "HCN"; else if (orderType.contains("独赢")) return "HCM"; else return "HCN"; } else return "H"; // 通用上半场 } // 下半场相关 else if (orderType.contains("下半场")) { if (orderType.contains("让球")) return "R2"; else if (orderType.contains("大小")) return "OU2"; else if (orderType.contains("独赢")) return "M2"; else if (orderType.contains("单双")) return "EO2"; else if (orderType.contains("角球")) { if (orderType.contains("让球")) return "RN2"; else if (orderType.contains("大小")) return "CN2"; else if (orderType.contains("独赢")) return "CM2"; else return "CN2"; } else return "2H"; // 通用下半场 } // 滚球相关 else if (orderType.contains("滚球")) { if (orderType.contains("让球")) return "RE"; else if (orderType.contains("大小")) return "ROU"; else if (orderType.contains("独赢")) return "RM"; else if (orderType.contains("单双")) return "REO"; else if (orderType.contains("角球")) { if (orderType.contains("让球")) return "RRN"; else if (orderType.contains("大小")) return "RCN"; else if (orderType.contains("独赢")) return "RCM"; else return "RCN"; } else return "RB"; // 通用滚球 } // 分节相关(篮球等) else if (orderType.contains("第一节") || orderType.contains("第二节") || orderType.contains("第三节") || orderType.contains("第四节") || orderType.contains("Q1") || orderType.contains("Q2") || orderType.contains("Q3") || orderType.contains("Q4")) { if (orderType.contains("让球")) return "Q1R"; // 第一节让球 else if (orderType.contains("大小")) return "Q1OU"; // 第一节大小 else if (orderType.contains("独赢")) return "Q1M"; // 第一节独赢 else if (orderType.contains("单双")) return "Q1EO"; // 第一节单双 else return "Q1"; // 通用第一节 } // 默认情况 else { qDebug() << "[警告] 未知的盘口类型:" << orderType; return ""; // 返回空字符串表示不支持 } } static QString get_rtypename(QMap order) { if (order["GT"].contains("篮球")) { if (order["SESSION"] == "早盘") { return "篮球早盘全部"; } if (order["SESSION"] == "今日") { return "篮球今日全部"; } if (order["SESSION"] == "滚球") { return "篮球滚球全部"; } } if (order["GT"] == "足球") { return order["GT"] + order["SESSION"] + order["STAGE"]; } return ""; } // 繁体转简体 static QString traditionalToSimplified(const QString& traditional) { if (traditional.isEmpty()) { return traditional; } // 将 QString 转换为 wchar_t 数组 int length = traditional.length(); wchar_t* inputBuffer = new wchar_t[length + 1]; traditional.toWCharArray(inputBuffer); inputBuffer[length] = L'\0'; wchar_t* outputBuffer = new wchar_t[length + 1]; // 使用 LCMapString 进行简繁转换 int result = LCMapStringW( LOCALE_SYSTEM_DEFAULT, // 系统区域设置 LCMAP_SIMPLIFIED_CHINESE, // 简体中文映射 inputBuffer, // 输入字符串 length, // 输入长度 outputBuffer, // 输出缓冲区 length // 输出缓冲区大小 ); QString simplified; if (result > 0) { outputBuffer[result] = L'\0'; simplified = QString::fromWCharArray(outputBuffer, result); } else { // 如果转换失败,返回原字符串 simplified = traditional; } delete[] inputBuffer; delete[] outputBuffer; return simplified; } // 标准化URL:保留主机名(包括子域名),移除路径和参数 static QString normalizeUrl(const QString& url, const QString& defaultUrl = "") { // 为空则返回默认值 if (url.isEmpty()) { return defaultUrl; } // 去除空格 QString trimmedUrl = url.trimmed(); QUrl qurl(trimmedUrl); // 如果URL无效或缺少协议,尝试添加https:// if (!qurl.isValid() || qurl.scheme().isEmpty()) { qurl = QUrl("https://" + trimmedUrl); } // 如果仍然无效,返回默认值 if (!qurl.isValid() || qurl.host().isEmpty()) { return defaultUrl; } // 获取主机名(保留www等子域名) QString host = qurl.host(); // 构建标准化URL QString scheme = (qurl.scheme() == "http") ? "http" : "https"; return scheme + "://" + host + "/"; } /* * 函数:switchConRtype * 目的: * 将前端内部使用的 rtype(玩法/赔率短码)映射为数据对象中实际使用的 ratio 字段名。 * 对应前端文件 `game_more_page.txt` 中的 JavaScript 实现:_self.switchConRtype。 * * 使用场景: * JSON/XML 解析时用到 -- 前端在读取比率时会先调用该映射得到类似 "ratio_ouo" 的键再去取值。 * * 参数: * - rtype: 要转换的玩法短码(例如 "ouc", "ouh", "rouc", "reh" 等),函数内部会转换为小写处理。 * - isOutside: 字符串标志(前端用 "Y" 表示外部),当 isOutside == "Y" 或 gtype != "ft" 时使用外部映射分支。 * - gtype: 比赛类别(如 "ft" 表示足球),用于区分 ft 与非-ft 的差异映射。 * * 返回值: * 返回映射后的字段名(通常为小写的 "ratio_xxx"),若映射表中不存在该 rtype,则返回原始 rtype(小写)。 * * 注意: * - 前端在最终使用时通常会把结果再做 .toUpperCase(),C++ 返回小写以便与前端行为一致(调用处按需转换)。 * - 建议将长映射表做成 static const(只初始化一次),避免每次调用都构造映射表。 * - 映射表内容严格来自前端实现,若后端命名变化请同步更新该表以保证解析一致性。 * * 返回示例: * switchConRtype("ouc", "Y", "ft") -> "ratio_ouo" * switchConRtype("ouc", "N", "ft") -> "ratio_o" * switchConRtype("rouh", "N", "ft") -> "ratio_rouu" * switchConRtype("unknown", "N", "ft") -> "unknown" (未匹配时返回原值) */ static QString switchConRtype(QString rtype, const QString &isOutside, const QString >ype) { // 统一使用小写处理,和前端 JS 的 rtype.toLowerCase() 行为一致 rtype = rtype.toLower(); // 规范 gtype:若调用时传空字符串,则视为 "ft"(与前端默认行为保持一致) QString _gtype = gtype.isEmpty() ? "ft" : gtype.toLower(); // 注意:为了代码可读性这里直接构造 QHash。 // 为了性能可以把下面整个表做成 static const QHash 并只初始化一次。 QHash hash; // ---------- 根据 isOutside 或 gtype 选择 ft / 非-ft 的初始映射 ---------- // 前端逻辑:若 isOutside == "Y" 或 gtype != "ft",使用“外部/非 ft”的映射分支 if (isOutside == "Y" || _gtype !="ft") { // 外部/非-ft 分支(部分短码指向 ratio_ouo/ratio_ouu 等) hash.insert("ouc", "ratio_ouo"); hash.insert("ouh", "ratio_ouu"); hash.insert("houc", "ratio_houo"); hash.insert("houh", "ratio_houu"); hash.insert("rh", "ratio_r"); hash.insert("rc", "ratio_r"); hash.insert("prh", "ratio_r"); hash.insert("prc", "ratio_r"); hash.insert("pouc", "ratio_ouo"); hash.insert("pouh", "ratio_ouu"); hash.insert("hrh", "ratio_hr"); hash.insert("hrc", "ratio_hr"); hash.insert("hprh", "ratio_hr"); hash.insert("hprc", "ratio_hr"); hash.insert("hpouc", "ratio_houo"); hash.insert("hpouh", "ratio_houu"); } else { // ft 内部分支(某些短码映射为 ratio_o/ratio_u/hratio 等) hash.insert("ouc", "ratio_o"); hash.insert("ouh", "ratio_u"); hash.insert("houc", "ratio_ho"); hash.insert("houh", "ratio_hu"); hash.insert("rh", "ratio"); hash.insert("rc", "ratio"); hash.insert("prh", "ratio"); hash.insert("prc", "ratio"); hash.insert("pouc", "ratio_o"); hash.insert("pouh", "ratio_u"); hash.insert("hrh", "hratio"); hash.insert("hrc", "hratio"); hash.insert("hprh", "hratio"); hash.insert("hprc", "hratio"); hash.insert("hpouc", "ratio_ho"); hash.insert("hpouh", "ratio_hu"); } // ---------- 通用映射表 ------------ // 以下映射项来自前端 `game_more_page.txt` 中的完整表(已逐项移植) // 如果后端新增/改名,需要在此同步更新。 hash.insert("rouc", "ratio_rouo"); hash.insert("rouh", "ratio_rouu"); hash.insert("hrouc", "ratio_hrouo"); hash.insert("hrouh", "ratio_hrouu"); hash.insert("reh", "ratio_re"); hash.insert("rec", "ratio_re"); hash.insert("hreh", "ratio_hre"); hash.insert("hrec", "ratio_hre"); hash.insert("arh", "ratio_ar"); hash.insert("arc", "ratio_ar"); hash.insert("brh", "ratio_br"); hash.insert("brc", "ratio_br"); hash.insert("crh", "ratio_cr"); hash.insert("crc", "ratio_cr"); hash.insert("drh", "ratio_dr"); hash.insert("drc", "ratio_dr"); hash.insert("erh", "ratio_er"); hash.insert("erc", "ratio_er"); hash.insert("frh", "ratio_fr"); hash.insert("frc", "ratio_fr"); hash.insert("aouo", "ratio_aouo"); hash.insert("aouu", "ratio_aouu"); hash.insert("bouo", "ratio_bouo"); hash.insert("bouu", "ratio_bouu"); hash.insert("couo", "ratio_couo"); hash.insert("couu", "ratio_couu"); hash.insert("douo", "ratio_douo"); hash.insert("douu", "ratio_douu"); hash.insert("eouo", "ratio_eouo"); hash.insert("eouu", "ratio_eouu"); hash.insert("fouo", "ratio_fouo"); hash.insert("fouu", "ratio_fouu"); hash.insert("parh", "ratio_ar"); hash.insert("parc", "ratio_ar"); hash.insert("pbrh", "ratio_br"); hash.insert("pbrc", "ratio_br"); hash.insert("pcrh", "ratio_cr"); hash.insert("pcrc", "ratio_cr"); hash.insert("pdrh", "ratio_dr"); hash.insert("pdrc", "ratio_dr"); hash.insert("perh", "ratio_er"); hash.insert("perc", "ratio_er"); hash.insert("pfrh", "ratio_fr"); hash.insert("pfrc", "ratio_fr"); hash.insert("paouo", "ratio_aouo"); hash.insert("paouu", "ratio_aouu"); hash.insert("pbouo", "ratio_bouo"); hash.insert("pbouu", "ratio_bouu"); hash.insert("pcouo", "ratio_couo"); hash.insert("pcouu", "ratio_couu"); hash.insert("pdouo", "ratio_douo"); hash.insert("pdouu", "ratio_douu"); hash.insert("peouo", "ratio_eouo"); hash.insert("peouu", "ratio_eouu"); hash.insert("pfouo", "ratio_fouo"); hash.insert("pfouu", "ratio_fouu"); hash.insert("rouho", "ratio_rouho"); hash.insert("rouhu", "ratio_rouhu"); hash.insert("rouco", "ratio_rouco"); hash.insert("roucu", "ratio_roucu"); hash.insert("hruho", "ratio_hruho"); hash.insert("hruhu", "ratio_hruhu"); hash.insert("hruco", "ratio_hruco"); hash.insert("hrucu", "ratio_hrucu"); hash.insert("ouho", "ratio_ouho"); hash.insert("ouhu", "ratio_ouhu"); hash.insert("ouco", "ratio_ouco"); hash.insert("oucu", "ratio_oucu"); hash.insert("houho", "ratio_houho"); hash.insert("houhu", "ratio_houhu"); hash.insert("houco", "ratio_houco"); hash.insert("houcu", "ratio_houcu"); hash.insert("w3h", "ratio_w3h"); hash.insert("w3c", "ratio_w3c"); hash.insert("w3n", "ratio_w3n"); hash.insert("areh", "ratio_are"); hash.insert("arec", "ratio_are"); hash.insert("breh", "ratio_bre"); hash.insert("brec", "ratio_bre"); hash.insert("creh", "ratio_cre"); hash.insert("crec", "ratio_cre"); hash.insert("dreh", "ratio_dre"); hash.insert("drec", "ratio_dre"); hash.insert("ereh", "ratio_ere"); hash.insert("erec", "ratio_ere"); hash.insert("freh", "ratio_fre"); hash.insert("frec", "ratio_fre"); hash.insert("arouo", "ratio_arouo"); hash.insert("arouu", "ratio_arouu"); hash.insert("brouo", "ratio_brouo"); hash.insert("brouu", "ratio_brouu"); hash.insert("crouo", "ratio_crouo"); hash.insert("crouu", "ratio_crouu"); hash.insert("drouo", "ratio_drouo"); hash.insert("drouu", "ratio_drouu"); hash.insert("erouo", "ratio_erouo"); hash.insert("erouu", "ratio_erouu"); hash.insert("frouo", "ratio_frouo"); hash.insert("frouu", "ratio_frouu"); hash.insert("pouho", "ratio_ouho"); hash.insert("pouhu", "ratio_ouhu"); hash.insert("pouco", "ratio_ouco"); hash.insert("poucu", "ratio_oucu"); hash.insert("hpouho", "ratio_houho"); hash.insert("hpouhu", "ratio_houhu"); hash.insert("hpouco", "ratio_houco"); hash.insert("hpoucu", "ratio_houcu"); hash.insert("taruo", "ratio_taruo"); hash.insert("taruu", "ratio_taruu"); hash.insert("tbruo", "ratio_tbruo"); hash.insert("tbruu", "ratio_tbruu"); hash.insert("tdruo", "ratio_tdruo"); hash.insert("tdruu", "ratio_tdruu"); hash.insert("teruo", "ratio_teruo"); hash.insert("teruu", "ratio_teruu"); hash.insert("prouc", "ratio_rouo"); hash.insert("prouh", "ratio_rouu"); hash.insert("hprouc", "ratio_hrouo"); hash.insert("hprouh", "ratio_hrouu"); hash.insert("preh", "ratio_re"); hash.insert("prec", "ratio_re"); hash.insert("hpreh", "ratio_hre"); hash.insert("hprec", "ratio_hre"); hash.insert("pareh", "ratio_are"); hash.insert("parec", "ratio_are"); hash.insert("pbreh", "ratio_bre"); hash.insert("pbrec", "ratio_bre"); hash.insert("pcreh", "ratio_cre"); hash.insert("pcrec", "ratio_cre"); hash.insert("pdreh", "ratio_dre"); hash.insert("pdrec", "ratio_dre"); hash.insert("pereh", "ratio_ere"); hash.insert("perec", "ratio_ere"); hash.insert("pfreh", "ratio_fre"); hash.insert("pfrec", "ratio_fre"); hash.insert("parouo", "ratio_arouo"); hash.insert("parouu", "ratio_arouu"); hash.insert("pbrouo", "ratio_brouo"); hash.insert("pbrouu", "ratio_brouu"); hash.insert("pcrouo", "ratio_crouo"); hash.insert("pcrouu", "ratio_crouu"); hash.insert("pdrouo", "ratio_drouo"); hash.insert("pdrouu", "ratio_drouu"); hash.insert("perouo", "ratio_erouo"); hash.insert("perouu", "ratio_erouu"); hash.insert("pfrouo", "ratio_frouo"); hash.insert("pfrouu", "ratio_frouu"); hash.insert("prouho", "ratio_rouho"); hash.insert("prouhu", "ratio_rouhu"); hash.insert("prouco", "ratio_rouco"); hash.insert("proucu", "ratio_roucu"); hash.insert("hpruho", "ratio_hruho"); hash.insert("hpruhu", "ratio_hruhu"); hash.insert("hpruco", "ratio_hruco"); hash.insert("hprucu", "ratio_hrucu"); hash.insert("ptaruo", "ratio_taruo"); hash.insert("ptaruu", "ratio_taruu"); hash.insert("ptbruo", "ratio_tbruo"); hash.insert("ptbruu", "ratio_tbruu"); hash.insert("ptdruo", "ratio_tdruo"); hash.insert("ptdruu", "ratio_tdruu"); hash.insert("pteruo", "ratio_teruo"); hash.insert("pteruu", "ratio_teruu"); // 若 hash 中存在对应的映射,返回映射值;否则返回原始 rtype(小写) return hash.value(rtype, rtype); } static QString rtypeToRATIO(const QString &rtype, const QString >ype) { QString rtypeLower = rtype.toLower(); QString _gtype = gtype.isEmpty() ? "ft" : gtype.toLower(); QMap hash; if (_gtype != "ft") { hash["ouc"] = "ratio_ouo"; hash["ouh"] = "ratio_ouu"; hash["houc"] = "ratio_houo"; hash["houh"] = "ratio_houu"; hash["rh"] = "ratio_r"; hash["rc"] = "ratio_r"; hash["prh"] = "ratio_r"; hash["prc"] = "ratio_r"; hash["pouc"] = "ratio_ouo"; hash["pouh"] = "ratio_ouu"; hash["hrh"] = "ratio_hr"; hash["hrc"] = "ratio_hr"; hash["hprh"] = "ratio_hr"; hash["hprc"] = "ratio_hr"; hash["hpouc"] = "ratio_houo"; hash["hpouh"] = "ratio_houu"; } else { hash["ouc"] = "ratio_o"; hash["ouh"] = "ratio_u"; hash["houc"] = "ratio_ho"; hash["houh"] = "ratio_hu"; hash["rh"] = "ratio"; hash["rc"] = "ratio"; hash["prh"] = "ratio"; hash["prc"] = "ratio"; hash["pouc"] = "ratio_o"; hash["pouh"] = "ratio_u"; hash["hrh"] = "hratio"; hash["hrc"] = "hratio"; hash["hprh"] = "hratio"; hash["hprc"] = "hratio"; hash["hpouc"] = "ratio_ho"; hash["hpouh"] = "ratio_hu"; } hash["rouc"] = "ratio_rouo"; hash["rouh"] = "ratio_rouu"; hash["hrouc"] = "ratio_hrouo"; hash["hrouh"] = "ratio_hrouu"; hash["reh"] = "ratio_re"; hash["rec"] = "ratio_re"; hash["hreh"] = "ratio_hre"; hash["hrec"] = "ratio_hre"; hash["arh"] = "ratio_ar"; hash["arc"] = "ratio_ar"; hash["brh"] = "ratio_br"; hash["brc"] = "ratio_br"; hash["crh"] = "ratio_cr"; hash["crc"] = "ratio_cr"; hash["drh"] = "ratio_dr"; hash["drc"] = "ratio_dr"; hash["erh"] = "ratio_er"; hash["erc"] = "ratio_er"; hash["frh"] = "ratio_fr"; hash["frc"] = "ratio_fr"; hash["aouo"] = "ratio_aouo"; hash["aouu"] = "ratio_aouu"; hash["bouo"] = "ratio_bouo"; hash["bouu"] = "ratio_bouu"; hash["couo"] = "ratio_couo"; hash["couu"] = "ratio_couu"; hash["douo"] = "ratio_douo"; hash["douu"] = "ratio_douu"; hash["eouo"] = "ratio_eouo"; hash["eouu"] = "ratio_eouu"; hash["fouo"] = "ratio_fouo"; hash["fouu"] = "ratio_fouu"; hash["parh"] = "ratio_ar"; hash["parc"] = "ratio_ar"; hash["pbrh"] = "ratio_br"; hash["pbrc"] = "ratio_br"; hash["pcrh"] = "ratio_cr"; hash["pcrc"] = "ratio_cr"; hash["pdrh"] = "ratio_dr"; hash["pdrc"] = "ratio_dr"; hash["perh"] = "ratio_er"; hash["perc"] = "ratio_er"; hash["pfrh"] = "ratio_fr"; hash["pfrc"] = "ratio_fr"; hash["paouo"] = "ratio_aouo"; hash["paouu"] = "ratio_aouu"; hash["pbouo"] = "ratio_bouo"; hash["pbouu"] = "ratio_bouu"; hash["pcouo"] = "ratio_couo"; hash["pcouu"] = "ratio_couu"; hash["pdouo"] = "ratio_douo"; hash["pdouu"] = "ratio_douu"; hash["peouo"] = "ratio_eouo"; hash["peouu"] = "ratio_eouu"; hash["pfouo"] = "ratio_fouo"; hash["pfouu"] = "ratio_fouu"; hash["rouho"] = "ratio_rouho"; hash["rouhu"] = "ratio_rouhu"; hash["rouco"] = "ratio_rouco"; hash["roucu"] = "ratio_roucu"; hash["hruho"] = "ratio_hruho"; hash["hruhu"] = "ratio_hruhu"; hash["hruco"] = "ratio_hruco"; hash["hrucu"] = "ratio_hrucu"; hash["ouho"] = "ratio_ouho"; hash["ouhu"] = "ratio_ouhu"; hash["ouco"] = "ratio_ouco"; hash["oucu"] = "ratio_oucu"; hash["houho"] = "ratio_houho"; hash["houhu"] = "ratio_houhu"; hash["houco"] = "ratio_houco"; hash["houcu"] = "ratio_houcu"; hash["w3h"] = "ratio_w3h"; hash["w3c"] = "ratio_w3c"; hash["w3n"] = "ratio_w3n"; hash["areh"] = "ratio_are"; hash["arec"] = "ratio_are"; hash["breh"] = "ratio_bre"; hash["brec"] = "ratio_bre"; hash["creh"] = "ratio_cre"; hash["crec"] = "ratio_cre"; hash["dreh"] = "ratio_dre"; hash["drec"] = "ratio_dre"; hash["ereh"] = "ratio_ere"; hash["erec"] = "ratio_ere"; hash["freh"] = "ratio_fre"; hash["frec"] = "ratio_fre"; hash["arouo"] = "ratio_arouo"; hash["arouu"] = "ratio_arouu"; hash["brouo"] = "ratio_brouo"; hash["brouu"] = "ratio_brouu"; hash["crouo"] = "ratio_crouo"; hash["crouu"] = "ratio_crouu"; hash["drouo"] = "ratio_drouo"; hash["drouu"] = "ratio_drouu"; hash["erouo"] = "ratio_erouo"; hash["erouu"] = "ratio_erouu"; hash["frouo"] = "ratio_frouo"; hash["frouu"] = "ratio_frouu"; hash["pouho"] = "ratio_ouho"; hash["pouhu"] = "ratio_ouhu"; hash["pouco"] = "ratio_ouco"; hash["poucu"] = "ratio_oucu"; hash["hpouho"] = "ratio_houho"; hash["hpouhu"] = "ratio_houhu"; hash["hpouco"] = "ratio_houco"; hash["hpoucu"] = "ratio_houcu"; hash["taruo"] = "ratio_taruo"; hash["taruu"] = "ratio_taruu"; hash["tbruo"] = "ratio_tbruo"; hash["tbruu"] = "ratio_tbruu"; hash["tdruo"] = "ratio_tdruo"; hash["tdruu"] = "ratio_tdruu"; hash["teruo"] = "ratio_teruo"; hash["teruu"] = "ratio_teruu"; hash["prouc"] = "ratio_rouo"; hash["prouh"] = "ratio_rouu"; hash["hprouc"] = "ratio_hrouo"; hash["hprouh"] = "ratio_hrouu"; hash["preh"] = "ratio_re"; hash["prec"] = "ratio_re"; hash["hpreh"] = "ratio_hre"; hash["hprec"] = "ratio_hre"; hash["pareh"] = "ratio_are"; hash["parec"] = "ratio_are"; hash["pbreh"] = "ratio_bre"; hash["pbrec"] = "ratio_bre"; hash["pcreh"] = "ratio_cre"; hash["pcrec"] = "ratio_cre"; hash["pdreh"] = "ratio_dre"; hash["pdrec"] = "ratio_dre"; hash["pereh"] = "ratio_ere"; hash["perec"] = "ratio_ere"; hash["pfreh"] = "ratio_fre"; hash["pfrec"] = "ratio_fre"; hash["parouo"] = "ratio_arouo"; hash["parouu"] = "ratio_arouu"; hash["pbrouo"] = "ratio_brouo"; hash["pbrouu"] = "ratio_brouu"; hash["pcrouo"] = "ratio_crouo"; hash["pcrouu"] = "ratio_crouu"; hash["pdrouo"] = "ratio_drouo"; hash["pdrouu"] = "ratio_drouu"; hash["perouo"] = "ratio_erouo"; hash["perouu"] = "ratio_erouu"; hash["pfrouo"] = "ratio_frouo"; hash["pfrouu"] = "ratio_frouu"; hash["prouho"] = "ratio_rouho"; hash["prouhu"] = "ratio_rouhu"; hash["prouco"] = "ratio_rouco"; hash["proucu"] = "ratio_roucu"; hash["hpruho"] = "ratio_hruho"; hash["hpruhu"] = "ratio_hruhu"; hash["hpruco"] = "ratio_hruco"; hash["hprucu"] = "ratio_hrucu"; hash["ptaruo"] = "ratio_taruo"; hash["ptaruu"] = "ratio_taruu"; hash["ptbruo"] = "ratio_tbruo"; hash["ptbruu"] = "ratio_tbruu"; hash["ptdruo"] = "ratio_tdruo"; hash["ptdruu"] = "ratio_tdruu"; if (hash.contains(rtypeLower)) { return hash[rtypeLower].toUpper(); } return QString(); } };