From 64053673d311feed12814ba9ad921d9448f9a07c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期六, 28 九月 2024 15:37:01 +0800
Subject: [PATCH] 5416 【工具】兑换码优化(兑换码邮件内容文件json支持不同的appID独立文件配置;)

---
 Tool/WebCenter/Coupon/CodeMail_hyenglish.json |   26 ++++++++++++++++++++++++++
 Tool/WebCenter/CouponCode/webapp.py           |   19 ++++++++++++++++---
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/Tool/WebCenter/Coupon/CodeMail_hyenglish.json b/Tool/WebCenter/Coupon/CodeMail_hyenglish.json
new file mode 100644
index 0000000..78698d2
--- /dev/null
+++ b/Tool/WebCenter/Coupon/CodeMail_hyenglish.json
@@ -0,0 +1,26 @@
+锘縶
+    "VIP666": {
+        "MailSender": "H峄� th峄憂g th瓢",
+        "MailTitle": "<gcode>VIP666 g贸i qu脿",
+        "MailText": "C岷 啤n b岷 膽茫 h峄� tr峄� c谩c tr貌 ch啤i, xin vui l貌ng nh岷璶 膽瓢峄 g贸i qu脿 VIP666.",
+        "Items": [[4680,1],[1128,1],[3801,1,1],[4501,2]],
+		"LV":100,
+		"VIPLV":5,
+    },
+	
+    "g001": {
+        "MailSender": "绯荤粺閭欢",
+        "MailTitle": "<gcode>鍘嗗彶绱杩斿埄娲诲姩",
+        "MailText": "绱Н鍏呭��1000鍏冭繑鍒�,鎰熻阿鎮ㄥ娓告垙鐨勬敮鎸侊紝璇峰強鏃堕鍙栫ぜ鍖呫��",
+        "Items": [[1015,1],[15177,2],[1128,2]],
+		"Prefix":"CuuThien"
+    },
+	
+    "h001": {
+        "MailSender": "H峄� th峄憂g th瓢",
+        "MailTitle": "<gcode>g贸i qu脿 h001",
+        "MailText": "C岷 啤n b岷 膽茫 h峄� tr峄� c谩c tr貌 ch啤i, xin vui l貌ng nh岷璶 膽瓢峄 g贸i qu脿 h001",
+        "Items": [[1015,10],[15177,20],[1128,20]],
+		"Prefix":"CuuThien"
+    }
+}
\ No newline at end of file
diff --git a/Tool/WebCenter/CouponCode/webapp.py b/Tool/WebCenter/CouponCode/webapp.py
index 7ebc83e..ae9894f 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鐨勭爜鍧囦唬琛ㄩ敊璇�
@@ -305,6 +315,7 @@
         return SendGm(ErrCode_Invalid, gmresult, pushurl)[1]
     
     prefix = "" # 鍥哄畾鍓嶇紑
+    MailJson = GetMailJson(agentName)
     if couponType in MailJson:
         mailInfo = MailJson[couponType]
         prefix = mailInfo.get("Prefix", "")
@@ -340,6 +351,7 @@
 def CommCheck(dataDict, coupontype):
     ## 閫氱敤甯歌妫�鏌�
     
+    MailJson = GetMailJson(dataDict.get("channel", ""))
     if coupontype in MailJson:
         mailInfo = MailJson[coupontype]
         lvLimit = mailInfo.get("LV", 0)
@@ -390,6 +402,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