예제 #1
0
    def POST(self):
        params=web.input()
        cid=int(params.get('cid'))
        content=params.get('content')
        from_uid=int(params.get("from_uid",1))
        piclist=params.get('piclist','')
        if len(piclist):
            piclist=piclist.split(',')
        else:
            piclist=[]
        mid=None
        if params.get('mid'):
            mid=int(params.get('mid'))

        newpost=CirclePost()
        newpost.picture_list=piclist
        newpost.cid=cid
        newpost.uid=from_uid
        newpost.content=content
        newpost.mid=mid
        newpost.save()
        json_msg=DefJsonEncoder.encode(newpost.toJson())
        pusher.rawPush(body=json_msg,
                                            routing_key="sys.circle_new_board",headers={"type":"circle.newpost"})
        return DefJsonEncoder.encode({"postid":newpost.postid})
예제 #2
0
    def POST(self):
        imgdata=json.loads(web.data())
        with dbconfig.Session() as session:
            newmsg=datamodel.message.Message()
            newmsg.fromid=imgdata['uid']
            newmsg.toid=imgdata['toid']
            content_data=imgdata.get('content')
            if content_data:
                newmsg.content=urllib.unquote_plus(content_data.encode('ascii')).decode('utf-8')
            fileurl=self.SITE+imgdata['hash']
            filetype=int(imgdata['filetype'])
            if filetype==1:
                newmsg.picture=fileurl
                newmsg.width=imgdata['width']
                newmsg.height=imgdata['height']
            elif filetype==2:
                newmsg.voice=fileurl
                newmsg.length=imgdata['length']
            elif filetype==3:
                newmsg.video=fileurl
                newmsg.length=imgdata['length']
            newmsg=session.merge(newmsg)
            session.commit()
            try:
                json_post=json.dumps(newmsg.toJson(),cls=AutoFitJson)
                pusher.rawPush(routing_key='sys.message_to_notify',headers={},body=json_post)
            except Exception,e:
                return json.dumps({'errno':5,'error':str(e)})

            return json.dumps({"errno":0,"error":"Success","result":{"url":fileurl,'msgid':newmsg.msgid}},cls=AutoFitJson)
예제 #3
0
    def POST(self):
        params=web.input()
        cid=int(params.get('cid'))
        from_uid=int(params.get("from_uid",1))
        roleids=[int(one) for one in params.get('roleid',"0").split(',')]
        if not cid:
            return 'need cid'
        content=params.get('content')
        if not content:
            return 'need content'

        with dbconfig.Session() as session:
            query_params=UserCircle.cid==cid
            if len(roleids)>0 and 0 not in roleids:
                query_params=and_(query_params,UserCircle.roleid.in_(roleids))
            allUser=session.query(UserCircle).filter(query_params).all()
            alluid=[one.uid for one in allUser]
            newmsgs=[]
            for to_uid in alluid:
                newmsg=Message()
                newmsg.toid=to_uid
                newmsg.fromid=from_uid
                newmsg.content=content
                newmsg=session.merge(newmsg)
                newmsgs.append(newmsg)
            session.commit()
            msgids=[]
            for newmsg in newmsgs:
                msgids.append(newmsg.msgid)
                json_msg=DefJsonEncoder.encode(newmsg.toJson())
                pusher.rawPush(body=json_msg,headers={},
                                                    routing_key='sys.message_to_notify')

            return DefJsonEncoder.encode({'msgid':msgids})
예제 #4
0
    def Check(self):
        params=web.input()
        data=params['data']
        encryptkey=params['encryptkey']

        mer=MerchantAPI()
        result=mer.result_decrypt({'data':data,
                            'encryptkey':encryptkey})
        with dbconfig.Session() as session:
            paystate=session.query(StorePayState).filter(StorePayState.orderid==result['orderid']).first()
            if paystate.paystate==1:
                return True
            paystate.paystate=1 if result['status']==1 else -1
            paystate.paytime=datetime.datetime.now()
            paystate.yborderid=result['yborderid']
            paystate.remain=result['amount']
            session.merge(paystate)

            sm=session.query(StoreMerchandise).filter(StoreMerchandise.mid==paystate.mid).first()
            log=StorePayLog(sm,paystate)
            log=session.merge(log)
            session.commit()

            try:
                json_post=DefJsonEncoder.encode(log.toJson())
                pusher.rawPush(exchange="system",routing_key='sys.paylog',headers={},body=json_post)
                return True
            except Exception,e:
                return False
예제 #5
0
    def POST(self):
        imgdata = json.loads(web.data())
        with dbconfig.Session() as session:
            newmsg = datamodel.message.Message()
            newmsg.fromid = imgdata["uid"]
            newmsg.toid = imgdata["toid"]
            content_data = imgdata.get("content")
            if content_data:
                newmsg.content = urllib.unquote_plus(content_data.encode("ascii")).decode("utf-8")
            fileurl = dbconfig.qiniuDownLoadLinkHead + imgdata["hash"]
            filetype = int(imgdata["filetype"])
            if filetype == 1:
                newmsg.picture = fileurl
                newmsg.width = imgdata["width"]
                newmsg.height = imgdata["height"]
            elif filetype == 2:
                newmsg.voice = fileurl
                newmsg.length = imgdata["length"]
            elif filetype == 3:
                newmsg.video = fileurl
                newmsg.length = imgdata["length"]
            newmsg = session.merge(newmsg)
            session.commit()
            try:
                json_post = json.dumps(newmsg.toJson(), cls=AutoFitJson)
                pusher.rawPush(routing_key="sys.message_to_notify", headers={}, body=json_post)
            except Exception, e:
                return json.dumps({"errno": 5, "error": str(e)})

            return json.dumps(
                {"errno": 0, "error": "Success", "result": {"url": fileurl, "msgid": newmsg.msgid}}, cls=AutoFitJson
            )
예제 #6
0
    def Check(self):
        all=web.input()
        tp=paylib.tenpaylib.tenpay()
        if tp.VerifySign(all):
            ps=datamodel.tenpaylog.TenpayState.objects(orderid=all['sp_billno']).first()
            new_pay_state=1 if int(all['pay_result'])==0 else -1
            if ps.paystate==new_pay_state:
                return True
            ps.paystate=new_pay_state
            ps.paytime=datetime.datetime.now()
            ps.transaction_id=all['transaction_id']
            ps.remain=all['total_fee']
            ps.save()

            pl=datamodel.tenpaylog.TenpayLog()
            pl.set_paystate(ps)
            pl.pay_info=all.get('pay_info')
            pl.bank_type=all.get('bank_type')
            pl.bank_billno=all.get('bank_billno')
            pl.time_end=all.get('time_end')
            pl.purchase_alias=all.get('purchase_alias')
            pl.save()

            try:
                json_post=DefJsonEncoder.encode(pl.toJson())
                pusher.rawPush(exchange="system",routing_key='sys.paylog',headers={},body=json_post)
            except Exception,e:
                print e
            return True
예제 #7
0
    def GET(self):
        try:
            params=web.input()
            payid=int(params.get("payid"))
            paylog=TenpayLog.objects(payid=payid).first()

            json_post=DefJsonEncoder.encode(paylog.toJson())
            pusher.rawPush(exchange="system",routing_key='sys.paylog',headers={},body=json_post)
            return "ok"
        except Exception,e:
            return traceback.format_exc()
예제 #8
0
    def GET(self):
        try:
            params=web.input()
            payid=params.get("payid")
            with dbconfig.Session() as session:
                paylog=session.query(StorePayLog).filter(StorePayLog.payid==payid).first()

                json_post=DefJsonEncoder.encode(paylog.toJson())
                pusher.rawPush(exchange="system",routing_key='sys.paylog',headers={},body=json_post)
                return "ok"
        except Exception,e:
            return False
예제 #9
0
 def POST(self):
     params=web.input()
     cid=int(params.get('cid'))
     board=params.get('board')
     with dbconfig.Session() as session:
         cdef=session.query(CircleDef).filter(CircleDef.cid==cid).first()
         cdef.board=board
         cdef=session.merge(cdef)
         cbhistory=CircleBoardHistory()
         cbhistory.cid=cid
         cbhistory.board=board
         cbhistory=session.merge(cbhistory)
         session.commit()
         pusher.rawPush(routing_key="sys.circle_new_board",headers={"type":"circle.newboard"},body=DefJsonEncoder.encode(cbhistory.toJson()))
     return DefJsonEncoder.encode({"cid":cid,"board":board})
예제 #10
0
    def POST(self):
        imgdata = json.loads(web.data())
        with dbconfig.Session() as session:
            newpost = datamodel.post.Post()
            newpost.uid = imgdata['uid']
            newpost.group_id = imgdata['gid']
            content_data = imgdata.get('content')
            if content_data:
                newpost.content = urllib.unquote_plus(
                    content_data.encode('ascii')).decode('utf-8')
            fileurl = self.SITE + imgdata['hash']
            filetype = int(imgdata['filetype'])
            if filetype == 1:
                newpost.picture = fileurl
                newpost.width = imgdata['width']
                newpost.height = imgdata['height']
            elif filetype == 2:
                newpost.voice = fileurl
                newpost.length = imgdata['length']
            elif filetype == 3:
                newpost.video = fileurl
                newpost.length = imgdata['length']
            newpost = session.merge(newpost)
            session.commit()
            try:
                json_post = json.dumps(newpost.toJson(), cls=AutoFitJson)
                pusher.rawPush(routing_key='sys.post_to_notify',
                               headers={},
                               body=json_post)
            except Exception, e:
                return json.dumps({'errno': 5, 'error': str(e)})

            return json.dumps(
                {
                    "errno": 0,
                    "error": "Success",
                    "result": {
                        "url": fileurl,
                        'postid': newpost.postid
                    }
                },
                cls=AutoFitJson)
예제 #11
0
    def POST(self):
        params=web.input(from_uid=1)
        from_uid=int(params.get('from_uid',1))
        to_uid=int(params.get('to_uid',0))
        if not to_uid:
            return 'need to_uid'
        content=params.get('content')
        if not content:
            return 'need content'

        with dbconfig.Session() as session:
            newmsg=Message()
            newmsg.toid=to_uid
            newmsg.fromid=from_uid
            newmsg.content=content
            newmsg=session.merge(newmsg)
            session.commit()

            json_msg=DefJsonEncoder.encode(newmsg.toJson())
            pusher.rawPush(body=json_msg,headers={},
                                                routing_key='sys.message_to_notify')
            return DefJsonEncoder.encode({'msgid':newmsg.msgid})
예제 #12
0
                    StorePayState.create_time > time_min,
                )
            )
            .all()
        )
        # all_pay=session.query(StorePayState).filter(StorePayState.paystate==0).all()
        for pay in all_pay:
            payinfo = mer.QueryPay(pay.orderid, "")
            print(payinfo)
            if "error_code" in payinfo:
                pay.paystate = -1
                session.merge(pay)
            else:
                pay.paystate = 1
                pay.paytime = datetime.datetime.now()
                pay.yborderid = payinfo["yborderid"]
                pay.remain = payinfo["amount"]
                session.merge(pay)
                sm = session.query(StoreMerchandise).filter(StoreMerchandise.mid == pay.mid).first()
                log = StorePayLog(sm, pay)
                log = session.merge(log)
                session.commit()

                try:
                    json_post = DefJsonEncoder.encode(log.toJson())
                    pusher.rawPush(exchange="system", routing_key="sys.paylog", headers={}, body=json_post)
                except Exception, e:
                    pass
        session.commit()
    time.sleep(30)