KbdishRuleInfo.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.DefaultInCartInfo import DefaultInCartInfo
  6. class KbdishRuleInfo(object):
  7. def __init__(self):
  8. self._biz_type = None
  9. self._default_in_cart_info = None
  10. self._dish_id = None
  11. self._ext_info = None
  12. self._rule_type = None
  13. self._rule_value = None
  14. self._sku_id = None
  15. self._status = None
  16. @property
  17. def biz_type(self):
  18. return self._biz_type
  19. @biz_type.setter
  20. def biz_type(self, value):
  21. self._biz_type = value
  22. @property
  23. def default_in_cart_info(self):
  24. return self._default_in_cart_info
  25. @default_in_cart_info.setter
  26. def default_in_cart_info(self, value):
  27. if isinstance(value, DefaultInCartInfo):
  28. self._default_in_cart_info = value
  29. else:
  30. self._default_in_cart_info = DefaultInCartInfo.from_alipay_dict(value)
  31. @property
  32. def dish_id(self):
  33. return self._dish_id
  34. @dish_id.setter
  35. def dish_id(self, value):
  36. self._dish_id = value
  37. @property
  38. def ext_info(self):
  39. return self._ext_info
  40. @ext_info.setter
  41. def ext_info(self, value):
  42. self._ext_info = value
  43. @property
  44. def rule_type(self):
  45. return self._rule_type
  46. @rule_type.setter
  47. def rule_type(self, value):
  48. self._rule_type = value
  49. @property
  50. def rule_value(self):
  51. return self._rule_value
  52. @rule_value.setter
  53. def rule_value(self, value):
  54. if isinstance(value, list):
  55. self._rule_value = list()
  56. for i in value:
  57. self._rule_value.append(i)
  58. @property
  59. def sku_id(self):
  60. return self._sku_id
  61. @sku_id.setter
  62. def sku_id(self, value):
  63. self._sku_id = value
  64. @property
  65. def status(self):
  66. return self._status
  67. @status.setter
  68. def status(self, value):
  69. self._status = value
  70. def to_alipay_dict(self):
  71. params = dict()
  72. if self.biz_type:
  73. if hasattr(self.biz_type, 'to_alipay_dict'):
  74. params['biz_type'] = self.biz_type.to_alipay_dict()
  75. else:
  76. params['biz_type'] = self.biz_type
  77. if self.default_in_cart_info:
  78. if hasattr(self.default_in_cart_info, 'to_alipay_dict'):
  79. params['default_in_cart_info'] = self.default_in_cart_info.to_alipay_dict()
  80. else:
  81. params['default_in_cart_info'] = self.default_in_cart_info
  82. if self.dish_id:
  83. if hasattr(self.dish_id, 'to_alipay_dict'):
  84. params['dish_id'] = self.dish_id.to_alipay_dict()
  85. else:
  86. params['dish_id'] = self.dish_id
  87. if self.ext_info:
  88. if hasattr(self.ext_info, 'to_alipay_dict'):
  89. params['ext_info'] = self.ext_info.to_alipay_dict()
  90. else:
  91. params['ext_info'] = self.ext_info
  92. if self.rule_type:
  93. if hasattr(self.rule_type, 'to_alipay_dict'):
  94. params['rule_type'] = self.rule_type.to_alipay_dict()
  95. else:
  96. params['rule_type'] = self.rule_type
  97. if self.rule_value:
  98. if isinstance(self.rule_value, list):
  99. for i in range(0, len(self.rule_value)):
  100. element = self.rule_value[i]
  101. if hasattr(element, 'to_alipay_dict'):
  102. self.rule_value[i] = element.to_alipay_dict()
  103. if hasattr(self.rule_value, 'to_alipay_dict'):
  104. params['rule_value'] = self.rule_value.to_alipay_dict()
  105. else:
  106. params['rule_value'] = self.rule_value
  107. if self.sku_id:
  108. if hasattr(self.sku_id, 'to_alipay_dict'):
  109. params['sku_id'] = self.sku_id.to_alipay_dict()
  110. else:
  111. params['sku_id'] = self.sku_id
  112. if self.status:
  113. if hasattr(self.status, 'to_alipay_dict'):
  114. params['status'] = self.status.to_alipay_dict()
  115. else:
  116. params['status'] = self.status
  117. return params
  118. @staticmethod
  119. def from_alipay_dict(d):
  120. if not d:
  121. return None
  122. o = KbdishRuleInfo()
  123. if 'biz_type' in d:
  124. o.biz_type = d['biz_type']
  125. if 'default_in_cart_info' in d:
  126. o.default_in_cart_info = d['default_in_cart_info']
  127. if 'dish_id' in d:
  128. o.dish_id = d['dish_id']
  129. if 'ext_info' in d:
  130. o.ext_info = d['ext_info']
  131. if 'rule_type' in d:
  132. o.rule_type = d['rule_type']
  133. if 'rule_value' in d:
  134. o.rule_value = d['rule_value']
  135. if 'sku_id' in d:
  136. o.sku_id = d['sku_id']
  137. if 'status' in d:
  138. o.status = d['status']
  139. return o