def matchCalcMoney(self, u, dealerid): udata = self.session.query(UserData).filter( UserData.userid == u.userid).first() if udata is None: self.errorReturn(GLBConfig.API_ERROR, '目标金额未设置.') self.matchresult(u, udata, SysUtil.getYesterday()) self.matchresult(u, udata, SysUtil.getToday()) ct = self.session.query(func.count('*')).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date == SysUtil.getToday()).\ filter(func.abs(MatchData.ResultMoney) < 0.001).scalar() if datetime.datetime.now().time() < datetime.time(19, 0, 0): if ct != 0: self.errorReturn(GLBConfig.API_ERROR, '有比赛结果未出.') self.getMatch(u, udata, dealerid)
def matchCalcMoney(self, u, udata, req_para): self.matchresult(u, udata, SysUtil.getLast2()) self.matchresult(u, udata, SysUtil.getYesterday()) self.matchresult(u, udata, SysUtil.getToday()) ct = self.session.query(func.count('*')).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date == SysUtil.getToday()).\ filter(func.abs(MatchData.ResultMoney) < 0.001).scalar() if datetime.datetime.now().time() < datetime.time(19, 0, 0): if ct != 0: self.errorReturn(GLBConfig.API_ERROR, '有比赛结果未出.') self.session.commit() self.session.query(MatchData).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date == SysUtil.getTomorrow()).delete() self.session.flush() if u.accounttype == GLBConfig.ATYPE_GROUP: self.getMatchGroup(u, udata) elif u.accounttype == GLBConfig.ATYPE_PERSION: if udata.mode == GLBConfig.MODE_A: if 'dealerid' in req_para.keys(): self.getMatchModeA(u, udata, req_para['dealerid']) if 'matchA' in req_para.keys(): self.getMatchModeASelfChoice(u, udata, req_para['matchA'], req_para['AResult'], req_para['matchB'], req_para['BResult']) if udata.mode == GLBConfig.MODE_B: self.getMatchModeB(u, udata) if udata.mode == GLBConfig.MODE_C: self.getMatchModeC(u, udata, req_para['matchid']) if udata.mode == GLBConfig.MODE_D: self.getMatchModeD(u, udata, req_para['matchid'])
def matchCalcMoney(self, u): udata = self.session.query(UserData).filter( UserData.userid == u.userid).first() if udata is None: self.errorReturn(GLBConfig.API_ERROR, '目标金额未设置.') ct = self.session.query(func.count('*')).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date == SysUtil.getToday()).\ filter(MatchData.ResultMoney == 0).scalar() if datetime.datetime.now().time() < datetime.time(19, 0, 0): if ct != 0: self.errorReturn(GLBConfig.API_ERROR, '有比赛结果未出.') mCount = self.getMatch(u) if mCount > 0: self.calMoney(u, udata, mCount)
def run(self): self.initialize() self.session.query(MatchInfo500D).delete() self.session.flush() urlid500W = 'http://trade.500.com/jczq/?date=' + SysUtil.getToday( ).isoformat() + '&playtype=both' content500W = urllib.request.urlopen(urlid500W, timeout=10).read() message500W = content500W.decode('gbk') soup500W = BeautifulSoup(message500W, 'html.parser') tb500Wdate = soup500W.findAll('div', 'bet_date') for i in range(0, len(tb500Wdate)): dateInfo = self.getDate(tb500Wdate[i].contents[0]) tb500Wtb = soup500W.findAll('table', 'bet_table') trs500W = tb500Wtb[i].findAll('tr') self.getMatchSync(trs500W, dateInfo, i) self.getDealerMatch() self.release()