@chevre/domain 24.1.0-alpha.5 → 24.1.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/emailMessageBuilder.js +4 -12
- package/lib/chevre/index.d.ts +1 -2
- package/lib/chevre/index.js +1 -3
- package/lib/chevre/repo/acceptedOffer.d.ts +20 -26
- package/lib/chevre/repo/acceptedOffer.js +113 -67
- package/lib/chevre/repo/acceptedOfferInReserve.d.ts +30 -0
- package/lib/chevre/repo/acceptedOfferInReserve.js +86 -0
- package/lib/chevre/repo/accountingReport.js +2 -30
- package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction/reserve.d.ts +1 -2
- package/lib/chevre/repo/assetTransaction/reserve.js +4 -50
- package/lib/chevre/repo/event.js +12 -8
- package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +7 -0
- package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.js +74 -0
- package/lib/chevre/repo/factory/reservation/createMongoConditions.d.ts +1 -1
- package/lib/chevre/repo/factory/reservation/createMongoConditions.js +171 -362
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +42 -42
- package/lib/chevre/repo/mongoose/schemas/order.js +108 -108
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -1
- package/lib/chevre/repo/mongoose/schemas/reservation.js +128 -146
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +84 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +2 -1
- package/lib/chevre/repo/order.d.ts +2 -83
- package/lib/chevre/repo/order.js +10 -373
- package/lib/chevre/repo/orderInTransaction.d.ts +52 -6
- package/lib/chevre/repo/orderInTransaction.js +58 -4
- package/lib/chevre/repo/place/hasPOS.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +20 -7
- package/lib/chevre/repo/reservation.js +16 -12
- package/lib/chevre/repo/role.d.ts +1 -15
- package/lib/chevre/repo/role.js +7 -14
- package/lib/chevre/repo/setting/integration.d.ts +27 -0
- package/lib/chevre/repo/setting/integration.js +102 -0
- package/lib/chevre/repo/transaction.d.ts +6 -6
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +11 -0
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +6 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +0 -1
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +14 -11
- package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/cancelReservation/start.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/check.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +0 -12
- package/lib/chevre/service/assetTransaction/reserve/start/factory/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +1 -1
- package/lib/chevre/service/delivery/factory.d.ts +6 -1
- package/lib/chevre/service/delivery/factory.js +1 -1
- package/lib/chevre/service/delivery/reservation/factory.d.ts +1 -3
- package/lib/chevre/service/delivery/reservation/factory.js +0 -17
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +2 -4
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +3 -3
- package/lib/chevre/service/notification/notifyByEmail.d.ts +3 -3
- package/lib/chevre/service/notification/notifyByEmail.js +7 -12
- package/lib/chevre/service/notification/sendEmailMessage.d.ts +2 -3
- package/lib/chevre/service/notification/sendEmailMessage.js +5 -4
- package/lib/chevre/service/offer/any.d.ts +7 -2
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +6 -3
- package/lib/chevre/service/offer/event/authorize/factory.js +13 -15
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +6 -2
- package/lib/chevre/service/offer/event/authorize.js +58 -11
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -3
- package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -1
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +15 -15
- package/lib/chevre/service/order/deleteOrder.js +19 -43
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +9 -11
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +0 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +6 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +0 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +0 -1
- package/lib/chevre/service/order/onOrderUpdated.js +0 -1
- package/lib/chevre/service/order/payOrder.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +4 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +0 -5
- package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder.d.ts +1 -1
- package/lib/chevre/service/order/returnOrder.js +0 -1
- package/lib/chevre/service/order/sendOrder.js +0 -4
- package/lib/chevre/service/payment/any/authorize.d.ts +1 -1
- package/lib/chevre/service/payment/any/person2username.js +0 -1
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize.js +4 -3
- package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +1 -1
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +1 -1
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +1 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +8 -1
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +1 -1
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +2 -2
- package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +1 -1
- package/lib/chevre/service/reserve/confirmReservation.js +7 -7
- package/lib/chevre/service/reserve/factory.js +2 -1
- package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
- package/lib/chevre/service/reserve/findByCode.js +1 -1
- package/lib/chevre/service/reserve/findReservations.d.ts +14 -6
- package/lib/chevre/service/reserve/findReservations.js +26 -36
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +0 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +0 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +4 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -10
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +0 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +0 -1
- package/lib/chevre/service/reserve/searchByOrder.js +7 -3
- package/lib/chevre/service/task/acceptCOAOffer.js +6 -3
- package/lib/chevre/service/task/authorizePayment.js +4 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +4 -2
- package/lib/chevre/service/task/checkMovieTicket.js +4 -2
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -3
- package/lib/chevre/service/task/createAccountingReport.js +4 -8
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +4 -2
- package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -2
- package/lib/chevre/service/task/invalidatePaymentUrl.js +3 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +3 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
- package/lib/chevre/service/task/pay.js +4 -2
- package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +1 -1
- package/lib/chevre/service/task/payment/payByTask.d.ts +1 -1
- package/lib/chevre/service/task/payment/payByTask.js +6 -7
- package/lib/chevre/service/task/payment/refundByTask.d.ts +1 -1
- package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +1 -1
- package/lib/chevre/service/task/placeOrder.js +3 -1
- package/lib/chevre/service/task/publishPaymentUrl.js +3 -1
- package/lib/chevre/service/task/refund.js +4 -2
- package/lib/chevre/service/task/returnReserveTransaction.js +4 -2
- package/lib/chevre/service/task/sendEmailMessage.js +5 -3
- package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
- package/lib/chevre/service/task/voidPayment.js +4 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +4 -2
- package/lib/chevre/service/task.d.ts +0 -7
- package/lib/chevre/service/taskHandler.js +1 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +5 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +0 -1
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/returnOrder/preStart.js +0 -3
- package/lib/chevre/service/validation/validateOrder.js +3 -78
- package/lib/chevre/settings.d.ts +0 -55
- package/lib/chevre/settings.js +1 -29
- package/lib/chevre/taskSettings.d.ts +0 -22
- package/lib/chevre/taskSettings.js +1 -7
- package/package.json +2 -2
- package/lib/chevre/credentials/customSearch.d.ts +0 -13
- package/lib/chevre/credentials/customSearch.js +0 -16
- package/lib/chevre/credentials/lineNotify.d.ts +0 -17
- package/lib/chevre/credentials/lineNotify.js +0 -20
- package/lib/chevre/credentials/sendGrid.d.ts +0 -24
- package/lib/chevre/credentials/sendGrid.js +0 -18
- package/lib/chevre/credentials.d.ts +0 -20
- package/lib/chevre/credentials.js +0 -42
|
@@ -43,7 +43,7 @@ function createOwnershipInfosFromOrder(params) {
|
|
|
43
43
|
ownershipInfo = (0, factory_2.createReservationOwnershipInfo)({
|
|
44
44
|
project: params.order.project,
|
|
45
45
|
ownedBy: ownedBy,
|
|
46
|
-
acceptedOffer
|
|
46
|
+
acceptedOffer,
|
|
47
47
|
ownedFrom: ownedFrom,
|
|
48
48
|
identifier: identifier,
|
|
49
49
|
acquiredFrom: acquiredFrom
|
|
@@ -6,9 +6,7 @@ export declare function createReservationOwnershipInfo(params: {
|
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
8
|
ownedBy: factory.ownershipInfo.IOwner[];
|
|
9
|
-
acceptedOffer: factory.order.IAcceptedOffer
|
|
10
|
-
itemOffered: factory.order.IReservation;
|
|
11
|
-
};
|
|
9
|
+
acceptedOffer: Pick<factory.order.IAcceptedOffer, 'itemOffered'>;
|
|
12
10
|
ownedFrom: Date;
|
|
13
11
|
identifier: string;
|
|
14
12
|
acquiredFrom: factory.ownershipInfo.IAcquiredFrom;
|
|
@@ -19,31 +19,14 @@ function createReservationOwnershipInfo(params) {
|
|
|
19
19
|
else {
|
|
20
20
|
throw new factory_1.factory.errors.NotImplemented(`itemOffered.typeOf '${itemOffered.typeOf}' not implemented`); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
21
21
|
}
|
|
22
|
-
// let bookingService = params.acceptedOffer.offeredThrough;
|
|
23
|
-
// if (bookingService === undefined) {
|
|
24
|
-
// // デフォルトブッキングサービスはChevre
|
|
25
|
-
// bookingService = {
|
|
26
|
-
// typeOf: 'WebAPI',
|
|
27
|
-
// identifier: factory.service.webAPI.Identifier.Chevre
|
|
28
|
-
// };
|
|
29
|
-
// }
|
|
30
22
|
let typeOfGood;
|
|
31
23
|
if (itemOffered.typeOf === factory_1.factory.reservationType.EventReservation) {
|
|
32
24
|
typeOfGood = {
|
|
33
25
|
typeOf: itemOffered.typeOf,
|
|
34
26
|
id: itemOffered.id,
|
|
35
27
|
reservationNumber: itemOffered.reservationNumber,
|
|
36
|
-
// bookingService: bookingService,
|
|
37
28
|
...(typeof itemOffered.issuedThrough?.typeOf === 'string') ? { issuedThrough: itemOffered.issuedThrough } : undefined
|
|
38
29
|
};
|
|
39
|
-
// } else if (itemOffered.typeOf === factory.reservationType.BusReservation) {
|
|
40
|
-
// typeOfGood = {
|
|
41
|
-
// typeOf: itemOffered.typeOf,
|
|
42
|
-
// id: itemOffered.id,
|
|
43
|
-
// reservationNumber: itemOffered.reservationNumber,
|
|
44
|
-
// bookingService: bookingService,
|
|
45
|
-
// ...(typeof itemOffered.issuedThrough?.typeOf === 'string') ? { issuedThrough: itemOffered.issuedThrough } : undefined
|
|
46
|
-
// };
|
|
47
30
|
}
|
|
48
31
|
else {
|
|
49
32
|
throw new factory_1.factory.errors.NotImplemented(`itemOffered.typeOf '${itemOffered.typeOf}' not implemented`); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { SendGridCredentials } from '../../credentials/sendGrid';
|
|
2
1
|
import type { TaskRepo } from '../../repo/task';
|
|
3
|
-
import {
|
|
2
|
+
import type { IntegrationSettingRepo } from '../../repo/setting/integration';
|
|
4
3
|
/**
|
|
5
4
|
* 中止されたタスクリストをEメールで通知する
|
|
6
5
|
* add(2025-03-13~)
|
|
@@ -9,7 +8,6 @@ declare function notifyAbortedTasksByEmail(params: {
|
|
|
9
8
|
dateAbortedGte: Date;
|
|
10
9
|
}): (repos: {
|
|
11
10
|
task: TaskRepo;
|
|
12
|
-
|
|
13
|
-
sendGrid: SendGridCredentials;
|
|
11
|
+
integrationSetting: IntegrationSettingRepo;
|
|
14
12
|
}) => Promise<void>;
|
|
15
13
|
export { notifyAbortedTasksByEmail };
|
|
@@ -14,8 +14,8 @@ const debug = (0, debug_1.default)('chevre-domain:service:notification');
|
|
|
14
14
|
* add(2025-03-13~)
|
|
15
15
|
*/
|
|
16
16
|
function notifyAbortedTasksByEmail(params) {
|
|
17
|
-
return async (repos
|
|
18
|
-
const
|
|
17
|
+
return async (repos) => {
|
|
18
|
+
const abortedTasksWithoutReport = await repos.integrationSetting.getByKey('abortedTasksWithoutReport');
|
|
19
19
|
const abortedTasks = await repos.task.projectFields({
|
|
20
20
|
status: { $eq: factory_1.factory.taskStatus.Aborted },
|
|
21
21
|
dateAborted: { $gte: params.dateAbortedGte },
|
|
@@ -30,7 +30,7 @@ function notifyAbortedTasksByEmail(params) {
|
|
|
30
30
|
const notifyResult = await (0, notifyByEmail_1.notifyByEmail)({
|
|
31
31
|
subject: message.subject, content: message.content,
|
|
32
32
|
logLevel: 'error'
|
|
33
|
-
})(
|
|
33
|
+
})(repos);
|
|
34
34
|
debug('notifyResult:', notifyResult);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IntegrationSettingRepo } from '../../repo/setting/integration';
|
|
2
2
|
declare function notifyByEmail(params: {
|
|
3
3
|
subject: string;
|
|
4
4
|
content: string;
|
|
5
5
|
logLevel: LineNotifyLogLevel;
|
|
6
|
-
}): (
|
|
7
|
-
|
|
6
|
+
}): (repos: {
|
|
7
|
+
integrationSetting: IntegrationSettingRepo;
|
|
8
8
|
}) => Promise<{
|
|
9
9
|
result: import("@chevre/factory/lib/chevre/action/transfer/send/message/email").IResult;
|
|
10
10
|
}>;
|
|
@@ -5,27 +5,22 @@ const client_1 = require("@sendgrid/client");
|
|
|
5
5
|
const http_status_1 = require("http-status");
|
|
6
6
|
const util_1 = require("util");
|
|
7
7
|
const factory_1 = require("../../factory");
|
|
8
|
-
// type ILineNotifyOperation<T> = (
|
|
9
|
-
// repos: undefined,
|
|
10
|
-
// credentials: {
|
|
11
|
-
// lineNotify: LINENotifyCredentials;
|
|
12
|
-
// }
|
|
13
|
-
// ) => Promise<T>;
|
|
14
8
|
function notifyByEmail(params) {
|
|
15
|
-
return async (
|
|
9
|
+
return async (repos) => {
|
|
16
10
|
const { logLevel } = params;
|
|
17
11
|
const shortSubject = params.subject;
|
|
18
12
|
const message = (0, util_1.format)('\n%s\n%s\n%s\n%s\n%s\n\n%s', `[${logLevel}] ${shortSubject}`, `now:${(new Date()).toISOString()}`, `pid:${process.pid}`, `GAE_APPLICATION:${process.env.GAE_APPLICATION}`,
|
|
19
13
|
// `GAE_INSTANCE:${process.env.GAE_INSTANCE}`,
|
|
20
14
|
`GAE_SERVICE:${process.env.GAE_SERVICE}`, params.content);
|
|
21
|
-
const
|
|
15
|
+
const sendGridSettings = await repos.integrationSetting.getByKey('sendGrid');
|
|
16
|
+
const apiKey = sendGridSettings?.apiKey;
|
|
22
17
|
if (typeof apiKey !== 'string') {
|
|
23
18
|
throw new factory_1.factory.errors.Internal('API Key not found');
|
|
24
19
|
}
|
|
25
|
-
const senderName =
|
|
26
|
-
const senderEmail =
|
|
27
|
-
const toRecipientEmail = (Array.isArray(
|
|
28
|
-
?
|
|
20
|
+
const senderName = sendGridSettings?.alert?.sender?.name;
|
|
21
|
+
const senderEmail = sendGridSettings?.alert?.sender?.email;
|
|
22
|
+
const toRecipientEmail = (Array.isArray(sendGridSettings?.alert?.toRecipient))
|
|
23
|
+
? sendGridSettings.alert?.toRecipient.at(0)?.email
|
|
29
24
|
: undefined;
|
|
30
25
|
if (typeof senderName !== 'string') {
|
|
31
26
|
throw new factory_1.factory.errors.Internal('senderName not found');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SendGridCredentials } from '../../credentials/sendGrid';
|
|
2
1
|
import { factory } from '../../factory';
|
|
3
2
|
import type { ActionRepo } from '../../repo/action';
|
|
4
3
|
import type { MessageRepo } from '../../repo/message';
|
|
5
4
|
import type { ProjectRepo } from '../../repo/project';
|
|
5
|
+
import type { IntegrationSettingRepo } from '../../repo/setting/integration';
|
|
6
6
|
/**
|
|
7
7
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
8
8
|
*/
|
|
@@ -14,7 +14,6 @@ declare function sendEmailMessage(params: factory.task.sendEmailMessage.IActionA
|
|
|
14
14
|
action: ActionRepo;
|
|
15
15
|
message: MessageRepo;
|
|
16
16
|
project: ProjectRepo;
|
|
17
|
-
|
|
18
|
-
sendGrid: SendGridCredentials;
|
|
17
|
+
integrationSetting: IntegrationSettingRepo;
|
|
19
18
|
}) => Promise<void>;
|
|
20
19
|
export { sendEmailMessage };
|
|
@@ -15,12 +15,13 @@ function createSendEmailMessageActionAttributes(params) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function createMailData(params) {
|
|
18
|
-
return async (repos
|
|
18
|
+
return async (repos) => {
|
|
19
19
|
const project = await repos.project.findById({
|
|
20
20
|
id: params.project.id,
|
|
21
21
|
inclusion: ['settings']
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
const sendGridSettings = await repos.integrationSetting.getByKey('sendGrid');
|
|
24
|
+
let apiKey = sendGridSettings?.apiKey;
|
|
24
25
|
// プロジェクト固有のSendGrid設定があれば、そちらを使用
|
|
25
26
|
if (typeof project.settings?.sendgridApiKey === 'string' && project.settings.sendgridApiKey.length > 0) {
|
|
26
27
|
apiKey = project.settings.sendgridApiKey;
|
|
@@ -71,8 +72,8 @@ function createMailData(params) {
|
|
|
71
72
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
72
73
|
*/
|
|
73
74
|
function sendEmailMessage(params) {
|
|
74
|
-
return async (repos
|
|
75
|
-
const { mailData, emailMessage, apiKey } = await createMailData(params)(repos
|
|
75
|
+
return async (repos) => {
|
|
76
|
+
const { mailData, emailMessage, apiKey } = await createMailData(params)(repos);
|
|
76
77
|
// add recipe(2025-03-12~)
|
|
77
78
|
let recipe = (0, factory_2.createSendEmailMessageRecipe)({
|
|
78
79
|
mailData,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { factory } from '../../factory';
|
|
2
|
-
import type { OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
2
|
+
import type { IMinimizedAcceptedOffer, OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
3
3
|
interface IAcceptOfferOperationRepos {
|
|
4
4
|
orderInTransaction: OrderInTransactionRepo;
|
|
5
5
|
}
|
|
@@ -10,7 +10,12 @@ export declare function acceptOffer(params: {
|
|
|
10
10
|
project: {
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
13
|
-
acceptedOffers: factory.order.IAcceptedOffer
|
|
13
|
+
acceptedOffers: IMinimizedAcceptedOffer[] | (Omit<factory.order.IAcceptedOffer, 'priceSpecification'> & {
|
|
14
|
+
/**
|
|
15
|
+
* COA以外では注文ドキュメントにpriceSpecificationが存在しないのでIFを補完
|
|
16
|
+
*/
|
|
17
|
+
priceSpecification?: factory.order.ITicketPriceSpecification;
|
|
18
|
+
})[];
|
|
14
19
|
}): IAcceptOfferOperation<void>;
|
|
15
20
|
export declare function voidAcceptedOffer(params: {
|
|
16
21
|
/**
|
|
@@ -23,7 +23,7 @@ declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
23
23
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
24
24
|
}): factory.action.authorize.offer.eventService.IAttributes;
|
|
25
25
|
declare function acceptedOffers2amount(params: {
|
|
26
|
-
acceptedOffers: IResultAcceptedOffer[];
|
|
26
|
+
acceptedOffers: Pick<IResultAcceptedOffer, 'priceSpecification' | 'id'>[];
|
|
27
27
|
}): number;
|
|
28
28
|
declare function acceptedOffers2authorizeResult(params: {
|
|
29
29
|
acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
|
|
@@ -32,8 +32,11 @@ declare function acceptedOffers2authorizeResult(params: {
|
|
|
32
32
|
ticketOffers: factory.product.ITicketOffer[];
|
|
33
33
|
}): factory.action.authorize.offer.eventService.IResult;
|
|
34
34
|
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
35
|
-
export type IResultAcceptedOffer = factory.order.
|
|
36
|
-
itemOffered: factory.order.
|
|
35
|
+
export type IResultAcceptedOffer = Omit<factory.order.IOptimizedAcceptedOffer, 'priceSpecification'> & {
|
|
36
|
+
itemOffered: factory.order.IEventReservation;
|
|
37
|
+
offeredThrough: factory.offer.IOfferedThrough;
|
|
38
|
+
serialNumber: string;
|
|
39
|
+
priceSpecification?: factory.order.ITicketPriceSpecification;
|
|
37
40
|
};
|
|
38
41
|
declare function responseBody2acceptedOffers4result(params: {
|
|
39
42
|
issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
|
|
@@ -302,20 +302,20 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
302
302
|
* 注文データの予約を生成する
|
|
303
303
|
*/
|
|
304
304
|
function createReservation(params) {
|
|
305
|
-
// const { itemOffered, event, reservationFor } = params;
|
|
306
305
|
const { itemOffered } = params;
|
|
307
306
|
const event = params.reservationFor;
|
|
308
307
|
let reservationItem;
|
|
308
|
+
const ticketType = {
|
|
309
|
+
typeOf: itemOffered.reservedTicket.ticketType.typeOf,
|
|
310
|
+
id: itemOffered.reservedTicket.ticketType.id,
|
|
311
|
+
identifier: itemOffered.reservedTicket.ticketType.identifier,
|
|
312
|
+
name: itemOffered.reservedTicket.ticketType.name,
|
|
313
|
+
description: itemOffered.reservedTicket.ticketType.description,
|
|
314
|
+
...((Array.isArray(itemOffered.reservedTicket.ticketType.additionalProperty)) && { additionalProperty: itemOffered.reservedTicket.ticketType.additionalProperty })
|
|
315
|
+
};
|
|
309
316
|
const reservedTicket = {
|
|
310
317
|
typeOf: itemOffered.reservedTicket.typeOf,
|
|
311
|
-
ticketType
|
|
312
|
-
typeOf: itemOffered.reservedTicket.ticketType.typeOf,
|
|
313
|
-
id: itemOffered.reservedTicket.ticketType.id,
|
|
314
|
-
identifier: itemOffered.reservedTicket.ticketType.identifier,
|
|
315
|
-
name: itemOffered.reservedTicket.ticketType.name,
|
|
316
|
-
description: itemOffered.reservedTicket.ticketType.description,
|
|
317
|
-
additionalProperty: itemOffered.reservedTicket.ticketType.additionalProperty
|
|
318
|
-
},
|
|
318
|
+
ticketType,
|
|
319
319
|
...(typeof itemOffered.reservedTicket.identifier === 'string')
|
|
320
320
|
? { identifier: itemOffered.reservedTicket.identifier }
|
|
321
321
|
: undefined, // チケット識別子追加(2024-04-15~)
|
|
@@ -367,19 +367,17 @@ function createReservation(params) {
|
|
|
367
367
|
if (params.issuedThrough.typeOf !== factory_1.factory.product.ProductType.EventService) {
|
|
368
368
|
throw new factory_1.factory.errors.Argument('issuedThrough', `issuedThrough.typeOf must be ${factory_1.factory.product.ProductType.EventService}`);
|
|
369
369
|
}
|
|
370
|
+
const { additionalProperty, additionalTicketText, programMembershipUsed } = itemOffered;
|
|
370
371
|
reservationItem = {
|
|
371
372
|
typeOf: itemOffered.typeOf,
|
|
372
|
-
additionalProperty: itemOffered.additionalProperty,
|
|
373
|
-
additionalTicketText: itemOffered.additionalTicketText,
|
|
374
373
|
id: itemOffered.id,
|
|
375
374
|
issuedThrough: params.issuedThrough,
|
|
376
375
|
reservationNumber: params.reservationNumber,
|
|
377
376
|
reservationFor,
|
|
378
377
|
reservedTicket,
|
|
379
|
-
|
|
380
|
-
...(typeof
|
|
381
|
-
|
|
382
|
-
: undefined
|
|
378
|
+
...((Array.isArray(additionalProperty)) && { additionalProperty }),
|
|
379
|
+
...((typeof additionalTicketText === 'string') && { additionalTicketText }),
|
|
380
|
+
...((typeof programMembershipUsed?.typeOf === 'string') && { programMembershipUsed }) // 使用メンバーシップがあれば追加
|
|
383
381
|
};
|
|
384
382
|
}
|
|
385
383
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { factory } from '../../../../factory';
|
|
2
|
-
import { Settings } from '../../../../
|
|
2
|
+
import type { IntegrationSettingRepo as Settings } from '../../../../repo/setting/integration';
|
|
3
3
|
import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
|
|
4
4
|
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
5
5
|
import type { EventRepo, IMinimizedIndividualEvent } from '../../../../repo/event';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { factory } from '../../../factory';
|
|
2
|
-
import { Settings } from '../../../
|
|
2
|
+
import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/integration';
|
|
3
3
|
import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
|
|
4
4
|
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
5
5
|
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
6
6
|
import type { EventRepo } from '../../../repo/event';
|
|
7
7
|
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
8
|
-
import { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
8
|
+
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
9
9
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
10
10
|
import type { MemberRepo } from '../../../repo/member';
|
|
11
11
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
@@ -67,6 +67,10 @@ interface IAuthorizeOptions {
|
|
|
67
67
|
* 最大n日前から予約可能
|
|
68
68
|
*/
|
|
69
69
|
maxReservationGracePeriodInDays: number;
|
|
70
|
+
/**
|
|
71
|
+
* 2026-06-04~
|
|
72
|
+
*/
|
|
73
|
+
useAcceptedOfferNoReservationFor: boolean;
|
|
70
74
|
}
|
|
71
75
|
/**
|
|
72
76
|
* 興行オファー承認
|
|
@@ -12,11 +12,7 @@ const searchOffersByIds_1 = require("./searchOffersByIds");
|
|
|
12
12
|
* 興行オファー承認
|
|
13
13
|
*/
|
|
14
14
|
function authorize(params, options) {
|
|
15
|
-
return async (repos, settings
|
|
16
|
-
// credentials: {
|
|
17
|
-
// jwt: JWTCredentials;
|
|
18
|
-
// }
|
|
19
|
-
) => {
|
|
15
|
+
return async (repos, settings) => {
|
|
20
16
|
const { noOfferSpecified } = options;
|
|
21
17
|
const { transaction, event } = await validateCreateRequest(params)(repos);
|
|
22
18
|
const { acceptedOffers, ticketOffers, unitPriceOffers } = await validateAcceptedOffers({
|
|
@@ -51,20 +47,26 @@ function authorize(params, options) {
|
|
|
51
47
|
validateEventOfferPeriod: params.validateEventOfferPeriod === true,
|
|
52
48
|
orderNumber,
|
|
53
49
|
instrument: params.instrument,
|
|
54
|
-
// useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, // discontinue(2024-07-02~)
|
|
55
|
-
// stockHoldUntilDaysAfterEventEnd,
|
|
56
50
|
...(typeof params.object.broker?.typeOf === 'string') ? { broker: params.object.broker } : undefined
|
|
57
51
|
}, options)(repos, settings);
|
|
58
52
|
acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
|
|
59
|
-
// add orderInTransaction(2024-01-15~)
|
|
60
53
|
if (!noOfferSpecified) {
|
|
61
|
-
|
|
54
|
+
const useAcceptedOfferNoReservationFor = options.useAcceptedOfferNoReservationFor === true;
|
|
62
55
|
await (0, any_1.acceptOffer)({
|
|
63
56
|
orderNumber,
|
|
64
57
|
project: transaction.project,
|
|
65
|
-
acceptedOffers: acceptedOffers4result
|
|
58
|
+
acceptedOffers: acceptedOffers4result.map((acceptOffer4result, offerIndex) => {
|
|
59
|
+
const { priceSpecification: _priceSpecification, itemOffered, ...acceptOfferNoPriceSpec } = acceptOffer4result;
|
|
60
|
+
const includeReservationFor = !useAcceptedOfferNoReservationFor
|
|
61
|
+
|| (useAcceptedOfferNoReservationFor && offerIndex === 0); // useAcceptedOfferNoReservationForの場合、ひとつめのオファーのみ含む(2026-06-04~)
|
|
62
|
+
return {
|
|
63
|
+
...acceptOfferNoPriceSpec,
|
|
64
|
+
itemOffered: minimizeItemOffered(itemOffered, {
|
|
65
|
+
includeReservationFor
|
|
66
|
+
})
|
|
67
|
+
};
|
|
68
|
+
})
|
|
66
69
|
})(repos);
|
|
67
|
-
// }
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
catch (error) {
|
|
@@ -81,6 +83,51 @@ function authorize(params, options) {
|
|
|
81
83
|
return { id: action.id, result };
|
|
82
84
|
};
|
|
83
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* 注文ドキュメントに保管するitemOfferedを最小化する
|
|
88
|
+
* 2026-05-25~
|
|
89
|
+
*/
|
|
90
|
+
function minimizeItemOffered(itemOffered, options) {
|
|
91
|
+
const { includeReservationFor } = options;
|
|
92
|
+
const { id, reservationNumber, typeOf, reservationFor } = itemOffered;
|
|
93
|
+
const minimizedReservation = {
|
|
94
|
+
id: reservationFor.id,
|
|
95
|
+
typeOf: reservationFor.typeOf,
|
|
96
|
+
location: {
|
|
97
|
+
branchCode: reservationFor.location.branchCode,
|
|
98
|
+
typeOf: reservationFor.location.typeOf
|
|
99
|
+
},
|
|
100
|
+
superEvent: {
|
|
101
|
+
id: reservationFor.superEvent.id,
|
|
102
|
+
typeOf: reservationFor.superEvent.typeOf,
|
|
103
|
+
location: {
|
|
104
|
+
branchCode: reservationFor.superEvent.location.branchCode,
|
|
105
|
+
typeOf: reservationFor.superEvent.location.typeOf
|
|
106
|
+
},
|
|
107
|
+
workPerformed: {
|
|
108
|
+
identifier: reservationFor.superEvent.workPerformed.identifier,
|
|
109
|
+
typeOf: reservationFor.superEvent.workPerformed.typeOf
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
startDate: reservationFor.startDate,
|
|
113
|
+
endDate: reservationFor.endDate
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
id,
|
|
117
|
+
reservationNumber,
|
|
118
|
+
typeOf,
|
|
119
|
+
...((includeReservationFor) && { reservationFor: minimizedReservation }),
|
|
120
|
+
// useAcceptedOfferNoReservedTicketでない場合のみreservedTicket保管(2026-06-03~)
|
|
121
|
+
// ...((!useAcceptedOfferNoReservedTicket) && {
|
|
122
|
+
// reservedTicket: {
|
|
123
|
+
// typeOf: reservedTicket.typeOf,
|
|
124
|
+
// // useAcceptedOfferNoTicketedSeatでない場合のみ座席保管(2026-06-01~)
|
|
125
|
+
// ...((!useAcceptedOfferNoTicketedSeat && typeof reservedTicket.ticketedSeat?.typeOf === 'string') && { ticketedSeat: reservedTicket.ticketedSeat }),
|
|
126
|
+
// ...((typeof reservedTicket.identifier === 'string') && { identifier: reservedTicket.identifier })
|
|
127
|
+
// }
|
|
128
|
+
// })
|
|
129
|
+
};
|
|
130
|
+
}
|
|
84
131
|
function validateCreateRequest(params) {
|
|
85
132
|
return async (repos) => {
|
|
86
133
|
const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { factory } from '../../../../factory';
|
|
2
|
-
import { Settings } from '../../../../
|
|
2
|
+
import type { IntegrationSettingRepo as Settings } from '../../../../repo/setting/integration';
|
|
3
3
|
import type { ActionRepo } from '../../../../repo/action';
|
|
4
4
|
import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
|
|
5
5
|
import type { OrderInTransactionRepo } from '../../../../repo/orderInTransaction';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { COA } from '@motionpicture/coa-service';
|
|
2
2
|
import { factory } from '../../../factory';
|
|
3
|
-
import { Settings } from '../../../
|
|
3
|
+
import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/integration';
|
|
4
4
|
import type { ActionRepo } from '../../../repo/action';
|
|
5
5
|
import type { AcceptCOAOfferActionRepo } from '../../../repo/action/acceptCOAOffer';
|
|
6
6
|
import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { COA } from '@motionpicture/coa-service';
|
|
2
2
|
import { factory } from '../../../factory';
|
|
3
|
-
import { Settings } from '../../../
|
|
3
|
+
import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/integration';
|
|
4
4
|
import type { ActionRepo } from '../../../repo/action';
|
|
5
5
|
import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
|
|
6
6
|
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
@@ -21,9 +21,7 @@ export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
21
21
|
export declare function offers2resultPrice(offers: IAcceptedOffer4COA[]): {
|
|
22
22
|
price: number;
|
|
23
23
|
};
|
|
24
|
-
type IResultAcceptedOffer =
|
|
25
|
-
itemOffered: factory.order.ICOAEventReservation;
|
|
26
|
-
};
|
|
24
|
+
type IResultAcceptedOffer = factory.order.ICOAAcceptedOffer;
|
|
27
25
|
/**
|
|
28
26
|
* COA仮予約結果から注文アイテムを生成する
|
|
29
27
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
2
|
import { factory } from '../../factory';
|
|
3
|
-
export declare function createAccountingReportIfNotExist(params: Pick<factory.order.IOrder, 'id' | 'orderNumber' | 'project' | '
|
|
3
|
+
export declare function createAccountingReportIfNotExist(params: Pick<factory.order.IOrder, 'id' | 'orderNumber' | 'project' | 'paymentMethods' | 'seller' | 'typeOf' | 'orderDate'> & {}): (repos: {
|
|
4
4
|
accountingReport: AccountingReportRepo;
|
|
5
5
|
}) => Promise<void>;
|
|
@@ -62,32 +62,32 @@ function createOrder4report(params) {
|
|
|
62
62
|
// }
|
|
63
63
|
// })
|
|
64
64
|
// : [];
|
|
65
|
-
const customer = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
65
|
+
// const customer: factory.report.accountingReport.IOptimizedCustomer = {
|
|
66
|
+
// id: params.customer.id,
|
|
67
|
+
// typeOf: params.customer.typeOf,
|
|
68
|
+
// additionalProperty: (Array.isArray(params.customer.additionalProperty))
|
|
69
|
+
// ? params.customer.additionalProperty
|
|
70
|
+
// : [],
|
|
71
|
+
// identifier: (Array.isArray(params.customer.identifier))
|
|
72
|
+
// ? params.customer.identifier
|
|
73
|
+
// : []
|
|
74
|
+
// };
|
|
75
75
|
return {
|
|
76
|
-
confirmationNumber: params.confirmationNumber,
|
|
77
76
|
id: params.id,
|
|
78
77
|
orderNumber: params.orderNumber,
|
|
79
|
-
paymentMethods: params.paymentMethods,
|
|
80
|
-
price: params.price,
|
|
81
|
-
priceCurrency: params.priceCurrency,
|
|
78
|
+
paymentMethods: params.paymentMethods.map(({ paymentMethodId }) => ({ paymentMethodId })),
|
|
82
79
|
seller: {
|
|
83
80
|
id: params.seller.id,
|
|
84
81
|
name: params.seller.name,
|
|
85
82
|
typeOf: params.seller.typeOf
|
|
86
83
|
},
|
|
87
84
|
typeOf: params.typeOf,
|
|
88
|
-
customer,
|
|
89
85
|
orderDate: (0, moment_timezone_1.default)(params.orderDate)
|
|
90
86
|
.toDate(),
|
|
87
|
+
// confirmationNumber: params.confirmationNumber, // discontinue(2026-05-06~)
|
|
88
|
+
// price: params.price, // discontinue(2026-05-06~)
|
|
89
|
+
// priceCurrency: params.priceCurrency, // discontinue(2026-05-06~)
|
|
90
|
+
// customer, // discontinue(2026-05-06~)
|
|
91
91
|
// numItems, // discontinue(2026-05-06~)
|
|
92
92
|
// orderedItem: params.orderedItem, // discontinue(2026-05-06~)
|
|
93
93
|
// acceptedOffers, // discontinue(2026-05-06~)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteOrder = deleteOrder;
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
// import { createOwnershipInfosFromOrder } from '../delivery/factory';
|
|
5
|
+
const factory_1 = require("../../factory");
|
|
6
6
|
/**
|
|
7
7
|
* 注文に関わるリソースを削除する
|
|
8
8
|
* 冪等性を確保すること
|
|
@@ -20,24 +20,24 @@ function deleteOrder(params) {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
if (typeof order.id !== 'string') {
|
|
23
|
-
throw new
|
|
23
|
+
throw new factory_1.factory.errors.Internal(`order.id undefined. orderNumber: ${params.object.orderNumber}`);
|
|
24
24
|
}
|
|
25
25
|
// 注文アイテムの予約を削除
|
|
26
26
|
await deleteReservationsByOrder(order)(repos);
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
catch (error) {
|
|
32
|
-
|
|
33
|
-
}
|
|
27
|
+
// 所有権は所有期限でcleanされるので、注文削除時連動はひとまず廃止(2026-05-17~)
|
|
28
|
+
// // 所有権削除
|
|
29
|
+
// try {
|
|
30
|
+
// await deleteOwnershipInfosByOrder(order)(repos);
|
|
31
|
+
// } catch (error) {
|
|
32
|
+
// console.error('deleteOwnershipInfosByOrder throws', error);
|
|
33
|
+
// }
|
|
34
34
|
// 経理レポート削除
|
|
35
35
|
await repos.accountingReport.deleteByOrderNumber({ mainEntity: { orderNumber: order.orderNumber } });
|
|
36
36
|
// メモ削除(2024-02-15~)
|
|
37
37
|
await repos.note.deleteNotesByAbout({
|
|
38
38
|
about: {
|
|
39
39
|
id: order.id,
|
|
40
|
-
typeOf:
|
|
40
|
+
typeOf: factory_1.factory.order.OrderType.Order
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
// 注文削除
|
|
@@ -49,7 +49,7 @@ function deleteOrder(params) {
|
|
|
49
49
|
function deletePersonIfNecessary(order) {
|
|
50
50
|
return async (repos) => {
|
|
51
51
|
// 代理注文を除く
|
|
52
|
-
const isCustomerPerson = order.customer.typeOf ===
|
|
52
|
+
const isCustomerPerson = order.customer.typeOf === factory_1.factory.personType.Person
|
|
53
53
|
&& typeof order.broker?.typeOf !== 'string';
|
|
54
54
|
if (isCustomerPerson) {
|
|
55
55
|
const ordersByPerson = await repos.order.projectFields({
|
|
@@ -60,12 +60,12 @@ function deletePersonIfNecessary(order) {
|
|
|
60
60
|
if (ordersByPerson.length === 0) {
|
|
61
61
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
62
62
|
if (typeof setting?.userPoolIdNew !== 'string') {
|
|
63
|
-
throw new
|
|
63
|
+
throw new factory_1.factory.errors.NotFound('setting.userPoolIdNew');
|
|
64
64
|
}
|
|
65
65
|
const deletePersonTask = {
|
|
66
|
-
project: { typeOf:
|
|
67
|
-
name:
|
|
68
|
-
status:
|
|
66
|
+
project: { typeOf: factory_1.factory.organizationType.Project, id: order.project.id },
|
|
67
|
+
name: factory_1.factory.taskName.DeletePerson,
|
|
68
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
69
69
|
runsAt: new Date(),
|
|
70
70
|
remainingNumberOfTries: 10,
|
|
71
71
|
numberOfTried: 0,
|
|
@@ -74,8 +74,8 @@ function deletePersonIfNecessary(order) {
|
|
|
74
74
|
id: order.customer.id,
|
|
75
75
|
agent: {
|
|
76
76
|
id: order.project.id,
|
|
77
|
-
typeOf:
|
|
78
|
-
name:
|
|
77
|
+
typeOf: factory_1.factory.organizationType.Project,
|
|
78
|
+
name: factory_1.factory.organizationType.Project
|
|
79
79
|
},
|
|
80
80
|
physically: true,
|
|
81
81
|
userPoolId: setting.userPoolIdNew,
|
|
@@ -94,7 +94,7 @@ function deleteReservationsByOrder(order) {
|
|
|
94
94
|
orderNumber: { $eq: order.orderNumber },
|
|
95
95
|
project: { id: { $eq: order.project.id } },
|
|
96
96
|
acceptedOffers: {
|
|
97
|
-
|
|
97
|
+
// itemOffered: { typeOf: { $in: [factory.reservationType.EventReservation] } }
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
const reservationIds = acceptedOffers.map((o) => String(o.itemOffered.id));
|
|
@@ -103,27 +103,3 @@ function deleteReservationsByOrder(order) {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
function deleteOwnershipInfosByOrder(order) {
|
|
107
|
-
return async (repos) => {
|
|
108
|
-
const now = new Date();
|
|
109
|
-
const ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({
|
|
110
|
-
order: {
|
|
111
|
-
...order,
|
|
112
|
-
acceptedOffers: await repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
113
|
-
orderNumber: { $eq: order.orderNumber },
|
|
114
|
-
project: { id: { $eq: order.project.id } }
|
|
115
|
-
})
|
|
116
|
-
},
|
|
117
|
-
offerIndexBase: 0
|
|
118
|
-
});
|
|
119
|
-
const ownershipIdentifiers = ownershipInfos.map((o) => String(o.identifier));
|
|
120
|
-
if (ownershipIdentifiers.length > 0) {
|
|
121
|
-
await repos.ownershipInfo.deleteExpiredByIdentifiers({
|
|
122
|
-
project: { id: order.project.id },
|
|
123
|
-
identifiers: ownershipIdentifiers,
|
|
124
|
-
// 所有期限切れのもの(ownedThroughの存在しないものは削除してはいけない)
|
|
125
|
-
ownedThrough: { $lte: now }
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|