You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

73 lines
1.7 KiB

  1. import re
  2. from common import util
  3. from official.model import ProdCategory
  4. from django.conf import settings
  5. from common import curl_interface
  6. import time
  7. def get_prod_info(prod_id):
  8. """
  9. 获取巴士产品信息
  10. :param prod_id:
  11. :return:
  12. """
  13. # 参数校验
  14. if re.match('^[1-9][0-9]{0,10}', prod_id) is None:
  15. return util.re_err('参数错误')
  16. # 数据获取
  17. get_info = ProdCategory.get_bus_line_prod(prod_id)
  18. if get_info['category_id'] != 1:
  19. return util.re_err('该产品不是巴士产品')
  20. # 获取价格日历
  21. date_price = get_date_price(prod_id)
  22. if date_price['flag'] is False:
  23. return date_price
  24. res = {
  25. 'prod_info': get_info,
  26. 'date_list': date_price['data']['list']
  27. }
  28. return util.re_su('', res)
  29. def get_line_stock(prod_id, date):
  30. """
  31. 获取产品库存
  32. :param prod_id:
  33. :param date:
  34. :return:
  35. """
  36. send_data = {
  37. 'pro_cate_id': prod_id,
  38. 'date': date
  39. }
  40. curl = curl_interface.CurlInterface(send_data, 4)
  41. get_stock = curl.exec(settings.WX_HOST + '/zzcx/home/bus/get-line-bus-stock', 'POST')
  42. return get_stock
  43. def get_date_price(prod_id):
  44. """
  45. 获取价格日历
  46. :param line_id:
  47. :return:
  48. """
  49. send_data = {
  50. 'pro_cate_id': prod_id,
  51. }
  52. curl = curl_interface.CurlInterface(send_data, 4)
  53. ticket_arr_cs = curl.exec(settings.WX_HOST + '/zzcx/home/bus/get-line-sale-date', 'POST')
  54. return ticket_arr_cs
  55. def get_prod_array(prod_id):
  56. """
  57. 获取票种数组
  58. :param prod_id:
  59. :return:
  60. """
  61. get_arr = ProdCategory.get_prod_array(prod_id)
  62. return util.re_su('', {'list': get_arr})