respgetchargeinfo.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "respgetchargeinfo.h"
  2. #include <QScriptValue>
  3. #include <QScriptEngine>
  4. #include <QScriptValueIterator>
  5. RespGetChargeInfo::RespGetChargeInfo(QString json)
  6. {
  7. this->json = json;
  8. QScriptEngine engine;
  9. QScriptValue sv = engine.evaluate("value = " + this->json);
  10. QScriptValueIterator it(sv);
  11. if(json.isEmpty())
  12. {
  13. rtnCode = RTNCODE_NETWORK_NOTAVAILABLE;
  14. rtnMemo = RTNMEMO_NETWORK_NOTAVAILABLE;
  15. }
  16. else if(json=="ABORT")
  17. {
  18. rtnCode = RTNCODE_NETWORK_ABORT;
  19. rtnMemo = RTNMEMO_NETWORK_ABORT;
  20. }
  21. else
  22. {
  23. rtnCode = RTNCODE_INVALID_FORMAT;
  24. rtnMemo = RTNMEMO_INVALID_FORMAT;
  25. while (it.hasNext())
  26. {
  27. it.next();
  28. if(it.name()=="rtnCode")
  29. {
  30. this->rtnCode = it.value().toInt32();
  31. }
  32. else if(it.name()=="rtnMemo")
  33. {
  34. this->rtnMemo = it.value().toString();
  35. }
  36. else if(it.name()=="rsCount")
  37. {
  38. this->rsCount = it.value().toInt32();
  39. }
  40. else if(it.name()=="sum_chargemoney")
  41. {
  42. this->totalMoney = it.value().toInt32();
  43. }
  44. else if(it.name()=="rs")
  45. {
  46. QScriptValueIterator it2(it.value());
  47. while(it2.hasNext()) {
  48. it2.next();
  49. if (it2.flags() & QScriptValue::SkipInEnumeration)
  50. continue;
  51. QScriptValue sv1 = it2.value();
  52. if (sv1.property("chargeid").toInt32() > 0) {
  53. map.insert("serialnum",sv1.property("serialnum").toString());
  54. map.insert("chargeid",sv1.property("chargeid").toString());
  55. map.insert("usercode",sv1.property("usercode").toString());
  56. map.insert("discountset",sv1.property("discountset").toString());
  57. map.insert("premoney",sv1.property("premoney").toString());
  58. map.insert("chargemoney",sv1.property("chargemoney").toString());
  59. map.insert("aftermoney",sv1.property("aftermoney").toString());
  60. map.insert("pregiftmoney",sv1.property("pregiftmoney").toString());
  61. map.insert("giftmoney",sv1.property("giftmoney").toString());
  62. map.insert("aftergiftmoney",sv1.property("aftergiftmoney").toString());
  63. map.insert("chargetime",sv1.property("chargetime").toString());
  64. map.insert("memo",sv1.property("memo").toString());
  65. map.insert("invoicememo",sv1.property("invoicememo").toString());
  66. map.insert("faxmemo",sv1.property("faxmemo").toString());
  67. }
  68. }
  69. }
  70. else
  71. {
  72. /*
  73. QScriptValue sv1 = it.value();
  74. map.insert("serialnum",sv1.property("serialnum").toString());
  75. map.insert("chargeid",sv1.property("chargeid").toString());
  76. map.insert("usercode",sv1.property("usercode").toString());
  77. map.insert("discountset",sv1.property("discountset").toString());
  78. map.insert("premoney",sv1.property("premoney").toString());
  79. map.insert("chargemoney",sv1.property("chargemoney").toString());
  80. map.insert("aftermoney",sv1.property("aftermoney").toString());
  81. map.insert("pregiftmoney",sv1.property("pregiftmoney").toString());
  82. map.insert("giftmoney",sv1.property("giftmoney").toString());
  83. map.insert("aftergiftmoney",sv1.property("aftergiftmoney").toString());
  84. map.insert("chargetime",sv1.property("chargetime").toString());
  85. map.insert("memo",sv1.property("memo").toString());
  86. map.insert("invoicememo",sv1.property("invoicememo").toString());
  87. map.insert("faxmemo",sv1.property("faxmemo").toString());
  88. */
  89. }
  90. }
  91. }
  92. }
  93. int RespGetChargeInfo::getRtnCode()
  94. {
  95. return this->rtnCode;
  96. }
  97. QString RespGetChargeInfo::getRtnMemo()
  98. {
  99. return this->rtnMemo;
  100. }
  101. int RespGetChargeInfo::getRsCount()
  102. {
  103. return this->rsCount;
  104. }
  105. QMultiMap<QString,QString> RespGetChargeInfo::getRs()
  106. {
  107. return this->map;
  108. }