| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147 |
- # import datetime
- import datetime
- import pymongo
- import time
- import logging
- from twisted.internet import defer, reactor
- # from .ball_func import fuhao
- from ..utils.helper import Helper
- # from .ball_func import get_pcode
- from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL, MATCH_RESULT, MATCH_STATUS
- # 滚球足球 插入
- class Roll_Zuqiupipeline(object):
- def open_spider(self, spider):
- self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
- self.db = self.mongo[M_DB]
- # @defer.inlineCallbacks
- # def process_item(self, item, spider):
- # out = defer.Deferred()
- # reactor.callInThread(self._do_calculation, item, out)
- # yield out
- # defer.returnValue(item)
- def process_item(self, item, spider):
- # def _do_calculation(self, item, out):
- logger = logging.getLogger(__name__)
- pt = 4
- # 比赛日期
- # try:
- # data_game = item['data_game'].split("/")
- # month = str(data_game[1].strip())
- # day = str(data_game[0])
- # except Exception as e:
- # logger.warning(e)
- # data_game = item['data_game'].split(" ")
- # months = str(data_game[1].strip())
- # month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
- # month = month_dict[months]
- # day = str(data_game[0])
- # 比赛时间
- time_game = str(item['time_game'])
- # 现在时间,时间戳
- utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
- cdate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- match_date = cdate.split(' ')[0]
- match_time = cdate.split(' ')[1]
- # 比赛id
- match_id = item['game_id']
- # 联赛id
- league_id = item['league_id']
- # 联赛name
- league_name = item['league_name']
- # 主队
- team_home = item['team_home']
- # 客队
- team_guest = item['team_guest']
- # number
- number = item['number']
- score_home = item['score_home']
- score_guest = item['score_guest']
- all_goal = int(score_home) + int(score_guest)
- half_way = item['half_way']
- match_score = "{}:{}".format(score_home, score_guest)
- last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
- league_list = []
- uuid = Helper.genearte_uuid(league_name + 'hg3535')
- horn_team = item['horn_team']
- if self.db.zq_league35.find({'league_id': league_id}).count() < 1:
- league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
- league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
- league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
- league_data = dict(zip(league_key, league_value))
- league_list.append(league_data)
- league_dict['data'] = league_list
- res = Helper.async_post(LEAGUE_URL, league_dict)
- if res:
- if "成功" in res:
- self.db.zq_league35.insert(league_data)
- # self.db.zq_league35.update({'lg_id': league_id}, {'$set': league_data},
- # upsert=True)
- logger.info('足球滚球联赛提交成功, {}'.format(res))
- logger.info(league_dict)
- else:
- logger.warning('足球滚球联赛提交失败, {}'.format(res))
- logger.warning(league_dict)
- else:
- logger.warning('足球滚球联赛接口异常提交失败, {}'.format(res))
- logger.warning(league_dict)
- else:
- logger.info('足球滚球联赛已存在, 不存在')
- if self.db.zq_competition35.find({"match_id": match_id, 'is_rollball': 1}).count() < 1:
- match_list = []
- match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
- match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
- "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
- "half_match_id", "is_today", "is_horn"]
- match_value = [team_home, team_guest, league_id, 1, match_id, match_date, match_time, number,
- "hg3535", 1, 0, 0, utime, uuid, 0, 0, 0]
- match_data = dict(zip(match_kay, match_value))
- match_list.append(match_data)
- match_dict['data'] = match_list
- res = Helper.async_post(MATCH_URL, match_dict)
- if res:
- if "成功" in res:
- self.db.zq_competition35.insert(match_data)
- # self.db.zq_competition35.update({'match_id': match_id, 'is_rollball': 1}, {'$set': match_data},
- # upsert=True)
- logger.info('足球滚球赛事提交成功, {}'.format(res))
- logger.info(match_data)
- else:
- logger.warning('足球滚球赛事,提交失败, {}'.format(res))
- logger.warning(match_data)
- else:
- logger.warning('足球滚球赛事接口异常提交失败, {}'.format(res))
- logger.warning(match_data)
- else:
- logger.info('足球滚球赛事已存在, 不提交')
- p_code = "GS"
- # 构建唯一索引
- half_size_guest = item["half_size_guest"]
- half_size_guest_rule = item["half_size_guest_rule"]
- half_size_home = item["half_size_home"]
- half_size_home_rule = item["half_size_home_rule"]
- data_list = []
- odds_onlys = []
- # half_size_guest
- for index, value in enumerate(half_size_guest):
- hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_size_guest_rule[index]
- half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
- data_list.append(half_size_guest_data)
- # half_size_home
- for index, value in enumerate(half_size_home):
- hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_size_home_rule[index]
- half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
- data_list.append(half_size_home_data)
- # 全场场大小
- size_guest = item["size_guest"]
- size_guest_rule = item["size_guest_rule"]
- size_home = item["size_home"]
- size_home_rule = item["size_home_rule"]
- # size_home
- for index, value in enumerate(size_home):
- hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = size_home_rule[index]
- size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_home_key, size_home_value))
- data_list.append(size_home_data)
- # size_guest
- for index, value in enumerate(size_guest):
- hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = size_guest_rule[index]
- size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_guest_key, size_guest_value))
- data_list.append(size_home_data)
- p_code = 'CO'
- half_concede_home_rule = item["half_concede_home_rule"]
- half_concede_home = item["half_concede_home"]
- half_concede_guest_rule = item["half_concede_guest_rule"]
- half_concede_guest = item["half_concede_guest"]
- # half_concede_home
- for index, value in enumerate(half_concede_guest):
- hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_concede_guest_rule[index]
- half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
- data_list.append(half_concede_guest_data)
- # half_concede_home
- for index, value in enumerate(half_concede_home):
- hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_concede_home_rule[index]
- half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
- data_list.append(half_concede_home_data)
- concede_guest = item["concede_guest"]
- concede_guest_rule = item["concede_guest_rule"]
- concede_home = item["concede_home"]
- concede_home_rule = item["concede_home_rule"]
- # concede_guest
- for index, value in enumerate(concede_guest):
- hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = concede_guest_rule[index]
- concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
- data_list.append(concede_guest_data)
- # concede_home
- for index, value in enumerate(concede_home):
- hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = concede_home_rule[index]
- concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_home_key, concede_home_value))
- data_list.append(concede_guest_data)
- # 独赢-------------------------------------------------------------------------------------------------------
- p_code = 'C'
- half_capot_home = item["half_capot_home"]
- half_capot_guest = item["half_capot_guest"]
- half_capot_dogfall = item["half_capot_dogfall"]
- capot_home = item["capot_home"]
- capot_guest = item["capot_guest"]
- capot_dogfall = item["capot_dogfall"]
- # half_capot_home
- hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
- data_list.append(half_capot_homet_data)
- # half_capot_guest
- hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
- data_list.append(half_capot_guest_data)
- # half_capot_dogfall
- hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
- data_list.append(half_capot_dogfall_data)
- # capot_dogfall
- hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
- sole, "hg3535", "0", ""]
- capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
- data_list.append(capot_dogfall_data)
- # capot_home
- hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- capot_homet_data = dict(zip(capot_home_key, capot_home_value))
- data_list.append(capot_homet_data)
- # capot_guest
- hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
- odds_only, sole, "hg3535", "0", ""]
- capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
- data_list.append(capot_guest_data)
- # 入球数单双--------------------------------------------------------------------------------------------------
- p_code = 'TS'
- odd_even_odd = item["odd_even_odd"]
- odd_even_even = item["odd_even_even"]
- half_odd_even_odd = item["half_odd_even_odd"]
- half_odd_even_even = item["half_odd_even_even"]
- # odd_even_odd
- hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
- odds_only, sole, "hg3535", "0", ""]
- single_data = dict(zip(single_key, single_value))
- data_list.append(single_data)
- # odd_even_even
- hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- double_data = dict(zip(double_key, double_value))
- data_list.append(double_data)
- # half_odd_even_even
- hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- half_double_data = dict(zip(half_double_key, half_double_value))
- data_list.append(half_double_data)
- # half_odd_even_odd
- hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
- sole, "hg3535", "0", ""]
- half_single_data = dict(zip(half_single_key, half_single_value))
- data_list.append(half_single_data)
- p_code = 'TG'
- # 总入球数 ---------------------------------------------------------------------------------------------------
- total_goals = item['total_goal']
- total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6', 'tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
- "tg2_h": '2', "tg3_h": '3或以上'}
- # 全场入球数 单双
- for key, value in total_goals.items():
- hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- total_goals_data = dict(zip(total_goals_key, total_goals_value))
- data_list.append(total_goals_data)
- # 全场半场 ---------------------------------------------------------------------------------------------------
- half_fulls = item['half_full']
- # p_code, p_id = get_pcode(corner_ball, 'half_full')
- p_code = 'HF'
- full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
- "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
- if half_fulls:
- for key, value in half_fulls.items():
- hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
- data_list.append(half_fulls_data)
- # 波胆-------------------------------------------------------------------------------------------------------
- p_code = 'B'
- bodan_datas = item['bodan_data']
- # p_code, p_id = get_pcode(corner_ball, 'bodan')
- bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
- "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
- "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
- "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
- "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
- "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
- "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
- "bo_h": "其他"}
- if bodan_datas:
- for key, value in bodan_datas.items():
- hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
- data_list.append(bodan_dict_data)
- # 最先进球/最后进球 -------------------------------------------------------------------------------------------
- first_last_balls = item['first_last_ball']
- p_code = 'FLB'
- first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
- if first_last_balls:
- for key, value in first_last_balls.items():
- hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition",
- "odds_only", "sole", "source", "type", "team"]
- first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
- odds_only,
- sole, "hg3535", "0", ""]
- first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
- data_list.append(first_last_balls_data)
- p_code = 'TB'
- # 球队得分全场,上半场
- full_dicts = item['full_data']
- half_dicts = item['half_data']
- full_dict_rules = item['full_data_rule']
- half_dict_rules = item['half_data_rule']
- if full_dicts:
- for key, value in full_dicts.items():
- hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
- data_list.append(full_dict_rules_data)
- if half_dicts:
- for key, value in half_dicts.items():
- hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
- data_list.append(half_dicts_data)
- p_code = 'CB'
- # 球队得分全场,上半场
- horn_ou_dict = item['horn_ou_dict']
- horn_ou_dict_rule = item['horn_ou_dict_rule']
- horn_oe_dict = item['horn_oe_dict']
- horn_oe_dict_rule = item['horn_oe_dict_rule']
- if horn_ou_dict:
- for key, value in horn_ou_dict.items():
- hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
- odds_only, sole, "hg3535", "0", ""]
- horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
- data_list.append(horn_ou_data)
- if horn_oe_dict:
- for key, value in horn_oe_dict.items():
- hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
- odds_only, sole, "hg3535", "0", ""]
- horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
- data_list.append(horn_oe_data)
- odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
- "is_stringscene", "utime", "pt"]
- odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, number, uuid,
- 0, utime, pt]
- odds_dict = dict(zip(odds_key, odds_value))
- if data_list:
- res = Helper.async_post(ODDS_URL, odds_dict)
- if res:
- if "成功" in res:
- logger.info('足球滚球详细赔率提交成功, {}'.format(res))
- logger.info(odds_dict)
- else:
- logger.warning('足球滚球详细赔率提交失败, {}'.format(res))
- logger.warning(odds_dict)
- else:
- logger.warning('足球滚球详细赔率接口异常,提交失败, {}'.format(res))
- logger.warning(odds_dict)
- else:
- logger.info('足球滚球详细赔率列表为空')
- data_list = []
- zq_rball = {"home_team": team_home, "guest_team": team_guest,
- "lg_id": league_id, "home_rate": 0,
- "guest_rate": 0, "home_score": score_home,
- "guest_score": score_guest, "all_goal": all_goal, "status": 1,
- "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
- "match_winer": "", "match_time": time_game,
- "match_process": half_way, "tag": number,
- "match_id": match_id, "p_code": ""}
- data_list.append(zq_rball)
- r_data_dict = {
- "game_code": "zq",
- "title": "match_result_r",
- "source": "hg3535",
- "data": data_list
- }
- if data_list:
- try:
- res = Helper.async_post(MATCH_RESULT, r_data_dict)
- if res:
- if "成功" in res:
- logger.info('足球滚球结果记录提交成功, {}'.format(res))
- logger.info(r_data_dict)
- else:
- logger.warning('足球滚球结果记录提交失败, {}'.format(res))
- logger.warning(r_data_dict)
- else:
- logger.warning('足球滚球结果记录接口异常,提交失败, {}'.format(res))
- logger.warning(r_data_dict)
- except Exception as e:
- logger.warning('滚球数据接口异常,提交失败, {}'.format(e))
- # status_dict = {"game_code": 'zq', "title": "match_status", "source": "hg3535"}
- # data_list = []
- # data = {'match_id': match_id, 'status': 1, "is_rollball": 0, "is_today": 0, "is_morningplate": 0,
- # "is_stringscene": 0, "is_horn": 0}
- # data_list.append(data)
- # status_dict['data'] = data_list
- # res = Helper.async_post(MATCH_STATUS, status_dict)
- # if res:
- # if "成功" in res:
- # self.db.match_status35.insert(status_dict)
- # logger.info('{},赛事结果状态交成功, {}'.format('zq', res))
- # logger.info(status_dict)
- # else:
- # logger.warning('{},赛事结果状态交失败, {}'.format('zq', res))
- # logger.warning(status_dict)
- # else:
- # logger.warning('{},赛事结果状态接口异常提交失败, {}'.format('zq', res))
- # logger.warning(status_dict)
- # 角球分割处理--------------------------------------------------------------------------------------------------
- if horn_team:
- team_home = horn_team['horn_home']
- team_guest = horn_team['horn_guest']
- horn_scoreh = horn_team['horn_scoreh']
- horn_scoreg = horn_team['horn_scoreg']
- all_goal = int(horn_scoreh) + int(horn_scoreg)
- match_id = horn_team['horn_id']
- # half_way = item['half_way']
- match_score = "{}:{}".format(horn_scoreh, horn_scoreg)
- if self.db.zq_competition35.find({"match_id": match_id, 'is_rollball': 1}).count() < 1:
- match_list = []
- match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
- match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
- "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
- "half_match_id", "is_today", "is_horn"]
- match_value = [team_home, team_guest, league_id, 1, match_id, match_date, match_time, number,
- "hg3535", 1, 0, 0, utime, uuid, 0, 0, 1]
- match_data = dict(zip(match_kay, match_value))
- match_list.append(match_data)
- match_dict['data'] = match_list
- res = Helper.async_post(MATCH_URL, match_dict)
- if res:
- if "成功" in res:
- self.db.zq_competition35.insert(match_data)
- # self.db.zq_competition35.update({'match_id': match_id, 'is_rollball': 1}, {'$set': match_data},
- # upsert=True)
- logger.info('足球滚球角球, 赛事提交成功, {}'.format(res))
- logger.info(match_data)
- else:
- logger.warning('足球滚球赛事, 角球提交失败, {}'.format(res))
- logger.warning(match_data)
- else:
- logger.warning('足球滚球赛事接口异常, 角球赛事提交失败, {}'.format(res))
- logger.warning(match_data)
- else:
- logger.info('足球滚球赛事已存在, 不提交')
- p_code = "GS"
- # 构建唯一索引
- half_size_guest = item["half_size_guest"]
- half_size_guest_rule = item["half_size_guest_rule"]
- half_size_home = item["half_size_home"]
- half_size_home_rule = item["half_size_home_rule"]
- data_list = []
- odds_onlys = []
- # half_size_guest
- for index, value in enumerate(half_size_guest):
- hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_size_guest_rule[index]
- half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
- data_list.append(half_size_guest_data)
- # half_size_home
- for index, value in enumerate(half_size_home):
- hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_size_home_rule[index]
- half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
- data_list.append(half_size_home_data)
- # 全场场大小
- size_guest = item["size_guest"]
- size_guest_rule = item["size_guest_rule"]
- size_home = item["size_home"]
- size_home_rule = item["size_home_rule"]
- # size_home
- for index, value in enumerate(size_home):
- hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = size_home_rule[index]
- size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_home_key, size_home_value))
- data_list.append(size_home_data)
- # size_guest
- for index, value in enumerate(size_guest):
- hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
- match_id)
- sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = size_guest_rule[index]
- size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- size_home_data = dict(zip(size_guest_key, size_guest_value))
- data_list.append(size_home_data)
- p_code = 'CO'
- half_concede_home_rule = item["half_concede_home_rule"]
- half_concede_home = item["half_concede_home"]
- half_concede_guest_rule = item["half_concede_guest_rule"]
- half_concede_guest = item["half_concede_guest"]
- # half_concede_home
- for index, value in enumerate(half_concede_guest):
- hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_concede_guest_rule[index]
- half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
- data_list.append(half_concede_guest_data)
- # half_concede_home
- for index, value in enumerate(half_concede_home):
- hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = half_concede_home_rule[index]
- half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
- data_list.append(half_concede_home_data)
- concede_guest = item["concede_guest"]
- concede_guest_rule = item["concede_guest_rule"]
- concede_home = item["concede_home"]
- concede_home_rule = item["concede_home_rule"]
- # concede_guest
- for index, value in enumerate(concede_guest):
- hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = concede_guest_rule[index]
- concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
- odds_only, sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
- data_list.append(concede_guest_data)
- # concede_home
- for index, value in enumerate(concede_home):
- hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
- value) + "hg3535" + str(match_id)
- sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- condition = concede_home_rule[index]
- concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
- sole, "hg3535", "0", ""]
- concede_guest_data = dict(zip(concede_home_key, concede_home_value))
- data_list.append(concede_guest_data)
- # 独赢-------------------------------------------------------------------------------------------------------
- p_code = 'C'
- half_capot_home = item["half_capot_home"]
- half_capot_guest = item["half_capot_guest"]
- half_capot_dogfall = item["half_capot_dogfall"]
- capot_home = item["capot_home"]
- capot_guest = item["capot_guest"]
- capot_dogfall = item["capot_dogfall"]
- # half_capot_home
- hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
- data_list.append(half_capot_homet_data)
- # half_capot_guest
- hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
- data_list.append(half_capot_guest_data)
- # half_capot_dogfall
- hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
- odds_only, sole, "hg3535", "0", ""]
- half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
- data_list.append(half_capot_dogfall_data)
- # capot_dogfall
- hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
- sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
- sole, "hg3535", "0", ""]
- capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
- data_list.append(capot_dogfall_data)
- # capot_home
- hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
- sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
- odds_only, sole, "hg3535", "0", ""]
- capot_homet_data = dict(zip(capot_home_key, capot_home_value))
- data_list.append(capot_homet_data)
- # capot_guest
- hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
- sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
- odds_only, sole, "hg3535", "0", ""]
- capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
- data_list.append(capot_guest_data)
- # 入球数单双--------------------------------------------------------------------------------------------------
- p_code = 'TS'
- odd_even_odd = item["odd_even_odd"]
- odd_even_even = item["odd_even_even"]
- half_odd_even_odd = item["half_odd_even_odd"]
- half_odd_even_even = item["half_odd_even_even"]
- # odd_even_odd
- hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
- odds_only, sole, "hg3535", "0", ""]
- single_data = dict(zip(single_key, single_value))
- data_list.append(single_data)
- # odd_even_even
- hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- double_data = dict(zip(double_key, double_value))
- data_list.append(double_data)
- # half_odd_even_even
- hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
- sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
- odds_only, sole, "hg3535", "0", ""]
- half_double_data = dict(zip(half_double_key, half_double_value))
- data_list.append(half_double_data)
- # half_odd_even_odd
- hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
- sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
- sole, "hg3535", "0", ""]
- half_single_data = dict(zip(half_single_key, half_single_value))
- data_list.append(half_single_data)
- p_code = 'TG'
- # 总入球数 ---------------------------------------------------------------------------------------------------
- total_goals = item['total_goal']
- total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6', 'tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
- "tg2_h": '2', "tg3_h": '3或以上'}
- # 全场入球数 单双
- for key, value in total_goals.items():
- hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- total_goals_data = dict(zip(total_goals_key, total_goals_value))
- data_list.append(total_goals_data)
- # 全场半场 ---------------------------------------------------------------------------------------------------
- half_fulls = item['half_full']
- # p_code, p_id = get_pcode(corner_ball, 'half_full')
- p_code = 'HF'
- full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
- "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
- if half_fulls:
- for key, value in half_fulls.items():
- hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
- data_list.append(half_fulls_data)
- # 波胆-------------------------------------------------------------------------------------------------------
- p_code = 'B'
- bodan_datas = item['bodan_data']
- # p_code, p_id = get_pcode(corner_ball, 'bodan')
- bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
- "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
- "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
- "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
- "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
- "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
- "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
- "bo_h": "其他"}
- if bodan_datas:
- for key, value in bodan_datas.items():
- hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
- "odds_only", "sole", "source", "type", "team"]
- bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
- sole, "hg3535", "0", ""]
- bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
- data_list.append(bodan_dict_data)
- # 最先进球/最后进球 -------------------------------------------------------------------------------------------
- first_last_balls = item['first_last_ball']
- p_code = 'FLB'
- first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
- if first_last_balls:
- for key, value in first_last_balls.items():
- hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition",
- "odds_only", "sole", "source", "type", "team"]
- first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
- odds_only,
- sole, "hg3535", "0", ""]
- first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
- data_list.append(first_last_balls_data)
- p_code = 'TB'
- # 球队得分全场,上半场
- full_dicts = item['full_data']
- half_dicts = item['half_data']
- full_dict_rules = item['full_data_rule']
- half_dict_rules = item['half_data_rule']
- if full_dicts:
- for key, value in full_dicts.items():
- hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
- data_list.append(full_dict_rules_data)
- if half_dicts:
- for key, value in half_dicts.items():
- hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
- odds_only, sole, "hg3535", "0", ""]
- half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
- data_list.append(half_dicts_data)
- p_code = 'CB'
- horn_ou_dict = item['horn_ou_dict']
- horn_ou_dict_rule = item['horn_ou_dict_rule']
- horn_oe_dict = item['horn_oe_dict']
- horn_oe_dict_rule = item['horn_oe_dict_rule']
- if horn_ou_dict:
- for key, value in horn_ou_dict.items():
- hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
- odds_only, sole, "hg3535", "0", ""]
- horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
- data_list.append(horn_ou_data)
- if horn_oe_dict:
- for key, value in horn_oe_dict.items():
- hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
- sole_str = p_code + key + '0' + str(match_id) + "hg3535"
- odds_only = Helper.genearte_MD5(hash_str, pt)
- sole = Helper.genearte_MD5(sole_str, pt)
- horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
- "condition", "odds_only", "sole", "source", "type", "team"]
- horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
- odds_only, sole, "hg3535", "0", ""]
- horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
- data_list.append(horn_oe_data)
- odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
- "is_stringscene", "utime", "pt"]
- odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, number, uuid,
- 0, utime, pt]
- odds_dict = dict(zip(odds_key, odds_value))
- if data_list:
- res = Helper.async_post(ODDS_URL, odds_dict)
- if res:
- if "成功" in res:
- logger.info('足球滚球, 角球详细赔率提交成功, {}'.format(res))
- logger.info(odds_dict)
- else:
- logger.warning('足球滚球, 角球详细赔率提交失败, {}'.format(res))
- logger.warning(odds_dict)
- else:
- logger.warning('足球滚球, 角球详细赔率接口异常,提交失败, {}'.format(res))
- logger.warning(odds_dict)
- else:
- logger.info('足球滚球, 角球详细赔率列表为空')
- data_list = []
- zq_rball = {"home_team": team_home, "guest_team": team_guest,
- "lg_id": league_id, "home_rate": 0,
- "guest_rate": 0, "home_score": horn_scoreh,
- "guest_score": horn_scoreg, "all_goal": all_goal, "status": 1,
- "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
- "match_winer": "", "match_time": time_game,
- "match_process": half_way, "tag": number,
- "match_id": match_id, "p_code": ""}
- data_list.append(zq_rball)
- r_data_dict = {
- "game_code": "zq",
- "title": "match_result_r",
- "source": "hg3535",
- "data": data_list
- }
- if data_list:
- try:
- res = Helper.async_post(MATCH_RESULT, r_data_dict)
- if res:
- if "成功" in res:
- logger.info('足球滚球, 角球结果记录提交成功, {}'.format(res))
- logger.info(r_data_dict)
- else:
- logger.warning('足球滚球, 角球结果记录提交失败, {}'.format(res))
- logger.warning(r_data_dict)
- else:
- logger.warning('足球滚球, 角球结果记录接口异常,提交失败, {}'.format(res))
- logger.warning(r_data_dict)
- except Exception as e:
- logger.warning('滚球数据接口异常, 角球结果提交失败, {}'.format(e))
- # status_dict = {"game_code": 'zq', "title": "match_status", "source": "hg3535"}
- # data_list = []
- # data = {'match_id': match_id, 'status': 1, "is_rollball": 0, "is_today": 0, "is_morningplate": 0,
- # "is_stringscene": 0, "is_horn": 0}
- # data_list.append(data)
- # status_dict['data'] = data_list
- # res = Helper.async_post(MATCH_STATUS, status_dict)
- # if res:
- # if "成功" in res:
- # self.db.match_status35.insert(status_dict)
- # logger.info('{},赛事结果状态交成功, {}'.format('zq', res))
- # logger.info(status_dict)
- # else:
- # logger.warning('{},赛事结果状态交失败, {}'.format('zq', res))
- # logger.warning(status_dict)
- # else:
- # logger.warning('{},赛事结果状态接口异常提交失败, {}'.format('zq', res))
- # logger.warning(status_dict)
- # reactor.callFromThread(out.callback, item)
|