Пример #1
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
Пример #2
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)