Commit fc9f20bf by unknown

1. 修改充值/激活界面。 2. 错误信息加入错误码。

parent 79fb9d12
......@@ -45,10 +45,10 @@ void CardReader::Stop()
_isRunning = false;
}
void CardReader::setError(const QString &error)
void CardReader::setError(const QString &error, int errCode)
{
_error = error;
FM_ERROR() << error;
_error = QString("[%1]%2").arg(errCode).arg(error) ;
FM_ERROR() << _error;
emit hadError(_error);
}
......@@ -63,7 +63,7 @@ bool CardReader::ConnectDevice(int port, int baud)
if((int)_handle<=0)
{
setError("连接设备失败");
setError("连接设备失败", (int)_handle);
return false;
}
......@@ -79,8 +79,9 @@ void CardReader::DisConnectDevice()
bool CardReader::LoadKeyHex(qint8 sec, const QString &password)
{
char *pwd = password.toLatin1().data();
if(rf_load_key_hex(_handle, 0, sec, pwd) != 0) {
setError(QString("%1扇区密码加载失败").arg(sec));
int rt;
if((rt = rf_load_key_hex(_handle, 0, sec, pwd)) != 0) {
setError(QString("%1扇区密码加载失败").arg(sec), rt);
return false;
}
return true;
......@@ -90,8 +91,9 @@ bool CardReader::ReadData(qint8 sec, QString &data, qint8 blockNums, bool isHex)
{
data.clear();
// 验证密码
if(rf_authentication(_handle, 0, sec) != 0) {
setError(QString("%1扇区密码错误").arg(sec));
int rt;
if((rt = rf_authentication(_handle, 0, sec)) != 0) {
setError(QString("%1扇区密码错误").arg(sec), rt);
return false;
}
......@@ -100,16 +102,16 @@ bool CardReader::ReadData(qint8 sec, QString &data, qint8 blockNums, bool isHex)
// 读卡,16进制
char _data[32];
ZeroMemory(_data, 32);
if(rf_read_hex(_handle, sec*4+i, _data) != 0) {
setError(QString("%1扇区数据读取失败").arg(sec));
if((rt = rf_read_hex(_handle, sec*4+i, _data)) != 0) {
setError(QString("%1扇区数据读取失败").arg(sec), rt);
return false;
}
data += QString::fromLatin1(_data).trimmed();
} else {
unsigned char _data[17];
ZeroMemory(_data, 17);
if(rf_read(_handle, sec*4+i, _data) != 0) {
setError(QString("%1扇区数据读取失败").arg(sec));
if((rt = rf_read(_handle, sec*4+i, _data)) != 0) {
setError(QString("%1扇区数据读取失败").arg(sec), rt);
return false;
}
data += QString::fromLatin1((char*)_data).trimmed();
......@@ -134,7 +136,8 @@ bool CardReader::OperatorCard()
bool isActived = true;
QString data, uuid, vipNo="";
unsigned long snr;
if(rf_card(_handle, 0, &snr) != 0) {
int rt;
if((rt = rf_card(_handle, 0, &snr)) != 0) {
return false;
}
......@@ -196,14 +199,15 @@ bool CardReader::Active(const QString &vipNo)
return false;
}
// 鉴权
if(rf_authentication(_handle, 0, sector) != 0){
setError(QString("%1扇区密码错误").arg(sector));
int rt;
if((rt = rf_authentication(_handle, 0, sector)) != 0){
setError(QString("%1扇区密码错误").arg(sector), rt);
return false;
}
// 写入卡号
char* writeData = vipNo.toLatin1().toHex().mid(0,32).data();
if(rf_write_hex(_handle, sector*4, writeData) !=0 ) {
setError("写入卡号失败");
if((rt = rf_write_hex(_handle, sector*4, writeData)) !=0 ) {
setError("写入卡号失败", rt);
return false;
}
// 修改密码
......@@ -211,22 +215,22 @@ bool CardReader::Active(const QString &vipNo)
unsigned char wkey[7];
ZeroMemory(wkey, 7);
a_hex(tmpData.data(), wkey, 12);
if(rf_changeb3(_handle, sector, wkey, 0, 0, 0, 1, 0, wkey) != 0) {
setError("修改密码失败");
if((rt = rf_changeb3(_handle, sector, wkey, 0, 0, 0, 1, 0, wkey)) != 0) {
setError("修改密码失败", rt);
return false;
}
// 删除原扇区内容
LoadKeyHex(def_sector, def_pwd);
// 鉴权
if(rf_authentication(_handle, 0, def_sector) != 0) {
setError(QString("%1扇区密码错误").arg(def_sector));
if((rt = rf_authentication(_handle, 0, def_sector) != 0)) {
setError(QString("%1扇区密码错误").arg(def_sector), rt);
return false;
}
// 初始化为0
char zeroData[33] = "00000000000000000000000000000000";
if(rf_write_hex(_handle, def_sector*4, zeroData) !=0 ){
setError("擦除原数据失败");
if((rt = rf_write_hex(_handle, def_sector*4, zeroData)) !=0 ){
setError("擦除原数据失败", rt);
return false;
}
rf_beep(_handle, 30);
......
......@@ -48,7 +48,7 @@ private:
bool activedSuccess;
void setError(const QString& error);
void setError(const QString& error, int errCode=0);
bool OperatorCard();
bool LoadKeyHex(qint8 sec, const QString &password);
......
......@@ -25,7 +25,7 @@ void FMVip::recharge(const QString &fm_open_id, int amount, QJsonObject &rspObj)
{
QJsonObject reqObj;
reqObj["fm_cmd"] = "order_recharge_request";
reqObj["trans_id"] = createTransId("117017", "8888");
reqObj["trans_id"] = createTransId("fm9999", "8888");
QJsonObject transObj;
transObj["account"] = fm_open_id;
transObj["amount"] = amount;
......@@ -49,7 +49,7 @@ void FMVip::sendToServer(QJsonObject &reqObj, QJsonObject &rspObj)
reqObj["business_date"] = QDate::currentDate().toString("yyyyMMdd");
reqObj["t"] = QString::number(QDateTime::currentMSecsSinceEpoch());
reqObj["partner_id"] = PARTNER_ID;
reqObj["store_id"] = "117017";
reqObj["store_id"] = "fm9999";
reqObj["pos_id"] = "8888";
reqObj["operator_id"] = "8888";
......
......@@ -18,7 +18,7 @@
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font: normal 22px &quot;Microsoft YaHei&quot;;
font: normal 22px &quot;Microsoft YaHei&quot; ;
color: rgb(90,90,90);
}
#RechargeWnd {
......@@ -102,7 +102,7 @@ QPushButton#recharge_btn:hover {
}
#card_desc_label,#max_recharge_desc_label, #amount_desc_label, #re_amount_desc_label {
min-width:100; max-width: 100;
min-width:120; max-width: 120;
}
#recharge_info_label {
......@@ -212,8 +212,14 @@ QPushButton#recharge_btn:hover {
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="card_desc_label">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 号:</string>
<string>卡 号:</string>
</property>
</widget>
</item>
......@@ -243,6 +249,12 @@ QPushButton#recharge_btn:hover {
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="max_recharge_desc_label">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>账户限额:</string>
</property>
......@@ -287,8 +299,14 @@ QPushButton#recharge_btn:hover {
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="amount_desc_label">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 额:</string>
<string>余 额:</string>
</property>
</widget>
</item>
......@@ -322,7 +340,7 @@ QPushButton#recharge_btn:hover {
</property>
<property name="maximumSize">
<size>
<width>400</width>
<width>200</width>
<height>16777215</height>
</size>
</property>
......@@ -377,6 +395,12 @@ QPushButton#recharge_btn:hover {
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="re_amount_desc_label">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>充值金额:</string>
</property>
......
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