@chevre/domain 20.1.0-alpha.5 → 20.1.0-alpha.50
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/example/src/chevre/deleteReservationTicketUnderNames.ts +20 -0
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +157 -0
- package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +116 -0
- package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +139 -0
- package/example/src/chevre/migrateEventProjectAttributes.ts +57 -0
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
- package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
- package/example/src/chevre/searchEvents.ts +36 -16
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -4
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -4
- package/lib/chevre/factory/reservedAgentIdentifireNames.d.ts +1 -0
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +12 -0
- package/lib/chevre/repo/accountAction.d.ts +0 -18
- package/lib/chevre/repo/accountAction.js +402 -355
- package/lib/chevre/repo/accountTitle.d.ts +1 -0
- package/lib/chevre/repo/accountTitle.js +6 -1
- package/lib/chevre/repo/additionalProperty.d.ts +35 -0
- package/lib/chevre/repo/additionalProperty.js +205 -0
- package/lib/chevre/repo/categoryCode.d.ts +1 -0
- package/lib/chevre/repo/categoryCode.js +15 -1
- package/lib/chevre/repo/creativeWork.js +10 -1
- package/lib/chevre/repo/customer.d.ts +1 -0
- package/lib/chevre/repo/customer.js +5 -0
- package/lib/chevre/repo/event.d.ts +12 -4
- package/lib/chevre/repo/event.js +84 -48
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
- package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
- package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
- package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
- package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
- package/lib/chevre/repo/mongoose/model/event.js +53 -0
- package/lib/chevre/repo/mongoose/model/offer.js +7 -1
- package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
- package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
- package/lib/chevre/repo/mongoose/model/place.js +42 -0
- package/lib/chevre/repo/offer.js +10 -1
- package/lib/chevre/repo/offerCatalog.js +10 -10
- package/lib/chevre/repo/person.js +4 -1
- package/lib/chevre/repo/place.d.ts +1 -0
- package/lib/chevre/repo/place.js +54 -7
- package/lib/chevre/repo/reservation.d.ts +17 -2
- package/lib/chevre/repo/reservation.js +41 -1
- package/lib/chevre/repo/transaction.js +20 -5
- package/lib/chevre/repository.d.ts +6 -3
- package/lib/chevre/repository.js +10 -5
- package/lib/chevre/service/account.d.ts +0 -4
- package/lib/chevre/service/account.js +24 -22
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/deposit.js +3 -3
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/transfer.js +3 -3
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +86 -42
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +9 -19
- package/lib/chevre/service/assetTransaction/reserve/factory.js +119 -115
- package/lib/chevre/service/assetTransaction/reserve.js +41 -95
- package/lib/chevre/service/delivery/factory.js +2 -1
- package/lib/chevre/service/event.js +20 -6
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize.js +65 -27
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +17 -12
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
- package/lib/chevre/service/offer/factory.js +7 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +11 -3
- package/lib/chevre/service/order/onOrderStatusChanged.js +3 -2
- package/lib/chevre/service/order/placeOrder.js +13 -5
- package/lib/chevre/service/order/returnOrder.js +2 -1
- package/lib/chevre/service/order/sendOrder.js +2 -1
- package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -5
- package/lib/chevre/service/reserve/cancelReservation.js +260 -107
- package/lib/chevre/service/reserve/confirmReservation.js +65 -33
- package/lib/chevre/service/reserve/factory.d.ts +14 -2
- package/lib/chevre/service/reserve/factory.js +13 -6
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +85 -30
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +15 -31
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +20 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +2 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +2 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -1
- package/lib/chevre/service/transaction/returnOrder.js +10 -1
- package/lib/chevre/service/transaction.js +1 -14
- package/lib/chevre/service.d.ts +2 -0
- package/lib/chevre/service.js +2 -0
- package/package.json +4 -4
- package/example/src/chevre/accountBlanceTest.ts +0 -24
- package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
- package/example/src/chevre/createSeats.ts +0 -59
- package/example/src/chevre/deleteEvents.ts +0 -50
- package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
- package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
- package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
- package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
- package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
- package/example/src/chevre/publishConfirmationNumber.ts +0 -30
- package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
- package/example/src/chevre/publishTransactionNumber.ts +0 -28
- package/example/src/chevre/renameTransaction.ts +0 -22
- package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
|
@@ -19,78 +19,140 @@ const onReservationCanceled_1 = require("./potentialActions/onReservationCancele
|
|
|
19
19
|
/**
|
|
20
20
|
* 進行中の予約をキャンセルする
|
|
21
21
|
*/
|
|
22
|
+
// tslint:disable-next-line:max-func-body-length
|
|
22
23
|
function cancelPendingReservation(actionAttributesList) {
|
|
24
|
+
// tslint:disable-next-line:max-func-body-length
|
|
23
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
26
|
const now = new Date();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const cancelingSubReservation = (_a = reserveTransaction.object.subReservation) === null || _a === void 0 ? void 0 : _a.find((r) => {
|
|
43
|
-
return r.id === actionAttributes.object.id;
|
|
27
|
+
let canceledReservations = [];
|
|
28
|
+
if (actionAttributesList.length > 0) {
|
|
29
|
+
// tslint:disable-next-line:max-func-body-length
|
|
30
|
+
yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
// let canceledReservation: factory.reservation.eventReservation.IReservation | undefined;
|
|
32
|
+
const reserveTransactionId = actionAttributes.purpose.id;
|
|
33
|
+
// アクション開始
|
|
34
|
+
const action = yield repos.action.start(actionAttributes);
|
|
35
|
+
const actionObject = actionAttributes.object;
|
|
36
|
+
let cancelResult;
|
|
37
|
+
try {
|
|
38
|
+
// 予約取引を検索
|
|
39
|
+
const reserveTransactions = yield repos.assetTransaction.search({
|
|
40
|
+
limit: 1,
|
|
41
|
+
page: 1,
|
|
42
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
43
|
+
ids: [reserveTransactionId]
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
if (
|
|
45
|
+
const reserveTransaction = reserveTransactions.shift();
|
|
46
|
+
if (reserveTransaction !== undefined) {
|
|
47
47
|
const reservationFor = reserveTransaction.object.reservationFor;
|
|
48
48
|
if (reservationFor === undefined) {
|
|
49
49
|
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
// ReservationPackageに対応(2022-12-23~)
|
|
52
|
+
if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
|
|
53
|
+
const subReservation = reserveTransaction.object.subReservation;
|
|
54
|
+
if (Array.isArray(subReservation) && subReservation.length > 0) {
|
|
55
|
+
yield Promise.all(subReservation.map((cancelingSubReservation) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
// const cancelingReservation: factory.reservation.eventReservation.IReservation = {
|
|
57
|
+
// ...cancelingSubReservation,
|
|
58
|
+
// reservationFor
|
|
59
|
+
// };
|
|
60
|
+
yield processUnlockSeat({
|
|
61
|
+
reservation: {
|
|
62
|
+
id: cancelingSubReservation.id,
|
|
63
|
+
reservedTicket: cancelingSubReservation.reservedTicket,
|
|
64
|
+
subReservation: cancelingSubReservation.subReservation,
|
|
65
|
+
reservationFor: { id: reservationFor.id }
|
|
66
|
+
},
|
|
67
|
+
expectedHolder: reserveTransactionId
|
|
68
|
+
})(repos);
|
|
69
|
+
yield processUnlockOfferRateLimit({
|
|
70
|
+
reservation: {
|
|
71
|
+
reservationNumber: cancelingSubReservation.reservationNumber,
|
|
72
|
+
reservedTicket: cancelingSubReservation.reservedTicket
|
|
73
|
+
},
|
|
74
|
+
reservationFor
|
|
75
|
+
})(repos);
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
78
|
+
// 予約番号単位でキャンセル状態に変更する
|
|
79
|
+
cancelResult = yield repos.reservation.cancelByReservationNumber({
|
|
80
|
+
reservationNumber: actionObject.reservationNumber,
|
|
81
|
+
previousReservationStatus: actionObject.reservationStatus,
|
|
82
|
+
modifiedTime: now
|
|
67
83
|
});
|
|
68
|
-
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// 廃止(2022-12-27~)
|
|
87
|
+
throw new factory.errors.NotImplemented(`object.typeOf '${actionObject.typeOf}' not implemented`);
|
|
88
|
+
// const cancelingSubReservation = reserveTransaction.object.subReservation?.find((r) => {
|
|
89
|
+
// return r.id === actionObject.id;
|
|
90
|
+
// });
|
|
91
|
+
// // 取消対象予約が取引に存在すれば、適宜unlock
|
|
92
|
+
// if (cancelingSubReservation !== undefined) {
|
|
93
|
+
// const cancelingReservation: factory.reservation.eventReservation.IReservation = {
|
|
94
|
+
// ...cancelingSubReservation,
|
|
95
|
+
// reservationFor
|
|
96
|
+
// };
|
|
97
|
+
// await processUnlockSeat({
|
|
98
|
+
// reservation: cancelingReservation,
|
|
99
|
+
// expectedHolder: reserveTransactionId
|
|
100
|
+
// })(repos);
|
|
101
|
+
// await processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
|
|
102
|
+
// // 予約が存在すればキャンセル状態に変更する
|
|
103
|
+
// const reservationCount = await repos.reservation.count({
|
|
104
|
+
// typeOf: cancelingSubReservation.typeOf,
|
|
105
|
+
// ids: [cancelingSubReservation.id]
|
|
106
|
+
// });
|
|
107
|
+
// if (reservationCount > 0) {
|
|
108
|
+
// await repos.reservation.cancel<factory.reservationType.EventReservation>({
|
|
109
|
+
// id: cancelingSubReservation.id,
|
|
110
|
+
// previousReservationStatus: actionObject.reservationStatus,
|
|
111
|
+
// modifiedTime: now
|
|
112
|
+
// });
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
69
115
|
}
|
|
70
116
|
}
|
|
71
117
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
118
|
+
catch (error) {
|
|
119
|
+
// actionにエラー結果を追加
|
|
120
|
+
try {
|
|
121
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
122
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
123
|
+
}
|
|
124
|
+
catch (__) {
|
|
125
|
+
// 失敗したら仕方ない
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
78
128
|
}
|
|
79
|
-
|
|
80
|
-
|
|
129
|
+
// アクション完了
|
|
130
|
+
const actionResult = Object.assign({}, (cancelResult !== undefined) ? {
|
|
131
|
+
cancelResult: {
|
|
132
|
+
n: cancelResult.n,
|
|
133
|
+
nModified: cancelResult.nModified,
|
|
134
|
+
ok: cancelResult.ok
|
|
135
|
+
}
|
|
136
|
+
} : undefined
|
|
137
|
+
// canceledReservationId: canceledReservation?.id
|
|
138
|
+
);
|
|
139
|
+
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
140
|
+
// await onReservationCanceledByAction(actionAttributes)({ task: repos.task });
|
|
141
|
+
if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
|
|
142
|
+
// 最新のconfirmedReservationsを検索
|
|
143
|
+
canceledReservations = yield repos.reservation.search({
|
|
144
|
+
reservationNumber: { $eq: actionObject.reservationNumber },
|
|
145
|
+
typeOf: factory.reservationType.EventReservation
|
|
146
|
+
});
|
|
147
|
+
canceledReservations = canceledReservations.map((r) => {
|
|
148
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
149
|
+
delete r._id;
|
|
150
|
+
return r;
|
|
151
|
+
});
|
|
81
152
|
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const actionResult = {
|
|
86
|
-
canceledReservationId: canceledReservation === null || canceledReservation === void 0 ? void 0 : canceledReservation.id
|
|
87
|
-
};
|
|
88
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
89
|
-
if (canceledReservation !== undefined) {
|
|
90
|
-
yield (0, onReservationCanceled_1.onReservationCanceledByAction)(actionAttributes)({ task: repos.task });
|
|
91
|
-
}
|
|
92
|
-
})));
|
|
93
|
-
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false)({ task: repos.task });
|
|
153
|
+
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false)({ task: repos.task });
|
|
154
|
+
})));
|
|
155
|
+
}
|
|
94
156
|
});
|
|
95
157
|
}
|
|
96
158
|
exports.cancelPendingReservation = cancelPendingReservation;
|
|
@@ -98,61 +160,152 @@ exports.cancelPendingReservation = cancelPendingReservation;
|
|
|
98
160
|
* 予約をキャンセルする
|
|
99
161
|
*/
|
|
100
162
|
function cancelReservation(actionAttributesList) {
|
|
163
|
+
// tslint:disable-next-line:max-func-body-length
|
|
101
164
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
102
165
|
const now = new Date();
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
166
|
+
if (actionAttributesList.length > 0) {
|
|
167
|
+
// tslint:disable-next-line:max-func-body-length
|
|
168
|
+
yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const action = yield repos.action.start(actionAttributes);
|
|
170
|
+
let cancelResult;
|
|
171
|
+
try {
|
|
172
|
+
if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
|
|
173
|
+
// 予約取引を検索
|
|
174
|
+
const reserveTransactions = yield repos.assetTransaction.search({
|
|
175
|
+
limit: 1,
|
|
176
|
+
page: 1,
|
|
177
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
178
|
+
transactionNumber: { $eq: actionAttributes.object.reservationNumber }
|
|
179
|
+
});
|
|
180
|
+
const reserveTransaction = reserveTransactions.shift();
|
|
181
|
+
if (reserveTransaction === undefined) {
|
|
182
|
+
throw new factory.errors.NotFound('ReserveTransaction');
|
|
183
|
+
}
|
|
184
|
+
const reservationFor = reserveTransaction.object.reservationFor;
|
|
185
|
+
if (reservationFor === undefined) {
|
|
186
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
187
|
+
}
|
|
188
|
+
const subReservation = reserveTransaction.object.subReservation;
|
|
189
|
+
if (Array.isArray(subReservation) && subReservation.length > 0) {
|
|
190
|
+
yield Promise.all(subReservation.map((cancelingSubReservation) => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
// const cancelingReservation: factory.reservation.eventReservation.IReservation = {
|
|
192
|
+
// ...cancelingSubReservation,
|
|
193
|
+
// reservationFor
|
|
194
|
+
// };
|
|
195
|
+
yield processUnlockSeat({
|
|
196
|
+
reservation: {
|
|
197
|
+
id: cancelingSubReservation.id,
|
|
198
|
+
reservedTicket: cancelingSubReservation.reservedTicket,
|
|
199
|
+
subReservation: cancelingSubReservation.subReservation,
|
|
200
|
+
reservationFor: { id: reservationFor.id }
|
|
201
|
+
},
|
|
202
|
+
expectedHolder: reserveTransaction.id
|
|
203
|
+
})(repos);
|
|
204
|
+
yield processUnlockOfferRateLimit({
|
|
205
|
+
reservation: {
|
|
206
|
+
reservationNumber: cancelingSubReservation.reservationNumber,
|
|
207
|
+
reservedTicket: cancelingSubReservation.reservedTicket
|
|
208
|
+
},
|
|
209
|
+
reservationFor
|
|
210
|
+
})(repos);
|
|
211
|
+
})));
|
|
212
|
+
}
|
|
213
|
+
// 予約番号単位でキャンセル状態に変更する
|
|
214
|
+
cancelResult = yield repos.reservation.cancelByReservationNumber({
|
|
215
|
+
reservationNumber: actionAttributes.object.reservationNumber,
|
|
216
|
+
previousReservationStatus: actionAttributes.object.reservationStatus,
|
|
217
|
+
modifiedTime: now
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const reservation = yield repos.reservation.findById({
|
|
222
|
+
id: actionAttributes.object.id
|
|
223
|
+
});
|
|
224
|
+
// 予約取引を検索
|
|
225
|
+
const reserveTransactions = yield repos.assetTransaction.search({
|
|
226
|
+
limit: 1,
|
|
227
|
+
page: 1,
|
|
228
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
229
|
+
object: { reservations: { id: { $in: [reservation.id] } } }
|
|
230
|
+
});
|
|
231
|
+
const reserveTransaction = reserveTransactions.shift();
|
|
232
|
+
let expectedHolder;
|
|
233
|
+
if (reserveTransaction !== undefined) {
|
|
234
|
+
expectedHolder = reserveTransaction.id;
|
|
235
|
+
}
|
|
236
|
+
if (typeof expectedHolder === 'string') {
|
|
237
|
+
yield processUnlockSeat({
|
|
238
|
+
reservation: {
|
|
239
|
+
id: reservation.id,
|
|
240
|
+
reservedTicket: reservation.reservedTicket,
|
|
241
|
+
subReservation: reservation.subReservation,
|
|
242
|
+
reservationFor: { id: reservation.reservationFor.id }
|
|
243
|
+
},
|
|
244
|
+
expectedHolder
|
|
245
|
+
})(repos);
|
|
246
|
+
}
|
|
247
|
+
yield processUnlockOfferRateLimit({
|
|
248
|
+
reservation: {
|
|
249
|
+
reservationNumber: reservation.reservationNumber,
|
|
250
|
+
reservedTicket: reservation.reservedTicket
|
|
251
|
+
},
|
|
252
|
+
reservationFor: reservation.reservationFor
|
|
253
|
+
})(repos);
|
|
254
|
+
// 予約をキャンセル状態に変更する
|
|
255
|
+
yield repos.reservation.cancel({
|
|
256
|
+
id: reservation.id,
|
|
257
|
+
previousReservationStatus: actionAttributes.object.reservationStatus,
|
|
258
|
+
modifiedTime: now
|
|
259
|
+
});
|
|
260
|
+
}
|
|
122
261
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
262
|
+
catch (error) {
|
|
263
|
+
// actionにエラー結果を追加
|
|
264
|
+
try {
|
|
265
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
266
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
267
|
+
}
|
|
268
|
+
catch (__) {
|
|
269
|
+
// 失敗したら仕方ない
|
|
270
|
+
}
|
|
271
|
+
throw error;
|
|
128
272
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
273
|
+
const actionResult = Object.assign({}, (cancelResult !== undefined) ? {
|
|
274
|
+
cancelResult: {
|
|
275
|
+
n: cancelResult.n,
|
|
276
|
+
nModified: cancelResult.nModified,
|
|
277
|
+
ok: cancelResult.ok
|
|
278
|
+
}
|
|
279
|
+
} : undefined
|
|
280
|
+
// canceledReservationId: canceledReservation?.id
|
|
281
|
+
);
|
|
282
|
+
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
283
|
+
// await onReservationCanceledByAction(actionAttributes)({ task: repos.task });
|
|
284
|
+
let canceledReservations = [];
|
|
285
|
+
if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
|
|
286
|
+
const reservationNumber = actionAttributes.object.reservationNumber;
|
|
287
|
+
if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
|
|
288
|
+
// 最新のconfirmedReservationsを検索
|
|
289
|
+
canceledReservations = yield repos.reservation.search({
|
|
290
|
+
reservationNumber: { $eq: reservationNumber },
|
|
291
|
+
typeOf: factory.reservationType.EventReservation
|
|
292
|
+
});
|
|
293
|
+
canceledReservations = canceledReservations.map((r) => {
|
|
294
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
295
|
+
delete r._id;
|
|
296
|
+
return r;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
143
299
|
}
|
|
144
|
-
|
|
145
|
-
|
|
300
|
+
else {
|
|
301
|
+
const canceledReservation = yield repos.reservation.findById({
|
|
302
|
+
id: actionAttributes.object.id
|
|
303
|
+
});
|
|
304
|
+
canceledReservations = [canceledReservation];
|
|
146
305
|
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
canceledReservationId: canceledReservation === null || canceledReservation === void 0 ? void 0 : canceledReservation.id
|
|
151
|
-
};
|
|
152
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
153
|
-
yield (0, onReservationCanceled_1.onReservationCanceledByAction)(actionAttributes)({ task: repos.task });
|
|
154
|
-
})));
|
|
155
|
-
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, true)({ task: repos.task });
|
|
306
|
+
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, true)({ task: repos.task });
|
|
307
|
+
})));
|
|
308
|
+
}
|
|
156
309
|
});
|
|
157
310
|
}
|
|
158
311
|
exports.cancelReservation = cancelReservation;
|
|
@@ -10,49 +10,81 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.confirmReservation = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 予約サービス
|
|
15
|
+
*/
|
|
16
|
+
const factory = require("../../factory");
|
|
13
17
|
const onReservationConfirmed_1 = require("./potentialActions/onReservationConfirmed");
|
|
14
18
|
/**
|
|
15
19
|
* 予約を確定する
|
|
16
20
|
*/
|
|
17
21
|
function confirmReservation(actionAttributesList) {
|
|
22
|
+
// tslint:disable-next-line:max-func-body-length
|
|
18
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// 予約を確定状態に変更する
|
|
25
|
-
reservation = yield repos.reservation.confirm({
|
|
26
|
-
// 更新属性をwhitelist化(2022-06-13~)
|
|
27
|
-
// ...actionAttributes.object,
|
|
28
|
-
id: reservation.id,
|
|
29
|
-
previousReservationStatus: reservation.reservationStatus,
|
|
30
|
-
underName: reservation.underName,
|
|
31
|
-
reservedTicket: reservation.reservedTicket
|
|
32
|
-
});
|
|
33
|
-
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
34
|
-
delete reservation._id;
|
|
35
|
-
confirmedReservations.push(reservation);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
// actionにエラー結果を追加
|
|
24
|
+
let confirmedReservations = [];
|
|
25
|
+
if (actionAttributesList.length > 0) {
|
|
26
|
+
yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const reservation = actionAttributes.object;
|
|
28
|
+
const action = yield repos.action.start(actionAttributes);
|
|
39
29
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
// ReservationPackageに対応(2022-12-22~)
|
|
31
|
+
if (reservation.typeOf === factory.reservationType.ReservationPackage) {
|
|
32
|
+
// 予約を確定状態に変更する
|
|
33
|
+
yield repos.reservation.confirmByReservationNumber({
|
|
34
|
+
reservationNumber: reservation.reservationNumber,
|
|
35
|
+
previousReservationStatus: reservation.reservationStatus,
|
|
36
|
+
underName: reservation.underName
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// 予約を確定状態に変更する
|
|
41
|
+
// reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
|
|
42
|
+
yield repos.reservation.confirm({
|
|
43
|
+
// 更新属性をwhitelist化(2022-06-13~)
|
|
44
|
+
// ...actionAttributes.object,
|
|
45
|
+
id: reservation.id,
|
|
46
|
+
previousReservationStatus: reservation.reservationStatus,
|
|
47
|
+
underName: reservation.underName
|
|
48
|
+
// issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
|
|
49
|
+
// reservedTicket: reservation.reservedTicket
|
|
50
|
+
});
|
|
51
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
52
|
+
// delete (<any>reservation)._id;
|
|
53
|
+
// confirmedReservations.push(reservation);
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
|
-
catch (
|
|
44
|
-
//
|
|
56
|
+
catch (error) {
|
|
57
|
+
// actionにエラー結果を追加
|
|
58
|
+
try {
|
|
59
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
60
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
61
|
+
}
|
|
62
|
+
catch (__) {
|
|
63
|
+
// 失敗したら仕方ない
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
45
66
|
}
|
|
46
|
-
|
|
67
|
+
// アクション完了
|
|
68
|
+
const actionResult = {};
|
|
69
|
+
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
70
|
+
yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
|
|
71
|
+
})));
|
|
72
|
+
// 確定予約通知タスクを予約番号単位で作成する(2022-12-21~)
|
|
73
|
+
const reservationNumber = actionAttributesList[0].object.reservationNumber;
|
|
74
|
+
if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
|
|
75
|
+
// 最新のconfirmedReservationsを検索
|
|
76
|
+
confirmedReservations = yield repos.reservation.search({
|
|
77
|
+
reservationNumber: { $eq: reservationNumber },
|
|
78
|
+
typeOf: factory.reservationType.EventReservation
|
|
79
|
+
});
|
|
80
|
+
confirmedReservations = confirmedReservations.map((r) => {
|
|
81
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
82
|
+
delete r._id;
|
|
83
|
+
return r;
|
|
84
|
+
});
|
|
47
85
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
confirmedReservationId: reservation.id
|
|
51
|
-
};
|
|
52
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
53
|
-
yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes, reservation)({ task: repos.task });
|
|
54
|
-
})));
|
|
55
|
-
yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
|
|
86
|
+
yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
|
|
87
|
+
}
|
|
56
88
|
});
|
|
57
89
|
}
|
|
58
90
|
exports.confirmReservation = confirmReservation;
|
|
@@ -5,10 +5,22 @@ export interface IProject {
|
|
|
5
5
|
id: string;
|
|
6
6
|
typeOf: factory.organizationType.Project;
|
|
7
7
|
}
|
|
8
|
+
export declare type ISubReservation = Omit<IEventReservation, 'broker' | 'project' | 'reservationFor' | 'reservationNumber' | 'reservationStatus' | 'underName'>;
|
|
9
|
+
/**
|
|
10
|
+
* 確定予約通知
|
|
11
|
+
*/
|
|
12
|
+
export interface IReservationPackage4informConfirmed {
|
|
13
|
+
project: IProject;
|
|
14
|
+
reservationFor: factory.reservation.IReservationFor<factory.reservationType.EventReservation>;
|
|
15
|
+
reservationNumber: string;
|
|
16
|
+
reservationStatus: factory.reservationStatusType;
|
|
17
|
+
subReservation: ISubReservation[];
|
|
18
|
+
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
19
|
+
typeOf: factory.reservationType.ReservationPackage;
|
|
20
|
+
}
|
|
8
21
|
/**
|
|
9
22
|
* 確定予約通知
|
|
10
23
|
*/
|
|
11
|
-
export declare type IReservation4informConfirmed = IEventReservation;
|
|
12
24
|
/**
|
|
13
25
|
* 予約取消通知
|
|
14
26
|
*/
|
|
@@ -44,7 +56,7 @@ export interface IReservation4informUsed {
|
|
|
44
56
|
dateUsed?: Date;
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
|
-
export declare type IReservation4inform =
|
|
59
|
+
export declare type IReservation4inform = IReservationPackage4informConfirmed | IReservation4informCanceled | IReservation4informCheckedIn | IReservation4informUsed;
|
|
48
60
|
export declare type IInformObject = IReservation4inform[];
|
|
49
61
|
export declare type InformReservationActionattributes = factory.action.interact.inform.IAttributes<IInformObject, any>;
|
|
50
62
|
export declare const NUM_TRY_INFORM_RESERVATION: number;
|
|
@@ -3,13 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NUM_TRY_INFORM_RESERVATION = exports.maskUnderName = void 0;
|
|
4
4
|
const MASKED_PROFILE = '****';
|
|
5
5
|
function maskUnderName(reservation) {
|
|
6
|
-
|
|
6
|
+
// 予約後を隠蔽(2022-12-24~)
|
|
7
|
+
// const underNameIdentifiers: factory.propertyValue.IPropertyValue<string>[] | undefined =
|
|
8
|
+
// (Array.isArray(reservation.underName?.identifier))
|
|
9
|
+
// ? reservation.underName?.identifier.filter((p) => {
|
|
10
|
+
// return !RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
|
|
11
|
+
// })
|
|
12
|
+
// : undefined;
|
|
13
|
+
var _a;
|
|
7
14
|
const underName = (typeof ((_a = reservation.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
8
|
-
? Object.assign(Object.assign({}, reservation.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return Object.assign(Object.assign(
|
|
15
|
+
? Object.assign(Object.assign({}, reservation.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE,
|
|
16
|
+
// ... (Array.isArray(underNameIdentifiers)) ? { identifier: underNameIdentifiers } : undefined,
|
|
17
|
+
// identifierも隠蔽(2022-12-27~)
|
|
18
|
+
identifier: [] }) : undefined;
|
|
19
|
+
return Object.assign(Object.assign({}, reservation), (underName !== undefined) ? { underName } : undefined);
|
|
13
20
|
}
|
|
14
21
|
exports.maskUnderName = maskUnderName;
|
|
15
22
|
exports.NUM_TRY_INFORM_RESERVATION = 10;
|
|
@@ -7,7 +7,7 @@ declare type IEventReservation = factory.reservation.IReservation<factory.reserv
|
|
|
7
7
|
/**
|
|
8
8
|
* 予約確定後のアクション
|
|
9
9
|
*/
|
|
10
|
-
export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes
|
|
10
|
+
export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes): (repos: {
|
|
11
11
|
task: TaskRepo;
|
|
12
12
|
}) => Promise<void>;
|
|
13
13
|
export declare function onReservationConfirmed(confirmedReservations: IEventReservation[]): (repos: {
|