@chevre/domain 25.2.0-alpha.1 → 25.2.0-alpha.10
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/lib/chevre/repo/action/actionProcess.js +57 -57
- package/lib/chevre/repo/action.d.ts +4 -1
- package/lib/chevre/repo/action.js +3 -2
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +67 -66
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -1
- package/lib/chevre/service/offer/event/authorize/factory.js +10 -12
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/payment/any/authorize.js +6 -32
- package/lib/chevre/service/payment/any/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +22 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +120 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +9 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +109 -93
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +7 -0
- package/lib/chevre/service/transaction/placeOrder/confirm.js +17 -42
- package/package.json +2 -2
|
@@ -19,9 +19,9 @@ exports.AVAILABLE_PROJECT_FIELDS = [
|
|
|
19
19
|
'endDate',
|
|
20
20
|
'purpose',
|
|
21
21
|
'potentialActions',
|
|
22
|
-
'amount',
|
|
23
|
-
'fromLocation',
|
|
24
|
-
'toLocation',
|
|
22
|
+
// 'amount', // discontinue(2026-07-08~)
|
|
23
|
+
// 'fromLocation', // discontinue(2026-07-08~)
|
|
24
|
+
// 'toLocation', // discontinue(2026-07-08~)
|
|
25
25
|
'instrument',
|
|
26
26
|
'location',
|
|
27
27
|
'replacer',
|
|
@@ -322,60 +322,60 @@ class ActionProcessRepo {
|
|
|
322
322
|
startDate: { $lte: startDateLte }
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
-
const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
|
|
326
|
-
if (Array.isArray(fromLocationTypeOfIn)) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
|
|
335
|
-
if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
|
|
344
|
-
if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
|
|
353
|
-
if (Array.isArray(toLocationTypeOfIn)) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
|
|
362
|
-
if (Array.isArray(toLocationAccountNumberIn)) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
|
|
371
|
-
if (Array.isArray(toLocationAccountTypeIn)) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
325
|
+
// const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
|
|
326
|
+
// if (Array.isArray(fromLocationTypeOfIn)) {
|
|
327
|
+
// andConditions.push({
|
|
328
|
+
// 'fromLocation.typeOf': {
|
|
329
|
+
// $exists: true,
|
|
330
|
+
// $in: fromLocationTypeOfIn
|
|
331
|
+
// }
|
|
332
|
+
// });
|
|
333
|
+
// }
|
|
334
|
+
// const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
|
|
335
|
+
// if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
336
|
+
// andConditions.push({
|
|
337
|
+
// 'fromLocation.accountNumber': {
|
|
338
|
+
// $exists: true,
|
|
339
|
+
// $in: fromLocationAccountNumberIn
|
|
340
|
+
// }
|
|
341
|
+
// });
|
|
342
|
+
// }
|
|
343
|
+
// const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
|
|
344
|
+
// if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
345
|
+
// andConditions.push({
|
|
346
|
+
// 'fromLocation.accountType': {
|
|
347
|
+
// $exists: true,
|
|
348
|
+
// $in: fromLocationAccountTypeIn
|
|
349
|
+
// }
|
|
350
|
+
// });
|
|
351
|
+
// }
|
|
352
|
+
// const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
|
|
353
|
+
// if (Array.isArray(toLocationTypeOfIn)) {
|
|
354
|
+
// andConditions.push({
|
|
355
|
+
// 'toLocation.typeOf': {
|
|
356
|
+
// $exists: true,
|
|
357
|
+
// $in: toLocationTypeOfIn
|
|
358
|
+
// }
|
|
359
|
+
// });
|
|
360
|
+
// }
|
|
361
|
+
// const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
|
|
362
|
+
// if (Array.isArray(toLocationAccountNumberIn)) {
|
|
363
|
+
// andConditions.push({
|
|
364
|
+
// 'toLocation.accountNumber': {
|
|
365
|
+
// $exists: true,
|
|
366
|
+
// $in: toLocationAccountNumberIn
|
|
367
|
+
// }
|
|
368
|
+
// });
|
|
369
|
+
// }
|
|
370
|
+
// const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
|
|
371
|
+
// if (Array.isArray(toLocationAccountTypeIn)) {
|
|
372
|
+
// andConditions.push({
|
|
373
|
+
// 'toLocation.accountType': {
|
|
374
|
+
// $exists: true,
|
|
375
|
+
// $in: toLocationAccountTypeIn
|
|
376
|
+
// }
|
|
377
|
+
// });
|
|
378
|
+
// }
|
|
379
379
|
const purposeTypeOfIn = params.purpose?.typeOf?.$in;
|
|
380
380
|
if (Array.isArray(purposeTypeOfIn)) {
|
|
381
381
|
andConditions.push({
|
|
@@ -71,7 +71,10 @@ export declare class ActionRepo extends ActionProcessRepo<IAction<StartableActio
|
|
|
71
71
|
*/
|
|
72
72
|
deleteEndDatePassedCertainPeriod(params: {
|
|
73
73
|
$lt: Date;
|
|
74
|
-
}): Promise<
|
|
74
|
+
}): Promise<{
|
|
75
|
+
deleteActionRecipesResult: import("mongodb").DeleteResult;
|
|
76
|
+
deleteActionsResult: import("mongodb").DeleteResult;
|
|
77
|
+
} | undefined>;
|
|
75
78
|
/**
|
|
76
79
|
* 取引からアクションを削除する
|
|
77
80
|
*/
|
|
@@ -454,7 +454,7 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
454
454
|
async deleteEndDatePassedCertainPeriod(params) {
|
|
455
455
|
const { $lt } = params;
|
|
456
456
|
if ($lt instanceof Date) {
|
|
457
|
-
await this.actionModel.deleteMany({
|
|
457
|
+
const deleteActionsResult = await this.actionModel.deleteMany({
|
|
458
458
|
// 終了日時を一定期間過ぎたもの
|
|
459
459
|
endDate: { $exists: true, $lt }
|
|
460
460
|
})
|
|
@@ -463,10 +463,11 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
463
463
|
const dateCreatedLt = (0, moment_1.default)($lt)
|
|
464
464
|
.add(-1, 'day') // レシピ作成とアクション終了の時間差を考慮
|
|
465
465
|
.toDate();
|
|
466
|
-
await this.actionRecipeModel.deleteMany({
|
|
466
|
+
const deleteActionRecipesResult = await this.actionRecipeModel.deleteMany({
|
|
467
467
|
dateCreated: { $lt: dateCreatedLt }
|
|
468
468
|
})
|
|
469
469
|
.exec();
|
|
470
|
+
return { deleteActionRecipesResult, deleteActionsResult };
|
|
470
471
|
}
|
|
471
472
|
}
|
|
472
473
|
/**
|
|
@@ -904,7 +904,7 @@ class AssetTransactionRepo {
|
|
|
904
904
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
905
905
|
*/
|
|
906
906
|
async deleteEndDatePassedCertainPeriod(params) {
|
|
907
|
-
|
|
907
|
+
return this.transactionModel.deleteMany({
|
|
908
908
|
// 終了日時を一定期間過ぎたもの
|
|
909
909
|
endDate: {
|
|
910
910
|
$exists: true,
|
|
@@ -21,9 +21,9 @@ const schemaDefinition = {
|
|
|
21
21
|
endDate: Date,
|
|
22
22
|
purpose: mongoose_1.SchemaTypes.Mixed,
|
|
23
23
|
potentialActions: mongoose_1.SchemaTypes.Mixed,
|
|
24
|
-
amount:
|
|
25
|
-
fromLocation:
|
|
26
|
-
toLocation:
|
|
24
|
+
// amount: SchemaTypes.Mixed, // discontinue(2026-07-08~)
|
|
25
|
+
// fromLocation: SchemaTypes.Mixed, // discontinue(2026-07-08~)
|
|
26
|
+
// toLocation: SchemaTypes.Mixed, // discontinue(2026-07-08~)
|
|
27
27
|
instrument: mongoose_1.SchemaTypes.Mixed,
|
|
28
28
|
location: mongoose_1.SchemaTypes.Mixed, // add location(2022-11-11~)
|
|
29
29
|
replacer: mongoose_1.SchemaTypes.Mixed, // add replacer(2024-03-19~)
|
|
@@ -221,15 +221,16 @@ const indexes = [
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
],
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
// 承認アクションのobject.event廃止につき検索条件も廃止(2026-07-07~)
|
|
225
|
+
// [
|
|
226
|
+
// { 'object.event.id': 1, startDate: -1 },
|
|
227
|
+
// {
|
|
228
|
+
// name: 'searchByObjectEventId',
|
|
229
|
+
// partialFilterExpression: {
|
|
230
|
+
// 'object.event.id': { $exists: true }
|
|
231
|
+
// }
|
|
232
|
+
// }
|
|
233
|
+
// ],
|
|
233
234
|
[
|
|
234
235
|
{ 'about.id': 1, startDate: -1 },
|
|
235
236
|
{
|
|
@@ -329,60 +330,60 @@ const indexes = [
|
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
],
|
|
332
|
-
[
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
],
|
|
341
|
-
[
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
],
|
|
350
|
-
[
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
],
|
|
359
|
-
[
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
],
|
|
368
|
-
[
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
],
|
|
377
|
-
[
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
],
|
|
333
|
+
// [
|
|
334
|
+
// { 'fromLocation.typeOf': 1, startDate: -1 },
|
|
335
|
+
// {
|
|
336
|
+
// name: 'searchByFromLocationTypeOf',
|
|
337
|
+
// partialFilterExpression: {
|
|
338
|
+
// 'fromLocation.typeOf': { $exists: true }
|
|
339
|
+
// }
|
|
340
|
+
// }
|
|
341
|
+
// ],
|
|
342
|
+
// [
|
|
343
|
+
// { 'fromLocation.accountNumber': 1, startDate: -1 },
|
|
344
|
+
// {
|
|
345
|
+
// name: 'searchByFromLocationAccountNumber',
|
|
346
|
+
// partialFilterExpression: {
|
|
347
|
+
// 'fromLocation.accountNumber': { $exists: true }
|
|
348
|
+
// }
|
|
349
|
+
// }
|
|
350
|
+
// ],
|
|
351
|
+
// [
|
|
352
|
+
// { 'fromLocation.accountType': 1, startDate: -1 },
|
|
353
|
+
// {
|
|
354
|
+
// name: 'searchByFromLocationAccountType',
|
|
355
|
+
// partialFilterExpression: {
|
|
356
|
+
// 'fromLocation.accountType': { $exists: true }
|
|
357
|
+
// }
|
|
358
|
+
// }
|
|
359
|
+
// ],
|
|
360
|
+
// [
|
|
361
|
+
// { 'toLocation.typeOf': 1, startDate: -1 },
|
|
362
|
+
// {
|
|
363
|
+
// name: 'searchByToLocationTypeOf',
|
|
364
|
+
// partialFilterExpression: {
|
|
365
|
+
// 'toLocation.typeOf': { $exists: true }
|
|
366
|
+
// }
|
|
367
|
+
// }
|
|
368
|
+
// ],
|
|
369
|
+
// [
|
|
370
|
+
// { 'toLocation.accountNumber': 1, startDate: -1 },
|
|
371
|
+
// {
|
|
372
|
+
// name: 'searchByToLocationAccountNumber',
|
|
373
|
+
// partialFilterExpression: {
|
|
374
|
+
// 'toLocation.accountNumber': { $exists: true }
|
|
375
|
+
// }
|
|
376
|
+
// }
|
|
377
|
+
// ],
|
|
378
|
+
// [
|
|
379
|
+
// { 'toLocation.accountType': 1, startDate: -1 },
|
|
380
|
+
// {
|
|
381
|
+
// name: 'searchByToLocationAccountType',
|
|
382
|
+
// partialFilterExpression: {
|
|
383
|
+
// 'toLocation.accountType': { $exists: true }
|
|
384
|
+
// }
|
|
385
|
+
// }
|
|
386
|
+
// ],
|
|
386
387
|
[
|
|
387
388
|
{ 'instrument.transactionNumber': 1, startDate: -1 },
|
|
388
389
|
{
|
|
@@ -28,7 +28,6 @@ declare function acceptedOffers2amount(params: {
|
|
|
28
28
|
acceptedOffers: Pick<IResultAcceptedOffer, 'priceSpecification' | 'id'>[];
|
|
29
29
|
}): number;
|
|
30
30
|
declare function acceptedOffers2authorizeResult(params: {
|
|
31
|
-
acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
|
|
32
31
|
acceptedOffers4result: IResultAcceptedOffer[];
|
|
33
32
|
noOfferSpecified: boolean;
|
|
34
33
|
ticketOffers: factory.product.ITicketOffer[];
|
|
@@ -173,9 +173,8 @@ function acceptedOffers2programMembershipUsed(params) {
|
|
|
173
173
|
return programMembershipUsed;
|
|
174
174
|
}
|
|
175
175
|
function acceptedOffers2authorizeResult(params) {
|
|
176
|
-
const {
|
|
177
|
-
const priceCurrency =
|
|
178
|
-
// redefine as typeOf: AggregateOffer(2024-06-18~)
|
|
176
|
+
const { acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
|
|
177
|
+
// const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
|
|
179
178
|
let offers;
|
|
180
179
|
let price;
|
|
181
180
|
let programMembershipUsed = [];
|
|
@@ -183,13 +182,15 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
183
182
|
price = acceptedOffers2amount({ acceptedOffers: acceptedOffers4result }); // オファー指定の場合のみ金額計算(2023-11-27~)
|
|
184
183
|
programMembershipUsed = acceptedOffers2programMembershipUsed({ acceptedOffers: acceptedOffers4result });
|
|
185
184
|
// オファーIDごとに集計
|
|
186
|
-
const offerIds = [...new Set(
|
|
185
|
+
const offerIds = [...new Set(acceptedOffers4result.map((o) => String(o.id)))];
|
|
186
|
+
// const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
|
|
187
187
|
offers = offerIds.map((offerId) => {
|
|
188
188
|
const acceptedOffer = ticketOffers.find(({ id }) => id === offerId);
|
|
189
189
|
if (acceptedOffer === undefined) {
|
|
190
190
|
throw new factory_1.factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
|
|
191
191
|
}
|
|
192
|
-
const amountOfThisGood =
|
|
192
|
+
const amountOfThisGood = acceptedOffers4result.filter(({ id }) => id === offerId).length;
|
|
193
|
+
// const amountOfThisGood: number = acceptedOffers.filter(({ id }) => id === offerId).length;
|
|
193
194
|
const { acceptedPaymentMethod, priceSpecification } = acceptedOffer;
|
|
194
195
|
const unitPriceSpec = priceSpecification.priceComponent.find((spec) => spec.typeOf === factory_1.factory.priceSpecificationType.UnitPriceSpecification
|
|
195
196
|
&& (!Array.isArray(spec.appliesToAddOn)) // アドオン単価ではない
|
|
@@ -197,14 +198,14 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
197
198
|
if (unitPriceSpec === undefined) {
|
|
198
199
|
throw new factory_1.factory.errors.Internal(`unitPriceSpec not found [id:${offerId}]`);
|
|
199
200
|
}
|
|
200
|
-
const { eligibleQuantity
|
|
201
|
+
const { eligibleQuantity } = unitPriceSpec;
|
|
201
202
|
return {
|
|
202
203
|
id: offerId,
|
|
203
204
|
includesObject: { amountOfThisGood },
|
|
204
205
|
typeOf: factory_1.factory.offerType.Offer,
|
|
205
206
|
priceSpecification: {
|
|
206
207
|
...(eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined,
|
|
207
|
-
...(eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined
|
|
208
|
+
// ...(eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined // discontinue(2026-07-05~)
|
|
208
209
|
},
|
|
209
210
|
...(acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined
|
|
210
211
|
};
|
|
@@ -212,14 +213,11 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
212
213
|
}
|
|
213
214
|
return {
|
|
214
215
|
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
215
|
-
priceCurrency,
|
|
216
|
-
amount: [],
|
|
216
|
+
// priceCurrency, // discontinue(2026-07-06~)
|
|
217
|
+
// amount: [], // discontinue(2026-07-06~)
|
|
217
218
|
itemOffered: {
|
|
218
219
|
serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
|
|
219
220
|
},
|
|
220
|
-
// requestBody: {}, // discontinue(2024-06-11~)
|
|
221
|
-
// responseBody: {}, // discontinue(2024-06-11~)
|
|
222
|
-
// acceptedOffers: [] // discontinue(2024-06-17~)
|
|
223
221
|
...(typeof price === 'number') ? { price } : undefined,
|
|
224
222
|
...(Array.isArray(offers)) ? { offers } : undefined
|
|
225
223
|
};
|
|
@@ -78,7 +78,7 @@ function authorize(params, options) {
|
|
|
78
78
|
}
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
|
-
const result = (0, factory_2.acceptedOffers2authorizeResult)({
|
|
81
|
+
const result = (0, factory_2.acceptedOffers2authorizeResult)({ acceptedOffers4result, noOfferSpecified, ticketOffers });
|
|
82
82
|
await repos.authorizeOfferAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
83
83
|
return { id: action.id, result };
|
|
84
84
|
};
|
|
@@ -109,8 +109,8 @@ function authorize(params, options) {
|
|
|
109
109
|
result = {
|
|
110
110
|
typeOf: factory_2.factory.offerType.AggregateOffer, // add(2024-06-18~)
|
|
111
111
|
price: price,
|
|
112
|
-
priceCurrency:
|
|
113
|
-
amount: []
|
|
112
|
+
// priceCurrency: factory.priceCurrency.JPY, // discontinue(2026-07-06~)
|
|
113
|
+
// amount: [] // discontinue(2026-07-06~)
|
|
114
114
|
};
|
|
115
115
|
await (0, any_1.acceptOffer)({
|
|
116
116
|
project: transaction.project,
|
|
@@ -133,7 +133,7 @@ function changeOffers(params) {
|
|
|
133
133
|
const actionResult = {
|
|
134
134
|
...authorizeAction.result,
|
|
135
135
|
price: price,
|
|
136
|
-
amount: []
|
|
136
|
+
// amount: [] // discontinue(2026-07-06~)
|
|
137
137
|
};
|
|
138
138
|
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
139
139
|
await repos.action.reStart({ id: authorizeAction.id, typeOf: authorizeAction.typeOf });
|
|
@@ -209,40 +209,14 @@ function authorize(params) {
|
|
|
209
209
|
* 承認しようとしているobjectからaccountIdを決定する
|
|
210
210
|
*/
|
|
211
211
|
function fixAccountIdIfPossible(params) {
|
|
212
|
-
return async (
|
|
213
|
-
// repos: {
|
|
214
|
-
// action: ActionRepo;
|
|
215
|
-
// authorization: AuthorizationRepo;
|
|
216
|
-
// ticket: TicketRepo;
|
|
217
|
-
// }
|
|
218
|
-
// credentials: {
|
|
219
|
-
// jwt: JWTCredentials;
|
|
220
|
-
// }
|
|
221
|
-
) => {
|
|
212
|
+
return async () => {
|
|
222
213
|
let accountId = '';
|
|
223
|
-
const fromLocation = params.object?.fromLocation;
|
|
214
|
+
// const fromLocation = params.object?.fromLocation;
|
|
224
215
|
const movieTickets = params.object?.movieTickets;
|
|
225
|
-
// discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
226
|
-
if (typeof fromLocation === 'string') {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// const { authorizedObject } = await verifyToken({
|
|
230
|
-
// project: { id: params.project.id },
|
|
231
|
-
// agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
232
|
-
// token: fromLocation
|
|
233
|
-
// })(repos);
|
|
234
|
-
// const paymentCardOwnershipInfo = authorizedObject;
|
|
235
|
-
// if (Array.isArray(paymentCardOwnershipInfo)) {
|
|
236
|
-
// throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
|
|
237
|
-
// }
|
|
238
|
-
// if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
239
|
-
// throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
|
|
240
|
-
// }
|
|
241
|
-
// if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
242
|
-
// throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
243
|
-
// }
|
|
244
|
-
// accountId = paymentCardOwnershipInfo.typeOfGood.identifier;
|
|
245
|
-
}
|
|
216
|
+
// // discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
217
|
+
// if (typeof fromLocation === 'string') {
|
|
218
|
+
// throw new factory.errors.NotImplemented('object.fromLocation as string not implemented');
|
|
219
|
+
// }
|
|
246
220
|
// 購入番号管理番号をaccountIdにセット(2024-03-24~)
|
|
247
221
|
if (Array.isArray(movieTickets) && movieTickets.length > 0) {
|
|
248
222
|
accountId = movieTickets[0].identifier; // 決済カードidentifierは1つのみ許可の前提
|
|
@@ -140,7 +140,7 @@ function creatPayTransactionStartParams(params) {
|
|
|
140
140
|
...(typeof params.object.name === 'string') ? { name: params.object.name } : undefined,
|
|
141
141
|
...(typeof accountId === 'string') ? { accountId } : undefined,
|
|
142
142
|
...(typeof params.object.description === 'string') ? { description: params.object.description } : undefined,
|
|
143
|
-
...(typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined,
|
|
143
|
+
// ...(typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined, // discontinue(2026-07-08~)
|
|
144
144
|
...(params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined,
|
|
145
145
|
...(Array.isArray(movieTickets)) ? { movieTickets } : undefined
|
|
146
146
|
},
|
package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OfferRepo } from '../../../../repo/offer/unitPriceInCatalog';
|
|
2
|
+
import { factory } from '../../../../factory';
|
|
3
|
+
export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction;
|
|
4
|
+
type IOrderAcceptedOffer = Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'offeredThrough' | 'serialNumber' | 'priceSpecification' | 'id'>;
|
|
5
|
+
export declare function createAuthorizeOfferResultsExpected(params: {
|
|
6
|
+
authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[];
|
|
7
|
+
}): Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[];
|
|
8
|
+
/**
|
|
9
|
+
* 注文ドキュメントと予約取引ドキュメントを参照することによって生成した、単価オファー検証条件
|
|
10
|
+
* 元々オファー承認アクションのresultに保管されていた
|
|
11
|
+
*/
|
|
12
|
+
type IPreparedUnitPriceOfferConditions = Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>;
|
|
13
|
+
declare function prepareUnitPriceOfferConditions(params: {
|
|
14
|
+
project: {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
acceptedOffers: IOrderAcceptedOffer[];
|
|
18
|
+
authorizeEventServiceOfferActions: IAuthorizeEventServiceOffer[];
|
|
19
|
+
}): (repos: {
|
|
20
|
+
offer: OfferRepo;
|
|
21
|
+
}) => Promise<IPreparedUnitPriceOfferConditions[]>;
|
|
22
|
+
export { IPreparedUnitPriceOfferConditions, prepareUnitPriceOfferConditions };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createAuthorizeOfferResultsExpected = createAuthorizeOfferResultsExpected;
|
|
7
|
+
exports.prepareUnitPriceOfferConditions = prepareUnitPriceOfferConditions;
|
|
8
|
+
const debug_1 = __importDefault(require("debug"));
|
|
9
|
+
const factory_1 = require("../../../../factory");
|
|
10
|
+
const debug = (0, debug_1.default)('chevre-domain:service:transaction:placeOrder:confirm:prepareUnitPriceOfferConditions');
|
|
11
|
+
function acceptedOffers2authorizeResult(params) {
|
|
12
|
+
const { acceptedOffers4result, unitPriceOffers } = params;
|
|
13
|
+
const programMembershipUsed = acceptedOffers2programMembershipUsed({ acceptedOffers: acceptedOffers4result });
|
|
14
|
+
// オファーIDごとに集計
|
|
15
|
+
const offerIds = [...new Set(acceptedOffers4result.map((o) => String(o.id)))];
|
|
16
|
+
const offers = offerIds.map((offerId) => {
|
|
17
|
+
const acceptedOffer = unitPriceOffers.find(({ id }) => id === offerId);
|
|
18
|
+
if (acceptedOffer === undefined) {
|
|
19
|
+
throw new factory_1.factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
|
|
20
|
+
}
|
|
21
|
+
const amountOfThisGood = acceptedOffers4result.filter(({ id }) => id === offerId).length;
|
|
22
|
+
const { acceptedPaymentMethod, priceSpecification } = acceptedOffer;
|
|
23
|
+
const unitPriceSpec = priceSpecification;
|
|
24
|
+
if (unitPriceSpec === undefined) {
|
|
25
|
+
throw new factory_1.factory.errors.Internal(`unitPriceSpec not found [id:${offerId}]`);
|
|
26
|
+
}
|
|
27
|
+
const { eligibleQuantity } = unitPriceSpec;
|
|
28
|
+
return {
|
|
29
|
+
id: offerId,
|
|
30
|
+
includesObject: { amountOfThisGood },
|
|
31
|
+
typeOf: factory_1.factory.offerType.Offer,
|
|
32
|
+
priceSpecification: {
|
|
33
|
+
...(eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined,
|
|
34
|
+
},
|
|
35
|
+
...(acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
// amount: [], // discontinue(2026-07-06~)
|
|
40
|
+
itemOffered: {
|
|
41
|
+
serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
|
|
42
|
+
},
|
|
43
|
+
offers
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function acceptedOffers2programMembershipUsed(params) {
|
|
47
|
+
const programMembershipUsed = [];
|
|
48
|
+
const permitIdentifiers = [];
|
|
49
|
+
params.acceptedOffers.forEach(({ itemOffered }) => {
|
|
50
|
+
if (itemOffered.programMembershipUsed?.typeOf === factory_1.factory.programMembership.ProgramMembershipType.ProgramMembership) {
|
|
51
|
+
// メンバーシップコードに対してユニークに集計
|
|
52
|
+
if (!permitIdentifiers.includes(itemOffered.programMembershipUsed.identifier)) {
|
|
53
|
+
permitIdentifiers.push(itemOffered.programMembershipUsed.identifier);
|
|
54
|
+
const issuedThroughTypeOf = itemOffered.programMembershipUsed.issuedThrough.typeOf;
|
|
55
|
+
if (issuedThroughTypeOf === factory_1.factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
56
|
+
programMembershipUsed.push({
|
|
57
|
+
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
58
|
+
identifier: itemOffered.programMembershipUsed.identifier,
|
|
59
|
+
issuedThrough: { typeOf: issuedThroughTypeOf }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
programMembershipUsed.push({
|
|
64
|
+
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
65
|
+
identifier: itemOffered.programMembershipUsed.identifier,
|
|
66
|
+
issuedThrough: { typeOf: issuedThroughTypeOf, id: itemOffered.programMembershipUsed.issuedThrough.id }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return programMembershipUsed;
|
|
73
|
+
}
|
|
74
|
+
function createAuthorizeOfferResultsExpected(params) {
|
|
75
|
+
return params.authorizeEventServiceOfferActions.map((a) => {
|
|
76
|
+
return {
|
|
77
|
+
id: a.id,
|
|
78
|
+
result: a.result
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function prepareUnitPriceOfferConditions(params) {
|
|
83
|
+
return async (repos) => {
|
|
84
|
+
// COAの場合は単価オファーを参照せずにそのまま返す
|
|
85
|
+
const isCOA = params.authorizeEventServiceOfferActions.some((action) => action.instrument.typeOf === factory_1.factory.assetTransactionType.COAReserveTransaction);
|
|
86
|
+
if (isCOA) {
|
|
87
|
+
return params.authorizeEventServiceOfferActions.map(({ id, result }) => ({ id, result }));
|
|
88
|
+
}
|
|
89
|
+
const conditions = [];
|
|
90
|
+
const offerIds = [...new Set(params.acceptedOffers.map((o) => String(o.id)))];
|
|
91
|
+
const unitPriceOffers = await repos.offer.search({
|
|
92
|
+
id: { $in: offerIds }
|
|
93
|
+
}, {
|
|
94
|
+
acceptedPaymentMethod: 1,
|
|
95
|
+
priceSpecification: 1,
|
|
96
|
+
});
|
|
97
|
+
debug('unitPriceOffers:', unitPriceOffers);
|
|
98
|
+
for (const authorizeEventServiceOfferAction of params.authorizeEventServiceOfferActions) {
|
|
99
|
+
if (authorizeEventServiceOfferAction.result === undefined) {
|
|
100
|
+
throw new Error('authorizeEventServiceOfferAction.result should exist');
|
|
101
|
+
}
|
|
102
|
+
const acceptedOffers4action = params.acceptedOffers.filter(((offer) => {
|
|
103
|
+
return offer.serialNumber === authorizeEventServiceOfferAction.instrument.transactionNumber;
|
|
104
|
+
}));
|
|
105
|
+
conditions.push({
|
|
106
|
+
id: authorizeEventServiceOfferAction.id,
|
|
107
|
+
result: {
|
|
108
|
+
typeOf: authorizeEventServiceOfferAction.result.typeOf,
|
|
109
|
+
// priceCurrency: authorizeEventServiceOfferAction.result.priceCurrency,
|
|
110
|
+
price: authorizeEventServiceOfferAction.result.price,
|
|
111
|
+
...acceptedOffers2authorizeResult({
|
|
112
|
+
acceptedOffers4result: acceptedOffers4action,
|
|
113
|
+
unitPriceOffers
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return conditions;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { factory } from '../../../../factory';
|
|
2
2
|
import { PlaceOrderFactory } from '../../../../factory/transaction';
|
|
3
|
+
import { IPreparedUnitPriceOfferConditions } from './prepareUnitPriceOfferConditions';
|
|
3
4
|
import { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IPayTransaction } from './validation/factory';
|
|
4
5
|
export { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IPayTransaction };
|
|
5
6
|
/**
|
|
@@ -35,9 +36,16 @@ export declare function validatePaymentMethods(params: {
|
|
|
35
36
|
* 興行オファー適用条件確認
|
|
36
37
|
*/
|
|
37
38
|
export declare function validateEventOffers(params: {
|
|
39
|
+
project: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
38
42
|
order: {
|
|
39
43
|
price: number;
|
|
40
44
|
};
|
|
41
45
|
paymentMethods: factory.order.IReferencedInvoice[];
|
|
42
|
-
|
|
46
|
+
/**
|
|
47
|
+
* 承認アクションのresultに条件が保管されているはず(2026-07-06時点で)
|
|
48
|
+
*/
|
|
49
|
+
authorizeOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[];
|
|
50
|
+
unitPriceOfferConditions?: IPreparedUnitPriceOfferConditions[];
|
|
43
51
|
}): void;
|
|
@@ -17,23 +17,20 @@ const factory_1 = require("../../../../factory");
|
|
|
17
17
|
const validateInvoiceReferencesOrder_1 = require("./validation/validateInvoiceReferencesOrder");
|
|
18
18
|
const validateMovieTicket_1 = require("./validation/validateMovieTicket");
|
|
19
19
|
const validatePrice_1 = require("./validation/validatePrice");
|
|
20
|
-
const debug = (0, debug_1.default)('chevre-domain:service:transaction');
|
|
20
|
+
const debug = (0, debug_1.default)('chevre-domain:service:transaction:placeOrder:confirm:validation');
|
|
21
21
|
/**
|
|
22
22
|
* 取引が確定可能な状態かどうかをチェックする
|
|
23
23
|
*/
|
|
24
|
-
function validateTransaction(transaction, acceptPayActions, authorizePaymentActions, authorizeEventServiceOfferActions,
|
|
25
|
-
// authorizeProductOfferActions: Pick<IAuthorizeProductOffer, 'id' | 'result'>[],
|
|
26
|
-
eventReservationAcceptedOffers, payTransactions, customer) {
|
|
24
|
+
function validateTransaction(transaction, acceptPayActions, authorizePaymentActions, authorizeEventServiceOfferActions, eventReservationAcceptedOffers, payTransactions, customer) {
|
|
27
25
|
// validateProfile(transaction);
|
|
28
26
|
validateProfile({ customer });
|
|
29
27
|
(0, validatePrice_1.validatePrice)(authorizePaymentActions, authorizeEventServiceOfferActions);
|
|
30
28
|
// 請求のreferencesOrder検証(2025-11-23~)
|
|
31
29
|
(0, validateInvoiceReferencesOrder_1.validateInvoiceReferencesOrder)(authorizePaymentActions, eventReservationAcceptedOffers);
|
|
32
|
-
// 利用可能な通貨単位に対して取引検証
|
|
33
|
-
validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOfferActions);
|
|
30
|
+
// // 利用可能な通貨単位に対して取引検証
|
|
31
|
+
// validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOfferActions); // discontinue(2026-07-06~)
|
|
34
32
|
// 利用可能なMovieTicketIF決済方法タイプに対して動的にコーディング
|
|
35
33
|
const movieTicketPaymentMethodTypes = findMovieTicketPaymentMethodTypesFromTransaction(authorizePaymentActions, eventReservationAcceptedOffers);
|
|
36
|
-
debug('processing validateMovieTicket... movieTicketPaymentMethodTypes:', movieTicketPaymentMethodTypes);
|
|
37
34
|
if (Array.isArray(movieTicketPaymentMethodTypes) && movieTicketPaymentMethodTypes.length > 0) {
|
|
38
35
|
movieTicketPaymentMethodTypes.forEach((paymentMethodType) => {
|
|
39
36
|
const authorizeMovieTicketActions = authorizePaymentActions.filter((a) => {
|
|
@@ -59,7 +56,6 @@ eventReservationAcceptedOffers, payTransactions, customer) {
|
|
|
59
56
|
authorizedMovieTickets.push(...object.paymentMethod.movieTickets);
|
|
60
57
|
}
|
|
61
58
|
});
|
|
62
|
-
debug(authorizedMovieTickets.length, 'movie tickets authorized', 'transaction:', transaction.id);
|
|
63
59
|
// validateMovieTicket(paymentMethodType, { id: transaction.id }, authorizePaymentActions, eventReservationAcceptedOffers);
|
|
64
60
|
(0, validateMovieTicket_1.validateMovieTicket)(paymentMethodType, { id: transaction.id }, authorizedMovieTickets, eventReservationAcceptedOffers);
|
|
65
61
|
});
|
|
@@ -95,18 +91,6 @@ function findMovieTicketPaymentMethodTypesFromTransaction(authorizePaymentAction
|
|
|
95
91
|
// ];
|
|
96
92
|
return [...new Set(paymentMethodTypes)];
|
|
97
93
|
}
|
|
98
|
-
// function validateProfile(transaction: Pick<factory.transaction.placeOrder.ITransaction, 'object'>) {
|
|
99
|
-
// // object.customerで検証(2022-05-26~)
|
|
100
|
-
// const profile = transaction.object.customer;
|
|
101
|
-
// const profileSatisfied = typeof profile?.typeOf === 'string' && profile.typeOf.length > 0
|
|
102
|
-
// && typeof profile.email === 'string' && profile.email.length > 0
|
|
103
|
-
// && typeof profile.familyName === 'string' && profile.familyName.length > 0
|
|
104
|
-
// && typeof profile.givenName === 'string' && profile.givenName.length > 0
|
|
105
|
-
// && typeof profile.telephone === 'string' && profile.telephone.length > 0;
|
|
106
|
-
// if (!profileSatisfied) {
|
|
107
|
-
// throw new factory.errors.Argument('Transaction', 'Customer Profile Required');
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
94
|
function validateProfile(params) {
|
|
111
95
|
const profile = params.customer;
|
|
112
96
|
const profileSatisfied = typeof profile?.typeOf === 'string' && profile.typeOf.length > 0
|
|
@@ -148,63 +132,63 @@ function validatePaymentUrl(transaction, acceptPayActions, authorizePaymentActio
|
|
|
148
132
|
}
|
|
149
133
|
}
|
|
150
134
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
135
|
+
// JPY以外の通貨決済はひとまず廃止(2026-07-06~)
|
|
136
|
+
// /**
|
|
137
|
+
// * JPY以外の通貨について取引を検証する
|
|
138
|
+
// */
|
|
139
|
+
// function validateMonetaryAmount(
|
|
140
|
+
// _authorizePaymentActions: IAuthorizePaymentAction[],
|
|
141
|
+
// authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'result'>[]
|
|
142
|
+
// ) {
|
|
143
|
+
// // PaymentCard決済を廃止したので、JPY以外の通貨に対しての承認はありえない(2026-04-18~)
|
|
144
|
+
// const authorizeMonetaryAmountActions: IAuthorizePaymentAction[] = [];
|
|
145
|
+
// const requiredMonetaryAmountByCurrencyType: {
|
|
146
|
+
// currency: string;
|
|
147
|
+
// value: number;
|
|
148
|
+
// }[] = [];
|
|
149
|
+
// authorizeEventServiceOfferActions.forEach(
|
|
150
|
+
// (a) => {
|
|
151
|
+
// const amount = a.result?.amount;
|
|
152
|
+
// if (Array.isArray(amount)) {
|
|
153
|
+
// amount.forEach((monetaryAmount) => {
|
|
154
|
+
// if (typeof monetaryAmount.value === 'number') {
|
|
155
|
+
// requiredMonetaryAmountByCurrencyType.push({ currency: monetaryAmount.currency, value: monetaryAmount.value });
|
|
156
|
+
// }
|
|
157
|
+
// });
|
|
158
|
+
// }
|
|
159
|
+
// },
|
|
160
|
+
// 0
|
|
161
|
+
// );
|
|
162
|
+
// const requiredCurrencyTypes = [...new Set(requiredMonetaryAmountByCurrencyType.map((m) => m.currency))];
|
|
163
|
+
// const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map(({ result }) => {
|
|
164
|
+
// const resultAsInvoice = (Array.isArray(result))
|
|
165
|
+
// ? result[0]
|
|
166
|
+
// : undefined;
|
|
167
|
+
// return resultAsInvoice?.totalPaymentDue?.currency as string;
|
|
168
|
+
// }
|
|
169
|
+
// ))];
|
|
170
|
+
// if (requiredCurrencyTypes.length !== authorizedCurrencyTypes.length) {
|
|
171
|
+
// throw new factory.errors.Argument('Transaction', 'MonetaryAmount account types not matched');
|
|
172
|
+
// }
|
|
173
|
+
// const requireMonetaryAmountSatisfied = requiredCurrencyTypes.every((currencyType) => {
|
|
174
|
+
// const requiredMonetaryAmount = requiredMonetaryAmountByCurrencyType
|
|
175
|
+
// .filter((m) => m.currency === currencyType)
|
|
176
|
+
// .reduce((a, b) => a + b.value, 0);
|
|
177
|
+
// let authorizedMonetaryAmount = 0;
|
|
178
|
+
// authorizeMonetaryAmountActions.forEach(({ result }) => {
|
|
179
|
+
// const resultAsInvoice = (Array.isArray(result))
|
|
180
|
+
// ? result[0]
|
|
181
|
+
// : undefined;
|
|
182
|
+
// if (resultAsInvoice?.totalPaymentDue?.currency === currencyType) {
|
|
183
|
+
// authorizedMonetaryAmount += resultAsInvoice.totalPaymentDue.value;
|
|
184
|
+
// }
|
|
185
|
+
// });
|
|
186
|
+
// return requiredMonetaryAmount === authorizedMonetaryAmount;
|
|
187
|
+
// });
|
|
188
|
+
// if (!requireMonetaryAmountSatisfied) {
|
|
189
|
+
// throw new factory.errors.Argument('Transaction', 'Required MonetaryAmount not satisfied');
|
|
190
|
+
// }
|
|
191
|
+
// }
|
|
208
192
|
/**
|
|
209
193
|
* 注文オファー数検証
|
|
210
194
|
*/
|
|
@@ -257,7 +241,6 @@ function validateAcceptedOffers(params) {
|
|
|
257
241
|
});
|
|
258
242
|
if (ticketIdentifiers.length > 0) {
|
|
259
243
|
ticketIdentifiers = [...new Set(ticketIdentifiers)];
|
|
260
|
-
debug('ticketIdentifiers unique?', ticketIdentifiers.join(' '), 'numAcceptedOffers:', numAcceptedOffers);
|
|
261
244
|
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
262
245
|
if (ticketIdentifiers.length !== numAcceptedOffers) {
|
|
263
246
|
throw new factory_1.factory.errors.Argument('Transaction', 'ticketIdentifiers must be unique');
|
|
@@ -274,7 +257,6 @@ function validateAcceptedOffers(params) {
|
|
|
274
257
|
});
|
|
275
258
|
if (ticketNumbers.length > 0) {
|
|
276
259
|
ticketNumbers = [...new Set(ticketNumbers)];
|
|
277
|
-
debug('ticketNumbers unique?', ticketNumbers.join(' '), 'numAcceptedOffers:', numAcceptedOffers);
|
|
278
260
|
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
279
261
|
if (ticketNumbers.length !== numAcceptedOffers) {
|
|
280
262
|
throw new factory_1.factory.errors.Argument('Transaction', 'ticketNumbers must be unique');
|
|
@@ -313,6 +295,34 @@ function validatePaymentMethods(params, options) {
|
|
|
313
295
|
* 興行オファー適用条件確認
|
|
314
296
|
*/
|
|
315
297
|
function validateEventOffers(params) {
|
|
298
|
+
const { unitPriceOfferConditions } = params;
|
|
299
|
+
/**
|
|
300
|
+
* 以下処理で検証に使用するアクション結果リスト
|
|
301
|
+
*/
|
|
302
|
+
let validatingAuthorizeOfferActions;
|
|
303
|
+
// 承認アクションと比較する
|
|
304
|
+
if (Array.isArray(unitPriceOfferConditions)) {
|
|
305
|
+
const everyActionsMatched = unitPriceOfferConditions.length === params.authorizeOfferActions.length
|
|
306
|
+
&& params.authorizeOfferActions.every((authorizeEventServiceOfferAction) => {
|
|
307
|
+
const conditionExpected = unitPriceOfferConditions.find(({ id }) => id === authorizeEventServiceOfferAction.id);
|
|
308
|
+
const resultMatched = (0, util_1.isDeepStrictEqual)(conditionExpected?.result, authorizeEventServiceOfferAction.result);
|
|
309
|
+
debug('validateEventOffers: unitPriceOfferConditions: resultMatched?', resultMatched, params.project.id, authorizeEventServiceOfferAction.id);
|
|
310
|
+
if (!resultMatched) {
|
|
311
|
+
console.error('validateEventOffers: unitPriceOfferConditions not matched!', params.project.id, authorizeEventServiceOfferAction.id, conditionExpected?.result, authorizeEventServiceOfferAction.result);
|
|
312
|
+
}
|
|
313
|
+
return resultMatched;
|
|
314
|
+
});
|
|
315
|
+
// 全アクションについて結果が一致していればunitPriceOfferConditionsを採用する(2026-07-07~)
|
|
316
|
+
if (everyActionsMatched) {
|
|
317
|
+
validatingAuthorizeOfferActions = [...unitPriceOfferConditions];
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
validatingAuthorizeOfferActions = [...params.authorizeOfferActions];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
validatingAuthorizeOfferActions = [...params.authorizeOfferActions];
|
|
325
|
+
}
|
|
316
326
|
const { paymentMethods } = params;
|
|
317
327
|
const firstCreditCardPaymentMethodIdentifier = paymentMethods.find((referenceInvoice) => {
|
|
318
328
|
return referenceInvoice.issuedThrough.typeOf === factory_1.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
@@ -322,37 +332,44 @@ function validateEventOffers(params) {
|
|
|
322
332
|
return referenceInvoice.issuedThrough.typeOf === factory_1.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
323
333
|
|| referenceInvoice.issuedThrough.typeOf === factory_1.factory.service.paymentService.PaymentServiceType.FaceToFace;
|
|
324
334
|
}).length;
|
|
325
|
-
|
|
335
|
+
validatingAuthorizeOfferActions.forEach((a) => {
|
|
326
336
|
// support result.offers(2024-06-18~)
|
|
327
337
|
const acceptedOffersInResult = a.result?.offers;
|
|
328
338
|
if (Array.isArray(acceptedOffersInResult) && acceptedOffersInResult.length > 0) {
|
|
329
339
|
acceptedOffersInResult.forEach((acceptedOfferInResult) => {
|
|
330
340
|
const offerId = acceptedOfferInResult.id;
|
|
331
341
|
const unitPriceSpec = acceptedOfferInResult.priceSpecification;
|
|
332
|
-
//
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
// 適用金額要件は廃止(2026-07-05~)
|
|
343
|
+
// // 適用金額要件を満たしていなければエラー
|
|
344
|
+
// const eligibleTransactionVolumePrice = unitPriceSpec?.eligibleTransactionVolume?.price;
|
|
345
|
+
// const eligibleTransactionVolumePriceCurrency = unitPriceSpec?.eligibleTransactionVolume?.priceCurrency;
|
|
346
|
+
// if (typeof eligibleTransactionVolumePrice === 'number') {
|
|
347
|
+
// if (params.order.price < eligibleTransactionVolumePrice) {
|
|
348
|
+
// throw new factory.errors.Argument(
|
|
349
|
+
// 'Transaction',
|
|
350
|
+
// format(
|
|
351
|
+
// 'Transaction volume must be more than or equal to %s %s for offer:%s',
|
|
352
|
+
// eligibleTransactionVolumePrice,
|
|
353
|
+
// eligibleTransactionVolumePriceCurrency,
|
|
354
|
+
// offerId
|
|
355
|
+
// )
|
|
356
|
+
// );
|
|
357
|
+
// }
|
|
358
|
+
// }
|
|
340
359
|
// 適用数量検証(全興行オファー承認アクションについて)(2023-11-15~)
|
|
341
360
|
// 適用数量要件を満たしていなければエラー
|
|
342
|
-
const numAcceptedOffersByOfferId =
|
|
361
|
+
const numAcceptedOffersByOfferId = validatingAuthorizeOfferActions.reduce((previousNumOffer, { result }) => {
|
|
343
362
|
const numOfferOnCurrentAction = result?.offers?.find(({ id }) => id === offerId)?.includesObject.amountOfThisGood;
|
|
344
363
|
return previousNumOffer + ((typeof numOfferOnCurrentAction === 'number') ? numOfferOnCurrentAction : 0);
|
|
345
364
|
}, 0);
|
|
346
365
|
const eligibleQuantityMaxValue = unitPriceSpec?.eligibleQuantity?.maxValue;
|
|
347
366
|
if (typeof eligibleQuantityMaxValue === 'number') {
|
|
348
|
-
debug('validateEventOffers: numAcceptedOffersByOfferId > eligibleQuantityMaxValue?', numAcceptedOffersByOfferId, eligibleQuantityMaxValue);
|
|
349
367
|
if (numAcceptedOffersByOfferId > eligibleQuantityMaxValue) {
|
|
350
368
|
throw new factory_1.factory.errors.Argument('Transaction', `Number of offer:${offerId} must be less than or equal to ${eligibleQuantityMaxValue}`);
|
|
351
369
|
}
|
|
352
370
|
}
|
|
353
371
|
const eligibleQuantityMinValue = unitPriceSpec?.eligibleQuantity?.minValue;
|
|
354
372
|
if (typeof eligibleQuantityMinValue === 'number') {
|
|
355
|
-
debug('validateEventOffers: numAcceptedOffersByOfferId < eligibleQuantityMinValue?', numAcceptedOffersByOfferId, eligibleQuantityMinValue);
|
|
356
373
|
if (numAcceptedOffersByOfferId < eligibleQuantityMinValue) {
|
|
357
374
|
throw new factory_1.factory.errors.Argument('Transaction', `Number of offer:${offerId} must be more than or equal to ${eligibleQuantityMinValue}`);
|
|
358
375
|
}
|
|
@@ -363,7 +380,6 @@ function validateEventOffers(params) {
|
|
|
363
380
|
const satisfyAcceptedPaymentMethod = numCreditCardOrFaceToFacePaymentMethod === 1
|
|
364
381
|
&& typeof firstCreditCardPaymentMethodIdentifier === 'string'
|
|
365
382
|
&& acceptedPaymentMethodTypes.includes(firstCreditCardPaymentMethodIdentifier);
|
|
366
|
-
debug('validateEventOffers: satisfyAcceptedPaymentMethod?', JSON.stringify(acceptedPaymentMethodTypes));
|
|
367
383
|
if (!satisfyAcceptedPaymentMethod) {
|
|
368
384
|
throw new factory_1.factory.errors.Argument('Transaction', `acceptedPaymentMethod requirement not satisfied`);
|
|
369
385
|
}
|
|
@@ -372,7 +388,7 @@ function validateEventOffers(params) {
|
|
|
372
388
|
}
|
|
373
389
|
});
|
|
374
390
|
// check programMembershipUsed(2024-08-15~)
|
|
375
|
-
const programMembershipRequired =
|
|
391
|
+
const programMembershipRequired = validatingAuthorizeOfferActions.reduce((a, b) => {
|
|
376
392
|
const programMembershipUsedfromResult = b.result?.itemOffered?.serviceOutput.programMembershipUsed;
|
|
377
393
|
if (Array.isArray(programMembershipUsedfromResult)) {
|
|
378
394
|
a.push(...programMembershipUsedfromResult);
|
|
@@ -5,6 +5,7 @@ import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
|
5
5
|
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
6
6
|
import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
7
7
|
import type { MessageRepo } from '../../../repo/message';
|
|
8
|
+
import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
|
|
8
9
|
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
9
10
|
import type { ProjectRepo } from '../../../repo/project';
|
|
10
11
|
import type { SettingRepo } from '../../../repo/setting';
|
|
@@ -19,6 +20,7 @@ interface IConfirmOperationRepos {
|
|
|
19
20
|
assetTransaction: AssetTransactionRepo;
|
|
20
21
|
authorization: AuthorizationRepo;
|
|
21
22
|
message: MessageRepo;
|
|
23
|
+
offer: OfferRepo;
|
|
22
24
|
project: ProjectRepo;
|
|
23
25
|
placeOrder: PlaceOrderRepo;
|
|
24
26
|
orderInTransaction: OrderInTransactionRepo;
|
|
@@ -39,6 +41,11 @@ interface IConfirmOptions {
|
|
|
39
41
|
* 注文における最大CreditCardIF決済方法数
|
|
40
42
|
*/
|
|
41
43
|
maxNumCreditCardPaymentMethod: number;
|
|
44
|
+
/**
|
|
45
|
+
* 2026-07-06~
|
|
46
|
+
* 実験的に
|
|
47
|
+
*/
|
|
48
|
+
usePrepareUnitPriceOfferConditions?: boolean;
|
|
42
49
|
}
|
|
43
50
|
type IConfirmParams = PlaceOrderFactory.IConfirmParams;
|
|
44
51
|
interface IConfirmResult {
|
|
@@ -12,6 +12,7 @@ const factory_2 = require("../../order/placeOrder/factory");
|
|
|
12
12
|
const orderedItem_1 = require("../../order/placeOrder/factory/orderedItem");
|
|
13
13
|
const result_1 = require("./confirm/factory/result");
|
|
14
14
|
const potentialActions_1 = require("./confirm/potentialActions");
|
|
15
|
+
const prepareUnitPriceOfferConditions_1 = require("./confirm/prepareUnitPriceOfferConditions");
|
|
15
16
|
const publishCode_1 = require("./confirm/publishCode");
|
|
16
17
|
const validation_1 = require("./confirm/validation");
|
|
17
18
|
const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
|
|
@@ -114,6 +115,16 @@ function confirm(params, options) {
|
|
|
114
115
|
project: { id: transaction.project.id }
|
|
115
116
|
}))
|
|
116
117
|
.filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
|
|
118
|
+
// 単価オファーの全適用条件を検証するために、単価オファーを参照(2026-07-06~)
|
|
119
|
+
let unitPriceOfferConditions;
|
|
120
|
+
const { usePrepareUnitPriceOfferConditions } = options;
|
|
121
|
+
if (usePrepareUnitPriceOfferConditions === true) {
|
|
122
|
+
unitPriceOfferConditions = await (0, prepareUnitPriceOfferConditions_1.prepareUnitPriceOfferConditions)({
|
|
123
|
+
project: { id: transaction.project.id, },
|
|
124
|
+
acceptedOffers,
|
|
125
|
+
authorizeEventServiceOfferActions
|
|
126
|
+
})({ offer: repos.offer });
|
|
127
|
+
}
|
|
117
128
|
// authorizePaymentActionsからpayTransactionsを参照(2024-06-20~)
|
|
118
129
|
let payTransactions = [];
|
|
119
130
|
// 決済承認アクションのinstrument依存をobject依存へ変更(2025-12-14~)
|
|
@@ -134,22 +145,10 @@ function confirm(params, options) {
|
|
|
134
145
|
orderNumber, transaction,
|
|
135
146
|
acceptPayActions,
|
|
136
147
|
authorizePaymentActions, authorizeEventServiceOfferActions,
|
|
137
|
-
// authorizeProductOfferActions,
|
|
138
148
|
acceptedOffers, payTransactions, customer,
|
|
139
|
-
...(typeof code === 'string') ? { code } : undefined
|
|
149
|
+
...(typeof code === 'string') ? { code } : undefined,
|
|
150
|
+
...((Array.isArray(unitPriceOfferConditions)) && { unitPriceOfferConditions })
|
|
140
151
|
}, options);
|
|
141
|
-
// discontinue emailMessageRepo
|
|
142
|
-
// // デフォルトEメールメッセージを検索
|
|
143
|
-
// let emailMessageOnOrderSent: factory.creativeWork.message.email.ICreativeWork | undefined;
|
|
144
|
-
// if (repos.emailMessage !== undefined) {
|
|
145
|
-
// const searchEmailMessagesResult = await repos.emailMessage.search({
|
|
146
|
-
// limit: 1,
|
|
147
|
-
// page: 1,
|
|
148
|
-
// project: { id: { $eq: transaction.project.id } },
|
|
149
|
-
// about: { identifier: { $eq: factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
|
|
150
|
-
// });
|
|
151
|
-
// emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
152
|
-
// }
|
|
153
152
|
// ポストアクションを作成
|
|
154
153
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['defaultSenderEmail']);
|
|
155
154
|
if (typeof setting?.defaultSenderEmail !== 'string') {
|
|
@@ -319,17 +318,17 @@ function createResult(params, options) {
|
|
|
319
318
|
}
|
|
320
319
|
});
|
|
321
320
|
// 取引の確定条件が全て整っているかどうか確認
|
|
322
|
-
(0, validation_1.validateTransaction)(transaction, params.acceptPayActions, params.authorizePaymentActions, params.authorizeEventServiceOfferActions,
|
|
323
|
-
// params.authorizeProductOfferActions,
|
|
324
|
-
eventReservationAcceptedOffers, params.payTransactions, params.customer);
|
|
321
|
+
(0, validation_1.validateTransaction)(transaction, params.acceptPayActions, params.authorizePaymentActions, params.authorizeEventServiceOfferActions, eventReservationAcceptedOffers, params.payTransactions, params.customer);
|
|
325
322
|
const { paymentMethods, price } = (0, factory_2.createPaymentMethods)({ authorizePaymentActions: params.authorizePaymentActions });
|
|
326
323
|
const orderedItem = (0, orderedItem_1.acceptedOffers2orderedItem)({
|
|
327
324
|
eventReservationAcceptedOffers
|
|
328
325
|
});
|
|
329
326
|
(0, validation_1.validateEventOffers)({
|
|
327
|
+
project: { id: transaction.project.id },
|
|
330
328
|
order: { price },
|
|
331
329
|
paymentMethods,
|
|
332
|
-
|
|
330
|
+
authorizeOfferActions: params.authorizeEventServiceOfferActions,
|
|
331
|
+
...((Array.isArray(params.unitPriceOfferConditions)) && { unitPriceOfferConditions: params.unitPriceOfferConditions })
|
|
333
332
|
});
|
|
334
333
|
// 注文オファー検証
|
|
335
334
|
(0, validation_1.validateAcceptedOffers)({
|
|
@@ -390,21 +389,6 @@ function createResult(params, options) {
|
|
|
390
389
|
}
|
|
391
390
|
function searchAcceptPayActions(params) {
|
|
392
391
|
return async (repos) => {
|
|
393
|
-
// let acceptPayActions = <IAcceptPayAction[]>await repos.action.search(
|
|
394
|
-
// {
|
|
395
|
-
// project: { id: { $eq: params.project.id } },
|
|
396
|
-
// typeOf: { $eq: factory.actionType.AcceptAction },
|
|
397
|
-
// actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
398
|
-
// purpose: {
|
|
399
|
-
// id: { $in: [params.id] },
|
|
400
|
-
// typeOf: { $in: [factory.transactionType.PlaceOrder] }
|
|
401
|
-
// },
|
|
402
|
-
// object: {
|
|
403
|
-
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
404
|
-
// }
|
|
405
|
-
// },
|
|
406
|
-
// ['object', 'endDate', 'result']
|
|
407
|
-
// );
|
|
408
392
|
let acceptPayActions = await repos.acceptPayAction.findAcceptActionsByPurpose({
|
|
409
393
|
project: { id: params.project.id },
|
|
410
394
|
actionStatus: factory_1.factory.actionStatusType.CompletedActionStatus,
|
|
@@ -423,15 +407,6 @@ function searchAcceptPayActions(params) {
|
|
|
423
407
|
function searchAuthorizeActions(params) {
|
|
424
408
|
return async (repos) => {
|
|
425
409
|
// 取引に対する全ての承認アクションをマージ
|
|
426
|
-
// let authorizeActions = <IAuthorizeOfferOrPaymentAction[]>await repos.action.searchByPurpose({
|
|
427
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
428
|
-
// purpose: {
|
|
429
|
-
// typeOf: factory.transactionType.PlaceOrder,
|
|
430
|
-
// id: params.id
|
|
431
|
-
// },
|
|
432
|
-
// // Completedに絞る(2023-05-16~)
|
|
433
|
-
// actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
434
|
-
// });
|
|
435
410
|
let authorizeActions = [
|
|
436
411
|
...await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodActionsByPurpose({
|
|
437
412
|
purpose: {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "9.5.0-alpha.
|
|
14
|
+
"@chevre/factory": "9.5.0-alpha.5",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "25.2.0-alpha.
|
|
94
|
+
"version": "25.2.0-alpha.10"
|
|
95
95
|
}
|