示例#1
0
文件: admin.py 项目: wickila/lunch
    def POST(self):
        user = lunch.get_current_user()
        if user and user.permission>10:
            data = web.input()
            opcode = int(data.opcode)
            id = int(data.id)
            try:
                reason = data.reason
            except:
                reason = ''
            applys = model.db.select('restapply',where='id=$id',vars=locals())
            if len(applys)>0:
                apl = applys[0]
                model.db.update('restapply',where='id=$id',state=opcode,reason=reason,vars=locals())
                if opcode == 1:
                    model.db.update('user',where='username=$apl.username',permission=1,vars=locals())
                    content = config.MESSAGE['rest_apply_accept']
                elif opcode == -1:
#                    model.db.update('user',where='username=$apl.username',permission=0,vars=locals())
                    content = config.MESSAGE['rest_apply_reject']+reason
                if opcode == 1 or opcode == -1:
                    model.db.insert('message',receiver=apl.username,messagetype=config.MESSAGE_TYPE['restapply'],content=content)
                apl.state = opcode
                apl.createdtime = str(apl.createdtime)
                return lunch.write_json({'result':True,'message':'success','apply':apl})
            else:
                return lunch.write_json({'result':False,'message':'apply dose not exite'})
示例#2
0
文件: api.py 项目: wickila/lunch
 def POST(self,id):
     user = lunch.get_current_user()
     post_data = web.input()
     state  = int(post_data.state)
     cancelreason = ''
     if 'cancelreason' in post_data:
         cancelreason = post_data.cancelreason
     if user:
         order = model.db.select('lunchorder',where='id=$id',vars=locals())
         if len(order)>0:
             order = order[0]
             t = datetime.datetime.strptime(order.modifiedtime,'%Y-%m-%d %H:%M:%S')
             if (order.bossusername == user.username and (not state == 3)) or (order.username == user.username and state == 3):
                 sql = None
                 if state == 1:
                     sql = "update restuarant set totalensure = totalensure+1,totalensuretime = totalensuretime+%d where username='******';"%((datetime.datetime.now()-datetime.datetime.strptime(order.modifiedtime,'%Y-%m-%d %H:%M:%S')).seconds,order.bossusername)
                 elif state == 2:
                     sql = "update restuarant set totaldelivery = totaldelivery+1,totaldeliverytime = totaldeliverytime+%d where username='******';"%((datetime.datetime.now()-datetime.datetime.strptime(order.modifiedtime,'%Y-%m-%d %H:%M:%S')).seconds,order.bossusername)
                 if sql:
                     model.db.query(sql)
                 model.db.update('lunchorder',where='id=$id',state=state, cancelreason=cancelreason,modifiedtime = str(datetime.datetime.now()).split('.')[0],vars=locals())
                 order.state = state
                 order.createdtime = str(order.createdtime).split('.')[0]
                 order.modifiedtime = str(datetime.datetime.now()).split('.')[0]
                 return lunch.write_json({'result':True,'message':'delete success','order':order})
         else:
             return lunch.write_json({'result':False,'message':'invlid order'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#3
0
文件: api.py 项目: wickila/lunch
 def POST(self,id):
     user = lunch.get_current_user()
     post_data = web.input(imgfile={})
     if user and user.permission>0:
         mns = model.db.select('menu',where='id=$id',vars=locals())
         if len(mns)>0:
             menu = mns[0]
             filedir = '/static/upload/menu-thumbnail'
             if not os.path.isdir('.'+filedir):
                 os.mkdir('.'+filedir)
             if 'imgfile' in post_data: # to check if the file-object is created
                 filepath=post_data.imgfile.filename.replace('\\','/') # replaces the windows-style slashes with linux ones.
                 filename=str(id)+'.'+filepath.split('/')[-1].split('.')[-1] # splits the and chooses the last part (the filename with extension)
                 fout = open('.'+filedir +'/'+ filename,'wb') # creates the file where the uploaded file should be stored
                 fout.write(post_data.imgfile.file.read()) # writes the uploaded file to the newly created file.
                 fout.close() # closes the file, upload complete.
                 pydic = {'imgurl':filedir +'/'+ filename}
                 model.db.update('menu',thumbnail=pydic['imgurl'],where='id=$id',vars=locals())
                 menu.thumbnail = pydic['imgurl']
                 pydic['menu'] = menu
                 pydic['message'] = 'success'
                 web.header('Content-Type', 'application/json')
                 return lunch.write_json(pydic)
         else:
             return lunch.write_json({'result':False,'message':'menu not found'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#4
0
文件: api.py 项目: wickila/lunch
 def POST(self,id):
     user = lunch.get_current_user()
     post_data = web.input()
     if user and user.permission>0:
         model.db.delete('concact',where='id=$id',vars=locals())
         return lunch.write_json({'result':True,'message':'delete success'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#5
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     user = lunch.get_current_user()
     if user:
         username = user.username
         concacts = model.db.select('concact',where='username=$username',vars=locals())
         ccs = [concact for concact in concacts]
         return lunch.write_json({'result':True,'message':'success','concacts':ccs})
     return lunch.write_json({'result':False,'message':'you hava not login'})
示例#6
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     post_data = web.input()
     if user:
         concactname = post_data.concactname
         adress = post_data.adress
         phone = post_data.phone
         id = model.db.insert('concact',username=user.username,concactname=concactname,adress=adress,phone=phone)
         return lunch.write_json({'result':True,'message':'success','concact':{'id':id,'username':user.username,'concactname':concactname,'adress':adress,'phone':phone}})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#7
0
文件: api.py 项目: wickila/lunch
 def POST(self,id):
     user = lunch.get_current_user()
     post_data = web.input()
     if user:
         concactname = post_data.concactname
         adress = post_data.adress
         phone = post_data.phone
         model.db.update('concact',where='id=$id',username=user.username,concactname=concactname,adress=adress,phone=phone)
         return lunch.write_json({'result':True,'message':'success'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#8
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     user = lunch.get_current_user()
     if user and user.permission>0:
         thumbnails = []
         rootdir = "./static/img/thumbnails"
         for parent, dirnames, filenames in os.walk(rootdir):
             for filename in filenames:
                 thumbnails.append({'src':'/static/img/thumbnails/'+filename,'name':filename})
         return lunch.write_json({'result':True,'thumbnails':thumbnails})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#9
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     data = web.input()
     receiver = data.receiver
     content = data.content
     messagetype = int(data.messagetype)
     user = lunch.get_current_user()
     if user:
         model.db.insert('message',receiver=receiver,content=content,sender=user.username,messagetype=messagetype)
         return lunch.write_json({'result':True,'message':'success'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
     
示例#10
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     if user:
         data = web.input()
         restname = data.restname
         adress = data.adress
         phone = data.phone
         message = data.message
         model.db.insert('restapply',restname=restname,adress=adress,phone=phone,message=message,username=user.username)
         return lunch.write_json({'result':True,'message':'success'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#11
0
文件: api.py 项目: wickila/lunch
 def GET(self,id):
     user = lunch.get_current_user()
     if user:
         order = model.db.select('lunchorder',where='id=$id',vars=locals())
         if len(order)>0:
             order = order[0]
             order.createdtime = str(order.createdtime).split('.')[0]
             return lunch.write_json({'result':True,'message':'delete success','order':order})
         else:
             return lunch.write_json({'result':False,'message':'invlid order'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#12
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     post_data = web.input()
     if user and user.permission>0:
         username = user.username
         rests = model.db.select('restuarant',where='username=$username',vars=locals())
         if len(rests)>0:
             name = post_data.name
             rest = rests[0]
             mtid = model.db.insert('menutype',name=name,username=username,rid=rest.id)
             menutype = model.db.select('menutype',where='id=$mtid',vars=locals())[0]
             return lunch.write_json({'result':True,'message':'success','menutype':menutype})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#13
0
文件: api.py 项目: wickila/lunch
 def GET(self,page):
     page = int(page)
     user = lunch.get_current_user()
     page_count = 10
     if user:
         sql = "select * from message where receiver='%s' order by id desc LIMIT %d, %d" % (user.username,(page-1)*page_count,page_count)
         total = len(model.db.query("select id from message where receiver='%s'" % user.username))
         messages = model.db.query(sql)
         msgs = []
         for message in messages:
             message.createdtime = str(message.createdtime)
             msgs.append(message)
         return lunch.write_json({'result':True,'message':'success','total':total,'messages':msgs})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#14
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     user = lunch.get_current_user()
     if user and user.permission>0:
         username=user.username
         rs = model.db.select('restuarant',where='username=$username',vars=locals())
         result = {'result':True,'message':'success'}
         if len(rs)>0:
             r = rs[0]
             rid = r.id
             menutypes = [menutype for menutype in model.db.select('menutype',where='rid=$rid',vars=locals())]
             r['menutypes'] = menutypes
             r.created_time = str(r.created_time)
             result['restuarant'] = r
         return lunch.write_json(result)
     return lunch.write_json({'result':False,'message':'you have not login or permission is not enough'})
示例#15
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     post_data = web.input()
     if user and user.permission>0:
         name = post_data.name
         description = post_data.description
         price = post_data.price
         discount = post_data.discount
         mtype = post_data.mtype
         thumbnail = post_data.thumbnail
         taste = int(post_data.taste)
         rid = model.db.query("select id from restuarant where username='******'" % user.username)[0].id
         mid = model.db.insert('menu',name=name,description=description,price=price,discount=discount,mtype=mtype,uid=user.id,rid=rid,thumbnail=thumbnail,taste=taste)
         mns = model.db.select('menu',where='id=$mid',vars=locals())
         m = mns[0]
         return lunch.write_json({'result':True,'message':'success','menu':m})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#16
0
文件: api.py 项目: wickila/lunch
 def POST(self,mid):
     user = lunch.get_current_user()
     post_data = web.input()
     if user and user.permission>0:
         name = post_data.name
         description = post_data.description
         price = post_data.price
         discount = post_data.discount
         mtype = post_data.mtype
         thumbnail = post_data.thumbnail
         state = int(post_data.state)
         taste = int(post_data.taste)
         model.db.update('menu',where='id=$mid',vars=locals(),name=name,description=description,price=price,discount=discount,mtype=mtype,thumbnail=thumbnail,soldout=state,taste=taste)
         mns = model.db.select('menu',where='id=$mid',vars=locals())
         m = mns[0]
         return lunch.write_json({'result':True,'message':'success','menu':m})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#17
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     data = web.input()
     restname = data.restname
     rests = model.db.select('restuarant',where='name=$restname',vars=locals())
     restuarants = []
     for restuarant in rests:
         restuarant.created_time = str(restuarant.created_time).split('.')[0]
         restuarants.append(restuarant)
     return lunch.write_json({'result':True,'restuarants':restuarants})
示例#18
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     user = lunch.get_current_user()
     post_data = web.input()
     try:
         page = int(post_data.page)
     except:
         page = 1
     page_count = 5
     if user:
         sql = "select * from lunchorder where username='******' order by id desc LIMIT %d, %d" % (user.username,(page-1)*page_count,page_count)
         orders = model.db.query(sql)
         total = len(model.db.query("select * from lunchorder where username='******'" % user.username))
         ods = []
         for order in orders:
             order.createdtime = str(order.createdtime)
             ods.append(order)
         return lunch.write_json({'result':True,'message':'seccuss','orders':ods,'total':total})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#19
0
文件: api.py 项目: wickila/lunch
 def GET(self,id):
     q = model.db.select('restuarant',where='id=$id',vars=locals())
     if len(q)>0:
         restuarant = q[0]
         rid = restuarant.id
         menutypes = [menutype for menutype in model.db.select('menutype',where='rid=$rid',vars=locals())]
         restuarant['menutypes'] = menutypes
         restuarant.created_time = str(restuarant.created_time)
     return lunch.write_json({'result':True,'restuarant':restuarant})
示例#20
0
文件: api.py 项目: wickila/lunch
 def POST(self,id):
     user = lunch.get_current_user()
     post_data = web.input()
     if user and user.permission>0:
         username = user.username
         rests = model.db.select('restuarant',where='username=$username',vars=locals())
         if len(rests)>0:
             rest = rests[0]
             menutypes = model.db.select('menutype',where='id=$id',vars=locals())
             if len(menutypes)>0:
                 menutype = menutypes[0]
                 if menutype.username == user.username:
                     model.db.delete('menutype',where='id=$id',vars=locals())
                     model.db.update('menu',where='mtype=$id',mtype=0)
                     return lunch.write_json({'result':True,'message':'success'})
                 return lunch.write_json({'result':False,'message':'you cant delete other persons menutype!'})
             else:
                 return lunch.write_json({'result':True,'message':'menutype does not exist'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#21
0
 def POST(self):
     user_data = web.input()
     name = user_data.name
     rtype = int(user_data.rtype)
     description = user_data.description
     adress = user_data.adress
     phone = user_data.phone
     minprice = int(user_data.minprice)
     maxdistance = int(user_data.maxdistance)
     starttime = user_data.starttime
     endtime = user_data.endtime
     enabled = user_data.enabled == 'true'
     user = lunch.get_current_user()
     if user and user.permission > 0:
         username = user.username
         rid = model.db.update('restuarant',where='username=$username',name=name,rtype=rtype,description=description,adress=adress,telephone=phone,minprice=minprice,maxdistance=maxdistance,starttime=starttime,endtime=endtime,enabled=enabled,vars=locals())
         r = model.db.select('restuarant',where='username=$username',vars=locals())[0]
         r.created_time = str(r.created_time)
         return lunch.write_json({'result':True,'message':'modified success!','restuarant':r})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#22
0
 def POST(self):
     user = lunch.get_current_user()
     if user:
         post_data = web.input(img={})
         filedir = '/static/upload/rest-avatar'
         if not os.path.isdir('.'+filedir):
             os.mkdir('.'+filedir)
         if 'img' in post_data: # to check if the file-object is created
             filepath=post_data.img.filename.replace('\\','/') # replaces the windows-style slashes with linux ones.
             filename=str(user.id)+'.'+filepath.split('/')[-1].split('.')[-1] # splits the and chooses the last part (the filename with extension)
             fout = open('.'+filedir +'/'+ filename,'wb') # creates the file where the uploaded file should be stored
             fout.write(post_data.img.file.read()) # writes the uploaded file to the newly created file.
             fout.close() # closes the file, upload complete.
             pydic = {'imgurl':filedir +'/'+ filename}
             username = user.username
             model.db.update('restuarant',avatarurl=pydic['imgurl'],where='username=$username',vars=locals())
             user.avatar_url = pydic['imgurl']
             web.header('Content-Type', 'application/json')
             return lunch.write_json(pydic)
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#23
0
 def POST(self):
     user_data = web.input()
     lat = float(user_data.lat)
     lng = float(user_data.lng)
     rest_name = user_data.rest_name
     adress = user_data.adress;
     user = lunch.get_current_user()
     dic = {'result':False,'type':0}
     if user and user.restnum==0:
         uid = user.id
         rests = model.db.query("select id from restuarant where username='******'" % user.username)
         if len(rests)>0:
             return lunch.write_json({'result':False,'message':'you already have a shop'})
         rest_id = model.db.insert('restuarant',hash_location=geohash.encode(lat, lng, 12),name=rest_name,username=user.username,lat=lat,lng=lng,adress=adress,maxdistance=500)
         rest = model.db.query('select * from restuarant where id=$rest_id',vars=locals())[0]
         rest.created_time = str(rest.created_time).split('.')[0]
         model.db.update('user',where='id=$uid',restnum=1,vars=locals())
         user.restnum = 1
         dic = {'result':True,'message':'success','type':1,'rest':rest}
         return lunch.write_json(dic)
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#24
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     post_data = web.input()
     oid = int(post_data.orderid)
     content = post_data.content
     thanks = int(post_data.thanks)
     if user:
         orders = model.db.select('lunchorder',where='id=$oid',vars=locals())
         if len(orders)>0:
             order = orders[0]
             if order.username == user.username:
                 rest = model.db.query("select * from restuarant where name='%s' and username='******'"%(order.restname,order.bossusername))[0]
                 if order.state == 3 or thanks>math.ceil(order.price/10):
                     model.db.update('lunchorder',where='id=$oid',state=4,vars=locals())
                     model.db.insert('comment',username=user.username,orderid=oid,content=content,thanks=thanks,rid=rest.id)
                     model.db.update('restuarant',where='id=$rest.id',thanks=rest.thanks+thanks,vars=locals())
                     return lunch.write_json({'result':True,'message':'success'})
                 return lunch.write_json({'result':False,'message':'invalid option'})
             return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
         return lunch.write_json({'result':False,'message':'invalid order'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#25
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     user = lunch.get_current_user()
     post_data = web.input()
     try:
         page = int(post_data.page)
     except:
         page = 1
     page_count = 5
     if user and user.permission>0:
         sql = "select * from lunchorder where bossusername='******' order by id desc LIMIT %d, %d" % (user.username,(page-1)*page_count,page_count)
         total = len(model.db.query("select id from lunchorder where bossusername='******'" % user.username))
         orders = model.db.query(sql)
         ods = []
         hasNew = False
         for order in orders:
             order.createdtime = str(order.createdtime)
             if (not hasNew) and (not order.isnew):
                 hasNew = True
                 model.db.update('lunchorder',where='bossusername=$user.username',isnew=1,vars=locals())
             ods.append(order)
         return lunch.write_json({'result':True,'message':'seccuss','orders':ods,'total':total,'hasNew':hasNew})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})
示例#26
0
文件: user.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     if user:
         username = user.username
         user_data = web.input()
         email = user_data.email
         pwd = user_data.email_pwd
         p_sha1 = hashlib.sha1(pwd).hexdigest()
         result = {'result':False,'message':'密码错误'}
         if user.password == p_sha1:
             model.db.update('user',where='username=$username',vars=locals(),email=email)
             web.config._session.user.email = email
             web.header('Content-Type', 'application/json')
             result = {'result':True,'message':'修改成功'}
         return lunch.write_json(result)
     raise web.seeother("/signin")
示例#27
0
文件: user.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     if user:
         post_data = web.input(img={})
         filedir = '/static/upload/avatar'
         if not os.path.isdir('.'+filedir):
             os.mkdir('.'+filedir)
         if 'img' in post_data: # to check if the file-object is created
             filepath=post_data.img.filename.replace('\\','/') # replaces the windows-style slashes with linux ones.
             filename=str(user.id)+'.'+filepath.split('/')[-1].split('.')[1] # splits the and chooses the last part (the filename with extension)
             fout = open('.'+filedir +'/'+ filename,'wb') # creates the file where the uploaded file should be stored
             fout.write(post_data.img.file.read()) # writes the uploaded file to the newly created file.
             fout.close() # closes the file, upload complete.
             pydic = {'imgurl':filedir +'/'+ filename}
             id = user.id
             model.db.update('user',avatarurl=pydic['imgurl'],where='id=$id',vars=locals())
             user.avatarurl = pydic['imgurl']
             web.header('Content-Type', 'application/json')
             return lunch.write_json(pydic)
     raise web.seeother('/signin')
示例#28
0
 def GET(self,id):
     data = web.input()
     page_count=10
     try:
         page = int(data.page)
     except:
         page = 1
     sql = "select * from comment where rid=%d order by id desc LIMIT %d, %d" % (int(id),(page-1)*page_count,page_count)
     comments = model.db.query(sql)
     cmts = []
     for comment in comments:
         u = model.db.query("select avatarurl from user where username='******'" % comment.username)
         avatarurl = ''
         if len(u) > 0:
             u = u[0]
             avatarurl = u.avatarurl
         comment.createdtime = str(comment.createdtime)
         comment['avatarurl'] = avatarurl
         cmts.append(comment)
     return lunch.write_json({'result':True,'message':'success','comments':cmts})
示例#29
0
文件: api.py 项目: wickila/lunch
 def GET(self):
     data = web.input()
     lat = float(data.lat)
     lng = float(data.lng)
     percision = 6
     if 'percision' in data:
         percision = int(data.percision)
     if percision>11:
         percision = 11
     elif percision<1:
         percision = 1
     hash_location = geohash.encode(lat, lng, 12)
     hash_location = hash_location[0:percision]
     neighbors = self.get_neighbors(hash_location,config.LOCATION_PRECISION)
     neighbors.sort()
     rs = model.db.query("SELECT * FROM restuarant WHERE hash_location >= '%s' AND hash_location <= '%s'" % (neighbors[0],neighbors[-1]))
     restuarants = []
     for restuarant in rs:
         restuarant.created_time = str(restuarant.created_time).split('.')[0]
         restuarants.append(restuarant)
     return lunch.write_json({'result':True,'restuarants':restuarants})
示例#30
0
文件: api.py 项目: wickila/lunch
 def POST(self):
     user = lunch.get_current_user()
     post_data = web.input()
     if user:
         concact = post_data.concact
         if not concact:
             return lunch.write_json({'result':False,'message':'invlid concact'})
         rid = post_data.rid
         message = post_data.message
         state = 0
         menus = post_data.menus
         menus = json.loads(menus)
         its = {}
         price = float(post_data.price)
         sql = 'select * from menu where'
         for i,menu in enumerate(menus):
             its[menu['id']] = menu
             sql += ' id=%s' % menu['id']
             if i<len(menus)-1:
                 sql+=' or'
         menus = model.db.query(sql)
         if len(menus) == len(menus):
             p = 0
             soldouts = []
             for menu in menus:
                 if menu.soldout == 0:
                     soldouts.append(menu)
                 p+=menu.price*menu.discount*0.1*int(its[menu.id]['num'])
             if len(soldouts)>0:
                 message = ','.join([menu.name for menu in soldouts])+'卖完啦,换换口味看?'
                 return lunch.write_json({'result':False,'message':message})
             if price-p<0.1:
                 rs = model.db.select('restuarant',where='id=$rid',vars=locals())
                 if len(rs)>0:
                     rest = rs[0]
                     oid = model.db.insert('lunchorder',username=user.username,concact=concact,bossusername=rest.username,message=message,menus=post_data.menus,price=price,restname=rest.name,modifiedtime=str(datetime.datetime.now()).split('.')[0])
                     order = model.db.select('lunchorder',where='id=$oid',vars=locals())[0]
                     order.createdtime = str(order.createdtime)
                     return lunch.write_json({'result':True,'message':'order success','order':order,'rid':rest.id})
                 return lunch.write_json({'result':False,'message':'invlid restuarant'})
             return lunch.write_json({'result':False,'message':'invlid price'})
         return lunch.write_json({'result':False,'message':'invlid menus'})
     return lunch.write_json({'result':False,'message':'you have not login or you permission is not enough'})