ConsumeInfo.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ConsumeInfo(object):
  6. def __init__(self):
  7. self._taken_time = None
  8. self._user_name = None
  9. self._voucher_amt = None
  10. @property
  11. def taken_time(self):
  12. return self._taken_time
  13. @taken_time.setter
  14. def taken_time(self, value):
  15. self._taken_time = value
  16. @property
  17. def user_name(self):
  18. return self._user_name
  19. @user_name.setter
  20. def user_name(self, value):
  21. self._user_name = value
  22. @property
  23. def voucher_amt(self):
  24. return self._voucher_amt
  25. @voucher_amt.setter
  26. def voucher_amt(self, value):
  27. self._voucher_amt = value
  28. def to_alipay_dict(self):
  29. params = dict()
  30. if self.taken_time:
  31. if hasattr(self.taken_time, 'to_alipay_dict'):
  32. params['taken_time'] = self.taken_time.to_alipay_dict()
  33. else:
  34. params['taken_time'] = self.taken_time
  35. if self.user_name:
  36. if hasattr(self.user_name, 'to_alipay_dict'):
  37. params['user_name'] = self.user_name.to_alipay_dict()
  38. else:
  39. params['user_name'] = self.user_name
  40. if self.voucher_amt:
  41. if hasattr(self.voucher_amt, 'to_alipay_dict'):
  42. params['voucher_amt'] = self.voucher_amt.to_alipay_dict()
  43. else:
  44. params['voucher_amt'] = self.voucher_amt
  45. return params
  46. @staticmethod
  47. def from_alipay_dict(d):
  48. if not d:
  49. return None
  50. o = ConsumeInfo()
  51. if 'taken_time' in d:
  52. o.taken_time = d['taken_time']
  53. if 'user_name' in d:
  54. o.user_name = d['user_name']
  55. if 'voucher_amt' in d:
  56. o.voucher_amt = d['voucher_amt']
  57. return o