Commit 5b86310c by 李定达

1.调整界面

parent 401c325c
...@@ -111,7 +111,8 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata) ...@@ -111,7 +111,8 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata)
outdata = QByteArray(out); outdata = QByteArray(out);
return true; return true;
} }
QLOG_ERROR() << "get function (GetValue) failed"; else
QLOG_ERROR() << "get function (GetValue) failed";
} }
else else
QLOG_ERROR() << "load dll failed"; QLOG_ERROR() << "load dll failed";
...@@ -134,9 +135,9 @@ bool Control::GetRSA() ...@@ -134,9 +135,9 @@ bool Control::GetRSA()
QEventLoop loop; QEventLoop loop;
QtConcurrent::run( [ this, &loop, &rlt, getrsacret]() QtConcurrent::run( [ this, &loop, &rlt, getrsacret]()
{ {
int i = GetString(_request.Reserved1, 48).toInt(); int i = FMTool::GetString(_request.Reserved1, 48).toInt();
QString storeID = GetString(_request.StoreNo, 20); QString storeID = FMTool::GetString(_request.StoreNo, 20);
QString PosNO = GetString(_request.DeviceNo, 6); QString PosNO = FMTool::GetString(_request.DeviceNo, 6);
rlt = getrsacret(i, storeID.toLatin1().data(), PosNO.toLatin1().data()); rlt = getrsacret(i, storeID.toLatin1().data(), PosNO.toLatin1().data());
...@@ -145,7 +146,8 @@ bool Control::GetRSA() ...@@ -145,7 +146,8 @@ bool Control::GetRSA()
loop.exec(); loop.exec();
} }
QLOG_ERROR() << "get function (GetRSACret) failed"; else
QLOG_ERROR() << "get function (GetRSACret) failed";
} }
else else
QLOG_ERROR() << "load dll failed"; QLOG_ERROR() << "load dll failed";
......
...@@ -7,122 +7,127 @@ ...@@ -7,122 +7,127 @@
#include "requestmodel.h" #include "requestmodel.h"
#include "global.h" #include "global.h"
class FMTool
{
public:
static int GBKToUTF8(unsigned char * lpGBKStr,int gbkLen, unsigned char * lpUTF8Str,int nUTF8StrLen)
{
wchar_t * lpUnicodeStr = NULL;
int nRetLen = 0;
if(!lpGBKStr) //如果GBK字符串为NULL则出错退出
return 0;
int GBKToUTF8(unsigned char * lpGBKStr,int gbkLen, unsigned char * lpUTF8Str,int nUTF8StrLen) nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度
{ //lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间
wchar_t * lpUnicodeStr = NULL; lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1));
int nRetLen = 0;
if(!lpGBKStr) //如果GBK字符串为NULL则出错退出 nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,lpUnicodeStr,nRetLen); //转换到Unicode编码
return 0; if(!nRetLen) //转换失败则出错退出
return 0;
nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度 nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,NULL,0,NULL,NULL); //获取转换到UTF8编码后所需要的字符空间长度
//lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间
lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1));
nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,lpUnicodeStr,nRetLen); //转换到Unicode编码 if(!lpUTF8Str) //输出缓冲区为空则返回转换后需要的空间大小
if(!nRetLen) //转换失败则出错退出 {
return 0; if(lpUnicodeStr)
free(lpUnicodeStr);
return nRetLen;
}
nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,NULL,0,NULL,NULL); //获取转换到UTF8编码后所需要的字符空间长度 if(nUTF8StrLen < nRetLen) //如果输出缓冲区长度不够则退出
{
if(lpUnicodeStr)
free(lpUnicodeStr);
return 0;
}
nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,(char *)lpUTF8Str,nUTF8StrLen,NULL,NULL); //转换到UTF8编码
if(!lpUTF8Str) //输出缓冲区为空则返回转换后需要的空间大小
{
if(lpUnicodeStr) if(lpUnicodeStr)
free(lpUnicodeStr); free(lpUnicodeStr);
return nRetLen; return nRetLen;
} }
if(nUTF8StrLen < nRetLen) //如果输出缓冲区长度不够则退出 static int UTF8ToGBK(unsigned char * lpUTF8Str,unsigned char * lpGBKStr,int nGBKStrLen)
{ {
if(lpUnicodeStr) wchar_t * lpUnicodeStr = NULL;
free(lpUnicodeStr); int nRetLen = 0;
return 0;
}
nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,(char *)lpUTF8Str,nUTF8StrLen,NULL,NULL); //转换到UTF8编码 if(!lpUTF8Str) //如果UTF8字符串为NULL则出错退出
return 0;
if(lpUnicodeStr) nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度
free(lpUnicodeStr); //lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间
lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1));
nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,lpUnicodeStr,nRetLen); //转换到Unicode编码
if(!nRetLen) //转换失败则出错退出
return 0;
return nRetLen; nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,NULL,NULL,NULL,NULL); //获取转换到GBK编码后所需要的字符空间长度
}
int UTF8ToGBK(unsigned char * lpUTF8Str,unsigned char * lpGBKStr,int nGBKStrLen)
{
wchar_t * lpUnicodeStr = NULL;
int nRetLen = 0;
if(!lpUTF8Str) //如果UTF8字符串为NULL则出错退出 if(!lpGBKStr) //输出缓冲区为空则返回转换后需要的空间大小
return 0; {
if(lpUnicodeStr)
free(lpUnicodeStr);
return nRetLen;
}
nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度 if(nGBKStrLen < nRetLen) //如果输出缓冲区长度不够则退出
//lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间 {
lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1)); if(lpUnicodeStr)
nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,lpUnicodeStr,nRetLen); //转换到Unicode编码 free(lpUnicodeStr);
if(!nRetLen) //转换失败则出错退出 return 0;
return 0; }
nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,NULL,NULL,NULL,NULL); //获取转换到GBK编码后所需要的字符空间长度 nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,(char *)lpGBKStr,nRetLen,NULL,NULL); //转换到GBK编码
if(!lpGBKStr) //输出缓冲区为空则返回转换后需要的空间大小
{
if(lpUnicodeStr) if(lpUnicodeStr)
free(lpUnicodeStr); free(lpUnicodeStr);
return nRetLen; return nRetLen;
} }
if(nGBKStrLen < nRetLen) //如果输出缓冲区长度不够则退出 //获取AlipayRequest中的值并过滤空格并进行编码转换
static QString GetString(const void *beginptr, int size)
{ {
if(lpUnicodeStr)
free(lpUnicodeStr);
return 0;
}
nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,(char *)lpGBKStr,nRetLen,NULL,NULL); //转换到GBK编码 QString tmp = "";
if(lpUnicodeStr) char buf[MAX_CHILED_LEN] = { 0 };
free(lpUnicodeStr); char tmpbuf[MAX_CHILED_LEN] = { 0 };
return nRetLen; strncpy(buf, (char *)beginptr, size);
}
//获取AlipayRequest中的值并过滤空格并进行编码转换 qDebug() << buf;
QString GetString(const void *beginptr, int size)
{
QString tmp = ""; for(int i = strlen(buf) - 1; i >= 0; --i )
{
if(buf[i] == ' ')
buf[i] = 0;
else
break;
}
char buf[MAX_CHILED_LEN] = { 0 }; strcpy(tmpbuf, buf);
char tmpbuf[MAX_CHILED_LEN] = { 0 };
strncpy(buf, (char *)beginptr, size); int len = GBKToUTF8((unsigned char *)tmpbuf, strlen(tmpbuf), NULL, 0);
qDebug() << buf; char *utfbuf = (char *)malloc(sizeof(char) * (len + 2));
memset(utfbuf, 0, len + 2);
for(int i = strlen(buf) - 1; i >= 0; --i ) if(GBKToUTF8((unsigned char *)tmpbuf, strlen(tmpbuf), (unsigned char *)utfbuf, len + 1) > 0)
{ tmp = QString(utfbuf);
if(buf[i] == ' ')
buf[i] = 0;
else
break;
}
strcpy(tmpbuf, buf); qDebug() << tmp.toLatin1().data();
int len = GBKToUTF8((unsigned char *)tmpbuf, strlen(tmpbuf), NULL, 0); return QString(tmpbuf);
}
char *utfbuf = (char *)malloc(sizeof(char) * (len + 2));
memset(utfbuf, 0, len + 2);
if(GBKToUTF8((unsigned char *)tmpbuf, strlen(tmpbuf), (unsigned char *)utfbuf, len + 1) > 0)
tmp = QString(utfbuf);
qDebug() << tmp.toLatin1().data(); };
return QString(tmpbuf);
}
#endif // FMTOOL #endif // FMTOOL
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "ui_hostwidget.h" #include "ui_hostwidget.h"
#include "QKeyEvent" #include "QKeyEvent"
#include "QsLog.h" #include "QsLog.h"
#include "fmtool.h"
HostWidget::HostWidget(QWidget *parent) : HostWidget::HostWidget(QWidget *parent) :
FMPWindow(parent), FMPWindow(parent),
...@@ -77,9 +78,10 @@ void HostWidget::keyPressEvent(QKeyEvent *ke) ...@@ -77,9 +78,10 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
} }
} }
void HostWidget::ShowWithRequest(const AlipayRequest &request) void HostWidget::ShowWithRequest(AlipayRequest request)
{ {
QString reqtype; QString reqtype;
_data = request;
reqtype.append(request.TransType[0]).append(request.TransType[1]); reqtype.append(request.TransType[0]).append(request.TransType[1]);
...@@ -130,6 +132,10 @@ void HostWidget::on_btn_mananger_register_clicked() ...@@ -130,6 +132,10 @@ void HostWidget::on_btn_mananger_register_clicked()
QStringList list; QStringList list;
ShowWidget(ui->sign); ShowWidget(ui->sign);
ui->btn_sign_sign->hide();
ui->label_sign_title->setText("签到中...");
ui->label_sign_msg->setText("");
ui->label_sign_storeid->setText(FMTool::GetString(_data.StoreNo, 20));
emit RequestWithType(sign, list); emit RequestWithType(sign, list);
} }
...@@ -175,6 +181,5 @@ void HostWidget::on_btn_sign_sign_clicked() ...@@ -175,6 +181,5 @@ void HostWidget::on_btn_sign_sign_clicked()
QStringList list; QStringList list;
ui->btn_sign_sign->hide(); ui->btn_sign_sign->hide();
//ui->btn_sign_exit->setDisabled(true);
emit RequestWithType(sign, list); emit RequestWithType(sign, list);
} }
...@@ -21,7 +21,7 @@ public: ...@@ -21,7 +21,7 @@ public:
~HostWidget(); ~HostWidget();
void ShowWithRequest(const AlipayRequest &request); void ShowWithRequest(AlipayRequest request);
void ShowWiteMGS(ReqType type, bool flag, QString message = QString()); void ShowWiteMGS(ReqType type, bool flag, QString message = QString());
...@@ -64,6 +64,8 @@ private: ...@@ -64,6 +64,8 @@ private:
QWidget *_curr_show_widget; QWidget *_curr_show_widget;
AlipayRequest _data;
}; };
......
...@@ -34,17 +34,17 @@ private: ...@@ -34,17 +34,17 @@ private:
json.insert(JSON_KEY_VER, DEFAULT_JSON_VER_VALUE); json.insert(JSON_KEY_VER, DEFAULT_JSON_VER_VALUE);
json.insert(JSON_KEY_REQTYPE, JSON_REQTYPE_PAY); json.insert(JSON_KEY_REQTYPE, JSON_REQTYPE_PAY);
json.insert(JSON_KEY_PARTNERID, GetString((const void *)&(request.Reserved1), 48).toInt()); json.insert(JSON_KEY_PARTNERID, FMTool::GetString((const void *)&(request.Reserved1), 48).toInt());
json.insert(JSON_KEY_STOREID, GetString((const void *)&(request.StoreNo), 20)); json.insert(JSON_KEY_STOREID, FMTool::GetString((const void *)&(request.StoreNo), 20));
json.insert(JSON_KEY_STATIONID, GetString((const void *)&(request.DeviceNo), 6)); json.insert(JSON_KEY_STATIONID, FMTool::GetString((const void *)&(request.DeviceNo), 6));
json.insert(JSON_KEY_OPERATORID, GetString((const void *)&(request.CashierNo), 6)); json.insert(JSON_KEY_OPERATORID, FMTool::GetString((const void *)&(request.CashierNo), 6));
json.insert(JSON_KEY_TRANSID, GetString((const void *)&(request.CashTraceNo), 6)); json.insert(JSON_KEY_TRANSID, FMTool::GetString((const void *)&(request.CashTraceNo), 6));
json.insert(JSON_KEY_BUSINESSDATE, GetString((const void *)&(request.BusinessDay), 8)); json.insert(JSON_KEY_BUSINESSDATE, FMTool::GetString((const void *)&(request.BusinessDay), 8));
json.insert(JSON_KEY_CODE, list[0]); json.insert(JSON_KEY_CODE, list[0]);
json.insert(JSON_KEY_TRANSAMOUNT, GetString((const void *)&(request.Amount), 12).toInt()); json.insert(JSON_KEY_TRANSAMOUNT, FMTool::GetString((const void *)&(request.Amount), 12).toInt());
json.insert(JSON_KEY_UNAMOUNT, GetString((const void *)&(request.non_sale_Amount), 12).toInt()); json.insert(JSON_KEY_UNAMOUNT, FMTool::GetString((const void *)&(request.non_sale_Amount), 12).toInt());
QString len = GetString((const void *)&(request.item_line_qty), 2); QString len = FMTool::GetString((const void *)&(request.item_line_qty), 2);
QJsonArray prod; QJsonArray prod;
...@@ -54,17 +54,17 @@ private: ...@@ -54,17 +54,17 @@ private:
struct product *pro = (struct product *)request.item_information[i]; struct product *pro = (struct product *)request.item_information[i];
object.insert(JSON_KEY_PRODUCTS_CONSUMENUM, GetString((const void *)&(pro->buyCount), 4)); object.insert(JSON_KEY_PRODUCTS_CONSUMENUM, FMTool::GetString((const void *)&(pro->buyCount), 4));
object.insert(JSON_KEY_PRODUCTS_PID, GetString((const void *)&(pro->productID), 8)); object.insert(JSON_KEY_PRODUCTS_PID, FMTool::GetString((const void *)&(pro->productID), 8));
object.insert(JSON_KEY_PRODUCTS_NAME, GetString((const void *)&(pro->productName), 20)); object.insert(JSON_KEY_PRODUCTS_NAME, FMTool::GetString((const void *)&(pro->productName), 20));
object.insert(JSON_KEY_PRODUCTS_SALESTYPE, DEFAULT_JSON_PRODUCTS_NORMAL); object.insert(JSON_KEY_PRODUCTS_SALESTYPE, DEFAULT_JSON_PRODUCTS_NORMAL);
QString typebuf = GetString((const void *)&(pro->isCombo), 1); QString typebuf = FMTool::GetString((const void *)&(pro->isCombo), 1);
if(typebuf == 0) if(typebuf == 0)
object.insert(JSON_KEY_PRODUCTS_SALESTYPE, DEFAULT_JSON_PRODUCTS_FREE); object.insert(JSON_KEY_PRODUCTS_SALESTYPE, DEFAULT_JSON_PRODUCTS_FREE);
object.insert(JSON_KEY_PRODUCTS_PRICE, GetString((const void *)&(pro->unitPrice), 8)); object.insert(JSON_KEY_PRODUCTS_PRICE, FMTool::GetString((const void *)&(pro->unitPrice), 8));
prod.append(object); prod.append(object);
} }
...@@ -82,14 +82,14 @@ private: ...@@ -82,14 +82,14 @@ private:
json.insert(JSON_KEY_VER, DEFAULT_JSON_VER_VALUE); json.insert(JSON_KEY_VER, DEFAULT_JSON_VER_VALUE);
json.insert(JSON_KEY_REQTYPE, JSON_REQTYPE_REFUND); json.insert(JSON_KEY_REQTYPE, JSON_REQTYPE_REFUND);
json.insert(JSON_KEY_PARTNERID, GetString((const void *)&(request.Reserved1), 48)); json.insert(JSON_KEY_PARTNERID, FMTool::GetString((const void *)&(request.Reserved1), 48));
json.insert(JSON_KEY_STOREID, GetString((const void *)&(request.StoreNo), 20)); json.insert(JSON_KEY_STOREID, FMTool::GetString((const void *)&(request.StoreNo), 20));
json.insert(JSON_KEY_STATIONID, GetString((const void *)&(request.DeviceNo), 6)); json.insert(JSON_KEY_STATIONID, FMTool::GetString((const void *)&(request.DeviceNo), 6));
json.insert(JSON_KEY_OPERATORID, GetString((const void *)&(request.CashierNo), 6)); json.insert(JSON_KEY_OPERATORID, FMTool::GetString((const void *)&(request.CashierNo), 6));
json.insert(JSON_KEY_TRANSID, GetString((const void *)&(request.CashTraceNo), 6)); json.insert(JSON_KEY_TRANSID, FMTool::GetString((const void *)&(request.CashTraceNo), 6));
json.insert(JSON_KEY_BUSINESSDATE, GetString((const void *)&(request.BusinessDay), 8)); json.insert(JSON_KEY_BUSINESSDATE, FMTool::GetString((const void *)&(request.BusinessDay), 8));
json.insert(JSON_KEY_CODE, list[0]); json.insert(JSON_KEY_CODE, list[0]);
json.insert(JSON_KEY_REFUNDAMOUT, GetString((const void *)&(request.Amount), 12).toInt()); json.insert(JSON_KEY_REFUNDAMOUT, FMTool::GetString((const void *)&(request.Amount), 12).toInt());
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment