Files

1703 lines
49 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "Utils.h"
#include <QDebug>
Utils::Utils()
{
}
Utils::~Utils()
{
}
Utils& Utils::instance()
{
static Utils m_instance;
return m_instance;
}
QString Utils::findSuffix(const QString& str1, const QString& str2) {
if (!str1.startsWith(str2)) {
// 如果str2不是str1的前缀,可以返回一个空字符串或抛出异常
// 这里选择返回一个空字符串作为示例
return QString();
}
// 找到str2在str1中的结束位置(即最后一个字符的索引加1)
int endIndex = str2.length();
// 使用mid()方法从str2之后开始提取子字符串
// 注意:mid()方法的第一个参数是起始索引(包含),第二个参数是长度(可选)
// 这里我们省略第二个参数,表示从endIndex开始提取到str1的末尾
return str1.mid(endIndex);
}
QString Utils::convertToBase(const QString& input) {
// 假设输入字符串的格式是 "前缀_数字"
// 使用'_'作为分隔符来分割字符串
QStringList parts = input.split('_');
// 检查是否成功分割出至少两部分
if (parts.size() > 0) {
// 返回第一部分,即前缀
return parts.first();
}
else {
// 如果没有'_'或者输入为空,则直接返回原字符串
return input;
}
}
QMap<QString, QString> Utils::toClient(QMap<QString, QString> order)
{
QMap<QString, QString> newOrder = order;
// 让球
if (newOrder["rtype"] == "REH" || newOrder["rtype"] == "RH")
{
newOrder["wtype"] = "R";
newOrder["rtype"] = "RH";
newOrder["chose_team"] = "H";
}
// 受让
if (newOrder["rtype"] == "REC" || newOrder["rtype"] == "RC")
{
newOrder["wtype"] = "R";
newOrder["rtype"] = "RC";
newOrder["chose_team"] = "C";
}
// 大
if (newOrder["rtype"] == "ROUC" || newOrder["rtype"] == "OUC")
{
newOrder["wtype"] = "OU";
newOrder["rtype"] = "OUC";
newOrder["chose_team"] = "C";
}
// 小
if (newOrder["rtype"] == "ROUH" || newOrder["rtype"] == "OUH")
{
newOrder["wtype"] = "OU";
newOrder["rtype"] = "OUH";
newOrder["chose_team"] = "H";
}
// 独赢主
if (newOrder["rtype"] == "RMH" || newOrder["rtype"] == "MH")
{
newOrder["wtype"] = "M";
newOrder["rtype"] = "MH";
newOrder["chose_team"] = "H";
}
// 独赢客
if (newOrder["rtype"] == "RMC" || newOrder["rtype"] == "MC")
{
newOrder["wtype"] = "M";
newOrder["rtype"] = "MC";
newOrder["chose_team"] = "C";
}
// 独赢和
if (newOrder["rtype"] == "RMN" || newOrder["rtype"] == "MN")
{
newOrder["wtype"] = "M";
newOrder["rtype"] = "MN";
newOrder["chose_team"] = "N";
}
// 单
if (newOrder["rtype"] == "REOO" || newOrder["rtype"] == "EOO")
{
newOrder["wtype"] = "T";
newOrder["rtype"] = "ODD";
newOrder["chose_team"] = "ODD";
}
// 双
if (newOrder["rtype"] == "REOE" || newOrder["rtype"] == "EOE")
{
newOrder["wtype"] = "T";
newOrder["rtype"] = "EVEN";
newOrder["chose_team"] = "EVEN";
}
// 主队大
if (newOrder["rtype"] == "ROUHO" || newOrder["rtype"] == "OUHO")
{
newOrder["rtype"] = "OUHO";
newOrder["chose_team"] = "O";
}
// 主队小
if (newOrder["rtype"] == "ROUHU" || newOrder["rtype"] == "OUHU")
{
newOrder["rtype"] = "OUHU";
newOrder["chose_team"] = "U";
}
// 客队大
if (newOrder["rtype"] == "ROUCO" || newOrder["rtype"] == "OUCO")
{
newOrder["rtype"] = "OUCO";
newOrder["chose_team"] = "O";
}
// 客队小
if (newOrder["rtype"] == "ROUCU" || newOrder["rtype"] == "OUCU")
{
newOrder["rtype"] = "OUCU";
newOrder["chose_team"] = "U";
}
return newOrder;
}
/// <summary>
/// 转换为今日
/// </summary>
/// <param name="order">早盘订单信息</param>
/// <returns>今日订单信息</returns>
QMap<QString, QString> Utils::toToday(QMap<QString, QString> order)
{
QMap<QString, QString> newOrder = order;
// session转换为早盘
newOrder["session"] = "FT";
// 根据原始订单信息设置正确的项目名称
QString gtype = order.value("gtype", "FT");
QString name = order.value("name", "");
// 判断是全场还是上半场
if (name.contains("上半场")) {
newOrder["project"] = (gtype == "FT" ? "足球今日上半场" : "篮球今日上半场");
}
else {
newOrder["project"] = (gtype == "FT" ? "足球今日全场" : "篮球今日全场");
}
// rtype早盘->今日无需转换?
return newOrder;
}
QMap<QString, QString> Utils::toLive(QMap<QString, QString> order)
{
QMap<QString, QString> newOrder = order;
newOrder["session"] = "RB";
// 根据原始订单信息设置正确的项目名称
QString gtype = order.value("gtype", "FT");
QString name = order.value("name", "");
// 判断是全场还是上半场
if (name.contains("上半场")) {
newOrder["project"] = (gtype == "FT" ? "足球滚球上半场" : "篮球滚球上半场");
}
else {
newOrder["project"] = (gtype == "FT" ? "足球滚球全场" : "篮球滚球全场");
}
// 今日转滚球的投注类型转换(需要将今日格式转换为滚球格式)
QString rtype = order.value("rtype", "");
if (rtype == "RH") {
newOrder["rtype"] = "REH";
}
else if (rtype == "RC") {
newOrder["rtype"] = "REC";
}
else if (rtype == "OUC") {
newOrder["rtype"] = "ROUC";
}
else if (rtype == "OUH") {
newOrder["rtype"] = "ROUH";
}
else if (rtype == "MH") {
newOrder["rtype"] = "RMH";
}
else if (rtype == "MC") {
newOrder["rtype"] = "RMC";
}
else if (rtype == "MN") {
newOrder["rtype"] = "RMN";
}
else if (rtype == "EOO") {
newOrder["rtype"] = "REOO";
}
else if (rtype == "EOE") {
newOrder["rtype"] = "REOE";
}
else if (rtype == "OUHO") {
newOrder["rtype"] = "ROUHO";
}
else if (rtype == "OUHU") {
newOrder["rtype"] = "ROUHU";
}
else if (rtype == "OUCO") {
newOrder["rtype"] = "ROUCO";
}
else if (rtype == "OUCU") {
newOrder["rtype"] = "ROUCU";
}
// 上半场转换
else if (rtype == "HRH") {
newOrder["rtype"] = "HREH";
}
else if (rtype == "HRC") {
newOrder["rtype"] = "HREC";
}
else if (rtype == "HOUC") {
newOrder["rtype"] = "HROUC";
}
else if (rtype == "HOUH") {
newOrder["rtype"] = "HROUH";
}
else if (rtype == "HMH") {
newOrder["rtype"] = "HRMH";
}
else if (rtype == "HMC") {
newOrder["rtype"] = "HRMC";
}
else if (rtype == "HMN") {
newOrder["rtype"] = "HRMN";
}
else if (rtype == "HEOO") {
newOrder["rtype"] = "HREOO";
}
else if (rtype == "HEOE") {
newOrder["rtype"] = "HREOE";
}
else if (rtype == "HOUHO") {
newOrder["rtype"] = "HROUHO";
}
else if (rtype == "HOUHU") {
newOrder["rtype"] = "HROUHU";
}
else if (rtype == "HOUCO") {
newOrder["rtype"] = "HROUCO";
}
else if (rtype == "HOUCU") {
newOrder["rtype"] = "HROUCU";
}
return newOrder;
}
QMap<QString, QString> Utils::toContra(QMap<QString, QString> order)
{
QMap<QString, QString> newOrder = order;
QString rtype = order["rtype"];
if (order["ORDER_TYPE"] == order["TEAM_H"])
{
newOrder["ORDER_TYPE"] = order["TEAM_C"];
}
else if (order["ORDER_TYPE"] == order["TEAM_C"])
{
newOrder["ORDER_TYPE"] = order["TEAM_H"];
}
else if (order["ORDER_TYPE"] == "大")
{
newOrder["ORDER_TYPE"] = "小";
}
else if (order["ORDER_TYPE"] == "小")
{
newOrder["ORDER_TYPE"] = "大";
}
else if (order["ORDER_TYPE"] == "独赢主")
{
newOrder["ORDER_TYPE"] = "独赢客";
}
else if (order["ORDER_TYPE"] == "独赢客")
{
newOrder["ORDER_TYPE"] = "独赢主";
}
else if (order["ORDER_TYPE"] == "单")
{
newOrder["ORDER_TYPE"] = "双";
}
else if (order["ORDER_TYPE"] == "双")
{
newOrder["ORDER_TYPE"] = "单";
}
// 和局不做处理
// 先按 rtype 翻转,同时写入中文 type
// 滚球 全场 让球
if (rtype == "REH") {newOrder["rtype"] = "REC"; }
else if (rtype == "REC") { newOrder["rtype"] = "REH"; }
// 滚球 全场 大小
else if (rtype == "ROUC") { newOrder["rtype"] = "ROUH"; }
else if (rtype == "ROUH") { newOrder["rtype"] = "ROUC"; }
// 滚球 全场 独赢
else if (rtype == "RMH") {newOrder["rtype"] = "RMC"; }
else if (rtype == "RMC") { newOrder["rtype"] = "RMH"; }
else if (rtype == "RMN") { newOrder["rtype"] = "RMN"; /* 和局不切队 */ }
// 滚球 全场 单双
else if (rtype == "REOO") { newOrder["rtype"] = "REOE"; }
else if (rtype == "REOE") { newOrder["rtype"] = "REOO"; }
// 滚球 主/客 队大小
else if (rtype == "ROUHO") { newOrder["rtype"] = "ROUHU"; }
else if (rtype == "ROUHU") { newOrder["rtype"] = "ROUHO"; }
else if (rtype == "ROUCO") { newOrder["rtype"] = "ROUCU"; }
else if (rtype == "ROUCU") { newOrder["rtype"] = "ROUCO"; }
// 滚球 上半场 让球/大小/独赢/单双/球队大小
else if (rtype == "HREH") { newOrder["rtype"] = "HREC";}
else if (rtype == "HREC") { newOrder["rtype"] = "HREH"; }
else if (rtype == "HROUC") { newOrder["rtype"] = "HROUH"; }
else if (rtype == "HROUH") { newOrder["rtype"] = "HROUC"; }
else if (rtype == "HRMH") { newOrder["rtype"] = "HRMC"; }
else if (rtype == "HRMC") { newOrder["rtype"] = "HRMH"; }
else if (rtype == "HRMN") { newOrder["rtype"] = "HRMN"; /* 和局不切队 */ }
else if (rtype == "HREOO") { newOrder["rtype"] = "HREOE"; }
else if (rtype == "HREOE") { newOrder["rtype"] = "HREOO"; }
else if (rtype == "HROUHO") { newOrder["rtype"] = "HROUHU"; }
else if (rtype == "HROUHU") { newOrder["rtype"] = "HROUHO"; }
else if (rtype == "HROUCO") { newOrder["rtype"] = "HROUCU"; }
else if (rtype == "HROUCU") { newOrder["rtype"] = "HROUCO"; }
// 今日/早盘 全场 让球/大小/独赢/单双/球队大小
else if (rtype == "RH") { newOrder["rtype"] = "RC"; }
else if (rtype == "RC") { newOrder["rtype"] = "RH"; }
else if (rtype == "OUC") { newOrder["rtype"] = "OUH"; }
else if (rtype == "OUH") { newOrder["rtype"] = "OUC"; }
else if (rtype == "MH") { newOrder["rtype"] = "MC"; }
else if (rtype == "MC") { newOrder["rtype"] = "MH"; }
else if (rtype == "MN") { newOrder["rtype"] = "MN"; /* 和局不切队 */ }
else if (rtype == "EOO") { newOrder["rtype"] = "EOE"; }
else if (rtype == "EOE") { newOrder["rtype"] = "EOO"; }
else if (rtype == "OUHO") { newOrder["rtype"] = "OUHU"; }
else if (rtype == "OUHU") { newOrder["rtype"] = "OUHO"; }
else if (rtype == "OUCO") { newOrder["rtype"] = "OUCU"; }
else if (rtype == "OUCU") {newOrder["rtype"] = "OUCO"; }
// 今日/早盘 上半场
else if (rtype == "HRH") { newOrder["rtype"] = "HRC"; }
else if (rtype == "HRC") { newOrder["rtype"] = "HRH"; }
else if (rtype == "HOUC") { newOrder["rtype"] = "HOUH"; }
else if (rtype == "HOUH") { newOrder["rtype"] = "HOUC"; }
else if (rtype == "HMH") { newOrder["rtype"] = "HMC"; }
else if (rtype == "HMC") { newOrder["rtype"] = "HMH";}
else if (rtype == "HMN") { newOrder["rtype"] = "HMN"; /* 和局不切队 */ }
else if (rtype == "HEOO") { newOrder["rtype"] = "HEOE"; }
else if (rtype == "HEOE") { newOrder["rtype"] = "HEOO"; }
else if (rtype == "HOUHO") { newOrder["rtype"] = "HOUHU"; }
else if (rtype == "HOUHU") { newOrder["rtype"] = "HOUHO"; }
else if (rtype == "HOUCO") { newOrder["rtype"] = "HOUCU"; }
else if (rtype == "HOUCU") { newOrder["rtype"] = "HOUCO"; }
return newOrder;
}
QMap<QString, QString> Utils::type(QString projcet, QString ORDER_TYPE)
{
QMap<QString, QString> map;
map["projcet"] = projcet;
map["ORDER_TYPE"] = ORDER_TYPE;
if (projcet == "足球滚球全场")
{
map["GT"] = "足球";
map["SESSION"] = "滚球";
map["STAGE"] = "全场";
if (ORDER_TYPE == "让球")
{
map["wtype"] = "RE";
map["rtype"] = "REH";
}
else if (ORDER_TYPE == "受让")
{
map["wtype"] = "RE";
map["rtype"] = "REC";
}
else if (ORDER_TYPE == "大")
{
map["wtype"] = "ROU";
map["rtype"] = "ROUC";
}
else if (ORDER_TYPE == "小")
{
map["wtype"] = "ROU";
map["rtype"] = "ROUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["wtype"] = "RM";
map["rtype"] = "RMH";
}
else if (ORDER_TYPE == "独赢客")
{
map["wtype"] = "RM";
map["rtype"] = "RMC";
}
else if (ORDER_TYPE == "独赢和")
{
map["wtype"] = "RM";
map["rtype"] = "RMN";
}
else if (ORDER_TYPE == "单")
{
map["wtype"] = "REO";
map["rtype"] = "REOO";
}
else if (ORDER_TYPE == "双")
{
map["wtype"] = "REO";
map["rtype"] = "REOE";
}
else if (ORDER_TYPE == "主队大")
{
map["wtype"] = "ROUH";
map["rtype"] = "ROUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["wtype"] = "ROUH";
map["rtype"] = "ROUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["wtype"] = "ROUC";
map["rtype"] = "ROUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["wtype"] = "ROUC";
map["rtype"] = "ROUCU";
}
}
else if (projcet == "足球滚球上半场")
{
map["GT"] = "足球";
map["SESSION"] = "滚球";
map["STAGE"] = "上半场";
if (ORDER_TYPE == "让球")
{
map["wtype"] = "HRE";
map["rtype"] = "HREH";
}
else if (ORDER_TYPE == "受让")
{
map["wtype"] = "HRE";
map["rtype"] = "HREC";
}
else if (ORDER_TYPE == "大")
{
map["wtype"] = "HROU";
map["rtype"] = "HROUC";
}
else if (ORDER_TYPE == "小")
{
map["wtype"] = "HROU";
map["rtype"] = "HROUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["wtype"] = "HRM";
map["rtype"] = "HRMH";
}
else if (ORDER_TYPE == "独赢客")
{
map["wtype"] = "HRM";
map["rtype"] = "HRMC";
}
else if (ORDER_TYPE == "独赢和")
{
map["wtype"] = "HRM";
map["rtype"] = "HRMN";
}
else if (ORDER_TYPE == "单")
{
map["wtype"] = "HREO";
map["rtype"] = "HREOO";
}
else if (ORDER_TYPE == "双")
{
map["wtype"] = "HREO";
map["rtype"] = "HREOE";
}
else if (ORDER_TYPE == "主队大")
{
map["wtype"] = "HROUH";
map["rtype"] = "HROUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["wtype"] = "HROUH";
map["rtype"] = "HROUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["wtype"] = "HROUC";
map["rtype"] = "HROUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["wtype"] = "HROUC";
map["rtype"] = "HROUCU";
}
}
else if (projcet == "足球今日全场")
{
map["GT"] = "足球";
map["SESSION"] = "今日";
map["STAGE"] = "全场";
if (ORDER_TYPE == "让球")
{
map["wtype"] = "R";
map["rtype"] = "RH";
}
else if (ORDER_TYPE == "受让")
{
map["wtype"] = "R";
map["rtype"] = "RC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "OUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "OUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "MH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "MC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "MN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "EOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "EOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "OUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "OUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "OUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "OUCU";
}
}
else if (projcet == "足球今日上半场")
{
map["GT"] = "足球";
map["SESSION"] = "今日";
map["STAGE"] = "上半场";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "HRH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "HRC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "HOUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "HOUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "HMH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "HMC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "HMN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "HEOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "HEOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "HOUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "HOUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "HOUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "HOUCU";
}
}
else if (projcet == "足球早盘全场")
{
map["GT"] = "足球";
map["SESSION"] = "早盘";
map["STAGE"] = "全场";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "RH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "RC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "OUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "OUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "MH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "MC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "MN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "EOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "EOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "OUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "OUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "OUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "OUCU";
}
}
else if (projcet == "足球早盘上半场")
{
map["GT"] = "足球";
map["SESSION"] = "早盘";
map["STAGE"] = "上半场";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "HRH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "HRC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "HOUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "HOUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "HMH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "HMC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "HMN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "HEOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "HEOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "HOUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "HOUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "HOUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "HOUCU";
}
}
else if (projcet == "篮球滚球全部")
{
map["GT"] = "篮球";
map["SESSION"] = "滚球";
map["STAGE"] = "全部";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "REH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "REC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "ROUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "ROUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "RMH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "RMC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "RMN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "REOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "REOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "ROUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "ROUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "ROUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "ROUCU";
}
}
else if (projcet == "篮球今日全部")
{
map["GT"] = "篮球";
map["SESSION"] = "今日";
map["STAGE"] = "全部";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "RH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "RC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "OUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "OUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "MH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "MC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "MN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "EOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "EOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "OUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "OUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "OUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "OUCU";
}
}
else if (projcet == "篮球早盘全部")
{
map["GT"] = "篮球";
map["SESSION"] = "早盘";
map["STAGE"] = "全部";
if (ORDER_TYPE == "让球")
{
map["rtype"] = "RH";
}
else if (ORDER_TYPE == "受让")
{
map["rtype"] = "RC";
}
else if (ORDER_TYPE == "大")
{
map["rtype"] = "OUC";
}
else if (ORDER_TYPE == "小")
{
map["rtype"] = "OUH";
}
else if (ORDER_TYPE == "独赢主")
{
map["rtype"] = "MH";
}
else if (ORDER_TYPE == "独赢客")
{
map["rtype"] = "MC";
}
else if (ORDER_TYPE == "独赢和")
{
map["rtype"] = "MN";
}
else if (ORDER_TYPE == "单")
{
map["rtype"] = "EOO";
}
else if (ORDER_TYPE == "双")
{
map["rtype"] = "EOE";
}
else if (ORDER_TYPE == "主队大")
{
map["rtype"] = "OUHO";
}
else if (ORDER_TYPE == "主队小")
{
map["rtype"] = "OUHU";
}
else if (ORDER_TYPE == "客队大")
{
map["rtype"] = "OUCO";
}
else if (ORDER_TYPE == "客队小")
{
map["rtype"] = "OUCU";
}
}
return map;
}
QString Utils::get_wagers_wtype_name(QString wtype)
{
// 滚球 RE 让球 ROU大小 RM独赢 HRE 让球上半 HROU 大小上半 HRM 独赢上半 RG下个进球 RTS双方球队进球
// 滚球全场 REO单双
if (wtype == "R" || wtype == "RE" || wtype == "HR" || wtype == "HRE")
{
return "让球";
}
if (wtype == "OU" || wtype == "ROU" || wtype == "HOU" || wtype == "HROU")
{
return "大小";
}
if (wtype == "M" || wtype == "RM" || wtype == "HM" || wtype == "HRM")
{
return "独赢";
}
if (wtype == "G" || wtype == "RG" || wtype == "HG" || wtype == "HRG")
{
return "下个进球";
}
if (wtype == "TS" || wtype == "RTS" || wtype == "HTS" || wtype == "HRTS")
{
return "双方球队进球";
}
if (wtype == "EO" || wtype == "REO" || wtype == "HEO" || wtype == "HREO") // RT 滚球单双 EO 早盘单双
{
return "单双"; // ODD / EVEN ?
}
if (wtype == "OUH" || wtype == "ROUH" || wtype == "HOUH" || wtype == "HROUH")
{
return "队伍1进球";
}
if (wtype == "OUC" || wtype == "ROUC" || wtype == "HOUC" || wtype == "HROUC")
{
return "队伍2进球";
}
if (wtype == "SH" || wtype == "RSH" || wtype == "HSH" || wtype == "HRSH")
{
return "下个点球";
}
return "";
// R 让球
// OU 大小
// M 独赢
// HR 让球上半场
// HOU 大小上半场
// HM 独赢上半场
// TS 双方进球 TSY 是/ TSN 否
// EO 单双
}
/// <summary>
/// 通过错误代码获取错误信息
/// </summary>
/// <param name="errorCode">错误代码</param>
/// <returns>错误信息</returns>
QString Utils::error(QString errorCode)
{
static QMap<QString, QString> errorMap;
if (!errorMap.isEmpty())
{
if (errorMap[errorCode].isEmpty() || errorMap[errorCode]=="")
{
return "未知错误代码";
}
return errorMap[errorCode];
}
errorMap["0X001"] = "由于网站流量较高,请重新再试。谢谢";
errorMap["0X002"] = "由于网站流量较高,请重新再试。谢谢";
errorMap["0X003"] = "系统正在忙碌中,请稍后再试。";
errorMap["0X004"] = "系统正在忙碌中,请稍后再试。";
errorMap["0X005"] = "系统正在忙碌中,请稍后再试。";
errorMap["0X006"] = "系统最佳化中,请稍后。";
errorMap["0X007"] = "系统正在忙碌中,请稍后再试。";
errorMap["0X008"] = "系统正在忙碌中,请稍后再试。";
errorMap["1X000"] = "此选项不再开放投注。请从交易单中移除。";
errorMap["1X001"] = "此选项目前不开放投注。";
errorMap["1X002"] = "已超过停止交易时间,无法进行交易。";
errorMap["1X003"] = "本场次已转至走地盘口,请至走地交易。";
errorMap["1X004"] = "最小投注金额为";
errorMap["1X005"] = "让球数,赔率或比分已更新。";
errorMap["1X006"] = "让球数,赔率或比分已更新。";
errorMap["1X007"] = "输入比数后 1 分钟内,无法进行交易!!";
errorMap["1X008"] = "交易金额不可大于股东单场总信用额度。请联络您的直属上线以解决这个问题。";
errorMap["1X009"] = "暂时停止交易";
errorMap["1X010"] = "暂时停止交易";
errorMap["1X011"] = "此选项不再开放投注。请从交易单中移除。";
errorMap["1X012"] = "您的总投注金额已超过您的余额,请重新编辑投注金额。";
errorMap["1X013"] = "赔率错误,请重新交易。";
errorMap["1X014"] = "登入失败,请重新尝试。";
errorMap["1X015"] = "让球数,赔率或比分已更新。";
errorMap["1X016"] = "让球数,赔率或比分已更新。";
errorMap["1X017"] = "已超过某场次之过关注单限额";
errorMap["1X018"] = "最高投注额设在 ";
errorMap["1X019"] = "同组合可赢金额不得超过人民币 ";
errorMap["1X020"] = "单注最高可赢金额: 人民币 ";
errorMap["1X021"] = "让过赛事重覆";
errorMap["1X022"] = "最小投注金额为";
errorMap["1X023"] = "本场有下注金额最高是 ";
errorMap["1X024"] = "下注失败,请重新交易。";
errorMap["1X025"] = "球头错误。";
errorMap["1X026"] = "所选赛程跨天。";
errorMap["1X027"] = "过关串数错误";
errorMap["1X029"] = "您没有足够的昨日余额进行昨日赛事的投注";
errorMap["1X030"] = "本场有下注金额最高是 ";
errorMap["1X031"] = "最高投注额设在 ";
errorMap["1X032"] = "综合过关选项不足";
errorMap["1X034"] = "被标注的选项无法串综合过关。";
errorMap["1X035"] = errorMap["1X016"];
errorMap["1X036"] = "本场有下注金额最高是 ";
errorMap["1X037"] = "额度最佳化中,请稍后再试。";
errorMap["1X038"] = errorMap["0X008"];
errorMap["score_changed"] = "让球数,赔率或比分已更新。";
errorMap["order_failed"] = "投注失败";
errorMap["connectFail"] = "系统目前无法回应,请稍后再试。";
errorMap["1more_failed"] = "至少一张注单投注失败。";
errorMap["1more_place_failed"] = "至少一张注单无法投注。";
errorMap["1more_pending"] = "至少一张注单目前正在处理中。";
errorMap["1more_rejected"] = "至少一张注单被拒收。";
errorMap["bet_success"] = "您已成功投注。";
errorMap["bet_pending"] = "您的注单正在处理中,请稍候。";
errorMap["bet_rejected"] = "您的注单已被拒收。";
errorMap["1more_rejected_toast"] = "您有至少一张注单已被拒绝。请到“交易状况”查看详情";
errorMap["bet_try_again"] = "由于网站流量较高,请重新再试。谢谢";
errorMap["max"] = "为上限";
errorMap["error_mem_max"] = "本场累积下注共:";
errorMap["error_mem_max1"] = ",总下注金额已超过单场限额。";
errorMap["error7D"] = "过关选项的日期间距不可超过7天。";
errorMap["errorLogin"] = "现在我们的系统面临技术问题。请稍后再尝试登入。对于这样的不便我们深感抱歉,我们也正在全力的解决该问题。谢谢您的耐心等待。";
errorMap["betError000"] = "交易失败,请重新交易。";
errorMap["betError9487"] = "交易失败,请重新交易.";
errorMap["betError878787"] = "网路不稳,请至交易状况确认注单是否成功。";
errorMap["totalBet_close"] = "目前无法同时下注单注和过关的模式。";
errorMap["betError016"] = "交易单处理中,请稍后....";
errorMap["betError021"] = "不接受";
errorMap["betError022"] = "串过关投注。";
errorMap["str_over_sc"] = "交易金额已超过单场最高限额。";
errorMap["user_stop"] = "您的帐户已被停用,请联系您的上线开启你的帐号。";
errorMap["user_forbid"] = "您的帐号已被禁止登入,请联系您的上线开启你的帐号!";
errorMap["4pwd_input"] = "输入密码";
errorMap["4pwd_confirmed"] = "确认密码";
errorMap["4pwd_title"] = "移除四位数密码";
errorMap["4pwd_btn"] = "确认";
errorMap["4pwd_removed"] = "您已经成功移除四位数密码登入";
errorMap["4pwd_removedAlready"] = "您已经移除四位数密码登入";
errorMap["4pwd_login_fail"] = "密码错误,请重新输入";
errorMap["4pwd_fail_twice"] = "您已经连续两次输入错误密码,请使用您的帐号密码登入。";
errorMap["4pwd_doubleCheck_fail"] = "两次输入的四位数密码必须一致";
errorMap["4pwd_block"] = "密码错误次数过多,请联系您的上线寻求协助。";
errorMap["4pwd_db_fail"] = "基于安全考量,此设备/浏览器的四位数密码登入已被禁用。请使用您的帐号密码登入。";
errorMap["4pwd_chg_pwd"] = "基于安全考量,在更改帐号密码后,四位数密码登入已被删除。请使用您的帐号密码登入。";
errorMap["4pwd_fistcome"] = "设定您的简易密码以便快速登入。";
errorMap["4pwd_onepassd"] = "重新输入你的简易密码来登入或是";
errorMap["indexsubmit"] = "提交";
errorMap["changepwd_oldpassword"] = "请输入现用密码。";
errorMap["changepwd_password"] = "请输入新密码。";
errorMap["changepwd_REpassword"] = "请输入确认密码。";
errorMap["changepwd_oldpassworderror"] = "您输入的密码不正确,请重试。";
errorMap["changepwd_passworderror"] = "您的新密码必须和现用密码不一样。";
errorMap["changepwd_REpassworderror"] = "密码确认错误,请重新输入。";
errorMap["changepwd_error"] = "1.您的新密码必须由 6-12个字母和数字 (A-Z 或 0-9)组成。\n2.您的新密码不能和现用密码相同";
errorMap["changepwd_passwordcomplete"] = "你的密码已成功修改完成。";
errorMap["changepwd_stop"] = "停止修改密码?";
errorMap["rule_error_1"] = "您的新密码必须由 6-12个字母和数字 (A-Z 或 0-9)组成。";
errorMap["rule_error_2"] = "您输入的密码不符合要求:\n1. 您的新密码必须由6 - 12个字母和数字(A - Z 或 0 - 9)组成。\n2. 您的新密码不能和现用密码相同";
errorMap["rule_error_3"] = "密码过于简易会导致安全性的问题,请尝试使用其他密码组合。";
errorMap["rule_error_4"] = "安全代码过于简易会导致安全性的问题,请尝试使用其他安全代码组合。";
errorMap["rule_error_5"] = "您的密码必须根据以下规则:\n1. 至少要有两个大或小写英文字母和数字(0 - 9)组合,字数最少6至12个。\n2. 三个不同的字母数字。\n3. 不准许有空格。";
errorMap["changeemail_page"] = "要注册密码恢复?";
errorMap["login_internalerror"] = "网路过慢,请重新登入!";
errorMap["login_usr"] = "请输入登录帐号 ?";
errorMap["login_pwd"] = "请输入密码 ? ";
errorMap["login_error"] = "您输入的帐号或密码不正确。 请重新登入。";
errorMap["login_lock"] = "请几分钟后再试一次。";
errorMap["mail_disable"] = "此功能暂时已被禁用,请联系您的上线。";
errorMap["mail_cancel"] = "取消注册?";
errorMap["mail_delete"] = "删除密码恢复用的电子信箱?";
errorMap["mail_error"] = "连线异常,请联系您的线上。";
errorMap["mail_error1"] = "请输入有效电子邮件。";
errorMap["mail_pop"] = "认证码已经送到您的电子信箱";
errorMap["mail_lock"] = "您输入的验证码不正确, 请再尝试输入。";
errorMap["mail_complete"] = "已成功注册。";
errorMap["mail_gmail"] = "此功能不再支援Gmail。请用其他供应商的电子邮件。";
errorMap["chgid_complete"] = "你的帐号已成功创建";
errorMap["chgid_error"] = "请输入登录帐号。";
errorMap["chgid_error_duplicate"] = "此登录帐号已有人使用。";
errorMap["chgid_error_rule"] = "您输入的登录帐号不符合要求:\n1.您的登入帐号必须由2个英文大小写字母(A-Z或a-z)和数字(0-9)组合,输入限制6-12字元\n2.您的登入帐号不准许有空格。";
errorMap["chgid_error_passwd"] = "登录帐号请勿和帐号密码相同。";
errorMap["right_msg"] = "显示帐户金额";
errorMap["todat_wagers_magtitle"] = "系统公告";
errorMap["alldateno"] = "目前没有任何赛事。";
errorMap["dateno"] = "您选择的日期没有任何赛事。";
errorMap["pls_enter_email"] = "请输入有效的电子邮件。";
errorMap["pls_enter_usertag"] = "请输入 帐号 或 登录帐号。";
errorMap["verify_sent_ok"] = "验证码已经送到您的电子信箱";
errorMap["verify_cancel"] = "取消密码恢复用电子信箱?";
errorMap["pls_enter_passwords"] = "请输入密码。";
errorMap["pls_enter_pwd_chk"] = "请输入确认密码。";
errorMap["pwd_chk_error"] = "密码确认错误,请重新输入。";
errorMap["pwd_rule_error"] = "您的新密码必须由 6-12个字母和数字 (A-Z 或 0-9)组成.";
errorMap["pwd_rule_error2"] = "您的密码必须由根据以下规则:\n1. 至少要有两个大或小写英文字母和数字(0 - 9)组合, 字数最少6至12个。\n2. 三个不同的字母数字。\n3. 不准许有空格。";
errorMap["pwd_rule_error3"] = "密码过于简易会导致安全性的问题,请尝试使用其他密码组合。";
errorMap["pwd_rule_error4"] = "安全代码过于简易会导致安全性的问题,请尝试使用其他安全代码组合。";
errorMap["pwd_rule_error5"] = "您的密码必须根据以下规则:\n1. 至少要有两个大或小写英文字母和数字(0-9)组合,字数最少6至12个。\n2. 三个不同的字母数字。\n3. 不准许有空格。";
errorMap["history_pop"] = "日期区间错误。请输入正确的日期区间。";
return errorMap[errorCode];
}
QString Utils::formatGold(QString gold)
{
double doubleGold = gold.toDouble();
return QString::number(doubleGold,'f',2);
}
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
// 解析盘口数值(支持单一值和复合值)
// 参数:
// marketStr - 输入的盘口字符串,可以是单一值(如"1.5")或范围值(如"1.5/2")
// lowValue - 输出参数,解析得到的下限值
// highValue - 输出参数,解析得到的上限值
// 返回值:
// bool - 解析成功返回true,失败返回false
bool parseMarketValue(const std::string& marketStr, double& lowValue, double& highValue) {
std::string cleanStr = marketStr;
// 移除字符串中的所有空格,便于后续处理
cleanStr.erase(std::remove(cleanStr.begin(), cleanStr.end(), ' '), cleanStr.end());
// 查找分隔符 '/',用于判断是否为范围值
size_t slashPos = cleanStr.find('/');
// 如果没有找到分隔符,说明是单一数值
if (slashPos == std::string::npos) {
try {
// 将整个字符串转换为double类型
lowValue = std::stod(cleanStr);
highValue = lowValue; // 单一值时,上下限值相同
return true;
}
catch (...) {
// 转换失败,返回false
return false;
}
}
// 处理范围值(包含'/'分隔符的情况)
try {
// 提取'/'前的部分作为下限值字符串
std::string lowStr = cleanStr.substr(0, slashPos);
// 提取'/'后的部分作为上限值字符串
std::string highStr = cleanStr.substr(slashPos + 1);
// 将字符串转换为double数值
lowValue = std::stod(lowStr);
highValue = std::stod(highStr);
// 验证下限值不大于上限值,确保范围有效
return lowValue <= highValue;
}
catch (...) {
// 转换过程中出现异常,返回false
return false;
}
}
// 让球/受让盘口判断函数(修正版)
// 对于让球方:数值升高(负值变小或正值变大)表示让球优势增加,更难赢
// 对于让球方:数值降低(负值变大或正值变小)表示让球优势减小,更容易赢
// 对于受让方:数值升高(正值变大)表示受让优势增加,更容易赢
// 对于受让方:数值降低(正值变小)表示受让优势减小,更难赢
// 让球/受让盘口判断函数(修正版)
// 让球/受让盘口判断函数(修正版)
// 让球/受让盘口判断函数(修正版)
MarketChange Utils::checkHandicapChange(const std::string& marketType,
const std::string& oldMarket,
const std::string& newMarket) {
double oldLow, oldHigh, newLow, newHigh;
if (!parseMarketValue(oldMarket, oldLow, oldHigh) || !parseMarketValue(newMarket, newLow, newHigh)) {
return MARKET_INVALID;
}
const double tolerance = 0.01;
// 检查是否为复合盘口(上下限不同)
bool oldIsCompound = (std::abs(oldHigh - oldLow) > tolerance);
bool newIsCompound = (std::abs(newHigh - newLow) > tolerance);
if (marketType == "让球") {
// 特殊处理:复合盘口变单一盘口
if (oldIsCompound && !newIsCompound) {
// 从复合盘口变为单一盘口,需要判断是变好还是变差
// 关键是比较新单一值与旧上限值的关系
if (std::abs(newLow - oldHigh) < tolerance) {
// 新单一值等于旧上限值:变差(门槛提高)
return MARKET_WORSENED;
}
else if (std::abs(newLow - oldLow) < tolerance) {
// 新单一值等于旧下限值:变好(门槛降低)
return MARKET_IMPROVED;
}
// 让球方:数值变大(更容易赢)
else if (newLow > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 单一盘口变复合盘口
else if (!oldIsCompound && newIsCompound) {
// 从单一盘口变为复合盘口,需要判断是变好还是变差
// 关键是比较旧单一值与新下限值的关系
if (std::abs(newLow - oldLow) < tolerance) {
// 新下限值等于旧单一值:变差(门槛提高)
return MARKET_WORSENED;
}
else if (std::abs(newHigh - oldLow) < tolerance) {
// 新上限值等于旧单一值:变好(门槛降低)
return MARKET_IMPROVED;
}
// 让球方:数值变大(更容易赢)
else if (newLow > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 都是复合盘口
else if (oldIsCompound && newIsCompound) {
// 比较下限值
if (std::abs(newLow - oldLow) < tolerance) {
return MARKET_UNCHANGED;
}
// 让球方:数值变大(更容易赢)
if (newLow > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 都是单一盘口
else {
if (std::abs(newLow - oldLow) < tolerance) {
return MARKET_UNCHANGED;
}
// 让球方:数值变大(更容易赢)
if (newLow > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
}
else if (marketType == "受让") {
// 受让方:数值变大(更容易赢),数值变小(更难赢)
// 特殊处理:复合盘口变单一盘口
if (oldIsCompound && !newIsCompound) {
// 从复合盘口变为单一盘口,比较新单一值与旧上限值
if (std::abs(newLow - oldHigh) < tolerance) {
// 新单一值等于旧上限值:变好(门槛降低)
return MARKET_IMPROVED;
}
// 受让方:数值变大(更容易赢)
else if (newLow > oldHigh + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 单一盘口变复合盘口
else if (!oldIsCompound && newIsCompound) {
// 从单一盘口变为复合盘口,比较旧单一值与新上限值
if (std::abs(newHigh - oldLow) < tolerance) {
// 新上限值等于旧单一值:变好(门槛降低)
return MARKET_IMPROVED;
}
// 受让方:数值变大(更容易赢)
else if (newHigh > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 都是复合盘口
else if (oldIsCompound && newIsCompound) {
// 比较上限值(受让方主要看上盘)
if (std::abs(newHigh - oldHigh) < tolerance) {
return MARKET_UNCHANGED;
}
// 受让方:数值变大(更容易赢)
if (newHigh > oldHigh + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
// 都是单一盘口
else {
if (std::abs(newLow - oldLow) < tolerance) {
return MARKET_UNCHANGED;
}
// 受让方:数值变大(更容易赢)
if (newLow > oldLow + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else {
return MARKET_WORSENED; // 更难赢
}
}
}
else {
return MARKET_INVALID;
}
return MARKET_UNCHANGED;
}
// 大小球盘口判断函数(保持不变,逻辑正确)
// 对于大球盘:数值降低更容易赢(门槛降低)
// 对于小球盘:数值升高更容易赢(门槛提高)
MarketChange Utils::checkOverUnderChange(const std::string& marketType,
const std::string& oldMarket,
const std::string& newMarket) {
double oldLow, oldHigh, newLow, newHigh;
if (!parseMarketValue(oldMarket, oldLow, oldHigh) || !parseMarketValue(newMarket, newLow, newHigh)) {
return MARKET_INVALID;
}
const double tolerance = 0.01;
double oldAvg = (oldLow + oldHigh) / 2.0;
double newAvg = (newLow + newHigh) / 2.0;
if (std::abs(newAvg - oldAvg) < tolerance) {
return MARKET_UNCHANGED;
}
if (marketType == "大" || marketType == "over" || marketType == "OVER") {
// 大球盘:数值降低更容易赢(门槛降低)
if (newAvg < oldAvg - tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else if (newAvg > oldAvg + tolerance) {
return MARKET_WORSENED; // 更难赢
}
}
else if (marketType == "小" || marketType == "under" || marketType == "UNDER") {
// 小球盘:数值升高更容易赢(门槛提高)
if (newAvg > oldAvg + tolerance) {
return MARKET_IMPROVED; // 更容易赢
}
else if (newAvg < oldAvg - tolerance) {
return MARKET_WORSENED; // 更难赢
}
}
else {
return MARKET_INVALID;
}
return MARKET_UNCHANGED;
}
#include <string>
#include <cctype>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <limits.h>
#endif
int Utils::get_number_of_application_name() {
std::string filepath;
// 获取可执行文件完整路径
#ifdef _WIN32
char buffer[MAX_PATH];
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
filepath = buffer;
#else
char buffer[PATH_MAX];
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
if (len != -1) {
buffer[len] = '\0';
filepath = buffer;
}
#endif
// 从完整路径中提取文件名
std::string filename;
size_t lastSlash = filepath.find_last_of("/\\");
if (lastSlash != std::string::npos) {
filename = filepath.substr(lastSlash + 1);
}
else {
filename = filepath;
}
// 提取文件名中的数字
std::string numberStr;
bool foundDigit = false;
for (char c : filename) {
if (std::isdigit(c)) {
numberStr += c;
foundDigit = true;
}
else if (foundDigit) {
// 遇到非数字字符且已经找到过数字,停止提取
break;
}
}
// 如果找到数字,转换为整数
if (!numberStr.empty()) {
try {
// 数字范围超过5,返回默认值1
if (std::stoi(numberStr) < 1 || std::stoi(numberStr) > 5)
{
return 1; //返回默认值1
}
return std::stoi(numberStr);
}
catch (const std::exception&) {
return 1; // 转换失败,返回默认值1
}
}
return 1; // 未找到数字,返回默认值1
}
//
//QString Utils::switchConRtype(QString rtype, QString isOutside, QString gtype) {
// rtype = rtype.toLowerCase();
// var _gtype = gtype ? gtype : top.choice_gtype;
// var hash = new Object;
// if (isOutside == "Y" || _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_pdrouu";
// 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_tdr uu";
// hash["pteruo"] = "ratio_teruo";
// hash["pteruu"] = "ratio_teruu";
// return hash[rtype] != null ? hash[rtype] : rtype
//}
//;