@chevre/domain 21.4.0-alpha.14 → 21.4.0-alpha.16
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/migrateReservationProvider.ts +107 -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/order.d.ts +3 -0
- package/lib/chevre/repo/order.js +5 -5
- package/lib/chevre/repo/reservation.d.ts +33 -20
- package/lib/chevre/repo/reservation.js +97 -79
- 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/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -1
- 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);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
13
|
+
|
|
14
|
+
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
15
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = reservationRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
typeOf: {
|
|
20
|
+
$in: [
|
|
21
|
+
chevre.factory.reservationType.EventReservation
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
// bookingTime: {
|
|
25
|
+
// $gte: moment('2023-06-09T00:00:00Z')
|
|
26
|
+
// .toDate()
|
|
27
|
+
// }
|
|
28
|
+
// organizer: { $exists: false }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_id: 1,
|
|
32
|
+
project: 1,
|
|
33
|
+
provider: 1,
|
|
34
|
+
bookingTime: 1,
|
|
35
|
+
reservationFor: 1
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
console.log('reservations found');
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
await cursor.eachAsync(async (doc) => {
|
|
43
|
+
i += 1;
|
|
44
|
+
const reservation: Pick<
|
|
45
|
+
chevre.factory.reservation.IReservation<chevre.factory.reservationType.EventReservation>,
|
|
46
|
+
'id' | 'project' | 'provider' | 'bookingTime' | 'reservationFor'
|
|
47
|
+
> = doc.toObject();
|
|
48
|
+
|
|
49
|
+
const providerId = reservation.provider?.id;
|
|
50
|
+
const alreadyMigrated = typeof providerId === 'string';
|
|
51
|
+
|
|
52
|
+
if (alreadyMigrated) {
|
|
53
|
+
console.log('already exist...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
54
|
+
} else {
|
|
55
|
+
const movieTheaterId: string = reservation.reservationFor.superEvent.location.id;
|
|
56
|
+
const movieTheaterBranchCode: string = reservation.reservationFor.superEvent.location.branchCode;
|
|
57
|
+
const movieTheaters = <Pick<
|
|
58
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
59
|
+
'parentOrganization' | 'branchCode'
|
|
60
|
+
>[]>
|
|
61
|
+
await placeRepo.searchMovieTheaters(
|
|
62
|
+
{
|
|
63
|
+
limit: 1,
|
|
64
|
+
page: 1,
|
|
65
|
+
project: { id: { $eq: reservation.project.id } },
|
|
66
|
+
id: { $eq: movieTheaterId }
|
|
67
|
+
},
|
|
68
|
+
['parentOrganization', 'branchCode'],
|
|
69
|
+
[]
|
|
70
|
+
);
|
|
71
|
+
const movieTheater = movieTheaters.shift();
|
|
72
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
73
|
+
console.log(
|
|
74
|
+
'movieTheater found',
|
|
75
|
+
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
76
|
+
'movieTheaterId:', movieTheaterId,
|
|
77
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
78
|
+
i
|
|
79
|
+
);
|
|
80
|
+
if (typeof sellerId !== 'string') {
|
|
81
|
+
throw new Error('movieTheater not found');
|
|
82
|
+
}
|
|
83
|
+
if (typeof sellerId === 'string') {
|
|
84
|
+
const newProvider: chevre.factory.reservation.IProvider = {
|
|
85
|
+
id: sellerId,
|
|
86
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
87
|
+
};
|
|
88
|
+
console.log('updating reservation...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
89
|
+
await reservationRepo.updatePartiallyById({
|
|
90
|
+
id: reservation.id,
|
|
91
|
+
update: <any>{
|
|
92
|
+
provider: newProvider
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
updateCount += 1;
|
|
96
|
+
console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log(i, 'reservations checked');
|
|
102
|
+
console.log(updateCount, 'reservations updated');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
main()
|
|
106
|
+
.then()
|
|
107
|
+
.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' });
|
|
@@ -77,6 +77,9 @@ export declare class MongoRepository {
|
|
|
77
77
|
findByOrderNumberAndReservationId(params: {
|
|
78
78
|
orderNumber: string;
|
|
79
79
|
reservationId: string;
|
|
80
|
+
seller?: {
|
|
81
|
+
id?: string;
|
|
82
|
+
};
|
|
80
83
|
}): Promise<Pick<factory.order.IOrder, 'orderNumber' | 'orderStatus' | 'typeOf'>>;
|
|
81
84
|
/**
|
|
82
85
|
* 注文番号で削除する
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -853,6 +853,7 @@ class MongoRepository {
|
|
|
853
853
|
});
|
|
854
854
|
}
|
|
855
855
|
findByOrderNumberAndReservationId(params) {
|
|
856
|
+
var _a;
|
|
856
857
|
return __awaiter(this, void 0, void 0, function* () {
|
|
857
858
|
const projection = {
|
|
858
859
|
orderStatus: 1,
|
|
@@ -860,15 +861,14 @@ class MongoRepository {
|
|
|
860
861
|
orderNumber: 1,
|
|
861
862
|
_id: 0
|
|
862
863
|
};
|
|
863
|
-
const doc = yield this.orderModel.findOne({
|
|
864
|
-
orderNumber: { $eq: params.orderNumber },
|
|
865
|
-
acceptedOffers: {
|
|
864
|
+
const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, acceptedOffers: {
|
|
866
865
|
$elemMatch: {
|
|
867
866
|
'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
|
|
868
867
|
'itemOffered.id': { $eq: params.reservationId }
|
|
869
868
|
}
|
|
870
|
-
}
|
|
871
|
-
|
|
869
|
+
} }, (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
870
|
+
? { 'seller.id': { $exists: true, $eq: params.seller.id } }
|
|
871
|
+
: undefined), projection)
|
|
872
872
|
.exec();
|
|
873
873
|
if (doc === null) {
|
|
874
874
|
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
2
26
|
import { Connection, UpdateWriteOpResult } from 'mongoose';
|
|
3
27
|
import * as factory from '../factory';
|
|
@@ -6,6 +30,11 @@ export interface IUpdatePartiallyParams {
|
|
|
6
30
|
'reservedTicket.dateUsed'?: Date;
|
|
7
31
|
}
|
|
8
32
|
export type ICancelResult = UpdateWriteOpResult;
|
|
33
|
+
export type ICreatingReservation<T extends factory.reservationType> = T extends factory.reservationType.BusReservation ? (factory.reservation.busReservation.IReservation) & {
|
|
34
|
+
_id: string;
|
|
35
|
+
} : T extends factory.reservationType.EventReservation ? (factory.reservation.eventReservation.IReservation) & {
|
|
36
|
+
_id: string;
|
|
37
|
+
} : never;
|
|
9
38
|
/**
|
|
10
39
|
* 予約リポジトリ
|
|
11
40
|
*/
|
|
@@ -13,10 +42,6 @@ export declare class MongoRepository {
|
|
|
13
42
|
private readonly reservationModel;
|
|
14
43
|
constructor(connection: Connection);
|
|
15
44
|
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
45
|
/**
|
|
21
46
|
* 汎用予約カウント
|
|
22
47
|
*/
|
|
@@ -32,26 +57,13 @@ export declare class MongoRepository {
|
|
|
32
57
|
inclusion?: string[];
|
|
33
58
|
exclusion?: string[];
|
|
34
59
|
}): 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
60
|
confirmManyIfNotExist(params: {
|
|
61
|
+
provider: factory.reservation.IProvider;
|
|
50
62
|
subReservation: factory.assetTransaction.reserve.IObjectSubReservation[];
|
|
63
|
+
issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
|
|
51
64
|
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
52
65
|
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
53
66
|
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
54
|
-
issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
55
67
|
}): Promise<BulkWriteOpResultObject | void>;
|
|
56
68
|
/**
|
|
57
69
|
* 予約取消
|
|
@@ -103,7 +115,7 @@ export declare class MongoRepository {
|
|
|
103
115
|
updatePartiallyById(params: {
|
|
104
116
|
id: string;
|
|
105
117
|
update: IUpdatePartiallyParams;
|
|
106
|
-
}): Promise<factory.reservation.eventReservation.IReservation
|
|
118
|
+
}): Promise<Pick<factory.reservation.eventReservation.IReservation, 'id'>>;
|
|
107
119
|
deleteByIds(params: {
|
|
108
120
|
project: {
|
|
109
121
|
id: string;
|
|
@@ -131,4 +143,5 @@ export declare class MongoRepository {
|
|
|
131
143
|
};
|
|
132
144
|
}): Promise<string[]>;
|
|
133
145
|
deleteReservedTicketUnderName(): Promise<import("mongodb").UpdateResult>;
|
|
146
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
134
147
|
}
|