@chevre/domain 21.4.0-alpha.15 → 21.4.0-alpha.17
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/migrateReservationProvider.ts +107 -0
- package/lib/chevre/repo/order.d.ts +21 -0
- package/lib/chevre/repo/order.js +40 -39
- package/lib/chevre/repo/reservation.d.ts +26 -2
- package/lib/chevre/repo/reservation.js +6 -1
- package/lib/chevre/service/order/returnOrder.js +8 -1
- package/lib/chevre/service/order/sendOrder.js +8 -1
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
- package/lib/chevre/service/task/returnPayTransaction.js +1 -0
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -39,6 +39,9 @@ export declare class MongoRepository {
|
|
|
39
39
|
* 注文ステータスを変更する
|
|
40
40
|
*/
|
|
41
41
|
changeStatus(params: {
|
|
42
|
+
project: {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
42
45
|
orderNumber: string;
|
|
43
46
|
orderStatus: factory.orderStatus;
|
|
44
47
|
previousOrderStatus: factory.orderStatus;
|
|
@@ -47,6 +50,9 @@ export declare class MongoRepository {
|
|
|
47
50
|
* 注文を返品する
|
|
48
51
|
*/
|
|
49
52
|
returnOrder(params: {
|
|
53
|
+
project: {
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
50
56
|
orderNumber: string;
|
|
51
57
|
dateReturned: Date;
|
|
52
58
|
returner: factory.order.IReturner;
|
|
@@ -55,6 +61,9 @@ export declare class MongoRepository {
|
|
|
55
61
|
* 変更可能な属性を更新する
|
|
56
62
|
*/
|
|
57
63
|
updateChangeableAttributes(params: {
|
|
64
|
+
project: {
|
|
65
|
+
id: string;
|
|
66
|
+
};
|
|
58
67
|
additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
|
|
59
68
|
name?: string;
|
|
60
69
|
orderNumber: string;
|
|
@@ -71,10 +80,22 @@ export declare class MongoRepository {
|
|
|
71
80
|
*/
|
|
72
81
|
findByOrderNumber(params: {
|
|
73
82
|
orderNumber: string;
|
|
83
|
+
project: {
|
|
84
|
+
id: string;
|
|
85
|
+
};
|
|
86
|
+
seller?: {
|
|
87
|
+
id?: string;
|
|
88
|
+
};
|
|
74
89
|
inclusion: string[];
|
|
75
90
|
exclusion: string[];
|
|
76
91
|
}): Promise<factory.order.IOrder>;
|
|
77
92
|
findByOrderNumberAndReservationId(params: {
|
|
93
|
+
project: {
|
|
94
|
+
id: string;
|
|
95
|
+
};
|
|
96
|
+
seller?: {
|
|
97
|
+
id?: string;
|
|
98
|
+
};
|
|
78
99
|
orderNumber: string;
|
|
79
100
|
reservationId: string;
|
|
80
101
|
}): Promise<Pick<factory.order.IOrder, 'orderNumber' | 'orderStatus' | 'typeOf'>>;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -24,34 +24,25 @@ 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;
|
|
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;
|
|
28
28
|
const andConditions = [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
33
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
34
|
-
andConditions.push({
|
|
35
|
-
'project.id': {
|
|
36
|
-
$eq: params.project.id.$eq
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
29
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
30
|
+
if (typeof projectIdEq === 'string') {
|
|
31
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
32
|
}
|
|
42
|
-
const additionalPropertyAll = (
|
|
33
|
+
const additionalPropertyAll = (_c = params.additionalProperty) === null || _c === void 0 ? void 0 : _c.$all;
|
|
43
34
|
if (Array.isArray(additionalPropertyAll)) {
|
|
44
35
|
andConditions.push({ additionalProperty: { $exists: true, $all: additionalPropertyAll } });
|
|
45
36
|
}
|
|
46
|
-
const additionalPropertyIn = (
|
|
37
|
+
const additionalPropertyIn = (_d = params.additionalProperty) === null || _d === void 0 ? void 0 : _d.$in;
|
|
47
38
|
if (Array.isArray(additionalPropertyIn)) {
|
|
48
39
|
andConditions.push({ additionalProperty: { $exists: true, $in: additionalPropertyIn } });
|
|
49
40
|
}
|
|
50
|
-
const additionalPropertyNin = (
|
|
41
|
+
const additionalPropertyNin = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$nin;
|
|
51
42
|
if (Array.isArray(additionalPropertyNin)) {
|
|
52
43
|
andConditions.push({ additionalProperty: { $nin: additionalPropertyNin } });
|
|
53
44
|
}
|
|
54
|
-
const additionalPropertyElemMatch = (
|
|
45
|
+
const additionalPropertyElemMatch = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
|
|
55
46
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
56
47
|
andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
|
|
57
48
|
}
|
|
@@ -103,7 +94,7 @@ class MongoRepository {
|
|
|
103
94
|
});
|
|
104
95
|
}
|
|
105
96
|
}
|
|
106
|
-
const brokerIdEq = (
|
|
97
|
+
const brokerIdEq = (_h = (_g = params.broker) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
107
98
|
if (typeof brokerIdEq === 'string') {
|
|
108
99
|
andConditions.push({
|
|
109
100
|
'broker.id': {
|
|
@@ -320,7 +311,7 @@ class MongoRepository {
|
|
|
320
311
|
}
|
|
321
312
|
}
|
|
322
313
|
}
|
|
323
|
-
const nameEq = (
|
|
314
|
+
const nameEq = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
324
315
|
if (typeof nameEq === 'string') {
|
|
325
316
|
andConditions.push({
|
|
326
317
|
name: {
|
|
@@ -329,7 +320,7 @@ class MongoRepository {
|
|
|
329
320
|
}
|
|
330
321
|
});
|
|
331
322
|
}
|
|
332
|
-
const nameRegex = (
|
|
323
|
+
const nameRegex = (_k = params.name) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
333
324
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
334
325
|
andConditions.push({
|
|
335
326
|
name: {
|
|
@@ -362,7 +353,7 @@ class MongoRepository {
|
|
|
362
353
|
}
|
|
363
354
|
});
|
|
364
355
|
}
|
|
365
|
-
const itemOfferedIdentifierIn = (
|
|
356
|
+
const itemOfferedIdentifierIn = (_o = (_m = (_l = params.acceptedOffers) === null || _l === void 0 ? void 0 : _l.itemOffered) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$in;
|
|
366
357
|
if (Array.isArray(itemOfferedIdentifierIn)) {
|
|
367
358
|
andConditions.push({
|
|
368
359
|
'acceptedOffers.itemOffered.identifier': {
|
|
@@ -371,7 +362,7 @@ class MongoRepository {
|
|
|
371
362
|
}
|
|
372
363
|
});
|
|
373
364
|
}
|
|
374
|
-
const itemOfferedTypeOfIn = (
|
|
365
|
+
const itemOfferedTypeOfIn = (_r = (_q = (_p = params.acceptedOffers) === null || _p === void 0 ? void 0 : _p.itemOffered) === null || _q === void 0 ? void 0 : _q.typeOf) === null || _r === void 0 ? void 0 : _r.$in;
|
|
375
366
|
if (Array.isArray(itemOfferedTypeOfIn)) {
|
|
376
367
|
andConditions.push({
|
|
377
368
|
'acceptedOffers.itemOffered.typeOf': {
|
|
@@ -380,7 +371,7 @@ class MongoRepository {
|
|
|
380
371
|
}
|
|
381
372
|
});
|
|
382
373
|
}
|
|
383
|
-
const itemOfferedIssuedThroughTypeOfEq = (
|
|
374
|
+
const itemOfferedIssuedThroughTypeOfEq = (_v = (_u = (_t = (_s = params.acceptedOffers) === null || _s === void 0 ? void 0 : _s.itemOffered) === null || _t === void 0 ? void 0 : _t.issuedThrough) === null || _u === void 0 ? void 0 : _u.typeOf) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
384
375
|
if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
|
|
385
376
|
andConditions.push({
|
|
386
377
|
'acceptedOffers.itemOffered.issuedThrough.typeOf': {
|
|
@@ -389,7 +380,7 @@ class MongoRepository {
|
|
|
389
380
|
}
|
|
390
381
|
});
|
|
391
382
|
}
|
|
392
|
-
const itemOfferedIssuedThroughIdIn = (
|
|
383
|
+
const itemOfferedIssuedThroughIdIn = (_z = (_y = (_x = (_w = params.acceptedOffers) === null || _w === void 0 ? void 0 : _w.itemOffered) === null || _x === void 0 ? void 0 : _x.issuedThrough) === null || _y === void 0 ? void 0 : _y.id) === null || _z === void 0 ? void 0 : _z.$in;
|
|
393
384
|
if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
|
|
394
385
|
andConditions.push({
|
|
395
386
|
'acceptedOffers.itemOffered.issuedThrough.id': {
|
|
@@ -398,7 +389,7 @@ class MongoRepository {
|
|
|
398
389
|
}
|
|
399
390
|
});
|
|
400
391
|
}
|
|
401
|
-
const itemOfferedProgramMembershipUsedIdentifierEq = (
|
|
392
|
+
const itemOfferedProgramMembershipUsedIdentifierEq = (_3 = (_2 = (_1 = (_0 = params.acceptedOffers) === null || _0 === void 0 ? void 0 : _0.itemOffered) === null || _1 === void 0 ? void 0 : _1.programMembershipUsed) === null || _2 === void 0 ? void 0 : _2.identifier) === null || _3 === void 0 ? void 0 : _3.$eq;
|
|
402
393
|
if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
|
|
403
394
|
andConditions.push({
|
|
404
395
|
'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
|
|
@@ -407,7 +398,7 @@ class MongoRepository {
|
|
|
407
398
|
}
|
|
408
399
|
});
|
|
409
400
|
}
|
|
410
|
-
const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (
|
|
401
|
+
const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_9 = (_8 = (_7 = (_6 = (_5 = (_4 = params.acceptedOffers) === null || _4 === void 0 ? void 0 : _4.itemOffered) === null || _5 === void 0 ? void 0 : _5.programMembershipUsed) === null || _6 === void 0 ? void 0 : _6.issuedThrough) === null || _7 === void 0 ? void 0 : _7.serviceType) === null || _8 === void 0 ? void 0 : _8.codeValue) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
411
402
|
if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
|
|
412
403
|
andConditions.push({
|
|
413
404
|
'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
|
|
@@ -603,7 +594,7 @@ class MongoRepository {
|
|
|
603
594
|
});
|
|
604
595
|
}
|
|
605
596
|
}
|
|
606
|
-
const paymentMethodAdditionalPropertyAll = (
|
|
597
|
+
const paymentMethodAdditionalPropertyAll = (_11 = (_10 = params.paymentMethods) === null || _10 === void 0 ? void 0 : _10.additionalProperty) === null || _11 === void 0 ? void 0 : _11.$all;
|
|
607
598
|
if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
|
|
608
599
|
andConditions.push({
|
|
609
600
|
'paymentMethods.additionalProperty': {
|
|
@@ -612,7 +603,7 @@ class MongoRepository {
|
|
|
612
603
|
}
|
|
613
604
|
});
|
|
614
605
|
}
|
|
615
|
-
const paymentMethodAdditionalPropertyIn = (
|
|
606
|
+
const paymentMethodAdditionalPropertyIn = (_13 = (_12 = params.paymentMethods) === null || _12 === void 0 ? void 0 : _12.additionalProperty) === null || _13 === void 0 ? void 0 : _13.$in;
|
|
616
607
|
if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
|
|
617
608
|
andConditions.push({
|
|
618
609
|
'paymentMethods.additionalProperty': {
|
|
@@ -696,8 +687,9 @@ class MongoRepository {
|
|
|
696
687
|
changeStatus(params) {
|
|
697
688
|
return __awaiter(this, void 0, void 0, function* () {
|
|
698
689
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
699
|
-
orderNumber: params.orderNumber,
|
|
700
|
-
orderStatus: params.previousOrderStatus
|
|
690
|
+
orderNumber: { $eq: params.orderNumber },
|
|
691
|
+
orderStatus: { $eq: params.previousOrderStatus },
|
|
692
|
+
'project.id': { $eq: params.project.id }
|
|
701
693
|
}, { orderStatus: params.orderStatus }, {
|
|
702
694
|
new: true,
|
|
703
695
|
projection: {
|
|
@@ -711,6 +703,7 @@ class MongoRepository {
|
|
|
711
703
|
if (doc === null) {
|
|
712
704
|
const order = yield this.findByOrderNumber({
|
|
713
705
|
orderNumber: params.orderNumber,
|
|
706
|
+
project: { id: params.project.id },
|
|
714
707
|
inclusion: [],
|
|
715
708
|
exclusion: []
|
|
716
709
|
});
|
|
@@ -735,8 +728,9 @@ class MongoRepository {
|
|
|
735
728
|
returnOrder(params) {
|
|
736
729
|
return __awaiter(this, void 0, void 0, function* () {
|
|
737
730
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
738
|
-
orderNumber: params.orderNumber,
|
|
739
|
-
orderStatus: factory.orderStatus.OrderDelivered
|
|
731
|
+
orderNumber: { $eq: params.orderNumber },
|
|
732
|
+
orderStatus: { $eq: factory.orderStatus.OrderDelivered },
|
|
733
|
+
'project.id': { $eq: params.project.id }
|
|
740
734
|
}, {
|
|
741
735
|
orderStatus: factory.orderStatus.OrderReturned,
|
|
742
736
|
dateReturned: params.dateReturned,
|
|
@@ -754,6 +748,7 @@ class MongoRepository {
|
|
|
754
748
|
if (doc === null) {
|
|
755
749
|
const order = yield this.findByOrderNumber({
|
|
756
750
|
orderNumber: params.orderNumber,
|
|
751
|
+
project: { id: params.project.id },
|
|
757
752
|
inclusion: [],
|
|
758
753
|
exclusion: []
|
|
759
754
|
});
|
|
@@ -777,7 +772,10 @@ class MongoRepository {
|
|
|
777
772
|
*/
|
|
778
773
|
updateChangeableAttributes(params) {
|
|
779
774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
780
|
-
const doc = yield this.orderModel.findOneAndUpdate({
|
|
775
|
+
const doc = yield this.orderModel.findOneAndUpdate({
|
|
776
|
+
orderNumber: { $eq: params.orderNumber },
|
|
777
|
+
'project.id': { $eq: params.project.id }
|
|
778
|
+
}, {
|
|
781
779
|
$set: Object.assign(Object.assign({}, (Array.isArray(params.additionalProperty)) ? { additionalProperty: params.additionalProperty } : undefined), (typeof params.name === 'string') ? { name: params.name } : undefined)
|
|
782
780
|
}, {
|
|
783
781
|
new: true,
|
|
@@ -844,7 +842,10 @@ class MongoRepository {
|
|
|
844
842
|
});
|
|
845
843
|
}
|
|
846
844
|
}
|
|
847
|
-
const doc = yield this.orderModel.findOne({
|
|
845
|
+
const doc = yield this.orderModel.findOne({
|
|
846
|
+
orderNumber: { $eq: params.orderNumber },
|
|
847
|
+
'project.id': { $eq: params.project.id }
|
|
848
|
+
}, projection)
|
|
848
849
|
.exec();
|
|
849
850
|
if (doc === null) {
|
|
850
851
|
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
@@ -853,6 +854,7 @@ class MongoRepository {
|
|
|
853
854
|
});
|
|
854
855
|
}
|
|
855
856
|
findByOrderNumberAndReservationId(params) {
|
|
857
|
+
var _a;
|
|
856
858
|
return __awaiter(this, void 0, void 0, function* () {
|
|
857
859
|
const projection = {
|
|
858
860
|
orderStatus: 1,
|
|
@@ -860,15 +862,14 @@ class MongoRepository {
|
|
|
860
862
|
orderNumber: 1,
|
|
861
863
|
_id: 0
|
|
862
864
|
};
|
|
863
|
-
const doc = yield this.orderModel.findOne({
|
|
864
|
-
orderNumber: { $eq: params.orderNumber },
|
|
865
|
-
acceptedOffers: {
|
|
865
|
+
const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, acceptedOffers: {
|
|
866
866
|
$elemMatch: {
|
|
867
867
|
'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
|
|
868
868
|
'itemOffered.id': { $eq: params.reservationId }
|
|
869
869
|
}
|
|
870
|
-
}
|
|
871
|
-
|
|
870
|
+
} }, (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
871
|
+
? { 'seller.id': { $exists: true, $eq: params.seller.id } }
|
|
872
|
+
: undefined), projection)
|
|
872
873
|
.exec();
|
|
873
874
|
if (doc === null) {
|
|
874
875
|
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
@@ -1,9 +1,32 @@
|
|
|
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';
|
|
4
28
|
export interface IUpdatePartiallyParams {
|
|
5
29
|
additionalTicketText?: string;
|
|
6
|
-
'reservedTicket.dateUsed'?: Date;
|
|
7
30
|
}
|
|
8
31
|
export type ICancelResult = UpdateWriteOpResult;
|
|
9
32
|
export type ICreatingReservation<T extends factory.reservationType> = T extends factory.reservationType.BusReservation ? (factory.reservation.busReservation.IReservation) & {
|
|
@@ -91,7 +114,7 @@ export declare class MongoRepository {
|
|
|
91
114
|
updatePartiallyById(params: {
|
|
92
115
|
id: string;
|
|
93
116
|
update: IUpdatePartiallyParams;
|
|
94
|
-
}): Promise<factory.reservation.eventReservation.IReservation
|
|
117
|
+
}): Promise<Pick<factory.reservation.eventReservation.IReservation, 'id'>>;
|
|
95
118
|
deleteByIds(params: {
|
|
96
119
|
project: {
|
|
97
120
|
id: string;
|
|
@@ -119,4 +142,5 @@ export declare class MongoRepository {
|
|
|
119
142
|
};
|
|
120
143
|
}): Promise<string[]>;
|
|
121
144
|
deleteReservedTicketUnderName(): Promise<import("mongodb").UpdateResult>;
|
|
145
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
122
146
|
}
|
|
@@ -1112,10 +1112,10 @@ class MongoRepository {
|
|
|
1112
1112
|
/**
|
|
1113
1113
|
* 予約部分更新
|
|
1114
1114
|
*/
|
|
1115
|
-
// public async findByIdAndUpdate(params: {
|
|
1116
1115
|
updatePartiallyById(params) {
|
|
1117
1116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1118
1117
|
return this.reservationModel.findOneAndUpdate({ _id: { $eq: params.id } }, params.update, { new: true })
|
|
1118
|
+
.select({ _id: 1 })
|
|
1119
1119
|
.exec()
|
|
1120
1120
|
.then((doc) => {
|
|
1121
1121
|
if (doc === null) {
|
|
@@ -1185,5 +1185,10 @@ class MongoRepository {
|
|
|
1185
1185
|
.exec();
|
|
1186
1186
|
});
|
|
1187
1187
|
}
|
|
1188
|
+
getCursor(conditions, projection) {
|
|
1189
|
+
return this.reservationModel.find(conditions, projection)
|
|
1190
|
+
.sort({ bookingTime: factory.sortType.Descending })
|
|
1191
|
+
.cursor();
|
|
1192
|
+
}
|
|
1188
1193
|
}
|
|
1189
1194
|
exports.MongoRepository = MongoRepository;
|
|
@@ -14,6 +14,7 @@ const order_1 = require("../../factory/order");
|
|
|
14
14
|
const factory_1 = require("../delivery/factory");
|
|
15
15
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
16
16
|
const factory = require("../../factory");
|
|
17
|
+
// tslint:disable-next-line:max-func-body-length
|
|
17
18
|
function returnOrder(params) {
|
|
18
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
const orderNumber = params.object.orderNumber;
|
|
@@ -21,7 +22,12 @@ function returnOrder(params) {
|
|
|
21
22
|
? params.object.dateReturned
|
|
22
23
|
: new Date();
|
|
23
24
|
const returner = params.agent;
|
|
24
|
-
let order = yield repos.order.findByOrderNumber({
|
|
25
|
+
let order = yield repos.order.findByOrderNumber({
|
|
26
|
+
orderNumber,
|
|
27
|
+
project: { id: params.project.id },
|
|
28
|
+
inclusion: [],
|
|
29
|
+
exclusion: []
|
|
30
|
+
});
|
|
25
31
|
// プロジェクト条件検証
|
|
26
32
|
if (order.project.id !== params.project.id) {
|
|
27
33
|
throw new factory.errors.NotFound('Order');
|
|
@@ -59,6 +65,7 @@ function returnOrder(params) {
|
|
|
59
65
|
returnedOwnershipInfos = yield processReturnOrder(order, dateReturned)({ ownershipInfo: repos.ownershipInfo });
|
|
60
66
|
// 注文ステータス変更
|
|
61
67
|
order = yield repos.order.returnOrder({
|
|
68
|
+
project: { id: order.project.id },
|
|
62
69
|
orderNumber,
|
|
63
70
|
dateReturned,
|
|
64
71
|
returner
|
|
@@ -31,7 +31,12 @@ function sendOrder(params) {
|
|
|
31
31
|
orderNumber
|
|
32
32
|
})({ transaction: repos.transaction });
|
|
33
33
|
// 注文取得
|
|
34
|
-
let order = yield repos.order.findByOrderNumber({
|
|
34
|
+
let order = yield repos.order.findByOrderNumber({
|
|
35
|
+
orderNumber,
|
|
36
|
+
project: { id: params.project.id },
|
|
37
|
+
inclusion: [],
|
|
38
|
+
exclusion: []
|
|
39
|
+
});
|
|
35
40
|
// プロジェクト条件検証
|
|
36
41
|
if (order.project.id !== params.project.id) {
|
|
37
42
|
throw new factory.errors.NotFound('Order');
|
|
@@ -69,6 +74,7 @@ function sendOrder(params) {
|
|
|
69
74
|
return repos.ownershipInfo.createIfNotExistByIdentifier(ownershipInfo);
|
|
70
75
|
})));
|
|
71
76
|
order = yield repos.order.changeStatus({
|
|
77
|
+
project: { id: order.project.id },
|
|
72
78
|
orderNumber,
|
|
73
79
|
orderStatus: factory.orderStatus.OrderDelivered,
|
|
74
80
|
previousOrderStatus: factory.orderStatus.OrderProcessing
|
|
@@ -98,6 +104,7 @@ function sendOrder(params) {
|
|
|
98
104
|
// すでにOrderReturnedだった場合、OrderDelivered->OrderReturnedの処理自体は成功しているので、後処理を続行する
|
|
99
105
|
const currentOrder = yield repos.order.findByOrderNumber({
|
|
100
106
|
orderNumber: params.object.orderNumber,
|
|
107
|
+
project: { id: params.project.id },
|
|
101
108
|
inclusion: ['orderStatus'],
|
|
102
109
|
exclusion: []
|
|
103
110
|
});
|
|
@@ -26,8 +26,10 @@ function verifyToken4reservation(params) {
|
|
|
26
26
|
case factory.order.OrderType.Order:
|
|
27
27
|
// reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
|
|
28
28
|
const order = yield repos.order.findByOrderNumberAndReservationId({
|
|
29
|
+
project: { id: params.project.id },
|
|
29
30
|
orderNumber: payload.orderNumber,
|
|
30
|
-
reservationId: params.reservationId
|
|
31
|
+
reservationId: params.reservationId,
|
|
32
|
+
seller: params.seller
|
|
31
33
|
});
|
|
32
34
|
// ステータス検証
|
|
33
35
|
switch (order.orderStatus) {
|
package/package.json
CHANGED