Пример #1
0
    def getMatch(self, u, udata, dealerid):
        tomorrow = SysUtil.getTomorrow()
        self.session.query(MatchData).\
            filter(MatchData.userid == u.userid).\
            filter(MatchData.date == tomorrow).delete()

        self.session.flush()

        matches = self.session.query(DealerMatch).\
            filter(DealerMatch.dealerid == int(dealerid)).\
            filter(DealerMatch.date == SysUtil.getTomorrow()).first()

        if matches is None:
            self.errorReturn(GLBConfig.API_ERROR, '无推荐内容.')

        ma = self.session.query(MatchInfoD).filter(
            MatchInfoD.matchid == matches.matchAID).first()
        mb = self.session.query(MatchInfoD).filter(
            MatchInfoD.matchid == matches.matchBID).first()

        listA = (ma.wrate, ma.drate, ma.lrate)
        listB = (mb.wrate, mb.drate, mb.lrate)

        account = self.session.query(AccountRunning).\
            filter(AccountRunning.userid == u.userid).\
            filter(AccountRunning.date < tomorrow).\
            order_by(AccountRunning.date.desc()).first()

        money = 0.0
        if account:
            if account.riskMoney < 0:
                money = account.riskMoney

        rate = listA[SysUtil.getResultIndex(
            matches.matchAResult)] * listB[SysUtil.getResultIndex(
                matches.matchBResult)]
        mMoney = (udata.basemony - money) / (rate - 1.00)

        md = MatchData(userid=u.userid,
                       date=tomorrow,
                       matchAID=matches.matchAID,
                       matchAResult=matches.matchAResult,
                       matchBID=matches.matchBID,
                       matchBResult=matches.matchBResult,
                       rate=rate,
                       money=mMoney,
                       singleFlag='2')
        self.session.add(md)
        self.session.flush(md)
Пример #2
0
    def getMatchModeASelfChoice(self, u, udata, matchA, AResult, matchB,
                                BResult):
        tomorrow = SysUtil.getTomorrow()
        ma = self.session.query(MatchInfoD).filter(
            MatchInfoD.matchid == matchA).first()
        if ma is None:
            self.errorReturn(GLBConfig.API_ERROR, '比赛不存在.')
        mb = self.session.query(MatchInfoD).filter(
            MatchInfoD.matchid == matchB).first()
        if mb is None:
            self.errorReturn(GLBConfig.API_ERROR, '比赛不存在.')

        listA = (ma.wrate, ma.drate, ma.lrate)
        listB = (mb.wrate, mb.drate, mb.lrate)

        account = self.session.query(AccountRunning).\
            filter(AccountRunning.userid == u.userid).\
            filter(AccountRunning.status == GLBConfig.ENABLE).\
            filter(AccountRunning.date < tomorrow).\
            order_by(AccountRunning.date.desc()).first()

        money = 0.0
        if account:
            if account.riskMoney < 0:
                money = account.riskMoney

        rate = listA[SysUtil.getResultIndex(AResult)] * listB[
            SysUtil.getResultIndex(BResult)]
        mMoney = (udata.basemoney - money) / (rate - 1.00)

        md = MatchData(userid=u.userid,
                       date=tomorrow,
                       matchAID=matchA,
                       matchAResult=AResult,
                       matchBID=matchB,
                       matchBResult=BResult,
                       rate=rate,
                       money=mMoney,
                       singleFlag='2')
        self.session.add(md)
        self.session.flush()