#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#  
 | 
##@package  
 | 
#  
 | 
# @todo: ÇþµÀɾµµ²âÊÔ³äֵ˫±¶·µÀû  
 | 
#  
 | 
# @author: Alee  
 | 
# @date 2019-1-22 ÏÂÎç08:22:54  
 | 
# @version 1.0  
 | 
#  
 | 
# @note: #×ܹ²681Ìõ, º¬Æ½Ì¨['kupai', 'uc', 'gionee', 'xiaomi', 'vivo', 'lenovo', 'meizu', 'yyb', 'oppo', 'qh360']  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
import PyGameData  
 | 
import ChConfig  
 | 
import GameWorld  
 | 
import ReadChConfig  
 | 
import datetime  
 | 
import IPY_GameWorld  
 | 
import PlayerControl  
 | 
import math  
 | 
  
 | 
Def_Qudao_DoubleBill = ['kupai', 'uc', 'gionee', 'xiaomi', 'vivo', 'lenovo', 'meizu', 'yyb', 'oppo', 'qh360']  
 | 
  
 | 
  
 | 
def OnMapQDDoubleBill(curPlayer):  
 | 
    try:  
 | 
        if GameWorld.IsCrossServer():  
 | 
            return  
 | 
          
 | 
        dbBillDict = ReadChConfig.GetEvalChConfig("DoubleBillConfig")  
 | 
        if not dbBillDict["IsOpen"]:  
 | 
            return  
 | 
          
 | 
        OnFirstQDDoubleBillQuery(curPlayer)  
 | 
        OnOtherQuDaoDoubleBill(curPlayer)  
 | 
    except Exception, e:  
 | 
        GameWorld.Log("OnMapQDDoubleBill Òì³£ %s-%s"%(curPlayer.GetID(), e))  
 | 
    return  
 | 
  
 | 
  
 | 
# ¿ç·þ²»´¦Àí  
 | 
# 1. µÚÒ»´ÎΪÇëÇóÊý¾Ý, Èç¹ûÊÇÉñ¾ö×ÚÔòÇëÇó×ÜÊý¾Ý  
 | 
# 2. ºóÐøÇл»µØÍ¼£¬ÅжÏÊÇ·ñ¸ôÌìÁìÈ¡  
 | 
def OnFirstQDDoubleBillQuery(curPlayer):  
 | 
    # 1 ÎªÎÞ³äÖµ 2 ÎªÒÑÁìÈ¡ ÆäËûÊýֵΪ¾ßÌå·µÀû×ÜÏÉÓñ  
 | 
    spID, accID = GetAccIDInfo(curPlayer.GetAccID())  
 | 
    if spID not in Def_Qudao_DoubleBill:  
 | 
        # ·ÇÇþµÀµÄ  
 | 
        return  
 | 
      
 | 
    gold = curPlayer.NomalDictGetProperty(ChConfig.Def_QuDao_DoubleBillGold)  
 | 
    if gold:  
 | 
        # ÒÑÇëÇó  
 | 
        return  
 | 
      
 | 
    # {spid:[accID...]}  
 | 
    if PyGameData.g_Qudao_DoubleBill:  
 | 
        # Óлº´æµ«²»ÔÚ»º´æÖÐµÄ  
 | 
        if spID not in PyGameData.g_Qudao_DoubleBill:  
 | 
            return  
 | 
          
 | 
        if accID not in PyGameData.g_Qudao_DoubleBill[spID]:  
 | 
            return  
 | 
      
 | 
    centerUrl = "center.2460web.com"  
 | 
    #centerUrl = "vm-mobilecom"  
 | 
    # ÏȸöÈËÇëÇó  
 | 
    getUrl = "http://%s:53004/DoublieBill.php?AccID=%s"%(centerUrl, curPlayer.GetAccID())  
 | 
    GameWorld.GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)  
 | 
      
 | 
    if curPlayer.GetMapID() != 10010:  
 | 
        return  
 | 
      
 | 
    if not PyGameData.g_Qudao_DoubleBill:  
 | 
        # »º´æÇëÇó  
 | 
        getUrl = "http://%s:53004/QueryAllDoubleBill.php?ccccc=fanggongji"%centerUrl  
 | 
        GameWorld.GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)  
 | 
      
 | 
    return  
 | 
  
 | 
  
 | 
# ºóÐøÌì·µ»Ø³äÖµ±ÈÀý  
 | 
def OnOtherQuDaoDoubleBill(curPlayer):  
 | 
    # 1 ÎªÎÞ³äÖµ 2 ÎªÒÑÁìÈ¡ ÆäËûÊýֵΪ¾ßÌå·µÀû×ÜÏÉÓñ  
 | 
    spID, accID = GetAccIDInfo(curPlayer.GetAccID())  
 | 
    if spID not in Def_Qudao_DoubleBill:  
 | 
        # ·ÇÇþµÀµÄ  
 | 
        return  
 | 
      
 | 
    gold = curPlayer.NomalDictGetProperty(ChConfig.Def_QuDao_DoubleBillGold)  
 | 
    if gold <= 2:  
 | 
        #ÎÞ¿ÉÁìÈ¡µÄ  
 | 
        return  
 | 
      
 | 
    CalcDoubleBillByDay(curPlayer)  
 | 
      
 | 
    return  
 | 
  
 | 
  
 | 
##»ñȡƽ̨Õ˺ŠºÍ spid  
 | 
def GetAccIDInfo(gameAccID):  
 | 
    infoList = gameAccID.split('@')  
 | 
    return infoList[1], infoList[0]  
 | 
  
 | 
# Ã¿ÈÕÁìÈ¡·µÀû  
 | 
def CalcDoubleBillByDay(curPlayer):  
 | 
    gold = curPlayer.NomalDictGetProperty(ChConfig.Def_QuDao_DoubleBillGold)  
 | 
    if gold <= 2:  
 | 
        return  
 | 
    dbBillDict = ReadChConfig.GetEvalChConfig("DoubleBillConfig")  
 | 
    billDayRate = dbBillDict["BillDayRate"]  
 | 
    # ¼Ç¼·µÀû´ÎÊý£º Ê±¼ä+´ÎÊý  
 | 
    #count = curDay.year*100000 + curDay.month*1000 + curDay.day*10 + 0  
 | 
    count = curPlayer.NomalDictGetProperty(ChConfig.Def_QuDao_DoubleBillCount)  
 | 
    realCnt = count%10  # ÒÑÁìÈ¡´ÎÊý  
 | 
    if realCnt >= len(billDayRate):  
 | 
        return  
 | 
    dateStr = "%d-%02d-%02d"%(count/100000, count%100000/1000, count%1000/10)  
 | 
    startDate = GameWorld.GetDateTimeByStr(dateStr, ChConfig.TYPE_Time_Format_Day)  
 | 
    curDay = datetime.datetime.today()  
 | 
    theDay = curDay - startDate  
 | 
    if theDay.days < realCnt:  
 | 
        return  
 | 
      
 | 
    giveGold = int(math.ceil(billDayRate[realCnt]/100.0*gold))  
 | 
      
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_QuDao_DoubleBillCount, count+1)  
 | 
      
 | 
    title = "²âÊÔÍæ¼Ò·µÀû".decode("gbk").encode("utf8")  
 | 
    content = "Ç×°®µÄµÀÓÑ£º</r><Space=2>»¶Ó¹éÀ´£¬¸ÐлÄúÔÚ¸¶·Ñɾµµ²âÊÔÆÚ¼ä¶ÔÎÒÃǵĴóÁ¦Ö§³Ö£¬¸øÄú·îÉϽñÈշݻعé´óÀñ¡£ÄúÔÚ¸¶·Ñɾµµ²âÊÔÆÚ¼äµÄ³äÖµ°´ÕÕ1Ôª=20ÏÉÓñµÄ±ÈÀý¹²¼Æ·µ»¹7Ì죬¾ßÌåÿÈÕ·µ»¹±ÈÀýÇëÄú²é¿´µÇ¼¹«¸æ-ɾµµ»Ø¹éÓÐÀñ¡£ÇëÄúÁôÒâÿÈÕ·µÀûÓʼþ£¬×£ÄúÓÎÏ·Óä¿ì!".decode("gbk").encode("utf8")  
 | 
      
 | 
    mailItemInfoList = []  
 | 
    if realCnt == 0:  
 | 
        mailItemInfoList = [[57, 1, 1]]  
 | 
    # ·¢Óʼþ  
 | 
    PlayerControl.SendMail(title, content, 30, [curPlayer.GetPlayerID()], mailItemInfoList, gold=giveGold)   
 | 
    GameWorld.Log("ÁìÈ¡ÇþµÀ·µÀû µÚ%s´Î ÏÉÓñ=%s"%(realCnt+1, giveGold))  
 | 
    return  
 | 
  
 |