增加RESEND信件功能、修正信件流水編號錯誤

This commit is contained in:
ericli1018
2025-07-14 15:39:45 +08:00
parent cd366e559e
commit 8a2e680f85
6 changed files with 277 additions and 6 deletions

View File

@ -349,7 +349,7 @@ class EventHealthAllowanceCrudController extends CrudController
[
"title" => "翻轉代謝新人生,皮蛇疫苗加碼補 審核通過!",
"body" => "一、登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
@ -380,7 +380,7 @@ class EventHealthAllowanceCrudController extends CrudController
"body" => "抱歉,您的審核未通過!請依以下理由重新上活動網站登記。"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)

View File

@ -352,7 +352,7 @@ class EventImprovedHealthCrudController extends CrudController
[
"title" => "健康達標GO大獎汽車不是夢 審核通過!",
"body" => "登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
@ -375,7 +375,7 @@ class EventImprovedHealthCrudController extends CrudController
"body" => "抱歉,您的審核未通過!請依以下理由重新上活動網站登記。"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)

View File

@ -365,7 +365,7 @@ class HealthAllowanceFillFormController extends Controller
"title" => "翻轉代謝新人生,皮蛇疫苗加碼補 登記成功!",
"body" => "我們將於3個工作天內進行審核您的資料並通知您審核結果敬請留意收信。"
."\n\n登記資料:"
."\n流水號: A-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n流水號: C-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$request->input('hospital_name')
."\n姓名:".(mb_strlen($request->input('name')) > 2 ? mb_substr($request->input('name'),0,1)."*".mb_substr($request->input('name'),-1) : mb_substr($request->input('name'),0,1)."*")
."\n身份證字號:".substr($request->input('twid'),0,2)."****".substr($request->input('twid'),-4)
@ -416,4 +416,97 @@ class HealthAllowanceFillFormController extends Controller
}
return redirect()->back()->with('success', '您已審格通過!');
}
public function doResendNotifyGet(Request $request)
{
$result = [];
$from = date('2025-06-26 16:43:00');
$to = date('2025-07-13 11:07:00');
$entries = EventHealthAllowance::whereBetween('updated_at', [$from, $to])->skip(0)->take(50)->get();
foreach($entries as $entry)
{
try {
switch($entry->check_state) {
case '1': //待審
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「翻轉代謝新人生皮蛇疫苗加碼補」登記成功信件',
[
"title" => "翻轉代謝新人生,皮蛇疫苗加碼補 登記成功!",
"body" => "我們將於3個工作天內進行審核您的資料並通知您審核結果敬請留意收信。"
."\n\n登記資料:"
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
case '2': //過通
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「翻轉代謝新人生皮蛇疫苗加碼補」審核通過信件。',
[
"title" => "翻轉代謝新人生,皮蛇疫苗加碼補 審核通過!",
"body" => "一、登記資料:"
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
."\n\n二、補助通知:"
."\n感謝您參與「114年桃園市健康管理計畫翻轉代謝新人生 皮蛇疫苗加碼補」。"
."\n請至本局指定醫療院所完成疫苗接種,並備妥以下資料申請經費補助:"
."\n1.活動審核通過通知信"
."\n2.帶狀皰疹疫苗接種收據或紀錄"
."\n3.本人帳戶影本如非臺灣銀行帳戶將扣除30元匯費"
."\n4.切結書"
."\n\n三、為確保資源分配公平,提醒您「翻轉代謝新人生 皮蛇疫苗加碼補」活動與「114年桃園市帶狀疱疹疫苗接種補助計畫」不可重複申請應擇一參加。如經查證您已參加「114年桃園市帶狀疱疹疫苗接種補助計畫」本活動所接受之經費補助將不予補助並需退還已補助之費用5,000元。"
."\n\n四、備妥以上資料於114年12月5日前以掛號方式寄至桃園市政府衛生局健康促進科桃園市桃園區縣府路55號信封註明114年桃園市健康管理計畫帶狀疱疹疫苗補助。"
."\n\n敬請配合,以利後續作業。"
,
]));
break;
case '3': //未通過
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「翻轉代謝新人生皮蛇疫苗加碼補」審核未通過信件。',
[
"title" => "翻轉代謝新人生,皮蛇疫苗加碼補 審核未通過!",
"body" => "抱歉,您的審核未通過!請依以下理由重新上活動網站登記。"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: C-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
}
$entry->updated_at = \Carbon\Carbon::now();
$entry->save();
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson];
} catch (Exception $ex) {
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson, 'err' => $ex->getMessage()];
}
}
return $result;
}
}

View File

@ -354,7 +354,7 @@ class ImprovedHealthFillFormController extends Controller
"title" => "健康達標GO大獎汽車不是夢 登記成功!",
"body" => "我們將於3個工作天內進行審核您的資料並通知您審核結果敬請留意收信。"
."\n\n登記資料:"
."\n流水號: A-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n流水號: B-".str_pad($eventItem->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$request->input('hospital_name')
."\n姓名:".(mb_strlen($request->input('name')) > 2 ? mb_substr($request->input('name'),0,1)."*".mb_substr($request->input('name'),-1) : mb_substr($request->input('name'),0,1)."*")
."\n身份證字號:".substr($request->input('twid'),0,2)."****".substr($request->input('twid'),-4)
@ -404,4 +404,89 @@ class ImprovedHealthFillFormController extends Controller
}
return redirect()->back()->with('success', '您已審格通過!');
}
public function doResendNotifyGet(Request $request)
{
$result = [];
$from = date('2025-06-26 16:43:00');
$to = date('2025-07-13 11:07:00');
$entries = EventImprovedHealth::whereBetween('updated_at', [$from, $to])->skip(0)->take(40)->get();
foreach($entries as $entry)
{
try {
switch($entry->check_state) {
case '1': //待審
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「健康達標GO大獎汽車不是夢」登記成功信件',
[
"title" => "健康達標GO大獎汽車不是夢 登記成功!",
"body" => "我們將於3個工作天內進行審核您的資料並通知您審核結果敬請留意收信。"
."\n\n登記資料:"
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
case '2': //過通
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「健康達標GO大獎汽車不是夢」審核通過信件。',
[
"title" => "健康達標GO大獎汽車不是夢 審核通過!",
"body" => "登記資料:"
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
."\n\n抽獎說明:"
."\n本活動將於10月抽出得獎名單並公告於「<a href=\"". route('news') ."\" target=\"_blank\">活動網站/最新消息</a>」及「<a href=\"https://dph.tycg.gov.tw/News.aspx?n=4219&sms=10121\" target=\"_blank\">桃園市政府衛生局網站/訊息公告/最新消息</a>」。"
,
]));
break;
case '3': //未通過
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「健康達標GO大獎汽車不是夢」審核未通過信件。',
[
"title" => "健康達標GO大獎汽車不是夢 審核未通過!",
"body" => "抱歉,您的審核未通過!請依以下理由重新上活動網站登記。"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: B-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
}
$entry->updated_at = \Carbon\Carbon::now();
$entry->save();
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson];
} catch (Exception $ex) {
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson, 'err' => $ex->getMessage()];
}
}
return $result;
}
}

View File

@ -331,4 +331,91 @@ class MetabolismFillFormController extends Controller
}
return redirect()->back()->with('success', '您已審格通過!');
}
public function doResendNotifyGet(Request $request)
{
$result = [];
$from = date('2025-06-26 16:43:00');
$to = date('2025-07-13 11:07:00');
$entries = EventMetabolism::whereBetween('updated_at', [$from, $to])->skip(0)->take(50)->get();
foreach($entries as $entry)
{
try {
switch($entry->check_state) {
case '1': //待審
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「符合代謝新收案早鳥報名最划算」登記成功信件',
[
"title" => "符合代謝新收案,早鳥報名最划算 登記成功!",
"body" => "我們將於3個工作天內進行審核您的資料並通知您審核結果敬請留意收信。"
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
case '2': //過通
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「符合代謝新收案早鳥報名最划算」審核通過信件。',
[
"title" => "符合代謝新收案,早鳥報名最划算 審核通過!",
"body" => "登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
."\n\n禮券發送方式說明:"
."\n凡報名經審核通過者我們將於3個工作天內將7-ELEVEN電子禮券序號寄送至您報名時所填寫的電子信箱敬請留意收信。"
."\n抽獎說明:"
."\n本活動將於10月抽出得獎名單並公告於「<a href=\"". route('news') ."\" target=\"_blank\">活動網站/最新消息</a>」及「<a href=\"https://dph.tycg.gov.tw/News.aspx?n=4219&sms=10121\" target=\"_blank\">桃園市政府衛生局網站/訊息公告/最新消息</a>」。"
,
]));
break;
case '3': //未通過
Mail::to($entry->email)->send(new EventNotifyMail(
'桃園市政府衛生局114年桃園市健康管理計畫「符合代謝新收案早鳥報名最划算」審核未通過信件。',
[
"title" => "符合代謝新收案,早鳥報名最划算 審核未通過!",
"body" => "抱歉,您的審核未通過!請依以下理由重新上活動網站登記。"
."\n理由:".$entry->check_reson
."\n\n登記資料:"
."\n流水號: A-".str_pad($entry->id, 6, '0', STR_PAD_LEFT)
."\n就醫院所:".$entry->hospital_name
."\n姓名:".(mb_strlen($entry->name) > 2 ? mb_substr($entry->name,0,1)."*".mb_substr($entry->name,-1) : mb_substr($entry->name,0,1)."*")
."\n身份證字號:".substr($entry->twid,0,2)."****".substr($entry->twid,-4)
."\n電話號碼:".substr($entry->phone,0,2)."****".substr($entry->phone,-4)
,
]));
break;
}
$entry->updated_at = \Carbon\Carbon::now();
$entry->save();
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson];
} catch (Exception $ex) {
$result[] = ['id' => $entry->id, 'email' => $entry->email, 'state' => $entry->check_state, 'reason' => $entry->check_reson, 'err' => $ex->getMessage()];
}
}
return $result;
}
}

View File

@ -31,6 +31,8 @@ Route::get('/metabolism_fill_form_ok', [\App\Http\Controllers\MetabolismFillForm
Route::get('/metabolism_check', [\App\Http\Controllers\MetabolismFillFormController::class, 'doCheckGet']);
Route::post('/metabolism_check', [\App\Http\Controllers\MetabolismFillFormController::class, 'doCheckPost']);
Route::get('/metabolism_resend', [\App\Http\Controllers\MetabolismFillFormController::class, 'doResendNotifyGet']);
//Route::get('/improved_health', function () {
// return view('improved_health');
//});
@ -41,6 +43,8 @@ Route::get('/improved_health_fill_form_ok', [\App\Http\Controllers\ImprovedHealt
Route::get('/improved_health_check', [\App\Http\Controllers\ImprovedHealthFillFormController::class, 'doCheckGet']);
Route::post('/improved_health_check', [\App\Http\Controllers\ImprovedHealthFillFormController::class, 'doCheckPost']);
Route::get('/improved_health_resend', [\App\Http\Controllers\ImprovedHealthFillFormController::class, 'doResendNotifyGet']);
//Route::get('/health_allowance', function () {
// return view('health_allowance');
@ -52,6 +56,8 @@ Route::get('/health_allowance_fill_form_ok', [\App\Http\Controllers\HealthAllowa
Route::get('/health_allowance_check', [\App\Http\Controllers\HealthAllowanceFillFormController::class, 'doCheckGet']);
Route::post('/health_allowance_check', [\App\Http\Controllers\HealthAllowanceFillFormController::class, 'doCheckPost']);
Route::get('/health_allowance_resend', [\App\Http\Controllers\HealthAllowanceFillFormController::class, 'doResendNotifyGet']);
Route::get('/link', function () {
return view('link');
});