Commit fc9f20bf by unknown

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

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