|
@@ -27,7 +27,7 @@ app = FastAPI()
|
|
|
|
|
|
origins = [
|
|
|
"http://139.162.121.30",
|
|
|
- "http://139.162.121.30:8002"
|
|
|
+ "http://139.162.121.30:8002",
|
|
|
]
|
|
|
|
|
|
app.add_middleware(
|
|
@@ -82,8 +82,25 @@ db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cm
|
|
|
# 正式機 DB
|
|
|
# db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
|
|
|
|
|
|
+class Execute(BaseModel):
|
|
|
+ exf_id: str
|
|
|
+ num: str # 合約編號
|
|
|
+ company: str #設計公司
|
|
|
+ mobile: str # 手機
|
|
|
+ telete: str # 電話
|
|
|
+ designer: str #設計師
|
|
|
+ sdate: str # 上架日期
|
|
|
+ edate: str # 下架日期
|
|
|
+ note: str # 備註說明
|
|
|
+ contract_time: str # 到期日
|
|
|
+ contract_person: str # 聯絡人
|
|
|
+ sales_dept: str # 部門別
|
|
|
+ sales_man: str # 接案業務
|
|
|
+ is_close: str # 是否結案 (N: 未結案,Y: 已結案,T: 未上線,D: 續約,E: 不續約延期,F: 不續約需下線,G: 已到期未續約)
|
|
|
+ price: int
|
|
|
+
|
|
|
@app.post("/is_close_changed_notice")
|
|
|
-async def is_close_changed_notice():
|
|
|
+async def is_close_changed_notice(e:Execute):
|
|
|
html = """
|
|
|
<!DOCTYPE html>
|
|
|
<head>
|
|
@@ -92,7 +109,15 @@ async def is_close_changed_notice():
|
|
|
<body>
|
|
|
"""
|
|
|
|
|
|
- html += "is_close_changed_notice()"
|
|
|
+ if (e.is_close == 'D') {
|
|
|
+ html += "D: 續約"
|
|
|
+ } elseif (e.is_close == 'E') {
|
|
|
+ html += "E: 不續約延期"
|
|
|
+ } elseif (e.is_close == 'F') {
|
|
|
+ html += "F: 不續約需下線"
|
|
|
+ } elseif (e.is_close == 'G') {
|
|
|
+ html += "G: 已到期未續約"
|
|
|
+ }
|
|
|
|
|
|
html += """
|
|
|
</body>
|
|
@@ -104,39 +129,4 @@ async def is_close_changed_notice():
|
|
|
|
|
|
# 寄送逾期執行表單Email通知
|
|
|
for email in email_list:
|
|
|
- #hhh_send_mail(email, html)
|
|
|
- SENDER = "Gorgeous Space <noreply@hhh.com.tw>"
|
|
|
- RECIPIENT = email
|
|
|
- AWS_REGION = "us-east-1"
|
|
|
- CHARSET = "UTF-8"
|
|
|
- client = boto3.client('ses',region_name=AWS_REGION)
|
|
|
-
|
|
|
- try:
|
|
|
- msg = MIMEMultipart()
|
|
|
- # msg["Subject"] = "逾期執行表單通知_" + str(datetime.date.today())
|
|
|
- msg["Subject"] = "逾期執行表單通知_" + (datetime.now() + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M")
|
|
|
- msg["From"] = "noreply@hhh.com.tw"
|
|
|
- msg["To"] = email
|
|
|
-
|
|
|
- # Set message body
|
|
|
- body = MIMEText(html, "html")
|
|
|
-
|
|
|
- msg.attach(body)
|
|
|
-
|
|
|
- response = client.send_raw_email(
|
|
|
- Source=msg["From"],
|
|
|
- Destinations=[msg["To"]],
|
|
|
- RawMessage={"Data": msg.as_string()}
|
|
|
- )
|
|
|
- print(response)
|
|
|
- # Display an error if something goes wrong.
|
|
|
- except ClientError as e:
|
|
|
- print(e.response['Error']['Message'])
|
|
|
- #return e.response['Error']['Message']
|
|
|
- else:
|
|
|
- print("Email sent! Message ID:"),
|
|
|
- print(response['MessageId'])
|
|
|
-
|
|
|
- return "Email sent! Message ID:" + response['MessageId']
|
|
|
-
|
|
|
- return response
|
|
|
+ hhh_send_mail(email, html)
|