@chevre/domain 20.4.0-alpha.30 → 20.4.0-alpha.32
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/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
- package/example/src/chevre/searchEventTicketOffers.ts +0 -1
- package/lib/chevre/repo/task.d.ts +8 -0
- package/lib/chevre/repo/task.js +8 -0
- package/lib/chevre/service/assetTransaction/registerService.js +3 -1
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +12 -8
- package/lib/chevre/service/offer/product.d.ts +7 -1
- package/lib/chevre/service/offer/product.js +53 -46
- package/lib/chevre/service/transaction/orderProgramMembership.js +1 -1
- package/package.json +1 -1
|
@@ -8,9 +8,11 @@ import { chevre } from '../../../lib/index';
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
12
12
|
|
|
13
|
-
const result = await
|
|
13
|
+
const result = await taskRepo.deleteByName({
|
|
14
|
+
name: <any>'DeleteAuthorization'
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
console.log('deleted', result);
|
|
16
18
|
}
|
|
@@ -55,6 +55,14 @@ export declare class MongoRepository {
|
|
|
55
55
|
id: string;
|
|
56
56
|
};
|
|
57
57
|
}): Promise<void>;
|
|
58
|
+
deleteByName(params: {
|
|
59
|
+
name: factory.taskName;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
ok?: number | undefined;
|
|
62
|
+
n?: number | undefined;
|
|
63
|
+
} & {
|
|
64
|
+
deletedCount?: number | undefined;
|
|
65
|
+
}>;
|
|
58
66
|
aggregateTask(params: {
|
|
59
67
|
project?: {
|
|
60
68
|
id?: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -310,6 +310,14 @@ class MongoRepository {
|
|
|
310
310
|
.exec();
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
+
deleteByName(params) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
return this.taskModel.deleteMany({
|
|
316
|
+
name: { $eq: params.name }
|
|
317
|
+
})
|
|
318
|
+
.exec();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
313
321
|
aggregateTask(params) {
|
|
314
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
315
323
|
const statuses = yield Promise.all([
|
|
@@ -94,8 +94,10 @@ function createTransactionObject(params) {
|
|
|
94
94
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
// オファー検索
|
|
96
96
|
const offers = yield (0, searchProductOffers_1.searchProductOffers)({
|
|
97
|
+
ids: params.acceptedOffers.map((o) => o.id),
|
|
97
98
|
itemOffered: { id: String(params.product.id) },
|
|
98
|
-
|
|
99
|
+
onlyValid: true,
|
|
100
|
+
addSortIndex: false
|
|
99
101
|
})(repos);
|
|
100
102
|
const transactionObject = [];
|
|
101
103
|
for (const acceptedOffer of params.acceptedOffers) {
|
|
@@ -5,10 +5,20 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
|
5
5
|
* プロダクトオファーを検索する
|
|
6
6
|
*/
|
|
7
7
|
export declare function searchProductOffers(params: {
|
|
8
|
+
/**
|
|
9
|
+
* 指定したIDのオファーだけ取得する場合
|
|
10
|
+
*/
|
|
11
|
+
ids?: string[];
|
|
8
12
|
itemOffered: {
|
|
9
13
|
id: string;
|
|
10
14
|
};
|
|
11
|
-
|
|
15
|
+
availableAt?: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
onlyValid: boolean;
|
|
19
|
+
addSortIndex: boolean;
|
|
20
|
+
limit?: number;
|
|
21
|
+
page?: number;
|
|
12
22
|
}): (repos: {
|
|
13
23
|
offer: OfferRepo;
|
|
14
24
|
product: ProductRepo;
|
|
@@ -23,16 +23,23 @@ function searchProductOffers(params) {
|
|
|
23
23
|
if (typeof offerCatalogId !== 'string') {
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
|
-
const { offers } = yield repos.offer.findOffersByOfferCatalogId({
|
|
26
|
+
const { offers, sortedOfferIds } = yield repos.offer.findOffersByOfferCatalogId({
|
|
27
|
+
ids: params.ids,
|
|
27
28
|
offerCatalog: { id: offerCatalogId },
|
|
28
29
|
excludeAppliesToMovieTicket: false,
|
|
29
|
-
|
|
30
|
+
limit: params.limit,
|
|
31
|
+
page: params.page,
|
|
32
|
+
sort: false,
|
|
33
|
+
onlyValid: params.onlyValid === true,
|
|
34
|
+
availableAtOrFrom: params.availableAt
|
|
30
35
|
});
|
|
31
36
|
return offers.map((o) => {
|
|
37
|
+
let sortIndex;
|
|
38
|
+
if (params.addSortIndex) {
|
|
39
|
+
sortIndex = sortedOfferIds.indexOf(String(o.id));
|
|
40
|
+
}
|
|
32
41
|
const unitSpec = o.priceSpecification;
|
|
33
42
|
const compoundPriceSpecification = {
|
|
34
|
-
// 不要な属性を除外(2022-11-02~)
|
|
35
|
-
// project: productWithOffers.project,
|
|
36
43
|
typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
|
|
37
44
|
priceCurrency: factory.priceCurrency.JPY,
|
|
38
45
|
valueAddedTaxIncluded: true,
|
|
@@ -40,10 +47,7 @@ function searchProductOffers(params) {
|
|
|
40
47
|
...(unitSpec !== undefined) ? [unitSpec] : []
|
|
41
48
|
]
|
|
42
49
|
};
|
|
43
|
-
return Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency,
|
|
44
|
-
// 不要な属性を除外(2022-11-07~)
|
|
45
|
-
// project: o.project,
|
|
46
|
-
typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
|
|
50
|
+
return Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
|
|
47
51
|
});
|
|
48
52
|
});
|
|
49
53
|
}
|
|
@@ -37,6 +37,10 @@ export { searchProductOffers };
|
|
|
37
37
|
* プロダクトオファーを検索する
|
|
38
38
|
*/
|
|
39
39
|
export declare function search(params: {
|
|
40
|
+
/**
|
|
41
|
+
* 指定したIDのオファーだけ取得する場合
|
|
42
|
+
*/
|
|
43
|
+
ids?: string[];
|
|
40
44
|
project: {
|
|
41
45
|
id: string;
|
|
42
46
|
};
|
|
@@ -50,7 +54,9 @@ export declare function search(params: {
|
|
|
50
54
|
id: string;
|
|
51
55
|
};
|
|
52
56
|
onlyValid: boolean;
|
|
53
|
-
|
|
57
|
+
limit?: number;
|
|
58
|
+
page?: number;
|
|
59
|
+
addSortIndex: boolean;
|
|
54
60
|
}): (repos: {
|
|
55
61
|
offer: OfferRepo;
|
|
56
62
|
product: ProductRepo;
|
|
@@ -25,9 +25,8 @@ exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
|
|
|
25
25
|
*/
|
|
26
26
|
function search(params) {
|
|
27
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a
|
|
28
|
+
var _a;
|
|
29
29
|
const now = moment();
|
|
30
|
-
let offers = [];
|
|
31
30
|
const searchProductsResult = yield repos.product.search({
|
|
32
31
|
limit: 1,
|
|
33
32
|
page: 1,
|
|
@@ -39,54 +38,63 @@ function search(params) {
|
|
|
39
38
|
throw new factory.errors.NotFound('Product');
|
|
40
39
|
}
|
|
41
40
|
// 販売者指定の場合、検証
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
if (product.typeOf === factory.product.ProductType.MembershipService
|
|
42
|
+
|| product.typeOf === factory.product.ProductType.PaymentCard) {
|
|
43
|
+
if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
44
|
+
const productOffers = product.offers;
|
|
45
|
+
if (!Array.isArray(productOffers)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const hasValidOffer = productOffers.some((o) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
|
|
51
|
+
&& o.validFrom !== undefined
|
|
52
|
+
&& moment(o.validFrom)
|
|
53
|
+
.isSameOrBefore(now)
|
|
54
|
+
&& o.validThrough !== undefined
|
|
55
|
+
&& moment(o.validThrough)
|
|
56
|
+
.isSameOrAfter(now);
|
|
57
|
+
});
|
|
58
|
+
if (!hasValidOffer) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
offers =
|
|
63
|
+
// let offers: factory.product.ITicketOffer[] = [];
|
|
64
|
+
return (0, searchProductOffers_1.searchProductOffers)({
|
|
65
|
+
ids: params.ids,
|
|
62
66
|
itemOffered: { id: params.itemOffered.id },
|
|
63
|
-
|
|
67
|
+
availableAt: params.availableAt,
|
|
68
|
+
onlyValid: params.onlyValid,
|
|
69
|
+
addSortIndex: params.addSortIndex
|
|
64
70
|
})(repos);
|
|
71
|
+
// Mongoへ移行(2023-03-01~)
|
|
65
72
|
// 店舗条件によって対象を絞る
|
|
66
|
-
const storeId =
|
|
67
|
-
if (typeof storeId === 'string') {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
73
|
+
// const storeId = params.availableAt?.id;
|
|
74
|
+
// if (typeof storeId === 'string') {
|
|
75
|
+
// // アプリケーションが利用可能なオファーに絞る
|
|
76
|
+
// offers = offers.filter((o) => {
|
|
77
|
+
// return Array.isArray(o.availableAtOrFrom)
|
|
78
|
+
// && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
|
|
79
|
+
// });
|
|
80
|
+
// }
|
|
81
|
+
// Mongoへ移行(2023-03-01~)
|
|
74
82
|
// 有効期間を適用
|
|
75
|
-
if (params.onlyValid === true) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
return offers;
|
|
83
|
+
// if (params.onlyValid === true) {
|
|
84
|
+
// offers = offers.filter((o) => {
|
|
85
|
+
// let isValid = true;
|
|
86
|
+
// if (o.validFrom !== undefined && moment(o.validFrom)
|
|
87
|
+
// .isAfter(now)) {
|
|
88
|
+
// isValid = false;
|
|
89
|
+
// }
|
|
90
|
+
// if (o.validThrough !== undefined && moment(o.validThrough)
|
|
91
|
+
// .isBefore(now)) {
|
|
92
|
+
// isValid = false;
|
|
93
|
+
// }
|
|
94
|
+
// return isValid;
|
|
95
|
+
// });
|
|
96
|
+
// }
|
|
97
|
+
// return offers;
|
|
90
98
|
});
|
|
91
99
|
}
|
|
92
100
|
exports.search = search;
|
|
@@ -202,8 +210,7 @@ function fixProductAndOffers(params) {
|
|
|
202
210
|
if (product === undefined) {
|
|
203
211
|
throw new factory.errors.NotFound('Product');
|
|
204
212
|
}
|
|
205
|
-
const availableOffers = yield search(Object.assign(
|
|
206
|
-
}))(repos);
|
|
213
|
+
const availableOffers = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
|
|
207
214
|
return { product, availableOffers };
|
|
208
215
|
});
|
|
209
216
|
}
|
|
@@ -218,7 +218,7 @@ function processAuthorizeProductOffer(params) {
|
|
|
218
218
|
itemOffered: { id: params.product.id },
|
|
219
219
|
seller: { id: String(seller.id) },
|
|
220
220
|
onlyValid: true,
|
|
221
|
-
|
|
221
|
+
addSortIndex: false
|
|
222
222
|
})(repos);
|
|
223
223
|
const acceptedProductOffer = offers.find((o) => o.identifier === acceptedOffer.identifier);
|
|
224
224
|
if (acceptedProductOffer === undefined) {
|
package/package.json
CHANGED