@chevre/domain 22.2.0-alpha.0 → 22.2.0-alpha.2
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/service/assetTransaction/reserve/start/createSubReservations.js +61 -27
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +9 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +26 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +127 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +12 -32
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +5 -1
- package/package.json +2 -2
|
@@ -271,43 +271,73 @@ function validateAdvanceBookingRequirement(params) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
function validateProgramMembershipUsed(params) {
|
|
274
|
-
// tslint:disable-next-line:max-func-body-length
|
|
274
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
275
275
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
276
|
-
var _a, _b, _c;
|
|
276
|
+
var _a, _b, _c, _d, _e, _f;
|
|
277
277
|
const now = new Date();
|
|
278
278
|
let programMembershipUsed;
|
|
279
279
|
const requestedProgramMembershipUsed = (_b = (_a = params.acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
|
|
280
280
|
if (typeof requestedProgramMembershipUsed === 'string') {
|
|
281
|
-
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'must be
|
|
281
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'must be permit');
|
|
282
|
+
}
|
|
283
|
+
if ((requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.typeOf) === 'Ticket') {
|
|
284
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'must be permit');
|
|
282
285
|
}
|
|
283
286
|
const programMembershipUsedIdentifier = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.identifier;
|
|
284
|
-
const
|
|
285
|
-
if (typeof programMembershipUsedIdentifier === 'string'
|
|
286
|
-
if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
|
|
287
|
-
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
288
|
-
}
|
|
287
|
+
const issuedThroughTypeOf = (_c = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
288
|
+
if (typeof programMembershipUsedIdentifier === 'string') {
|
|
289
289
|
let permitIssuedThrough;
|
|
290
290
|
// まずメンバーシップを検索して、存在しなければCreditCardを検索(どちらが発行元サービスか不明なので)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
291
|
+
if (issuedThroughTypeOf === factory.product.ProductType.MembershipService) {
|
|
292
|
+
const issuedThroughId = (_d = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _d === void 0 ? void 0 : _d.id;
|
|
293
|
+
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
294
|
+
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
295
|
+
}
|
|
296
|
+
permitIssuedThrough = (yield repos.product.searchProducts({
|
|
297
|
+
limit: 1,
|
|
298
|
+
page: 1,
|
|
299
|
+
id: { $eq: issuedThroughId },
|
|
300
|
+
typeOf: { $eq: factory.product.ProductType.MembershipService }
|
|
301
|
+
}, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
|
|
302
|
+
if (permitIssuedThrough === undefined) {
|
|
303
|
+
throw new factory.errors.NotFound(factory.product.ProductType.MembershipService);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
307
|
+
const issuedThroughId = (_e = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _e === void 0 ? void 0 : _e.id;
|
|
308
|
+
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
309
|
+
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
310
|
+
}
|
|
298
311
|
permitIssuedThrough = (yield repos.paymentService.searchPaymentServices({
|
|
299
312
|
limit: 1,
|
|
300
313
|
page: 1,
|
|
301
314
|
id: { $eq: issuedThroughId },
|
|
302
315
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
303
316
|
}, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
|
|
317
|
+
if (permitIssuedThrough === undefined) {
|
|
318
|
+
throw new factory.errors.NotFound(factory.service.paymentService.PaymentServiceType.CreditCard);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
322
|
+
// プロダクトは存在しないので特に検証なし
|
|
323
|
+
permitIssuedThrough = {
|
|
324
|
+
typeOf: factory.service.paymentService.PaymentServiceType.FaceToFace
|
|
325
|
+
};
|
|
304
326
|
}
|
|
305
|
-
|
|
306
|
-
throw new factory.errors.
|
|
327
|
+
else {
|
|
328
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
307
329
|
}
|
|
308
|
-
// permitIssuedThrough =
|
|
309
|
-
// await repos.product.findById({ id: issuedThroughId }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], []);
|
|
310
330
|
switch (permitIssuedThrough.typeOf) {
|
|
331
|
+
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
332
|
+
// 問答無用に受け入れる
|
|
333
|
+
programMembershipUsed = {
|
|
334
|
+
typeOf: factory.permit.PermitType.Permit,
|
|
335
|
+
identifier: programMembershipUsedIdentifier,
|
|
336
|
+
issuedThrough: {
|
|
337
|
+
typeOf: permitIssuedThrough.typeOf
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
break;
|
|
311
341
|
// 発行サービスがCreditCardのケースに対応(2023-09-01~)
|
|
312
342
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
313
343
|
// 決済サービスのserviceOutputにPermitが存在すれば、設定されたメンバーシップ区分のPermitをprogramMembershipUsedとして適用する
|
|
@@ -320,7 +350,6 @@ function validateProgramMembershipUsed(params) {
|
|
|
320
350
|
}
|
|
321
351
|
if ((issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.typeOf) === 'CategoryCode') {
|
|
322
352
|
programMembershipUsed = {
|
|
323
|
-
project: permitIssuedThrough.project,
|
|
324
353
|
typeOf: factory.permit.PermitType.Permit,
|
|
325
354
|
identifier: programMembershipUsedIdentifier,
|
|
326
355
|
issuedThrough: {
|
|
@@ -336,7 +365,7 @@ function validateProgramMembershipUsed(params) {
|
|
|
336
365
|
break;
|
|
337
366
|
case factory.product.ProductType.MembershipService:
|
|
338
367
|
// requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
|
|
339
|
-
const permitService = yield createPermitService({ issuedThrough: { id:
|
|
368
|
+
const permitService = yield createPermitService({ issuedThrough: { id: permitIssuedThrough.id } })(repos);
|
|
340
369
|
// メンバーシップの存在確認
|
|
341
370
|
const serviceOutput = yield permitService.findByIdentifier({
|
|
342
371
|
project: { id: params.project.id },
|
|
@@ -354,12 +383,17 @@ function validateProgramMembershipUsed(params) {
|
|
|
354
383
|
.isBefore(moment(now))) {
|
|
355
384
|
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
|
|
356
385
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
386
|
+
if (((_f = permitIssuedThrough.serviceType) === null || _f === void 0 ? void 0 : _f.typeOf) === 'CategoryCode') {
|
|
387
|
+
programMembershipUsed = {
|
|
388
|
+
typeOf: serviceOutput.typeOf,
|
|
389
|
+
identifier: programMembershipUsedIdentifier,
|
|
390
|
+
issuedThrough: {
|
|
391
|
+
id: permitIssuedThrough.id,
|
|
392
|
+
serviceType: permitIssuedThrough.serviceType,
|
|
393
|
+
typeOf: permitIssuedThrough.typeOf
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
363
397
|
break;
|
|
364
398
|
default:
|
|
365
399
|
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `${permitIssuedThrough.typeOf} not implemented`);
|
|
@@ -197,11 +197,18 @@ function validateEligibleMembershipType(params) {
|
|
|
197
197
|
// 使用メンバーシップがeligibleMembershipに含まれればよい
|
|
198
198
|
const eligibleMembershipType = params.availableOffer.eligibleMembershipType;
|
|
199
199
|
if (Array.isArray(eligibleMembershipType)) {
|
|
200
|
-
if (
|
|
200
|
+
if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) !== factory.permit.PermitType.Permit) {
|
|
201
201
|
throw new factory.errors.Argument('programMembershipUsed', 'programMembership required');
|
|
202
202
|
}
|
|
203
|
+
const { identifier, issuedThrough } = programMembershipUsed;
|
|
204
|
+
if (typeof identifier !== 'string' || identifier === '') {
|
|
205
|
+
throw new factory.errors.Argument('programMembershipUsed', 'programMembership.identifier required');
|
|
206
|
+
}
|
|
203
207
|
// programMembershipUsed.issuedThrough.serviceTypeで検証する
|
|
204
|
-
const isEligible = eligibleMembershipType.some((membershipType) =>
|
|
208
|
+
const isEligible = eligibleMembershipType.some((membershipType) =>
|
|
209
|
+
// FaceToFaceについては問答無用に受け入れる(2024-08-14~)
|
|
210
|
+
issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace
|
|
211
|
+
|| membershipType.codeValue === issuedThrough.serviceType.codeValue);
|
|
205
212
|
if (!isEligible) {
|
|
206
213
|
throw new factory.errors.Argument('programMembershipUsed', `${programMembershipUsed.identifier} is not eligible for the offer ${params.availableOffer.id}`);
|
|
207
214
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as factory from '../../../../../factory';
|
|
2
|
+
import type { JWTCredentials } from '../../../../../credentials/jwt';
|
|
3
|
+
import type { ActionRepo } from '../../../../../repo/action';
|
|
4
|
+
import type { AuthorizationRepo } from '../../../../../repo/authorization';
|
|
5
|
+
import type { OwnershipInfoRepo } from '../../../../../repo/ownershipInfo';
|
|
6
|
+
import type { TicketRepo } from '../../../../../repo/ticket';
|
|
7
|
+
/**
|
|
8
|
+
* チケット化された適用メンバーシップをPermitに変換する
|
|
9
|
+
*/
|
|
10
|
+
declare function requestedProgramMembershipUsed2permit(params: {
|
|
11
|
+
project: {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
programMembershipUsed?: factory.assetTransaction.reserve.IAcceptedProgramMembershipUsed;
|
|
15
|
+
placeOrder: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
}): (repos: {
|
|
19
|
+
action: ActionRepo;
|
|
20
|
+
authorization: AuthorizationRepo;
|
|
21
|
+
ownershipInfo: OwnershipInfoRepo;
|
|
22
|
+
ticket: TicketRepo;
|
|
23
|
+
}, credentials: {
|
|
24
|
+
jwt: JWTCredentials;
|
|
25
|
+
}) => Promise<factory.assetTransaction.reserve.IPermitIssuedThroughFaceToFace | factory.assetTransaction.reserve.IPermitIssuedThroughMembershipService | undefined>;
|
|
26
|
+
export { requestedProgramMembershipUsed2permit };
|
|
@@ -0,0 +1,127 @@
|
|
|
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.requestedProgramMembershipUsed2permit = void 0;
|
|
13
|
+
const factory = require("../../../../../factory");
|
|
14
|
+
const CodeService = require("../../../../code");
|
|
15
|
+
/**
|
|
16
|
+
* チケット化された適用メンバーシップをPermitに変換する
|
|
17
|
+
*/
|
|
18
|
+
function requestedProgramMembershipUsed2permit(params) {
|
|
19
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
20
|
+
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
|
+
let programMembershipUsedAsPermit;
|
|
23
|
+
const { programMembershipUsed, placeOrder } = params;
|
|
24
|
+
const now = new Date();
|
|
25
|
+
// トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
|
|
26
|
+
if (typeof programMembershipUsed === 'string') {
|
|
27
|
+
const { authorizedObject } = yield CodeService.verifyToken({
|
|
28
|
+
project: { id: params.project.id },
|
|
29
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
30
|
+
token: String(programMembershipUsed)
|
|
31
|
+
})(repos, credentials);
|
|
32
|
+
const permitOwnershipInfo = authorizedObject;
|
|
33
|
+
if (Array.isArray(permitOwnershipInfo)) {
|
|
34
|
+
throw new factory.errors.NotImplemented('programMembershipUsed as an array not implemented');
|
|
35
|
+
}
|
|
36
|
+
if (permitOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
37
|
+
throw new factory.errors.Argument('programMembershipUsed', 'must be OwnershipInfo');
|
|
38
|
+
}
|
|
39
|
+
const typeOfGood = permitOwnershipInfo.typeOfGood;
|
|
40
|
+
if (typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
41
|
+
throw new factory.errors.Argument('programMembershipUsed', 'must be Permit');
|
|
42
|
+
}
|
|
43
|
+
const issuedThroughTypeOf = (_a = typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
44
|
+
if (issuedThroughTypeOf !== factory.product.ProductType.MembershipService) {
|
|
45
|
+
throw new factory.errors.Argument('programMembershipUsed', 'must be issued through MembershipService');
|
|
46
|
+
}
|
|
47
|
+
if (typeof ((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) !== 'string') {
|
|
48
|
+
throw new factory.errors.NotFound('itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
49
|
+
}
|
|
50
|
+
if (issuedThroughTypeOf === factory.product.ProductType.MembershipService) {
|
|
51
|
+
programMembershipUsedAsPermit = {
|
|
52
|
+
identifier: typeOfGood.identifier,
|
|
53
|
+
issuedThrough: { id: typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
54
|
+
typeOf: factory.permit.PermitType.Permit
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) === 'Ticket') {
|
|
62
|
+
const { ticketToken } = programMembershipUsed;
|
|
63
|
+
if (typeof ticketToken === 'string') {
|
|
64
|
+
const ticket = (yield repos.ticket.search({
|
|
65
|
+
limit: 1,
|
|
66
|
+
page: 1,
|
|
67
|
+
project: { id: { $eq: params.project.id } },
|
|
68
|
+
ticketToken: { $eq: ticketToken }
|
|
69
|
+
})).shift();
|
|
70
|
+
if (ticket === undefined) {
|
|
71
|
+
throw new factory.errors.NotFound('Ticket');
|
|
72
|
+
}
|
|
73
|
+
// 承認を参照
|
|
74
|
+
const { object } = yield repos.authorization.findValidOneByCode({
|
|
75
|
+
project: { id: params.project.id },
|
|
76
|
+
code: ticket.ticketToken
|
|
77
|
+
});
|
|
78
|
+
if (object.typeOf !== 'OwnershipInfo') {
|
|
79
|
+
throw new factory.errors.Argument('programMembershipUsed', 'invalid authorization');
|
|
80
|
+
}
|
|
81
|
+
const ownershipInfoId = object.id;
|
|
82
|
+
const permitOwnershipInfo = (yield repos.ownershipInfo.search({
|
|
83
|
+
limit: 1,
|
|
84
|
+
page: 1,
|
|
85
|
+
project: { id: { $eq: params.project.id } },
|
|
86
|
+
ids: [ownershipInfoId],
|
|
87
|
+
ownedFrom: now,
|
|
88
|
+
ownedThrough: now
|
|
89
|
+
})).shift();
|
|
90
|
+
if (permitOwnershipInfo === undefined) {
|
|
91
|
+
throw new factory.errors.NotFound('OwnershipInfo');
|
|
92
|
+
}
|
|
93
|
+
// ownedBy検証
|
|
94
|
+
if (!Array.isArray(permitOwnershipInfo.ownedBy) || ((_c = permitOwnershipInfo.ownedBy[0]) === null || _c === void 0 ? void 0 : _c.id) !== placeOrder.id) {
|
|
95
|
+
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo not matched with placeOrder');
|
|
96
|
+
}
|
|
97
|
+
if (permitOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
98
|
+
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.typeOf must be Permit');
|
|
99
|
+
}
|
|
100
|
+
const issuedThroughTypeOf = (_d = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _d === void 0 ? void 0 : _d.typeOf;
|
|
101
|
+
if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
102
|
+
programMembershipUsedAsPermit = {
|
|
103
|
+
identifier: permitOwnershipInfo.typeOfGood.identifier,
|
|
104
|
+
issuedThrough: { typeOf: issuedThroughTypeOf },
|
|
105
|
+
typeOf: factory.permit.PermitType.Permit
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else if (issuedThroughTypeOf === factory.product.ProductType.MembershipService
|
|
109
|
+
|| issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
110
|
+
if (typeof ((_e = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _e === void 0 ? void 0 : _e.id) !== 'string') {
|
|
111
|
+
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.issuedThrough.id undefined');
|
|
112
|
+
}
|
|
113
|
+
programMembershipUsedAsPermit = {
|
|
114
|
+
identifier: permitOwnershipInfo.typeOfGood.identifier,
|
|
115
|
+
issuedThrough: { id: permitOwnershipInfo.typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
116
|
+
typeOf: factory.permit.PermitType.Permit
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return programMembershipUsedAsPermit;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
exports.requestedProgramMembershipUsed2permit = requestedProgramMembershipUsed2permit;
|
|
@@ -7,6 +7,7 @@ import type { EventRepo, IMinimizedIndividualEvent } from '../../../../repo/even
|
|
|
7
7
|
import type { OfferRepo } from '../../../../repo/offer';
|
|
8
8
|
import type { OfferCatalogRepo } from '../../../../repo/offerCatalog';
|
|
9
9
|
import type { OfferCatalogItemRepo } from '../../../../repo/offerCatalogItem';
|
|
10
|
+
import type { OwnershipInfoRepo } from '../../../../repo/ownershipInfo';
|
|
10
11
|
import type { PaymentServiceRepo } from '../../../../repo/paymentService';
|
|
11
12
|
import type { SeatRepo } from '../../../../repo/place/seat';
|
|
12
13
|
import type { PriceSpecificationRepo } from '../../../../repo/priceSpecification';
|
|
@@ -45,6 +46,7 @@ declare function processStartReserve4chevre(params: {
|
|
|
45
46
|
offerCatalog: OfferCatalogRepo;
|
|
46
47
|
offerCatalogItem: OfferCatalogItemRepo;
|
|
47
48
|
offerRateLimit: OfferRateLimitRepo;
|
|
49
|
+
ownershipInfo: OwnershipInfoRepo;
|
|
48
50
|
paymentService: PaymentServiceRepo;
|
|
49
51
|
product: ProductRepo;
|
|
50
52
|
productOffer: ProductOfferRepo;
|
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.processStartReserve4chevre = void 0;
|
|
13
13
|
const factory = require("../../../../factory");
|
|
14
14
|
const ReserveTransactionService = require("../../../assetTransaction/reserve");
|
|
15
|
-
const CodeService = require("../../../code");
|
|
16
15
|
const factory_1 = require("./factory");
|
|
16
|
+
const requestedProgramMembershipUsed2permit_1 = require("./processStartReserve4chevre/requestedProgramMembershipUsed2permit");
|
|
17
17
|
function processStartReserve4chevre(params, options) {
|
|
18
18
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const { event, transaction, transactionNumber } = params;
|
|
@@ -23,7 +23,7 @@ function processStartReserve4chevre(params, options) {
|
|
|
23
23
|
// object: <IObjectWithDetail>action.object,
|
|
24
24
|
acceptedOffers: params.acceptedOffers, event: { id: event.id }, transaction,
|
|
25
25
|
transactionNumber }, (params.broker !== undefined) ? { broker: params.broker } : undefined));
|
|
26
|
-
const startParamObject = yield validateObjectWithoutDetail(startParams)(repos, credentials);
|
|
26
|
+
const startParamObject = yield validateObjectWithoutDetail(startParams, { id: params.transaction.id })(repos, credentials);
|
|
27
27
|
const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject,
|
|
28
28
|
// discontinue preSearchedEvent(2024-07-17~)
|
|
29
29
|
// preSearchedEvent: event,
|
|
@@ -44,41 +44,21 @@ function processStartReserve4chevre(params, options) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
exports.processStartReserve4chevre = processStartReserve4chevre;
|
|
47
|
-
function validateObjectWithoutDetail(params) {
|
|
47
|
+
function validateObjectWithoutDetail(params, placeOrder) {
|
|
48
48
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
var _a, _b, _c
|
|
49
|
+
var _a, _b, _c;
|
|
50
50
|
const objectWithoutDetail = params.object;
|
|
51
51
|
if (Array.isArray(objectWithoutDetail.acceptedOffer)) {
|
|
52
52
|
const validatedAcceptedOffersWithoutDetail = [];
|
|
53
53
|
for (let acceptedOffer of objectWithoutDetail.acceptedOffer) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})(
|
|
62
|
-
const permitOwnershipInfo = authorizedObject;
|
|
63
|
-
if (Array.isArray(permitOwnershipInfo)) {
|
|
64
|
-
throw new factory.errors.NotImplemented('programMembershipUsed as an array not implemented');
|
|
65
|
-
}
|
|
66
|
-
if (permitOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
67
|
-
throw new factory.errors.Argument('programMembershipUsed', 'must be OwnershipInfo');
|
|
68
|
-
}
|
|
69
|
-
if (permitOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
70
|
-
throw new factory.errors.Argument('programMembershipUsed', 'must be Permit');
|
|
71
|
-
}
|
|
72
|
-
const typeOfGood = permitOwnershipInfo.typeOfGood;
|
|
73
|
-
const issuedThroughId = (_c = typeOfGood.issuedThrough) === null || _c === void 0 ? void 0 : _c.id;
|
|
74
|
-
if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
|
|
75
|
-
throw new factory.errors.NotFound('itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
76
|
-
}
|
|
77
|
-
programMembershipUsed = {
|
|
78
|
-
identifier: String(typeOfGood.identifier),
|
|
79
|
-
issuedThrough: { id: issuedThroughId }
|
|
80
|
-
};
|
|
81
|
-
acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_d = acceptedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed }) }) });
|
|
54
|
+
const programMembershipUsedAsPermit = yield (0, requestedProgramMembershipUsed2permit_1.requestedProgramMembershipUsed2permit)({
|
|
55
|
+
project: { id: params.project.id },
|
|
56
|
+
programMembershipUsed: (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed,
|
|
57
|
+
placeOrder: { id: placeOrder.id }
|
|
58
|
+
})(repos, credentials);
|
|
59
|
+
// 適用メンバーシップがあればacceptedOfferを強制的に上書き
|
|
60
|
+
if (programMembershipUsedAsPermit !== undefined) {
|
|
61
|
+
acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_c = acceptedOffer.itemOffered) === null || _c === void 0 ? void 0 : _c.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed: programMembershipUsedAsPermit }) }) });
|
|
82
62
|
}
|
|
83
63
|
validatedAcceptedOffersWithoutDetail.push(acceptedOffer);
|
|
84
64
|
}
|
|
@@ -9,6 +9,7 @@ import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
|
9
9
|
import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
10
10
|
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
11
11
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
12
|
+
import type { OwnershipInfoRepo } from '../../../repo/ownershipInfo';
|
|
12
13
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
13
14
|
import type { SeatRepo } from '../../../repo/place/seat';
|
|
14
15
|
import type { PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
@@ -33,6 +34,7 @@ interface IAuthorizeRepos {
|
|
|
33
34
|
offerRateLimit: OfferRateLimitRepo;
|
|
34
35
|
orderInTransaction: OrderInTransactionRepo;
|
|
35
36
|
orderNumber: OrderNumberRepo;
|
|
37
|
+
ownershipInfo: OwnershipInfoRepo;
|
|
36
38
|
paymentService: PaymentServiceRepo;
|
|
37
39
|
priceSpecification: PriceSpecificationRepo;
|
|
38
40
|
product: ProductRepo;
|
|
@@ -368,6 +368,7 @@ function processMoneyTransferTransaction(params) {
|
|
|
368
368
|
return pendingTransaction;
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
+
// tslint:disable-next-line:max-func-body-length
|
|
371
372
|
function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
372
373
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
373
374
|
var _a, _b, _c;
|
|
@@ -389,10 +390,13 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
|
389
390
|
if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
390
391
|
throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
391
392
|
}
|
|
393
|
+
if (((_a = paymentCardOwnershipInfo.typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) !== factory.product.ProductType.PaymentCard) {
|
|
394
|
+
throw new factory.errors.Argument('fromLocation', 'must be issued through PaymentCard');
|
|
395
|
+
}
|
|
392
396
|
fromLocation = {
|
|
393
397
|
typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
|
|
394
398
|
identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
|
|
395
|
-
issuedThrough: { id:
|
|
399
|
+
issuedThrough: { id: paymentCardOwnershipInfo.typeOfGood.issuedThrough.id }
|
|
396
400
|
};
|
|
397
401
|
}
|
|
398
402
|
else {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.381.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.381.0-alpha.3",
|
|
13
13
|
"@cinerino/sdk": "10.5.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.4.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "22.2.0-alpha.
|
|
113
|
+
"version": "22.2.0-alpha.2"
|
|
114
114
|
}
|