@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.60
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/countOffers.ts +32 -0
- package/example/src/chevre/findItemListElementByCatalogId.ts +23 -0
- package/example/src/chevre/importOffersFromCOA.ts +7 -1
- package/example/src/chevre/migrateAggregateOffers.ts +89 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
- package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
- package/example/src/chevre/searchAggregateOffers.ts +48 -0
- package/example/src/chevre/searchEventTicketOffers.ts +3 -1
- package/example/src/chevre/searchEvents.ts +9 -7
- package/example/src/chevre/searchOffersByCatalog.ts +9 -5
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
- package/example/src/chevre/searchOrders.ts +9 -7
- package/example/src/chevre/sync2aggregateOffer.ts +27 -0
- package/example/src/chevre/syncAggregateOffer.ts +25 -0
- package/lib/chevre/emailMessageBuilder.js +6 -5
- package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
- package/lib/chevre/repo/aggregateOffer.js +534 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +177 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +24 -33
- package/lib/chevre/repo/mongoose/schemas/offer.js +4 -3
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
- package/lib/chevre/repo/offer.d.ts +82 -47
- package/lib/chevre/repo/offer.js +1279 -289
- package/lib/chevre/repo/offerCatalog.d.ts +6 -0
- package/lib/chevre/repo/offerCatalog.js +13 -0
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +58 -26
- package/lib/chevre/repo/task.d.ts +7 -1
- package/lib/chevre/repo/task.js +100 -0
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
- package/lib/chevre/service/assetTransaction/registerService.js +2 -1
- package/lib/chevre/service/assetTransaction/reserve.js +111 -35
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/authorize.js +39 -35
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +8 -8
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -3
- package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
- package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
- package/lib/chevre/service/offer/factory.d.ts +12 -4
- package/lib/chevre/service/offer/factory.js +9 -11
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +8 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +10 -3
- package/lib/chevre/service/offer/product.d.ts +1 -0
- package/lib/chevre/service/offer/product.js +3 -2
- package/lib/chevre/service/offer.d.ts +1 -0
- package/lib/chevre/service/offer.js +7 -1
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
- package/lib/chevre/service/order/onOrderStatusChanged.js +81 -54
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +11 -13
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +33 -8
- package/lib/chevre/service/payment/any.js +30 -21
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
- package/lib/chevre/service/reserve/checkInReservation.js +3 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
- package/lib/chevre/service/task/onResourceUpdated.js +12 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
- package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +5 -3
- package/lib/chevre/settings.js +6 -6
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -122,11 +122,9 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
122
122
|
const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
|
|
123
123
|
accountsReceivablesByServiceType = validateMovieTicketResult.accountsReceivablesByServiceType;
|
|
124
124
|
const paymentMethod = transaction.object.paymentMethod;
|
|
125
|
-
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
125
|
+
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
|
|
126
126
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
127
|
-
const paymentMethodId =
|
|
128
|
-
? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
|
|
129
|
-
: transaction.id;
|
|
127
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
130
128
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
131
129
|
accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
|
|
132
130
|
if (typeof accountId !== 'string' || accountId.length === 0) {
|
|
@@ -157,15 +155,16 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
157
155
|
exports.authorize = authorize;
|
|
158
156
|
function voidTransaction(params) {
|
|
159
157
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var _a, _b, _c
|
|
158
|
+
var _a, _b, _c;
|
|
161
159
|
const transaction = params.object;
|
|
162
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
160
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
163
161
|
if (typeof paymentMethodType !== 'string') {
|
|
164
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
162
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
165
163
|
}
|
|
166
|
-
const paymentMethodId =
|
|
164
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
165
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
167
166
|
if (typeof paymentMethodId !== 'string') {
|
|
168
|
-
throw new factory.errors.ArgumentNull('object.
|
|
167
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
169
168
|
}
|
|
170
169
|
// 決済開始時に着券していれば、取消
|
|
171
170
|
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
@@ -192,14 +191,14 @@ function voidTransaction(params) {
|
|
|
192
191
|
paymentMethod: {
|
|
193
192
|
paymentMethodId: paymentMethodId,
|
|
194
193
|
typeOf: paymentMethodType,
|
|
195
|
-
name: (typeof ((
|
|
194
|
+
name: (typeof ((_b = transaction.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.name) === 'string')
|
|
196
195
|
? transaction.object.paymentMethod.name
|
|
197
196
|
: paymentMethodType,
|
|
198
197
|
additionalProperty: []
|
|
199
198
|
}
|
|
200
199
|
}], agent: {
|
|
201
200
|
id: seller.id,
|
|
202
|
-
name: (typeof seller.name === 'string') ? seller.name : String((
|
|
201
|
+
name: (typeof seller.name === 'string') ? seller.name : String((_c = seller.name) === null || _c === void 0 ? void 0 : _c.ja),
|
|
203
202
|
typeOf: seller.typeOf
|
|
204
203
|
}, recipient: transaction.recipient }, ((payAction === null || payAction === void 0 ? void 0 : payAction.purpose) !== undefined)
|
|
205
204
|
? { purpose: payAction.purpose }
|
|
@@ -68,7 +68,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
68
68
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
69
69
|
const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
|
|
70
70
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
71
|
-
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.
|
|
71
|
+
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
72
72
|
if (typeof serviceOutputIdentifier !== 'string') {
|
|
73
73
|
throw new factory.errors.ArgumentNull('object.paymentMethod.accountId');
|
|
74
74
|
}
|
|
@@ -76,7 +76,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
76
76
|
throw new factory.errors.ArgumentNull('object.paymentMethod.amount');
|
|
77
77
|
}
|
|
78
78
|
if (typeof paymentMethodType !== 'string') {
|
|
79
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
79
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
80
80
|
}
|
|
81
81
|
// プロダクトから通貨区分を取得
|
|
82
82
|
const paymentCatdProduct = yield repos.product.findById({ id: paymentServiceId }, ['serviceOutput'], []);
|
|
@@ -182,15 +182,12 @@ function processAccountTransaction(params) {
|
|
|
182
182
|
}
|
|
183
183
|
function voidTransaction(params) {
|
|
184
184
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
var _a, _b, _c
|
|
185
|
+
var _a, _b, _c;
|
|
186
186
|
const transaction = params.object;
|
|
187
|
-
const
|
|
188
|
-
const paymentMethodId =
|
|
189
|
-
if (typeof paymentMethodType !== 'string') {
|
|
190
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
191
|
-
}
|
|
187
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
188
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
192
189
|
if (typeof paymentMethodId !== 'string') {
|
|
193
|
-
throw new factory.errors.ArgumentNull('object.
|
|
190
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
194
191
|
}
|
|
195
192
|
const paymentServiceId = String(transaction.object.id);
|
|
196
193
|
// アクションステータスに関係なく取消処理実行
|
|
@@ -204,9 +201,9 @@ function voidTransaction(params) {
|
|
|
204
201
|
const accountTransactionService = new pecorinoapi.service.AccountTransaction({
|
|
205
202
|
endpoint: String(availableChannel.serviceUrl),
|
|
206
203
|
auth: new pecorinoapi.auth.ClientCredentials({
|
|
207
|
-
domain: String((
|
|
208
|
-
clientId: String((
|
|
209
|
-
clientSecret: String((
|
|
204
|
+
domain: String((_a = availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.authorizeServerDomain),
|
|
205
|
+
clientId: String((_b = availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.clientId),
|
|
206
|
+
clientSecret: String((_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.clientSecret),
|
|
210
207
|
scopes: [],
|
|
211
208
|
state: ''
|
|
212
209
|
})
|
|
@@ -27,7 +27,7 @@ function cleanUpDatabaseByProject(params) {
|
|
|
27
27
|
yield repos.categoryCode.deleteByProject({ project: { id: params.id } });
|
|
28
28
|
yield repos.creativeWork.deleteByProject({ project: { id: params.id } });
|
|
29
29
|
yield repos.event.deleteByProject({ project: { id: params.id } });
|
|
30
|
-
|
|
30
|
+
// await repos.offer.deleteByProject({ project: { id: params.id } });
|
|
31
31
|
yield repos.offerCatalog.deleteByProject({ project: { id: params.id } });
|
|
32
32
|
yield repos.place.deleteByProject({ project: { id: params.id } });
|
|
33
33
|
yield repos.priceSpecification.deleteByProject({ project: { id: params.id } });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
2
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
3
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
3
4
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
4
5
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
6
|
interface ICheckInReservationParams {
|
|
@@ -22,12 +23,19 @@ interface ICheckInReservationParams {
|
|
|
22
23
|
ids?: string[];
|
|
23
24
|
};
|
|
24
25
|
};
|
|
26
|
+
purpose: {
|
|
27
|
+
/**
|
|
28
|
+
* 承認コード
|
|
29
|
+
*/
|
|
30
|
+
code: string;
|
|
31
|
+
};
|
|
25
32
|
}
|
|
26
33
|
export declare function checkInReservation(params: ICheckInReservationParams & {
|
|
27
34
|
reserveIfNotYet: boolean;
|
|
28
35
|
}): (repos: {
|
|
29
36
|
action: ActionRepo;
|
|
30
37
|
assetTransaction: AssetTransactionRepo;
|
|
38
|
+
event: EventRepo;
|
|
31
39
|
reservation: ReservationRepo;
|
|
32
40
|
task: TaskRepo;
|
|
33
41
|
}) => Promise<void>;
|
|
@@ -58,8 +58,9 @@ function checkInReservation(params) {
|
|
|
58
58
|
ids: checkedInReservationIds,
|
|
59
59
|
reservationFor: params.object.reservationFor
|
|
60
60
|
},
|
|
61
|
-
now
|
|
62
|
-
|
|
61
|
+
now,
|
|
62
|
+
purpose: params.purpose
|
|
63
|
+
})({ event: repos.event, task: repos.task });
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
exports.checkInReservation = checkInReservation;
|
|
@@ -13,7 +13,6 @@ exports.onReservationCanceled = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -33,6 +32,7 @@ useInformReservation,
|
|
|
33
32
|
*/
|
|
34
33
|
reservationFor) {
|
|
35
34
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
36
|
if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
|
|
37
37
|
const now = new Date();
|
|
38
38
|
const project = canceledReservations[0].project;
|
|
@@ -41,9 +41,7 @@ reservationFor) {
|
|
|
41
41
|
if (useInformReservation) {
|
|
42
42
|
if (Array.isArray(informReservations)) {
|
|
43
43
|
// やや遅延させる(確定通知が未達の可能性を考慮して)
|
|
44
|
-
const informTaskRunsAt =
|
|
45
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
46
|
-
.toDate();
|
|
44
|
+
const informTaskRunsAt = now;
|
|
47
45
|
const reservations4inform = canceledReservations.map((r) => {
|
|
48
46
|
return {
|
|
49
47
|
typeOf: r.typeOf,
|
|
@@ -99,7 +97,8 @@ reservationFor) {
|
|
|
99
97
|
yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
|
|
100
98
|
project: { id: reservationFor.project.id },
|
|
101
99
|
reservationFor: [{ id: reservationFor.id }],
|
|
102
|
-
force: false
|
|
100
|
+
force: false,
|
|
101
|
+
identifier: `onReservationCanceled:${(_a = canceledReservations === null || canceledReservations === void 0 ? void 0 : canceledReservations[0]) === null || _a === void 0 ? void 0 : _a.reservationNumber}`
|
|
103
102
|
})({ task: repos.task });
|
|
104
103
|
}
|
|
105
104
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
1
2
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
3
|
export declare function onReservationCheckedIn(params: {
|
|
3
4
|
project: {
|
|
@@ -20,6 +21,13 @@ export declare function onReservationCheckedIn(params: {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
now: Date;
|
|
24
|
+
purpose: {
|
|
25
|
+
/**
|
|
26
|
+
* 承認コード
|
|
27
|
+
*/
|
|
28
|
+
code: string;
|
|
29
|
+
};
|
|
23
30
|
}): (repos: {
|
|
31
|
+
event: EventRepo;
|
|
24
32
|
task: TaskRepo;
|
|
25
33
|
}) => Promise<void>;
|
|
@@ -13,7 +13,6 @@ exports.onReservationCheckedIn = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約発券時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -28,10 +27,7 @@ function onReservationCheckedIn(params) {
|
|
|
28
27
|
const project = { id: params.project.id, typeOf: factory.organizationType.Project };
|
|
29
28
|
// inform galobally
|
|
30
29
|
if (Array.isArray(informReservations)) {
|
|
31
|
-
|
|
32
|
-
const informTaskRunsAt = moment(params.now)
|
|
33
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
34
|
-
.toDate();
|
|
30
|
+
const informTaskRunsAt = params.now;
|
|
35
31
|
informReservations.forEach((informReservation) => {
|
|
36
32
|
var _a;
|
|
37
33
|
const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
@@ -111,13 +107,22 @@ function onReservationCheckedIn(params) {
|
|
|
111
107
|
// 冗長な作成を避ける
|
|
112
108
|
const reservationForIds = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.ids;
|
|
113
109
|
if (Array.isArray(reservationForIds)) {
|
|
114
|
-
//
|
|
110
|
+
// 集計タスクを追加
|
|
115
111
|
yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
var _b;
|
|
113
|
+
// すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
|
|
114
|
+
const existingEvents = yield repos.event.search({
|
|
115
|
+
id: { $eq: reservationForId },
|
|
116
|
+
typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
|
|
117
|
+
}, { _id: 1 });
|
|
118
|
+
if (existingEvents.length > 0) {
|
|
119
|
+
yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
|
|
120
|
+
project: { id: params.project.id },
|
|
121
|
+
reservationFor: [{ id: reservationForId }],
|
|
122
|
+
force: false,
|
|
123
|
+
identifier: `onReservationCheckedIn:${(_b = params.purpose) === null || _b === void 0 ? void 0 : _b.code}`
|
|
124
|
+
})({ task: repos.task });
|
|
125
|
+
}
|
|
121
126
|
})));
|
|
122
127
|
}
|
|
123
128
|
});
|
|
@@ -70,7 +70,8 @@ function onReservationConfirmed(confirmedReservations) {
|
|
|
70
70
|
yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
|
|
71
71
|
project: confirmedReservations[0].project,
|
|
72
72
|
reservationFor: [{ id: confirmedReservations[0].reservationFor.id }],
|
|
73
|
-
force: false
|
|
73
|
+
force: false,
|
|
74
|
+
identifier: `onReservationConfirmed:${confirmedReservations[0].reservationNumber}`
|
|
74
75
|
})({ task: repos.task });
|
|
75
76
|
const now = new Date();
|
|
76
77
|
const taskAttributes = [];
|
|
@@ -13,7 +13,6 @@ exports.onReservationUsed = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約使用時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -30,9 +29,7 @@ function onReservationUsed(action, attendedReservation) {
|
|
|
30
29
|
// inform galobally
|
|
31
30
|
if (Array.isArray(informReservations)) {
|
|
32
31
|
// やや遅延させる(確定通知が未達の可能性を考慮して)
|
|
33
|
-
const informTaskRunsAt =
|
|
34
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
35
|
-
.toDate();
|
|
32
|
+
const informTaskRunsAt = now;
|
|
36
33
|
const reservation4inform = {
|
|
37
34
|
typeOf: attendedReservation.typeOf,
|
|
38
35
|
project: attendedReservation.project,
|
|
@@ -102,7 +99,8 @@ function onReservationUsed(action, attendedReservation) {
|
|
|
102
99
|
yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
|
|
103
100
|
project: attendedReservation.project,
|
|
104
101
|
reservationFor: [{ id: attendedReservation.reservationFor.id }],
|
|
105
|
-
force: false
|
|
102
|
+
force: false,
|
|
103
|
+
identifier: `onReservationUsed:${attendedReservation.id}`
|
|
106
104
|
})({ task: repos.task });
|
|
107
105
|
});
|
|
108
106
|
}
|
|
@@ -13,7 +13,6 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
|
-
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
17
16
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
18
17
|
const event_1 = require("../../repo/event");
|
|
19
18
|
const order_1 = require("../../repo/order");
|
|
@@ -41,8 +40,7 @@ function call(data) {
|
|
|
41
40
|
project: new project_1.MongoRepository(settings.connection),
|
|
42
41
|
seller: new seller_1.MongoRepository(settings.connection),
|
|
43
42
|
task: new task_1.MongoRepository(settings.connection),
|
|
44
|
-
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
45
|
-
registerServiceInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient)
|
|
43
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
46
44
|
});
|
|
47
45
|
});
|
|
48
46
|
}
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const COA = require("@motionpicture/coa-service");
|
|
14
14
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
15
15
|
const offer_1 = require("../../repo/offer");
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
16
17
|
const credentials_1 = require("../../credentials");
|
|
17
18
|
const OfferService = require("../offer");
|
|
18
19
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
@@ -26,6 +27,7 @@ function call(data) {
|
|
|
26
27
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
const categoryCodeRepo = new categoryCode_1.MongoRepository(settings.connection);
|
|
28
29
|
const offerRepo = new offer_1.MongoRepository(settings.connection);
|
|
30
|
+
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
29
31
|
const masterService = new COA.service.Master({
|
|
30
32
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
31
33
|
auth: coaAuthClient
|
|
@@ -33,6 +35,7 @@ function call(data) {
|
|
|
33
35
|
yield OfferService.event.importFromCOA(data)({
|
|
34
36
|
categoryCode: categoryCodeRepo,
|
|
35
37
|
offer: offerRepo,
|
|
38
|
+
task: taskRepo,
|
|
36
39
|
masterService
|
|
37
40
|
});
|
|
38
41
|
yield OfferService.event.importCategoryCodesFromCOA(data)({
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
15
|
+
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const order_1 = require("../../repo/order");
|
|
17
|
+
const task_1 = require("../../repo/task");
|
|
18
|
+
const transaction_1 = require("../../repo/transaction");
|
|
19
|
+
const onAssetTransactionStatusChanged_1 = require("../order/onAssetTransactionStatusChanged");
|
|
20
|
+
/**
|
|
21
|
+
* タスク実行関数
|
|
22
|
+
*/
|
|
23
|
+
function call(data) {
|
|
24
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (settings.redisClient === undefined) {
|
|
26
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
27
|
+
}
|
|
28
|
+
yield (0, onAssetTransactionStatusChanged_1.onAssetTransactionStatusChanged)(data)({
|
|
29
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
30
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
31
|
+
registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
|
|
32
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
33
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.call = call;
|
|
@@ -14,6 +14,7 @@ const factory = require("../../factory");
|
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
16
|
const code_1 = require("../../repo/code");
|
|
17
|
+
const event_1 = require("../../repo/event");
|
|
17
18
|
const order_1 = require("../../repo/order");
|
|
18
19
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
19
20
|
const reservation_1 = require("../../repo/reservation");
|
|
@@ -28,6 +29,7 @@ function call(data) {
|
|
|
28
29
|
action: new action_1.MongoRepository(settings.connection),
|
|
29
30
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
30
31
|
code: new code_1.MongoRepository(settings.connection),
|
|
32
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
31
33
|
order: new order_1.MongoRepository(settings.connection),
|
|
32
34
|
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
33
35
|
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
@@ -98,10 +100,12 @@ function onAuthorizationCreated(params) {
|
|
|
98
100
|
reservationNumbers: reservationNumbers,
|
|
99
101
|
reservationFor: { ids: reservationForIds }
|
|
100
102
|
},
|
|
101
|
-
reserveIfNotYet: params.reserveIfNotYet
|
|
103
|
+
reserveIfNotYet: params.reserveIfNotYet,
|
|
104
|
+
purpose: { code: params.code }
|
|
102
105
|
})({
|
|
103
106
|
action: repos.action,
|
|
104
107
|
assetTransaction: repos.assetTransaction,
|
|
108
|
+
event: repos.event,
|
|
105
109
|
reservation: repos.reservation,
|
|
106
110
|
task: repos.task
|
|
107
111
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
15
|
+
const order_1 = require("../../repo/order");
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
17
|
+
const transaction_1 = require("../../repo/transaction");
|
|
18
|
+
const payOrder_1 = require("../order/payOrder");
|
|
19
|
+
/**
|
|
20
|
+
* タスク実行関数
|
|
21
|
+
*/
|
|
22
|
+
function call(data) {
|
|
23
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (settings.redisClient === undefined) {
|
|
25
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
26
|
+
}
|
|
27
|
+
yield (0, payOrder_1.payOrder)(data)({
|
|
28
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
29
|
+
registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
|
|
30
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
31
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.call = call;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as AccountTitleRepo } from '../../../repo/accountTitle';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
4
|
+
import { MongoRepository as AggregateOfferRepo } from '../../../repo/aggregateOffer';
|
|
4
5
|
import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
5
6
|
import { MongoRepository as CreativeWorkRepo } from '../../../repo/creativeWork';
|
|
6
7
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
@@ -15,6 +16,7 @@ import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
|
15
16
|
export declare function onResourceDeleted(params: factory.task.onResourceUpdated.IData): (repos: {
|
|
16
17
|
accountTitle: AccountTitleRepo;
|
|
17
18
|
action: ActionRepo;
|
|
19
|
+
aggregateOffer: AggregateOfferRepo;
|
|
18
20
|
categoryCode: CategoryCodeRepo;
|
|
19
21
|
creativeWork: CreativeWorkRepo;
|
|
20
22
|
event: EventRepo;
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.onResourceDeleted = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
|
+
const syncOfferCatalog_1 = require("./syncOfferCatalog");
|
|
14
15
|
function onResourceDeleted(params) {
|
|
15
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const isDeleted = params.isDeleted === true;
|
|
@@ -52,6 +53,12 @@ function onResourceDeleted(params) {
|
|
|
52
53
|
project: { id: params.project.id },
|
|
53
54
|
ids: params.id
|
|
54
55
|
})(repos);
|
|
56
|
+
yield (0, syncOfferCatalog_1.syncOfferCatalog)({
|
|
57
|
+
project: { id: params.project.id },
|
|
58
|
+
ids: params.id,
|
|
59
|
+
typeOf: params.typeOf,
|
|
60
|
+
isDeleted: true
|
|
61
|
+
})(repos);
|
|
55
62
|
break;
|
|
56
63
|
case factory.product.ProductType.EventService:
|
|
57
64
|
case factory.product.ProductType.Product:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import { MongoRepository as AggregateOfferRepo } from '../../../repo/aggregateOffer';
|
|
3
|
+
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
4
|
+
/**
|
|
5
|
+
* カタログのitemListElementを集計オファーへ同期する
|
|
6
|
+
*/
|
|
7
|
+
export declare function syncOfferCatalog(params: {
|
|
8
|
+
project: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
ids: string[];
|
|
12
|
+
typeOf: factory.task.onResourceUpdated.OfferCatalogType;
|
|
13
|
+
isDeleted: boolean;
|
|
14
|
+
}): (repos: {
|
|
15
|
+
aggregateOffer: AggregateOfferRepo;
|
|
16
|
+
offerCatalog: OfferCatalogRepo;
|
|
17
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.syncOfferCatalog = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* カタログのitemListElementを集計オファーへ同期する
|
|
15
|
+
*/
|
|
16
|
+
function syncOfferCatalog(params) {
|
|
17
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
// if (params.ids.length !== 1) {
|
|
19
|
+
// throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
20
|
+
// }
|
|
21
|
+
if (params.isDeleted) {
|
|
22
|
+
for (const offerCatalogId of params.ids) {
|
|
23
|
+
// カタログを含む全集計オファーからカタログを除外
|
|
24
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog({
|
|
25
|
+
project: { id: params.project.id },
|
|
26
|
+
$pull: {
|
|
27
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
for (const offerCatalogId of params.ids) {
|
|
34
|
+
// 集計オファーIDリストを検索
|
|
35
|
+
const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
|
|
36
|
+
id: offerCatalogId,
|
|
37
|
+
project: { id: params.project.id }
|
|
38
|
+
});
|
|
39
|
+
// tslint:disable-next-line:no-console
|
|
40
|
+
console.log('onOfferCatalog', offerCatalogId, ' updated.', itemListElement.length, 'itemListElement found.', itemListElement);
|
|
41
|
+
const aggregateOfferIds = itemListElement.map((element) => element.id);
|
|
42
|
+
// カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
|
|
43
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
|
|
44
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
45
|
+
} }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
|
|
46
|
+
if (aggregateOfferIds.length > 0) {
|
|
47
|
+
// 新しいカタログに含まれる全集計オファーにカタログを追加
|
|
48
|
+
yield repos.aggregateOffer.pushIncludedInDataCatalog({
|
|
49
|
+
project: { id: params.project.id },
|
|
50
|
+
id: { $in: aggregateOfferIds },
|
|
51
|
+
$push: {
|
|
52
|
+
includedInDataCatalog: { $each: [{ id: offerCatalogId }] }
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.syncOfferCatalog = syncOfferCatalog;
|