zuqiu.py 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. import datetime
  2. import time
  3. import logging
  4. import pymongo
  5. from twisted.internet import defer, reactor
  6. from ..utils.helper import Helper
  7. from .ball_func import new_time
  8. from ..settings import M_HOST, M_USER, M_PASSWORD, M_POST, M_DB, LEAGUE_URL, ODDS_URL, MATCH_URL
  9. class Zuqiupipeline(object):
  10. def open_spider(self, spider):
  11. # self.connection = AsyncIOMotorClient("mongodb://{}:{}@{}:{}/database?authSource={}".format('kaiyou', 'kaiyou', '192.168.2.200', 27017, 'kaiyou'))
  12. # session = aiohttp.ClientSession()
  13. self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST, authSource='kaiyou')
  14. self.db = self.mongo[M_DB]
  15. @defer.inlineCallbacks
  16. def process_item(self, item, spider):
  17. out = defer.Deferred()
  18. reactor.callInThread(self._do_calculation, item, out)
  19. yield out
  20. # defer.returnValue(item)
  21. # def process_item(self, item, spider):
  22. def _do_calculation(self, item, out):
  23. logger = logging.getLogger(__name__)
  24. # 比赛日期
  25. try:
  26. data_game = item['data_game'].split("/")
  27. month = str(data_game[1].strip())
  28. day = str(data_game[0])
  29. except Exception as e:
  30. logger.warning(e)
  31. data_game = item['data_game'].split(" ")
  32. months = str(data_game[1].strip())
  33. month_dict = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07',
  34. 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}
  35. month = month_dict[months]
  36. day = str(data_game[0])
  37. # 比赛时间
  38. time_game = str(item['time_game'])
  39. # 比赛时间,时间戳
  40. us_time = str(datetime.datetime.now().year) + "-" + month + "-" + day + " " + time_game + ":00"
  41. # 现在时间,时间戳
  42. utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
  43. # 比赛id
  44. match_id = item['game_id']
  45. # 联赛id
  46. league_id = item['league_id']
  47. # 联赛name
  48. league_name = item['league_name']
  49. # # 主队
  50. team_home = item['team_home']
  51. # 客队
  52. team_guest = item['team_guest']
  53. # number
  54. tag_number = item['number']
  55. pt = str(item['pt'])
  56. match_date, match_time, time3 = new_time(us_time)
  57. # 联赛接口写入
  58. last_time = '{}-12-31 23:59:59'.format(datetime.datetime.now().year)
  59. league_list = []
  60. uuid = Helper.genearte_uuid(league_name + 'hg3535')
  61. if self.db.zq_league35.find({'lg_id': league_id}).count() < 1:
  62. league_dict = {"game_code": "zq", "title": "league", "source": "hg3535"}
  63. league_key = ["name_chinese", "kind", "match_mode", "if_stop", "last_time", "lg_id", "source", "uuid"]
  64. league_value = [league_name, "1", "1", "0", last_time, league_id, "hg3535", uuid]
  65. league_data = dict(zip(league_key, league_value))
  66. league_list.append(league_data)
  67. league_dict['data'] = league_list
  68. res = Helper.async_post(LEAGUE_URL, league_dict)
  69. if res:
  70. if res.get('status') == 1:
  71. self.db.zq_league35.insert(league_data)
  72. # self.db.zq_league35.update({'lg_id': league_id}, {'$set': league_data},
  73. # upsert=True)
  74. else:
  75. logging.warning('足球详细赔率接口异常, {}'.format(res))
  76. else:
  77. logging.info('{},联赛已存在, 不提交'.format(league_name))
  78. pt_dict = {'1': 'is_today', '2': 'is_morningplate', '3': 'is_stringscene', '4': 'is_rollball'}
  79. pt_status = pt_dict[pt]
  80. if pt == '3':
  81. is_rollball = 0
  82. is_today = 0
  83. is_morningplate = 0
  84. is_stringscene = 1
  85. elif pt == '2':
  86. is_rollball = 0
  87. is_today = 0
  88. is_morningplate = 1
  89. is_stringscene = 0
  90. else:
  91. is_today = 1
  92. is_rollball = 0
  93. is_morningplate = 0
  94. is_stringscene = 0
  95. match_list = []
  96. if self.db.zq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
  97. match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  98. match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  99. "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  100. "half_match_id", "is_today", "is_horn"]
  101. match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  102. "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, 0]
  103. match_data = dict(zip(match_kay, match_value))
  104. match_list.append(match_data)
  105. match_dict['data'] = match_list
  106. res = Helper.async_post(MATCH_URL, match_dict)
  107. if res:
  108. if res.get('status') == 1:
  109. self.db.zq_competition35.insert(match_data)
  110. # self.db.zq_competition35.update({'match_id': match_id, pt_status: 1}, {'$set': match_data},
  111. # upsert=True)
  112. else:
  113. logger.warning('足球赛事表提交失败, {}'.format(res))
  114. logger.warning(match_dict)
  115. else:
  116. logger.warning('足球赛事接口异常提交失败, {}'.format(res))
  117. logger.warning(match_dict)
  118. else:
  119. logger.info('足球赛事已存在,不提交')
  120. p_code = "GS"
  121. half_size_guest = item["half_size_guest"]
  122. half_size_guest_rule = item["half_size_guest_rule"]
  123. half_size_home = item["half_size_home"]
  124. half_size_home_rule = item["half_size_home_rule"]
  125. data_list = []
  126. odds_onlys = []
  127. # half_size_guest
  128. for index, value in enumerate(half_size_guest):
  129. hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
  130. value) + "hg3535" + str(match_id)
  131. sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
  132. odds_only = Helper.genearte_MD5(hash_str, pt)
  133. sole = Helper.genearte_MD5(sole_str, pt)
  134. half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  135. "odds_only", "sole", "source", "type", "team"]
  136. condition = half_size_guest_rule[index]
  137. half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
  138. odds_only, sole, "hg3535", "0", ""]
  139. half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
  140. data_list.append(half_size_guest_data)
  141. # half_size_home
  142. for index, value in enumerate(half_size_home):
  143. hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
  144. value) + "hg3535" + str(match_id)
  145. sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
  146. odds_only = Helper.genearte_MD5(hash_str, pt)
  147. sole = Helper.genearte_MD5(sole_str, pt)
  148. half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  149. "odds_only", "sole", "source", "type", "team"]
  150. condition = half_size_home_rule[index]
  151. half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
  152. odds_only, sole, "hg3535", "0", ""]
  153. half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
  154. data_list.append(half_size_home_data)
  155. # 全场场大小
  156. size_guest = item["size_guest"]
  157. size_guest_rule = item["size_guest_rule"]
  158. size_home = item["size_home"]
  159. size_home_rule = item["size_home_rule"]
  160. # size_home
  161. for index, value in enumerate(size_home):
  162. hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
  163. match_id)
  164. sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
  165. odds_only = Helper.genearte_MD5(hash_str, pt)
  166. sole = Helper.genearte_MD5(sole_str, pt)
  167. size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  168. "odds_only", "sole", "source", "type", "team"]
  169. condition = size_home_rule[index]
  170. size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
  171. sole, "hg3535", "0", ""]
  172. size_home_data = dict(zip(size_home_key, size_home_value))
  173. data_list.append(size_home_data)
  174. # size_guest
  175. for index, value in enumerate(size_guest):
  176. hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
  177. match_id)
  178. sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
  179. odds_only = Helper.genearte_MD5(hash_str, pt)
  180. sole = Helper.genearte_MD5(sole_str, pt)
  181. size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  182. "odds_only", "sole", "source", "type", "team"]
  183. condition = size_guest_rule[index]
  184. size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
  185. sole, "hg3535", "0", ""]
  186. size_home_data = dict(zip(size_guest_key, size_guest_value))
  187. data_list.append(size_home_data)
  188. p_code = 'CO'
  189. half_concede_home_rule = item["half_concede_home_rule"]
  190. half_concede_home = item["half_concede_home"]
  191. half_concede_guest_rule = item["half_concede_guest_rule"]
  192. half_concede_guest = item["half_concede_guest"]
  193. # half_concede_home
  194. if half_concede_guest:
  195. for index, value in enumerate(half_concede_guest):
  196. hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
  197. value) + "hg3535" + str(match_id)
  198. sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
  199. odds_only = Helper.genearte_MD5(hash_str, pt)
  200. sole = Helper.genearte_MD5(sole_str, pt)
  201. half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  202. "odds_only", "sole", "source", "type", "team"]
  203. condition = half_concede_guest_rule[index]
  204. half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
  205. odds_only, sole, "hg3535", "0", ""]
  206. half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
  207. data_list.append(half_concede_guest_data)
  208. # half_concede_home
  209. if half_concede_home:
  210. for index, value in enumerate(half_concede_home):
  211. hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
  212. value) + "hg3535" + str(match_id)
  213. sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
  214. odds_only = Helper.genearte_MD5(hash_str, pt)
  215. sole = Helper.genearte_MD5(sole_str, pt)
  216. half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  217. "odds_only", "sole", "source", "type", "team"]
  218. condition = half_concede_home_rule[index]
  219. half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
  220. odds_only, sole, "hg3535", "0", ""]
  221. half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
  222. data_list.append(half_concede_home_data)
  223. concede_guest = item["concede_guest"]
  224. concede_guest_rule = item["concede_guest_rule"]
  225. concede_home = item["concede_home"]
  226. concede_home_rule = item["concede_home_rule"]
  227. # concede_guest
  228. if concede_guest:
  229. for index, value in enumerate(concede_guest):
  230. hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
  231. value) + "hg3535" + str(match_id)
  232. sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
  233. odds_only = Helper.genearte_MD5(hash_str, pt)
  234. sole = Helper.genearte_MD5(sole_str, pt)
  235. concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  236. "odds_only", "sole", "source", "type", "team"]
  237. condition = concede_guest_rule[index]
  238. concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
  239. odds_only, sole, "hg3535", "0", ""]
  240. concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
  241. data_list.append(concede_guest_data)
  242. # concede_home
  243. if concede_home:
  244. for index, value in enumerate(concede_home):
  245. hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
  246. value) + "hg3535" + str(match_id)
  247. sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
  248. odds_only = Helper.genearte_MD5(hash_str, pt)
  249. sole = Helper.genearte_MD5(sole_str, pt)
  250. concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  251. "odds_only", "sole", "source", "type", "team"]
  252. condition = concede_home_rule[index]
  253. concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
  254. sole, "hg3535", "0", ""]
  255. concede_guest_data = dict(zip(concede_home_key, concede_home_value))
  256. data_list.append(concede_guest_data)
  257. # 独赢----------------------------------------------------------------------------------------------------------
  258. p_code = 'C'
  259. half_capot_home = item["half_capot_home"]
  260. half_capot_guest = item["half_capot_guest"]
  261. half_capot_dogfall = item["half_capot_dogfall"]
  262. capot_home = item["capot_home"]
  263. capot_guest = item["capot_guest"]
  264. capot_dogfall = item["capot_dogfall"]
  265. # half_capot_home
  266. hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
  267. sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
  268. odds_only = Helper.genearte_MD5(hash_str, pt)
  269. sole = Helper.genearte_MD5(sole_str, pt)
  270. half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  271. "odds_only", "sole", "source", "type", "team"]
  272. half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
  273. odds_only, sole, "hg3535", "0", ""]
  274. half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
  275. data_list.append(half_capot_homet_data)
  276. # half_capot_guest
  277. hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
  278. sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
  279. odds_only = Helper.genearte_MD5(hash_str, pt)
  280. sole = Helper.genearte_MD5(sole_str, pt)
  281. half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  282. "odds_only", "sole", "source", "type", "team"]
  283. half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
  284. odds_only, sole, "hg3535", "0", ""]
  285. half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
  286. data_list.append(half_capot_guest_data)
  287. # half_capot_dogfall
  288. hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
  289. sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
  290. odds_only = Helper.genearte_MD5(hash_str, pt)
  291. sole = Helper.genearte_MD5(sole_str, pt)
  292. half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  293. "odds_only", "sole", "source", "type", "team"]
  294. half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
  295. odds_only, sole, "hg3535", "0", ""]
  296. half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
  297. data_list.append(half_capot_dogfall_data)
  298. # capot_dogfall
  299. hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
  300. sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
  301. odds_only = Helper.genearte_MD5(hash_str, pt)
  302. sole = Helper.genearte_MD5(sole_str, pt)
  303. capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  304. "odds_only", "sole", "source", "type", "team"]
  305. capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
  306. sole, "hg3535", "0", ""]
  307. capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
  308. data_list.append(capot_dogfall_data)
  309. # capot_home
  310. hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
  311. sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
  312. odds_only = Helper.genearte_MD5(hash_str, pt)
  313. sole = Helper.genearte_MD5(sole_str, pt)
  314. capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  315. "odds_only", "sole", "source", "type", "team"]
  316. capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
  317. odds_only, sole, "hg3535", "0", ""]
  318. capot_homet_data = dict(zip(capot_home_key, capot_home_value))
  319. data_list.append(capot_homet_data)
  320. # capot_guest
  321. hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
  322. sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
  323. odds_only = Helper.genearte_MD5(hash_str, pt)
  324. sole = Helper.genearte_MD5(sole_str, pt)
  325. capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  326. "odds_only", "sole", "source", "type", "team"]
  327. capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
  328. odds_only, sole, "hg3535", "0", ""]
  329. capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
  330. data_list.append(capot_guest_data)
  331. # 入球数单双-----------------------------------------------------------------------------------------------------
  332. # p_code, p_id = get_pcode(corner_ball, 'two_sides')
  333. p_code = 'TS'
  334. odd_even_odd = item["odd_even_odd"]
  335. odd_even_even = item["odd_even_even"]
  336. half_odd_even_odd = item["half_odd_even_odd"]
  337. half_odd_even_even = item["half_odd_even_even"]
  338. # odd_even_odd
  339. hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
  340. sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
  341. odds_only = Helper.genearte_MD5(hash_str, pt)
  342. sole = Helper.genearte_MD5(sole_str, pt)
  343. single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  344. "odds_only", "sole", "source", "type", "team"]
  345. single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
  346. odds_only, sole, "hg3535", "0", ""]
  347. single_data = dict(zip(single_key, single_value))
  348. data_list.append(single_data)
  349. # odd_even_even
  350. hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
  351. sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
  352. odds_only = Helper.genearte_MD5(hash_str, pt)
  353. sole = Helper.genearte_MD5(sole_str, pt)
  354. double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  355. "odds_only", "sole", "source", "type", "team"]
  356. double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
  357. odds_only, sole, "hg3535", "0", ""]
  358. double_data = dict(zip(double_key, double_value))
  359. data_list.append(double_data)
  360. # half_odd_even_even
  361. hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
  362. sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
  363. odds_only = Helper.genearte_MD5(hash_str, pt)
  364. sole = Helper.genearte_MD5(sole_str, pt)
  365. half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  366. "odds_only", "sole", "source", "type", "team"]
  367. half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
  368. odds_only, sole, "hg3535", "0", ""]
  369. half_double_data = dict(zip(half_double_key, half_double_value))
  370. data_list.append(half_double_data)
  371. # half_odd_even_odd
  372. hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
  373. sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
  374. odds_only = Helper.genearte_MD5(hash_str, pt)
  375. sole = Helper.genearte_MD5(sole_str, pt)
  376. half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  377. "odds_only", "sole", "source", "type", "team"]
  378. half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
  379. sole, "hg3535", "0", ""]
  380. half_single_data = dict(zip(half_single_key, half_single_value))
  381. data_list.append(half_single_data)
  382. # 总入球数 ------------------------------------------------------------------------------------------------------
  383. p_code = 'TG'
  384. total_goals = item['total_goal']
  385. total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6','tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
  386. "tg2_h": '2', "tg3_h": '3或以上'}
  387. # 全场入球数 单双
  388. # 上半场入球数 单双
  389. for key, value in total_goals.items():
  390. hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
  391. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  392. odds_only = Helper.genearte_MD5(hash_str, pt)
  393. sole = Helper.genearte_MD5(sole_str, pt)
  394. total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  395. "odds_only", "sole", "source", "type", "team"]
  396. total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
  397. sole, "hg3535", "0", ""]
  398. total_goals_data = dict(zip(total_goals_key, total_goals_value))
  399. data_list.append(total_goals_data)
  400. # 全场半场 ------------------------------------------------------------------------------------------------------
  401. half_fulls = item['half_full']
  402. p_code = 'HF'
  403. full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
  404. "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
  405. if half_fulls:
  406. for key, value in half_fulls.items():
  407. hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
  408. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  409. odds_only = Helper.genearte_MD5(hash_str, pt)
  410. sole = Helper.genearte_MD5(sole_str, pt)
  411. half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  412. "odds_only", "sole", "source", "type", "team"]
  413. half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
  414. sole, "hg3535", "0", ""]
  415. half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
  416. data_list.append(half_fulls_data)
  417. # 波胆-----------------------------------------------------------------------------------------------------------
  418. bodan_datas = item['bodan_data']
  419. p_code = 'B'
  420. bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
  421. "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
  422. "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
  423. "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
  424. "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
  425. "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2", "b03_h": "0-3",
  426. "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2", "b33_h": "3-3",
  427. "bo_h": "其他"}
  428. if bodan_datas:
  429. for key, value in bodan_datas.items():
  430. hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
  431. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  432. odds_only = Helper.genearte_MD5(hash_str, pt)
  433. sole = Helper.genearte_MD5(sole_str, pt)
  434. bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  435. "odds_only", "sole", "source", "type", "team"]
  436. bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
  437. sole, "hg3535", "0", ""]
  438. bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
  439. data_list.append(bodan_dict_data)
  440. # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
  441. first_last_balls = item['first_last_ball']
  442. # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
  443. p_code = 'FLB'
  444. first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
  445. if first_last_balls:
  446. for key, value in first_last_balls.items():
  447. hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
  448. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  449. odds_only = Helper.genearte_MD5(hash_str, pt)
  450. sole = Helper.genearte_MD5(sole_str, pt)
  451. first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  452. "odds_only", "sole", "source", "type", "team"]
  453. first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key], odds_only,
  454. sole, "hg3535", "0", ""]
  455. first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
  456. data_list.append(first_last_balls_data)
  457. # 球队得分大小
  458. p_code = 'TB'
  459. # 全场
  460. full_dicts = item['full_data']
  461. # 上半场
  462. half_dicts = item['half_data']
  463. full_dict_rules = item['full_data_rule']
  464. half_dict_rules = item['half_data_rule']
  465. if full_dicts:
  466. for key, value in full_dicts.items():
  467. hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  468. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  469. odds_only = Helper.genearte_MD5(hash_str, pt)
  470. sole = Helper.genearte_MD5(sole_str, pt)
  471. full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  472. "condition", "odds_only", "sole", "source", "type", "team"]
  473. full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
  474. odds_only,sole, "hg3535", "0", ""]
  475. full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
  476. data_list.append(full_dict_rules_data)
  477. if half_dicts:
  478. for key, value in half_dicts.items():
  479. hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  480. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  481. odds_only = Helper.genearte_MD5(hash_str, pt)
  482. sole = Helper.genearte_MD5(sole_str, pt)
  483. half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  484. "condition","odds_only", "sole", "source", "type", "team"]
  485. half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
  486. odds_only, sole, "hg3535", "0", ""]
  487. half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
  488. data_list.append(half_dicts_data)
  489. p_code = 'CB'
  490. horn_ou_dict = item['horn_ou_dict']
  491. horn_ou_dict_rule = item['horn_ou_dict_rule']
  492. horn_oe_dict = item['horn_oe_dict']
  493. horn_oe_dict_rule = item['horn_oe_dict_rule']
  494. if horn_ou_dict:
  495. for key, value in horn_ou_dict.items():
  496. hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  497. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  498. odds_only = Helper.genearte_MD5(hash_str, pt)
  499. sole = Helper.genearte_MD5(sole_str, pt)
  500. horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  501. "condition", "odds_only", "sole", "source", "type", "team"]
  502. horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
  503. odds_only, sole, "hg3535", "0", ""]
  504. horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
  505. data_list.append(horn_ou_data)
  506. if horn_oe_dict:
  507. for key, value in horn_oe_dict.items():
  508. hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  509. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  510. odds_only = Helper.genearte_MD5(hash_str, pt)
  511. sole = Helper.genearte_MD5(sole_str, pt)
  512. horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  513. "condition", "odds_only", "sole", "source", "type", "team"]
  514. horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
  515. odds_only, sole, "hg3535", "0", ""]
  516. horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
  517. data_list.append(horn_oe_data)
  518. if pt == '3':
  519. ris_stringscene = 1
  520. else:
  521. ris_stringscene = 0
  522. odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid", "is_stringscene", "utime", "pt"]
  523. odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid, ris_stringscene, utime, pt]
  524. odds_dict = dict(zip(odds_key, odds_value))
  525. if data_list:
  526. res = Helper.async_post(ODDS_URL, odds_dict)
  527. if res:
  528. if res.get('status') == 1:
  529. logger.info('足球详细赔率提交成功, {}'.format(res))
  530. logger.info(odds_dict)
  531. else:
  532. logger.warning('足球相信赔率提交失败, {}'.format(res))
  533. logger.warning(odds_dict)
  534. else:
  535. logging.warning('足球详细赔率接口异常, {}'.format(res))
  536. else:
  537. logger.info('足球详细赔率列表为空')
  538. # 角球处理分割线---------------------------------------------------------------------------------------------------
  539. horn_team = item['horn_team']
  540. if horn_team:
  541. team_home = horn_team['horn_home']
  542. team_guest = horn_team['horn_guest']
  543. match_id = horn_team['horn_id']
  544. match_list = []
  545. if self.db.zq_competition35.find({'match_id': match_id, pt_status: 1}).count() < 1:
  546. match_dict = {"game_code": "zq", "title": "match", "source": "hg3535"}
  547. match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
  548. "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
  549. "half_match_id", "is_today", 'is_horn']
  550. match_value = [team_home, team_guest, league_id, 0, match_id, match_date, match_time, tag_number,
  551. "hg3535", is_rollball, is_morningplate, is_stringscene, us_time, uuid, 0, is_today, 1]
  552. match_data = dict(zip(match_kay, match_value))
  553. match_list.append(match_data)
  554. match_dict['data'] = match_list
  555. res = Helper.async_post(MATCH_URL, match_dict)
  556. if res:
  557. if res.get('status') == 1:
  558. self.db.zq_competition35.insert(match_data)
  559. # self.db.zq_competition35.update({'match_id': match_id, pt_status: 1}, {'$set': match_data},
  560. # upsert=True)
  561. logger.info('足球角球, 赛事表提交失败, {}'.format(res))
  562. logger.info(match_dict)
  563. else:
  564. logger.warning('足球角球, 赛事表提交失败, {}'.format(res))
  565. logger.warning(match_dict)
  566. else:
  567. logger.warning('足球角球, 赛事接口异常提交失败, {}'.format(res))
  568. logger.warning(match_dict)
  569. else:
  570. logger.info('足球角球, 赛事已存在,不提交')
  571. #
  572. # p_code = "GS"
  573. # half_size_guest = item["half_size_guest"]
  574. # half_size_guest_rule = item["half_size_guest_rule"]
  575. # half_size_home = item["half_size_home"]
  576. # half_size_home_rule = item["half_size_home_rule"]
  577. # data_list = []
  578. # odds_onlys = []
  579. # # half_size_guest
  580. # for index, value in enumerate(half_size_guest):
  581. # hash_str = p_code + "gss_h" + str(index) + str(half_size_guest_rule[index]) + str(
  582. # value) + "hg3535" + str(match_id)
  583. # sole_str = p_code + "gss_h" + str(index) + str(match_id) + "hg3535"
  584. # odds_only = Helper.genearte_MD5(hash_str, pt)
  585. # sole = Helper.genearte_MD5(sole_str, pt)
  586. # half_size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  587. # "condition",
  588. # "odds_only", "sole", "source", "type", "team"]
  589. # condition = half_size_guest_rule[index]
  590. # half_size_guest_value = [match_id, league_id, "gss_h", "0", index, p_code, value, condition,
  591. # odds_only, sole, "hg3535", "0", ""]
  592. # half_size_guest_data = dict(zip(half_size_guest_key, half_size_guest_value))
  593. # data_list.append(half_size_guest_data)
  594. # # half_size_home
  595. # for index, value in enumerate(half_size_home):
  596. # hash_str = p_code + "gsb_h" + str(index) + str(half_size_home_rule[index]) + str(
  597. # value) + "hg3535" + str(match_id)
  598. # sole_str = p_code + "gsb_h" + str(index) + str(match_id) + "hg3535"
  599. # odds_only = Helper.genearte_MD5(hash_str, pt)
  600. # sole = Helper.genearte_MD5(sole_str, pt)
  601. # half_size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  602. # "odds_only", "sole", "source", "type", "team"]
  603. # condition = half_size_home_rule[index]
  604. # half_size_home_value = [match_id, league_id, "gsb_h", "0", index, p_code, value, condition,
  605. # odds_only, sole, "hg3535", "0", ""]
  606. # half_size_home_data = dict(zip(half_size_home_key, half_size_home_value))
  607. # data_list.append(half_size_home_data)
  608. #
  609. # # 全场场大小
  610. # size_guest = item["size_guest"]
  611. # size_guest_rule = item["size_guest_rule"]
  612. # size_home = item["size_home"]
  613. # size_home_rule = item["size_home_rule"]
  614. # # size_home
  615. # for index, value in enumerate(size_home):
  616. # hash_str = p_code + "gsb" + str(index) + str(size_home_rule[index]) + str(value) + "hg3535" + str(
  617. # match_id)
  618. # sole_str = p_code + "gsb" + str(index) + str(match_id) + "hg3535"
  619. # odds_only = Helper.genearte_MD5(hash_str, pt)
  620. # sole = Helper.genearte_MD5(sole_str, pt)
  621. # size_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  622. # "odds_only", "sole", "source", "type", "team"]
  623. # condition = size_home_rule[index]
  624. # size_home_value = [match_id, league_id, "gsb", "0", index, p_code, value, condition, odds_only,
  625. # sole, "hg3535", "0", ""]
  626. # size_home_data = dict(zip(size_home_key, size_home_value))
  627. # data_list.append(size_home_data)
  628. # # size_guest
  629. # for index, value in enumerate(size_guest):
  630. # hash_str = p_code + "gss" + str(index) + str(size_guest_rule[index]) + str(value) + "hg3535" + str(
  631. # match_id)
  632. # sole_str = p_code + "gss" + str(index) + str(match_id) + "hg3535"
  633. # odds_only = Helper.genearte_MD5(hash_str, pt)
  634. # sole = Helper.genearte_MD5(sole_str, pt)
  635. # size_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  636. # "odds_only", "sole", "source", "type", "team"]
  637. # condition = size_guest_rule[index]
  638. # size_guest_value = [match_id, league_id, "gss", "0", index, p_code, value, condition, odds_only,
  639. # sole, "hg3535", "0", ""]
  640. # size_home_data = dict(zip(size_guest_key, size_guest_value))
  641. # data_list.append(size_home_data)
  642. #
  643. # p_code = 'CO'
  644. # half_concede_home_rule = item["half_concede_home_rule"]
  645. # half_concede_home = item["half_concede_home"]
  646. # half_concede_guest_rule = item["half_concede_guest_rule"]
  647. # half_concede_guest = item["half_concede_guest"]
  648. # # half_concede_home
  649. # if half_concede_guest:
  650. # for index, value in enumerate(half_concede_guest):
  651. # hash_str = p_code + "cog_h" + str(index) + str(half_concede_guest_rule[index]) + str(
  652. # value) + "hg3535" + str(match_id)
  653. # sole_str = p_code + "cog_h" + str(index) + str(match_id) + "hg3535"
  654. # odds_only = Helper.genearte_MD5(hash_str, pt)
  655. # sole = Helper.genearte_MD5(sole_str, pt)
  656. # half_concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  657. # "condition",
  658. # "odds_only", "sole", "source", "type", "team"]
  659. # condition = half_concede_guest_rule[index]
  660. # half_concede_guest_value = [match_id, league_id, "cog_h", "0", index, p_code, value, condition,
  661. # odds_only, sole, "hg3535", "0", ""]
  662. # half_concede_guest_data = dict(zip(half_concede_guest_key, half_concede_guest_value))
  663. # data_list.append(half_concede_guest_data)
  664. #
  665. # # half_concede_home
  666. # if half_concede_home:
  667. # for index, value in enumerate(half_concede_home):
  668. # hash_str = p_code + "coh_h" + str(index) + str(half_concede_home_rule[index]) + str(
  669. # value) + "hg3535" + str(match_id)
  670. # sole_str = p_code + "coh_h" + str(index) + str(match_id) + "hg3535"
  671. # odds_only = Helper.genearte_MD5(hash_str, pt)
  672. # sole = Helper.genearte_MD5(sole_str, pt)
  673. # half_concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  674. # "condition",
  675. # "odds_only", "sole", "source", "type", "team"]
  676. # condition = half_concede_home_rule[index]
  677. # half_concede_home_value = [match_id, league_id, "coh_h", "0", index, p_code, value, condition,
  678. # odds_only, sole, "hg3535", "0", ""]
  679. # half_concede_home_data = dict(zip(half_concede_home_key, half_concede_home_value))
  680. # data_list.append(half_concede_home_data)
  681. #
  682. # concede_guest = item["concede_guest"]
  683. # concede_guest_rule = item["concede_guest_rule"]
  684. # concede_home = item["concede_home"]
  685. # concede_home_rule = item["concede_home_rule"]
  686. # # concede_guest
  687. # if concede_guest:
  688. # for index, value in enumerate(concede_guest):
  689. # hash_str = p_code + "cog" + str(index) + str(concede_guest_rule[index]) + str(
  690. # value) + "hg3535" + str(match_id)
  691. # sole_str = p_code + "cog" + str(index) + str(match_id) + "hg3535"
  692. # odds_only = Helper.genearte_MD5(hash_str, pt)
  693. # sole = Helper.genearte_MD5(sole_str, pt)
  694. # concede_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  695. # "condition",
  696. # "odds_only", "sole", "source", "type", "team"]
  697. # condition = concede_guest_rule[index]
  698. # concede_guest_value = [match_id, league_id, "cog", "0", index, p_code, value, condition,
  699. # odds_only, sole, "hg3535", "0", ""]
  700. # concede_guest_data = dict(zip(concede_guest_key, concede_guest_value))
  701. # data_list.append(concede_guest_data)
  702. # # concede_home
  703. # if concede_home:
  704. # for index, value in enumerate(concede_home):
  705. # hash_str = p_code + "coh" + str(index) + str(concede_home_rule[index]) + str(
  706. # value) + "hg3535" + str(match_id)
  707. # sole_str = p_code + "coh" + str(index) + str(match_id) + "hg3535"
  708. # odds_only = Helper.genearte_MD5(hash_str, pt)
  709. # sole = Helper.genearte_MD5(sole_str, pt)
  710. # concede_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  711. # "condition",
  712. # "odds_only", "sole", "source", "type", "team"]
  713. # condition = concede_home_rule[index]
  714. # concede_home_value = [match_id, league_id, "coh", "0", index, p_code, value, condition, odds_only,
  715. # sole, "hg3535", "0", ""]
  716. # concede_guest_data = dict(zip(concede_home_key, concede_home_value))
  717. # data_list.append(concede_guest_data)
  718. #
  719. # # 独赢----------------------------------------------------------------------------------------------------------
  720. # p_code = 'C'
  721. # half_capot_home = item["half_capot_home"]
  722. # half_capot_guest = item["half_capot_guest"]
  723. # half_capot_dogfall = item["half_capot_dogfall"]
  724. # capot_home = item["capot_home"]
  725. # capot_guest = item["capot_guest"]
  726. # capot_dogfall = item["capot_dogfall"]
  727. #
  728. # # half_capot_home
  729. # hash_str = p_code + "ch_h" + '0' + '1' + str(half_capot_home) + "hg3535" + str(match_id)
  730. # sole_str = p_code + "ch_h" + '0' + str(match_id) + "hg3535"
  731. # odds_only = Helper.genearte_MD5(hash_str, pt)
  732. # sole = Helper.genearte_MD5(sole_str, pt)
  733. # half_capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  734. # "odds_only", "sole", "source", "type", "team"]
  735. # half_capot_home_value = [match_id, league_id, "ch_h", "0", 0, p_code, half_capot_home, '1',
  736. # odds_only, sole, "hg3535", "0", ""]
  737. # half_capot_homet_data = dict(zip(half_capot_home_key, half_capot_home_value))
  738. # data_list.append(half_capot_homet_data)
  739. #
  740. # # half_capot_guest
  741. # hash_str = p_code + "cg_h" + '0' + '2' + str(half_capot_guest) + "hg3535" + str(match_id)
  742. # sole_str = p_code + "cg_h" + '0' + str(match_id) + "hg3535"
  743. # odds_only = Helper.genearte_MD5(hash_str, pt)
  744. # sole = Helper.genearte_MD5(sole_str, pt)
  745. # half_capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  746. # "odds_only", "sole", "source", "type", "team"]
  747. # half_capot_guest_value = [match_id, league_id, "cg_h", "0", 0, p_code, half_capot_guest, '2',
  748. # odds_only, sole, "hg3535", "0", ""]
  749. # half_capot_guest_data = dict(zip(half_capot_guest_key, half_capot_guest_value))
  750. # data_list.append(half_capot_guest_data)
  751. #
  752. # # half_capot_dogfall
  753. # hash_str = p_code + "cd_h" + '0' + 'X' + str(half_capot_dogfall) + "hg3535" + str(match_id)
  754. # sole_str = p_code + "cd_h" + '0' + str(match_id) + "hg3535"
  755. # odds_only = Helper.genearte_MD5(hash_str, pt)
  756. # sole = Helper.genearte_MD5(sole_str, pt)
  757. # half_capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  758. # "odds_only", "sole", "source", "type", "team"]
  759. # half_capot_dogfall_value = [match_id, league_id, "cd_h", "0", 0, p_code, half_capot_dogfall, 'X',
  760. # odds_only, sole, "hg3535", "0", ""]
  761. # half_capot_dogfall_data = dict(zip(half_capot_dogfall_key, half_capot_dogfall_value))
  762. # data_list.append(half_capot_dogfall_data)
  763. #
  764. # # capot_dogfall
  765. # hash_str = p_code + "cd" + '0' + 'X' + str(capot_dogfall) + "hg3535" + str(match_id)
  766. # sole_str = p_code + "cd" + '0' + str(match_id) + "hg3535"
  767. # odds_only = Helper.genearte_MD5(hash_str, pt)
  768. # sole = Helper.genearte_MD5(sole_str, pt)
  769. # capot_dogfall_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  770. # "odds_only", "sole", "source", "type", "team"]
  771. # capot_dogfall_value = [match_id, league_id, "cd", "0", 0, p_code, capot_dogfall, 'X', odds_only,
  772. # sole, "hg3535", "0", ""]
  773. # capot_dogfall_data = dict(zip(capot_dogfall_key, capot_dogfall_value))
  774. # data_list.append(capot_dogfall_data)
  775. #
  776. # # capot_home
  777. # hash_str = p_code + "ch" + '0' + '1' + str(capot_home) + "hg3535" + str(match_id)
  778. # sole_str = p_code + "ch" + '0' + str(match_id) + "hg3535"
  779. # odds_only = Helper.genearte_MD5(hash_str, pt)
  780. # sole = Helper.genearte_MD5(sole_str, pt)
  781. # capot_home_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  782. # "odds_only", "sole", "source", "type", "team"]
  783. # capot_home_value = [match_id, league_id, "ch", "0", 0, p_code, capot_home, '1',
  784. # odds_only, sole, "hg3535", "0", ""]
  785. # capot_homet_data = dict(zip(capot_home_key, capot_home_value))
  786. # data_list.append(capot_homet_data)
  787. #
  788. # # capot_guest
  789. # hash_str = p_code + "cg" + '0' + '2' + str(capot_guest) + "hg3535" + str(match_id)
  790. # sole_str = p_code + "cg" + '0' + str(match_id) + "hg3535"
  791. # odds_only = Helper.genearte_MD5(hash_str, pt)
  792. # sole = Helper.genearte_MD5(sole_str, pt)
  793. # capot_guest_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  794. # "odds_only", "sole", "source", "type", "team"]
  795. # capot_guest_value = [match_id, league_id, "cg", "0", 0, p_code, capot_guest, '2',
  796. # odds_only, sole, "hg3535", "0", ""]
  797. # capot_guest_data = dict(zip(capot_guest_key, capot_guest_value))
  798. # data_list.append(capot_guest_data)
  799. #
  800. # # 入球数单双-----------------------------------------------------------------------------------------------------
  801. # # p_code, p_id = get_pcode(corner_ball, 'two_sides')
  802. # p_code = 'TS'
  803. # odd_even_odd = item["odd_even_odd"]
  804. # odd_even_even = item["odd_even_even"]
  805. # half_odd_even_odd = item["half_odd_even_odd"]
  806. # half_odd_even_even = item["half_odd_even_even"]
  807. #
  808. # # odd_even_odd
  809. # hash_str = p_code + "tss" + '0' + '单' + str(odd_even_odd) + "hg3535" + str(match_id)
  810. # sole_str = p_code + "tss" + '0' + str(match_id) + "hg3535"
  811. # odds_only = Helper.genearte_MD5(hash_str, pt)
  812. # sole = Helper.genearte_MD5(sole_str, pt)
  813. # single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  814. # "odds_only", "sole", "source", "type", "team"]
  815. # single_value = [match_id, league_id, "tss", "0", 0, p_code, odd_even_odd, '单',
  816. # odds_only, sole, "hg3535", "0", ""]
  817. # single_data = dict(zip(single_key, single_value))
  818. # data_list.append(single_data)
  819. #
  820. # # odd_even_even
  821. # hash_str = p_code + "tsd" + '0' + '双' + str(odd_even_even) + "hg3535" + str(match_id)
  822. # sole_str = p_code + "tsd" + '0' + str(match_id) + "hg3535"
  823. # odds_only = Helper.genearte_MD5(hash_str, pt)
  824. # sole = Helper.genearte_MD5(sole_str, pt)
  825. # double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  826. # "odds_only", "sole", "source", "type", "team"]
  827. # double_value = [match_id, league_id, "tsd", "0", 0, p_code, odd_even_even, '双',
  828. # odds_only, sole, "hg3535", "0", ""]
  829. # double_data = dict(zip(double_key, double_value))
  830. # data_list.append(double_data)
  831. #
  832. # # half_odd_even_even
  833. # hash_str = p_code + "tsd_h" + '0' + '双' + str(half_odd_even_even) + "hg3535" + str(match_id)
  834. # sole_str = p_code + "tsd_h" + '0' + str(match_id) + "hg3535"
  835. # odds_only = Helper.genearte_MD5(hash_str, pt)
  836. # sole = Helper.genearte_MD5(sole_str, pt)
  837. # half_double_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  838. # "odds_only", "sole", "source", "type", "team"]
  839. # half_double_value = [match_id, league_id, "tsd_h", "0", 0, p_code, half_odd_even_even, '双',
  840. # odds_only, sole, "hg3535", "0", ""]
  841. # half_double_data = dict(zip(half_double_key, half_double_value))
  842. # data_list.append(half_double_data)
  843. #
  844. # # half_odd_even_odd
  845. # hash_str = p_code + "tss_h" + '0' + '单' + str(half_odd_even_odd) + "hg3535" + str(match_id)
  846. # sole_str = p_code + "tss_h" + '0' + str(match_id) + "hg3535"
  847. # odds_only = Helper.genearte_MD5(hash_str, pt)
  848. # sole = Helper.genearte_MD5(sole_str, pt)
  849. # half_single_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  850. # "odds_only", "sole", "source", "type", "team"]
  851. # half_single_value = [match_id, league_id, "tss_h", "0", 0, p_code, half_odd_even_odd, '单', odds_only,
  852. # sole, "hg3535", "0", ""]
  853. # half_single_data = dict(zip(half_single_key, half_single_value))
  854. # data_list.append(half_single_data)
  855. #
  856. # # 总入球数 ---------------------------------------------------------------------------------------------------
  857. # p_code = 'TG'
  858. # total_goals = item['total_goal']
  859. # total_dict = {'tg0': '0-1', 'tg1': '2-3', 'tg2': '4-6', 'tg3': '7或以上', 'tg0_h': '0', "tg1_h": '1',
  860. # "tg2_h": '2', "tg3_h": '3或以上'}
  861. # # 全场入球数 单双
  862. # # 上半场入球数 单双
  863. # for key, value in total_goals.items():
  864. # hash_str = p_code + key + '0' + total_dict[key] + str(value) + "hg3535" + str(match_id)
  865. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  866. # odds_only = Helper.genearte_MD5(hash_str, pt)
  867. # sole = Helper.genearte_MD5(sole_str, pt)
  868. # total_goals_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  869. # "odds_only", "sole", "source", "type", "team"]
  870. # total_goals_value = [match_id, league_id, key, "0", 0, p_code, value, total_dict[key], odds_only,
  871. # sole, "hg3535", "0", ""]
  872. # total_goals_data = dict(zip(total_goals_key, total_goals_value))
  873. # data_list.append(total_goals_data)
  874. #
  875. # # 全场半场 ---------------------------------------------------------------------------------------------------
  876. # half_fulls = item['half_full']
  877. # p_code = 'HF'
  878. # full_dict = {"hfhh": "主主", "hfhd": "主和", "hfhg": "主客", "hfdh": "和主",
  879. # "hfdd": "和和", "hfdg": "和客", "hfgh": "客主", "hfgd": "客和", "hfgg": "客客"}
  880. # if half_fulls:
  881. # for key, value in half_fulls.items():
  882. # hash_str = p_code + key + '0' + full_dict[key] + str(value) + "hg3535" + str(match_id)
  883. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  884. # odds_only = Helper.genearte_MD5(hash_str, pt)
  885. # sole = Helper.genearte_MD5(sole_str, pt)
  886. # half_fulls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  887. # "odds_only", "sole", "source", "type", "team"]
  888. # half_fulls_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict[key], odds_only,
  889. # sole, "hg3535", "0", ""]
  890. # half_fulls_data = dict(zip(half_fulls_key, half_fulls_value))
  891. # data_list.append(half_fulls_data)
  892. #
  893. # # 波胆-----------------------------------------------------------------------------------------------------------
  894. # bodan_datas = item['bodan_data']
  895. # p_code = 'B'
  896. # bodan_dict = {"b10": "1-0", "b20": "2-0", "b21": "2-1", "b30": "3-0", "b31": "3-1", "b32": "3-2",
  897. # "b40": "4-0", "b41": "4-1", "b42": "4-2", "b43": "4-3", "b01": "0-1", "b02": "0-2",
  898. # "b12": "1-2", "b03": "0-3", "b13": "1-3", "b23": "2-3", "b04": "0-4", "b14": "1-4",
  899. # "b24": "2-4", "b34": "3-4", "b00": "0-0", "b11": "1-1", "b22": "2-2", "b33": "3-3",
  900. # "b44": "4-4", "bo": "其他", "b10_h": "1-0", "b20_h": "2-0", "b21_h": "2-1", "b30_h": "3-0",
  901. # "b31_h": "3-1", "b32_h": "3-2", "b01_h": "0-1", "b02_h": "0-2", "b12_h": "1-2",
  902. # "b03_h": "0-3",
  903. # "b13_h": "1-3", "b23_h": "2-3", "b00_h": "0-0", "b11_h": "1-1", "b22_h": "2-2",
  904. # "b33_h": "3-3",
  905. # "bo_h": "其他"}
  906. # if bodan_datas:
  907. # for key, value in bodan_datas.items():
  908. # hash_str = p_code + key + '0' + bodan_dict[key] + str(value) + "hg3535" + str(match_id)
  909. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  910. # odds_only = Helper.genearte_MD5(hash_str, pt)
  911. # sole = Helper.genearte_MD5(sole_str, pt)
  912. # bodan_dict_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds", "condition",
  913. # "odds_only", "sole", "source", "type", "team"]
  914. # bodan_dict_value = [match_id, league_id, key, "0", 0, p_code, value, bodan_dict[key], odds_only,
  915. # sole, "hg3535", "0", ""]
  916. # bodan_dict_data = dict(zip(bodan_dict_key, bodan_dict_value))
  917. # data_list.append(bodan_dict_data)
  918. #
  919. # # 最先进球/最后进球 ----------------------------------------------------------------------------------------------
  920. # first_last_balls = item['first_last_ball']
  921. # # p_code, p_id = get_pcode(corner_ball, 'first_last_ball')
  922. # p_code = 'FLB'
  923. # first_last_dict = {"flbfh": "最先进球", "flbfg": "最先进球", "flblh": "最后进球", "flblg": "最后进球", "flbn": "没有进球"}
  924. # if first_last_balls:
  925. # for key, value in first_last_balls.items():
  926. # hash_str = p_code + key + '0' + first_last_dict[key] + str(value) + "hg3535" + str(match_id)
  927. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  928. # odds_only = Helper.genearte_MD5(hash_str, pt)
  929. # sole = Helper.genearte_MD5(sole_str, pt)
  930. # first_last_balls_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  931. # "condition",
  932. # "odds_only", "sole", "source", "type", "team"]
  933. # first_last_balls_value = [match_id, league_id, key, "0", 0, p_code, value, first_last_dict[key],
  934. # odds_only,
  935. # sole, "hg3535", "0", ""]
  936. # first_last_balls_data = dict(zip(first_last_balls_key, first_last_balls_value))
  937. # data_list.append(first_last_balls_data)
  938. #
  939. # # 球队得分大小
  940. # p_code = 'TB'
  941. # # 全场
  942. # full_dicts = item['full_data']
  943. # # 上半场
  944. # half_dicts = item['half_data']
  945. # full_dict_rules = item['full_data_rule']
  946. # half_dict_rules = item['half_data_rule']
  947. # if full_dicts:
  948. # for key, value in full_dicts.items():
  949. # hash_str = p_code + key + '0' + full_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  950. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  951. # odds_only = Helper.genearte_MD5(hash_str, pt)
  952. # sole = Helper.genearte_MD5(sole_str, pt)
  953. # full_dict_rules_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  954. # "condition", "odds_only", "sole", "source", "type", "team"]
  955. # full_dict_rules_value = [match_id, league_id, key, "0", 0, p_code, value, full_dict_rules[key],
  956. # odds_only, sole, "hg3535", "0", ""]
  957. # full_dict_rules_data = dict(zip(full_dict_rules_key, full_dict_rules_value))
  958. # data_list.append(full_dict_rules_data)
  959. #
  960. # if half_dicts:
  961. # for key, value in half_dicts.items():
  962. # hash_str = p_code + key + '0' + half_dict_rules[key] + str(value) + "hg3535" + str(match_id)
  963. # sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  964. # odds_only = Helper.genearte_MD5(hash_str, pt)
  965. # sole = Helper.genearte_MD5(sole_str, pt)
  966. # half_dicts_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  967. # "condition", "odds_only", "sole", "source", "type", "team"]
  968. # half_dicts_value = [match_id, league_id, key, "0", 0, p_code, value, half_dict_rules[key],
  969. # odds_only, sole, "hg3535", "0", ""]
  970. # half_dicts_data = dict(zip(half_dicts_key, half_dicts_value))
  971. # data_list.append(half_dicts_data)
  972. #
  973. p_code = 'CB'
  974. horn_ou_dict = item['horn_ou_dict']
  975. horn_ou_dict_rule = item['horn_ou_dict_rule']
  976. horn_oe_dict = item['horn_oe_dict']
  977. horn_oe_dict_rule = item['horn_oe_dict_rule']
  978. if horn_ou_dict:
  979. for key, value in horn_ou_dict.items():
  980. hash_str = p_code + key + '0' + horn_ou_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  981. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  982. odds_only = Helper.genearte_MD5(hash_str, pt)
  983. sole = Helper.genearte_MD5(sole_str, pt)
  984. horn_ou_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  985. "condition", "odds_only", "sole", "source", "type", "team"]
  986. horn_ou_value = [match_id, league_id, key, "0", 0, p_code, value, horn_ou_dict_rule[key],
  987. odds_only, sole, "hg3535", "0", ""]
  988. horn_ou_data = dict(zip(horn_ou_key, horn_ou_value))
  989. data_list.append(horn_ou_data)
  990. if horn_oe_dict:
  991. for key, value in horn_oe_dict.items():
  992. hash_str = p_code + key + '0' + horn_oe_dict_rule[key] + str(value) + "hg3535" + str(match_id)
  993. sole_str = p_code + key + '0' + str(match_id) + "hg3535"
  994. odds_only = Helper.genearte_MD5(hash_str, pt)
  995. sole = Helper.genearte_MD5(sole_str, pt)
  996. horn_oe_key = ["match_id", "lg_id", "odds_code", "status", "sort", "p_code", "odds",
  997. "condition", "odds_only", "sole", "source", "type", "team"]
  998. horn_oe_value = [match_id, league_id, key, "0", 0, p_code, value, horn_oe_dict_rule[key],
  999. odds_only, sole, "hg3535", "0", ""]
  1000. horn_oe_data = dict(zip(horn_oe_key, horn_oe_value))
  1001. data_list.append(horn_oe_data)
  1002. if pt == '3':
  1003. ris_stringscene = 1
  1004. else:
  1005. ris_stringscene = 0
  1006. odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
  1007. "is_stringscene", "utime", "pt"]
  1008. odds_value = ["zq", "odds", match_id, league_id, data_list, "hg3535", odds_onlys, tag_number, uuid,
  1009. ris_stringscene, utime, pt]
  1010. odds_dict = dict(zip(odds_key, odds_value))
  1011. if data_list:
  1012. res = Helper.async_post(ODDS_URL, odds_dict)
  1013. if res:
  1014. if res.get('status') == 1:
  1015. logger.info('足球角球, 详细赔率提交成功, {}'.format(res))
  1016. logger.info(odds_dict)
  1017. else:
  1018. logger.warning('足球角球, 详细赔率提交失败, {}'.format(res))
  1019. logger.warning(odds_dict)
  1020. else:
  1021. logging.warning('足球角球, 详细赔率接口异常, {}'.format(res))
  1022. else:
  1023. logger.info('足球详细赔率列表为空')
  1024. reactor.callFromThread(out.callback, item)