def procDantuo(openCode, info): # 胆拖玩法 beishu = info['f_beishu'] zhushu = 0 bonus = newBonus() cdata = '' global _DT_RE_ for i in info['f_fileorcode'].split('$'): m = _DT_RE_.match(i) if not m: continue dan1 = m.group(1).split(',') tuo1 = m.group(2).split(',') dan2 = m.group(3).split(',') tuo2 = m.group(4).split(',') if dan1[0] == '': del dan1[0] if dan2[0] == '': del dan2[0] for i in Math.combination(tuo1, 5 - len(dan1)): reds = dan1 + i reds.sort() for j in Math.combination(tuo2, 2 - len(dan2)): blues = dan2 + j blues.sort() bs = calBonus(openCode, {'reds': reds, 'blues': blues}) zhushu += beishu if bs[0]: bonus[bs[0]] += beishu bonus['zmax'] = 1 money = zhushu * 2 if info['f_wtype'] == 143: money = zhushu * 3 ret = { 'zhushu': zhushu, 'money': money, 'wtype': info['f_wtype'], 'tid': info['f_tid'], 'srccode': info['f_fileorcode'], 'onenum': bonus['onenum'], 'twonum': bonus['twonum'], 'threenum': bonus['threenum'], 'fournum': bonus['fournum'], 'fivenum': bonus['fivenum'], 'sixnum': bonus['sixnum'], 'zmax': bonus['zmax'] } return ret
def PlayNum_CM(self, tmp_info, cc_dict, wtype, beishu, ggtype): playnum = int(tmp_info['PlayNum']) cc_list = cc_dict.keys() ret_list = list() tmp_code = list() finally_list = list() ret_m = Math.combination(cc_list, playnum) for info in ret_m: ret_code = list() tmp_list = list() for i in info: tmp_list.append(cc_dict[i]) self.orgaize_code(tmp_list, ret_code, tmp_code) ret_list += copy.deepcopy(ret_code) finally_list = ret_list """ if 58 == int(ggtype): for info in ret_list: for i in info: head = i.split('[')[0] for j in (i.split('[')[-1].split(']')[0]).split(','): finally_list.append([head + '[' + j + ']']) else: finally_list = ret_list """ return finally_list
def splitRedBall(self, rArr): ret = list() r1 = rArr[0:16] r2 = rArr[16:] max = 5 if len(r2) < 6: max = len(r2) for i in range(1, max + 1): tmp = list() # 不能同时调用两以上yield 蛋疼<<<<<碎了不 for b in Math.combination(r2, i): tmp.append(b) for a in Math.combination(r1, 6 - i): for b in tmp: yield a + b
def handTicket(self): #计算票奖金 matchList = self.parseCodeRate(self._ticket['f_ticketid'],self._ticket['f_fileorcode'],self._ticket['f_ratelist']) ggTypeInfo = JcConfig.getGGType(self._ticket['f_ggtype']) for items in Math.combination(matchList,int(ggTypeInfo['PlayNum'])): #几串几 gg_arr = ggTypeInfo['SelCodeNum'].split(',') #选择场次数 for sel in gg_arr: #几关 for matchComb in Math.combination(items,int(sel)): #组合投注场次 comb_ret = self.handMatchComb(matchComb,self.tkt_cancels) logger.debug(comb_ret) if comb_ret['valid'] == False: #无效立即终止,提高效率 self.tkt_valid = False return { 'tid':self._ticket['f_ticketid'],'orderid':self._ticket['f_orderid'],'valid':self.tkt_valid, 'getmoney':0,'pregetmoney':0,'returnmoney':0,'returnnum':0 } if comb_ret['isreturn'] == True: #返款 self.tkt_returnprize += comb_ret['pre_prize'] self.tkt_returnnum += comb_ret['zhushu'] else: self.tkt_preprize += comb_ret['pre_prize'] #税前奖金 self.tkt_prize += comb_ret['prize'] #税后奖金 self.tkt_zhushu += comb_ret['zhushu'] getmoney = 0 pregetmoney = 0 returnmoney = 0 returnnum = 0 if self.tkt_valid == True: beishu = Decimal(self._ticket['f_beishu']) pregetmoney = JcConfig.sixRound(self.tkt_preprize*beishu) getmoney = JcConfig.sixRound(self.tkt_prize*beishu) returnmoney = Decimal(self.tkt_returnprize)*beishu returnnum = self.tkt_returnnum*self._ticket['f_beishu'] """ #多关单式,无取消场次,中奖的,以出票返回的maxmoney为准 if len(matchList)>1 and self.tkt_zhushu == 1 and len(self.tkt_cancels) == 0 and self.tkt_prize>0 and self._ticket['maxmoney']>0: pregetmoney = JcConfig.sixRound(Decimal(self._ticket['maxmoney'])) getmoney = pregetmoney if (pregetmoney/beishu) > 10000: #单倍大于10000要扣税 getmoney = JcConfig.sixRound(Decimal(pregetmoney*Decimal('0.8'))) """ return { 'tid':self._ticket['f_ticketid'],'orderid':self._ticket['f_orderid'],'valid':self.tkt_valid, 'getmoney':getmoney,'pregetmoney':pregetmoney,'returnmoney':returnmoney,'returnnum':returnnum }
def procBasic(openCode, info): # 普通玩法 beishu = info['f_beishu'] zhushu = 0 bonus = newBonus() for code in info['f_fileorcode'].split('$'): reds, blues = code.split('|') reds = reds.strip().split(',') blues = blues.strip().split(',') if len(reds) > 5 or len(blues) > 2: for r in Math.combination(reds, 5): for b in Math.combination(blues, 2): bs = calBonus(openCode, {'reds': r, 'blues': b}) zhushu += beishu if bs[0]: bonus[bs[0]] += beishu bonus['zmax'] = 1 else: bs = calBonus(openCode, {'reds': reds, 'blues': blues}) zhushu += beishu if bs[0]: bonus[bs[0]] += beishu bonus['zmax'] = 1 money = zhushu * 2 if info['f_wtype'] == 98 or info['f_wtype'] == 388: money = zhushu * 3 ret = { 'zhushu': zhushu, 'money': money, 'wtype': info['f_wtype'], 'tid': info['f_tid'], 'srccode': info['f_fileorcode'], 'onenum': bonus['onenum'], 'twonum': bonus['twonum'], 'threenum': bonus['threenum'], 'fournum': bonus['fournum'], 'fivenum': bonus['fivenum'], 'sixnum': bonus['sixnum'], 'zmax': bonus['zmax'] } return ret
def handFushi(self, rArr, bArr, beishu): zhushu = 0 # 红球注数 r_zhushu = self.ArrInfo[len(rArr)][6] # 篮球注数 b_zhushu = self.ArrInfo[len(bArr)][1] zhushu = r_zhushu * b_zhushu # 单票最大倍数 max_beishu = self.TICK_RE['beishu'] # 可拆分最大倍数 lmt_beishu = max_beishu # 拆分结果 ret = list() # 此处以钱为标杆 if zhushu * self.singleMoney * max_beishu > self.limitMoney: lmt_beishu = self.limitMoney / (zhushu * self.singleMoney) # 需要拆蓝球 if lmt_beishu == 0: tmpArr = Math.combination(bArr, 1) for info in tmpArr: info_zhushu = self.ArrInfo[len(rArr)][6] * 1 lmt_beishu = self.limitMoney / (info_zhushu * self.singleMoney) tmp_ret = self.splitBeishu( ','.join(rArr) + '|' + ','.join(bArr), lmt_beishu, beishu, info_zhushu) # ret.append(tmp_ret) ret += tmp_ret # 不需要拆篮球 else: tmp_ret = self.splitBeishu( ','.join(rArr) + '|' + ','.join(bArr), lmt_beishu, beishu, zhushu) # ret.append(tmp_ret) ret += tmp_ret else: tmp_ret = self.splitBeishu(','.join(rArr) + '|' + ','.join(bArr), lmt_beishu, beishu, zhushu) ret += tmp_ret return ret
def splitCodeDT( self, codes ): dt_re = re.compile(r'\[D:(.*)\]\[T:(.*)\]') tmpstr = dt_re.match(codes) dcode = tmpstr.group(1).split(',') tcode = tmpstr.group(2).split(',') ret = '' ddict = dict() for info in range(Config.CODENUM[int(self.lotId)]['changcinum']): ddict[info] = dcode[info] tlist = list() for info in range(Config.CODENUM[int(self.lotId)]['changcinum']): tmpdict = dict() if '*' == tcode[info].strip(): continue tmpdict[info] = tcode[info] tlist.append(tmpdict) tmplist = list() yunum = Config.CODENUM[int(self.lotId)]['codenum'] - (Config.CODENUM[int(self.lotId)]['changcinum'] - dcode.count('*')) for info in Math.combination( tlist, yunum ): tmpdict = copy.deepcopy( ddict ) for var in info: tmpdict.update( var ) if self.countAllZhuShu( ','.join( tmpdict.values() ) ) > self.flagzhushu: tmplist += self.splitOverCode( tmpdict, info ) else: tmplist.append( tmpdict ) for info in tmplist: if '' == ret: ret = ','.join( info.values() ) else: ret += '$' + ','.join( info.values() ) return ret
def splitHlist(self, hlist, flagnum): tmplist = list() for info in hlist: for i in list(info['code']): tmpdict = dict() tmpdict[info['innum']] = i tmplist.append(tmpdict) td = dict() cmblist = list() for info in Math.combination(tmplist, flagnum): #去掉重复位置选项 for i in info: td = dict(td, **i) if len(td) == flagnum: cmblist.append(td) td = dict() return cmblist
def splitCodeFS( self, codes ): ret = '' fcode = codes.split(',') if Config.CODENUM[int(self.lotId)]['codenum'] == (14 - fcode.count('*') ): ret = codes return ret ddict = dict() for info in range(14): ddict[info] = '*' tlist = list() for info in range(14): tmpdict = dict() if '*' == fcode[info].strip(): continue tmpdict[info] = fcode[info] tlist.append(tmpdict) tmplist = list() yunum = Config.CODENUM[int(self.lotId)]['codenum'] for info in Math.combination( tlist, yunum ): tmpdict = copy.deepcopy( ddict ) for var in info: tmpdict.update( var ) tmplist.append( tmpdict ) for info in tmplist: if '' == ret: ret = ','.join( info.values() ) else: ret += '$' + ','.join( info.values() ) return ret