Commit 5b86310c by 李定达

1.调整界面

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