From d171a50540a656408fbcc1cda016e3d0aede51f9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 26 二月 2025 17:53:32 +0800
Subject: [PATCH] 10385 【越南】【英语】【BT】【GM】【砍树】福地新增鼠管及优化-服务端(优化结算奖励逻辑;)

---
 Tool/WebCenter/CouponCode/webapp.py |   33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/Tool/WebCenter/CouponCode/webapp.py b/Tool/WebCenter/CouponCode/webapp.py
index 7ebc83e..c827426 100644
--- a/Tool/WebCenter/CouponCode/webapp.py
+++ b/Tool/WebCenter/CouponCode/webapp.py
@@ -49,10 +49,20 @@
 PushTimeout = ConfigIO.GetInt("Coupon", "PushTimeout", 5)
 CommonCards = eval(ConfigIO.GetValue("Coupon", "CommonCards"))
 
+g_mailJsonDict = {} # {channel:MailJson, ...}
 # 鍙戞斁濂栧姳閭欢鍐呭json锛寀tf8缂栫爜
-f = open(os.getcwd() + "\\..\\Coupon\\CodeMail.json", "r")
-MailJson = eval(f.read())
-f.close()
+def GetMailJson(channel):
+    global g_mailJsonDict
+    if channel in g_mailJsonDict:
+        return g_mailJsonDict[channel]
+    jsonPath = os.getcwd() + ("\\..\\Coupon\\CodeMail_%s.json" % channel)
+    if not os.path.isfile(jsonPath):
+        jsonPath = os.getcwd() + "\\..\\Coupon\\CodeMail.json"
+    f = open(jsonPath, "r")
+    MailJson = eval(f.read())
+    f.close()
+    g_mailJsonDict[channel] = MailJson
+    return MailJson
 
 # 绀煎寘浣跨敤杩斿洖缁撴灉鐮佸畾涔�
 ErrCode_OK = 0 # 鎴愬姛锛岄潪0鐨勭爜鍧囦唬琛ㄩ敊璇�
@@ -304,16 +314,22 @@
         mylog.debug("time pass")
         return SendGm(ErrCode_Invalid, gmresult, pushurl)[1]
     
+    maxUseCount = 0 # -1-鏃犻檺锛�0鎴�1-榛樿1娆★紱 >1-闄愬埗娆℃暟锛� 娌℃湁閰嶇疆鐨勯粯璁�0鍗抽粯璁�1娆�
     prefix = "" # 鍥哄畾鍓嶇紑
+    MailJson = GetMailJson(agentName)
     if couponType in MailJson:
         mailInfo = MailJson[couponType]
         prefix = mailInfo.get("Prefix", "")
+        maxUseCount = CommFunc.ToIntDef(mailInfo.get("MaxUseCount", 0))
     elif ConfigIO.HasSection(couponType):
         if ConfigIO.HasOption(couponType, "Prefix"):
             prefix = ConfigIO.GetValue(couponType, "Prefix")
+            maxUseCount = ConfigIO.GetInt(couponType, "MaxUseCount")
             
     # h 寮�澶寸殑鍗$被鍨嬪彲閲嶅浣跨敤
-    if not codeStr.startswith(prefix + 'h'):
+    #if not codeStr.startswith(prefix + 'h'):
+    #淇敼涓烘寜閰嶇疆鏈�澶ф鏁板垽鏂嵆鍙�
+    if maxUseCount in [0, 1]:
         #鍐嶆煡涓�娆℃槸鍚︾敤杩囨鎵规鐨勫叾浠栧崱, 
         result, data3 = dbController.find_one(CouponDB.CouponCodeColName + "_" + agentName, \
                                               {"coupontype":data["coupontype"], "accid":accid})
@@ -322,6 +338,13 @@
             gmresult['coupontype'] = data["coupontype"]
             gmresult['code'] = codeStr
             mylog.debug("use again")
+            return SendGm(ErrCode_TypeUsed, gmresult, pushurl)[1]
+    elif maxUseCount > 1:
+        result, resultList = dbController.find(CouponDB.CouponCodeColName + "_" + agentName, {"coupontype":data["coupontype"], "accid":accid}, {"code":1})
+        if not result or len(resultList) >= maxUseCount:
+            gmresult['coupontype'] = data["coupontype"]
+            gmresult['code'] = codeStr
+            mylog.debug("use maxUseCount limit. %s" % maxUseCount)
             return SendGm(ErrCode_TypeUsed, gmresult, pushurl)[1]
         
     data['status'] = 1
@@ -340,6 +363,7 @@
 def CommCheck(dataDict, coupontype):
     ## 閫氱敤甯歌妫�鏌�
     
+    MailJson = GetMailJson(dataDict.get("channel", ""))
     if coupontype in MailJson:
         mailInfo = MailJson[coupontype]
         lvLimit = mailInfo.get("LV", 0)
@@ -390,6 +414,7 @@
             return errcode, CouponCodeResponse(errcode)
         
         coupontype = gmresult["coupontype"]
+        MailJson = GetMailJson(gmresult["channel"])
         if coupontype in MailJson:
             mailInfo = MailJson[coupontype]
             mailTitle = mailInfo.get("MailTitle", "MailTitle")

--
Gitblit v1.8.0