@chevre/domain 21.18.0-alpha.4 → 21.18.0-alpha.6
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/searchOrderAcceptedOffers.ts +2 -2
- package/example/src/chevre/searchOrders.ts +25 -19
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/repo/acceptedOffer.d.ts +54 -0
- package/lib/chevre/repo/acceptedOffer.js +183 -0
- package/lib/chevre/repo/order.d.ts +3 -47
- package/lib/chevre/repo/order.js +31 -171
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +27 -17
- package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder.js +4 -4
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const searchConditions: chevre.factory.order.ISearchConditions = {
|
|
14
14
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -20,7 +20,7 @@ async function main() {
|
|
|
20
20
|
acceptedOffers: { itemOffered: { typeOf: { $in: [chevre.factory.reservationType.EventReservation] } } }
|
|
21
21
|
// ...(typeof req.seller?.id === 'string') ? { seller: { id: { $eq: req.seller.id } } } : undefined // req.seller.idを考慮
|
|
22
22
|
};
|
|
23
|
-
const acceptedOffers = await
|
|
23
|
+
const acceptedOffers = await acceptedOfferRepo.searchAcceptedOffers(searchConditions, ['itemOffered', 'id']);
|
|
24
24
|
// tslint:disable-next-line:no-null-keyword
|
|
25
25
|
console.dir(acceptedOffers, { depth: 1 });
|
|
26
26
|
const reservationIds = acceptedOffers.map((acceptedOffer) => {
|
|
@@ -10,28 +10,34 @@ async function main() {
|
|
|
10
10
|
|
|
11
11
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
|
-
const orders = await orderRepo.search(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const orders = await orderRepo.search(
|
|
14
|
+
{
|
|
15
|
+
limit: 10,
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
acceptedOffers: {
|
|
18
|
+
// $size: 1
|
|
19
|
+
// itemOffered: {
|
|
20
|
+
// issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.MembershipService } }
|
|
21
|
+
// }
|
|
22
|
+
},
|
|
23
|
+
orderedItem: {
|
|
24
|
+
$size: 3
|
|
25
|
+
}
|
|
26
|
+
// paymentMethods: {
|
|
27
|
+
// paymentMethod: { identifier: { $in: ['Cash'] } }
|
|
28
|
+
// additionalProperty: {
|
|
29
|
+
// $in: [
|
|
30
|
+
// { name: 'orderId', value: '0102022031518442020' },
|
|
31
|
+
// { name: 'orderId', value: '0102022031518423030' }
|
|
32
|
+
// ]
|
|
20
33
|
// }
|
|
34
|
+
// }
|
|
21
35
|
},
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
{
|
|
37
|
+
orderNumber: 1,
|
|
38
|
+
customer: 1
|
|
24
39
|
}
|
|
25
|
-
|
|
26
|
-
// paymentMethod: { identifier: { $in: ['Cash'] } }
|
|
27
|
-
// additionalProperty: {
|
|
28
|
-
// $in: [
|
|
29
|
-
// { name: 'orderId', value: '0102022031518442020' },
|
|
30
|
-
// { name: 'orderId', value: '0102022031518423030' }
|
|
31
|
-
// ]
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
});
|
|
40
|
+
);
|
|
35
41
|
console.log('orders found', orders);
|
|
36
42
|
console.log(orders.length, 'orders found');
|
|
37
43
|
}
|
|
@@ -23,6 +23,7 @@ async function main() {
|
|
|
23
23
|
id: 'xxx'
|
|
24
24
|
}
|
|
25
25
|
})({
|
|
26
|
+
acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
|
|
26
27
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
27
28
|
merchantReturnPolicy: await chevre.repository.MerchantReturnPolicy.createInstance(mongoose.connection),
|
|
28
29
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
type IProjection4searchWithUnwoundAcceptedOffers = {
|
|
4
|
+
[key in keyof Omit<factory.order.IOrder, 'acceptedOffers'>]?: 1;
|
|
5
|
+
} & {
|
|
6
|
+
_id?: 0 | 1;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 注文オファーリポジトリ
|
|
10
|
+
*/
|
|
11
|
+
export declare class MongoRepository {
|
|
12
|
+
private readonly orderModel;
|
|
13
|
+
constructor(connection: Connection);
|
|
14
|
+
/**
|
|
15
|
+
* 注文の受入オファーIDリストを検索する
|
|
16
|
+
*/
|
|
17
|
+
searchAcceptedOfferIds(params: factory.order.ISearchConditions): Promise<(string)[]>;
|
|
18
|
+
/**
|
|
19
|
+
* オファー展開の注文検索
|
|
20
|
+
*/
|
|
21
|
+
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
|
|
22
|
+
/**
|
|
23
|
+
* オファーのみ展開して検索する
|
|
24
|
+
*/
|
|
25
|
+
searchAcceptedOffers(params: factory.order.ISearchConditions, inclusion?: (keyof factory.order.IAcceptedOffer<factory.order.IItemOffered>)[]): Promise<factory.order.IAcceptedOffer<factory.order.IItemOffered>[]>;
|
|
26
|
+
/**
|
|
27
|
+
* 注文に含まれる予約番号を検索する
|
|
28
|
+
*/
|
|
29
|
+
searchReservationNumbersByOrderNumbers(params: {
|
|
30
|
+
orderNumber: {
|
|
31
|
+
$in: string[];
|
|
32
|
+
};
|
|
33
|
+
}): Promise<(string)[]>;
|
|
34
|
+
/**
|
|
35
|
+
* 注文に含まれるイベントIDを検索する
|
|
36
|
+
*/
|
|
37
|
+
searchReservationForIdsByOrderNumbers(params: {
|
|
38
|
+
orderNumber: {
|
|
39
|
+
$in: string[];
|
|
40
|
+
};
|
|
41
|
+
}): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* 注文に含まれるacceptedOffersを検索する
|
|
44
|
+
*/
|
|
45
|
+
searchAcceptedOffersByOrderNumbers(params: {
|
|
46
|
+
orderNumber: {
|
|
47
|
+
$in: string[];
|
|
48
|
+
};
|
|
49
|
+
}): Promise<{
|
|
50
|
+
id: string;
|
|
51
|
+
priceSpecification: factory.order.ITicketPriceSpecification;
|
|
52
|
+
}[]>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MongoRepository = void 0;
|
|
13
|
+
const order_1 = require("./mongoose/schemas/order");
|
|
14
|
+
const order_2 = require("./order");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
/**
|
|
17
|
+
* 注文オファーリポジトリ
|
|
18
|
+
*/
|
|
19
|
+
class MongoRepository {
|
|
20
|
+
constructor(connection) {
|
|
21
|
+
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 注文の受入オファーIDリストを検索する
|
|
25
|
+
*/
|
|
26
|
+
searchAcceptedOfferIds(params) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const conditions = order_2.MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
29
|
+
const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
30
|
+
.select({
|
|
31
|
+
'acceptedOffers.id': 1
|
|
32
|
+
});
|
|
33
|
+
const orders = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
34
|
+
.exec()
|
|
35
|
+
.then((docs) => docs.map((doc) => {
|
|
36
|
+
return doc.toObject();
|
|
37
|
+
}));
|
|
38
|
+
const offerIds = orders.reduce((a, b) => {
|
|
39
|
+
const offerIdsByOrder = (Array.isArray(b.acceptedOffers))
|
|
40
|
+
? b.acceptedOffers.filter((offer) => typeof offer.id === 'string')
|
|
41
|
+
.map((offer) => {
|
|
42
|
+
return String(offer.id);
|
|
43
|
+
})
|
|
44
|
+
: [];
|
|
45
|
+
return [...a, ...offerIdsByOrder];
|
|
46
|
+
}, []);
|
|
47
|
+
return [...new Set(offerIds)];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* オファー展開の注文検索
|
|
52
|
+
*/
|
|
53
|
+
searchWithUnwoundAcceptedOffers(params, projection) {
|
|
54
|
+
var _a;
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const conditions = order_2.MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
57
|
+
const aggregate = this.orderModel.aggregate();
|
|
58
|
+
// pipelineの順序に注意
|
|
59
|
+
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
60
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
61
|
+
/* istanbul ignore else */
|
|
62
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
|
|
63
|
+
aggregate.sort({ orderDate: params.sort.orderDate });
|
|
64
|
+
}
|
|
65
|
+
aggregate.unwind('$acceptedOffers');
|
|
66
|
+
conditions.forEach((c) => {
|
|
67
|
+
aggregate.match(c);
|
|
68
|
+
});
|
|
69
|
+
aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
|
|
70
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
71
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
72
|
+
aggregate.limit(params.limit * page)
|
|
73
|
+
.skip(params.limit * (page - 1));
|
|
74
|
+
}
|
|
75
|
+
return aggregate
|
|
76
|
+
// .allowDiskUse(true) // false化(2023-11-30~)
|
|
77
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
78
|
+
.exec();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* オファーのみ展開して検索する
|
|
83
|
+
*/
|
|
84
|
+
searchAcceptedOffers(params, inclusion) {
|
|
85
|
+
var _a;
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const conditions = order_2.MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
88
|
+
const aggregate = this.orderModel.aggregate();
|
|
89
|
+
// pipelineの順序に注意
|
|
90
|
+
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
91
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
92
|
+
/* istanbul ignore else */
|
|
93
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
|
|
94
|
+
aggregate.sort({ orderDate: params.sort.orderDate });
|
|
95
|
+
}
|
|
96
|
+
aggregate.unwind('$acceptedOffers');
|
|
97
|
+
conditions.forEach((c) => {
|
|
98
|
+
aggregate.match(c);
|
|
99
|
+
});
|
|
100
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
101
|
+
const specifiedProjection = {
|
|
102
|
+
_id: 0
|
|
103
|
+
};
|
|
104
|
+
inclusion.forEach((key) => {
|
|
105
|
+
specifiedProjection[key] = `$acceptedOffers.${key}`;
|
|
106
|
+
});
|
|
107
|
+
aggregate.project(specifiedProjection);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
aggregate.project({
|
|
111
|
+
_id: 0,
|
|
112
|
+
itemOffered: '$acceptedOffers.itemOffered',
|
|
113
|
+
priceSpecification: '$acceptedOffers.priceSpecification',
|
|
114
|
+
typeOf: '$acceptedOffers.typeOf',
|
|
115
|
+
id: '$acceptedOffers.id',
|
|
116
|
+
offeredThrough: '$acceptedOffers.offeredThrough',
|
|
117
|
+
name: '$acceptedOffers.name'
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
121
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
122
|
+
aggregate.limit(params.limit * page)
|
|
123
|
+
.skip(params.limit * (page - 1));
|
|
124
|
+
}
|
|
125
|
+
return aggregate
|
|
126
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
127
|
+
.exec();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 注文に含まれる予約番号を検索する
|
|
132
|
+
*/
|
|
133
|
+
searchReservationNumbersByOrderNumbers(params) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
return this.orderModel.distinct('acceptedOffers.itemOffered.reservationNumber', {
|
|
139
|
+
'acceptedOffers.itemOffered.reservationNumber': { $exists: true },
|
|
140
|
+
orderNumber: { $in: params.orderNumber.$in }
|
|
141
|
+
})
|
|
142
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
143
|
+
.exec();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 注文に含まれるイベントIDを検索する
|
|
148
|
+
*/
|
|
149
|
+
searchReservationForIdsByOrderNumbers(params) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
return this.orderModel.distinct('acceptedOffers.itemOffered.reservationFor.id', {
|
|
155
|
+
'acceptedOffers.itemOffered.reservationFor.id': { $exists: true },
|
|
156
|
+
orderNumber: { $in: params.orderNumber.$in }
|
|
157
|
+
})
|
|
158
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
159
|
+
.exec();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 注文に含まれるacceptedOffersを検索する
|
|
164
|
+
*/
|
|
165
|
+
searchAcceptedOffersByOrderNumbers(params) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
const aggregate = this.orderModel.aggregate();
|
|
171
|
+
aggregate.unwind('$acceptedOffers');
|
|
172
|
+
aggregate.match({ orderNumber: { $in: params.orderNumber.$in } });
|
|
173
|
+
aggregate.project({
|
|
174
|
+
_id: 0,
|
|
175
|
+
id: '$acceptedOffers.id',
|
|
176
|
+
priceSpecification: '$acceptedOffers.priceSpecification'
|
|
177
|
+
});
|
|
178
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
179
|
+
.exec();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -24,12 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
-
type IKeyOfProjection = keyof factory.order.IOrder | '_id';
|
|
28
|
-
type IProjection4searchWithUnwoundAcceptedOffers = {
|
|
29
|
-
[key in keyof Omit<factory.order.IOrder, 'acceptedOffers'>]?: 1;
|
|
30
|
-
} & {
|
|
31
|
-
_id?: 0 | 1;
|
|
32
|
-
};
|
|
27
|
+
type IKeyOfProjection = keyof Omit<factory.order.IOrder, 'acceptedOffers'> | '_id';
|
|
33
28
|
/**
|
|
34
29
|
* 注文リポジトリ
|
|
35
30
|
*/
|
|
@@ -95,7 +90,7 @@ export declare class MongoRepository {
|
|
|
95
90
|
id: string;
|
|
96
91
|
inclusion: IKeyOfProjection[];
|
|
97
92
|
exclusion: IKeyOfProjection[];
|
|
98
|
-
}): Promise<factory.order.IOrder
|
|
93
|
+
}): Promise<Omit<factory.order.IOrder, 'acceptedOffers'>>;
|
|
99
94
|
/**
|
|
100
95
|
* 注文番号から注文を取得する
|
|
101
96
|
*/
|
|
@@ -132,46 +127,7 @@ export declare class MongoRepository {
|
|
|
132
127
|
*/
|
|
133
128
|
search(params: factory.order.ISearchConditions, projection?: {
|
|
134
129
|
[key in IKeyOfProjection]?: 0 | 1;
|
|
135
|
-
}): Promise<factory.order.IOrder[]>;
|
|
136
|
-
/**
|
|
137
|
-
* 注文の受入オファーIDリストを検索する
|
|
138
|
-
*/
|
|
139
|
-
searchAcceptedOfferIds(params: factory.order.ISearchConditions): Promise<(string)[]>;
|
|
140
|
-
/**
|
|
141
|
-
* オファー展開の注文検索
|
|
142
|
-
*/
|
|
143
|
-
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
|
|
144
|
-
/**
|
|
145
|
-
* オファーのみ展開して検索する
|
|
146
|
-
*/
|
|
147
|
-
searchAcceptedOffers(params: factory.order.ISearchConditions, inclusion?: (keyof factory.order.IAcceptedOffer<factory.order.IItemOffered>)[]): Promise<factory.order.IAcceptedOffer<factory.order.IItemOffered>[]>;
|
|
148
|
-
/**
|
|
149
|
-
* 注文に含まれる予約番号を検索する
|
|
150
|
-
*/
|
|
151
|
-
searchReservationNumbersByOrderNumbers(params: {
|
|
152
|
-
orderNumber: {
|
|
153
|
-
$in: string[];
|
|
154
|
-
};
|
|
155
|
-
}): Promise<(string)[]>;
|
|
156
|
-
/**
|
|
157
|
-
* 注文に含まれるイベントIDを検索する
|
|
158
|
-
*/
|
|
159
|
-
searchReservationForIdsByOrderNumbers(params: {
|
|
160
|
-
orderNumber: {
|
|
161
|
-
$in: string[];
|
|
162
|
-
};
|
|
163
|
-
}): Promise<string[]>;
|
|
164
|
-
/**
|
|
165
|
-
* 注文に含まれるacceptedOffersを検索する
|
|
166
|
-
*/
|
|
167
|
-
searchAcceptedOffersByOrderNumbers(params: {
|
|
168
|
-
orderNumber: {
|
|
169
|
-
$in: string[];
|
|
170
|
-
};
|
|
171
|
-
}): Promise<{
|
|
172
|
-
id: string;
|
|
173
|
-
priceSpecification: factory.order.ITicketPriceSpecification;
|
|
174
|
-
}[]>;
|
|
130
|
+
}): Promise<Omit<factory.order.IOrder, 'acceptedOffers'>[]>;
|
|
175
131
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
176
132
|
unsetUnnecessaryFields(params: {
|
|
177
133
|
filter: FilterQuery<any>;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -825,17 +825,20 @@ class MongoRepository {
|
|
|
825
825
|
}
|
|
826
826
|
findById(params) {
|
|
827
827
|
return __awaiter(this, void 0, void 0, function* () {
|
|
828
|
-
let projection = {};
|
|
828
|
+
let projection = { _id: 1 };
|
|
829
829
|
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
830
830
|
params.inclusion.forEach((field) => {
|
|
831
|
-
|
|
831
|
+
if (String(field) !== 'acceptedOffers') {
|
|
832
|
+
projection[field] = 1;
|
|
833
|
+
}
|
|
832
834
|
});
|
|
833
835
|
}
|
|
834
836
|
else {
|
|
835
837
|
projection = {
|
|
836
838
|
__v: 0,
|
|
837
839
|
createdAt: 0,
|
|
838
|
-
updatedAt: 0
|
|
840
|
+
updatedAt: 0,
|
|
841
|
+
acceptedOffers: 0
|
|
839
842
|
};
|
|
840
843
|
if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
|
|
841
844
|
params.exclusion.forEach((field) => {
|
|
@@ -859,7 +862,9 @@ class MongoRepository {
|
|
|
859
862
|
let projection = {};
|
|
860
863
|
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
861
864
|
params.inclusion.forEach((field) => {
|
|
862
|
-
|
|
865
|
+
if (String(field) !== 'acceptedOffers') {
|
|
866
|
+
projection[field] = 1;
|
|
867
|
+
}
|
|
863
868
|
});
|
|
864
869
|
}
|
|
865
870
|
else {
|
|
@@ -933,15 +938,29 @@ class MongoRepository {
|
|
|
933
938
|
var _a;
|
|
934
939
|
return __awaiter(this, void 0, void 0, function* () {
|
|
935
940
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
936
|
-
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
+
let projectStage = {};
|
|
942
|
+
// const projectionSpecified = projection !== undefined && projection !== null;
|
|
943
|
+
// const positiveProjectionExists: boolean = (projectionSpecified)
|
|
944
|
+
// ? Object.values(projection)
|
|
945
|
+
// .some((value) => value !== 0)
|
|
946
|
+
// : false;
|
|
947
|
+
const positiveProjectionFields = (projection !== undefined && projection !== null)
|
|
948
|
+
? Object.keys(projection)
|
|
949
|
+
.filter((key) => projection[key] !== 0
|
|
950
|
+
&& key !== 'acceptedOffers' // defaultで隠蔽(2023-12-06~)
|
|
951
|
+
)
|
|
952
|
+
: [];
|
|
953
|
+
if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
|
|
954
|
+
projectStage = {};
|
|
955
|
+
positiveProjectionFields.forEach((field) => {
|
|
956
|
+
projectStage[field] = 1;
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
projectStage = Object.assign({ __v: 0, createdAt: 0, updatedAt: 0, acceptedOffers: 0 }, projection);
|
|
961
|
+
}
|
|
941
962
|
const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
942
|
-
.select(
|
|
943
|
-
? projection
|
|
944
|
-
: Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
|
|
963
|
+
.select(projectStage);
|
|
945
964
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
946
965
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
947
966
|
query.limit(params.limit)
|
|
@@ -959,165 +978,6 @@ class MongoRepository {
|
|
|
959
978
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
960
979
|
});
|
|
961
980
|
}
|
|
962
|
-
/**
|
|
963
|
-
* 注文の受入オファーIDリストを検索する
|
|
964
|
-
*/
|
|
965
|
-
searchAcceptedOfferIds(params) {
|
|
966
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
967
|
-
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
968
|
-
const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
969
|
-
.select({
|
|
970
|
-
'acceptedOffers.id': 1
|
|
971
|
-
});
|
|
972
|
-
const orders = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
973
|
-
.exec()
|
|
974
|
-
.then((docs) => docs.map((doc) => {
|
|
975
|
-
return doc.toObject();
|
|
976
|
-
}));
|
|
977
|
-
const offerIds = orders.reduce((a, b) => {
|
|
978
|
-
const offerIdsByOrder = (Array.isArray(b.acceptedOffers))
|
|
979
|
-
? b.acceptedOffers.filter((offer) => typeof offer.id === 'string')
|
|
980
|
-
.map((offer) => {
|
|
981
|
-
return String(offer.id);
|
|
982
|
-
})
|
|
983
|
-
: [];
|
|
984
|
-
return [...a, ...offerIdsByOrder];
|
|
985
|
-
}, []);
|
|
986
|
-
return [...new Set(offerIds)];
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* オファー展開の注文検索
|
|
991
|
-
*/
|
|
992
|
-
searchWithUnwoundAcceptedOffers(params, projection) {
|
|
993
|
-
var _a;
|
|
994
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
995
|
-
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
996
|
-
const aggregate = this.orderModel.aggregate();
|
|
997
|
-
// pipelineの順序に注意
|
|
998
|
-
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
999
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
1000
|
-
/* istanbul ignore else */
|
|
1001
|
-
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
|
|
1002
|
-
aggregate.sort({ orderDate: params.sort.orderDate });
|
|
1003
|
-
}
|
|
1004
|
-
aggregate.unwind('$acceptedOffers');
|
|
1005
|
-
conditions.forEach((c) => {
|
|
1006
|
-
aggregate.match(c);
|
|
1007
|
-
});
|
|
1008
|
-
aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
|
|
1009
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1010
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1011
|
-
aggregate.limit(params.limit * page)
|
|
1012
|
-
.skip(params.limit * (page - 1));
|
|
1013
|
-
}
|
|
1014
|
-
return aggregate
|
|
1015
|
-
// .allowDiskUse(true) // false化(2023-11-30~)
|
|
1016
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1017
|
-
.exec();
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* オファーのみ展開して検索する
|
|
1022
|
-
*/
|
|
1023
|
-
searchAcceptedOffers(params, inclusion) {
|
|
1024
|
-
var _a;
|
|
1025
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1026
|
-
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
1027
|
-
const aggregate = this.orderModel.aggregate();
|
|
1028
|
-
// pipelineの順序に注意
|
|
1029
|
-
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
1030
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
1031
|
-
/* istanbul ignore else */
|
|
1032
|
-
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
|
|
1033
|
-
aggregate.sort({ orderDate: params.sort.orderDate });
|
|
1034
|
-
}
|
|
1035
|
-
aggregate.unwind('$acceptedOffers');
|
|
1036
|
-
conditions.forEach((c) => {
|
|
1037
|
-
aggregate.match(c);
|
|
1038
|
-
});
|
|
1039
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
1040
|
-
const specifiedProjection = {
|
|
1041
|
-
_id: 0
|
|
1042
|
-
};
|
|
1043
|
-
inclusion.forEach((key) => {
|
|
1044
|
-
specifiedProjection[key] = `$acceptedOffers.${key}`;
|
|
1045
|
-
});
|
|
1046
|
-
aggregate.project(specifiedProjection);
|
|
1047
|
-
}
|
|
1048
|
-
else {
|
|
1049
|
-
aggregate.project({
|
|
1050
|
-
_id: 0,
|
|
1051
|
-
itemOffered: '$acceptedOffers.itemOffered',
|
|
1052
|
-
priceSpecification: '$acceptedOffers.priceSpecification',
|
|
1053
|
-
typeOf: '$acceptedOffers.typeOf',
|
|
1054
|
-
id: '$acceptedOffers.id',
|
|
1055
|
-
offeredThrough: '$acceptedOffers.offeredThrough',
|
|
1056
|
-
name: '$acceptedOffers.name'
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1060
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1061
|
-
aggregate.limit(params.limit * page)
|
|
1062
|
-
.skip(params.limit * (page - 1));
|
|
1063
|
-
}
|
|
1064
|
-
return aggregate
|
|
1065
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1066
|
-
.exec();
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
/**
|
|
1070
|
-
* 注文に含まれる予約番号を検索する
|
|
1071
|
-
*/
|
|
1072
|
-
searchReservationNumbersByOrderNumbers(params) {
|
|
1073
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1074
|
-
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
1075
|
-
return [];
|
|
1076
|
-
}
|
|
1077
|
-
return this.orderModel.distinct('acceptedOffers.itemOffered.reservationNumber', {
|
|
1078
|
-
'acceptedOffers.itemOffered.reservationNumber': { $exists: true },
|
|
1079
|
-
orderNumber: { $in: params.orderNumber.$in }
|
|
1080
|
-
})
|
|
1081
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1082
|
-
.exec();
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* 注文に含まれるイベントIDを検索する
|
|
1087
|
-
*/
|
|
1088
|
-
searchReservationForIdsByOrderNumbers(params) {
|
|
1089
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1090
|
-
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
1091
|
-
return [];
|
|
1092
|
-
}
|
|
1093
|
-
return this.orderModel.distinct('acceptedOffers.itemOffered.reservationFor.id', {
|
|
1094
|
-
'acceptedOffers.itemOffered.reservationFor.id': { $exists: true },
|
|
1095
|
-
orderNumber: { $in: params.orderNumber.$in }
|
|
1096
|
-
})
|
|
1097
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1098
|
-
.exec();
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* 注文に含まれるacceptedOffersを検索する
|
|
1103
|
-
*/
|
|
1104
|
-
searchAcceptedOffersByOrderNumbers(params) {
|
|
1105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1106
|
-
if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
|
|
1107
|
-
return [];
|
|
1108
|
-
}
|
|
1109
|
-
const aggregate = this.orderModel.aggregate();
|
|
1110
|
-
aggregate.unwind('$acceptedOffers');
|
|
1111
|
-
aggregate.match({ orderNumber: { $in: params.orderNumber.$in } });
|
|
1112
|
-
aggregate.project({
|
|
1113
|
-
_id: 0,
|
|
1114
|
-
id: '$acceptedOffers.id',
|
|
1115
|
-
priceSpecification: '$acceptedOffers.priceSpecification'
|
|
1116
|
-
});
|
|
1117
|
-
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1118
|
-
.exec();
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
981
|
getCursor(conditions, projection) {
|
|
1122
982
|
return this.orderModel.find(conditions, projection)
|
|
1123
983
|
.sort({ orderDate: factory.sortType.Descending })
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* リポジトリ
|
|
3
3
|
*/
|
|
4
|
+
import type { MongoRepository as AcceptedOfferRepo } from './repo/acceptedOffer';
|
|
4
5
|
import type { MongoRepository as AccountRepo } from './repo/account';
|
|
5
6
|
import type { MongoRepository as AccountingReportRepo } from './repo/accountingReport';
|
|
6
7
|
import type { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
@@ -51,6 +52,10 @@ import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmat
|
|
|
51
52
|
import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
|
|
52
53
|
import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
|
|
53
54
|
import type { CognitoRepository as PersonRepo } from './repo/person';
|
|
55
|
+
export type AcceptedOffer = AcceptedOfferRepo;
|
|
56
|
+
export declare namespace AcceptedOffer {
|
|
57
|
+
function createInstance(...params: ConstructorParameters<typeof AcceptedOfferRepo>): Promise<AcceptedOfferRepo>;
|
|
58
|
+
}
|
|
54
59
|
export type Account = AccountRepo;
|
|
55
60
|
export declare namespace Account {
|
|
56
61
|
function createInstance(...params: ConstructorParameters<typeof AccountRepo>): Promise<AccountRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,7 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = void 0;
|
|
14
|
+
var AcceptedOffer;
|
|
15
|
+
(function (AcceptedOffer) {
|
|
16
|
+
let repo;
|
|
17
|
+
function createInstance(...params) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (repo === undefined) {
|
|
20
|
+
repo = (yield Promise.resolve().then(() => require('./repo/acceptedOffer'))).MongoRepository;
|
|
21
|
+
}
|
|
22
|
+
return new repo(...params);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
AcceptedOffer.createInstance = createInstance;
|
|
26
|
+
})(AcceptedOffer = exports.AcceptedOffer || (exports.AcceptedOffer = {}));
|
|
13
27
|
var Account;
|
|
14
28
|
(function (Account) {
|
|
15
29
|
let repo;
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
14
15
|
const action_1 = require("../../repo/action");
|
|
15
16
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
17
|
const code_1 = require("../../repo/code");
|
|
@@ -26,6 +27,7 @@ const reserve_1 = require("../reserve");
|
|
|
26
27
|
function call(data) {
|
|
27
28
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
yield onAuthorizationCreated(data)({
|
|
30
|
+
acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
|
|
29
31
|
action: new action_1.MongoRepository(settings.connection),
|
|
30
32
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
31
33
|
code: new code_1.MongoRepository(settings.connection),
|
|
@@ -38,6 +40,7 @@ function call(data) {
|
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
exports.call = call;
|
|
43
|
+
// tslint:disable-next-line:max-func-body-length
|
|
41
44
|
function onAuthorizationCreated(params) {
|
|
42
45
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
43
46
|
// 発券対象予約ID
|
|
@@ -55,24 +58,31 @@ function onAuthorizationCreated(params) {
|
|
|
55
58
|
// 注文検索
|
|
56
59
|
const orderNumber = authorizationObject.orderNumber;
|
|
57
60
|
if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
orderNumber,
|
|
61
|
-
project: { id: params.project.id },
|
|
62
|
-
inclusion: ['acceptedOffers'],
|
|
63
|
-
exclusion: []
|
|
61
|
+
reservationNumbers = yield repos.acceptedOffer.searchReservationNumbersByOrderNumbers({
|
|
62
|
+
orderNumber: { $in: [orderNumber] }
|
|
64
63
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
reservationForIds = yield repos.acceptedOffer.searchReservationForIdsByOrderNumbers({
|
|
65
|
+
orderNumber: { $in: [orderNumber] }
|
|
66
|
+
});
|
|
67
|
+
// const order: Pick<factory.order.IOrder, 'acceptedOffers'> = await repos.order.findByOrderNumber(
|
|
68
|
+
// {
|
|
69
|
+
// orderNumber,
|
|
70
|
+
// project: { id: params.project.id },
|
|
71
|
+
// inclusion: ['acceptedOffers'],
|
|
72
|
+
// exclusion: []
|
|
73
|
+
// }
|
|
74
|
+
// );
|
|
75
|
+
// const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
76
|
+
// reservationNumbers = acceptedOffers
|
|
77
|
+
// .filter((o) => o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
78
|
+
// || o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
79
|
+
// .map((o) => (<factory.order.IReservation>o.itemOffered).reservationNumber);
|
|
80
|
+
// reservationNumbers = [...new Set(reservationNumbers)];
|
|
81
|
+
// reservationForIds = acceptedOffers
|
|
82
|
+
// .filter((o) => o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
83
|
+
// || o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
84
|
+
// .map((o) => String((<factory.order.IReservation>o.itemOffered).reservationFor.id));
|
|
85
|
+
// reservationForIds = [...new Set(reservationForIds)];
|
|
76
86
|
}
|
|
77
87
|
break;
|
|
78
88
|
case 'OwnershipInfo':
|
|
@@ -412,8 +412,8 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
|
412
412
|
orderNumbers: [String(fromLocation.orderNumber)],
|
|
413
413
|
confirmationNumbers: [String(fromLocation.confirmationNumber)]
|
|
414
414
|
}, {
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
identifier: 1,
|
|
416
|
+
orderStatus: 1
|
|
417
417
|
});
|
|
418
418
|
const order = orders.shift();
|
|
419
419
|
if (order === undefined) {
|
|
@@ -467,8 +467,7 @@ function validateToLocation(project, toLocationBeforeStart, issuedThrough) {
|
|
|
467
467
|
orderNumbers: [String(toLocation.orderNumber)],
|
|
468
468
|
confirmationNumbers: [String(toLocation.confirmationNumber)]
|
|
469
469
|
}, {
|
|
470
|
-
|
|
471
|
-
orderedItem: 0
|
|
470
|
+
identifier: 1
|
|
472
471
|
});
|
|
473
472
|
const order = orders.shift();
|
|
474
473
|
if (order === undefined) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
3
|
import type { MongoRepository as EmailMessageRepo } from '../../repo/emailMessage';
|
|
3
4
|
import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
4
5
|
import type { MongoRepository as MerchantReturnPolicyRepo } from '../../repo/merchantReturnPolicy';
|
|
@@ -11,6 +12,7 @@ import type { MongoRepository as SellerRepo } from '../../repo/seller';
|
|
|
11
12
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
12
13
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
13
14
|
export interface IStartOperationRepos {
|
|
15
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
14
16
|
event: EventRepo;
|
|
15
17
|
merchantReturnPolicy: MerchantReturnPolicyRepo;
|
|
16
18
|
offer: OfferRepo;
|
|
@@ -181,15 +181,15 @@ function fixOrders(params) {
|
|
|
181
181
|
if (orders.length !== params.object.order.length) {
|
|
182
182
|
throw new factory.errors.NotFound('Order');
|
|
183
183
|
}
|
|
184
|
-
const offerIds = yield repos.
|
|
184
|
+
const offerIds = yield repos.acceptedOffer.searchAcceptedOfferIds({
|
|
185
185
|
project: { id: { $eq: params.project.id } },
|
|
186
186
|
confirmationNumbers: [params.object.order[0].confirmationNumber],
|
|
187
187
|
orderNumbers: [params.object.order[0].orderNumber]
|
|
188
188
|
});
|
|
189
|
-
const eventIds = yield repos.
|
|
189
|
+
const eventIds = yield repos.acceptedOffer.searchReservationForIdsByOrderNumbers({
|
|
190
190
|
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
191
191
|
});
|
|
192
|
-
const acceptedOffers = yield repos.
|
|
192
|
+
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumbers({
|
|
193
193
|
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
194
194
|
});
|
|
195
195
|
return { acceptedOffers, eventIds, offerIds, orders };
|
|
@@ -208,7 +208,7 @@ function checkUsedReservationExists(params) {
|
|
|
208
208
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
209
209
|
let usedReservationExists = false;
|
|
210
210
|
// 注文に含まれる予約の状態検証
|
|
211
|
-
const reservationNumbers = yield repos.
|
|
211
|
+
const reservationNumbers = yield repos.acceptedOffer.searchReservationNumbersByOrderNumbers({
|
|
212
212
|
orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
213
213
|
});
|
|
214
214
|
if (reservationNumbers.length > 0) {
|
package/package.json
CHANGED