DiscountInfo.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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.VoucherDescDetailModel import VoucherDescDetailModel
  6. class DiscountInfo(object):
  7. def __init__(self):
  8. self._apply_condition = None
  9. self._buy_send_desc = None
  10. self._discount = None
  11. self._discount_notes = None
  12. self._distance = None
  13. self._end_time = None
  14. self._image_url = None
  15. self._item_id = None
  16. self._item_name = None
  17. self._label = None
  18. self._original_price = None
  19. self._per_price = None
  20. self._pid = None
  21. self._price = None
  22. self._reason = None
  23. self._send_item_name = None
  24. self._shop_id = None
  25. self._shop_name = None
  26. self._sold = None
  27. self._start_time = None
  28. self._threshold_price = None
  29. self._top_price = None
  30. self._type = None
  31. self._validity_period = None
  32. self._validity_period_range_from = None
  33. self._validity_period_range_to = None
  34. self._validity_period_type = None
  35. self._vol_type = None
  36. @property
  37. def apply_condition(self):
  38. return self._apply_condition
  39. @apply_condition.setter
  40. def apply_condition(self, value):
  41. self._apply_condition = value
  42. @property
  43. def buy_send_desc(self):
  44. return self._buy_send_desc
  45. @buy_send_desc.setter
  46. def buy_send_desc(self, value):
  47. self._buy_send_desc = value
  48. @property
  49. def discount(self):
  50. return self._discount
  51. @discount.setter
  52. def discount(self, value):
  53. self._discount = value
  54. @property
  55. def discount_notes(self):
  56. return self._discount_notes
  57. @discount_notes.setter
  58. def discount_notes(self, value):
  59. if isinstance(value, list):
  60. self._discount_notes = list()
  61. for i in value:
  62. if isinstance(i, VoucherDescDetailModel):
  63. self._discount_notes.append(i)
  64. else:
  65. self._discount_notes.append(VoucherDescDetailModel.from_alipay_dict(i))
  66. @property
  67. def distance(self):
  68. return self._distance
  69. @distance.setter
  70. def distance(self, value):
  71. self._distance = value
  72. @property
  73. def end_time(self):
  74. return self._end_time
  75. @end_time.setter
  76. def end_time(self, value):
  77. self._end_time = value
  78. @property
  79. def image_url(self):
  80. return self._image_url
  81. @image_url.setter
  82. def image_url(self, value):
  83. self._image_url = value
  84. @property
  85. def item_id(self):
  86. return self._item_id
  87. @item_id.setter
  88. def item_id(self, value):
  89. self._item_id = value
  90. @property
  91. def item_name(self):
  92. return self._item_name
  93. @item_name.setter
  94. def item_name(self, value):
  95. self._item_name = value
  96. @property
  97. def label(self):
  98. return self._label
  99. @label.setter
  100. def label(self, value):
  101. self._label = value
  102. @property
  103. def original_price(self):
  104. return self._original_price
  105. @original_price.setter
  106. def original_price(self, value):
  107. self._original_price = value
  108. @property
  109. def per_price(self):
  110. return self._per_price
  111. @per_price.setter
  112. def per_price(self, value):
  113. self._per_price = value
  114. @property
  115. def pid(self):
  116. return self._pid
  117. @pid.setter
  118. def pid(self, value):
  119. self._pid = value
  120. @property
  121. def price(self):
  122. return self._price
  123. @price.setter
  124. def price(self, value):
  125. self._price = value
  126. @property
  127. def reason(self):
  128. return self._reason
  129. @reason.setter
  130. def reason(self, value):
  131. self._reason = value
  132. @property
  133. def send_item_name(self):
  134. return self._send_item_name
  135. @send_item_name.setter
  136. def send_item_name(self, value):
  137. self._send_item_name = value
  138. @property
  139. def shop_id(self):
  140. return self._shop_id
  141. @shop_id.setter
  142. def shop_id(self, value):
  143. self._shop_id = value
  144. @property
  145. def shop_name(self):
  146. return self._shop_name
  147. @shop_name.setter
  148. def shop_name(self, value):
  149. self._shop_name = value
  150. @property
  151. def sold(self):
  152. return self._sold
  153. @sold.setter
  154. def sold(self, value):
  155. self._sold = value
  156. @property
  157. def start_time(self):
  158. return self._start_time
  159. @start_time.setter
  160. def start_time(self, value):
  161. self._start_time = value
  162. @property
  163. def threshold_price(self):
  164. return self._threshold_price
  165. @threshold_price.setter
  166. def threshold_price(self, value):
  167. self._threshold_price = value
  168. @property
  169. def top_price(self):
  170. return self._top_price
  171. @top_price.setter
  172. def top_price(self, value):
  173. self._top_price = value
  174. @property
  175. def type(self):
  176. return self._type
  177. @type.setter
  178. def type(self, value):
  179. self._type = value
  180. @property
  181. def validity_period(self):
  182. return self._validity_period
  183. @validity_period.setter
  184. def validity_period(self, value):
  185. self._validity_period = value
  186. @property
  187. def validity_period_range_from(self):
  188. return self._validity_period_range_from
  189. @validity_period_range_from.setter
  190. def validity_period_range_from(self, value):
  191. self._validity_period_range_from = value
  192. @property
  193. def validity_period_range_to(self):
  194. return self._validity_period_range_to
  195. @validity_period_range_to.setter
  196. def validity_period_range_to(self, value):
  197. self._validity_period_range_to = value
  198. @property
  199. def validity_period_type(self):
  200. return self._validity_period_type
  201. @validity_period_type.setter
  202. def validity_period_type(self, value):
  203. self._validity_period_type = value
  204. @property
  205. def vol_type(self):
  206. return self._vol_type
  207. @vol_type.setter
  208. def vol_type(self, value):
  209. self._vol_type = value
  210. def to_alipay_dict(self):
  211. params = dict()
  212. if self.apply_condition:
  213. if hasattr(self.apply_condition, 'to_alipay_dict'):
  214. params['apply_condition'] = self.apply_condition.to_alipay_dict()
  215. else:
  216. params['apply_condition'] = self.apply_condition
  217. if self.buy_send_desc:
  218. if hasattr(self.buy_send_desc, 'to_alipay_dict'):
  219. params['buy_send_desc'] = self.buy_send_desc.to_alipay_dict()
  220. else:
  221. params['buy_send_desc'] = self.buy_send_desc
  222. if self.discount:
  223. if hasattr(self.discount, 'to_alipay_dict'):
  224. params['discount'] = self.discount.to_alipay_dict()
  225. else:
  226. params['discount'] = self.discount
  227. if self.discount_notes:
  228. if isinstance(self.discount_notes, list):
  229. for i in range(0, len(self.discount_notes)):
  230. element = self.discount_notes[i]
  231. if hasattr(element, 'to_alipay_dict'):
  232. self.discount_notes[i] = element.to_alipay_dict()
  233. if hasattr(self.discount_notes, 'to_alipay_dict'):
  234. params['discount_notes'] = self.discount_notes.to_alipay_dict()
  235. else:
  236. params['discount_notes'] = self.discount_notes
  237. if self.distance:
  238. if hasattr(self.distance, 'to_alipay_dict'):
  239. params['distance'] = self.distance.to_alipay_dict()
  240. else:
  241. params['distance'] = self.distance
  242. if self.end_time:
  243. if hasattr(self.end_time, 'to_alipay_dict'):
  244. params['end_time'] = self.end_time.to_alipay_dict()
  245. else:
  246. params['end_time'] = self.end_time
  247. if self.image_url:
  248. if hasattr(self.image_url, 'to_alipay_dict'):
  249. params['image_url'] = self.image_url.to_alipay_dict()
  250. else:
  251. params['image_url'] = self.image_url
  252. if self.item_id:
  253. if hasattr(self.item_id, 'to_alipay_dict'):
  254. params['item_id'] = self.item_id.to_alipay_dict()
  255. else:
  256. params['item_id'] = self.item_id
  257. if self.item_name:
  258. if hasattr(self.item_name, 'to_alipay_dict'):
  259. params['item_name'] = self.item_name.to_alipay_dict()
  260. else:
  261. params['item_name'] = self.item_name
  262. if self.label:
  263. if hasattr(self.label, 'to_alipay_dict'):
  264. params['label'] = self.label.to_alipay_dict()
  265. else:
  266. params['label'] = self.label
  267. if self.original_price:
  268. if hasattr(self.original_price, 'to_alipay_dict'):
  269. params['original_price'] = self.original_price.to_alipay_dict()
  270. else:
  271. params['original_price'] = self.original_price
  272. if self.per_price:
  273. if hasattr(self.per_price, 'to_alipay_dict'):
  274. params['per_price'] = self.per_price.to_alipay_dict()
  275. else:
  276. params['per_price'] = self.per_price
  277. if self.pid:
  278. if hasattr(self.pid, 'to_alipay_dict'):
  279. params['pid'] = self.pid.to_alipay_dict()
  280. else:
  281. params['pid'] = self.pid
  282. if self.price:
  283. if hasattr(self.price, 'to_alipay_dict'):
  284. params['price'] = self.price.to_alipay_dict()
  285. else:
  286. params['price'] = self.price
  287. if self.reason:
  288. if hasattr(self.reason, 'to_alipay_dict'):
  289. params['reason'] = self.reason.to_alipay_dict()
  290. else:
  291. params['reason'] = self.reason
  292. if self.send_item_name:
  293. if hasattr(self.send_item_name, 'to_alipay_dict'):
  294. params['send_item_name'] = self.send_item_name.to_alipay_dict()
  295. else:
  296. params['send_item_name'] = self.send_item_name
  297. if self.shop_id:
  298. if hasattr(self.shop_id, 'to_alipay_dict'):
  299. params['shop_id'] = self.shop_id.to_alipay_dict()
  300. else:
  301. params['shop_id'] = self.shop_id
  302. if self.shop_name:
  303. if hasattr(self.shop_name, 'to_alipay_dict'):
  304. params['shop_name'] = self.shop_name.to_alipay_dict()
  305. else:
  306. params['shop_name'] = self.shop_name
  307. if self.sold:
  308. if hasattr(self.sold, 'to_alipay_dict'):
  309. params['sold'] = self.sold.to_alipay_dict()
  310. else:
  311. params['sold'] = self.sold
  312. if self.start_time:
  313. if hasattr(self.start_time, 'to_alipay_dict'):
  314. params['start_time'] = self.start_time.to_alipay_dict()
  315. else:
  316. params['start_time'] = self.start_time
  317. if self.threshold_price:
  318. if hasattr(self.threshold_price, 'to_alipay_dict'):
  319. params['threshold_price'] = self.threshold_price.to_alipay_dict()
  320. else:
  321. params['threshold_price'] = self.threshold_price
  322. if self.top_price:
  323. if hasattr(self.top_price, 'to_alipay_dict'):
  324. params['top_price'] = self.top_price.to_alipay_dict()
  325. else:
  326. params['top_price'] = self.top_price
  327. if self.type:
  328. if hasattr(self.type, 'to_alipay_dict'):
  329. params['type'] = self.type.to_alipay_dict()
  330. else:
  331. params['type'] = self.type
  332. if self.validity_period:
  333. if hasattr(self.validity_period, 'to_alipay_dict'):
  334. params['validity_period'] = self.validity_period.to_alipay_dict()
  335. else:
  336. params['validity_period'] = self.validity_period
  337. if self.validity_period_range_from:
  338. if hasattr(self.validity_period_range_from, 'to_alipay_dict'):
  339. params['validity_period_range_from'] = self.validity_period_range_from.to_alipay_dict()
  340. else:
  341. params['validity_period_range_from'] = self.validity_period_range_from
  342. if self.validity_period_range_to:
  343. if hasattr(self.validity_period_range_to, 'to_alipay_dict'):
  344. params['validity_period_range_to'] = self.validity_period_range_to.to_alipay_dict()
  345. else:
  346. params['validity_period_range_to'] = self.validity_period_range_to
  347. if self.validity_period_type:
  348. if hasattr(self.validity_period_type, 'to_alipay_dict'):
  349. params['validity_period_type'] = self.validity_period_type.to_alipay_dict()
  350. else:
  351. params['validity_period_type'] = self.validity_period_type
  352. if self.vol_type:
  353. if hasattr(self.vol_type, 'to_alipay_dict'):
  354. params['vol_type'] = self.vol_type.to_alipay_dict()
  355. else:
  356. params['vol_type'] = self.vol_type
  357. return params
  358. @staticmethod
  359. def from_alipay_dict(d):
  360. if not d:
  361. return None
  362. o = DiscountInfo()
  363. if 'apply_condition' in d:
  364. o.apply_condition = d['apply_condition']
  365. if 'buy_send_desc' in d:
  366. o.buy_send_desc = d['buy_send_desc']
  367. if 'discount' in d:
  368. o.discount = d['discount']
  369. if 'discount_notes' in d:
  370. o.discount_notes = d['discount_notes']
  371. if 'distance' in d:
  372. o.distance = d['distance']
  373. if 'end_time' in d:
  374. o.end_time = d['end_time']
  375. if 'image_url' in d:
  376. o.image_url = d['image_url']
  377. if 'item_id' in d:
  378. o.item_id = d['item_id']
  379. if 'item_name' in d:
  380. o.item_name = d['item_name']
  381. if 'label' in d:
  382. o.label = d['label']
  383. if 'original_price' in d:
  384. o.original_price = d['original_price']
  385. if 'per_price' in d:
  386. o.per_price = d['per_price']
  387. if 'pid' in d:
  388. o.pid = d['pid']
  389. if 'price' in d:
  390. o.price = d['price']
  391. if 'reason' in d:
  392. o.reason = d['reason']
  393. if 'send_item_name' in d:
  394. o.send_item_name = d['send_item_name']
  395. if 'shop_id' in d:
  396. o.shop_id = d['shop_id']
  397. if 'shop_name' in d:
  398. o.shop_name = d['shop_name']
  399. if 'sold' in d:
  400. o.sold = d['sold']
  401. if 'start_time' in d:
  402. o.start_time = d['start_time']
  403. if 'threshold_price' in d:
  404. o.threshold_price = d['threshold_price']
  405. if 'top_price' in d:
  406. o.top_price = d['top_price']
  407. if 'type' in d:
  408. o.type = d['type']
  409. if 'validity_period' in d:
  410. o.validity_period = d['validity_period']
  411. if 'validity_period_range_from' in d:
  412. o.validity_period_range_from = d['validity_period_range_from']
  413. if 'validity_period_range_to' in d:
  414. o.validity_period_range_to = d['validity_period_range_to']
  415. if 'validity_period_type' in d:
  416. o.validity_period_type = d['validity_period_type']
  417. if 'vol_type' in d:
  418. o.vol_type = d['vol_type']
  419. return o