MEquityWorthInfo.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.MStepCashRule import MStepCashRule
  6. class MEquityWorthInfo(object):
  7. def __init__(self):
  8. self._calculate_type = None
  9. self._cash_amount = None
  10. self._dynamic_rule_type = None
  11. self._max_discount_amount = None
  12. self._max_discount_count = None
  13. self._multi_step_cash_rules = None
  14. self._rate = None
  15. self._reduce_to_amount = None
  16. self._rounding_type = None
  17. self._type = None
  18. @property
  19. def calculate_type(self):
  20. return self._calculate_type
  21. @calculate_type.setter
  22. def calculate_type(self, value):
  23. self._calculate_type = value
  24. @property
  25. def cash_amount(self):
  26. return self._cash_amount
  27. @cash_amount.setter
  28. def cash_amount(self, value):
  29. self._cash_amount = value
  30. @property
  31. def dynamic_rule_type(self):
  32. return self._dynamic_rule_type
  33. @dynamic_rule_type.setter
  34. def dynamic_rule_type(self, value):
  35. self._dynamic_rule_type = value
  36. @property
  37. def max_discount_amount(self):
  38. return self._max_discount_amount
  39. @max_discount_amount.setter
  40. def max_discount_amount(self, value):
  41. self._max_discount_amount = value
  42. @property
  43. def max_discount_count(self):
  44. return self._max_discount_count
  45. @max_discount_count.setter
  46. def max_discount_count(self, value):
  47. self._max_discount_count = value
  48. @property
  49. def multi_step_cash_rules(self):
  50. return self._multi_step_cash_rules
  51. @multi_step_cash_rules.setter
  52. def multi_step_cash_rules(self, value):
  53. if isinstance(value, list):
  54. self._multi_step_cash_rules = list()
  55. for i in value:
  56. if isinstance(i, MStepCashRule):
  57. self._multi_step_cash_rules.append(i)
  58. else:
  59. self._multi_step_cash_rules.append(MStepCashRule.from_alipay_dict(i))
  60. @property
  61. def rate(self):
  62. return self._rate
  63. @rate.setter
  64. def rate(self, value):
  65. self._rate = value
  66. @property
  67. def reduce_to_amount(self):
  68. return self._reduce_to_amount
  69. @reduce_to_amount.setter
  70. def reduce_to_amount(self, value):
  71. self._reduce_to_amount = value
  72. @property
  73. def rounding_type(self):
  74. return self._rounding_type
  75. @rounding_type.setter
  76. def rounding_type(self, value):
  77. self._rounding_type = value
  78. @property
  79. def type(self):
  80. return self._type
  81. @type.setter
  82. def type(self, value):
  83. self._type = value
  84. def to_alipay_dict(self):
  85. params = dict()
  86. if self.calculate_type:
  87. if hasattr(self.calculate_type, 'to_alipay_dict'):
  88. params['calculate_type'] = self.calculate_type.to_alipay_dict()
  89. else:
  90. params['calculate_type'] = self.calculate_type
  91. if self.cash_amount:
  92. if hasattr(self.cash_amount, 'to_alipay_dict'):
  93. params['cash_amount'] = self.cash_amount.to_alipay_dict()
  94. else:
  95. params['cash_amount'] = self.cash_amount
  96. if self.dynamic_rule_type:
  97. if hasattr(self.dynamic_rule_type, 'to_alipay_dict'):
  98. params['dynamic_rule_type'] = self.dynamic_rule_type.to_alipay_dict()
  99. else:
  100. params['dynamic_rule_type'] = self.dynamic_rule_type
  101. if self.max_discount_amount:
  102. if hasattr(self.max_discount_amount, 'to_alipay_dict'):
  103. params['max_discount_amount'] = self.max_discount_amount.to_alipay_dict()
  104. else:
  105. params['max_discount_amount'] = self.max_discount_amount
  106. if self.max_discount_count:
  107. if hasattr(self.max_discount_count, 'to_alipay_dict'):
  108. params['max_discount_count'] = self.max_discount_count.to_alipay_dict()
  109. else:
  110. params['max_discount_count'] = self.max_discount_count
  111. if self.multi_step_cash_rules:
  112. if isinstance(self.multi_step_cash_rules, list):
  113. for i in range(0, len(self.multi_step_cash_rules)):
  114. element = self.multi_step_cash_rules[i]
  115. if hasattr(element, 'to_alipay_dict'):
  116. self.multi_step_cash_rules[i] = element.to_alipay_dict()
  117. if hasattr(self.multi_step_cash_rules, 'to_alipay_dict'):
  118. params['multi_step_cash_rules'] = self.multi_step_cash_rules.to_alipay_dict()
  119. else:
  120. params['multi_step_cash_rules'] = self.multi_step_cash_rules
  121. if self.rate:
  122. if hasattr(self.rate, 'to_alipay_dict'):
  123. params['rate'] = self.rate.to_alipay_dict()
  124. else:
  125. params['rate'] = self.rate
  126. if self.reduce_to_amount:
  127. if hasattr(self.reduce_to_amount, 'to_alipay_dict'):
  128. params['reduce_to_amount'] = self.reduce_to_amount.to_alipay_dict()
  129. else:
  130. params['reduce_to_amount'] = self.reduce_to_amount
  131. if self.rounding_type:
  132. if hasattr(self.rounding_type, 'to_alipay_dict'):
  133. params['rounding_type'] = self.rounding_type.to_alipay_dict()
  134. else:
  135. params['rounding_type'] = self.rounding_type
  136. if self.type:
  137. if hasattr(self.type, 'to_alipay_dict'):
  138. params['type'] = self.type.to_alipay_dict()
  139. else:
  140. params['type'] = self.type
  141. return params
  142. @staticmethod
  143. def from_alipay_dict(d):
  144. if not d:
  145. return None
  146. o = MEquityWorthInfo()
  147. if 'calculate_type' in d:
  148. o.calculate_type = d['calculate_type']
  149. if 'cash_amount' in d:
  150. o.cash_amount = d['cash_amount']
  151. if 'dynamic_rule_type' in d:
  152. o.dynamic_rule_type = d['dynamic_rule_type']
  153. if 'max_discount_amount' in d:
  154. o.max_discount_amount = d['max_discount_amount']
  155. if 'max_discount_count' in d:
  156. o.max_discount_count = d['max_discount_count']
  157. if 'multi_step_cash_rules' in d:
  158. o.multi_step_cash_rules = d['multi_step_cash_rules']
  159. if 'rate' in d:
  160. o.rate = d['rate']
  161. if 'reduce_to_amount' in d:
  162. o.reduce_to_amount = d['reduce_to_amount']
  163. if 'rounding_type' in d:
  164. o.rounding_type = d['rounding_type']
  165. if 'type' in d:
  166. o.type = d['type']
  167. return o