@chevre/domain 20.1.0-alpha.4 → 20.1.0-alpha.40
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/deleteEvents.ts +9 -1
- 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/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/place.d.ts +1 -0
- package/lib/chevre/repo/place.js +54 -7
- package/lib/chevre/repo/reservation.d.ts +13 -0
- package/lib/chevre/repo/reservation.js +28 -0
- 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/pay/potentialActions.js +9 -19
- package/lib/chevre/service/assetTransaction/reserve/factory.js +119 -115
- package/lib/chevre/service/assetTransaction/reserve.js +99 -89
- 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/offer.js +6 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +4 -2
- 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.js +135 -87
- package/lib/chevre/service/reserve/confirmReservation.js +65 -33
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +67 -30
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -8
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +6 -3
- 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 +4 -3
- 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 +4 -5
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +4 -6
- 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/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/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,121 @@ 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
|
-
if (reserveTransaction !== undefined) {
|
|
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
|
+
var _a;
|
|
32
|
+
// let canceledReservation: factory.reservation.eventReservation.IReservation | undefined;
|
|
33
|
+
const reserveTransactionId = actionAttributes.purpose.id;
|
|
34
|
+
// アクション開始
|
|
35
|
+
const action = yield repos.action.start(actionAttributes);
|
|
36
|
+
try {
|
|
37
|
+
// 予約取引を検索
|
|
38
|
+
const reserveTransactions = yield repos.assetTransaction.search({
|
|
39
|
+
limit: 1,
|
|
40
|
+
page: 1,
|
|
41
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
42
|
+
ids: [reserveTransactionId]
|
|
44
43
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
const reserveTransaction = reserveTransactions.shift();
|
|
45
|
+
const actionObject = actionAttributes.object;
|
|
46
|
+
if (reserveTransaction !== undefined) {
|
|
47
|
+
// ReservationPackageに対応(2022-12-23~)
|
|
48
|
+
if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
|
|
49
|
+
const reservationFor = reserveTransaction.object.reservationFor;
|
|
50
|
+
if (reservationFor === undefined) {
|
|
51
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
52
|
+
}
|
|
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 = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
|
|
57
|
+
yield processUnlockSeat({
|
|
58
|
+
reservation: cancelingReservation,
|
|
59
|
+
expectedHolder: reserveTransactionId
|
|
60
|
+
})(repos);
|
|
61
|
+
yield processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
|
|
62
|
+
})));
|
|
63
|
+
}
|
|
64
|
+
// 予約番号単位でキャンセル状態に変更する
|
|
65
|
+
yield repos.reservation.cancelByReservationNumber({
|
|
66
|
+
reservationNumber: actionObject.reservationNumber,
|
|
67
|
+
previousReservationStatus: actionObject.reservationStatus,
|
|
66
68
|
now
|
|
67
69
|
});
|
|
68
|
-
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const cancelingSubReservation = (_a = reserveTransaction.object.subReservation) === null || _a === void 0 ? void 0 : _a.find((r) => {
|
|
73
|
+
return r.id === actionObject.id;
|
|
74
|
+
});
|
|
75
|
+
// 取消対象予約が取引に存在すれば、適宜unlock
|
|
76
|
+
if (cancelingSubReservation !== undefined) {
|
|
77
|
+
const reservationFor = reserveTransaction.object.reservationFor;
|
|
78
|
+
if (reservationFor === undefined) {
|
|
79
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
80
|
+
}
|
|
81
|
+
const cancelingReservation = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
|
|
82
|
+
yield processUnlockSeat({
|
|
83
|
+
reservation: cancelingReservation,
|
|
84
|
+
expectedHolder: reserveTransactionId
|
|
85
|
+
})(repos);
|
|
86
|
+
yield processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
|
|
87
|
+
// 予約が存在すればキャンセル状態に変更する
|
|
88
|
+
const reservationCount = yield repos.reservation.count({
|
|
89
|
+
typeOf: cancelingSubReservation.typeOf,
|
|
90
|
+
ids: [cancelingSubReservation.id]
|
|
91
|
+
});
|
|
92
|
+
if (reservationCount > 0) {
|
|
93
|
+
yield repos.reservation.cancel({
|
|
94
|
+
id: cancelingSubReservation.id,
|
|
95
|
+
previousReservationStatus: actionObject.reservationStatus,
|
|
96
|
+
now
|
|
97
|
+
});
|
|
98
|
+
// canceledReservations.push(canceledReservation);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
69
101
|
}
|
|
70
102
|
}
|
|
71
103
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
catch (error) {
|
|
105
|
+
// actionにエラー結果を追加
|
|
106
|
+
try {
|
|
107
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
108
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
109
|
+
}
|
|
110
|
+
catch (__) {
|
|
111
|
+
// 失敗したら仕方ない
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
81
114
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
89
|
-
if (canceledReservation !== undefined) {
|
|
115
|
+
// アクション完了
|
|
116
|
+
const actionResult = {
|
|
117
|
+
// canceledReservationId: canceledReservation?.id
|
|
118
|
+
};
|
|
119
|
+
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
90
120
|
yield (0, onReservationCanceled_1.onReservationCanceledByAction)(actionAttributes)({ task: repos.task });
|
|
121
|
+
})));
|
|
122
|
+
const reservationNumber = actionAttributesList[0].object.reservationNumber;
|
|
123
|
+
if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
|
|
124
|
+
// 最新のconfirmedReservationsを検索
|
|
125
|
+
canceledReservations = yield repos.reservation.search({
|
|
126
|
+
reservationNumber: { $eq: reservationNumber },
|
|
127
|
+
typeOf: factory.reservationType.EventReservation
|
|
128
|
+
});
|
|
129
|
+
canceledReservations = canceledReservations.map((r) => {
|
|
130
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
131
|
+
delete r._id;
|
|
132
|
+
return r;
|
|
133
|
+
});
|
|
91
134
|
}
|
|
92
|
-
|
|
93
|
-
|
|
135
|
+
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false)({ task: repos.task });
|
|
136
|
+
}
|
|
94
137
|
});
|
|
95
138
|
}
|
|
96
139
|
exports.cancelPendingReservation = cancelPendingReservation;
|
|
@@ -105,35 +148,40 @@ function cancelReservation(actionAttributesList) {
|
|
|
105
148
|
let canceledReservation;
|
|
106
149
|
const action = yield repos.action.start(actionAttributes);
|
|
107
150
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
// 予約取引を検索
|
|
112
|
-
const reserveTransactions = yield repos.assetTransaction.search({
|
|
113
|
-
limit: 1,
|
|
114
|
-
page: 1,
|
|
115
|
-
typeOf: factory.assetTransactionType.Reserve,
|
|
116
|
-
object: { reservations: { id: { $in: [reservation.id] } } }
|
|
117
|
-
});
|
|
118
|
-
const reserveTransaction = reserveTransactions.shift();
|
|
119
|
-
let exectedHolder;
|
|
120
|
-
if (reserveTransaction !== undefined) {
|
|
121
|
-
exectedHolder = reserveTransaction.id;
|
|
151
|
+
if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
|
|
152
|
+
throw new factory.errors.NotImplemented('ReservationPackage not implemented');
|
|
122
153
|
}
|
|
123
|
-
|
|
124
|
-
yield
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
154
|
+
else {
|
|
155
|
+
const reservation = yield repos.reservation.findById({
|
|
156
|
+
id: actionAttributes.object.id
|
|
157
|
+
});
|
|
158
|
+
// 予約取引を検索
|
|
159
|
+
const reserveTransactions = yield repos.assetTransaction.search({
|
|
160
|
+
limit: 1,
|
|
161
|
+
page: 1,
|
|
162
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
163
|
+
object: { reservations: { id: { $in: [reservation.id] } } }
|
|
164
|
+
});
|
|
165
|
+
const reserveTransaction = reserveTransactions.shift();
|
|
166
|
+
let exectedHolder;
|
|
167
|
+
if (reserveTransaction !== undefined) {
|
|
168
|
+
exectedHolder = reserveTransaction.id;
|
|
169
|
+
}
|
|
170
|
+
if (typeof exectedHolder === 'string') {
|
|
171
|
+
yield processUnlockSeat({
|
|
172
|
+
reservation: reservation,
|
|
173
|
+
expectedHolder: exectedHolder
|
|
174
|
+
})(repos);
|
|
175
|
+
}
|
|
176
|
+
yield processUnlockOfferRateLimit({ reservation, reservationFor: reservation.reservationFor })(repos);
|
|
177
|
+
// 予約をキャンセル状態に変更する
|
|
178
|
+
canceledReservation = yield repos.reservation.cancel({
|
|
179
|
+
id: reservation.id,
|
|
180
|
+
previousReservationStatus: actionAttributes.object.reservationStatus,
|
|
181
|
+
now
|
|
182
|
+
});
|
|
183
|
+
canceledReservations.push(canceledReservation);
|
|
128
184
|
}
|
|
129
|
-
yield processUnlockOfferRateLimit({ reservation, reservationFor: reservation.reservationFor })(repos);
|
|
130
|
-
// 予約をキャンセル状態に変更する
|
|
131
|
-
canceledReservation = yield repos.reservation.cancel({
|
|
132
|
-
id: reservation.id,
|
|
133
|
-
previousReservationStatus: actionAttributes.object.reservationStatus,
|
|
134
|
-
now
|
|
135
|
-
});
|
|
136
|
-
canceledReservations.push(canceledReservation);
|
|
137
185
|
}
|
|
138
186
|
catch (error) {
|
|
139
187
|
// actionにエラー結果を追加
|
|
@@ -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;
|
|
@@ -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: {
|
|
@@ -21,7 +21,9 @@ const informReservations = settings_1.settings.onReservationStatusChanged.inform
|
|
|
21
21
|
/**
|
|
22
22
|
* 予約確定後のアクション
|
|
23
23
|
*/
|
|
24
|
-
function onReservationConfirmedByAction(actionAttributes
|
|
24
|
+
function onReservationConfirmedByAction(actionAttributes
|
|
25
|
+
// confirmedReservation: IEventReservation
|
|
26
|
+
) {
|
|
25
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
const potentialActions = actionAttributes.potentialActions;
|
|
27
29
|
const now = new Date();
|
|
@@ -45,35 +47,34 @@ function onReservationConfirmedByAction(actionAttributes, confirmedReservation)
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
// inform galobally
|
|
48
|
-
if (Array.isArray(informReservations)) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
50
|
+
// if (Array.isArray(informReservations)) {
|
|
51
|
+
// const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
|
|
52
|
+
// taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
|
|
53
|
+
// const informUrl: string = String(informReservation.recipient?.url);
|
|
54
|
+
// const informReservationAttributes: InformReservationActionattributes = {
|
|
55
|
+
// agent: confirmedReservation.project,
|
|
56
|
+
// object: [reservation4inform],
|
|
57
|
+
// project: confirmedReservation.project,
|
|
58
|
+
// recipient: {
|
|
59
|
+
// id: '',
|
|
60
|
+
// name: informUrl,
|
|
61
|
+
// typeOf: factory.creativeWorkType.WebApplication,
|
|
62
|
+
// url: informUrl
|
|
63
|
+
// },
|
|
64
|
+
// typeOf: factory.actionType.InformAction
|
|
65
|
+
// };
|
|
66
|
+
// return {
|
|
67
|
+
// project: actionAttributes.project,
|
|
68
|
+
// name: factory.taskName.TriggerWebhook,
|
|
69
|
+
// status: factory.taskStatus.Ready,
|
|
70
|
+
// runsAt: now,
|
|
71
|
+
// remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
|
|
72
|
+
// numberOfTried: 0,
|
|
73
|
+
// executionResults: [],
|
|
74
|
+
// data: informReservationAttributes
|
|
75
|
+
// };
|
|
76
|
+
// }));
|
|
77
|
+
// }
|
|
77
78
|
// タスク保管
|
|
78
79
|
if (taskAttributes.length > 0) {
|
|
79
80
|
yield repos.task.saveMany(taskAttributes);
|
|
@@ -88,6 +89,42 @@ function onReservationConfirmed(confirmedReservations) {
|
|
|
88
89
|
project: confirmedReservations[0].project,
|
|
89
90
|
reservationFor: { id: confirmedReservations[0].reservationFor.id }
|
|
90
91
|
})({ task: repos.task });
|
|
92
|
+
const now = new Date();
|
|
93
|
+
const taskAttributes = [];
|
|
94
|
+
// inform galobally
|
|
95
|
+
if (Array.isArray(informReservations)) {
|
|
96
|
+
taskAttributes.push(...informReservations.map((informReservation) => {
|
|
97
|
+
var _a;
|
|
98
|
+
const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
99
|
+
const informObject = confirmedReservations.map(factory_1.maskUnderName);
|
|
100
|
+
const informReservationAttributes = {
|
|
101
|
+
agent: confirmedReservations[0].project,
|
|
102
|
+
object: informObject,
|
|
103
|
+
project: confirmedReservations[0].project,
|
|
104
|
+
recipient: {
|
|
105
|
+
id: '',
|
|
106
|
+
name: informUrl,
|
|
107
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
108
|
+
url: informUrl
|
|
109
|
+
},
|
|
110
|
+
typeOf: factory.actionType.InformAction
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
project: confirmedReservations[0].project,
|
|
114
|
+
name: factory.taskName.TriggerWebhook,
|
|
115
|
+
status: factory.taskStatus.Ready,
|
|
116
|
+
runsAt: now,
|
|
117
|
+
remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
|
|
118
|
+
numberOfTried: 0,
|
|
119
|
+
executionResults: [],
|
|
120
|
+
data: informReservationAttributes
|
|
121
|
+
};
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
// タスク保管
|
|
125
|
+
if (taskAttributes.length > 0) {
|
|
126
|
+
yield repos.task.saveMany(taskAttributes);
|
|
127
|
+
}
|
|
91
128
|
}
|
|
92
129
|
});
|
|
93
130
|
}
|
|
@@ -72,7 +72,7 @@ function confirmReserveTransaction(params) {
|
|
|
72
72
|
object = object;
|
|
73
73
|
yield ReserveTransactionService.confirm({
|
|
74
74
|
transactionNumber: object.transactionNumber,
|
|
75
|
-
object: object.object,
|
|
75
|
+
// object: object.object,
|
|
76
76
|
potentialActions: object.potentialActions
|
|
77
77
|
})(repos);
|
|
78
78
|
}
|
|
@@ -15,7 +15,6 @@ exports.orderProgramMembership = exports.ISS_PREFIX = void 0;
|
|
|
15
15
|
*/
|
|
16
16
|
const GMO = require("@motionpicture/gmo-service");
|
|
17
17
|
const createDebug = require("debug");
|
|
18
|
-
const moment = require("moment-timezone");
|
|
19
18
|
const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
|
|
20
19
|
const OfferService = require("../offer");
|
|
21
20
|
const AnyPaymentService = require("../payment/any");
|
|
@@ -120,16 +119,15 @@ function createStartPlaceOrderInProgressParams(params) {
|
|
|
120
119
|
id: customer.id,
|
|
121
120
|
identifier: customer.identifier,
|
|
122
121
|
memberOf: customer.memberOf
|
|
123
|
-
// ↓不要なので廃止(2022-05-26~)
|
|
124
|
-
// paramsにadditionalPropertyの指定があれば反映する
|
|
125
|
-
// ...(Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : []
|
|
126
122
|
};
|
|
127
123
|
return {
|
|
128
124
|
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
// expiresInSeconds指定に変更(2022-11-29~)
|
|
126
|
+
// expires: moment()
|
|
127
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
128
|
+
// .add(5, 'minutes')
|
|
129
|
+
// .toDate(),
|
|
130
|
+
expiresInSeconds: 300,
|
|
133
131
|
agent,
|
|
134
132
|
seller: { id: params.seller.id },
|
|
135
133
|
object: {
|
|
@@ -9,6 +9,7 @@ const settings_1 = require("../../../../settings");
|
|
|
9
9
|
*/
|
|
10
10
|
// tslint:disable-next-line:max-func-body-length
|
|
11
11
|
function createTasks(params) {
|
|
12
|
+
var _a;
|
|
12
13
|
const taskAttributes = [];
|
|
13
14
|
const transaction = params.transaction;
|
|
14
15
|
const taskRunsAt = params.runsAt;
|
|
@@ -24,7 +25,6 @@ function createTasks(params) {
|
|
|
24
25
|
executionResults: [],
|
|
25
26
|
data: {
|
|
26
27
|
agent: transaction.project,
|
|
27
|
-
// agent: transaction.seller,
|
|
28
28
|
object: transaction,
|
|
29
29
|
project: transaction.project,
|
|
30
30
|
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
@@ -72,6 +72,10 @@ function createTasks(params) {
|
|
|
72
72
|
if (potentialActions === undefined) {
|
|
73
73
|
throw new factory.errors.NotFound('Transaction PotentialActions');
|
|
74
74
|
}
|
|
75
|
+
const orderFromTransaction = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
|
|
76
|
+
if (orderFromTransaction === undefined) {
|
|
77
|
+
throw new factory.errors.NotFound('Transaction Result');
|
|
78
|
+
}
|
|
75
79
|
const orderActionAttributes = potentialActions.order;
|
|
76
80
|
const placeOrderTaskAttributes = {
|
|
77
81
|
project: transaction.project,
|
|
@@ -81,9 +85,8 @@ function createTasks(params) {
|
|
|
81
85
|
remainingNumberOfTries: 10,
|
|
82
86
|
numberOfTried: 0,
|
|
83
87
|
executionResults: [],
|
|
84
|
-
// data: orderActionAttributes
|
|
85
88
|
data: Object.assign({ project: orderActionAttributes.project, object: {
|
|
86
|
-
confirmationNumber:
|
|
89
|
+
confirmationNumber: orderFromTransaction.confirmationNumber,
|
|
87
90
|
orderNumber: orderActionAttributes.object.orderNumber
|
|
88
91
|
} }, (orderActionAttributes.potentialActions !== undefined)
|
|
89
92
|
? { potentialActions: orderActionAttributes.potentialActions }
|
|
@@ -10,7 +10,9 @@ function createStartParams(params, passport, seller, broker) {
|
|
|
10
10
|
if (typeof seller.id !== 'string') {
|
|
11
11
|
throw new factory.errors.NotFound('seller.id');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
if (typeof params.expiresInSeconds !== 'number') {
|
|
14
|
+
throw new factory.errors.ArgumentNull('expiresInSeconds');
|
|
15
|
+
}
|
|
14
16
|
return {
|
|
15
17
|
project: { typeOf: seller.project.typeOf, id: seller.project.id },
|
|
16
18
|
typeOf: factory.transactionType.PlaceOrder,
|
|
@@ -19,11 +21,14 @@ function createStartParams(params, passport, seller, broker) {
|
|
|
19
21
|
id: seller.id,
|
|
20
22
|
name: seller.name,
|
|
21
23
|
typeOf: seller.typeOf
|
|
22
|
-
// ↓最適化(2022-05-24~)
|
|
23
|
-
// ...{ project: seller.project }
|
|
24
24
|
},
|
|
25
25
|
object: transactionObject,
|
|
26
|
-
expires: params.expires
|
|
26
|
+
// expires: params.expires,
|
|
27
|
+
expiresInSeconds: params.expiresInSeconds
|
|
28
|
+
// 販売者にexpires設定があれば適用
|
|
29
|
+
// ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
|
|
30
|
+
// ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
|
|
31
|
+
// : undefined
|
|
27
32
|
};
|
|
28
33
|
}
|
|
29
34
|
exports.createStartParams = createStartParams;
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js
CHANGED
|
@@ -48,7 +48,8 @@ function createGivePointAwardActions(params) {
|
|
|
48
48
|
seller: params.order.seller,
|
|
49
49
|
// mask
|
|
50
50
|
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
51
|
-
|
|
51
|
+
// IOrderへ移行(2022-11-17~)
|
|
52
|
+
// confirmationNumber: params.order.confirmationNumber,
|
|
52
53
|
orderNumber: params.order.orderNumber,
|
|
53
54
|
price: params.order.price,
|
|
54
55
|
priceCurrency: params.order.priceCurrency,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js
CHANGED
|
@@ -66,7 +66,8 @@ function createMoneyTransferActions(params) {
|
|
|
66
66
|
seller: params.order.seller,
|
|
67
67
|
// mask
|
|
68
68
|
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
69
|
-
|
|
69
|
+
// IOrderへ移行(2022-11-17~)
|
|
70
|
+
// confirmationNumber: params.order.confirmationNumber,
|
|
70
71
|
orderNumber: params.order.orderNumber,
|
|
71
72
|
price: params.order.price,
|
|
72
73
|
priceCurrency: params.order.priceCurrency,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js
CHANGED
|
@@ -51,7 +51,8 @@ function createRegisterServiceActions(params) {
|
|
|
51
51
|
seller: params.order.seller,
|
|
52
52
|
// mask
|
|
53
53
|
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
54
|
-
|
|
54
|
+
// IOrderへ移行(2022-11-17~)
|
|
55
|
+
// confirmationNumber: params.order.confirmationNumber,
|
|
55
56
|
orderNumber: params.order.orderNumber,
|
|
56
57
|
price: params.order.price,
|
|
57
58
|
priceCurrency: params.order.priceCurrency,
|