@chevre/domain 21.8.0-alpha.9 → 21.8.0
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 +30 -0
- package/example/src/chevre/importOffersFromCOA.ts +7 -1
- 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/optimizeCatalogs.ts +54 -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/pushIncludedInDataCatalog.ts +47 -0
- package/example/src/chevre/searchAggregateOffers.ts +48 -0
- package/example/src/chevre/searchEventTicketOffers.ts +5 -1
- package/example/src/chevre/searchEvents.ts +9 -7
- package/example/src/chevre/searchOfferCatalogs.ts +7 -3
- package/example/src/chevre/searchOffers.ts +5 -2
- package/example/src/chevre/searchOffersByCatalog.ts +15 -9
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
- package/example/src/chevre/searchOrders.ts +9 -7
- package/example/src/chevre/syncCatalogs2aggregateOffers.ts +85 -0
- package/lib/chevre/emailMessageBuilder.js +6 -5
- package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
- package/lib/chevre/repo/aggregateOffer.js +562 -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 +189 -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/offerCatalog.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +10 -1
- 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 +87 -51
- package/lib/chevre/repo/offer.js +513 -283
- package/lib/chevre/repo/offerCatalog.d.ts +32 -3
- package/lib/chevre/repo/offerCatalog.js +97 -10
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +58 -26
- package/lib/chevre/repo/task.d.ts +6 -2
- package/lib/chevre/repo/task.js +58 -4
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -41
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -40
- package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +16 -0
- package/lib/chevre/service/aggregation/event/findEventOffers.js +58 -0
- 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/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 +3 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +48 -17
- 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 +10 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +51 -12
- package/lib/chevre/service/offer/product.d.ts +2 -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 +20 -46
- 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 +49 -9
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +11 -24
- 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/aggregateUseActionsOnEvent.js +2 -0
- 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/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 +78 -0
- package/lib/chevre/service/task/onResourceUpdated.js +12 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- 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 +3 -3
- package/lib/chevre/settings.js +4 -12
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +0 -149
- package/lib/chevre/repo/mongoose/schemas/offer.js +0 -210
|
@@ -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
|
}
|
|
@@ -14,6 +14,7 @@ const factory = require("../../factory");
|
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const event_1 = require("../../repo/event");
|
|
16
16
|
const offer_1 = require("../../repo/offer");
|
|
17
|
+
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
17
18
|
const place_1 = require("../../repo/place");
|
|
18
19
|
const product_1 = require("../../repo/product");
|
|
19
20
|
const AggregationService = require("../aggregation");
|
|
@@ -29,6 +30,7 @@ function call(data) {
|
|
|
29
30
|
action: new action_1.MongoRepository(settings.connection),
|
|
30
31
|
event: new event_1.MongoRepository(settings.connection),
|
|
31
32
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
33
|
+
offerCatalog: new offerCatalog_1.MongoRepository(settings.connection),
|
|
32
34
|
place: new place_1.MongoRepository(settings.connection),
|
|
33
35
|
product: new product_1.MongoRepository(settings.connection)
|
|
34
36
|
});
|
|
@@ -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
|
});
|
|
@@ -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,78 @@
|
|
|
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
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* カタログのitemListElementを集計オファーへ同期する
|
|
16
|
+
*/
|
|
17
|
+
function syncOfferCatalog(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// if (params.ids.length !== 1) {
|
|
20
|
+
// throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
21
|
+
// }
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if (params.isDeleted) {
|
|
24
|
+
for (const offerCatalogId of params.ids) {
|
|
25
|
+
const offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
26
|
+
const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
|
|
27
|
+
switch (itemListElementTypeOf) {
|
|
28
|
+
case factory.offerType.Offer:
|
|
29
|
+
// カタログを含む全集計オファーからカタログを除外
|
|
30
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog({
|
|
31
|
+
project: { id: params.project.id },
|
|
32
|
+
$pull: {
|
|
33
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
// no op
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
for (const offerCatalogId of params.ids) {
|
|
44
|
+
const offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
45
|
+
const itemListElementTypeOf = (_b = offerCatalogs.shift()) === null || _b === void 0 ? void 0 : _b.itemListElementTypeOf;
|
|
46
|
+
switch (itemListElementTypeOf) {
|
|
47
|
+
case factory.offerType.Offer:
|
|
48
|
+
// 集計オファーIDリストを検索
|
|
49
|
+
const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
|
|
50
|
+
id: offerCatalogId,
|
|
51
|
+
project: { id: params.project.id }
|
|
52
|
+
});
|
|
53
|
+
const aggregateOfferIds = itemListElement.map((element) => element.id);
|
|
54
|
+
// カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
|
|
55
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
|
|
56
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
57
|
+
} }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
|
|
58
|
+
if (aggregateOfferIds.length > 0) {
|
|
59
|
+
// 新しいカタログに含まれる全集計オファーにカタログを追加
|
|
60
|
+
yield repos.aggregateOffer.pushIncludedInDataCatalog({
|
|
61
|
+
project: { id: params.project.id },
|
|
62
|
+
id: { $in: aggregateOfferIds },
|
|
63
|
+
$push: {
|
|
64
|
+
includedInDataCatalog: { $each: [{ id: offerCatalogId }] }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// 同期済記録を補完
|
|
69
|
+
yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
// no op
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.syncOfferCatalog = syncOfferCatalog;
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const accountTitle_1 = require("../../repo/accountTitle");
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
|
+
const aggregateOffer_1 = require("../../repo/aggregateOffer");
|
|
16
17
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
17
18
|
const creativeWork_1 = require("../../repo/creativeWork");
|
|
18
19
|
const event_1 = require("../../repo/event");
|
|
@@ -25,6 +26,7 @@ const product_1 = require("../../repo/product");
|
|
|
25
26
|
const productOffer_1 = require("../../repo/productOffer");
|
|
26
27
|
const task_1 = require("../../repo/task");
|
|
27
28
|
const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
|
|
29
|
+
const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
|
|
28
30
|
const settings_1 = require("../../settings");
|
|
29
31
|
const informResources = settings_1.settings.onResourceUpdated.informResource;
|
|
30
32
|
/**
|
|
@@ -35,6 +37,7 @@ function call(data) {
|
|
|
35
37
|
yield onResourceUpdated(data)({
|
|
36
38
|
accountTitle: new accountTitle_1.MongoRepository(connectionSettings.connection),
|
|
37
39
|
action: new action_1.MongoRepository(connectionSettings.connection),
|
|
40
|
+
aggregateOffer: new aggregateOffer_1.MongoRepository(connectionSettings.connection),
|
|
38
41
|
categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
|
|
39
42
|
creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
|
|
40
43
|
event: new event_1.MongoRepository(connectionSettings.connection),
|
|
@@ -107,6 +110,15 @@ function onResourceUpdated(params) {
|
|
|
107
110
|
typeOf: params.typeOf
|
|
108
111
|
})(repos);
|
|
109
112
|
break;
|
|
113
|
+
// カタログに対応(2023-09-12~)
|
|
114
|
+
case 'OfferCatalog':
|
|
115
|
+
yield (0, syncOfferCatalog_1.syncOfferCatalog)({
|
|
116
|
+
project: { id: params.project.id },
|
|
117
|
+
ids: params.id,
|
|
118
|
+
typeOf: params.typeOf,
|
|
119
|
+
isDeleted: false
|
|
120
|
+
})(repos);
|
|
121
|
+
break;
|
|
110
122
|
default:
|
|
111
123
|
// no op
|
|
112
124
|
}
|
|
@@ -159,7 +159,11 @@ function transaction2refundFee(params) {
|
|
|
159
159
|
return refundFee;
|
|
160
160
|
}
|
|
161
161
|
function createStartRefundTransactionParams(params) {
|
|
162
|
-
var _a;
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
164
|
+
if (typeof paymentMethodType !== 'string') {
|
|
165
|
+
throw new factory.errors.NotFound('object.paymentMethod.identifier');
|
|
166
|
+
}
|
|
163
167
|
return {
|
|
164
168
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
165
169
|
typeOf: factory.assetTransactionType.Refund,
|
|
@@ -173,11 +177,12 @@ function createStartRefundTransactionParams(params) {
|
|
|
173
177
|
recipient: { typeOf: params.recipient.typeOf, name: params.recipient.name },
|
|
174
178
|
object: {
|
|
175
179
|
typeOf: params.paymentServiceType,
|
|
176
|
-
id: (typeof ((
|
|
180
|
+
id: (typeof ((_b = params.object.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? params.object.issuedThrough.id : '',
|
|
177
181
|
paymentMethod: {
|
|
178
182
|
additionalProperty: params.object.additionalProperty,
|
|
179
183
|
name: params.object.name,
|
|
180
|
-
typeOf: params.object.typeOf,
|
|
184
|
+
// typeOf: params.object.typeOf,
|
|
185
|
+
typeOf: paymentMethodType,
|
|
181
186
|
paymentMethodId: params.object.paymentMethodId
|
|
182
187
|
},
|
|
183
188
|
refundFee: params.refundFee
|
|
@@ -65,35 +65,51 @@ function createPaymentMethods(params) {
|
|
|
65
65
|
const authorizePaymentActions = params.authorizeActions
|
|
66
66
|
.filter((a) => {
|
|
67
67
|
var _a;
|
|
68
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
69
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
70
|
+
: a.result;
|
|
68
71
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
69
|
-
&& (
|
|
72
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
70
73
|
});
|
|
71
74
|
// 決済方法をセット
|
|
72
75
|
authorizePaymentActions.forEach((a) => {
|
|
73
|
-
var _a, _b, _c;
|
|
74
|
-
const result = a.result;
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
// const result = (<factory.action.authorize.paymentMethod.any.IResult>a.result);
|
|
78
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
79
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
80
|
+
: a.result;
|
|
81
|
+
const paymentMethodAmountCurrencyByAuthorizeAction = (_c = (_b = resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency;
|
|
79
82
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
80
|
-
const paymentMethodType = (
|
|
83
|
+
const paymentMethodType = (_d = resultAsInvoice.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf;
|
|
81
84
|
if (typeof paymentMethodType !== 'string') {
|
|
82
85
|
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
86
|
}
|
|
84
|
-
|
|
87
|
+
const paymentMethodOfInvoice = Object.assign({ identifier: paymentMethodType }, (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
88
|
+
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
89
|
+
: undefined);
|
|
90
|
+
paymentMethods.push({
|
|
91
|
+
accountId: resultAsInvoice.accountId,
|
|
92
|
+
additionalProperty: (Array.isArray(resultAsInvoice.additionalProperty)) ? resultAsInvoice.additionalProperty : [],
|
|
93
|
+
issuedThrough: resultAsInvoice.issuedThrough,
|
|
94
|
+
name: resultAsInvoice.name,
|
|
95
|
+
paymentMethodId: resultAsInvoice.paymentMethodId,
|
|
96
|
+
paymentStatus: resultAsInvoice.paymentStatus,
|
|
97
|
+
totalPaymentDue: resultAsInvoice.totalPaymentDue,
|
|
98
|
+
typeOf: paymentMethodType,
|
|
99
|
+
// CreditCardIFのカード通貨区分を追加(2023-08-15~)
|
|
100
|
+
// 決済方法区分を保証(2023-08-28~)
|
|
101
|
+
paymentMethod: paymentMethodOfInvoice
|
|
102
|
+
});
|
|
85
103
|
});
|
|
86
104
|
// 決済方法から注文金額の計算
|
|
87
|
-
// price += authorizePaymentActions
|
|
88
|
-
// .filter((a) => {
|
|
89
|
-
// return a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY;
|
|
90
|
-
// })
|
|
91
|
-
// .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
|
|
92
105
|
price += authorizePaymentActions
|
|
93
106
|
.reduce((a, b) => {
|
|
94
107
|
var _a, _b;
|
|
95
|
-
const
|
|
96
|
-
? b.result.
|
|
108
|
+
const resultAsInvoice = (Array.isArray(b.result))
|
|
109
|
+
? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
110
|
+
: b.result;
|
|
111
|
+
const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
|
|
112
|
+
? resultAsInvoice.totalPaymentDue.value
|
|
97
113
|
: 0;
|
|
98
114
|
return a + jpyAmount;
|
|
99
115
|
}, 0);
|