zuqiu.py 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <<<<<<< HEAD
  2. from twisted.internet import defer,reactor
  3. from ..utils.helper import Helper
  4. class ZuqiuPipeline(object):
  5. def open_spider(self, spider):
  6. pass
  7. @defer.inlineCallbacks
  8. def process_item(self,item,spider):
  9. out=defer.Deferred()
  10. reactor.callInThread(self._do_calculation,item,out)
  11. yield out
  12. def _do_calculation(self,item,out):
  13. param={"id":item["id"],"league":item["league"],"team_h":item["team_h"],
  14. "team_c":item["team_c"],"ior_RTS2Y":item["ior_RTS2Y"],"ior_RTS2N":item["ior_RTS2N"],
  15. "ior_REH":item["ior_REH"],"ior_REC":item["ior_REC"],"ior_ROUC":item["ior_ROUC"],
  16. "ior_HROUH":item["ior_HROUH"],"ratio_rouo":item["ratio_rouo"],"ratio_rouu":item["ratio_rouu"]}
  17. data=Helper.async_post("")
  18. =======
  19. import datetime
  20. import time
  21. import logging
  22. import pymongo
  23. from twisted.internet import defer, reactor
  24. from ..utils.helper import Helper
  25. # from .ball_func import new_time
  26. from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL
  27. class Zuqiupipeline(object):
  28. def open_spider(self, spider):
  29. self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST, authSource=M_DB)
  30. self.db = self.mongo[M_DB]
  31. # @defer.inlineCallbacks
  32. # def process_item(self, item, spider):
  33. # out = defer.Deferred()
  34. # reactor.callInThread(self._do_calculation, item, out)
  35. # yield out
  36. # # defer.returnValue(item)
  37. def process_item(self, item, spider):
  38. # def _do_calculation(self, item, out):
  39. logger = logging.getLogger(__name__)
  40. # 比赛日期
  41. try:
  42. data_game = item['data_game'].split("/")
  43. month = str(data_game[1].strip())
  44. day = str(data_game[0].strip())
  45. except Exception as e:
  46. logger.warning(e)
  47. data_game = item['data_game'].split(" ")
  48. months = str(data_game[1].strip())
  49. month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
  50. 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
  51. month = month_dict[months]
  52. day = str(data_game[0]).strip()
  53. # 比赛时间
  54. time_game = str(item['time_game'])
  55. # 比赛时间,时间戳
  56. us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
  57. # 美东日期
  58. # new_us_time = us_time.split(' ')[0]
  59. # 现在时间,时间戳
  60. utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
  61. # 比赛id
  62. match_id = item['game_id']
  63. # 联赛id
  64. league_id = item['league_id']
  65. # 联赛name
  66. league_name = item['league_name']
  67. # # 主队
  68. team_home = item['team_home']
  69. # 客队
  70. team_guest = item['team_guest']
  71. # number
  72. tag_number = item['number']
  73. pt = str(item['pt'])
  74. # match_date, match_time, time3 = new_time(us_time)
  75. # 联赛接口写入
  76. last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
  77. league_list = []
  78. # uuid = Helper.genearte_uuid(league_name + 'hg3535')
  79. uuid = Helper.genearte_uuid(league_name)
  80. if self.db.zq_league35.find({'lg_id': league_id}).count() < 1:
  81. # if self.db.zq_league35.find({'uuid': uuid}).count() < 1:
  82. league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
  83. league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
  84. league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
  85. league_data = dict(zip(league_key, league_value))
  86. league_list.append(league_data)
  87. league_dict['data'] = league_list
  88. res = Helper.async_post(LEAGUE_URL, league_dict)
  89. if res:
  90. if res.get('status') == 1:
  91. self.db.zq_league35.insert(league_data)
  92. else:
  93. logging.warning('足球详细赔率接口异常, {}'.format(res))
  94. else:
  95. logging.info('{},联赛已存在, 不提交'.format(league_name))
  96. pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
  97. pt_status = pt_dict[pt]
  98. if pt == '3':
  99. is_rollball = 0
  100. is_today = 0
  101. is_morningplate = 0
  102. is_stringscene = 1
  103. elif pt == '2':
  104. is_rollball = 0
  105. is_today = 0
  106. is_morningplate = 1
  107. is_stringscene = 0
  108. else:
  109. is_today = 1
  110. is_rollball = 0
  111. is_morningplate = 0
  112. is_stringscene = 0
  113. match_list = []
  114. match_identity = Helper.genearte_uuid(team_home + team_guest + match_date)
  115. if self.db.zq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
  116. # if self.db.zq_competition35.find({'match_identity': match_identity, pt_status: 1}).count() < 1:
  117. match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  118. match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  119. "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  120. "half_match_id", "is_today", "is_horn", 'match_identity']
  121. match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  122. "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, 0, match_identity]
  123. match_data = dict(zip(match_kay, match_value))
  124. match_list.append(match_data)
  125. match_dict['data'] = match_list
  126. res = Helper.async_post(MATCH_URL, match_dict)
  127. if res:
  128. if res.get('status') == 1:
  129. self.db.zq_competition35.insert(match_data)
  130. else:
  131. logger.warning('足球赛事表提交失败, {}'.format(res))
  132. # logger.warning(match_dict)
  133. else:
  134. logger.warning('足球赛事接口异常提交失败, {}'.format(res))
  135. # logger.warning(match_dict)
  136. else:
  137. logger.info('足球赛事已存在,不提交')
  138. #
  139. # p_code = "GS"
  140. # half_size_guest = item["half_size_guest"]
  141. # half_size_guest_rule = item["half_size_guest_rule"]
  142. # half_size_home = item["half_size_home"]
  143. # half_size_home_rule = item["half_size_home_rule"]
  144. # data_list = []
  145. # odds_onlys = []
  146. # # half_size_guest
  147. # for index, value in enumerate(half_size_guest):
  148. # hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
  149. # value) + "hg3535" + str(match_id)
  150. # sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
  151. # odds_only = Helper.genearte_MD5(hash_str, pt)
  152. # sole = Helper.genearte_MD5(sole_str, pt)
  153. # half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  154. # "odds_only", "sole", "source", "type", "team"]
  155. # condition = half_size_guest_rule[index]
  156. # half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
  157. # odds_only, sole, "hg3535", "0", ""]
  158. # half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
  159. # data_list.append(half_size_guest_data)
  160. # # half_size_home
  161. # for index, value in enumerate(half_size_home):
  162. # hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
  163. # value) + "hg3535" + str(match_id)
  164. # sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
  165. # odds_only = Helper.genearte_MD5(hash_str, pt)
  166. # sole = Helper.genearte_MD5(sole_str, pt)
  167. # half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  168. # "odds_only", "sole", "source", "type", "team"]
  169. # condition = half_size_home_rule[index]
  170. # half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
  171. # odds_only, sole, "hg3535", "0", ""]
  172. # half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
  173. # data_list.append(half_size_home_data)
  174. #
  175. # # 全场场大小
  176. # size_guest = item["size_guest"]
  177. # size_guest_rule = item["size_guest_rule"]
  178. # size_home = item["size_home"]
  179. # size_home_rule = item["size_home_rule"]
  180. # # size_home
  181. # for index, value in enumerate(size_home):
  182. # hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
  183. # match_id)
  184. # sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
  185. # odds_only = Helper.genearte_MD5(hash_str, pt)
  186. # sole = Helper.genearte_MD5(sole_str, pt)
  187. # size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  188. # "odds_only", "sole", "source", "type", "team"]
  189. # condition = size_home_rule[index]
  190. # size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
  191. # sole, "hg3535", "0", ""]
  192. # size_home_data = dict(zip(size_home_key, size_home_value))
  193. # data_list.append(size_home_data)
  194. # # size_guest
  195. # for index, value in enumerate(size_guest):
  196. # hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
  197. # match_id)
  198. # sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
  199. # odds_only = Helper.genearte_MD5(hash_str, pt)
  200. # sole = Helper.genearte_MD5(sole_str, pt)
  201. # size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  202. # "odds_only", "sole", "source", "type", "team"]
  203. # condition = size_guest_rule[index]
  204. # size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
  205. # sole, "hg3535", "0", ""]
  206. # size_home_data = dict(zip(size_guest_key, size_guest_value))
  207. # data_list.append(size_home_data)
  208. #
  209. # p_code = 'CO'
  210. # half_concede_home_rule = item["half_concede_home_rule"]
  211. # half_concede_home = item["half_concede_home"]
  212. # half_concede_guest_rule = item["half_concede_guest_rule"]
  213. # half_concede_guest = item["half_concede_guest"]
  214. # # half_concede_home
  215. # if half_concede_guest:
  216. # for index, value in enumerate(half_concede_guest):
  217. # hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
  218. # value) + "hg3535" + str(match_id)
  219. # sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
  220. # odds_only = Helper.genearte_MD5(hash_str, pt)
  221. # sole = Helper.genearte_MD5(sole_str, pt)
  222. # half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  223. # "odds_only", "sole", "source", "type", "team"]
  224. # condition = half_concede_guest_rule[index]
  225. # half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
  226. # odds_only, sole, "hg3535", "0", ""]
  227. # half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
  228. # data_list.append(half_concede_guest_data)
  229. #
  230. # # half_concede_home
  231. # if half_concede_home:
  232. # for index, value in enumerate(half_concede_home):
  233. # hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
  234. # value) + "hg3535" + str(match_id)
  235. # sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
  236. # odds_only = Helper.genearte_MD5(hash_str, pt)
  237. # sole = Helper.genearte_MD5(sole_str, pt)
  238. # half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  239. # "odds_only", "sole", "source", "type", "team"]
  240. # condition = half_concede_home_rule[index]
  241. # half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
  242. # odds_only, sole, "hg3535", "0", ""]
  243. # half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
  244. # data_list.append(half_concede_home_data)
  245. #
  246. # concede_guest = item["concede_guest"]
  247. # concede_guest_rule = item["concede_guest_rule"]
  248. # concede_home = item["concede_home"]
  249. # concede_home_rule = item["concede_home_rule"]
  250. # # concede_guest
  251. # if concede_guest:
  252. # for index, value in enumerate(concede_guest):
  253. # hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
  254. # value) + "hg3535" + str(match_id)
  255. # sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
  256. # odds_only = Helper.genearte_MD5(hash_str, pt)
  257. # sole = Helper.genearte_MD5(sole_str, pt)
  258. # concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  259. # "odds_only", "sole", "source", "type", "team"]
  260. # condition = concede_guest_rule[index]
  261. # concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
  262. # odds_only, sole, "hg3535", "0", ""]
  263. # concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
  264. # data_list.append(concede_guest_data)
  265. # # concede_home
  266. # if concede_home:
  267. # for index, value in enumerate(concede_home):
  268. # hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
  269. # value) + "hg3535" + str(match_id)
  270. # sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
  271. # odds_only = Helper.genearte_MD5(hash_str, pt)
  272. # sole = Helper.genearte_MD5(sole_str, pt)
  273. # concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  274. # "odds_only", "sole", "source", "type", "team"]
  275. # condition = concede_home_rule[index]
  276. # concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
  277. # sole, "hg3535", "0", ""]
  278. # concede_guest_data = dict(zip(concede_home_key, concede_home_value))
  279. # data_list.append(concede_guest_data)
  280. #
  281. # # 独赢----------------------------------------------------------------------------------------------------------
  282. # p_code = 'C'
  283. # half_capot_home = item["half_capot_home"]
  284. # half_capot_guest = item["half_capot_guest"]
  285. # half_capot_dogfall = item["half_capot_dogfall"]
  286. # capot_home = item["capot_home"]
  287. # capot_guest = item["capot_guest"]
  288. # capot_dogfall = item["capot_dogfall"]
  289. #
  290. # # half_capot_home
  291. # hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
  292. # sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
  293. # odds_only = Helper.genearte_MD5(hash_str, pt)
  294. # sole = Helper.genearte_MD5(sole_str, pt)
  295. # half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  296. # "odds_only", "sole", "source", "type", "team"]
  297. # half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
  298. # odds_only, sole, "hg3535", "0", ""]
  299. # half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
  300. # data_list.append(half_capot_homet_data)
  301. #
  302. # # half_capot_guest
  303. # hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
  304. # sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
  305. # odds_only = Helper.genearte_MD5(hash_str, pt)
  306. # sole = Helper.genearte_MD5(sole_str, pt)
  307. # half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  308. # "odds_only", "sole", "source", "type", "team"]
  309. # half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
  310. # odds_only, sole, "hg3535", "0", ""]
  311. # half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
  312. # data_list.append(half_capot_guest_data)
  313. #
  314. # # half_capot_dogfall
  315. # hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
  316. # sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
  317. # odds_only = Helper.genearte_MD5(hash_str, pt)
  318. # sole = Helper.genearte_MD5(sole_str, pt)
  319. # half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  320. # "odds_only", "sole", "source", "type", "team"]
  321. # half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
  322. # odds_only, sole, "hg3535", "0", ""]
  323. # half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
  324. # data_list.append(half_capot_dogfall_data)
  325. #
  326. # # capot_dogfall
  327. # hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
  328. # sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
  329. # odds_only = Helper.genearte_MD5(hash_str, pt)
  330. # sole = Helper.genearte_MD5(sole_str, pt)
  331. # capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  332. # "odds_only", "sole", "source", "type", "team"]
  333. # capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
  334. # sole, "hg3535", "0", ""]
  335. # capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
  336. # data_list.append(capot_dogfall_data)
  337. #
  338. # # capot_home
  339. # hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
  340. # sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
  341. # odds_only = Helper.genearte_MD5(hash_str, pt)
  342. # sole = Helper.genearte_MD5(sole_str, pt)
  343. # capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  344. # "odds_only", "sole", "source", "type", "team"]
  345. # capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
  346. # odds_only, sole, "hg3535", "0", ""]
  347. # capot_homet_data = dict(zip(capot_home_key, capot_home_value))
  348. # data_list.append(capot_homet_data)
  349. #
  350. # # capot_guest
  351. # hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
  352. # sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
  353. # odds_only = Helper.genearte_MD5(hash_str, pt)
  354. # sole = Helper.genearte_MD5(sole_str, pt)
  355. # capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  356. # "odds_only", "sole", "source", "type", "team"]
  357. # capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
  358. # odds_only, sole, "hg3535", "0", ""]
  359. # capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
  360. # data_list.append(capot_guest_data)
  361. #
  362. # # 入球数单双-----------------------------------------------------------------------------------------------------
  363. # # p_code, p_id = get_pcode(corner_ball, 'two_sides')
  364. # p_code = 'TS'
  365. # odd_even_odd = item["odd_even_odd"]
  366. # odd_even_even = item["odd_even_even"]
  367. # half_odd_even_odd = item["half_odd_even_odd"]
  368. # half_odd_even_even = item["half_odd_even_even"]
  369. #
  370. # # odd_even_odd
  371. # hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
  372. # sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
  373. # odds_only = Helper.genearte_MD5(hash_str, pt)
  374. # sole = Helper.genearte_MD5(sole_str, pt)
  375. # single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  376. # "odds_only", "sole", "source", "type", "team"]
  377. # single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
  378. # odds_only, sole, "hg3535", "0", ""]
  379. # single_data = dict(zip(single_key, single_value))
  380. # data_list.append(single_data)
  381. #
  382. # # odd_even_even
  383. # hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
  384. # sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
  385. # odds_only = Helper.genearte_MD5(hash_str, pt)
  386. # sole = Helper.genearte_MD5(sole_str, pt)
  387. # double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  388. # "odds_only", "sole", "source", "type", "team"]
  389. # double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
  390. # odds_only, sole, "hg3535", "0", ""]
  391. # double_data = dict(zip(double_key, double_value))
  392. # data_list.append(double_data)
  393. #
  394. # # half_odd_even_even
  395. # hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
  396. # sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
  397. # odds_only = Helper.genearte_MD5(hash_str, pt)
  398. # sole = Helper.genearte_MD5(sole_str, pt)
  399. # half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  400. # "odds_only", "sole", "source", "type", "team"]
  401. # half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
  402. # odds_only, sole, "hg3535", "0", ""]
  403. # half_double_data = dict(zip(half_double_key, half_double_value))
  404. # data_list.append(half_double_data)
  405. #
  406. # # half_odd_even_odd
  407. # hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
  408. # sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
  409. # odds_only = Helper.genearte_MD5(hash_str, pt)
  410. # sole = Helper.genearte_MD5(sole_str, pt)
  411. # half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  412. # "odds_only", "sole", "source", "type", "team"]
  413. # half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
  414. # sole, "hg3535", "0", ""]
  415. # half_single_data = dict(zip(half_single_key, half_single_value))
  416. # data_list.append(half_single_data)
  417. #
  418. # # 总入球数 ------------------------------------------------------------------------------------------------------
  419. # p_code = 'TG'
  420. # total_goals = item['total_goal']
  421. # total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
  422. # "tg2_h": '2', "tg3_h": '3或以上'}
  423. # # 全场入球数 单双
  424. # # 上半场入球数 单双
  425. # for key, value in total_goals.items():
  426. # hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
  427. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  428. # odds_only = Helper.genearte_MD5(hash_str, pt)
  429. # sole = Helper.genearte_MD5(sole_str, pt)
  430. # total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  431. # "odds_only", "sole", "source", "type", "team"]
  432. # total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
  433. # sole, "hg3535", "0", ""]
  434. # total_goals_data = dict(zip(total_goals_key, total_goals_value))
  435. # data_list.append(total_goals_data)
  436. #
  437. # # 全场半场 ------------------------------------------------------------------------------------------------------
  438. # half_fulls = item['half_full']
  439. # p_code = 'HF'
  440. # full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
  441. # "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
  442. # if half_fulls:
  443. # for key, value in half_fulls.items():
  444. # hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
  445. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  446. # odds_only = Helper.genearte_MD5(hash_str, pt)
  447. # sole = Helper.genearte_MD5(sole_str, pt)
  448. # half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  449. # "odds_only", "sole", "source", "type", "team"]
  450. # half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
  451. # sole, "hg3535", "0", ""]
  452. # half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
  453. # data_list.append(half_fulls_data)
  454. #
  455. # # 波胆-----------------------------------------------------------------------------------------------------------
  456. # bodan_datas = item['bodan_data']
  457. # p_code = 'B'
  458. # bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
  459. # "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
  460. # "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
  461. # "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
  462. # "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
  463. # "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
  464. # "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
  465. # "bo_h": "其他"}
  466. # if bodan_datas:
  467. # for key, value in bodan_datas.items():
  468. # hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
  469. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  470. # odds_only = Helper.genearte_MD5(hash_str, pt)
  471. # sole = Helper.genearte_MD5(sole_str, pt)
  472. # bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  473. # "odds_only", "sole", "source", "type", "team"]
  474. # bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
  475. # sole, "hg3535", "0", ""]
  476. # bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
  477. # data_list.append(bodan_dict_data)
  478. #
  479. # # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
  480. # first_last_balls = item['first_last_ball']
  481. # # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
  482. # p_code = 'FLB'
  483. # first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
  484. # if first_last_balls:
  485. # for key, value in first_last_balls.items():
  486. # hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
  487. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  488. # odds_only = Helper.genearte_MD5(hash_str, pt)
  489. # sole = Helper.genearte_MD5(sole_str, pt)
  490. # first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  491. # "odds_only", "sole", "source", "type", "team"]
  492. # first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key], odds_only,
  493. # sole, "hg3535", "0", ""]
  494. # first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
  495. # data_list.append(first_last_balls_data)
  496. #
  497. # # 球队得分大小
  498. # p_code = 'TB'
  499. # # 全场
  500. # full_dicts = item['full_data']
  501. # # 上半场
  502. # half_dicts = item['half_data']
  503. # full_dict_rules = item['full_data_rule']
  504. # half_dict_rules = item['half_data_rule']
  505. # if full_dicts:
  506. # for key, value in full_dicts.items():
  507. # hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  508. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  509. # odds_only = Helper.genearte_MD5(hash_str, pt)
  510. # sole = Helper.genearte_MD5(sole_str, pt)
  511. # full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  512. # "condition", "odds_only", "sole", "source", "type", "team"]
  513. # full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
  514. # odds_only,sole, "hg3535", "0", ""]
  515. # full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
  516. # data_list.append(full_dict_rules_data)
  517. #
  518. # if half_dicts:
  519. # for key, value in half_dicts.items():
  520. # hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  521. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  522. # odds_only = Helper.genearte_MD5(hash_str, pt)
  523. # sole = Helper.genearte_MD5(sole_str, pt)
  524. # half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  525. # "condition","odds_only", "sole", "source", "type", "team"]
  526. # half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
  527. # odds_only, sole, "hg3535", "0", ""]
  528. # half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
  529. # data_list.append(half_dicts_data)
  530. #
  531. # p_code = 'CB'
  532. # horn_ou_dict = item['horn_ou_dict']
  533. # horn_ou_dict_rule = item['horn_ou_dict_rule']
  534. # horn_oe_dict = item['horn_oe_dict']
  535. # horn_oe_dict_rule = item['horn_oe_dict_rule']
  536. # if horn_ou_dict:
  537. # for key, value in horn_ou_dict.items():
  538. # hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  539. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  540. # odds_only = Helper.genearte_MD5(hash_str, pt)
  541. # sole = Helper.genearte_MD5(sole_str, pt)
  542. # horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  543. # "condition", "odds_only", "sole", "source", "type", "team"]
  544. # horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
  545. # odds_only, sole, "hg3535", "0", ""]
  546. # horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
  547. # data_list.append(horn_ou_data)
  548. #
  549. # if horn_oe_dict:
  550. # for key, value in horn_oe_dict.items():
  551. # hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  552. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  553. # odds_only = Helper.genearte_MD5(hash_str, pt)
  554. # sole = Helper.genearte_MD5(sole_str, pt)
  555. # horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  556. # "condition", "odds_only", "sole", "source", "type", "team"]
  557. # horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
  558. # odds_only, sole, "hg3535", "0", ""]
  559. # horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
  560. # data_list.append(horn_oe_data)
  561. #
  562. # if pt == '3':
  563. # ris_stringscene = 1
  564. # else:
  565. # ris_stringscene = 0
  566. # odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid", "is_stringscene", "utime", "pt", 'match_identity']
  567. # odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid, ris_stringscene, utime, pt, match_identity]
  568. # odds_dict = dict(zip(odds_key, odds_value))
  569. # if data_list:
  570. # res = Helper.async_post(ODDS_URL, odds_dict)
  571. # if res:
  572. # if res.get('status') == 1:
  573. # logger.info('足球详细赔率提交成功, {}'.format(res))
  574. # # logger.info(odds_dict)
  575. # else:
  576. # logger.warning('足球相信赔率提交失败, {}'.format(res))
  577. # # logger.warning(odds_dict)
  578. # else:
  579. # logging.warning('足球详细赔率接口异常, {}'.format(res))
  580. # else:
  581. # logger.info('足球详细赔率列表为空')
  582. # # # 角球处理分割线---------------------------------------------------------------------------------------------------
  583. # # horn_team = item['horn_team']
  584. # # if horn_team:
  585. # # team_home = horn_team['horn_home']
  586. # # team_guest = horn_team['horn_guest']
  587. # # match_id = horn_team['horn_id']
  588. # # match_list = []
  589. # # match_identity = Helper.genearte_uuid(team_home + team_guest + new_us_time)
  590. # # # if self.db.zq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
  591. # # if self.db.zq_competition35.find({'match_identity': match_identity, pt_status: 1}).count() < 1:
  592. # # match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  593. # # match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  594. # # "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  595. # # "half_match_id", "is_today", 'is_horn', 'match_identity']
  596. # # match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  597. # # "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, 1, match_identity]
  598. # # match_data = dict(zip(match_kay, match_value))
  599. # # match_list.append(match_data)
  600. # # match_dict['data'] = match_list
  601. # # res = Helper.async_post(MATCH_URL, match_dict)
  602. # # if res:
  603. # # if res.get('status') == 1:
  604. # # self.db.zq_competition35.insert(match_data)
  605. # # logger.info('足球角球, 赛事表提交失败, {}'.format(res))
  606. # # # logger.info(match_dict)
  607. # # else:
  608. # # logger.warning('足球角球, 赛事表提交失败, {}'.format(res))
  609. # # # logger.warning(match_dict)
  610. # # else:
  611. # # logger.warning('足球角球, 赛事接口异常提交失败, {}'.format(res))
  612. # # # logger.warning(match_dict)
  613. # # else:
  614. # # logger.info('足球角球, 赛事已存在,不提交')
  615. # # data_list = []
  616. # # odds_onlys = []
  617. # # p_code = 'CB'
  618. # # horn_ou_dict = item['horn_ou_dict']
  619. # # horn_ou_dict_rule = item['horn_ou_dict_rule']
  620. # # horn_oe_dict = item['horn_oe_dict']
  621. # # horn_oe_dict_rule = item['horn_oe_dict_rule']
  622. # # if horn_ou_dict:
  623. # # for key, value in horn_ou_dict.items():
  624. # # hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  625. # # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  626. # # odds_only = Helper.genearte_MD5(hash_str, pt)
  627. # # sole = Helper.genearte_MD5(sole_str, pt)
  628. # # horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  629. # # "condition", "odds_only", "sole", "source", "type", "team"]
  630. # # horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
  631. # # odds_only, sole, "hg3535", "0", ""]
  632. # # horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
  633. # # data_list.append(horn_ou_data)
  634. # #
  635. # # if horn_oe_dict:
  636. # # for key, value in horn_oe_dict.items():
  637. # # hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  638. # # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  639. # # odds_only = Helper.genearte_MD5(hash_str, pt)
  640. # # sole = Helper.genearte_MD5(sole_str, pt)
  641. # # horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  642. # # "condition", "odds_only", "sole", "source", "type", "team"]
  643. # # horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
  644. # # odds_only, sole, "hg3535", "0", ""]
  645. # # horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
  646. # # data_list.append(horn_oe_data)
  647. # #
  648. # # if pt == '3':
  649. # # ris_stringscene = 1
  650. # # else:
  651. # # ris_stringscene = 0
  652. # # odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
  653. # # "is_stringscene", "utime", "pt", 'match_identity']
  654. # # odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
  655. # # ris_stringscene, utime, pt, match_identity]
  656. # # odds_dict = dict(zip(odds_key, odds_value))
  657. # # if data_list:
  658. # # res = Helper.async_post(ODDS_URL, odds_dict)
  659. # # if res:
  660. # # if res.get('status') == 1:
  661. # # logger.info('足球角球, 详细赔率提交成功, {}'.format(res))
  662. # # # logger.info(odds_dict)
  663. # # else:
  664. # # logger.warning('足球角球, 详细赔率提交失败, {}'.format(res))
  665. # # # logger.warning(odds_dict)
  666. # # else:
  667. # # logging.warning('足球角球, 详细赔率接口异常, {}'.format(res))
  668. # # else:
  669. # # logger.info('足球详细赔率列表为空')
  670. # reactor.callFromThread(out.callback, item)
  671. >>>>>>> 10c979a4fcc4f2d36f17fa2ecd6de7bad38358f3