SaleProduct.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.ProductProvider import ProductProvider
  6. class SaleProduct(object):
  7. def __init__(self):
  8. self._channel_type = None
  9. self._id = None
  10. self._market_price = None
  11. self._product_provider = None
  12. self._sale_price = None
  13. self._status = None
  14. @property
  15. def channel_type(self):
  16. return self._channel_type
  17. @channel_type.setter
  18. def channel_type(self, value):
  19. self._channel_type = value
  20. @property
  21. def id(self):
  22. return self._id
  23. @id.setter
  24. def id(self, value):
  25. self._id = value
  26. @property
  27. def market_price(self):
  28. return self._market_price
  29. @market_price.setter
  30. def market_price(self, value):
  31. self._market_price = value
  32. @property
  33. def product_provider(self):
  34. return self._product_provider
  35. @product_provider.setter
  36. def product_provider(self, value):
  37. if isinstance(value, ProductProvider):
  38. self._product_provider = value
  39. else:
  40. self._product_provider = ProductProvider.from_alipay_dict(value)
  41. @property
  42. def sale_price(self):
  43. return self._sale_price
  44. @sale_price.setter
  45. def sale_price(self, value):
  46. self._sale_price = value
  47. @property
  48. def status(self):
  49. return self._status
  50. @status.setter
  51. def status(self, value):
  52. self._status = value
  53. def to_alipay_dict(self):
  54. params = dict()
  55. if self.channel_type:
  56. if hasattr(self.channel_type, 'to_alipay_dict'):
  57. params['channel_type'] = self.channel_type.to_alipay_dict()
  58. else:
  59. params['channel_type'] = self.channel_type
  60. if self.id:
  61. if hasattr(self.id, 'to_alipay_dict'):
  62. params['id'] = self.id.to_alipay_dict()
  63. else:
  64. params['id'] = self.id
  65. if self.market_price:
  66. if hasattr(self.market_price, 'to_alipay_dict'):
  67. params['market_price'] = self.market_price.to_alipay_dict()
  68. else:
  69. params['market_price'] = self.market_price
  70. if self.product_provider:
  71. if hasattr(self.product_provider, 'to_alipay_dict'):
  72. params['product_provider'] = self.product_provider.to_alipay_dict()
  73. else:
  74. params['product_provider'] = self.product_provider
  75. if self.sale_price:
  76. if hasattr(self.sale_price, 'to_alipay_dict'):
  77. params['sale_price'] = self.sale_price.to_alipay_dict()
  78. else:
  79. params['sale_price'] = self.sale_price
  80. if self.status:
  81. if hasattr(self.status, 'to_alipay_dict'):
  82. params['status'] = self.status.to_alipay_dict()
  83. else:
  84. params['status'] = self.status
  85. return params
  86. @staticmethod
  87. def from_alipay_dict(d):
  88. if not d:
  89. return None
  90. o = SaleProduct()
  91. if 'channel_type' in d:
  92. o.channel_type = d['channel_type']
  93. if 'id' in d:
  94. o.id = d['id']
  95. if 'market_price' in d:
  96. o.market_price = d['market_price']
  97. if 'product_provider' in d:
  98. o.product_provider = d['product_provider']
  99. if 'sale_price' in d:
  100. o.sale_price = d['sale_price']
  101. if 'status' in d:
  102. o.status = d['status']
  103. return o