TBMiniShopBo.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.ItemBo import ItemBo
  6. from alipay.aop.api.domain.ItemBo import ItemBo
  7. class TBMiniShopBo(object):
  8. def __init__(self):
  9. self._address = None
  10. self._attribute = None
  11. self._coupons = None
  12. self._items = None
  13. self._logo_url = None
  14. self._mini_shop_id = None
  15. self._shop_head_name = None
  16. self._shop_id = None
  17. self._shop_name = None
  18. @property
  19. def address(self):
  20. return self._address
  21. @address.setter
  22. def address(self, value):
  23. self._address = value
  24. @property
  25. def attribute(self):
  26. return self._attribute
  27. @attribute.setter
  28. def attribute(self, value):
  29. self._attribute = value
  30. @property
  31. def coupons(self):
  32. return self._coupons
  33. @coupons.setter
  34. def coupons(self, value):
  35. if isinstance(value, list):
  36. self._coupons = list()
  37. for i in value:
  38. if isinstance(i, ItemBo):
  39. self._coupons.append(i)
  40. else:
  41. self._coupons.append(ItemBo.from_alipay_dict(i))
  42. @property
  43. def items(self):
  44. return self._items
  45. @items.setter
  46. def items(self, value):
  47. if isinstance(value, list):
  48. self._items = list()
  49. for i in value:
  50. if isinstance(i, ItemBo):
  51. self._items.append(i)
  52. else:
  53. self._items.append(ItemBo.from_alipay_dict(i))
  54. @property
  55. def logo_url(self):
  56. return self._logo_url
  57. @logo_url.setter
  58. def logo_url(self, value):
  59. self._logo_url = value
  60. @property
  61. def mini_shop_id(self):
  62. return self._mini_shop_id
  63. @mini_shop_id.setter
  64. def mini_shop_id(self, value):
  65. self._mini_shop_id = value
  66. @property
  67. def shop_head_name(self):
  68. return self._shop_head_name
  69. @shop_head_name.setter
  70. def shop_head_name(self, value):
  71. self._shop_head_name = value
  72. @property
  73. def shop_id(self):
  74. return self._shop_id
  75. @shop_id.setter
  76. def shop_id(self, value):
  77. self._shop_id = value
  78. @property
  79. def shop_name(self):
  80. return self._shop_name
  81. @shop_name.setter
  82. def shop_name(self, value):
  83. self._shop_name = value
  84. def to_alipay_dict(self):
  85. params = dict()
  86. if self.address:
  87. if hasattr(self.address, 'to_alipay_dict'):
  88. params['address'] = self.address.to_alipay_dict()
  89. else:
  90. params['address'] = self.address
  91. if self.attribute:
  92. if hasattr(self.attribute, 'to_alipay_dict'):
  93. params['attribute'] = self.attribute.to_alipay_dict()
  94. else:
  95. params['attribute'] = self.attribute
  96. if self.coupons:
  97. if isinstance(self.coupons, list):
  98. for i in range(0, len(self.coupons)):
  99. element = self.coupons[i]
  100. if hasattr(element, 'to_alipay_dict'):
  101. self.coupons[i] = element.to_alipay_dict()
  102. if hasattr(self.coupons, 'to_alipay_dict'):
  103. params['coupons'] = self.coupons.to_alipay_dict()
  104. else:
  105. params['coupons'] = self.coupons
  106. if self.items:
  107. if isinstance(self.items, list):
  108. for i in range(0, len(self.items)):
  109. element = self.items[i]
  110. if hasattr(element, 'to_alipay_dict'):
  111. self.items[i] = element.to_alipay_dict()
  112. if hasattr(self.items, 'to_alipay_dict'):
  113. params['items'] = self.items.to_alipay_dict()
  114. else:
  115. params['items'] = self.items
  116. if self.logo_url:
  117. if hasattr(self.logo_url, 'to_alipay_dict'):
  118. params['logo_url'] = self.logo_url.to_alipay_dict()
  119. else:
  120. params['logo_url'] = self.logo_url
  121. if self.mini_shop_id:
  122. if hasattr(self.mini_shop_id, 'to_alipay_dict'):
  123. params['mini_shop_id'] = self.mini_shop_id.to_alipay_dict()
  124. else:
  125. params['mini_shop_id'] = self.mini_shop_id
  126. if self.shop_head_name:
  127. if hasattr(self.shop_head_name, 'to_alipay_dict'):
  128. params['shop_head_name'] = self.shop_head_name.to_alipay_dict()
  129. else:
  130. params['shop_head_name'] = self.shop_head_name
  131. if self.shop_id:
  132. if hasattr(self.shop_id, 'to_alipay_dict'):
  133. params['shop_id'] = self.shop_id.to_alipay_dict()
  134. else:
  135. params['shop_id'] = self.shop_id
  136. if self.shop_name:
  137. if hasattr(self.shop_name, 'to_alipay_dict'):
  138. params['shop_name'] = self.shop_name.to_alipay_dict()
  139. else:
  140. params['shop_name'] = self.shop_name
  141. return params
  142. @staticmethod
  143. def from_alipay_dict(d):
  144. if not d:
  145. return None
  146. o = TBMiniShopBo()
  147. if 'address' in d:
  148. o.address = d['address']
  149. if 'attribute' in d:
  150. o.attribute = d['attribute']
  151. if 'coupons' in d:
  152. o.coupons = d['coupons']
  153. if 'items' in d:
  154. o.items = d['items']
  155. if 'logo_url' in d:
  156. o.logo_url = d['logo_url']
  157. if 'mini_shop_id' in d:
  158. o.mini_shop_id = d['mini_shop_id']
  159. if 'shop_head_name' in d:
  160. o.shop_head_name = d['shop_head_name']
  161. if 'shop_id' in d:
  162. o.shop_id = d['shop_id']
  163. if 'shop_name' in d:
  164. o.shop_name = d['shop_name']
  165. return o