MStepCashRule.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class MStepCashRule(object):
  6. def __init__(self):
  7. self._reduction_amount = None
  8. self._threshold_amount = None
  9. @property
  10. def reduction_amount(self):
  11. return self._reduction_amount
  12. @reduction_amount.setter
  13. def reduction_amount(self, value):
  14. self._reduction_amount = value
  15. @property
  16. def threshold_amount(self):
  17. return self._threshold_amount
  18. @threshold_amount.setter
  19. def threshold_amount(self, value):
  20. self._threshold_amount = value
  21. def to_alipay_dict(self):
  22. params = dict()
  23. if self.reduction_amount:
  24. if hasattr(self.reduction_amount, 'to_alipay_dict'):
  25. params['reduction_amount'] = self.reduction_amount.to_alipay_dict()
  26. else:
  27. params['reduction_amount'] = self.reduction_amount
  28. if self.threshold_amount:
  29. if hasattr(self.threshold_amount, 'to_alipay_dict'):
  30. params['threshold_amount'] = self.threshold_amount.to_alipay_dict()
  31. else:
  32. params['threshold_amount'] = self.threshold_amount
  33. return params
  34. @staticmethod
  35. def from_alipay_dict(d):
  36. if not d:
  37. return None
  38. o = MStepCashRule()
  39. if 'reduction_amount' in d:
  40. o.reduction_amount = d['reduction_amount']
  41. if 'threshold_amount' in d:
  42. o.threshold_amount = d['threshold_amount']
  43. return o