def get(self): dao = OrderDao() data = dao.tn_list("travel_infor") if data: return jsonify({ "code":701, "msg":"成功!", "data":data }) else: return jsonify({ "code": 702, "msg": "没有数据!" })
def post(self): json = request.get_json() dao = OrderDao() peo_count = json.get("peo_count") child_count = json.get("child_count") if child_count is None: child_count = 0 date = json.get("date") price = json.get("price") scenicid = json.get("scenicid") scenic_name = dao.scenic_list("scenics",scenicid)[0]["name"] cityname = json.get("cityname") price_z = price*peo_count + price*child_count*0.8 lals = getcode(scenic_name) dao.scenic_insert(lals,scenicid) lal = getcode(cityname) # 经纬度 dis = dao.travel_type(lal[1],lal[0],scenicid) sc_items = dao.scenic_list("scenics", scenicid) cityid = sc_items[0]["city_id"] city_dao = CityDao() sc_city_name = city_dao.city_name(cityid)[0]["name"] if float(dis[0]["dis"]) > 800: f_dict = { "出发地":cityname, "目的地":sc_city_name, "出发日期":date, "出发时间":"07:05", "到达时间":"09:25", "类型":"惠选经济舱", "航班号":"国航HU7137", "飞行时间":"2小时20分钟" } else: f_dict = { "出发时间":"07:00:00", "返回": "国贸", "备注": "距离远的游客请自行前往集合点" } ins_items = dao.tn_list("insurances") return jsonify({ "code":8103, "msg":"返回数据!", "data":{ "scenic_name":scenic_name, "pro_code":"210107045", "peo_count":peo_count, "child_count":child_count, "date":date, "f_dict":f_dict, "insurances":ins_items, "price_z":price_z } })