Mike há 4 anos atrás
pai
commit
d40b06ef4f
1 ficheiros alterados com 42 adições e 62 exclusões
  1. 42 62
      is_close_changed_notice.py

+ 42 - 62
is_close_changed_notice.py

@@ -99,66 +99,46 @@ class Execute(BaseModel):
     is_close: str # 是否結案 (N: 未結案,Y: 已結案,T: 未上線,D: 續約,E: 不續約延期,F: 不續約需下線,G: 已到期未續約)
     price: str
 
-@app.post("/is_close_changed_notice")
-async def is_close_changed_notice(e: Execute):
-    html = """
-        <!DOCTYPE html>
-        <head>
-            <meta charset="UTF-8">
-        </head>
-        <body>
-        """
-    html += "<div>exf_id = " + e.exf_id + ", is_close = " + e.is_close + "</div>";
-    
-    if e.is_close == 'D':
-        html += "D: 續約"
-    elif e.is_close == 'E':
-        html += "E: 不續約延期"
-    elif e.is_close == 'F':
-        html += "F: 不續約需下線"
-    elif e.is_close == 'G':
-        html += "G: 已到期未續約"
-
-    html += """
-        </body>
-        </html>
-        """ 
-    
-    # Email清單
-    email_list = ['mike@choozmo.com']
-
-    # 寄送逾期執行表單Email通知
-    for email in email_list:
-        hhh_send_mail(email, html)
-
-# @app.get("/is_close_changed_notice")
-# async def is_close_changed_notice(exf_id: str = 0, is_close: str = ''):
-#     html = """
-#         <!DOCTYPE html>
-#         <head>
-#             <meta charset="UTF-8">
-#         </head>
-#         <body>
-#         """
-#     html += "<div>exf_id = " + exf_id + ", is_close = " + is_close + "</div>";
-    
-#     if is_close == 'D':
-#         html += "D: 續約"
-#     elif is_close == 'E':
-#         html += "E: 不續約延期"
-#     elif is_close == 'F':
-#         html += "F: 不續約需下線"
-#     elif is_close == 'G':
-#         html += "G: 已到期未續約"
-
-#     html += """
-#         </body>
-#         </html>
-#         """ 
-    
-#     # Email清單
-#     email_list = ['mike@choozmo.com']
 
-#     # 寄送逾期執行表單Email通知
-#     for email in email_list:
-#         hhh_send_mail(email, html)
+@app.get("/is_close_changed_notice")
+async def is_close_changed_notice(exf_id: str = 0, is_close: str = ''):
+    # 取得合約資料
+    q = "SELECT * \
+        FROM execute_form \
+        WHERE exf_id = " + exf_id
+
+    q_result_count = len(list(db.query(q)))
+
+    if q_result_count == 0: # 無合約資料
+        return
+    
+    for r in db.query(q):
+        html = """
+            <!DOCTYPE html>
+            <head>
+                <meta charset="UTF-8">
+            </head>
+            <body>
+            """
+        html += "<div>exf_id = " + r.exf_id + ", is_close = " + r.is_close + "</div>";
+        
+        if is_close == 'D':
+            html += "D: 續約"
+        elif is_close == 'E':
+            html += "E: 不續約延期"
+        elif is_close == 'F':
+            html += "F: 不續約需下線"
+        elif is_close == 'G':
+            html += "G: 已到期未續約"
+
+        html += """
+            </body>
+            </html>
+            """ 
+        
+        # Email清單
+        email_list = ['mike@choozmo.com']
+
+        # 寄送逾期執行表單Email通知
+        for email in email_list:
+            hhh_send_mail(email, html)