PrizePriceStrategy.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class PrizePriceStrategy(object):
  6. def __init__(self):
  7. self._max_price = None
  8. self._min_price = None
  9. self._stragety_value = None
  10. self._strategy_type = None
  11. @property
  12. def max_price(self):
  13. return self._max_price
  14. @max_price.setter
  15. def max_price(self, value):
  16. self._max_price = value
  17. @property
  18. def min_price(self):
  19. return self._min_price
  20. @min_price.setter
  21. def min_price(self, value):
  22. self._min_price = value
  23. @property
  24. def stragety_value(self):
  25. return self._stragety_value
  26. @stragety_value.setter
  27. def stragety_value(self, value):
  28. self._stragety_value = value
  29. @property
  30. def strategy_type(self):
  31. return self._strategy_type
  32. @strategy_type.setter
  33. def strategy_type(self, value):
  34. self._strategy_type = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.max_price:
  38. if hasattr(self.max_price, 'to_alipay_dict'):
  39. params['max_price'] = self.max_price.to_alipay_dict()
  40. else:
  41. params['max_price'] = self.max_price
  42. if self.min_price:
  43. if hasattr(self.min_price, 'to_alipay_dict'):
  44. params['min_price'] = self.min_price.to_alipay_dict()
  45. else:
  46. params['min_price'] = self.min_price
  47. if self.stragety_value:
  48. if hasattr(self.stragety_value, 'to_alipay_dict'):
  49. params['stragety_value'] = self.stragety_value.to_alipay_dict()
  50. else:
  51. params['stragety_value'] = self.stragety_value
  52. if self.strategy_type:
  53. if hasattr(self.strategy_type, 'to_alipay_dict'):
  54. params['strategy_type'] = self.strategy_type.to_alipay_dict()
  55. else:
  56. params['strategy_type'] = self.strategy_type
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = PrizePriceStrategy()
  63. if 'max_price' in d:
  64. o.max_price = d['max_price']
  65. if 'min_price' in d:
  66. o.min_price = d['min_price']
  67. if 'stragety_value' in d:
  68. o.stragety_value = d['stragety_value']
  69. if 'strategy_type' in d:
  70. o.strategy_type = d['strategy_type']
  71. return o