| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| ##@package  | 
| #  | 
| # @todo:   | 
| #  | 
| # @author: Alee  | 
| # @date 2019-1-24 ÏÂÎç06:59:05  | 
| # @version 1.0  | 
| #  | 
| # @note:   | 
| #  | 
| #---------------------------------------------------------------------  | 
| import json  | 
| import md5  | 
| import urllib2  | 
| import urllib  | 
| import time  | 
| fileIO = open("FixDBBill.txt")  | 
|   | 
|   | 
| def SendGm(gameAccID, dbState, serverid):  | 
|     try:  | 
|   | 
|         if serverid == "s15":  | 
|             #serverIP = "s1.xmgame.2460web.com"  | 
|             serverIP = "vm-mobile-v8"  | 
|         elif serverid == "s2":  | 
|             #serverIP = "s2.xmgame.2460web.com"  | 
|             serverIP = "vm-mobile-v8"  | 
|         else:  | 
|             return "´íÎóµÄserverid:%s"%serverid  | 
|         # GMÍÆË͵ØÖ·  | 
|         #GMToolPage = http://s1.yhlz.09ge.com:30001/Server/Tool.php  | 
|         gmurl = "http://%s:%s/Server/Tool.php"%(serverIP, 80)  | 
|         gmkey = "Y25GVFoyOVFjbWtyTDJJckt5OU1OQ3RtUFQxPV"  | 
|         if not gmkey or not gmurl:  | 
|             return  | 
|           | 
|         pack_data = {}  | 
|         pack_data["AccID"] = gameAccID  | 
|         # ·µ»Ø1£ºÎÞ³äÖµ£¬2£ºÒѶһ»£¨Ö»ÄÜÒ»¸ö·þ£©£¬ÆäËû¶î¶ÈΪÏÉÓñ  | 
|         pack_data["GoldState"] = str(dbState)  | 
|   | 
|         pack_data["pack_type"] = "GMT_QDFLDoubleBill"  | 
|         pack_data["key"] = gmkey;  | 
|         pack_data['coding'] = "utf8"  | 
|       | 
|         #ʹÓÃkey¼ÓÃÜ  | 
|         pack_data_dict = json.dumps(pack_data)  | 
|   | 
|         print "OnDoubleBill SendGm:%s-%s"%(gmurl, pack_data_dict)  | 
|         sign = md5.md5(pack_data_dict+gmkey).hexdigest()  | 
|         post = {}  | 
|         post['pack'] = pack_data_dict;  | 
|         post['sign'] = sign;  | 
|         result = urllib2.urlopen(gmurl, urllib.urlencode(post), 10)  | 
|   | 
|         content = result.read()  | 
|         result.close()  | 
|         print content  | 
|         return True  | 
|     except Exception, e:  | 
|         return "gm error %s"%e  | 
|     return  | 
|   | 
|   | 
| writeIO = open("result.txt", 'a')  | 
|   | 
| for line in fileIO.readlines():  | 
|     line = line.strip()  | 
|     spid, accid, gold, serverid = line.split()  | 
|     gameAccID = "%s@%s@%s"%(accid, spid, serverid)  | 
|     #print spid, accid, gold, serverid  | 
|     result = SendGm(gameAccID, gold, serverid)  | 
|       | 
|     if not result:  | 
|         writeIO.write("Òì³£: %s, %s\n"%(gameAccID, line))  | 
|       | 
|     elif result == True:  | 
|         writeIO.write("³É¹¦: %s, %s\n"%(gameAccID, line))  | 
|           | 
|     else:  | 
|         writeIO.write("Òì³£: %s, %s, %s\n"%(gameAccID, line, result))  | 
|   | 
|     time.sleep(1)  | 
| writeIO.close()  | 
| fileIO.close()  | 
|   | 
| import os  | 
| os.system("pause")  | 
|   | 
|      |