def on_get(self, req, resp): self.initialize() req_para = falcon.util.uri.parse_query_string(req.query_string) matches = [] if 'userid' in req_para.keys(): u = self.session.query(User).filter( User.userid == req_para['userid']).first() if u is None: self.errorReturn(GLBConfig.API_ERROR, '用户不存在.') for md, mi, m in self.session.query(MatchData, MatchInfoD, MatchInfo500Time).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date >= SysUtil.getYesterday()).\ filter(MatchData.matchAID == MatchInfoD.matchid).\ filter(MatchInfoD.match == MatchInfo500Time.match).all(): matches.append(m) for md, mi, m in self.session.query(MatchData, MatchInfoD, MatchInfo500Time).\ filter(MatchData.singleFlag == GLBConfig.M_DUAL).\ filter(MatchData.userid == u.userid).\ filter(MatchData.date >= SysUtil.getYesterday()).\ filter(MatchData.matchBID == MatchInfoD.matchid).\ filter(MatchInfoD.match == MatchInfo500Time.match).all(): matches.append(m) else: matches = self.session.query(MatchInfo500Time).\ filter(MatchInfo500Time.mststus != '完').all() matchesB = self.session.query(MatchInfo500Time).\ filter(MatchInfo500Time.mststus == '完').all() for m in matchesB: matches.append(m) maData = [] if matches: for m in matches: maData.append({ 'match': m.match, 'mtime': m.mtime.strftime('%Y-%m-%d %H:%M'), 'matchtype': m.matchtype, 'matchzhu': m.matchzhu, 'matchke': m.matchke, 'zhuScore': m.zhuScore, 'keScore': m.keScore, 'zhuHScore': m.zhuHScore, 'keHScore': m.keHScore, 'mststus': m.mststus }) self.result['data'] = maData req.context['result'] = self.result resp.set_header('Powered-By', '*****@*****.**') resp.status = falcon.HTTP_200 self.release()
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'])