@chevre/domain 20.4.0-alpha.3 → 20.4.0-alpha.30
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
- package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
- package/example/src/chevre/reIndex.ts +25 -0
- package/example/src/chevre/searchEventTicketOffers.ts +7 -4
- package/example/src/chevre/searchOfferCatalogs.ts +14 -16
- package/example/src/chevre/searchOffersByCatalog.ts +2 -1
- package/example/src/chevre/searchTasks.ts +22 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
- package/lib/chevre/repo/account.d.ts +4 -10
- package/lib/chevre/repo/account.js +72 -60
- package/lib/chevre/repo/assetTransaction.d.ts +1 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/code.d.ts +0 -7
- package/lib/chevre/repo/code.js +0 -17
- package/lib/chevre/repo/event.d.ts +5 -4
- package/lib/chevre/repo/event.js +12 -30
- package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
- package/lib/chevre/repo/mongoose/model/comments.js +1 -1
- package/lib/chevre/repo/mongoose/model/offer.js +19 -9
- package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
- package/lib/chevre/repo/offer.d.ts +17 -2
- package/lib/chevre/repo/offer.js +77 -44
- package/lib/chevre/repo/offerCatalog.d.ts +3 -5
- package/lib/chevre/repo/offerCatalog.js +78 -37
- package/lib/chevre/repo/priceSpecification.d.ts +11 -0
- package/lib/chevre/repo/priceSpecification.js +44 -66
- package/lib/chevre/repo/serviceOutput.d.ts +4 -0
- package/lib/chevre/repo/serviceOutput.js +6 -0
- package/lib/chevre/repo/task.js +13 -9
- package/lib/chevre/repository.d.ts +6 -0
- package/lib/chevre/repository.js +8 -1
- package/lib/chevre/service/account.d.ts +0 -8
- package/lib/chevre/service/account.js +16 -10
- package/lib/chevre/service/accountTransaction/deposit.js +2 -1
- package/lib/chevre/service/accountTransaction/factory.js +25 -20
- package/lib/chevre/service/accountTransaction/transfer.js +4 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
- package/lib/chevre/service/assetTransaction/pay.js +19 -14
- package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
- package/lib/chevre/service/assetTransaction/reserve.js +2 -15
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +1 -38
- package/lib/chevre/service/delivery.js +12 -3
- package/lib/chevre/service/event.js +0 -3
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +7 -8
- package/lib/chevre/service/offer/event/authorize.js +3 -4
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +164 -314
- package/lib/chevre/service/offer/factory.d.ts +6 -1
- package/lib/chevre/service/offer/factory.js +42 -24
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +5 -1
- package/lib/chevre/service/payment/any/factory.js +29 -2
- package/lib/chevre/service/payment/any.js +11 -4
- package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
- package/lib/chevre/service/payment/movieTicket.js +17 -8
- package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
- package/lib/chevre/service/payment/paymentCard.js +16 -8
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/settings.d.ts +4 -0
- package/lib/chevre/settings.js +8 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
- package/example/src/chevre/migrateProjectSubscription.ts +0 -51
- package/example/src/chevre/migrateSection.ts +0 -105
- package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
- package/lib/chevre/service/task/deleteAuthorization.js +0 -29
|
@@ -17,6 +17,7 @@ const createDebug = require("debug");
|
|
|
17
17
|
const moment = require("moment-timezone");
|
|
18
18
|
const event_1 = require("../../../repo/event");
|
|
19
19
|
const factory = require("../../../factory");
|
|
20
|
+
const settings_1 = require("../../../settings");
|
|
20
21
|
const debug = createDebug('chevre-domain:service');
|
|
21
22
|
/**
|
|
22
23
|
* イベントデータをID指定で集計する
|
|
@@ -28,31 +29,34 @@ function aggregateScreeningEvent(params) {
|
|
|
28
29
|
// const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
|
|
29
30
|
const event = yield repos.event.findMinimizedIndividualEventById(params);
|
|
30
31
|
let aggregatingEvents = [event];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
// プロジェクト限定(2023-02-22~)
|
|
33
|
+
if (settings_1.settings.useOfferRateLimitProjects.includes(event.project.id)) {
|
|
34
|
+
const availableOffers = yield findOffers({ event })(repos);
|
|
35
|
+
const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
|
|
36
|
+
if (offerRateLimitExists) {
|
|
37
|
+
// 同location、かつ同時間帯、のイベントに関しても集計する(ttts暫定対応)
|
|
38
|
+
const startFrom = moment(event.startDate)
|
|
39
|
+
.startOf('hour')
|
|
40
|
+
.toDate();
|
|
41
|
+
const startThrough = moment(startFrom)
|
|
42
|
+
.add(1, 'hour')
|
|
43
|
+
.add(-1, 'second')
|
|
44
|
+
.toDate();
|
|
45
|
+
// 取得属性最適化(2023-01-25~)
|
|
46
|
+
aggregatingEvents = yield repos.event.search({
|
|
47
|
+
limit: 100,
|
|
48
|
+
page: 1,
|
|
49
|
+
project: { id: { $eq: event.project.id } },
|
|
50
|
+
typeOf: event.typeOf,
|
|
51
|
+
eventStatuses: [factory.eventStatusType.EventScheduled],
|
|
52
|
+
startFrom: startFrom,
|
|
53
|
+
startThrough: startThrough,
|
|
54
|
+
location: { branchCode: { $eq: event.location.branchCode } }
|
|
55
|
+
}, event_1.PROJECTION_MINIMIZED_EVENT);
|
|
56
|
+
// ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
|
|
57
|
+
aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
|
|
58
|
+
aggregatingEvents = [event, ...aggregatingEvents];
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
debug(aggregatingEvents.length, 'aggregatingEvents found', aggregatingEvents.map((e) => e.id));
|
|
58
62
|
for (const aggregatingEvent of aggregatingEvents) {
|
|
@@ -79,41 +83,29 @@ function aggregateByEvent(params) {
|
|
|
79
83
|
branchCode: { $eq: event.location.branchCode },
|
|
80
84
|
containedInPlace: { id: { $eq: movieTheaterId } }
|
|
81
85
|
});
|
|
82
|
-
// 施設取得
|
|
83
|
-
// const movieTheater = await findLocation(params)(repos);
|
|
84
|
-
// // 万が一施設が存在しなければ処理終了
|
|
85
|
-
// if (movieTheater === undefined) {
|
|
86
|
-
// return;
|
|
87
|
-
// }
|
|
88
|
-
// const screeningRoom = <factory.place.screeningRoom.IPlace | undefined>
|
|
89
|
-
// movieTheater.containsPlace.find((p) => p.branchCode === event.location.branchCode);
|
|
90
|
-
// if (screeningRoom === undefined) {
|
|
91
|
-
// // 基本的にありえないはずだが、万が一スクリーンが見つからなければcapacityは0のまま
|
|
92
|
-
// // tslint:disable-next-line:no-console
|
|
93
|
-
// console.error(new Error(`Screening room not found. branchCode: ${event.location.branchCode}`));
|
|
94
|
-
// return;
|
|
95
|
-
// }
|
|
96
86
|
// 予約集計
|
|
97
87
|
const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
|
|
98
88
|
aggregateDate: now,
|
|
99
89
|
event: event,
|
|
100
90
|
screeningRoom: screeningRoom
|
|
101
91
|
})(repos);
|
|
92
|
+
// プロジェクト限定(2023-02-22~)
|
|
102
93
|
// オファーごとの集計
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
let aggregateOffer;
|
|
95
|
+
if (settings_1.settings.useAggregateOfferProjects.includes(event.project.id)) {
|
|
96
|
+
aggregateOffer = yield aggregateOfferByEvent({
|
|
97
|
+
aggregateDate: now,
|
|
98
|
+
event: Object.assign(Object.assign({}, event), { maximumAttendeeCapacity,
|
|
99
|
+
remainingAttendeeCapacity }),
|
|
100
|
+
screeningRoom: screeningRoom
|
|
101
|
+
})(repos);
|
|
102
|
+
debug('offers aggregated', aggregateOffer);
|
|
103
|
+
}
|
|
110
104
|
// 値がundefinedの場合に更新しないように注意
|
|
111
105
|
const update = {
|
|
112
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
aggregateOffer }, (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
|
|
116
|
-
$unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
|
|
106
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
107
|
+
aggregateReservation }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) === 'string') ? { aggregateOffer: aggregateOffer } : undefined), (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
|
|
108
|
+
$unset: Object.assign(Object.assign(Object.assign({ noExistingAttributeName: 1 }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) !== 'string') ? { aggregateOffer: '' } : undefined), (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
|
|
117
109
|
};
|
|
118
110
|
debug('update:', update);
|
|
119
111
|
// 保管
|
|
@@ -125,37 +117,6 @@ function aggregateByEvent(params) {
|
|
|
125
117
|
});
|
|
126
118
|
}
|
|
127
119
|
exports.aggregateByEvent = aggregateByEvent;
|
|
128
|
-
/**
|
|
129
|
-
* イベントロケーション取得
|
|
130
|
-
* NotFoundエラーをハンドリングする
|
|
131
|
-
*/
|
|
132
|
-
// function findLocation(params: {
|
|
133
|
-
// event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
|
|
134
|
-
// }) {
|
|
135
|
-
// return async (repos: {
|
|
136
|
-
// place: PlaceRepo;
|
|
137
|
-
// }): Promise<factory.place.movieTheater.IPlace | undefined> => {
|
|
138
|
-
// let movieTheater: factory.place.movieTheater.IPlace | undefined;
|
|
139
|
-
// try {
|
|
140
|
-
// if (params.event.typeOf === factory.eventType.ScreeningEvent) {
|
|
141
|
-
// movieTheater = await repos.place.findById({ id: params.event.superEvent.location.id });
|
|
142
|
-
// } else {
|
|
143
|
-
// const movieTheaterId: string =
|
|
144
|
-
// String(params.event.offers?.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
|
|
145
|
-
// movieTheater = await repos.place.findById({ id: movieTheaterId });
|
|
146
|
-
// }
|
|
147
|
-
// } catch (error) {
|
|
148
|
-
// let throwsError = true;
|
|
149
|
-
// if (error instanceof factory.errors.NotFound) {
|
|
150
|
-
// throwsError = false;
|
|
151
|
-
// }
|
|
152
|
-
// if (throwsError) {
|
|
153
|
-
// throw error;
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// return movieTheater;
|
|
157
|
-
// };
|
|
158
|
-
// }
|
|
159
120
|
/**
|
|
160
121
|
* 集計後アクション
|
|
161
122
|
*/
|
|
@@ -208,10 +169,12 @@ function findOffers(params) {
|
|
|
208
169
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
209
170
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
210
171
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
211
|
-
|
|
172
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
212
173
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
174
|
+
excludeAppliesToMovieTicket: false,
|
|
213
175
|
sort: false // ソート不要(2023-01-27~)
|
|
214
176
|
});
|
|
177
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
215
178
|
}
|
|
216
179
|
}
|
|
217
180
|
else {
|
|
@@ -91,10 +91,12 @@ function findOffers(params) {
|
|
|
91
91
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
92
92
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
93
93
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
94
|
-
|
|
94
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
95
95
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
96
|
+
excludeAppliesToMovieTicket: false,
|
|
96
97
|
sort: false // ソート不要(2023-01-27~)
|
|
97
98
|
});
|
|
99
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
else {
|
|
@@ -62,20 +62,29 @@ function start(params) {
|
|
|
62
62
|
recipient: params.recipient,
|
|
63
63
|
object: Object.assign(Object.assign({ amount,
|
|
64
64
|
fromLocation,
|
|
65
|
-
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType,
|
|
65
|
+
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType, transactionNumber: transactionNumber }, (typeof params.identifier === 'string') ? { identifier: params.identifier } : undefined) }, (typeof params.object.description === 'string') ? { description: params.object.description } : {}), { force: params.object.force === true }),
|
|
66
66
|
expires: params.expires
|
|
67
67
|
};
|
|
68
68
|
// 取引開始
|
|
69
69
|
let transaction;
|
|
70
70
|
try {
|
|
71
71
|
transaction = yield repos.assetTransaction.start(startParams);
|
|
72
|
-
const pendingTransaction =
|
|
73
|
-
yield
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
// const pendingTransaction = await authorizeAccount({ transaction })(repos);
|
|
73
|
+
yield authorizeAccount({ transaction })(repos);
|
|
74
|
+
// 更新不要(2023-02-20~)
|
|
75
|
+
// await repos.assetTransaction.findByIdAndUpdate<factory.assetTransactionType.MoneyTransfer>({
|
|
76
|
+
// id: transaction.id,
|
|
77
|
+
// update: {
|
|
78
|
+
// 'object.pendingTransaction': {
|
|
79
|
+
// typeOf: pendingTransaction.typeOf,
|
|
80
|
+
// id: pendingTransaction.id,
|
|
81
|
+
// transactionNumber: pendingTransaction.transactionNumber,
|
|
82
|
+
// ...(typeof pendingTransaction.identifier === 'string')
|
|
83
|
+
// ? { identifier: pendingTransaction.identifier }
|
|
84
|
+
// : undefined
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
79
88
|
}
|
|
80
89
|
catch (error) {
|
|
81
90
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -113,13 +122,12 @@ function authorizeAccount(params) {
|
|
|
113
122
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
114
123
|
var _a, _b, _c;
|
|
115
124
|
const transaction = params.transaction;
|
|
116
|
-
let pendingTransaction;
|
|
117
125
|
const fromLocation = transaction.object.fromLocation;
|
|
118
126
|
const toLocation = transaction.object.toLocation;
|
|
119
127
|
if (typeof ((_a = transaction.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.typeOf) !== 'string') {
|
|
120
128
|
throw new factory.errors.NotFound('transaction.object.pendingTransaction.typeOf');
|
|
121
129
|
}
|
|
122
|
-
|
|
130
|
+
yield MoneyTransferService.authorize({
|
|
123
131
|
typeOf: transaction.object.pendingTransaction.typeOf,
|
|
124
132
|
identifier: transaction.object.pendingTransaction.identifier,
|
|
125
133
|
transactionNumber: transaction.object.pendingTransaction.transactionNumber,
|
|
@@ -143,7 +151,7 @@ function authorizeAccount(params) {
|
|
|
143
151
|
recipient: transaction.recipient,
|
|
144
152
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
145
153
|
})(repos);
|
|
146
|
-
return pendingTransaction;
|
|
154
|
+
// return pendingTransaction;
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
157
|
function fixMonetaryAmount(params, product) {
|
|
@@ -220,26 +220,32 @@ function validateSeller(params) {
|
|
|
220
220
|
}
|
|
221
221
|
function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
222
222
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a;
|
|
224
|
+
const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
|
|
225
|
+
if (typeof amount !== 'number') {
|
|
226
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod?.amount');
|
|
227
|
+
}
|
|
223
228
|
yield (0, validation_1.validateAccount)(params)(repos);
|
|
224
|
-
const
|
|
229
|
+
const { pendingTransaction, currency, accountNumber } = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
|
|
225
230
|
const totalPaymentDue = {
|
|
226
231
|
typeOf: 'MonetaryAmount',
|
|
227
|
-
currency
|
|
228
|
-
value:
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
currency,
|
|
233
|
+
value: amount
|
|
234
|
+
// value: (typeof pendingTransaction.object.amount === 'number')
|
|
235
|
+
// ? pendingTransaction.object.amount
|
|
236
|
+
// : pendingTransaction.object.amount.value
|
|
231
237
|
};
|
|
232
|
-
const
|
|
233
|
-
typeOf:
|
|
234
|
-
id:
|
|
235
|
-
transactionNumber:
|
|
236
|
-
object: { fromLocation: { accountNumber
|
|
238
|
+
const savingPendingTransaction = {
|
|
239
|
+
typeOf: pendingTransaction.typeOf,
|
|
240
|
+
id: pendingTransaction.id,
|
|
241
|
+
transactionNumber: pendingTransaction.transactionNumber,
|
|
242
|
+
object: { fromLocation: { accountNumber } }
|
|
237
243
|
};
|
|
238
244
|
return saveAuthorizeResult({
|
|
239
245
|
id: transaction.id,
|
|
240
246
|
update: {
|
|
241
247
|
'object.paymentMethod.totalPaymentDue': totalPaymentDue,
|
|
242
|
-
'object.pendingTransaction':
|
|
248
|
+
'object.pendingTransaction': savingPendingTransaction
|
|
243
249
|
}
|
|
244
250
|
})(repos);
|
|
245
251
|
});
|
|
@@ -263,11 +269,10 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId) {
|
|
|
263
269
|
}
|
|
264
270
|
function processAuthorizeMovieTicket(params, transaction, paymentServiceId) {
|
|
265
271
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
|
|
267
|
-
const authorizeResult = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
|
|
272
|
+
const { accountId, checkResult, payAction } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
|
|
268
273
|
return saveAuthorizeResult({
|
|
269
274
|
id: transaction.id,
|
|
270
|
-
update: Object.assign({ 'object.accountId':
|
|
275
|
+
update: Object.assign({ 'object.accountId': accountId, 'object.paymentMethod.accountId': accountId, 'object.payAction': payAction }, (checkResult !== undefined) ? { 'object.checkResult': checkResult } : undefined)
|
|
271
276
|
})(repos);
|
|
272
277
|
});
|
|
273
278
|
}
|
|
@@ -58,13 +58,15 @@ function createServiceOutput(params) {
|
|
|
58
58
|
throw new factory.errors.ArgumentNull('object.itemOffered.serviceOutput.accessCode');
|
|
59
59
|
}
|
|
60
60
|
paymentAccount = {
|
|
61
|
-
|
|
61
|
+
// 廃止(2023-02-20~)
|
|
62
|
+
// project: { typeOf: product.project.typeOf, id: product.project.id },
|
|
62
63
|
// ひとまず固定
|
|
63
64
|
// 口座は複数のプロダクトに結合する可能性もあり、どのように利用されるかは知らない。ただbalanceを管理するだけ。通貨は知っている。
|
|
64
65
|
typeOf: factory.accountType.Account,
|
|
65
66
|
// ひとまずPermit識別子と口座番号は同一
|
|
66
|
-
accountNumber: identifier
|
|
67
|
-
|
|
67
|
+
accountNumber: identifier
|
|
68
|
+
// 廃止(2023-02-16~)
|
|
69
|
+
// accountType: amount.currency
|
|
68
70
|
};
|
|
69
71
|
break;
|
|
70
72
|
case factory.product.ProductType.MembershipService:
|
|
@@ -73,7 +75,10 @@ function createServiceOutput(params) {
|
|
|
73
75
|
default:
|
|
74
76
|
throw new factory.errors.NotImplemented(`Product type ${product.typeOf} not implemented`);
|
|
75
77
|
}
|
|
76
|
-
const issuedThrough = Object.assign({
|
|
78
|
+
const issuedThrough = Object.assign({
|
|
79
|
+
// 廃止(2023-02-20~)
|
|
80
|
+
// project: { typeOf: product.project.typeOf, id: product.project.id },
|
|
81
|
+
typeOf: product.typeOf, id: product.id }, (typeof ((_m = product.serviceType) === null || _m === void 0 ? void 0 : _m.typeOf) === 'string') ? { serviceType: product.serviceType } : undefined);
|
|
77
82
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project: { typeOf: product.project.typeOf, id: product.project.id }, identifier: identifier, issuedThrough, typeOf: serviceOutputType, dateIssued: params.dateIssued }, (typeof accessCode === 'string') ? { accessCode } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof validFor === 'string') ? { validFor } : undefined), (name !== undefined) ? { name } : undefined), (amount !== undefined) ? { amount } : undefined), (depositAmount !== undefined) ? { depositAmount } : undefined), (paymentAmount !== undefined) ? { paymentAmount } : undefined), (paymentAccount !== undefined) ? { paymentAccount } : undefined), (issuedBy !== undefined) ? { issuedBy } : undefined);
|
|
78
83
|
}
|
|
79
84
|
exports.createServiceOutput = createServiceOutput;
|
|
@@ -117,26 +117,13 @@ function addReservations(params) {
|
|
|
117
117
|
event: { id: event.id },
|
|
118
118
|
// 対応アプリケーション条件追加(2023-01-27~)
|
|
119
119
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
120
|
-
|
|
120
|
+
onlyValid: true,
|
|
121
|
+
addSortIndex: false,
|
|
121
122
|
validateOfferRateLimit: true
|
|
122
123
|
})(repos);
|
|
123
124
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
124
125
|
availableOffers = searchEventTicketOffersResult.unitPriceOffers;
|
|
125
126
|
}
|
|
126
|
-
// 冗長なfindOffersByOfferCatalogId処理を削除(2023-01-26~)
|
|
127
|
-
// let availableOffers: factory.unitPriceOffer.IUnitPriceOffer[] = [];
|
|
128
|
-
// // 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
129
|
-
// const eventOffers = <factory.event.screeningEvent.IOffer | undefined>event.offers;
|
|
130
|
-
// if (typeof eventOffers?.itemOffered?.id === 'string') {
|
|
131
|
-
// const eventService = <factory.product.IProduct>await repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
132
|
-
// if (typeof eventService.hasOfferCatalog?.id === 'string') {
|
|
133
|
-
// availableOffers = await repos.offer.findOffersByOfferCatalogId({
|
|
134
|
-
// offerCatalog: { id: eventService.hasOfferCatalog.id }
|
|
135
|
-
// });
|
|
136
|
-
// }
|
|
137
|
-
// } else {
|
|
138
|
-
// throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
139
|
-
// }
|
|
140
127
|
const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event: { id: event.id } })(repos);
|
|
141
128
|
// 仮予約作成
|
|
142
129
|
const { acceptedOffers4transactionObject, objectSubReservations } = yield createAcceptedOffers4transactionObject({
|
|
@@ -33,4 +33,4 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
|
|
|
33
33
|
project: ProjectRepo;
|
|
34
34
|
task: TaskRepo;
|
|
35
35
|
assetTransaction: AssetTransactionRepo;
|
|
36
|
-
}) => Promise<(import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/deleteAssetTransaction").ITask | import("@chevre/factory/lib/task/
|
|
36
|
+
}) => Promise<(import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/deleteAssetTransaction").ITask | import("@chevre/factory/lib/task/deleteOrder").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/deleteMember").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask)[] | undefined>;
|
|
@@ -3,14 +3,6 @@ import { MongoRepository as AuthorizationRepo } from '../repo/code';
|
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
export declare type IToken = string;
|
|
5
5
|
export declare type ICode = string;
|
|
6
|
-
/**
|
|
7
|
-
* 承認を削除する
|
|
8
|
-
* 冪等性を確保すること
|
|
9
|
-
*/
|
|
10
|
-
export declare function deleteAuthorization(params: factory.task.IData<factory.taskName.DeleteAuthorization>): (repos: {
|
|
11
|
-
action: ActionRepo;
|
|
12
|
-
authorization: AuthorizationRepo;
|
|
13
|
-
}) => Promise<void>;
|
|
14
6
|
/**
|
|
15
7
|
* コードをトークンに変換する
|
|
16
8
|
*/
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.verifyToken = exports.getToken =
|
|
12
|
+
exports.verifyToken = exports.getToken = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 承認サービス
|
|
15
15
|
*/
|
|
@@ -17,43 +17,6 @@ const jwt = require("jsonwebtoken");
|
|
|
17
17
|
const code_1 = require("../repo/code");
|
|
18
18
|
const factory = require("../factory");
|
|
19
19
|
const credentials_1 = require("../credentials");
|
|
20
|
-
/**
|
|
21
|
-
* 承認を削除する
|
|
22
|
-
* 冪等性を確保すること
|
|
23
|
-
*/
|
|
24
|
-
function deleteAuthorization(params) {
|
|
25
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const authorization = params.object;
|
|
27
|
-
// Deleteアクションを作成(logとしての意味合いも含めて)
|
|
28
|
-
const actionAttributes = {
|
|
29
|
-
typeOf: factory.actionType.DeleteAction,
|
|
30
|
-
project: authorization.project,
|
|
31
|
-
object: authorization,
|
|
32
|
-
agent: authorization.project
|
|
33
|
-
};
|
|
34
|
-
let deleteAuthorizationResult;
|
|
35
|
-
const action = yield repos.action.start(actionAttributes);
|
|
36
|
-
try {
|
|
37
|
-
// 承認削除
|
|
38
|
-
deleteAuthorizationResult = yield repos.authorization.deleteByCode({ code: authorization.code });
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
// actionにエラー結果を追加
|
|
42
|
-
try {
|
|
43
|
-
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
44
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
45
|
-
}
|
|
46
|
-
catch (__) {
|
|
47
|
-
// 失敗したら仕方ない
|
|
48
|
-
}
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
// アクション完了
|
|
52
|
-
const actionResult = { deleteAuthorizationResult };
|
|
53
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
exports.deleteAuthorization = deleteAuthorization;
|
|
57
20
|
/**
|
|
58
21
|
* コードをトークンに変換する
|
|
59
22
|
*/
|
|
@@ -88,7 +88,10 @@ function createGivePointAwardStartParams4moneyTransfer(params, transactionNumber
|
|
|
88
88
|
: params.purpose.typeOf,
|
|
89
89
|
fromLocation: agent,
|
|
90
90
|
toLocation,
|
|
91
|
-
pendingTransaction: {
|
|
91
|
+
pendingTransaction: {
|
|
92
|
+
typeOf: factory.account.transactionType.Deposit,
|
|
93
|
+
transactionNumber
|
|
94
|
+
}
|
|
92
95
|
} }, (typeof params.object.identifier === 'string') ? { identifier: params.object.identifier } : undefined);
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
@@ -181,7 +184,10 @@ function processReturnPointAwardByTransactionIdentifier(params) {
|
|
|
181
184
|
fromLocation,
|
|
182
185
|
toLocation: depositTransaction.object.fromLocation,
|
|
183
186
|
description: `[Return Award]${depositTransaction.object.description}`,
|
|
184
|
-
pendingTransaction: {
|
|
187
|
+
pendingTransaction: {
|
|
188
|
+
typeOf: factory.account.transactionType.Withdraw,
|
|
189
|
+
transactionNumber
|
|
190
|
+
},
|
|
185
191
|
force: true
|
|
186
192
|
}
|
|
187
193
|
})(repos);
|
|
@@ -260,7 +266,10 @@ function processReturnPointAwardByTransactionFromLocationIdentifier(params) {
|
|
|
260
266
|
// },
|
|
261
267
|
toLocation,
|
|
262
268
|
description: `[Return Award]${returningTransaction.object.description}`,
|
|
263
|
-
pendingTransaction: {
|
|
269
|
+
pendingTransaction: {
|
|
270
|
+
typeOf: factory.account.transactionType.Transfer,
|
|
271
|
+
transactionNumber
|
|
272
|
+
},
|
|
264
273
|
force: true
|
|
265
274
|
}
|
|
266
275
|
})(repos);
|
|
@@ -456,10 +456,7 @@ function createScreeningEventFromCOA(params) {
|
|
|
456
456
|
identifier: id,
|
|
457
457
|
name: params.superEvent.name,
|
|
458
458
|
eventStatus: factory.eventStatusType.EventScheduled,
|
|
459
|
-
workPerformed: params.superEvent.workPerformed,
|
|
460
459
|
location: {
|
|
461
|
-
// 不要なので廃止(2022-12-19~)
|
|
462
|
-
// project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
463
460
|
typeOf: params.screenRoom.typeOf,
|
|
464
461
|
branchCode: params.screenRoom.branchCode,
|
|
465
462
|
name: params.screenRoom.name
|
|
@@ -28,9 +28,9 @@ function authorize(params) {
|
|
|
28
28
|
id: params.purpose.id
|
|
29
29
|
});
|
|
30
30
|
// 口座取引開始
|
|
31
|
-
let pendingTransaction;
|
|
31
|
+
// let pendingTransaction: factory.action.transfer.moneyTransfer.IPendingTransaction;
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
yield processAccountTransaction({
|
|
34
34
|
typeOf: params.typeOf,
|
|
35
35
|
identifier: params.identifier,
|
|
36
36
|
transactionNumber: params.transactionNumber,
|
|
@@ -46,13 +46,12 @@ function authorize(params) {
|
|
|
46
46
|
error = (0, errorHandler_1.handlePecorinoError)(error);
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
|
-
return pendingTransaction;
|
|
49
|
+
// return pendingTransaction;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
exports.authorize = authorize;
|
|
53
53
|
function processAccountTransaction(params) {
|
|
54
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
let pendingTransaction;
|
|
56
55
|
const transaction = params.transaction;
|
|
57
56
|
const agent = createAccountTransactionAgent(params);
|
|
58
57
|
const recipient = createAccountTransactionRecipient(params);
|
|
@@ -75,7 +74,7 @@ function processAccountTransaction(params) {
|
|
|
75
74
|
});
|
|
76
75
|
switch (params.typeOf) {
|
|
77
76
|
case factory.account.transactionType.Deposit:
|
|
78
|
-
|
|
77
|
+
yield processDepositTransaction({
|
|
79
78
|
identifier: params.identifier,
|
|
80
79
|
transactionNumber: params.transactionNumber,
|
|
81
80
|
project: params.project,
|
|
@@ -88,7 +87,7 @@ function processAccountTransaction(params) {
|
|
|
88
87
|
})({ permit: permitService });
|
|
89
88
|
break;
|
|
90
89
|
case factory.account.transactionType.Transfer:
|
|
91
|
-
|
|
90
|
+
yield processTransferTransaction({
|
|
92
91
|
identifier: params.identifier,
|
|
93
92
|
transactionNumber: params.transactionNumber,
|
|
94
93
|
project: params.project,
|
|
@@ -101,7 +100,7 @@ function processAccountTransaction(params) {
|
|
|
101
100
|
})({ permit: permitService });
|
|
102
101
|
break;
|
|
103
102
|
case factory.account.transactionType.Withdraw:
|
|
104
|
-
|
|
103
|
+
yield processWithdrawTransaction({
|
|
105
104
|
identifier: params.identifier,
|
|
106
105
|
transactionNumber: params.transactionNumber,
|
|
107
106
|
project: params.project,
|
|
@@ -116,7 +115,7 @@ function processAccountTransaction(params) {
|
|
|
116
115
|
default:
|
|
117
116
|
throw new factory.errors.Argument('Object', 'At least one of accounts from and to must be specified');
|
|
118
117
|
}
|
|
119
|
-
return pendingTransaction;
|
|
118
|
+
// return pendingTransaction;
|
|
120
119
|
});
|
|
121
120
|
}
|
|
122
121
|
function processDepositTransaction(params) {
|
|
@@ -223,9 +223,9 @@ function validateAcceptedOffers(params) {
|
|
|
223
223
|
// 受け入れたオファーIDだけ取得する(2023-01-26~)
|
|
224
224
|
ids: offerIds,
|
|
225
225
|
event: { id: params.event.id },
|
|
226
|
-
// seller: params.seller,
|
|
227
226
|
store: params.store,
|
|
228
|
-
|
|
227
|
+
onlyValid: true,
|
|
228
|
+
addSortIndex: false,
|
|
229
229
|
validateOfferRateLimit: true
|
|
230
230
|
})(repos);
|
|
231
231
|
// 利用可能なチケットオファーであれば受け入れる
|
|
@@ -313,9 +313,8 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
313
313
|
addOn: (Array.isArray(offerWithoutDetail.addOn))
|
|
314
314
|
? offerWithoutDetail.addOn.map((a) => {
|
|
315
315
|
return {
|
|
316
|
-
// project: offer.project,
|
|
317
316
|
typeOf: factory.offerType.Offer,
|
|
318
|
-
id: a.id,
|
|
317
|
+
id: String(a.id),
|
|
319
318
|
priceCurrency: offer.priceCurrency
|
|
320
319
|
};
|
|
321
320
|
})
|
|
@@ -294,7 +294,7 @@ function coaTicket2offer(params) {
|
|
|
294
294
|
const eligibleMembershipType = (params.ticketResult.flgMember === COA.factory.master.FlgMember.Member
|
|
295
295
|
&& typeof ((_b = params.defaultMembershipType) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
296
296
|
? [{
|
|
297
|
-
project: params.defaultMembershipType.project,
|
|
297
|
+
// project: params.defaultMembershipType.project,
|
|
298
298
|
typeOf: params.defaultMembershipType.typeOf,
|
|
299
299
|
id: params.defaultMembershipType.id,
|
|
300
300
|
codeValue: params.defaultMembershipType.codeValue,
|