Mike %!s(int64=3) %!d(string=hai) anos
pai
achega
587fb1fb1f
Modificáronse 1 ficheiros con 50 adicións e 2 borrados
  1. 50 2
      is_close_changed_notice.py

+ 50 - 2
is_close_changed_notice.py

@@ -88,6 +88,19 @@ def hhh_send_mail(email, subject, html):
         print(response['MessageId'])
 
 
+'''
+原有狀態:
+N: 未結案
+Y: 已結案
+T: 未上線
+C: 轉約 (已刪除)
+
+新增狀態:
+D: 續約
+E: 不續約延期
+F: 不續約需下線
+G: 已到期未續約
+'''
 
 @app.get("/is_close_changed_notice")
 async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
@@ -119,12 +132,41 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
          
         if is_close == 'D':
             html += '<div>本合約狀態已修改為 <span style="color:red;">續約</span></div>'
+            
+            # 發送通知給負責業務、CRM、Kevin、Sam
+            email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw']
+
+            #  負責業務
+            print('負責業務: ' + r['sales_man'])
+            email_list.append(r['sales_man'])
+
+            # 取得執行單位Email清單
+            q1 = "SELECT DISTINCT(execute_man) \
+                FROM execute_detail \
+                WHERE exf_id=" + exf_id
+            
+            q1_result_count = len(list(db.query(q1)))
+
+            if q1_result_count > 0: # 有執行單位Email清單
+                for r1 in db.query(q1):
+                    print('執行單位: ' + r['sales_man'])
+                    email_list.append(r1['execute_man'])
         elif is_close == 'E':
             html += '<div>本合約狀態已修改為 <span style="color:red;">不續約延期</span></div>'
+            
+            # 發送通知給負責業務、CRM、Kevin、Sam
+            # 以變更後的合約日期來發送通知信
+            # email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw']
         elif is_close == 'F':
             html += '<div>本合約狀態已修改為 <span style="color:red;">不續約需下線</span></div>'
+            
+            # 發送通知通知給負責業務、CRM、財務部、Kevin、Sam
+            # email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw']
         elif is_close == 'G':
             html += '<div>本合約狀態已修改為 <span style="color:red;">已到期未續約</span></div>'
+            
+            # 發送通知給負責業務、Kevin、Sam
+            # email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw']
         else:
             print ('修改狀態: ' + is_close + ',不需通知')
             return
@@ -135,10 +177,16 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
             </body>
             </html>
             """ 
-        
+
+    # 寄送逾期執行表單Email通知
+    for email in email_list: # test
+        print('寄送Email: ' + email)
+
+    '''
     # Email清單
     email_list = ['mike@choozmo.com']
 
     # 寄送逾期執行表單Email通知
     for email in email_list:
-        hhh_send_mail(email, subject, html)
+        hhh_send_mail(email, subject, html)
+    '''