From 4d91a243d50d39d07071f48f8c8ff7b3209eb58e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 13 十二月 2021 15:47:12 +0800
Subject: [PATCH] 9265 【BT5】【后端】53、新增幸运云购(主干 BTGM等级限制购买次数改为VIP等级限制)
---
Tool/WebCenter/CouponCode/webapp.py | 111 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 83 insertions(+), 28 deletions(-)
diff --git a/Tool/WebCenter/CouponCode/webapp.py b/Tool/WebCenter/CouponCode/webapp.py
index fcb4389..10d6398 100644
--- a/Tool/WebCenter/CouponCode/webapp.py
+++ b/Tool/WebCenter/CouponCode/webapp.py
@@ -50,15 +50,26 @@
Def_CardMsg = {
0:"CodeRewardSys2", # 鍏戞崲鐮佹棤鏁�
- 1: "CodeRewardSys1", # 鍏戞崲鍗″鍔卞凡鍙戣嚦閭欢
+ 1:"CodeRewardSys1", # 鍏戞崲鍗″鍔卞凡鍙戣嚦閭欢
2:"CodeRewardSys3", # 鍏戞崲鐮佸凡浣跨敤杩�
3:"CodeRewardSys4", # 鍚岀被鍨嬪厬鎹㈢爜鍙兘浣跨敤涓�娆�
+ 4:"LvErr", # 绛夌骇涓嶈冻
+ 5:"VipLevel", # VIP绛夌骇涓嶈冻
}
myapp = Bottle()
+# 闃叉鐭椂闂村唴鐨勫娆℃棤鏁堣闂� accid锛歵ime
+AccID_Cache_Dict = {}
+
+def CleanAccID():
+ global AccID_Cache_Dict
+
+ if len(AccID_Cache_Dict) < 100:
+ return
+ AccID_Cache_Dict = {}
#/api/Coupon/index.php?couponBatchId=%s&agentName=%s"
@@ -117,6 +128,7 @@
# http://center.xxx.com:53003/Coupon/CouponCode.php
@myapp.route('/Coupon/CouponCode.php')
def CouponCode():
+ global AccID_Cache_Dict
dataDict = request.GET
for key, value in dataDict.items():
@@ -129,14 +141,9 @@
codeStr = dataDict.get("code", "")
if not codeStr:
return
-
+ codeStr = codeStr.strip()
+ #鍙槸鐢ㄦ潵鎷兼帴璐﹀彿
spID = dataDict.get("spid", "")
- if not spID:
- tdict = {"jisugame":"jisu", 'spxjgame':'sipu', 'mrgame':'maoer',
- "jisugameios":"jisu", 'spyxxjios':'sipu', 'mrgameios':'maoer'}
-
- # 娌′紶鐨勮瘽榛樿鍜宎ppid涓�鏍�
- spID = tdict.get(agentName, agentName)
accid = dataDict.get("accid", "")
if not accid:
@@ -152,6 +159,20 @@
# 杞寲涓烘父鎴忚处鍙�
accid = "%s@%s@s%s"%(accid.lower(), spID, sid)
+ try:
+ CleanAccID()
+ #mylog.debug("AccID_Cache_Dict : %s"%str(AccID_Cache_Dict))
+ if accid not in AccID_Cache_Dict:
+ AccID_Cache_Dict[accid] = int(time.time())
+ elif time.time() - AccID_Cache_Dict[accid] < 2:
+ mylog.debug("==========bad: fast click %s"%accid)
+ return
+
+ AccID_Cache_Dict[accid] = int(time.time())
+ except:
+ pass
+
+
dbController = CouponDB.GetDBEventCon()
if not dbController:
# 鏃犳硶鑾峰彇鏁版嵁搴�
@@ -162,13 +183,19 @@
gmresult = {'accID':accid, 'sid':sid, 'channel':agentName}
#-----------缁熶竴鍥哄畾鐮佸鐞�----------------------
- if codeStr in CommonCards:
+ CommonCardsList = CommonCards.get(agentName, [])
+ if codeStr in CommonCardsList:
# 涓嶅悓鍥哄畾鐮佸悇鑷彧鑳介涓�娆�
result, commondata = dbController.find_one(CouponDB.CouponCodeColName + "_Common", {"code":codeStr, "accid":accid})
if commondata:
# 宸蹭娇鐢�
gmresult['status'] = 2
mylog.debug("common status=2")
+ return SendGm(gmresult, pushurl)
+
+ commCheckStatus = CommCheck(dataDict, codeStr)
+ if commCheckStatus != None:
+ gmresult['status'] = commCheckStatus
return SendGm(gmresult, pushurl)
gmresult['status'] = 1
@@ -208,12 +235,11 @@
dbController.update(CouponDB.CouponWXColName, {"code":codeStr, "operateid":operateID}, wxdata)
# 閫氱煡鍚庡彴璁板綍
SendDataCollectorBillInfo(wxdata, pushurl, operateID)
- return
+ return
-
- #-----------鎵归噺鍏戞崲鐮佸鐞�----------------------
+ #-----------鎵归噺鍏戞崲鐮佸鐞嗭紝鍚岀被鍨嬪彧棰嗗彇涓�娆�----------------------
result, data = dbController.find_one(CouponDB.CouponCodeColName + "_" + agentName, {"code":codeStr, "channel":agentName})
-
+
if not data:
#鏃犳鍗�
gmresult['status'] = 0
@@ -223,6 +249,11 @@
#宸蹭娇鐢紝鍚屽崱鍙疯褰曢粯璁ゅ彲鐢紝閬垮厤鏂嚎鍙戦�佸け璐ョ殑鎯呭喌锛堟湭杩斿洖缁撴灉楠岃瘉鎯呭喌涓嬶級
gmresult['status'] = 2
mylog.debug("card used!")
+ return SendGm(gmresult, pushurl)
+
+ commCheckStatus = CommCheck(dataDict, data["coupontype"])
+ if commCheckStatus != None:
+ gmresult['status'] = commCheckStatus
return SendGm(gmresult, pushurl)
result, data2 = dbController.find_one(CouponDB.CouponBatchColName, {"couponid":data["couponid"]})
@@ -247,17 +278,20 @@
gmresult['status'] = 0
mylog.debug("time pass")
return SendGm(gmresult, pushurl)
- #鍐嶆煡涓�娆℃槸鍚︾敤杩囨鎵规鐨勫叾浠栧崱,
- result, data3 = dbController.find_one(CouponDB.CouponCodeColName + "_" + agentName, \
- {"couponid":data["couponid"], "accid":accid})
- if data3:
- #鐢ㄨ繃鍚岀被鍗★紝宸茶褰曡繃涓嶅啀鍋氭柊璁板綍
- gmresult['status'] = 3
- gmresult['coupontype'] = data["coupontype"]
- gmresult['code'] = codeStr
- mylog.debug("use again")
- return SendGm(gmresult, pushurl)
+ # h 寮�澶寸殑鍗$被鍨嬪彲閲嶅浣跨敤
+ if not codeStr.startswith('h'):
+ #鍐嶆煡涓�娆℃槸鍚︾敤杩囨鎵规鐨勫叾浠栧崱,
+ result, data3 = dbController.find_one(CouponDB.CouponCodeColName + "_" + agentName, \
+ {"coupontype":data["coupontype"], "accid":accid})
+ if data3:
+ #鐢ㄨ繃鍚岀被鍗★紝宸茶褰曡繃涓嶅啀鍋氭柊璁板綍
+ gmresult['status'] = 3
+ gmresult['coupontype'] = data["coupontype"]
+ gmresult['code'] = codeStr
+ mylog.debug("use again")
+ return SendGm(gmresult, pushurl)
+
data['status'] = 1
data['accid'] = accid
data['usetime'] = str(datetime.datetime.today())
@@ -271,7 +305,24 @@
mylog.debug("card ok!")
return SendGm(gmresult, pushurl)
-
+def CommCheck(dataDict, coupontype):
+ ## 閫氱敤甯歌妫�鏌�
+
+ # 浣跨敤绛夌骇
+ lvLimit = ConfigIO.GetInt(coupontype, "LV")
+ playerLV = CommFunc.ToIntDef(dataDict.get("level", 0))
+ if lvLimit > 0 and playerLV < lvLimit:
+ mylog.debug("playerLV(%s) < lvLimit(%s)" % (playerLV, lvLimit))
+ return 4
+
+ # vip绛夌骇鐩稿叧
+ vipLVLimit = ConfigIO.GetInt(coupontype, "VIPLV")
+ playerVIPLV = CommFunc.ToIntDef(dataDict.get("viplevel", 0))
+ if vipLVLimit > 0 and playerVIPLV < vipLVLimit:
+ mylog.debug("playerVIPLV(%s) < vipLVLimit(%s)" % (playerVIPLV, vipLVLimit))
+ return 5
+
+ return
def SendGm(gmresult, pushurl):
try:
@@ -323,7 +374,7 @@
for itemList in Items:
pack_data["ItemID%s"%i] = str(itemList[0])
pack_data["ItemCnt%s"%i] = str(itemList[1])
- pack_data["IsBind%s"%i] = '1'
+ pack_data["IsBind%s"%i] = str(itemList[2] if len(itemList) > 2 else 0)
i += 1
pack_data["pack_type"] = "GMT_AddPersonalCompensation"
@@ -338,9 +389,9 @@
post = {}
post['pack'] = pack_data_dict;
post['sign'] = sign;
- result = urllib2.urlopen(gmurl, urllib.urlencode(post), 10)
+ result = urllib2.urlopen(gmurl, urllib.urlencode(post), 3)
- content = result.read()
+ #content = result.read()
result.close()
# 鎴愬姛鎻愮ず
@@ -361,7 +412,7 @@
post['sign'] = sign;
urllib2.urlopen(gmurl, urllib.urlencode(post), 3)
- return content
+ return 0
except Exception, e:
mylog.debug("gm error %s"%e)
return
@@ -451,3 +502,7 @@
mylog.debug("SendDataCollectorBillInfo error %s"%e)
+# 鏌ヨ瀹℃牳鏃堕棿
+@myapp.route('/auditdate.php')
+def QueryAuditdate():
+ return "2021-06-22 11:30:00"
--
Gitblit v1.8.0