示例#1
0
    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": "保存失败!"
            })
示例#2
0
 def post(self):
     json = request.get_json()
     name = json.get("name")
     phone_num = json.get("phone_num")
     email = json.get("email")
     document_type = json.get("document_type")
     id_number = json.get("id_number")
     token = json.get("token")
     p_num = r.get(token)
     user_dao = UserDao()
     user_id = user_dao.user_id_list(p_num)
     dao = OrderDao()
     try:
         dao.save("travel_infor",**{
             "name":name,
             "phone_num":phone_num,
             "email":email,
             "document_type":document_type,
             "id_number":id_number,
             "user_id":user_id
         })
         return jsonify({
             "code":705,
             "msg":"成功!",
             "data":{
                 "name":name,
                 "phone_num":phone_num,
                 "email":email,
                 "document_type":document_type,
                 "id_number":id_number
             }
         })
     except:
         return jsonify({
             "code":706,
             "msg":"保存失败!"
         })