def post(self): json = request.get_json() dao = OrderDao() peo_count = json.get("peo_count") child_count = json.get("child_count") scenicid = json.get("scenicid") date = request.form.get("date") price = request.form.get("price") order_time = datetime.now() username = json.get("username") phone_num = json.get("phone_num") email = json.get("email") token = json.get("token") p_num = r.get(token) user_dao = UserDao() user_id = user_dao.user_id_list(p_num) todao = TeOrderDao() order_code = todao.next_order_num() try: dao.save("travel_infor", **{ "code":order_code, "order_status":0, "start_time":date, "order_time":order_time, "price":price, "scenic_id":scenicid, "user_id": user_id }) dao.save("contact_infor",**{ "name":username, "phone_num":phone_num, "email":email, "user_id":user_id }) order_id = dao.order_list(order_code) dao.save("order_detail", **{ "adult_num": peo_count, "child_num": child_count, "flight_id": 1, "insurance": 1, "order_id":order_id }) return jsonify({ "code": 703, "msg": "成功!" }) except: return jsonify({ "code": 704, "msg": "保存失败!" })
def order_list(): try: token = request.args.get("token") if not token: return jsonify({"code": 400, "msg": "您还未登录,请先登录!"}) user_id = get_token_user_id(token) # 通过token获取id dao = OrderDao() data = dao.order_list(user_id) return jsonify({"code": 200, "msg": "添加购物车成功", "data": data}) except: return jsonify({"code": 400, "msg": "获取订单列表成功"})