@chevre/domain 20.1.0-alpha.40 → 20.1.0-alpha.42
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/reservation.d.ts +5 -4
- package/lib/chevre/repo/reservation.js +3 -3
- package/lib/chevre/service/reserve/cancelReservation.js +17 -14
- package/lib/chevre/service/reserve/factory.d.ts +14 -2
- package/lib/chevre/service/reserve/factory.js +2 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +20 -2
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Connection } from 'mongoose';
|
|
1
|
+
import { Connection, UpdateWriteOpResult } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
export interface IUpdatePartiallyParams {
|
|
4
4
|
additionalTicketText?: string;
|
|
5
5
|
'reservedTicket.dateUsed'?: Date;
|
|
6
6
|
}
|
|
7
|
+
export declare type ICancelResult = UpdateWriteOpResult;
|
|
7
8
|
/**
|
|
8
9
|
* 予約リポジトリ
|
|
9
10
|
*/
|
|
@@ -46,7 +47,7 @@ export declare class MongoRepository {
|
|
|
46
47
|
cancel<T extends factory.reservationType>(params: {
|
|
47
48
|
id: string;
|
|
48
49
|
previousReservationStatus?: factory.reservationStatusType;
|
|
49
|
-
|
|
50
|
+
modifiedTime: Date;
|
|
50
51
|
}): Promise<factory.reservation.IReservation<T>>;
|
|
51
52
|
/**
|
|
52
53
|
* 予約取消
|
|
@@ -54,8 +55,8 @@ export declare class MongoRepository {
|
|
|
54
55
|
cancelByReservationNumber(params: {
|
|
55
56
|
reservationNumber: string;
|
|
56
57
|
previousReservationStatus?: factory.reservationStatusType;
|
|
57
|
-
|
|
58
|
-
}): Promise<
|
|
58
|
+
modifiedTime: Date;
|
|
59
|
+
}): Promise<ICancelResult>;
|
|
59
60
|
/**
|
|
60
61
|
* 発券する
|
|
61
62
|
*/
|
|
@@ -934,7 +934,7 @@ class MongoRepository {
|
|
|
934
934
|
: undefined);
|
|
935
935
|
const update = Object.assign(Object.assign({}, (typeof params.previousReservationStatus === 'string')
|
|
936
936
|
? { previousReservationStatus: params.previousReservationStatus }
|
|
937
|
-
: undefined), { reservationStatus: factory.reservationStatusType.ReservationCancelled, modifiedTime: params.
|
|
937
|
+
: undefined), { reservationStatus: factory.reservationStatusType.ReservationCancelled, modifiedTime: params.modifiedTime });
|
|
938
938
|
const doc = yield this.reservationModel.findOneAndUpdate(conditions, update, { new: true })
|
|
939
939
|
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
940
940
|
.exec();
|
|
@@ -962,8 +962,8 @@ class MongoRepository {
|
|
|
962
962
|
: undefined);
|
|
963
963
|
const update = Object.assign(Object.assign({}, (typeof params.previousReservationStatus === 'string')
|
|
964
964
|
? { previousReservationStatus: params.previousReservationStatus }
|
|
965
|
-
: undefined), { reservationStatus: factory.reservationStatusType.ReservationCancelled, modifiedTime: params.
|
|
966
|
-
|
|
965
|
+
: undefined), { reservationStatus: factory.reservationStatusType.ReservationCancelled, modifiedTime: params.modifiedTime });
|
|
966
|
+
return this.reservationModel.updateMany(conditions, update)
|
|
967
967
|
.exec();
|
|
968
968
|
});
|
|
969
969
|
}
|
|
@@ -33,6 +33,7 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
33
33
|
const reserveTransactionId = actionAttributes.purpose.id;
|
|
34
34
|
// アクション開始
|
|
35
35
|
const action = yield repos.action.start(actionAttributes);
|
|
36
|
+
let cancelResult;
|
|
36
37
|
try {
|
|
37
38
|
// 予約取引を検索
|
|
38
39
|
const reserveTransactions = yield repos.assetTransaction.search({
|
|
@@ -44,12 +45,12 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
44
45
|
const reserveTransaction = reserveTransactions.shift();
|
|
45
46
|
const actionObject = actionAttributes.object;
|
|
46
47
|
if (reserveTransaction !== undefined) {
|
|
48
|
+
const reservationFor = reserveTransaction.object.reservationFor;
|
|
49
|
+
if (reservationFor === undefined) {
|
|
50
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
51
|
+
}
|
|
47
52
|
// ReservationPackageに対応(2022-12-23~)
|
|
48
53
|
if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
|
|
49
|
-
const reservationFor = reserveTransaction.object.reservationFor;
|
|
50
|
-
if (reservationFor === undefined) {
|
|
51
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
52
|
-
}
|
|
53
54
|
const subReservation = reserveTransaction.object.subReservation;
|
|
54
55
|
if (Array.isArray(subReservation) && subReservation.length > 0) {
|
|
55
56
|
yield Promise.all(subReservation.map((cancelingSubReservation) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -62,10 +63,10 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
62
63
|
})));
|
|
63
64
|
}
|
|
64
65
|
// 予約番号単位でキャンセル状態に変更する
|
|
65
|
-
yield repos.reservation.cancelByReservationNumber({
|
|
66
|
+
cancelResult = yield repos.reservation.cancelByReservationNumber({
|
|
66
67
|
reservationNumber: actionObject.reservationNumber,
|
|
67
68
|
previousReservationStatus: actionObject.reservationStatus,
|
|
68
|
-
now
|
|
69
|
+
modifiedTime: now
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
@@ -74,10 +75,6 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
74
75
|
});
|
|
75
76
|
// 取消対象予約が取引に存在すれば、適宜unlock
|
|
76
77
|
if (cancelingSubReservation !== undefined) {
|
|
77
|
-
const reservationFor = reserveTransaction.object.reservationFor;
|
|
78
|
-
if (reservationFor === undefined) {
|
|
79
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
80
|
-
}
|
|
81
78
|
const cancelingReservation = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
|
|
82
79
|
yield processUnlockSeat({
|
|
83
80
|
reservation: cancelingReservation,
|
|
@@ -93,7 +90,7 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
93
90
|
yield repos.reservation.cancel({
|
|
94
91
|
id: cancelingSubReservation.id,
|
|
95
92
|
previousReservationStatus: actionObject.reservationStatus,
|
|
96
|
-
now
|
|
93
|
+
modifiedTime: now
|
|
97
94
|
});
|
|
98
95
|
// canceledReservations.push(canceledReservation);
|
|
99
96
|
}
|
|
@@ -113,9 +110,15 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
113
110
|
throw error;
|
|
114
111
|
}
|
|
115
112
|
// アクション完了
|
|
116
|
-
const actionResult = {
|
|
113
|
+
const actionResult = Object.assign({}, (cancelResult !== undefined) ? {
|
|
114
|
+
cancelResult: {
|
|
115
|
+
n: cancelResult.n,
|
|
116
|
+
nModified: cancelResult.nModified,
|
|
117
|
+
ok: cancelResult.ok
|
|
118
|
+
}
|
|
119
|
+
} : undefined
|
|
117
120
|
// canceledReservationId: canceledReservation?.id
|
|
118
|
-
|
|
121
|
+
);
|
|
119
122
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
120
123
|
yield (0, onReservationCanceled_1.onReservationCanceledByAction)(actionAttributes)({ task: repos.task });
|
|
121
124
|
})));
|
|
@@ -178,7 +181,7 @@ function cancelReservation(actionAttributesList) {
|
|
|
178
181
|
canceledReservation = yield repos.reservation.cancel({
|
|
179
182
|
id: reservation.id,
|
|
180
183
|
previousReservationStatus: actionAttributes.object.reservationStatus,
|
|
181
|
-
now
|
|
184
|
+
modifiedTime: now
|
|
182
185
|
});
|
|
183
186
|
canceledReservations.push(canceledReservation);
|
|
184
187
|
}
|
|
@@ -5,10 +5,22 @@ export interface IProject {
|
|
|
5
5
|
id: string;
|
|
6
6
|
typeOf: factory.organizationType.Project;
|
|
7
7
|
}
|
|
8
|
+
export declare type ISubReservation = Omit<IEventReservation, 'project' | 'reservationFor' | 'reservationNumber' | 'reservationStatus' | 'underName'>;
|
|
9
|
+
/**
|
|
10
|
+
* 確定予約通知
|
|
11
|
+
*/
|
|
12
|
+
export interface IReservationPackage4informConfirmed {
|
|
13
|
+
project: IProject;
|
|
14
|
+
reservationFor: factory.reservation.IReservationFor<factory.reservationType.EventReservation>;
|
|
15
|
+
reservationNumber: string;
|
|
16
|
+
reservationStatus: factory.reservationStatusType;
|
|
17
|
+
subReservation: ISubReservation[];
|
|
18
|
+
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
19
|
+
typeOf: factory.reservationType.ReservationPackage;
|
|
20
|
+
}
|
|
8
21
|
/**
|
|
9
22
|
* 確定予約通知
|
|
10
23
|
*/
|
|
11
|
-
export declare type IReservation4informConfirmed = IEventReservation;
|
|
12
24
|
/**
|
|
13
25
|
* 予約取消通知
|
|
14
26
|
*/
|
|
@@ -44,7 +56,7 @@ export interface IReservation4informUsed {
|
|
|
44
56
|
dateUsed?: Date;
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
|
-
export declare type IReservation4inform =
|
|
59
|
+
export declare type IReservation4inform = IReservationPackage4informConfirmed | IReservation4informCanceled | IReservation4informCheckedIn | IReservation4informUsed;
|
|
48
60
|
export declare type IInformObject = IReservation4inform[];
|
|
49
61
|
export declare type InformReservationActionattributes = factory.action.interact.inform.IAttributes<IInformObject, any>;
|
|
50
62
|
export declare const NUM_TRY_INFORM_RESERVATION: number;
|
|
@@ -3,13 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NUM_TRY_INFORM_RESERVATION = exports.maskUnderName = void 0;
|
|
4
4
|
const MASKED_PROFILE = '****';
|
|
5
5
|
function maskUnderName(reservation) {
|
|
6
|
-
var _a
|
|
6
|
+
var _a;
|
|
7
7
|
const underName = (typeof ((_a = reservation.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
8
8
|
? Object.assign(Object.assign({}, reservation.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE }) : undefined;
|
|
9
|
-
|
|
10
|
-
? Object.assign(Object.assign({}, reservation.reservedTicket.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE }) : undefined;
|
|
11
|
-
const reservedTicket = Object.assign(Object.assign({}, reservation.reservedTicket), (reservedTicketUnderName !== undefined) ? { underName: reservedTicketUnderName } : undefined);
|
|
12
|
-
return Object.assign(Object.assign(Object.assign({}, reservation), (underName !== undefined) ? { underName } : undefined), { reservedTicket });
|
|
9
|
+
return Object.assign(Object.assign({}, reservation), (underName !== undefined) ? { underName } : undefined);
|
|
13
10
|
}
|
|
14
11
|
exports.maskUnderName = maskUnderName;
|
|
15
12
|
exports.NUM_TRY_INFORM_RESERVATION = 10;
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.onReservationConfirmed = exports.onReservationConfirmedByAction = void 0;
|
|
13
24
|
/**
|
|
@@ -94,9 +105,16 @@ function onReservationConfirmed(confirmedReservations) {
|
|
|
94
105
|
// inform galobally
|
|
95
106
|
if (Array.isArray(informReservations)) {
|
|
96
107
|
taskAttributes.push(...informReservations.map((informReservation) => {
|
|
97
|
-
var _a;
|
|
108
|
+
var _a, _b;
|
|
98
109
|
const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
99
|
-
|
|
110
|
+
// ReservationPackage通知に変更(2022-12-24~)
|
|
111
|
+
// const informObject: IInformObject = confirmedReservations.map(maskUnderName);
|
|
112
|
+
const informObject = [Object.assign({ project: confirmedReservations[0].project, reservationFor: confirmedReservations[0].reservationFor, reservationNumber: confirmedReservations[0].reservationNumber, reservationStatus: confirmedReservations[0].reservationStatus, subReservation: confirmedReservations.map((r) => {
|
|
113
|
+
const { project, reservationFor, reservationNumber, reservationStatus, underName } = r, subReservation = __rest(r, ["project", "reservationFor", "reservationNumber", "reservationStatus", "underName"]);
|
|
114
|
+
return subReservation;
|
|
115
|
+
}), typeOf: factory.reservationType.ReservationPackage }, (typeof ((_b = confirmedReservations[0].underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
116
|
+
? { underName: (0, factory_1.maskUnderName)(confirmedReservations[0]).underName }
|
|
117
|
+
: undefined)];
|
|
100
118
|
const informReservationAttributes = {
|
|
101
119
|
agent: confirmedReservations[0].project,
|
|
102
120
|
object: informObject,
|
package/package.json
CHANGED