Merged PR 638: ライセンス発行依頼受付通知 [U-105] の実装

## 概要
[Task3302: ライセンス発行依頼受付通知 [U-105] の実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3302)

- ライセンス注文時のメール通知処理を既存処理に追加しました。

## レビューポイント
- テンプレートの適用に問題はないでしょうか?
- メールに渡す値の取得処理は認識通りでしょうか?

## UIの変更
- なし

## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-12-19 01:16:50 +00:00
parent a676d65f0a
commit 4d325d1751
7 changed files with 249 additions and 22 deletions

View File

@ -27,8 +27,8 @@
"debug.javascript.usePreview": false,
"editor.copyWithSyntaxHighlighting": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,

View File

@ -1,7 +1,7 @@
{
"terminal.integrated.shell.linux": "/bin/bash",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.format.enable": false,
"[javascript]": {

View File

@ -106,6 +106,28 @@ export class LicensesService {
parentAccountId,
orderCount,
);
// メール送信処理
try {
const customer = await this.getAccountInformation(context, myAccountId);
const dealer = await this.getAccountInformation(
context,
parentAccountId,
);
this.sendgridService.sendMailWithU105(
context,
customer.adminEmails,
customer.companyName,
orderCount,
poNumber,
dealer.adminEmails,
dealer.companyName,
);
} catch (e) {
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
// メール送信に関する例外はログだけ出して握りつぶす
}
} catch (e) {
switch (e.constructor) {
case PoNumberAlreadyExistError:
@ -331,7 +353,11 @@ export class LicensesService {
await this.usersRepository.findUserByExternalId(context, externalId)
).account_id;
// 注文キャンセル処理
const { canceledOrderId } = await this.licensesRepository.cancelOrder(context, myAccountId, poNumber);
const { canceledOrderId } = await this.licensesRepository.cancelOrder(
context,
myAccountId,
poNumber,
);
// メール送信処理
try {
@ -366,7 +392,7 @@ export class LicensesService {
context,
customerAccountId,
poNumber,
canceledOrderId
canceledOrderId,
);
if (order == null) {

View File

@ -21,6 +21,8 @@ export class SendGridService {
private readonly mailFrom: string;
private readonly templateEmailVerifyHtml: string;
private readonly templateEmailVerifyText: string;
private readonly templateU105Html: string;
private readonly templateU105Text: string;
private readonly templateU106Html: string;
private readonly templateU106Text: string;
@ -44,6 +46,15 @@ export class SendGridService {
'utf-8',
);
this.templateU105Html = readFileSync(
path.resolve(__dirname, `../../templates/template_U_105.html`),
'utf-8',
);
this.templateU105Text = readFileSync(
path.resolve(__dirname, `../../templates/template_U_105.txt`),
'utf-8',
);
this.templateU106Html = readFileSync(
path.resolve(__dirname, `../../templates/template_U_106.html`),
'utf-8',
@ -156,6 +167,61 @@ export class SendGridService {
};
}
/**
* U-105使
* @param context
* @param customerMails (primary/secondary)
* @param customerAccountName
* @param lisenceCount
* @param poNumber PO番号
* @param dealerEmails (primary/secondary)
* @param dealerAccountName
* @returns mail with u105
*/
async sendMailWithU105(
context: Context,
customerMails: string[],
customerAccountName: string,
lisenceCount: number,
poNumber: string,
dealerEmails: string[],
dealerAccountName: string,
): Promise<void> {
this.logger.log(
`[IN] [${context.getTrackingId()}] ${this.sendMailWithU105.name}`,
);
try {
const subject = 'License Requested Notification [U-105]';
// メールの本文を作成する
const html = this.templateU105Html
.replaceAll(CUSTOMER_NAME, customerAccountName)
.replaceAll(DEALER_NAME, dealerAccountName)
.replaceAll(PO_NUMBER, poNumber)
.replaceAll(LICENSE_QUANTITY, `${lisenceCount}`);
const text = this.templateU105Text
.replaceAll(CUSTOMER_NAME, customerAccountName)
.replaceAll(DEALER_NAME, dealerAccountName)
.replaceAll(PO_NUMBER, poNumber)
.replaceAll(LICENSE_QUANTITY, `${lisenceCount}`);
// メールを送信する
this.sendMail(
context,
customerMails,
dealerEmails,
this.mailFrom,
subject,
text,
html,
);
} finally {
this.logger.log(
`[OUT] [${context.getTrackingId()}] ${this.sendMailWithU105.name}`,
);
}
}
/**
* U-106使
* @param context
@ -184,23 +250,15 @@ export class SendGridService {
// メールの本文を作成する
const html = this.templateU106Html
.split(CUSTOMER_NAME)
.join(customerAccountName)
.split(DEALER_NAME)
.join(dealerAccountName)
.split(PO_NUMBER)
.join(poNumber)
.split(LICENSE_QUANTITY)
.join(`${lisenceCount}`);
.replaceAll(CUSTOMER_NAME, customerAccountName)
.replaceAll(DEALER_NAME, dealerAccountName)
.replaceAll(PO_NUMBER, poNumber)
.replaceAll(LICENSE_QUANTITY, `${lisenceCount}`);
const text = this.templateU106Text
.split(CUSTOMER_NAME)
.join(customerAccountName)
.split(DEALER_NAME)
.join(dealerAccountName)
.split(PO_NUMBER)
.join(poNumber)
.split(LICENSE_QUANTITY)
.join(`${lisenceCount}`);
.replaceAll(CUSTOMER_NAME, customerAccountName)
.replaceAll(DEALER_NAME, dealerAccountName)
.replaceAll(PO_NUMBER, poNumber)
.replaceAll(LICENSE_QUANTITY, `${lisenceCount}`);
// メールを送信する
this.sendMail(

View File

@ -0,0 +1,93 @@
<html>
<head>
<title>License Requested Notification [U-105]</title>
</head>
<body>
<div>
<h3>&lt;English&gt;</h3>
<p>Dear $CUSTOMER_NAME$,</p>
<p>
We have received your requested license order.<br />
- Number of licenses ordered: $LICENSE_QUANTITY$<br />
- PO Number: $PO_NUMBER$
</p>
<p>
Licenses will be issued by your $DEALER_NAME$ which you have selected in
the setting. Licenses issued by your dealer will be stored in your
license inventory. Please log in to the ODMS Cloud to view and assign
licenses to your users.
</p>
<p>
Licenses are valid for 12 months from the date they are assigned to a
user.
</p>
<p>
If you need support regarding ODMS Cloud, please contact $DEALER_NAME$.
</p>
<p>
If you have received this e-mail in error, please delete this e-mail
from your system.<br />
This is an automatically generated e-mail and this mailbox is not
monitored. Please do not reply.
</p>
</div>
<div>
<h3>&lt;Deutsch&gt;</h3>
<p>Dear $CUSTOMER_NAME$,</p>
<p>
We have received your requested license order.<br />
- Number of licenses ordered: $LICENSE_QUANTITY$<br />
- PO Number: $PO_NUMBER$
</p>
<p>
Licenses will be issued by your $DEALER_NAME$ which you have selected in
the setting. Licenses issued by your dealer will be stored in your
license inventory. Please log in to the ODMS Cloud to view and assign
licenses to your users.
</p>
<p>
Licenses are valid for 12 months from the date they are assigned to a
user.
</p>
<p>
If you need support regarding ODMS Cloud, please contact $DEALER_NAME$.
</p>
<p>
If you have received this e-mail in error, please delete this e-mail
from your system.<br />
This is an automatically generated e-mail and this mailbox is not
monitored. Please do not reply.
</p>
</div>
<div>
<h3>&lt;Français&gt;</h3>
<p>Chère/Cher $CUSTOMER_NAME$,</p>
<p>
Nous avons reçu votre commande de licence demandée.<br />
- Nombre de licences commandées: $LICENSE_QUANTITY$<br />
- Numéro de bon de commande: $PO_NUMBER$
</p>
<p>
Les licences seront délivrées par votre $DEALER_NAME$ que vous avez
sélectionné dans les paramètres. Les licences délivrées par votre
concessionnaire seront stockées dans votre inventaire de licences.
Veuillez vous connecter au ODMS Cloud pour afficher et attribuer des
licences à vos utilisateurs.
</p>
<p>
Les licences sont valables 12 mois à compter de la date à laquelle elles
sont attribuées à un utilisateur.
</p>
<p>
Si vous avez besoin d'assistance concernant ODMS Cloud, veuillez
contacter $DEALER_NAME$.
</p>
<p>
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail
de votre système.<br />
Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres
n'est pas surveillée. Merci de ne pas répondre.
</p>
</div>
</body>
</html>

View File

@ -0,0 +1,50 @@
<English>
Dear $CUSTOMER_NAME$,
We have received your requested license order.
- Number of licenses ordered: $LICENSE_QUANTITY$
- PO Number: $PO_NUMBER$
Licenses will be issued by your $DEALER_NAME$ which you have selected in the setting. Licenses issued by your dealer will be stored in your license inventory. Please log in to the ODMS Cloud to view and assign licenses to your users.
Licenses are valid for 12 months from the date they are assigned to a user.
If you need support regarding ODMS Cloud, please contact $DEALER_NAME$.
If you have received this e-mail in error, please delete this e-mail from your system.
This is an automatically generated e-mail and this mailbox is not monitored. Please do not reply.
<Deutsch>
Dear $CUSTOMER_NAME$,
We have received your requested license order.
- Number of licenses ordered: $LICENSE_QUANTITY$
- PO Number: $PO_NUMBER$
Licenses will be issued by your $DEALER_NAME$ which you have selected in the setting. Licenses issued by your dealer will be stored in your license inventory. Please log in to the ODMS Cloud to view and assign licenses to your users.
Licenses are valid for 12 months from the date they are assigned to a user.
If you need support regarding ODMS Cloud, please contact $DEALER_NAME$.
If you have received this e-mail in error, please delete this e-mail from your system.
This is an automatically generated e-mail and this mailbox is not monitored. Please do not reply.
<Français>
Chère/Cher $CUSTOMER_NAME$,
Nous avons reçu votre commande de licence demandée.
- Nombre de licences commandées: $LICENSE_QUANTITY$
- Numéro de bon de commande: $PO_NUMBER$
Les licences seront délivrées par votre $DEALER_NAME$ que vous avez sélectionné dans les paramètres. Les licences délivrées par votre concessionnaire seront stockées dans votre inventaire de licences. Veuillez vous connecter au ODMS Cloud pour afficher et attribuer des licences à vos utilisateurs.
Les licences sont valables 12 mois à compter de la date à laquelle elles sont attribuées à un utilisateur.
Si vous avez besoin d'assistance concernant ODMS Cloud, veuillez contacter $DEALER_NAME$.
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail de votre système.
Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres n'est pas surveillée. Merci de ne pas répondre.

View File

@ -6,7 +6,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",