@chevre/domain 21.9.0-alpha.16 → 21.9.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/syncCatalogs2aggregateOffers.ts +20 -19
- package/lib/chevre/repo/offer.d.ts +3 -5
- package/lib/chevre/repo/offer.js +32 -20
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -4
- package/lib/chevre/service/offer/product/searchProductOffers.js +3 -3
- package/lib/chevre/service/offer/product.js +3 -30
- package/package.json +2 -2
|
@@ -11,11 +11,12 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
// tslint:disable-next-line:max-func-body-length
|
|
12
12
|
async function main() {
|
|
13
13
|
const now = new Date();
|
|
14
|
+
console.log('now:', now);
|
|
14
15
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
16
|
|
|
16
17
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
17
18
|
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
18
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
+
// const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
20
|
|
|
20
21
|
const cursor = offerCatalogRepo.getCursor(
|
|
21
22
|
{
|
|
@@ -53,24 +54,24 @@ async function main() {
|
|
|
53
54
|
console.log('already synced.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
54
55
|
} else {
|
|
55
56
|
console.log('creating task...', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
56
|
-
const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
57
|
+
// const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
|
|
58
|
+
// typeOf: 'OfferCatalog',
|
|
59
|
+
// id: [String(offerCatalog.id)],
|
|
60
|
+
// isNew: false,
|
|
61
|
+
// isDeleted: false,
|
|
62
|
+
// project: { id: offerCatalog.project.id },
|
|
63
|
+
// useInform: false
|
|
64
|
+
// };
|
|
65
|
+
// const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
|
|
66
|
+
// data: syncTaskData,
|
|
67
|
+
// executionResults: [],
|
|
68
|
+
// name: chevre.factory.taskName.OnResourceUpdated,
|
|
69
|
+
// numberOfTried: 0,
|
|
70
|
+
// project: offerCatalog.project,
|
|
71
|
+
// remainingNumberOfTries: 1,
|
|
72
|
+
// runsAt: now,
|
|
73
|
+
// status: chevre.factory.taskStatus.Ready
|
|
74
|
+
// };
|
|
74
75
|
// await taskRepo.saveMany([syncTask], { emitImmediately: false });
|
|
75
76
|
updateCount += 1;
|
|
76
77
|
console.log('task saved.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
@@ -40,10 +40,10 @@ export declare class MongoRepository {
|
|
|
40
40
|
offers: IUnitPriceOfferFromAggregateOffer[];
|
|
41
41
|
}>;
|
|
42
42
|
/**
|
|
43
|
-
* 単価オファーIDとカタログID
|
|
44
|
-
*
|
|
43
|
+
* 単価オファーIDとカタログIDで単価オファーを全て検索する
|
|
44
|
+
* 単価オファーIDを一定数指定する想定なのでpagingは不要
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
searchAllByIdsAndOfferCatalogId(params: {
|
|
47
47
|
/**
|
|
48
48
|
* 指定したIDの単価オファーだけ取得
|
|
49
49
|
*/
|
|
@@ -61,8 +61,6 @@ export declare class MongoRepository {
|
|
|
61
61
|
unacceptedPaymentMethod?: string[];
|
|
62
62
|
excludeAppliesToMovieTicket: boolean;
|
|
63
63
|
onlyValid?: boolean;
|
|
64
|
-
limit?: number;
|
|
65
|
-
page?: number;
|
|
66
64
|
projection?: IProjection;
|
|
67
65
|
}): Promise<{
|
|
68
66
|
offers: IUnitPriceOfferFromAggregateOffer[];
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -21,12 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
|
+
const createDebug = require("debug");
|
|
24
25
|
const mongoose_1 = require("mongoose");
|
|
25
26
|
const uniqid = require("uniqid");
|
|
26
27
|
const factory = require("../factory");
|
|
27
28
|
const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
|
|
28
29
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
29
30
|
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
31
|
+
const debug = createDebug('chevre-domain:repo:offer');
|
|
30
32
|
const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
|
|
31
33
|
/**
|
|
32
34
|
* 単価オファーリポジトリ
|
|
@@ -474,29 +476,33 @@ class MongoRepository {
|
|
|
474
476
|
});
|
|
475
477
|
}
|
|
476
478
|
/**
|
|
477
|
-
* 単価オファーIDとカタログID
|
|
478
|
-
*
|
|
479
|
+
* 単価オファーIDとカタログIDで単価オファーを全て検索する
|
|
480
|
+
* 単価オファーIDを一定数指定する想定なのでpagingは不要
|
|
479
481
|
*/
|
|
480
|
-
|
|
482
|
+
searchAllByIdsAndOfferCatalogId(params) {
|
|
481
483
|
var _a;
|
|
482
484
|
return __awaiter(this, void 0, void 0, function* () {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
485
|
+
if (!Array.isArray(params.ids) || params.ids.length === 0) {
|
|
486
|
+
throw new factory.errors.ArgumentNull('offer.ids');
|
|
487
|
+
}
|
|
488
|
+
// 解釈を集計オファーIDに変更する必要がある(2023-09-11~)
|
|
489
|
+
// 単価オファーIDリスト→集計オファーIDに変換→カタログ条件にセット
|
|
490
|
+
const aggregateOfferIds = yield this.aggregateOfferModel.distinct('_id', { 'offers.id': { $in: params.ids } })
|
|
491
|
+
.exec();
|
|
492
|
+
if (aggregateOfferIds.length === 0) {
|
|
493
|
+
throw new factory.errors.NotFound(factory.offerType.AggregateOffer);
|
|
491
494
|
}
|
|
492
|
-
const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog(
|
|
495
|
+
const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
|
|
496
|
+
id: params.subOfferCatalog.id,
|
|
497
|
+
isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem,
|
|
498
|
+
itemListElementIds: aggregateOfferIds
|
|
499
|
+
});
|
|
493
500
|
let offers = [];
|
|
494
501
|
if (sortedOfferIds.length > 0) {
|
|
495
|
-
|
|
502
|
+
debug('searchAllByIdsAndOfferCatalogId:searching offers...,sortedOfferIds:', sortedOfferIds, 'ids:', params.ids);
|
|
503
|
+
const searchOffersConditions = Object.assign({
|
|
496
504
|
// aggregateOffer.idで検索する(2023-09-09~)
|
|
497
|
-
parentOffer: { id: { $in: sortedOfferIds } }
|
|
498
|
-
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
|
|
499
|
-
: undefined), { priceSpecification: {
|
|
505
|
+
parentOffer: { id: { $in: sortedOfferIds } }, id: { $in: params.ids }, priceSpecification: {
|
|
500
506
|
appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
501
507
|
? {
|
|
502
508
|
serviceOutput: {
|
|
@@ -508,10 +514,16 @@ class MongoRepository {
|
|
|
508
514
|
serviceType: { $exists: false }
|
|
509
515
|
}
|
|
510
516
|
: undefined)
|
|
511
|
-
}, onlyValid: params.onlyValid === true }
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
517
|
+
}, onlyValid: params.onlyValid === true }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
518
|
+
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
|
|
519
|
+
: undefined
|
|
520
|
+
// ...(typeof params.limit === 'number' && typeof params.page === 'number')
|
|
521
|
+
// // 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
|
|
522
|
+
// ? { sort: { identifier: factory.sortType.Ascending } }
|
|
523
|
+
// : undefined,
|
|
524
|
+
// ...(typeof params.limit === 'number') ? { limit: params.limit } : undefined,
|
|
525
|
+
// ...(typeof params.page === 'number') ? { page: params.page } : undefined
|
|
526
|
+
);
|
|
515
527
|
offers = yield this.search(searchOffersConditions, params.projection);
|
|
516
528
|
}
|
|
517
529
|
return { offers };
|
|
@@ -58,15 +58,15 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
58
58
|
if (!Array.isArray(params.ids)) {
|
|
59
59
|
throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
60
60
|
}
|
|
61
|
-
const { offers } = yield repos.offer.
|
|
61
|
+
const { offers } = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
62
62
|
ids: params.ids,
|
|
63
63
|
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
64
64
|
availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
|
|
65
65
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
66
66
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
67
|
-
onlyValid: params.onlyValid === true
|
|
68
|
-
limit: params.limit,
|
|
69
|
-
page: params.page
|
|
67
|
+
onlyValid: params.onlyValid === true
|
|
68
|
+
// limit: params.limit,
|
|
69
|
+
// page: params.page
|
|
70
70
|
});
|
|
71
71
|
return { availableOffers: offers };
|
|
72
72
|
}
|
|
@@ -59,12 +59,12 @@ function searchProductOffers(params) {
|
|
|
59
59
|
if (!Array.isArray(params.ids)) {
|
|
60
60
|
throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
61
61
|
}
|
|
62
|
-
const searchByOfferCatalogIdResult = yield repos.offer.
|
|
62
|
+
const searchByOfferCatalogIdResult = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
63
63
|
ids: params.ids,
|
|
64
64
|
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
65
65
|
excludeAppliesToMovieTicket: false,
|
|
66
|
-
limit: params.limit,
|
|
67
|
-
page: params.page,
|
|
66
|
+
// limit: params.limit,
|
|
67
|
+
// page: params.page,
|
|
68
68
|
onlyValid: params.onlyValid === true,
|
|
69
69
|
availableAtOrFrom: params.availableAt
|
|
70
70
|
});
|
|
@@ -19,7 +19,6 @@ const placeOrderInProgress_1 = require("../transaction/placeOrderInProgress");
|
|
|
19
19
|
const factory_1 = require("./product/factory");
|
|
20
20
|
const searchProductOffers_1 = require("./product/searchProductOffers");
|
|
21
21
|
exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
|
|
22
|
-
// export { searchProductOffers };
|
|
23
22
|
/**
|
|
24
23
|
* プロダクトオファーを検索する
|
|
25
24
|
*/
|
|
@@ -60,43 +59,17 @@ function search(params) {
|
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
|
-
// let offers: factory.product.ITicketOffer[] = [];
|
|
64
62
|
const offers = yield (0, searchProductOffers_1.searchProductOffers)({
|
|
65
63
|
ids: params.ids,
|
|
66
64
|
itemOffered: { id: params.itemOffered.id },
|
|
67
65
|
availableAt: params.availableAt,
|
|
68
66
|
onlyValid: params.onlyValid,
|
|
69
67
|
addSortIndex: params.addSortIndex,
|
|
70
|
-
useIncludeInDataCatalog: params.useIncludeInDataCatalog
|
|
68
|
+
useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
69
|
+
limit: params.limit,
|
|
70
|
+
page: params.page
|
|
71
71
|
})(repos);
|
|
72
72
|
return { offers, product };
|
|
73
|
-
// Mongoへ移行(2023-03-01~)
|
|
74
|
-
// 店舗条件によって対象を絞る
|
|
75
|
-
// const storeId = params.availableAt?.id;
|
|
76
|
-
// if (typeof storeId === 'string') {
|
|
77
|
-
// // アプリケーションが利用可能なオファーに絞る
|
|
78
|
-
// offers = offers.filter((o) => {
|
|
79
|
-
// return Array.isArray(o.availableAtOrFrom)
|
|
80
|
-
// && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
|
|
81
|
-
// });
|
|
82
|
-
// }
|
|
83
|
-
// Mongoへ移行(2023-03-01~)
|
|
84
|
-
// 有効期間を適用
|
|
85
|
-
// if (params.onlyValid === true) {
|
|
86
|
-
// offers = offers.filter((o) => {
|
|
87
|
-
// let isValid = true;
|
|
88
|
-
// if (o.validFrom !== undefined && moment(o.validFrom)
|
|
89
|
-
// .isAfter(now)) {
|
|
90
|
-
// isValid = false;
|
|
91
|
-
// }
|
|
92
|
-
// if (o.validThrough !== undefined && moment(o.validThrough)
|
|
93
|
-
// .isBefore(now)) {
|
|
94
|
-
// isValid = false;
|
|
95
|
-
// }
|
|
96
|
-
// return isValid;
|
|
97
|
-
// });
|
|
98
|
-
// }
|
|
99
|
-
// return offers;
|
|
100
73
|
});
|
|
101
74
|
}
|
|
102
75
|
exports.search = search;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@chevre/factory": "4.330.0",
|
|
13
|
-
"@cinerino/sdk": "3.169.0
|
|
13
|
+
"@cinerino/sdk": "3.169.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.9.0-alpha.
|
|
120
|
+
"version": "21.9.0-alpha.17"
|
|
121
121
|
}
|