| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #include "respgetchargeinfo.h"
- #include <QScriptValue>
- #include <QScriptEngine>
- #include <QScriptValueIterator>
- RespGetChargeInfo::RespGetChargeInfo(QString json)
- {
- this->json = json;
- QScriptEngine engine;
- QScriptValue sv = engine.evaluate("value = " + this->json);
- QScriptValueIterator it(sv);
- if(json.isEmpty())
- {
- rtnCode = RTNCODE_NETWORK_NOTAVAILABLE;
- rtnMemo = RTNMEMO_NETWORK_NOTAVAILABLE;
- }
- else if(json=="ABORT")
- {
- rtnCode = RTNCODE_NETWORK_ABORT;
- rtnMemo = RTNMEMO_NETWORK_ABORT;
- }
- else
- {
- rtnCode = RTNCODE_INVALID_FORMAT;
- rtnMemo = RTNMEMO_INVALID_FORMAT;
- while (it.hasNext())
- {
- it.next();
- if(it.name()=="rtnCode")
- {
- this->rtnCode = it.value().toInt32();
- }
- else if(it.name()=="rtnMemo")
- {
- this->rtnMemo = it.value().toString();
- }
- else if(it.name()=="rsCount")
- {
- this->rsCount = it.value().toInt32();
- }
- else if(it.name()=="sum_chargemoney")
- {
- this->totalMoney = it.value().toInt32();
- }
- else if(it.name()=="rs")
- {
- QScriptValueIterator it2(it.value());
- while(it2.hasNext()) {
- it2.next();
- if (it2.flags() & QScriptValue::SkipInEnumeration)
- continue;
- QScriptValue sv1 = it2.value();
- if (sv1.property("chargeid").toInt32() > 0) {
- map.insert("serialnum",sv1.property("serialnum").toString());
- map.insert("chargeid",sv1.property("chargeid").toString());
- map.insert("usercode",sv1.property("usercode").toString());
- map.insert("discountset",sv1.property("discountset").toString());
- map.insert("premoney",sv1.property("premoney").toString());
- map.insert("chargemoney",sv1.property("chargemoney").toString());
- map.insert("aftermoney",sv1.property("aftermoney").toString());
- map.insert("pregiftmoney",sv1.property("pregiftmoney").toString());
- map.insert("giftmoney",sv1.property("giftmoney").toString());
- map.insert("aftergiftmoney",sv1.property("aftergiftmoney").toString());
- map.insert("chargetime",sv1.property("chargetime").toString());
- map.insert("memo",sv1.property("memo").toString());
- map.insert("invoicememo",sv1.property("invoicememo").toString());
- map.insert("faxmemo",sv1.property("faxmemo").toString());
- }
- }
- }
- else
- {
- /*
- QScriptValue sv1 = it.value();
- map.insert("serialnum",sv1.property("serialnum").toString());
- map.insert("chargeid",sv1.property("chargeid").toString());
- map.insert("usercode",sv1.property("usercode").toString());
- map.insert("discountset",sv1.property("discountset").toString());
- map.insert("premoney",sv1.property("premoney").toString());
- map.insert("chargemoney",sv1.property("chargemoney").toString());
- map.insert("aftermoney",sv1.property("aftermoney").toString());
- map.insert("pregiftmoney",sv1.property("pregiftmoney").toString());
- map.insert("giftmoney",sv1.property("giftmoney").toString());
- map.insert("aftergiftmoney",sv1.property("aftergiftmoney").toString());
- map.insert("chargetime",sv1.property("chargetime").toString());
- map.insert("memo",sv1.property("memo").toString());
- map.insert("invoicememo",sv1.property("invoicememo").toString());
- map.insert("faxmemo",sv1.property("faxmemo").toString());
- */
- }
- }
- }
- }
- int RespGetChargeInfo::getRtnCode()
- {
- return this->rtnCode;
- }
- QString RespGetChargeInfo::getRtnMemo()
- {
- return this->rtnMemo;
- }
- int RespGetChargeInfo::getRsCount()
- {
- return this->rsCount;
- }
- QMultiMap<QString,QString> RespGetChargeInfo::getRs()
- {
- return this->map;
- }
|