@chevre/domain 21.24.0 → 21.24.1
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/findReservationByCode.ts +2 -2
- package/lib/chevre/repo/code.d.ts +0 -1
- package/lib/chevre/repo/code.js +9 -9
- package/lib/chevre/repo/order.js +3 -1
- package/lib/chevre/repo/reservation.d.ts +3 -3
- package/lib/chevre/repo/reservation.js +0 -24
- package/lib/chevre/service/reserve/findByCode.d.ts +10 -3
- package/lib/chevre/service/reserve/findByCode.js +23 -46
- package/package.json +1 -1
|
@@ -11,11 +11,11 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
|
|
12
12
|
const CODE = '068cb0ba-8529-4a2b-8cf5-890d5af9c536';
|
|
13
13
|
const RESERVATION_ID = '589701779538948-0';
|
|
14
|
+
// const RESERVATION_ID = '589701779538948-1';
|
|
14
15
|
|
|
15
16
|
async function main() {
|
|
16
17
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
17
18
|
|
|
18
|
-
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
19
19
|
const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
|
|
20
20
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
21
21
|
const reservationRepo = await chevre.repository.Reservation.createInstance(mongoose.connection);
|
|
@@ -38,8 +38,8 @@ async function main() {
|
|
|
38
38
|
code: CODE,
|
|
39
39
|
id: RESERVATION_ID
|
|
40
40
|
})({
|
|
41
|
-
acceptedOffer: acceptedOfferRepo,
|
|
42
41
|
authorization: authorizationRepo,
|
|
42
|
+
order: orderRepo,
|
|
43
43
|
reservation: reservationRepo
|
|
44
44
|
});
|
|
45
45
|
// tslint:disable-next-line:no-null-keyword
|
|
@@ -30,7 +30,6 @@ export declare class MongoRepository {
|
|
|
30
30
|
};
|
|
31
31
|
code: ICode;
|
|
32
32
|
}): Promise<IObject>;
|
|
33
|
-
count(params: factory.authorization.ISearchConditions): Promise<number>;
|
|
34
33
|
search(params: factory.authorization.ISearchConditions): Promise<factory.authorization.IAuthorization[]>;
|
|
35
34
|
/**
|
|
36
35
|
* 有効期限を一定期間過ぎた承認を削除する
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -119,7 +119,9 @@ class MongoRepository {
|
|
|
119
119
|
code: { $eq: String(params.code) },
|
|
120
120
|
validFrom: { $lte: now },
|
|
121
121
|
validUntil: { $gte: now }
|
|
122
|
-
}, { object: 1 })
|
|
122
|
+
}, { object: 1, _id: 0 })
|
|
123
|
+
// projection的にleanで十分
|
|
124
|
+
.lean()
|
|
123
125
|
.exec();
|
|
124
126
|
if (doc === null) {
|
|
125
127
|
throw new factory.errors.NotFound(this.authorizationModel.modelName);
|
|
@@ -127,14 +129,12 @@ class MongoRepository {
|
|
|
127
129
|
return doc.object;
|
|
128
130
|
});
|
|
129
131
|
}
|
|
130
|
-
count(params) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
}
|
|
132
|
+
// public async count(params: factory.authorization.ISearchConditions): Promise<number> {
|
|
133
|
+
// const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
134
|
+
// return this.authorizationModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
135
|
+
// .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
136
|
+
// .exec();
|
|
137
|
+
// }
|
|
138
138
|
search(params) {
|
|
139
139
|
var _a;
|
|
140
140
|
return __awaiter(this, void 0, void 0, function* () {
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -936,11 +936,13 @@ class MongoRepository {
|
|
|
936
936
|
} }, (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
937
937
|
? { 'seller.id': { $exists: true, $eq: params.seller.id } }
|
|
938
938
|
: undefined), projection)
|
|
939
|
+
// projection的にleanで十分
|
|
940
|
+
.lean()
|
|
939
941
|
.exec();
|
|
940
942
|
if (doc === null) {
|
|
941
943
|
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
942
944
|
}
|
|
943
|
-
return doc
|
|
945
|
+
return doc;
|
|
944
946
|
});
|
|
945
947
|
}
|
|
946
948
|
/**
|
|
@@ -54,8 +54,8 @@ export declare class MongoRepository {
|
|
|
54
54
|
}): Promise<factory.reservation.IReservation<factory.reservationType.EventReservation>[]>;
|
|
55
55
|
findById<T extends factory.reservationType>(params: {
|
|
56
56
|
id: string;
|
|
57
|
-
inclusion?:
|
|
58
|
-
exclusion?:
|
|
57
|
+
inclusion?: IKeyOfProjection[];
|
|
58
|
+
exclusion?: IKeyOfProjection[];
|
|
59
59
|
}): Promise<factory.reservation.IReservation<T>>;
|
|
60
60
|
confirmManyIfNotExist(params: {
|
|
61
61
|
provider: factory.reservation.IProvider;
|
|
@@ -115,7 +115,7 @@ export declare class MongoRepository {
|
|
|
115
115
|
updatePartiallyById(params: {
|
|
116
116
|
id: string;
|
|
117
117
|
update: IUpdatePartiallyParams;
|
|
118
|
-
}): Promise<
|
|
118
|
+
}): Promise<void>;
|
|
119
119
|
deleteByIds(params: {
|
|
120
120
|
project: {
|
|
121
121
|
id: string;
|
|
@@ -878,29 +878,6 @@ class MongoRepository {
|
|
|
878
878
|
return doc.toObject();
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
|
-
// public async confirmByReservationNumber(params: {
|
|
882
|
-
// reservationNumber: string;
|
|
883
|
-
// previousReservationStatus: factory.reservationStatusType;
|
|
884
|
-
// underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
885
|
-
// broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
886
|
-
// issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
|
|
887
|
-
// }): Promise<void> {
|
|
888
|
-
// const conditions = {
|
|
889
|
-
// reservationNumber: { $eq: String(params.reservationNumber) },
|
|
890
|
-
// reservationStatus: { $eq: params.previousReservationStatus }
|
|
891
|
-
// };
|
|
892
|
-
// const update = {
|
|
893
|
-
// // previousReservationStatusを保管(2023-01-19~)
|
|
894
|
-
// previousReservationStatus: params.previousReservationStatus,
|
|
895
|
-
// reservationStatus: factory.reservationStatusType.ReservationConfirmed,
|
|
896
|
-
// modifiedTime: new Date(),
|
|
897
|
-
// ...(params.underName !== undefined) ? { underName: params.underName } : undefined,
|
|
898
|
-
// ...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined,
|
|
899
|
-
// ...(typeof params.issuedThrough?.typeOf === 'string') ? { issuedThrough: params.issuedThrough } : undefined
|
|
900
|
-
// };
|
|
901
|
-
// await this.reservationModel.updateMany(conditions, update)
|
|
902
|
-
// .exec();
|
|
903
|
-
// }
|
|
904
881
|
confirmManyIfNotExist(params) {
|
|
905
882
|
return __awaiter(this, void 0, void 0, function* () {
|
|
906
883
|
const modifiedTime = new Date();
|
|
@@ -1101,7 +1078,6 @@ class MongoRepository {
|
|
|
1101
1078
|
if (doc === null) {
|
|
1102
1079
|
throw new factory.errors.ArgumentNull(this.reservationModel.modelName);
|
|
1103
1080
|
}
|
|
1104
|
-
return doc.toObject();
|
|
1105
1081
|
});
|
|
1106
1082
|
});
|
|
1107
1083
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
3
2
|
import type { MongoRepository as AuthorizationRepo } from '../../repo/code';
|
|
3
|
+
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
4
|
import type { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
5
5
|
type AvailableReservationType = factory.reservationType.BusReservation | factory.reservationType.EventReservation;
|
|
6
6
|
type IReservationResult = Pick<factory.reservation.IReservation<AvailableReservationType>, 'id' | 'additionalTicketText' | 'reservationStatus'> & {
|
|
7
7
|
reservedTicket: {
|
|
8
|
-
ticketType: Pick<factory.reservation.ITicketType<AvailableReservationType>, 'identifier'
|
|
8
|
+
ticketType: Pick<factory.reservation.ITicketType<AvailableReservationType>, 'identifier'> & {
|
|
9
|
+
name: {
|
|
10
|
+
ja?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
14
|
};
|
|
11
15
|
declare function findByCode(params: {
|
|
@@ -20,9 +24,12 @@ declare function findByCode(params: {
|
|
|
20
24
|
* 注文コード
|
|
21
25
|
*/
|
|
22
26
|
code: string;
|
|
27
|
+
seller?: {
|
|
28
|
+
id?: string;
|
|
29
|
+
};
|
|
23
30
|
}): (repos: {
|
|
24
|
-
acceptedOffer: AcceptedOfferRepo;
|
|
25
31
|
authorization: AuthorizationRepo;
|
|
32
|
+
order: OrderRepo;
|
|
26
33
|
reservation: ReservationRepo;
|
|
27
34
|
}) => Promise<{
|
|
28
35
|
reservation: IReservationResult;
|
|
@@ -13,72 +13,49 @@ exports.findByCode = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
function findByCode(params) {
|
|
15
15
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a
|
|
16
|
+
var _a;
|
|
17
17
|
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
18
18
|
throw new factory.errors.ArgumentNull('id');
|
|
19
19
|
}
|
|
20
20
|
if (typeof params.code !== 'string' || params.code.length === 0) {
|
|
21
21
|
throw new factory.errors.ArgumentNull('code');
|
|
22
22
|
}
|
|
23
|
+
const reservationId = String(params.id);
|
|
23
24
|
const authorizationObject = yield repos.authorization.findValidObjectByCode({
|
|
24
25
|
project: { id: params.project.id },
|
|
25
26
|
code: params.code
|
|
26
27
|
});
|
|
27
|
-
let reservationIdInOrder;
|
|
28
|
-
let reservationTypeInOrder;
|
|
29
|
-
let offeredThroughIdentifier = factory.service.webAPI.Identifier.Chevre;
|
|
30
28
|
switch (authorizationObject.typeOf) {
|
|
31
29
|
case factory.order.OrderType.Order:
|
|
32
30
|
const { orderNumber } = authorizationObject;
|
|
33
31
|
if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
const itemOfferedTypeOf = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.typeOf;
|
|
42
|
-
if (itemOfferedTypeOf === factory.reservationType.BusReservation
|
|
43
|
-
|| itemOfferedTypeOf === factory.reservationType.EventReservation) {
|
|
44
|
-
reservationIdInOrder = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.id;
|
|
45
|
-
reservationTypeInOrder = itemOfferedTypeOf;
|
|
46
|
-
offeredThroughIdentifier = (_a = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
47
|
-
}
|
|
32
|
+
// reservationIdを含む注文の存在を確認するだけでよい
|
|
33
|
+
yield repos.order.findByOrderNumberAndReservationId({
|
|
34
|
+
project: { id: params.project.id },
|
|
35
|
+
orderNumber,
|
|
36
|
+
reservationId,
|
|
37
|
+
seller: params.seller
|
|
38
|
+
});
|
|
48
39
|
}
|
|
49
40
|
break;
|
|
50
41
|
default:
|
|
51
42
|
throw new factory.errors.NotImplemented(`authorization object typeOf: ${authorizationObject.typeOf} not implemented`);
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const { id, additionalTicketText, reservationStatus, reservedTicket } = reservationFromRepo;
|
|
67
|
-
reservation = {
|
|
68
|
-
id, additionalTicketText, reservationStatus,
|
|
69
|
-
reservedTicket: {
|
|
70
|
-
ticketType: {
|
|
71
|
-
identifier: reservedTicket.ticketType.identifier,
|
|
72
|
-
name: { ja: (_b = reservedTicket.ticketType.name) === null || _b === void 0 ? void 0 : _b.ja }
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
44
|
+
const reservationFromRepo = yield repos.reservation.findById({
|
|
45
|
+
id: reservationId,
|
|
46
|
+
inclusion: ['id', 'additionalTicketText', 'reservationStatus', 'reservedTicket'],
|
|
47
|
+
exclusion: []
|
|
48
|
+
});
|
|
49
|
+
const { id, additionalTicketText, reservationStatus, reservedTicket } = reservationFromRepo;
|
|
50
|
+
const reservation = {
|
|
51
|
+
id, additionalTicketText, reservationStatus,
|
|
52
|
+
reservedTicket: {
|
|
53
|
+
ticketType: {
|
|
54
|
+
identifier: reservedTicket.ticketType.identifier,
|
|
55
|
+
name: { ja: (_a = reservedTicket.ticketType.name) === null || _a === void 0 ? void 0 : _a.ja }
|
|
56
|
+
}
|
|
77
57
|
}
|
|
78
|
-
}
|
|
79
|
-
if (reservation === undefined) {
|
|
80
|
-
throw new factory.errors.NotFound('Reservation');
|
|
81
|
-
}
|
|
58
|
+
};
|
|
82
59
|
return { reservation };
|
|
83
60
|
});
|
|
84
61
|
}
|
package/package.json
CHANGED