Esempio n. 1
0
def counts():
    if request.method == 'POST':
        if auto.decodejwt(request.form['jwtstr']):

            try:
                newordercount = mongo.order.find({
                    'restaurant_id':
                    ObjectId(request.form["restaurant_id"]),
                    "status":
                    0
                }).count()
                newmessagecount = mongo.message.find({
                    "infoto." + str(request.form["restaurant_id"]):
                    0
                }).count()
                data = {}
                data['neworder'] = str(newordercount)
                data['newmessage'] = str(newmessagecount)
                result = tool.return_json(0, "success", True, data)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
            except Exception, e:
                print e
                result = tool.return_json(0, "field", False, None)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
        else:
            result = tool.return_json(0, "field", False, None)
            return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 2
0
def updateident():
    if request.method == 'POST':
        if auto.decodejwt(request.form['jwtstr']):

            try:
                lastlogin = {
                    "ident": request.form['ident'],
                    "type": request.form['type'],
                    "time": datetime.datetime.now()
                }
                item = mongouser.user_web.update({{
                    "_id":
                    ObjectId(request.form['user_web_id'])
                }, {
                    "$set": {
                        "lastlogin": lastlogin
                    }
                }})
                json = {"status": 1, "msg": ""}
                result = tool.return_json(0, "field", False, json)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
            except Exception, e:
                print e
                result = tool.return_json(0, "field", False, None)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
        else:
            result = tool.return_json(0, "field", False, None)
            return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 3
0
def webuserqrcode():
    if auto.decodejwt(request.form['jwtstr']):
        json = {
            "url": "/m/userQRCode/",
            "restaurant_id": request.form['restaurant_id'],
            "webuser_id": request.form['webuser_id']
        }

        result = tool.return_json(0, "success", True, json)
        return json_util.dumps(result, ensure_ascii=False, indent=2)
    else:
        result = tool.return_json(0, "field", False, None)
        return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 4
0
def dishsclass():
    if request.method == "POST":
        jwtstr = request.form["jwtstr"]
        restaurant_id = request.form["restaurant_id"]
    jwtmsg = auto.decodejwt(jwtstr)
    menu = mongo.restaurant.find_one({"_id": ObjectId(restaurant_id)}, {
        "menu.name": 1,
        "menu.id": 1,
        "_id": 0
    })
    json = menu
    result = tool.return_json(0, "success", jwtmsg, json)
    return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 5
0
def appversionvuser():
    if request.method == "POST":
        jwtstr = request.form["jwtstr"]
    jwtmsg = auto.decodejwt(jwtstr)
    json = {}
    if jwtmsg:
        item = mongo.android_version.find({
            "appid": 2
        }).sort("addtime", pymongo.DESCENDING)[0]
        json = {
            "url": item["url"],
            "version": item["version"],
            "describe": item["describe"]
        }
    result = tool.return_json(0, "success", jwtmsg, json)
    return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 6
0
def getqrcode():
    if request.method == 'POST':
        if auto.decodejwt(request.form['jwtstr']):

            try:
                item = mongo.webuser.find(
                    {"_id": ObjectId(request.form['webuser_id'])})
                qrcode_img = ''
                for i in item:
                    qrcode_img = i['qrcode_img']
                result = tool.return_json(0, "SUCCESS", True, qrcode_img)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
            except Exception, e:
                print e
                result = tool.return_json(0, "field", True, str(e))
                return json_util.dumps(result, ensure_ascii=False, indent=2)
        else:
            result = tool.return_json(0, "field", False, None)
            return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 7
0
def share():
    if request.method == 'POST':
        if auto.decodejwt(request.form['jwtstr']):
            try:
                item = mongo.fenxiang.find()
                json = {}
                for i in item:
                    json['title'] = i['Title']
                    json['content'] = i['Content']
                    json['img'] = i['img']
                    json['url'] = i['url']
                result = tool.return_json(0, "SUCCESS", True, json)
                return json_util.dumps(result, ensure_ascii=False, indent=2)
            except Exception, e:
                print e
                result = tool.return_json(0, "field", True, str(e))
                return json_util.dumps(result, ensure_ascii=False, indent=2)
        else:
            result = tool.return_json(0, "field", False, None)
            return json_util.dumps(result, ensure_ascii=False, indent=2)
Esempio n. 8
0
def addfeedbackvuser():
    # try:
    if request.method == 'POST':
        content = request.form['content']
        # email=request.form['email']
        webuserid = request.form['userid']
        jwtstr = request.form["jwtstr"]
    jwtmsg = auto.decodejwt(jwtstr)
    item = {
        "webuserid": ObjectId(webuserid),
        "email": "",
        "contents": content,
        "addtime": datetime.datetime.now(),
        "isread": 2,
        "reContents": "",
        "userid": ObjectId("000000000000000000000000"),
        "source": 2
    }
    feedback = mongo.addfeedback.insert_one(item)
    result = tool.return_json(0, "success", jwtmsg, {"status": True})
    return json_util.dumps(result, ensure_ascii=False, indent=2)