test.py 852 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. from apps.web.core.adapter.base import SmartBox
  4. from apps.web.core.networking import MessageSender
  5. class JNDZTest(SmartBox):
  6. def analyze_event_data(self, data):
  7. if data[4:6] == "10":
  8. if len(data) == 12:
  9. return
  10. return {'cardNo': str(int(data[8:16], 16)), 'preFee': int(data[16:18], 16), 'cmdCode': data[4:6], 'oper': data[18:20], "sourceData": data}
  11. def response_card(self, res, balance, fee, oper, cardNoHex):
  12. MessageSender.send(
  13. device=self.device,
  14. cmd=220,
  15. payload={
  16. "res": res,
  17. "balance": balance,
  18. "card_cst": fee,
  19. "card_ope": int(oper),
  20. "card_id": cardNoHex,
  21. "funCode": "10"
  22. }
  23. )