Commit 7de539ee by NitefullWind

1. 放通支付宝和微信条码。

parent 83e99230
...@@ -584,9 +584,7 @@ void Control::Request(ReqType type, QStringList list) ...@@ -584,9 +584,7 @@ void Control::Request(ReqType type, QStringList list)
bool isOk = true; bool isOk = true;
if(type == pay) { if(type == pay) {
QString payCode = list[0]; if(!IsValidCode(list[0])) {
int beginNum = payCode.mid(0, 2).toInt();
if(beginNum<25 || beginNum>30) {
isOk = false; isOk = false;
SetResPonseWithMessage("23", QString::fromLocal8Bit("无效条码")); SetResPonseWithMessage("23", QString::fromLocal8Bit("无效条码"));
} }
...@@ -710,3 +708,17 @@ void Control::OnInterrupt() ...@@ -710,3 +708,17 @@ void Control::OnInterrupt()
// _widget->StopPay(); // _widget->StopPay();
// } // }
} }
bool Control::IsValidCode(const QString &code)
{
int beginNum = code.mid(0, 2).toInt();
if(beginNum>=25 && beginNum<=30) {
return true;
}
if(beginNum == 13 && code.length() == 18) {
return true;
}
return false;
}
...@@ -63,6 +63,8 @@ private: ...@@ -63,6 +63,8 @@ private:
void InitPOSReqJsonObj(const char *indata); void InitPOSReqJsonObj(const char *indata);
static bool IsValidCode(const QString &code);
public slots: public slots:
void RequestWithType(ReqType type, QStringList list); void RequestWithType(ReqType type, QStringList list);
......
...@@ -14,7 +14,7 @@ include($$PWD/sbkpay.pri) ...@@ -14,7 +14,7 @@ include($$PWD/sbkpay.pri)
SOURCES += main.cpp SOURCES += main.cpp
CONFIG += C++11 SBKDLL1 CONFIG += C++11 SBKDLL
#DEFINES += MOCK #DEFINES += MOCK
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#define VER_MAJOR 0 #define VER_MAJOR 0
#define VER_MINOR 2 #define VER_MINOR 2
#define VER_REVISION 2 #define VER_REVISION 3
#define VER_BUILD 1 #define VER_BUILD 0
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -40,6 +40,9 @@ private slots: ...@@ -40,6 +40,9 @@ private slots:
void test_POSRequest_data(); void test_POSRequest_data();
void test_POSRequest(); void test_POSRequest();
void test_IsValidCode_data();
void test_IsValidCode();
}; };
TestSimphony::TestSimphony() TestSimphony::TestSimphony()
...@@ -278,6 +281,29 @@ void TestSimphony::test_POSRequest() ...@@ -278,6 +281,29 @@ void TestSimphony::test_POSRequest()
} }
} }
void TestSimphony::test_IsValidCode_data()
{
QTest::addColumn<QString>("code");
QTest::addColumn<bool>("isValid");
QTest::newRow("Alipay code begin with: 24.") << "2412345678" << false;
QTest::newRow("Alipay code begin with: 25.") << "251234567899999" << true;
QTest::newRow("Alipay code begin with: 28.") << "28123456788888" << true;
QTest::newRow("Alipay code begin with: 30.") << "3012345678" << true;
QTest::newRow("Alipay code begin with: 31.") << "311234567812" << false;
QTest::newRow("Wxpay code begin with: 12, Len: 18.") << "120123456789012345" << false;
QTest::newRow("Wxpay code begin with: 13, Len: 18.") << "130123456789012345" << true;
QTest::newRow("Wxpay code begin with: 13, Len: 17.") << "13012345678901234" << false;
}
void TestSimphony::test_IsValidCode()
{
QFETCH(QString, code);
QFETCH(bool, isValid);
QCOMPARE(Control::IsValidCode(code), isValid);
}
QTEST_MAIN(TestSimphony) QTEST_MAIN(TestSimphony)
#include "tst_testsimphony.moc" #include "tst_testsimphony.moc"
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