DiscountInfos.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class DiscountInfos(object):
  6. def __init__(self):
  7. self._amount = None
  8. self._ext_infos = None
  9. self._mdiscount_amount = None
  10. self._name = None
  11. self._platform_discount_amount = None
  12. self._type = None
  13. @property
  14. def amount(self):
  15. return self._amount
  16. @amount.setter
  17. def amount(self, value):
  18. self._amount = value
  19. @property
  20. def ext_infos(self):
  21. return self._ext_infos
  22. @ext_infos.setter
  23. def ext_infos(self, value):
  24. self._ext_infos = value
  25. @property
  26. def mdiscount_amount(self):
  27. return self._mdiscount_amount
  28. @mdiscount_amount.setter
  29. def mdiscount_amount(self, value):
  30. self._mdiscount_amount = value
  31. @property
  32. def name(self):
  33. return self._name
  34. @name.setter
  35. def name(self, value):
  36. self._name = value
  37. @property
  38. def platform_discount_amount(self):
  39. return self._platform_discount_amount
  40. @platform_discount_amount.setter
  41. def platform_discount_amount(self, value):
  42. self._platform_discount_amount = value
  43. @property
  44. def type(self):
  45. return self._type
  46. @type.setter
  47. def type(self, value):
  48. self._type = value
  49. def to_alipay_dict(self):
  50. params = dict()
  51. if self.amount:
  52. if hasattr(self.amount, 'to_alipay_dict'):
  53. params['amount'] = self.amount.to_alipay_dict()
  54. else:
  55. params['amount'] = self.amount
  56. if self.ext_infos:
  57. if hasattr(self.ext_infos, 'to_alipay_dict'):
  58. params['ext_infos'] = self.ext_infos.to_alipay_dict()
  59. else:
  60. params['ext_infos'] = self.ext_infos
  61. if self.mdiscount_amount:
  62. if hasattr(self.mdiscount_amount, 'to_alipay_dict'):
  63. params['mdiscount_amount'] = self.mdiscount_amount.to_alipay_dict()
  64. else:
  65. params['mdiscount_amount'] = self.mdiscount_amount
  66. if self.name:
  67. if hasattr(self.name, 'to_alipay_dict'):
  68. params['name'] = self.name.to_alipay_dict()
  69. else:
  70. params['name'] = self.name
  71. if self.platform_discount_amount:
  72. if hasattr(self.platform_discount_amount, 'to_alipay_dict'):
  73. params['platform_discount_amount'] = self.platform_discount_amount.to_alipay_dict()
  74. else:
  75. params['platform_discount_amount'] = self.platform_discount_amount
  76. if self.type:
  77. if hasattr(self.type, 'to_alipay_dict'):
  78. params['type'] = self.type.to_alipay_dict()
  79. else:
  80. params['type'] = self.type
  81. return params
  82. @staticmethod
  83. def from_alipay_dict(d):
  84. if not d:
  85. return None
  86. o = DiscountInfos()
  87. if 'amount' in d:
  88. o.amount = d['amount']
  89. if 'ext_infos' in d:
  90. o.ext_infos = d['ext_infos']
  91. if 'mdiscount_amount' in d:
  92. o.mdiscount_amount = d['mdiscount_amount']
  93. if 'name' in d:
  94. o.name = d['name']
  95. if 'platform_discount_amount' in d:
  96. o.platform_discount_amount = d['platform_discount_amount']
  97. if 'type' in d:
  98. o.type = d['type']
  99. return o