@chevre/domain 21.4.0-alpha.14 → 21.4.0-alpha.15
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/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
- package/example/src/chevre/processReserve.ts +0 -1
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +4 -1
- package/lib/chevre/repo/assetTransaction.js +6 -12
- package/lib/chevre/repo/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.js +6 -3
- package/lib/chevre/repo/reservation.d.ts +7 -19
- package/lib/chevre/repo/reservation.js +91 -78
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +6 -1
- package/lib/chevre/service/assetTransaction/reserve/factory.js +15 -38
- package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/reserve.js +6 -21
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/event/authorize.js +6 -2
- package/lib/chevre/service/reserve/cancelReservation.js +15 -28
- package/lib/chevre/service/reserve/confirmReservation.js +12 -30
- package/package.json +3 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const now = new Date();
|
|
14
|
+
|
|
15
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
16
|
+
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
17
|
+
const personRepo = new chevre.repository.Person({ userPoolId: USERPOOL_ID_NEW });
|
|
18
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
+
|
|
20
|
+
const cursor = orderRepo.getCursor(
|
|
21
|
+
{
|
|
22
|
+
'project.id': { $eq: project.id },
|
|
23
|
+
'customer.typeOf': { $eq: chevre.factory.personType.Person },
|
|
24
|
+
'acceptedOffers.itemOffered.typeOf': { $exists: true.valueOf, $eq: chevre.factory.reservationType.EventReservation }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
_id: 1,
|
|
28
|
+
project: 1,
|
|
29
|
+
orderNumber: 1,
|
|
30
|
+
orderDate: 1,
|
|
31
|
+
customer: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('orders found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
let updateCount = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const order = <Pick<chevre.factory.order.IOrder, 'id' | 'orderDate' | 'orderNumber' | 'customer' | 'project'>>doc.toObject();
|
|
41
|
+
|
|
42
|
+
// person検索
|
|
43
|
+
console.log('seaching person....', order.project.id, order.orderNumber, order.orderDate, order.customer.id, i);
|
|
44
|
+
const people = await personRepo.search({ id: String(order.customer.id) });
|
|
45
|
+
const person = people.shift();
|
|
46
|
+
const activePerson = (<any>person).Enabled === true;
|
|
47
|
+
if (activePerson) {
|
|
48
|
+
// activeであれば何もしない
|
|
49
|
+
console.log(
|
|
50
|
+
'person found', order.project.id, order.orderNumber, order.orderDate,
|
|
51
|
+
person?.memberOf?.membershipNumber,
|
|
52
|
+
(<any>person).Enabled, i);
|
|
53
|
+
} else {
|
|
54
|
+
// migrateアクション検索
|
|
55
|
+
const deletePersonActions = <chevre.factory.action.update.deleteAction.member.IAction[]>await actionRepo.search(
|
|
56
|
+
{
|
|
57
|
+
limit: 1,
|
|
58
|
+
page: 1,
|
|
59
|
+
project: { id: { $eq: order.project.id } },
|
|
60
|
+
actionStatus: { $in: [chevre.factory.actionStatusType.CompletedActionStatus] },
|
|
61
|
+
typeOf: { $eq: chevre.factory.actionType.DeleteAction },
|
|
62
|
+
object: {
|
|
63
|
+
id: { $eq: order.customer.id },
|
|
64
|
+
typeOf: { $eq: chevre.factory.personType.Person }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[],
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
70
|
+
const deletePersonAction = deletePersonActions.shift();
|
|
71
|
+
if (deletePersonAction !== undefined) {
|
|
72
|
+
// migrateアクションがあれば何もしない
|
|
73
|
+
const migratedUser: boolean = deletePersonAction.object.migrate === true;
|
|
74
|
+
console.log('migratedUser:', migratedUser);
|
|
75
|
+
if (migratedUser) {
|
|
76
|
+
console.log(
|
|
77
|
+
'person migrated', order.project.id, order.orderNumber, order.orderDate,
|
|
78
|
+
person?.memberOf?.membershipNumber, i);
|
|
79
|
+
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(
|
|
85
|
+
'creating task...', order.project.id, order.orderNumber, order.orderDate,
|
|
86
|
+
person?.memberOf?.membershipNumber, i);
|
|
87
|
+
// task作成
|
|
88
|
+
const deleteTransactionTasks: chevre.factory.task.deleteTransaction.IAttributes[] = [
|
|
89
|
+
chevre.factory.transactionType.MoneyTransfer,
|
|
90
|
+
chevre.factory.transactionType.PlaceOrder,
|
|
91
|
+
chevre.factory.transactionType.ReturnOrder
|
|
92
|
+
].map((transactionType) => {
|
|
93
|
+
return {
|
|
94
|
+
project: { id: order.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
95
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
96
|
+
status: chevre.factory.taskStatus.Ready,
|
|
97
|
+
runsAt: now,
|
|
98
|
+
remainingNumberOfTries: 3,
|
|
99
|
+
numberOfTried: 0,
|
|
100
|
+
executionResults: [],
|
|
101
|
+
data: {
|
|
102
|
+
object: {
|
|
103
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.AgentId,
|
|
104
|
+
agent: { id: order.customer.id },
|
|
105
|
+
project: { id: order.project.id },
|
|
106
|
+
typeOf: transactionType
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
// console.log(deleteTransactionTasks);
|
|
112
|
+
await taskRepo.saveMany(deleteTransactionTasks, { emitImmediately: false });
|
|
113
|
+
updateCount += 1;
|
|
114
|
+
console.log(
|
|
115
|
+
'task created.', order.project.id, order.orderNumber, order.orderDate,
|
|
116
|
+
person?.memberOf?.membershipNumber, i);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
console.log(i, 'orders checked');
|
|
121
|
+
console.log(updateCount, 'tasks created');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
main()
|
|
125
|
+
.then()
|
|
126
|
+
.catch(console.error);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
|
-
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
2
|
+
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
@@ -67,7 +67,10 @@ export declare class MongoRepository {
|
|
|
67
67
|
addReservations(params: {
|
|
68
68
|
typeOf: factory.assetTransactionType.Reserve;
|
|
69
69
|
id: string;
|
|
70
|
-
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'issuedThrough' | 'reservationFor' | 'subReservation'
|
|
70
|
+
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'issuedThrough' | 'reservationFor' | 'subReservation'> & {
|
|
71
|
+
issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
|
|
72
|
+
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
73
|
+
};
|
|
71
74
|
}): Promise<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
|
|
72
75
|
/**
|
|
73
76
|
* 取引を確定する
|
|
@@ -319,23 +319,17 @@ class MongoRepository {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
addReservations(params) {
|
|
322
|
-
var _a;
|
|
323
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
324
323
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
325
324
|
_id: { $eq: params.id },
|
|
326
325
|
typeOf: { $eq: params.typeOf },
|
|
327
326
|
status: { $eq: factory.transactionStatusType.InProgress }
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
'object.
|
|
333
|
-
|
|
334
|
-
// 冗長なので削除(2021/10/19~)
|
|
335
|
-
// 'object.reservations': params.object.subReservation,
|
|
336
|
-
'object.subReservation': params.object.subReservation }, (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
337
|
-
? { 'object.issuedThrough': params.object.issuedThrough }
|
|
338
|
-
: undefined), { new: true })
|
|
327
|
+
}, {
|
|
328
|
+
'object.acceptedOffer': params.object.acceptedOffer,
|
|
329
|
+
'object.issuedThrough': params.object.issuedThrough,
|
|
330
|
+
'object.reservationFor': params.object.reservationFor,
|
|
331
|
+
'object.subReservation': params.object.subReservation
|
|
332
|
+
}, { new: true })
|
|
339
333
|
.exec();
|
|
340
334
|
if (doc === null) {
|
|
341
335
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -54,9 +54,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
54
54
|
}, {
|
|
55
55
|
typeOf: string;
|
|
56
56
|
project: any;
|
|
57
|
+
organizer: any;
|
|
57
58
|
checkInCount: number;
|
|
58
59
|
attendeeCount: number;
|
|
59
|
-
organizer: any;
|
|
60
60
|
_id?: string | undefined;
|
|
61
61
|
name?: any;
|
|
62
62
|
alternateName?: any;
|
|
@@ -88,9 +88,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
88
88
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
89
89
|
typeOf: string;
|
|
90
90
|
project: any;
|
|
91
|
+
organizer: any;
|
|
91
92
|
checkInCount: number;
|
|
92
93
|
attendeeCount: number;
|
|
93
|
-
organizer: any;
|
|
94
94
|
_id?: string | undefined;
|
|
95
95
|
name?: any;
|
|
96
96
|
alternateName?: any;
|
|
@@ -122,9 +122,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
122
122
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
123
123
|
typeOf: string;
|
|
124
124
|
project: any;
|
|
125
|
+
organizer: any;
|
|
125
126
|
checkInCount: number;
|
|
126
127
|
attendeeCount: number;
|
|
127
|
-
organizer: any;
|
|
128
128
|
_id?: string | undefined;
|
|
129
129
|
name?: any;
|
|
130
130
|
alternateName?: any;
|
|
@@ -54,9 +54,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
54
54
|
}, {
|
|
55
55
|
typeOf: string;
|
|
56
56
|
additionalProperty: any[];
|
|
57
|
+
provider: any[];
|
|
57
58
|
offers: any[];
|
|
58
59
|
productID: string;
|
|
59
|
-
provider: any[];
|
|
60
60
|
name?: any;
|
|
61
61
|
project?: any;
|
|
62
62
|
description?: any;
|
|
@@ -67,9 +67,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
67
67
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
68
68
|
typeOf: string;
|
|
69
69
|
additionalProperty: any[];
|
|
70
|
+
provider: any[];
|
|
70
71
|
offers: any[];
|
|
71
72
|
productID: string;
|
|
72
|
-
provider: any[];
|
|
73
73
|
name?: any;
|
|
74
74
|
project?: any;
|
|
75
75
|
description?: any;
|
|
@@ -80,9 +80,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
80
80
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
81
81
|
typeOf: string;
|
|
82
82
|
additionalProperty: any[];
|
|
83
|
+
provider: any[];
|
|
83
84
|
offers: any[];
|
|
84
85
|
productID: string;
|
|
85
|
-
provider: any[];
|
|
86
86
|
name?: any;
|
|
87
87
|
project?: any;
|
|
88
88
|
description?: any;
|
|
@@ -67,6 +67,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
67
67
|
underName?: any;
|
|
68
68
|
issuedThrough?: any;
|
|
69
69
|
subReservation?: any;
|
|
70
|
+
provider?: any;
|
|
70
71
|
reservedTicket?: any;
|
|
71
72
|
additionalTicketText?: string | undefined;
|
|
72
73
|
bookingTime?: Date | undefined;
|
|
@@ -95,6 +96,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
95
96
|
underName?: any;
|
|
96
97
|
issuedThrough?: any;
|
|
97
98
|
subReservation?: any;
|
|
99
|
+
provider?: any;
|
|
98
100
|
reservedTicket?: any;
|
|
99
101
|
additionalTicketText?: string | undefined;
|
|
100
102
|
bookingTime?: Date | undefined;
|
|
@@ -123,6 +125,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
123
125
|
underName?: any;
|
|
124
126
|
issuedThrough?: any;
|
|
125
127
|
subReservation?: any;
|
|
128
|
+
provider?: any;
|
|
126
129
|
reservedTicket?: any;
|
|
127
130
|
additionalTicketText?: string | undefined;
|
|
128
131
|
bookingTime?: Date | undefined;
|
|
@@ -10,6 +10,7 @@ exports.modelName = modelName;
|
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose_1.Schema({
|
|
12
12
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
provider: mongoose_1.SchemaTypes.Mixed,
|
|
13
14
|
_id: String,
|
|
14
15
|
typeOf: {
|
|
15
16
|
type: String,
|
|
@@ -74,9 +75,11 @@ exports.schema = schema;
|
|
|
74
75
|
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
75
76
|
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
76
77
|
schema.index({ bookingTime: -1 }, { name: 'searchByBookingTime-v3' });
|
|
77
|
-
schema.index({ 'project.id': 1, bookingTime: -1 }, {
|
|
78
|
-
|
|
79
|
-
}
|
|
78
|
+
schema.index({ 'project.id': 1, bookingTime: -1 }, { name: 'searchByProjectId-v20220721' });
|
|
79
|
+
// schema.index(
|
|
80
|
+
// { 'provider.id': 1, bookingTime: -1 },
|
|
81
|
+
// { name: 'searchByProviderId' }
|
|
82
|
+
// );
|
|
80
83
|
schema.index({ typeOf: 1, bookingTime: -1 }, { name: 'searchByTypeOf-v3' });
|
|
81
84
|
schema.index({ reservationNumber: 1, bookingTime: -1 }, { name: 'searchByReservationNumber-v3' });
|
|
82
85
|
schema.index({ reservationStatus: 1, bookingTime: -1 }, { name: 'searchByReservationStatus-v3' });
|
|
@@ -6,6 +6,11 @@ export interface IUpdatePartiallyParams {
|
|
|
6
6
|
'reservedTicket.dateUsed'?: Date;
|
|
7
7
|
}
|
|
8
8
|
export type ICancelResult = UpdateWriteOpResult;
|
|
9
|
+
export type ICreatingReservation<T extends factory.reservationType> = T extends factory.reservationType.BusReservation ? (factory.reservation.busReservation.IReservation) & {
|
|
10
|
+
_id: string;
|
|
11
|
+
} : T extends factory.reservationType.EventReservation ? (factory.reservation.eventReservation.IReservation) & {
|
|
12
|
+
_id: string;
|
|
13
|
+
} : never;
|
|
9
14
|
/**
|
|
10
15
|
* 予約リポジトリ
|
|
11
16
|
*/
|
|
@@ -13,10 +18,6 @@ export declare class MongoRepository {
|
|
|
13
18
|
private readonly reservationModel;
|
|
14
19
|
constructor(connection: Connection);
|
|
15
20
|
static CREATE_MONGO_CONDITIONS(params: factory.reservation.ISearchConditions<factory.reservationType>): any[];
|
|
16
|
-
createMany(params: {
|
|
17
|
-
reservations: factory.assetTransaction.reserve.IObjectSubReservation[];
|
|
18
|
-
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
19
|
-
}): Promise<void>;
|
|
20
21
|
/**
|
|
21
22
|
* 汎用予約カウント
|
|
22
23
|
*/
|
|
@@ -32,26 +33,13 @@ export declare class MongoRepository {
|
|
|
32
33
|
inclusion?: string[];
|
|
33
34
|
exclusion?: string[];
|
|
34
35
|
}): Promise<factory.reservation.IReservation<T>>;
|
|
35
|
-
confirmByReservationNumber(params: {
|
|
36
|
-
reservationNumber: string;
|
|
37
|
-
previousReservationStatus: factory.reservationStatusType;
|
|
38
|
-
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
39
|
-
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
40
|
-
issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
41
|
-
}): Promise<void>;
|
|
42
|
-
confirmByIdIfNotExist__(params: {
|
|
43
|
-
reservation: factory.assetTransaction.reserve.IObjectSubReservation;
|
|
44
|
-
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
45
|
-
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
46
|
-
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
47
|
-
issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
48
|
-
}): Promise<void>;
|
|
49
36
|
confirmManyIfNotExist(params: {
|
|
37
|
+
provider: factory.reservation.IProvider;
|
|
50
38
|
subReservation: factory.assetTransaction.reserve.IObjectSubReservation[];
|
|
39
|
+
issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
|
|
51
40
|
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
52
41
|
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
53
42
|
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
54
|
-
issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
55
43
|
}): Promise<BulkWriteOpResultObject | void>;
|
|
56
44
|
/**
|
|
57
45
|
* 予約取消
|
|
@@ -22,18 +22,18 @@ class MongoRepository {
|
|
|
22
22
|
}
|
|
23
23
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
24
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
26
26
|
// MongoDB検索条件
|
|
27
27
|
const andConditions = [
|
|
28
28
|
{ typeOf: params.typeOf }
|
|
29
29
|
];
|
|
30
30
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
31
31
|
if (typeof projectIdEq === 'string') {
|
|
32
|
-
andConditions.push({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
32
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
33
|
+
}
|
|
34
|
+
const providerIdEq = (_d = (_c = params.provider) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
35
|
+
if (typeof providerIdEq === 'string') {
|
|
36
|
+
andConditions.push({ 'provider.id': { $eq: providerIdEq } });
|
|
37
37
|
}
|
|
38
38
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
39
39
|
/* istanbul ignore else */
|
|
@@ -172,24 +172,24 @@ class MongoRepository {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
const additionalTicketTextRegex = (
|
|
175
|
+
const additionalTicketTextRegex = (_e = params.additionalTicketText) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
176
176
|
if (typeof additionalTicketTextRegex === 'string' && additionalTicketTextRegex.length > 0) {
|
|
177
|
-
const additionalTicketTextOptions = (
|
|
177
|
+
const additionalTicketTextOptions = (_f = params.additionalTicketText) === null || _f === void 0 ? void 0 : _f.$options;
|
|
178
178
|
andConditions.push({
|
|
179
179
|
additionalTicketText: Object.assign({ $exists: true, $regex: new RegExp(additionalTicketTextRegex) }, (typeof additionalTicketTextOptions === 'string') ? { $options: additionalTicketTextOptions } : undefined)
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const reservationStatusEq = (
|
|
184
|
+
const reservationStatusEq = (_g = params.reservationStatus) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
185
185
|
if (typeof reservationStatusEq === 'string') {
|
|
186
186
|
andConditions.push({ reservationStatus: { $eq: reservationStatusEq } });
|
|
187
187
|
}
|
|
188
|
-
const reservationStatusNe = (
|
|
188
|
+
const reservationStatusNe = (_h = params.reservationStatus) === null || _h === void 0 ? void 0 : _h.$ne;
|
|
189
189
|
if (typeof reservationStatusNe === 'string') {
|
|
190
190
|
andConditions.push({ reservationStatus: { $ne: reservationStatusNe } });
|
|
191
191
|
}
|
|
192
|
-
const reservationStatusIn = (
|
|
192
|
+
const reservationStatusIn = (_j = params.reservationStatus) === null || _j === void 0 ? void 0 : _j.$in;
|
|
193
193
|
if (Array.isArray(reservationStatusIn)) {
|
|
194
194
|
andConditions.push({ reservationStatus: { $in: reservationStatusIn } });
|
|
195
195
|
}
|
|
@@ -234,7 +234,7 @@ class MongoRepository {
|
|
|
234
234
|
}
|
|
235
235
|
switch (params.typeOf) {
|
|
236
236
|
case factory.reservationType.BusReservation:
|
|
237
|
-
const reservationForTypeOfEq = (
|
|
237
|
+
const reservationForTypeOfEq = (_k = params.reservationFor) === null || _k === void 0 ? void 0 : _k.typeOf;
|
|
238
238
|
if (typeof reservationForTypeOfEq === 'string') {
|
|
239
239
|
andConditions.push({
|
|
240
240
|
'reservationFor.typeOf': {
|
|
@@ -243,7 +243,7 @@ class MongoRepository {
|
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
const reservationForIdEq = (
|
|
246
|
+
const reservationForIdEq = (_m = (_l = params.reservationFor) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
|
|
247
247
|
if (typeof reservationForIdEq === 'string') {
|
|
248
248
|
andConditions.push({
|
|
249
249
|
'reservationFor.id': {
|
|
@@ -252,7 +252,7 @@ class MongoRepository {
|
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
const reservationForIdIn = (
|
|
255
|
+
const reservationForIdIn = (_p = (_o = params.reservationFor) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$in;
|
|
256
256
|
if (Array.isArray(reservationForIdIn)) {
|
|
257
257
|
andConditions.push({
|
|
258
258
|
'reservationFor.id': {
|
|
@@ -263,7 +263,7 @@ class MongoRepository {
|
|
|
263
263
|
}
|
|
264
264
|
break;
|
|
265
265
|
case factory.reservationType.EventReservation:
|
|
266
|
-
if (typeof ((
|
|
266
|
+
if (typeof ((_q = params.reservationFor) === null || _q === void 0 ? void 0 : _q.id) === 'string') {
|
|
267
267
|
andConditions.push({
|
|
268
268
|
'reservationFor.id': {
|
|
269
269
|
$exists: true,
|
|
@@ -272,7 +272,7 @@ class MongoRepository {
|
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
else {
|
|
275
|
-
const reservationForIdEq4eventReservation = (
|
|
275
|
+
const reservationForIdEq4eventReservation = (_s = (_r = params.reservationFor) === null || _r === void 0 ? void 0 : _r.id) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
276
276
|
if (typeof reservationForIdEq4eventReservation === 'string') {
|
|
277
277
|
andConditions.push({
|
|
278
278
|
'reservationFor.id': {
|
|
@@ -526,7 +526,7 @@ class MongoRepository {
|
|
|
526
526
|
}
|
|
527
527
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
528
528
|
/* istanbul ignore else */
|
|
529
|
-
const ticketedSeatSeatingTypeIn = (
|
|
529
|
+
const ticketedSeatSeatingTypeIn = (_u = (_t = params.reservedTicket.ticketedSeat) === null || _t === void 0 ? void 0 : _t.seatingType) === null || _u === void 0 ? void 0 : _u.$in;
|
|
530
530
|
if (Array.isArray(ticketedSeatSeatingTypeIn)) {
|
|
531
531
|
andConditions.push({
|
|
532
532
|
'reservedTicket.ticketedSeat.seatingType': {
|
|
@@ -537,7 +537,7 @@ class MongoRepository {
|
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
const brokerIdRegex = (
|
|
540
|
+
const brokerIdRegex = (_v = params.broker) === null || _v === void 0 ? void 0 : _v.id;
|
|
541
541
|
if (typeof brokerIdRegex === 'string' && brokerIdRegex.length > 0) {
|
|
542
542
|
andConditions.push({
|
|
543
543
|
'broker.id': {
|
|
@@ -546,7 +546,7 @@ class MongoRepository {
|
|
|
546
546
|
}
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
|
-
const brokerIdentifierAll = (
|
|
549
|
+
const brokerIdentifierAll = (_x = (_w = params.broker) === null || _w === void 0 ? void 0 : _w.identifier) === null || _x === void 0 ? void 0 : _x.$all;
|
|
550
550
|
if (Array.isArray(brokerIdentifierAll)) {
|
|
551
551
|
andConditions.push({
|
|
552
552
|
'broker.identifier': {
|
|
@@ -555,7 +555,7 @@ class MongoRepository {
|
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
const brokerIdentifierIn = (
|
|
558
|
+
const brokerIdentifierIn = (_z = (_y = params.broker) === null || _y === void 0 ? void 0 : _y.identifier) === null || _z === void 0 ? void 0 : _z.$in;
|
|
559
559
|
if (Array.isArray(brokerIdentifierIn)) {
|
|
560
560
|
andConditions.push({
|
|
561
561
|
'broker.identifier': {
|
|
@@ -564,7 +564,7 @@ class MongoRepository {
|
|
|
564
564
|
}
|
|
565
565
|
});
|
|
566
566
|
}
|
|
567
|
-
const brokerIdentifierNin = (
|
|
567
|
+
const brokerIdentifierNin = (_1 = (_0 = params.broker) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$nin;
|
|
568
568
|
if (Array.isArray(brokerIdentifierNin)) {
|
|
569
569
|
andConditions.push({
|
|
570
570
|
'broker.identifier': {
|
|
@@ -572,7 +572,7 @@ class MongoRepository {
|
|
|
572
572
|
}
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
|
-
const brokerIdentifierElemMatch = (
|
|
575
|
+
const brokerIdentifierElemMatch = (_3 = (_2 = params.broker) === null || _2 === void 0 ? void 0 : _2.identifier) === null || _3 === void 0 ? void 0 : _3.$elemMatch;
|
|
576
576
|
if (brokerIdentifierElemMatch !== undefined && brokerIdentifierElemMatch !== null) {
|
|
577
577
|
andConditions.push({
|
|
578
578
|
'broker.identifier': {
|
|
@@ -607,9 +607,9 @@ class MongoRepository {
|
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
else {
|
|
610
|
-
const emailRegex = (
|
|
610
|
+
const emailRegex = (_4 = params.underName.email) === null || _4 === void 0 ? void 0 : _4.$regex;
|
|
611
611
|
if (typeof emailRegex === 'string' && emailRegex.length > 0) {
|
|
612
|
-
const emailOptions = (
|
|
612
|
+
const emailOptions = (_5 = params.underName.email) === null || _5 === void 0 ? void 0 : _5.$options;
|
|
613
613
|
andConditions.push({
|
|
614
614
|
'underName.email': Object.assign({ $exists: true, $regex: new RegExp(emailRegex) }, (typeof emailOptions === 'string') ? { $options: emailOptions } : undefined)
|
|
615
615
|
});
|
|
@@ -628,9 +628,9 @@ class MongoRepository {
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
else {
|
|
631
|
-
const underNameNameRegex = (
|
|
631
|
+
const underNameNameRegex = (_6 = params.underName.name) === null || _6 === void 0 ? void 0 : _6.$regex;
|
|
632
632
|
if (typeof underNameNameRegex === 'string' && underNameNameRegex.length > 0) {
|
|
633
|
-
const underNameNameOptions = (
|
|
633
|
+
const underNameNameOptions = (_7 = params.underName.name) === null || _7 === void 0 ? void 0 : _7.$options;
|
|
634
634
|
andConditions.push({
|
|
635
635
|
'underName.name': Object.assign({ $exists: true, $regex: new RegExp(underNameNameRegex) }, (typeof underNameNameOptions === 'string') ? { $options: underNameNameOptions } : undefined)
|
|
636
636
|
});
|
|
@@ -659,9 +659,9 @@ class MongoRepository {
|
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
661
|
else {
|
|
662
|
-
const givenNameRegex = (
|
|
662
|
+
const givenNameRegex = (_8 = params.underName.givenName) === null || _8 === void 0 ? void 0 : _8.$regex;
|
|
663
663
|
if (typeof givenNameRegex === 'string' && givenNameRegex.length > 0) {
|
|
664
|
-
const givenNameOptions = (
|
|
664
|
+
const givenNameOptions = (_9 = params.underName.givenName) === null || _9 === void 0 ? void 0 : _9.$options;
|
|
665
665
|
andConditions.push({
|
|
666
666
|
'underName.givenName': Object.assign({ $exists: true, $regex: new RegExp(givenNameRegex) }, (typeof givenNameOptions === 'string') ? { $options: givenNameOptions } : undefined)
|
|
667
667
|
});
|
|
@@ -680,9 +680,9 @@ class MongoRepository {
|
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
else {
|
|
683
|
-
const familyNameRegex = (
|
|
683
|
+
const familyNameRegex = (_10 = params.underName.familyName) === null || _10 === void 0 ? void 0 : _10.$regex;
|
|
684
684
|
if (typeof familyNameRegex === 'string' && familyNameRegex.length > 0) {
|
|
685
|
-
const familyNameOptions = (
|
|
685
|
+
const familyNameOptions = (_11 = params.underName.familyName) === null || _11 === void 0 ? void 0 : _11.$options;
|
|
686
686
|
andConditions.push({
|
|
687
687
|
'underName.familyName': Object.assign({ $exists: true, $regex: new RegExp(familyNameRegex) }, (typeof familyNameOptions === 'string') ? { $options: familyNameOptions } : undefined)
|
|
688
688
|
});
|
|
@@ -783,7 +783,7 @@ class MongoRepository {
|
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
|
-
const programMembershipUsedIdentifierEq = (
|
|
786
|
+
const programMembershipUsedIdentifierEq = (_13 = (_12 = params.programMembershipUsed) === null || _12 === void 0 ? void 0 : _12.identifier) === null || _13 === void 0 ? void 0 : _13.$eq;
|
|
787
787
|
if (typeof programMembershipUsedIdentifierEq === 'string') {
|
|
788
788
|
andConditions.push({
|
|
789
789
|
'programMembershipUsed.identifier': {
|
|
@@ -792,7 +792,7 @@ class MongoRepository {
|
|
|
792
792
|
}
|
|
793
793
|
});
|
|
794
794
|
}
|
|
795
|
-
const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (
|
|
795
|
+
const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_17 = (_16 = (_15 = (_14 = params.programMembershipUsed) === null || _14 === void 0 ? void 0 : _14.issuedThrough) === null || _15 === void 0 ? void 0 : _15.serviceType) === null || _16 === void 0 ? void 0 : _16.codeValue) === null || _17 === void 0 ? void 0 : _17.$eq;
|
|
796
796
|
if (typeof programMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
|
|
797
797
|
andConditions.push({
|
|
798
798
|
'programMembershipUsed.issuedThrough.serviceType.codeValue': {
|
|
@@ -801,7 +801,7 @@ class MongoRepository {
|
|
|
801
801
|
}
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
|
-
const appliesToMovieTicketIdentifierEq = (
|
|
804
|
+
const appliesToMovieTicketIdentifierEq = (_21 = (_20 = (_19 = (_18 = params.price) === null || _18 === void 0 ? void 0 : _18.priceComponent) === null || _19 === void 0 ? void 0 : _19.appliesToMovieTicket) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$eq;
|
|
805
805
|
if (typeof appliesToMovieTicketIdentifierEq === 'string') {
|
|
806
806
|
andConditions.push({
|
|
807
807
|
'price.priceComponent.appliesToMovieTicket.identifier': {
|
|
@@ -812,25 +812,24 @@ class MongoRepository {
|
|
|
812
812
|
}
|
|
813
813
|
return andConditions;
|
|
814
814
|
}
|
|
815
|
-
createMany(params
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
}
|
|
815
|
+
// public async createMany(params: {
|
|
816
|
+
// reservations: factory.assetTransaction.reserve.IObjectSubReservation[];
|
|
817
|
+
// reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
818
|
+
// }): Promise<void> {
|
|
819
|
+
// if (params.reservations.length > 0) {
|
|
820
|
+
// const result = await this.reservationModel.insertMany(
|
|
821
|
+
// params.reservations.map((r) => {
|
|
822
|
+
// return { ...r, _id: r.id, reservationFor: params.reservationFor };
|
|
823
|
+
// }),
|
|
824
|
+
// { ordered: false, rawResult: true }
|
|
825
|
+
// );
|
|
826
|
+
// if (result.insertedCount !== params.reservations.length) {
|
|
827
|
+
// throw new factory.errors.ServiceUnavailable('all reservations not saved');
|
|
828
|
+
// }
|
|
829
|
+
// } else {
|
|
830
|
+
// // no op
|
|
831
|
+
// }
|
|
832
|
+
// }
|
|
834
833
|
/**
|
|
835
834
|
* 汎用予約カウント
|
|
836
835
|
*/
|
|
@@ -899,30 +898,29 @@ class MongoRepository {
|
|
|
899
898
|
return doc.toObject();
|
|
900
899
|
});
|
|
901
900
|
}
|
|
902
|
-
confirmByReservationNumber(params
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}
|
|
901
|
+
// public async confirmByReservationNumber(params: {
|
|
902
|
+
// reservationNumber: string;
|
|
903
|
+
// previousReservationStatus: factory.reservationStatusType;
|
|
904
|
+
// underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
905
|
+
// broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
906
|
+
// issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
907
|
+
// }): Promise<void> {
|
|
908
|
+
// const conditions = {
|
|
909
|
+
// reservationNumber: { $eq: String(params.reservationNumber) },
|
|
910
|
+
// reservationStatus: { $eq: params.previousReservationStatus }
|
|
911
|
+
// };
|
|
912
|
+
// const update = {
|
|
913
|
+
// // previousReservationStatusを保管(2023-01-19~)
|
|
914
|
+
// previousReservationStatus: params.previousReservationStatus,
|
|
915
|
+
// reservationStatus: factory.reservationStatusType.ReservationConfirmed,
|
|
916
|
+
// modifiedTime: new Date(),
|
|
917
|
+
// ...(params.underName !== undefined) ? { underName: params.underName } : undefined,
|
|
918
|
+
// ...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined,
|
|
919
|
+
// ...(typeof params.issuedThrough?.typeOf === 'string') ? { issuedThrough: params.issuedThrough } : undefined
|
|
920
|
+
// };
|
|
921
|
+
// await this.reservationModel.updateMany(conditions, update)
|
|
922
|
+
// .exec();
|
|
923
|
+
// }
|
|
926
924
|
confirmManyIfNotExist(params) {
|
|
927
925
|
return __awaiter(this, void 0, void 0, function* () {
|
|
928
926
|
const modifiedTime = new Date();
|
|
@@ -930,11 +928,26 @@ class MongoRepository {
|
|
|
930
928
|
if (Array.isArray(params.subReservation)) {
|
|
931
929
|
params.subReservation.forEach((subReservation) => {
|
|
932
930
|
var _a, _b;
|
|
931
|
+
let setOnInsert;
|
|
932
|
+
switch (subReservation.typeOf) {
|
|
933
|
+
case factory.reservationType.BusReservation:
|
|
934
|
+
setOnInsert = Object.assign(Object.assign(Object.assign(Object.assign({}, subReservation), { _id: subReservation.id, issuedThrough: params.issuedThrough, reservationFor: params.reservationFor, reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime,
|
|
935
|
+
// providerを追加(2023-07-19~)
|
|
936
|
+
provider: params.provider }), (params.underName !== undefined) ? { underName: params.underName } : undefined), (typeof ((_a = params.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.broker } : undefined);
|
|
937
|
+
break;
|
|
938
|
+
case factory.reservationType.EventReservation:
|
|
939
|
+
setOnInsert = Object.assign(Object.assign(Object.assign(Object.assign({}, subReservation), { _id: subReservation.id, issuedThrough: params.issuedThrough, reservationFor: params.reservationFor, reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime,
|
|
940
|
+
// providerを追加(2023-07-19~)
|
|
941
|
+
provider: params.provider }), (params.underName !== undefined) ? { underName: params.underName } : undefined), (typeof ((_b = params.broker) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { broker: params.broker } : undefined);
|
|
942
|
+
break;
|
|
943
|
+
default:
|
|
944
|
+
throw new factory.errors.NotImplemented(`${subReservation.typeOf} not implemented`);
|
|
945
|
+
}
|
|
933
946
|
bulkWriteOps.push({
|
|
934
947
|
updateOne: {
|
|
935
|
-
filter: { _id: { $eq:
|
|
948
|
+
filter: { _id: { $eq: setOnInsert.id } },
|
|
936
949
|
update: {
|
|
937
|
-
$setOnInsert:
|
|
950
|
+
$setOnInsert: setOnInsert
|
|
938
951
|
},
|
|
939
952
|
upsert: true
|
|
940
953
|
}
|
|
@@ -4,8 +4,13 @@ import { IAcceptedAddOn } from './factory/price';
|
|
|
4
4
|
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
5
5
|
export { IAcceptedAddOn };
|
|
6
6
|
export declare function createStartParams(params: factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
|
|
7
|
+
provider: {
|
|
8
|
+
/**
|
|
9
|
+
* 販売者ID
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
7
13
|
reservationNumber: string;
|
|
8
|
-
disablePendingReservations: boolean;
|
|
9
14
|
useHoldStockByTransactionNumber: boolean;
|
|
10
15
|
}): factory.assetTransaction.IStartParams<factory.assetTransactionType.Reserve>;
|
|
11
16
|
/**
|
|
@@ -11,9 +11,13 @@ const price_1 = require("./factory/price");
|
|
|
11
11
|
function createStartParams(params) {
|
|
12
12
|
var _a;
|
|
13
13
|
const reservationNumber = params.reservationNumber;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const provider = {
|
|
15
|
+
id: params.provider.id,
|
|
16
|
+
typeOf: factory.organizationType.Corporation
|
|
17
|
+
};
|
|
18
|
+
const reservationPackage = Object.assign({ provider, reservationNumber: reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending,
|
|
19
|
+
// trueで固定(2023-07-19~)
|
|
20
|
+
disablePendingReservations: true, useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, typeOf: factory.reservationType.ReservationPackage }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined);
|
|
17
21
|
return {
|
|
18
22
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
19
23
|
typeOf: factory.assetTransactionType.Reserve,
|
|
@@ -413,36 +417,14 @@ function createReservation(params) {
|
|
|
413
417
|
}
|
|
414
418
|
// priceを最適化
|
|
415
419
|
const price4reservation = (0, price_1.createPrice)(params);
|
|
416
|
-
// const eventOffers = <factory.event.screeningEvent.IOffer | undefined>params.reservationFor.offers;
|
|
417
|
-
// // offersは必ず存在するはず
|
|
418
|
-
// if (eventOffers === undefined) {
|
|
419
|
-
// throw new factory.errors.NotFound('reservationFor.offers');
|
|
420
|
-
// }
|
|
421
|
-
// const serviceTypeOfIssuedThrough: factory.reservation.eventReservation.IServiceTypeOfIssuedThrough | undefined
|
|
422
|
-
// = (typeof eventOffers.itemOffered.serviceType?.codeValue === 'string')
|
|
423
|
-
// ? {
|
|
424
|
-
// codeValue: eventOffers.itemOffered.serviceType.codeValue,
|
|
425
|
-
// inCodeSet: {
|
|
426
|
-
// typeOf: 'CategoryCodeSet',
|
|
427
|
-
// identifier: factory.categoryCode.CategorySetIdentifier.ServiceType
|
|
428
|
-
// },
|
|
429
|
-
// typeOf: 'CategoryCode'
|
|
430
|
-
// }
|
|
431
|
-
// : undefined;
|
|
432
|
-
// const availableChannel: factory.reservation.IServiceChannel = eventOffers.itemOffered.availableChannel;
|
|
433
420
|
if (params.reservationFor.typeOf === factory.eventType.ScreeningEvent) {
|
|
434
|
-
// const issuedThrough: factory.reservation.eventReservation.IIssuedThrough = {
|
|
435
|
-
// typeOf: factory.product.ProductType.EventService,
|
|
436
|
-
// // 興行IDを追加(2022-09-08~)
|
|
437
|
-
// id: eventOffers.itemOffered.id,
|
|
438
|
-
// availableChannel,
|
|
439
|
-
// // issuedThrough.serviceTypeを連携
|
|
440
|
-
// ...(typeof serviceTypeOfIssuedThrough?.typeOf === 'string') ? { serviceType: serviceTypeOfIssuedThrough } : undefined
|
|
441
|
-
// };
|
|
442
421
|
return Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.EventReservation, id: params.id,
|
|
443
422
|
// reservationPackage保管に移行(2023-06-06~)
|
|
444
423
|
// issuedThrough,
|
|
445
|
-
additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
|
|
424
|
+
additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
|
|
425
|
+
// statusは不要なので削除(2023-07-19~)
|
|
426
|
+
// reservationStatus: factory.reservationStatusType.ReservationPending,
|
|
427
|
+
reservedTicket: params.reservedTicket,
|
|
446
428
|
// 最適化(2022-12-19~)
|
|
447
429
|
underName: {
|
|
448
430
|
typeOf: params.agent.typeOf,
|
|
@@ -463,18 +445,13 @@ function createReservation(params) {
|
|
|
463
445
|
: undefined);
|
|
464
446
|
}
|
|
465
447
|
else {
|
|
466
|
-
// const issuedThrough: factory.reservation.busReservation.IIssuedThrough = {
|
|
467
|
-
// typeOf: factory.product.ProductType.Transportation,
|
|
468
|
-
// // 興行IDを追加(2022-09-08~)
|
|
469
|
-
// id: eventOffers.itemOffered.id,
|
|
470
|
-
// availableChannel,
|
|
471
|
-
// // issuedThrough.serviceTypeを連携
|
|
472
|
-
// ...(typeof serviceTypeOfIssuedThrough?.typeOf === 'string') ? { serviceType: serviceTypeOfIssuedThrough } : undefined
|
|
473
|
-
// };
|
|
474
448
|
return Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.BusReservation, id: params.id,
|
|
475
449
|
// reservationPackage保管に移行(2023-06-06~)
|
|
476
450
|
// issuedThrough,
|
|
477
|
-
additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
|
|
451
|
+
additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
|
|
452
|
+
// statusは不要なので削除(2023-07-19~)
|
|
453
|
+
// reservationStatus: factory.reservationStatusType.ReservationPending,
|
|
454
|
+
reservedTicket: params.reservedTicket, underName: {
|
|
478
455
|
typeOf: params.agent.typeOf,
|
|
479
456
|
name: params.agent.name
|
|
480
457
|
}, checkedIn: false, attended: false }, (typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined), (Array.isArray(params.subReservation))
|
|
@@ -96,7 +96,6 @@ type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail &
|
|
|
96
96
|
* 取引開始
|
|
97
97
|
*/
|
|
98
98
|
export declare function start(params: IStartParams & {
|
|
99
|
-
disablePendingReservations: boolean;
|
|
100
99
|
useHoldStockByTransactionNumber: boolean;
|
|
101
100
|
stockHoldUntilDaysAfterEventEnd: number;
|
|
102
101
|
}): IStartOperation<{
|
|
@@ -55,7 +55,7 @@ function start(params) {
|
|
|
55
55
|
now,
|
|
56
56
|
store: { id: (_c = params.availableAtOrFrom) === null || _c === void 0 ? void 0 : _c.id }
|
|
57
57
|
});
|
|
58
|
-
const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { reservationNumber: reservationNumber }));
|
|
58
|
+
const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { provider: { id: event.organizer.id }, reservationNumber: reservationNumber }));
|
|
59
59
|
// 取引作成
|
|
60
60
|
let transaction;
|
|
61
61
|
try {
|
|
@@ -139,20 +139,6 @@ function addReservations(params) {
|
|
|
139
139
|
// 予約イベント最適化
|
|
140
140
|
const reservationFor = (0, factory_1.createReservationFor)(event);
|
|
141
141
|
const { issuedThrough } = (0, factory_1.createIssuedThrough)({ reservationFor: event });
|
|
142
|
-
// const minimizedObjectSubReservations: factory.assetTransaction.reserve.IMinimizedObjectSubReservation[] =
|
|
143
|
-
// objectSubReservations.map((r) => {
|
|
144
|
-
// return {
|
|
145
|
-
// id: r.id,
|
|
146
|
-
// typeOf: r.typeOf,
|
|
147
|
-
// reservedTicket: {
|
|
148
|
-
// ticketType: r.reservedTicket.ticketType,
|
|
149
|
-
// ...(typeof r.reservedTicket.ticketedSeat?.typeOf === 'string')
|
|
150
|
-
// ? { ticketedSeat: r.reservedTicket.ticketedSeat }
|
|
151
|
-
// : undefined
|
|
152
|
-
// },
|
|
153
|
-
// ...(Array.isArray(r.subReservation)) ? { subReservation: r.subReservation } : undefined
|
|
154
|
-
// };
|
|
155
|
-
// });
|
|
156
142
|
// 取引に予約追加
|
|
157
143
|
let lockedOfferRateLimitKeys = [];
|
|
158
144
|
try {
|
|
@@ -165,9 +151,7 @@ function addReservations(params) {
|
|
|
165
151
|
// issuedThroughを追加(2023-06-05~)
|
|
166
152
|
issuedThrough,
|
|
167
153
|
reservationFor,
|
|
168
|
-
// subReservationにreservationForを保管しない(2021-10-19~)
|
|
169
154
|
subReservation: objectSubReservations
|
|
170
|
-
// subReservation: minimizedObjectSubReservations
|
|
171
155
|
}
|
|
172
156
|
});
|
|
173
157
|
}
|
|
@@ -191,10 +175,11 @@ function addReservations(params) {
|
|
|
191
175
|
},
|
|
192
176
|
stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
|
|
193
177
|
})(repos);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
178
|
+
// 完全廃止(2023-07-19~)
|
|
179
|
+
// if (transaction.object.disablePendingReservations !== true) {
|
|
180
|
+
// // 予約作成(insertManyで実装)
|
|
181
|
+
// await repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
|
|
182
|
+
// }
|
|
198
183
|
// ストックホルダー処理(stockHolderで残席数を集計しているので必要)
|
|
199
184
|
yield onReservationsCreated({ event })(repos);
|
|
200
185
|
return { transaction, objectSubReservations, issuedThrough };
|
|
@@ -67,7 +67,8 @@ function authorize(params) {
|
|
|
67
67
|
unitPriceOffers,
|
|
68
68
|
validateEvent: params.validateEvent === true,
|
|
69
69
|
validateEventOfferPeriod: params.validateEventOfferPeriod === true,
|
|
70
|
-
|
|
70
|
+
// 完全廃止(2023-07-19~)
|
|
71
|
+
// disablePendingReservations: params.disablePendingReservations,
|
|
71
72
|
useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber,
|
|
72
73
|
stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
|
|
73
74
|
})(repos);
|
|
@@ -165,7 +166,10 @@ function processStartReserve4chevre(params) {
|
|
|
165
166
|
// requestBody = startParams;
|
|
166
167
|
const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
|
|
167
168
|
// 予約取引開始
|
|
168
|
-
const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true,
|
|
169
|
+
const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true,
|
|
170
|
+
// 完全廃止(2023-07-19~)
|
|
171
|
+
// disablePendingReservations: params.disablePendingReservations,
|
|
172
|
+
useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd }))(repos);
|
|
169
173
|
responseBody = startReserveTransactionResult.transaction;
|
|
170
174
|
// 予約取引からオファー情報を生成する
|
|
171
175
|
acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
|
|
@@ -23,22 +23,15 @@ function cancelPendingReservation(actionAttributes) {
|
|
|
23
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var _a;
|
|
25
25
|
const now = new Date();
|
|
26
|
-
|
|
26
|
+
const canceledReservations = [];
|
|
27
27
|
const { reserveTransaction } = yield cancelPengindIfNotYet(actionAttributes, now)(repos);
|
|
28
28
|
if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
|
|
29
29
|
if (reserveTransaction.object.disablePendingReservations === true) {
|
|
30
30
|
// Pendingが存在しない場合は検索しても無駄(2023-06-05~)
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
typeOf: factory.reservationType.EventReservation
|
|
36
|
-
});
|
|
37
|
-
canceledReservations = canceledReservations.map((r) => {
|
|
38
|
-
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
39
|
-
delete r._id;
|
|
40
|
-
return r;
|
|
41
|
-
});
|
|
33
|
+
// 完全廃止(2023-07-19~)
|
|
34
|
+
throw new factory.errors.NotImplemented('disablePendingReservations must be true');
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false, {
|
|
@@ -48,7 +41,7 @@ function cancelPendingReservation(actionAttributes) {
|
|
|
48
41
|
});
|
|
49
42
|
}
|
|
50
43
|
exports.cancelPendingReservation = cancelPendingReservation;
|
|
51
|
-
function cancelPengindIfNotYet(params,
|
|
44
|
+
function cancelPengindIfNotYet(params, __) {
|
|
52
45
|
// tslint:disable-next-line:max-func-body-length
|
|
53
46
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
47
|
const actionAttributes = params;
|
|
@@ -83,7 +76,7 @@ function cancelPengindIfNotYet(params, now) {
|
|
|
83
76
|
// アクション開始
|
|
84
77
|
const action = yield repos.action.start(actionAttributes);
|
|
85
78
|
const actionObject = actionAttributes.object;
|
|
86
|
-
let cancelResult;
|
|
79
|
+
// let cancelResult: ICancelResult | undefined;
|
|
87
80
|
try {
|
|
88
81
|
if (reserveTransaction !== undefined) {
|
|
89
82
|
const reservationFor = reserveTransaction.object.reservationFor;
|
|
@@ -126,12 +119,8 @@ function cancelPengindIfNotYet(params, now) {
|
|
|
126
119
|
// disablePendingReservationsの場合は処理不要(2023-06-05~)
|
|
127
120
|
}
|
|
128
121
|
else {
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
reservationNumber: actionObject.reservationNumber,
|
|
132
|
-
previousReservationStatus: actionObject.reservationStatus,
|
|
133
|
-
modifiedTime: now
|
|
134
|
-
});
|
|
122
|
+
// 完全廃止(2023-07-19~)
|
|
123
|
+
throw new factory.errors.NotImplemented('disablePendingReservations must be true');
|
|
135
124
|
}
|
|
136
125
|
}
|
|
137
126
|
else {
|
|
@@ -152,17 +141,15 @@ function cancelPengindIfNotYet(params, now) {
|
|
|
152
141
|
throw error;
|
|
153
142
|
}
|
|
154
143
|
// アクション完了
|
|
155
|
-
const actionResult =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
} : undefined
|
|
144
|
+
const actionResult = {
|
|
145
|
+
// ...(cancelResult !== undefined) ? {
|
|
146
|
+
// cancelResult: {
|
|
147
|
+
// matchedCount: cancelResult.matchedCount,
|
|
148
|
+
// modifiedCount: cancelResult.modifiedCount
|
|
149
|
+
// }
|
|
150
|
+
// } : undefined
|
|
164
151
|
// canceledReservationId: canceledReservation?.id
|
|
165
|
-
|
|
152
|
+
};
|
|
166
153
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
167
154
|
}
|
|
168
155
|
return { reserveTransaction };
|
|
@@ -51,7 +51,7 @@ exports.confirmReservation = confirmReservation;
|
|
|
51
51
|
function reserveIfNotYet(params, options) {
|
|
52
52
|
// tslint:disable-next-line:max-func-body-length
|
|
53
53
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a;
|
|
54
|
+
var _a, _b;
|
|
55
55
|
const reservationPackage = params.object;
|
|
56
56
|
// 冪等性を担保(2023-05-31~)
|
|
57
57
|
debug('searching completed reserveAction... byTask:', options === null || options === void 0 ? void 0 : options.byTask, 'reservationNumber:', reservationPackage.reservationNumber);
|
|
@@ -97,50 +97,32 @@ function reserveIfNotYet(params, options) {
|
|
|
97
97
|
if (reserveTransaction.object.disablePendingReservations === true) {
|
|
98
98
|
const reservationFor = reserveTransaction.object.reservationFor;
|
|
99
99
|
const subReservations = reserveTransaction.object.subReservation;
|
|
100
|
-
|
|
100
|
+
const issuedThrough = reserveTransaction.object.issuedThrough;
|
|
101
|
+
if (Array.isArray(subReservations)
|
|
102
|
+
&& typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.typeOf) === 'string'
|
|
103
|
+
&& typeof (issuedThrough === null || issuedThrough === void 0 ? void 0 : issuedThrough.typeOf) === 'string') {
|
|
101
104
|
// confirmManyに変更(2023-06-13~)
|
|
102
105
|
const confirmManyIfNotExistResult = yield repos.reservation.confirmManyIfNotExist({
|
|
106
|
+
provider: (typeof ((_b = reserveTransaction.object.provider) === null || _b === void 0 ? void 0 : _b.id) === 'string')
|
|
107
|
+
? reserveTransaction.object.provider
|
|
108
|
+
: { id: reserveTransaction.agent.id, typeOf: factory.organizationType.Corporation },
|
|
103
109
|
subReservation: subReservations,
|
|
110
|
+
issuedThrough,
|
|
104
111
|
reservationFor,
|
|
105
112
|
underName,
|
|
106
|
-
broker: reserveTransaction.object.broker
|
|
107
|
-
issuedThrough: reserveTransaction.object.issuedThrough
|
|
113
|
+
broker: reserveTransaction.object.broker
|
|
108
114
|
});
|
|
109
115
|
debug('confirmManyIfNotExistResult:', confirmManyIfNotExistResult, 'reservationNumber:', reservationPackage.reservationNumber);
|
|
110
|
-
// await Promise.all(subReservations.map(async (subReservation) => {
|
|
111
|
-
// await repos.reservation.confirmByIdIfNotExist({
|
|
112
|
-
// reservation: subReservation,
|
|
113
|
-
// reservationFor,
|
|
114
|
-
// underName,
|
|
115
|
-
// broker: reserveTransaction.object.broker,
|
|
116
|
-
// issuedThrough: reserveTransaction.object.issuedThrough
|
|
117
|
-
// });
|
|
118
|
-
// }));
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
else {
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
reservationNumber: reservationPackage.reservationNumber,
|
|
125
|
-
previousReservationStatus: reservationPackage.reservationStatus,
|
|
126
|
-
underName,
|
|
127
|
-
broker: reserveTransaction.object.broker,
|
|
128
|
-
issuedThrough: reserveTransaction.object.issuedThrough
|
|
129
|
-
});
|
|
119
|
+
// 完全廃止(2023-07-19~)
|
|
120
|
+
throw new factory.errors.NotImplemented('disablePendingReservations must be true');
|
|
130
121
|
}
|
|
131
122
|
}
|
|
132
123
|
else {
|
|
133
124
|
// 廃止(2023-01-18)
|
|
134
125
|
throw new factory.errors.Forbidden(`${reservationPackage.typeOf} not acceptable`);
|
|
135
|
-
// 予約を確定状態に変更する
|
|
136
|
-
// await repos.reservation.confirm<factory.reservationType.EventReservation>({
|
|
137
|
-
// id: reservation.id,
|
|
138
|
-
// previousReservationStatus: reservation.reservationStatus,
|
|
139
|
-
// underName: reservation.underName
|
|
140
|
-
// });
|
|
141
|
-
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
142
|
-
// delete (<any>reservation)._id;
|
|
143
|
-
// confirmedReservations.push(reservation);
|
|
144
126
|
}
|
|
145
127
|
}
|
|
146
128
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.160.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.316.0-alpha.0",
|
|
13
|
+
"@cinerino/sdk": "3.160.0-alpha.5",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.4.0-alpha.
|
|
120
|
+
"version": "21.4.0-alpha.15"
|
|
121
121
|
}
|