@chevre/domain 21.5.0-alpha.2 → 21.5.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/assetTransaction.js +13 -9
- package/lib/chevre/repo/event.d.ts +25 -0
- package/lib/chevre/repo/event.js +19 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +6 -0
- package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +11 -3
- package/lib/chevre/service/assetTransaction/cancelReservation.js +13 -6
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +83 -0
- package/lib/chevre/service/task/returnReserveTransaction.js +2 -1
- package/package.json +3 -3
|
@@ -24,7 +24,7 @@ class MongoRepository {
|
|
|
24
24
|
}
|
|
25
25
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
26
26
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
27
|
-
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;
|
|
27
|
+
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, _22, _23, _24;
|
|
28
28
|
const andConditions = [
|
|
29
29
|
{
|
|
30
30
|
typeOf: params.typeOf
|
|
@@ -176,7 +176,11 @@ class MongoRepository {
|
|
|
176
176
|
case factory.assetTransactionType.CancelReservation:
|
|
177
177
|
break;
|
|
178
178
|
case factory.assetTransactionType.Reserve:
|
|
179
|
-
const
|
|
179
|
+
const objectProviderIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.provider) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
|
|
180
|
+
if (typeof objectProviderIdEq === 'string') {
|
|
181
|
+
andConditions.push({ 'object.provider.id': { $exists: true, $eq: objectProviderIdEq } });
|
|
182
|
+
}
|
|
183
|
+
const objectReservationForIdEq = (_1 = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationFor) === null || _0 === void 0 ? void 0 : _0.id) === null || _1 === void 0 ? void 0 : _1.$eq;
|
|
180
184
|
if (typeof objectReservationForIdEq === 'string') {
|
|
181
185
|
andConditions.push({
|
|
182
186
|
'object.reservationFor.id': {
|
|
@@ -185,7 +189,7 @@ class MongoRepository {
|
|
|
185
189
|
}
|
|
186
190
|
});
|
|
187
191
|
}
|
|
188
|
-
const objectReservationNumberIn = (
|
|
192
|
+
const objectReservationNumberIn = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.reservationNumber) === null || _3 === void 0 ? void 0 : _3.$in;
|
|
189
193
|
if (Array.isArray(objectReservationNumberIn)) {
|
|
190
194
|
andConditions.push({
|
|
191
195
|
'object.reservationNumber': {
|
|
@@ -194,7 +198,7 @@ class MongoRepository {
|
|
|
194
198
|
}
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
|
-
const objectReservationNumberEq = (
|
|
201
|
+
const objectReservationNumberEq = (_5 = (_4 = params.object) === null || _4 === void 0 ? void 0 : _4.reservationNumber) === null || _5 === void 0 ? void 0 : _5.$eq;
|
|
198
202
|
if (typeof objectReservationNumberEq === 'string') {
|
|
199
203
|
andConditions.push({
|
|
200
204
|
'object.reservationNumber': {
|
|
@@ -203,7 +207,7 @@ class MongoRepository {
|
|
|
203
207
|
}
|
|
204
208
|
});
|
|
205
209
|
}
|
|
206
|
-
const objectSubReservationIdIn = (
|
|
210
|
+
const objectSubReservationIdIn = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.reservations) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$in;
|
|
207
211
|
if (Array.isArray(objectSubReservationIdIn)) {
|
|
208
212
|
andConditions.push({
|
|
209
213
|
'object.subReservation.id': {
|
|
@@ -238,7 +242,7 @@ class MongoRepository {
|
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
|
-
const objectUnderNameIdEq = (
|
|
245
|
+
const objectUnderNameIdEq = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.underName) === null || _10 === void 0 ? void 0 : _10.id) === null || _11 === void 0 ? void 0 : _11.$eq;
|
|
242
246
|
if (typeof objectUnderNameIdEq === 'string') {
|
|
243
247
|
andConditions.push({
|
|
244
248
|
'object.underName.id': {
|
|
@@ -247,7 +251,7 @@ class MongoRepository {
|
|
|
247
251
|
}
|
|
248
252
|
});
|
|
249
253
|
}
|
|
250
|
-
const objectSubReservationSeatNumberEq = (
|
|
254
|
+
const objectSubReservationSeatNumberEq = (_16 = (_15 = (_14 = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.reservations) === null || _13 === void 0 ? void 0 : _13.reservedTicket) === null || _14 === void 0 ? void 0 : _14.ticketedSeat) === null || _15 === void 0 ? void 0 : _15.seatNumber) === null || _16 === void 0 ? void 0 : _16.$eq;
|
|
251
255
|
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
252
256
|
andConditions.push({
|
|
253
257
|
'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
@@ -258,7 +262,7 @@ class MongoRepository {
|
|
|
258
262
|
}
|
|
259
263
|
break;
|
|
260
264
|
case factory.assetTransactionType.RegisterService:
|
|
261
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
265
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_20 = (_19 = (_18 = (_17 = params.object) === null || _17 === void 0 ? void 0 : _17.itemOffered) === null || _18 === void 0 ? void 0 : _18.serviceOutput) === null || _19 === void 0 ? void 0 : _19.identifier) === null || _20 === void 0 ? void 0 : _20.$eq;
|
|
262
266
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
263
267
|
andConditions.push({
|
|
264
268
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -267,7 +271,7 @@ class MongoRepository {
|
|
|
267
271
|
}
|
|
268
272
|
});
|
|
269
273
|
}
|
|
270
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
274
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_24 = (_23 = (_22 = (_21 = params.object) === null || _21 === void 0 ? void 0 : _21.itemOffered) === null || _22 === void 0 ? void 0 : _22.serviceOutput) === null || _23 === void 0 ? void 0 : _23.identifier) === null || _24 === void 0 ? void 0 : _24.$in;
|
|
271
275
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
272
276
|
andConditions.push({
|
|
273
277
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -202,6 +202,31 @@ export declare class MongoRepository {
|
|
|
202
202
|
id: string;
|
|
203
203
|
};
|
|
204
204
|
}): Promise<import("mongodb").DeleteResult>;
|
|
205
|
+
deleteManyByScreeningRoom(params: {
|
|
206
|
+
project: {
|
|
207
|
+
id: string;
|
|
208
|
+
};
|
|
209
|
+
location: {
|
|
210
|
+
/**
|
|
211
|
+
* ルームコード
|
|
212
|
+
*/
|
|
213
|
+
branchCode: string;
|
|
214
|
+
containedInPlace: {
|
|
215
|
+
/**
|
|
216
|
+
* 施設ID
|
|
217
|
+
*/
|
|
218
|
+
id: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
222
|
+
deleteManyBySuperEventId(params: {
|
|
223
|
+
project: {
|
|
224
|
+
id: string;
|
|
225
|
+
};
|
|
226
|
+
superEvent: {
|
|
227
|
+
id: string;
|
|
228
|
+
};
|
|
229
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
205
230
|
deleteManyBySuperEventLocationId(params: {
|
|
206
231
|
project: {
|
|
207
232
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -926,6 +926,25 @@ class MongoRepository {
|
|
|
926
926
|
.exec();
|
|
927
927
|
});
|
|
928
928
|
}
|
|
929
|
+
deleteManyByScreeningRoom(params) {
|
|
930
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
931
|
+
return this.eventModel.deleteMany({
|
|
932
|
+
'project.id': { $eq: params.project.id },
|
|
933
|
+
'location.branchCode': { $exists: true, $eq: params.location.branchCode },
|
|
934
|
+
'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
|
|
935
|
+
})
|
|
936
|
+
.exec();
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
deleteManyBySuperEventId(params) {
|
|
940
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
941
|
+
return this.eventModel.deleteMany({
|
|
942
|
+
'project.id': { $eq: params.project.id },
|
|
943
|
+
'superEvent.id': { $exists: true, $eq: params.superEvent.id }
|
|
944
|
+
})
|
|
945
|
+
.exec();
|
|
946
|
+
});
|
|
947
|
+
}
|
|
929
948
|
deleteManyBySuperEventLocationId(params) {
|
|
930
949
|
return __awaiter(this, void 0, void 0, function* () {
|
|
931
950
|
return this.eventModel.deleteMany({
|
|
@@ -99,6 +99,12 @@ schema.index({ 'object.paymentMethodId': 1, startDate: -1 }, {
|
|
|
99
99
|
'object.paymentMethodId': { $exists: true }
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
+
schema.index({ 'object.provider.id': 1, startDate: -1 }, {
|
|
103
|
+
name: 'searchByObjectProviderId',
|
|
104
|
+
partialFilterExpression: {
|
|
105
|
+
'object.provider.id': { $exists: true }
|
|
106
|
+
}
|
|
107
|
+
});
|
|
102
108
|
schema.index({ 'object.subReservation.id': 1, startDate: -1 }, {
|
|
103
109
|
name: 'searchByObjectSubReservationsId',
|
|
104
110
|
partialFilterExpression: {
|
|
@@ -18,15 +18,23 @@ export type ITransactionOperation<T> = (repos: {
|
|
|
18
18
|
/**
|
|
19
19
|
* 取引開始
|
|
20
20
|
*/
|
|
21
|
-
export declare function start(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail
|
|
21
|
+
export declare function start(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {
|
|
22
|
+
seller: {
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
}): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
|
|
22
26
|
/**
|
|
23
27
|
* 取引確定
|
|
24
28
|
*/
|
|
25
29
|
export declare function confirm(params: factory.assetTransaction.cancelReservation.IConfirmParams): ITransactionOperation<void>;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* 取引開始&確定
|
|
28
32
|
*/
|
|
29
|
-
export declare function startAndConfirm(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {
|
|
33
|
+
export declare function startAndConfirm(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {
|
|
34
|
+
seller: {
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
}): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
|
|
30
38
|
/**
|
|
31
39
|
* 取引タスク出力
|
|
32
40
|
*/
|
|
@@ -18,16 +18,17 @@ const factory = require("../../factory");
|
|
|
18
18
|
const factory_1 = require("./cancelReservation/factory");
|
|
19
19
|
function validateStartParams(params) {
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a, _b;
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
22
|
let reserveTransaction;
|
|
23
23
|
let reservations;
|
|
24
|
+
const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
|
|
24
25
|
// 予約番号で取引存在確認
|
|
25
|
-
if (typeof ((
|
|
26
|
+
if (typeof ((_b = params.object.reservation) === null || _b === void 0 ? void 0 : _b.reservationNumber) === 'string') {
|
|
26
27
|
const transactions = yield repos.assetTransaction.search({
|
|
27
28
|
limit: 1,
|
|
28
29
|
page: 1,
|
|
29
30
|
typeOf: factory.assetTransactionType.Reserve,
|
|
30
|
-
object: { reservationNumber: { $eq: params.object.reservation.reservationNumber } }
|
|
31
|
+
object: Object.assign({ reservationNumber: { $eq: params.object.reservation.reservationNumber } }, (typeof sellerId === 'string') ? { provider: { id: { $eq: sellerId } } } : undefined)
|
|
31
32
|
});
|
|
32
33
|
reserveTransaction = transactions.shift();
|
|
33
34
|
// ここでReservationConfirmedでない予約をスルーしても、
|
|
@@ -48,15 +49,21 @@ function validateStartParams(params) {
|
|
|
48
49
|
// 取引指定が確認できなければ、予約指定を確認
|
|
49
50
|
if (reserveTransaction === undefined) {
|
|
50
51
|
// 予約存在確認
|
|
51
|
-
if (typeof ((
|
|
52
|
+
if (typeof ((_c = params.object.reservation) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
|
|
52
53
|
const reservation = yield repos.reservation.findById({
|
|
53
54
|
id: params.object.reservation.id
|
|
54
55
|
});
|
|
55
|
-
|
|
56
|
+
// 販売者検証(2023-08-01~)
|
|
57
|
+
if (typeof sellerId === 'string') {
|
|
58
|
+
if (((_d = reservation.provider) === null || _d === void 0 ? void 0 : _d.id) !== sellerId) {
|
|
59
|
+
throw new factory.errors.NotFound(factory.reservationType.EventReservation);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
56
62
|
// 予約ステータス確認
|
|
57
63
|
if (reservation.reservationStatus !== factory.reservationStatusType.ReservationConfirmed) {
|
|
58
64
|
throw new factory.errors.Argument('object.reservation.id', `Reservation ${reservation.id} not confirmed`);
|
|
59
65
|
}
|
|
66
|
+
reservations = [reservation];
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
if (reserveTransaction === undefined && reservations === undefined) {
|
|
@@ -125,7 +132,7 @@ function confirm(params) {
|
|
|
125
132
|
}
|
|
126
133
|
exports.confirm = confirm;
|
|
127
134
|
/**
|
|
128
|
-
*
|
|
135
|
+
* 取引開始&確定
|
|
129
136
|
*/
|
|
130
137
|
function startAndConfirm(params) {
|
|
131
138
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16,6 +16,19 @@ function onResourceDeleted(params) {
|
|
|
16
16
|
const isDeleted = params.isDeleted === true;
|
|
17
17
|
if (isDeleted) {
|
|
18
18
|
switch (params.typeOf) {
|
|
19
|
+
case factory.eventType.ScreeningEventSeries:
|
|
20
|
+
yield deleteResourcesByScreeningEventSeries({
|
|
21
|
+
project: { id: params.project.id },
|
|
22
|
+
ids: params.id
|
|
23
|
+
})(repos);
|
|
24
|
+
break;
|
|
25
|
+
case factory.placeType.ScreeningRoom:
|
|
26
|
+
yield deleteResourcesByScreeningRoom({
|
|
27
|
+
project: { id: params.project.id },
|
|
28
|
+
branchCode: params.branchCode,
|
|
29
|
+
containedInPlace: { id: params.containedInPlace.id }
|
|
30
|
+
})(repos);
|
|
31
|
+
break;
|
|
19
32
|
case factory.placeType.MovieTheater:
|
|
20
33
|
yield deleteResourcesByMovieTheater({
|
|
21
34
|
project: { id: params.project.id },
|
|
@@ -35,6 +48,76 @@ function onResourceDeleted(params) {
|
|
|
35
48
|
});
|
|
36
49
|
}
|
|
37
50
|
exports.onResourceDeleted = onResourceDeleted;
|
|
51
|
+
function deleteResourcesByScreeningEventSeries(params) {
|
|
52
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (params.ids.length !== 1) {
|
|
54
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
55
|
+
}
|
|
56
|
+
for (const eventId of params.ids) {
|
|
57
|
+
const deleteActionAttributes = {
|
|
58
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
59
|
+
object: { id: eventId, typeOf: factory.eventType.ScreeningEventSeries },
|
|
60
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
61
|
+
typeOf: factory.actionType.DeleteAction
|
|
62
|
+
};
|
|
63
|
+
let deleteResult;
|
|
64
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
65
|
+
try {
|
|
66
|
+
// イベント削除
|
|
67
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyBySuperEventId({
|
|
68
|
+
project: { id: params.project.id },
|
|
69
|
+
superEvent: { id: eventId }
|
|
70
|
+
});
|
|
71
|
+
deleteResult = { deleteScreeningEventResult };
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
try {
|
|
75
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
76
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
77
|
+
}
|
|
78
|
+
catch (_) {
|
|
79
|
+
// no op
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function deleteResourcesByScreeningRoom(params) {
|
|
88
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const deleteActionAttributes = {
|
|
90
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
91
|
+
object: { branchCode: params.branchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
|
|
92
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
93
|
+
typeOf: factory.actionType.DeleteAction
|
|
94
|
+
};
|
|
95
|
+
let deleteResult;
|
|
96
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
97
|
+
try {
|
|
98
|
+
// イベント削除
|
|
99
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyByScreeningRoom({
|
|
100
|
+
project: { id: params.project.id },
|
|
101
|
+
location: {
|
|
102
|
+
branchCode: params.branchCode,
|
|
103
|
+
containedInPlace: { id: params.containedInPlace.id }
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
deleteResult = { deleteScreeningEventResult };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
try {
|
|
110
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
111
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
112
|
+
}
|
|
113
|
+
catch (_) {
|
|
114
|
+
// no op
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
119
|
+
});
|
|
120
|
+
}
|
|
38
121
|
function deleteResourcesByMovieTheater(params) {
|
|
39
122
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
40
123
|
if (params.ids.length !== 1) {
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.162.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.321.0",
|
|
13
|
+
"@cinerino/sdk": "3.162.0-alpha.7",
|
|
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.5.0-alpha.
|
|
120
|
+
"version": "21.5.0-alpha.4"
|
|
121
121
|
}
|