def getMatchGroup(self, u, ud): tomorrow = SysUtil.getTomorrow() # filter(or_(and_(MatchInfoD.date==tomorrow,MatchInfoD.matchTime < datetime.time(22,00,00)), # and_(MatchInfoD.date==SysUtil.getToday(),MatchInfoD.matchTime >= datetime.time(22,00,00)) )).\ matches = self.session.query(MatchInfoD).\ filter(MatchInfoD.date == tomorrow).\ filter(MatchInfoD.singleFlag == '1').\ filter(MatchInfoD.minrate > 0.1).\ order_by(MatchInfoD.wrate).all() count = 0 for m in matches: rateList = (m.wrate, m.drate, m.lrate) rateAIdex = SysUtil.getMaxIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.minrate < 1.46: if m.rankDValue > 8 or m.rankDValue < -8: rateAIdex = 0 rateBIdex = 2 if m.matchtypename == '欧洲杯' and m.minrate < 1.30: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.matchtypename == '奥运女足' and m.minrate < 1.351: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.matchtypename == '奥运男足' and m.minrate < 1.351: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) mA = MatchData(userid=u.userid, date=tomorrow, matchAID=m.matchid, matchAResult=SysUtil.getMatchResult(rateAIdex), rate=rateList[rateAIdex], singleFlag=GLBConfig.M_SINGLE) self.session.add(mA) mB = MatchData(userid=u.userid, date=tomorrow, matchAID=m.matchid, matchAResult=SysUtil.getMatchResult(rateBIdex), rate=rateList[rateBIdex], singleFlag=GLBConfig.M_SINGLE) self.session.add(mB) self.session.flush() count += 1 if count > 2: break if count > 0: self.calMoney(u, ud, count)
def getMatchDraw(date): matches = session.query(MatchInfo).\ filter(MatchInfo.date==date).\ filter(MatchInfo.singleFlag == '1').\ filter(MatchInfo.minrate > 0.1).\ order_by(MatchInfo.wrate).all() count = 0 if matches: for m in matches: rateList = (m.wrate,m.drate,m.lrate) rateAIdex = SysUtil.getMaxIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.minrate < 1.46: if m.rankDValue > 8 or m.rankDValue < -8: rateAIdex = 0 rateBIdex = 2 if m.matchtypename == '欧洲杯' and m.minrate < 1.30: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.matchtypename == '奥运女足' and m.minrate < 1.351: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) if m.matchtypename == '奥运男足' and m.minrate < 1.351: rateAIdex = SysUtil.getMinIndex(rateList) rateBIdex = SysUtil.getMidIndex(rateList) mA = MatchDataBatch(date = date, matchAID = m.matchid, matchAResult = SysUtil.getMatchResult(rateAIdex), rate = rateList[rateAIdex], singleFlag = GLBConfig.M_SINGLE) session.add(mA) mB = MatchDataBatch(date = date, matchAID = m.matchid, matchAResult = SysUtil.getMatchResult(rateBIdex), rate = rateList[rateBIdex], singleFlag = GLBConfig.M_SINGLE) session.add(mB) session.commit() count += 1 if count > 2: break return count
def getDealerMatch(self): dealers = self.session.query(Dealer).filter( Dealer.dealertype == GLBConfig.D_TYPE_C).all() for d in dealers: if len(self.session.query(DealerMatch).\ filter(DealerMatch.dealerid == d.uid).\ filter(DealerMatch.date == SysUtil.getTomorrow()).all()) > 0: continue if d.uid == 1: matches = self.session.query(MatchInfoD).\ filter(MatchInfoD.date == SysUtil.getTomorrow()).\ filter(MatchInfoD.minrate >= 2.0).\ filter(MatchInfoD.minrate <= 3.0).all() elif d.uid == 2: matches = self.session.query(MatchInfoD).\ filter(MatchInfoD.date == SysUtil.getTomorrow()).\ filter(MatchInfoD.minrate >= 1.0).\ filter(MatchInfoD.minrate <= 2.5).all() elif d.uid == 3: matches = self.session.query(MatchInfoD).\ filter(MatchInfoD.date == SysUtil.getTomorrow()).\ filter(MatchInfoD.minrate >= 1.5).\ filter(MatchInfoD.minrate <= 2.5).all() if len(matches) > 1: choice = random.sample(matches, 2) rateAList = (choice[0].wrate, choice[0].drate, choice[0].lrate) minRateAIdex = SysUtil.getMinIndex(rateAList) rateBList = (choice[1].wrate, choice[1].drate, choice[1].lrate) minRateBIdex = SysUtil.getMinIndex(rateBList) dm = DealerMatch( dealerid=d.uid, date=SysUtil.getTomorrow(), matchAID=choice[0].matchid, matchAResult=SysUtil.getMatchResult(minRateAIdex), matchBID=choice[1].matchid, matchBResult=SysUtil.getMatchResult(minRateBIdex), matchdesc='') self.session.add(dm) self.session.commit()