@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.60
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/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +25 -17
- package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
- package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
- package/example/src/chevre/event/importEventsFromCOAByTitle.ts +2 -2
- package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
- package/example/src/chevre/eventSeries/unsetVideoFormat.ts +31 -0
- package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -43
- package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
- package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +8 -3
- package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
- package/example/src/chevre/orderNumber/decryptOrderNumber.ts +14 -0
- package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
- package/example/src/chevre/place/adminEntranceGates.ts +69 -0
- package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
- package/example/src/chevre/place/findRooms.ts +24 -0
- package/example/src/chevre/place/findSections.ts +28 -0
- package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
- package/example/src/chevre/place/seatsJson2csv.ts +63 -0
- package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
- package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
- package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
- package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
- package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
- package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
- package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
- package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
- package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
- package/lib/chevre/emailMessageBuilder.js +1 -0
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/factory/event.js +11 -5
- package/lib/chevre/factory/transactionNumber.d.ts +19 -0
- package/lib/chevre/factory/transactionNumber.js +54 -0
- package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
- package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
- package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
- package/lib/chevre/repo/aggregateOffer.js +11 -3
- package/lib/chevre/repo/aggregateOrder.js +0 -93
- package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
- package/lib/chevre/repo/aggregateReservation.js +0 -2
- package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
- package/lib/chevre/repo/confirmationNumber.js +32 -25
- package/lib/chevre/repo/event.d.ts +3 -3
- package/lib/chevre/repo/event.js +20 -8
- package/lib/chevre/repo/eventOffer.d.ts +8 -0
- package/lib/chevre/repo/eventOffer.js +11 -0
- package/lib/chevre/repo/eventSeries.d.ts +18 -25
- package/lib/chevre/repo/eventSeries.js +155 -101
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +13 -25
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
- package/lib/chevre/repo/offerCatalog.d.ts +14 -1
- package/lib/chevre/repo/offerCatalog.js +41 -19
- package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
- package/lib/chevre/repo/offerCatalogItem.js +32 -17
- package/lib/chevre/repo/orderNumber.d.ts +7 -0
- package/lib/chevre/repo/orderNumber.js +110 -34
- package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
- package/lib/chevre/repo/place/entranceGate.js +172 -0
- package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
- package/lib/chevre/repo/place/movieTheater.js +77 -6
- package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
- package/lib/chevre/repo/place/screeningRoom.js +227 -135
- package/lib/chevre/repo/place/seat.d.ts +47 -45
- package/lib/chevre/repo/place/seat.js +175 -45
- package/lib/chevre/repo/place/section.d.ts +60 -30
- package/lib/chevre/repo/place/section.js +337 -127
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
- package/lib/chevre/repo/setting.d.ts +1 -1
- package/lib/chevre/repo/setting.js +2 -2
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/transactionNumber.d.ts +5 -0
- package/lib/chevre/repo/transactionNumber.js +63 -27
- package/lib/chevre/repository.d.ts +8 -0
- package/lib/chevre/repository.js +16 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
- package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
- package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
- package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
- package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
- package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
- package/lib/chevre/service/offer/onEventChanged.js +10 -6
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/offer.d.ts +5 -0
- package/lib/chevre/service/offer.js +34 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +2 -2
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
- package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
- package/lib/chevre/service/task/onResourceDeleted.js +168 -0
- package/lib/chevre/service/task/onResourceUpdated.js +205 -42
- package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
- package/lib/chevre/service/taskHandler.js +1 -0
- package/package.json +10 -8
- package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
- package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
- package/example/src/chevre/offers/createSampleOffers.ts +0 -154
- package/example/src/chevre/settings/addSettings.ts +0 -46
- package/lib/chevre/service/eventOld.d.ts +0 -60
- package/lib/chevre/service/eventOld.js +0 -864
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// tslint:disable:object-literal-key-quotes no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function testGeneration() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
|
|
10
|
+
connection: mongoose.connection
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const ts = new Date(); // 同一ミリ秒固定
|
|
14
|
+
const results: Record<string, string>[] = [];
|
|
15
|
+
|
|
16
|
+
console.log(`--- 同一ミリ秒(${ts})内での連続生成テスト ---`);
|
|
17
|
+
|
|
18
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
for (let i = 0; i < 100; i += 1) {
|
|
20
|
+
// 同一ミリ秒内でシーケンス(00-99)だけが変わる状況を再現
|
|
21
|
+
const { transactionNumber, timestamp, incrReply } = await transactionNumberRepo.publishByTimestamp({ startDate: ts });
|
|
22
|
+
|
|
23
|
+
// 復号して元のデータに戻るかチェック
|
|
24
|
+
const decoded = await transactionNumberRepo.decrypt(transactionNumber);
|
|
25
|
+
const isSuccess = decoded === `${timestamp}${incrReply.toString()
|
|
26
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
+
.padStart(2, '0')}`;
|
|
28
|
+
|
|
29
|
+
results.push({
|
|
30
|
+
timestamp: timestamp,
|
|
31
|
+
'シーケンス': incrReply.toString(),
|
|
32
|
+
'生成された番号 (17桁)': transactionNumber,
|
|
33
|
+
'ソルト(2文字目)': transactionNumber[1],
|
|
34
|
+
'復号結果': decoded,
|
|
35
|
+
'復号確認': isSuccess ? '✅OK' : '❌NG'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.table(results);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
testGeneration();
|
|
@@ -9,16 +9,20 @@ import { chevre } from '../../../lib/index';
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
let updateResult: any;
|
|
15
15
|
|
|
16
|
-
updateResult = await
|
|
16
|
+
updateResult = await movieTheaterRepo.unsetUnnecessaryFields({
|
|
17
17
|
filter: {
|
|
18
|
-
|
|
18
|
+
$or: [
|
|
19
|
+
{ 'offers.availabilityStartsGraceTimeOnPOS': { $exists: true } },
|
|
20
|
+
{ 'offers.availabilityEndsGraceTimeOnPOS': { $exists: true } }
|
|
21
|
+
]
|
|
19
22
|
},
|
|
20
23
|
$unset: {
|
|
21
|
-
'
|
|
24
|
+
'offers.availabilityStartsGraceTimeOnPOS': 1,
|
|
25
|
+
'offers.availabilityEndsGraceTimeOnPOS': 1
|
|
22
26
|
}
|
|
23
27
|
});
|
|
24
28
|
console.log(updateResult);
|
|
@@ -4,5 +4,5 @@ export type IMinimizedIndividualEvent = Pick<factory.event.screeningEvent.IEvent
|
|
|
4
4
|
* 興行イベントのsuperEventを作成する
|
|
5
5
|
*/
|
|
6
6
|
export declare function minimizeSuperEvent(params: {
|
|
7
|
-
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | '
|
|
7
|
+
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
|
|
8
8
|
}): factory.event.screeningEvent.ISuperEvent;
|
|
@@ -23,10 +23,7 @@ function minimizeSuperEvent(params) {
|
|
|
23
23
|
// ? { kanaName: params.superEventFromDB.location.kanaName }
|
|
24
24
|
// : undefined
|
|
25
25
|
);
|
|
26
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.eventType.ScreeningEventSeries,
|
|
27
|
-
// 不要なので廃止(2023-06-09~)
|
|
28
|
-
// project: { typeOf: chevre.factory.organizationType.Project, id: params.project.id },
|
|
29
|
-
id: params.superEventFromDB.id, videoFormat: params.superEventFromDB.videoFormat, soundFormat: params.superEventFromDB.soundFormat, workPerformed,
|
|
26
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.eventType.ScreeningEventSeries, id: params.superEventFromDB.id, soundFormat: params.superEventFromDB.soundFormat, workPerformed,
|
|
30
27
|
location, kanaName: params.superEventFromDB.kanaName, name: Object.assign(Object.assign({}, (typeof params.superEventFromDB.name.en === 'string') ? { en: params.superEventFromDB.name.en } : undefined), (typeof params.superEventFromDB.name.ja === 'string') ? { ja: params.superEventFromDB.name.ja } : undefined) }, (Array.isArray(params.superEventFromDB.additionalProperty))
|
|
31
28
|
? { additionalProperty: params.superEventFromDB.additionalProperty }
|
|
32
29
|
: undefined), (params.superEventFromDB.startDate instanceof Date)
|
|
@@ -41,5 +38,14 @@ function minimizeSuperEvent(params) {
|
|
|
41
38
|
? { dubLanguage: params.superEventFromDB.dubLanguage }
|
|
42
39
|
: undefined), (params.superEventFromDB.subtitleLanguage !== undefined)
|
|
43
40
|
? { subtitleLanguage: params.superEventFromDB.subtitleLanguage }
|
|
44
|
-
: undefined
|
|
41
|
+
: undefined
|
|
42
|
+
// 完全に廃止(2026-02-10~)
|
|
43
|
+
// // videoFormatをデータとしても廃止(万が一に備えてUSE_DEPRECATED_VIDEO_FORMAT_EVENTSで再設定可能)(2026-02-04~)
|
|
44
|
+
// ...(USE_DEPRECATED_VIDEO_FORMAT_EVENTS)
|
|
45
|
+
// ? {
|
|
46
|
+
// // 現時点で型廃止済だがデータとしては互換性維持(2026-01-15~)
|
|
47
|
+
// videoFormat: params.superEventFromDB.videoFormat
|
|
48
|
+
// }
|
|
49
|
+
// : undefined
|
|
50
|
+
);
|
|
45
51
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 取引番号ファクトリー
|
|
3
|
+
*/
|
|
4
|
+
export declare class TransactionNumberFactory {
|
|
5
|
+
private readonly fpeSecret;
|
|
6
|
+
private readonly version;
|
|
7
|
+
constructor(params: {
|
|
8
|
+
fpeSecret: string;
|
|
9
|
+
version: string;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* 生成: SEQが100を超えると自動で18桁に拡張
|
|
13
|
+
*/
|
|
14
|
+
generate(timestamp: string, seq: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* 復号: 17桁でも18桁でも、2文字目以降をまるごとデコード
|
|
17
|
+
*/
|
|
18
|
+
decrypt(transactionNumber: string): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionNumberFactory = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const fpe2Module = require("node-fpe-v2");
|
|
6
|
+
const factory = require("../factory");
|
|
7
|
+
// 型定義が新しいtypescriptに適合しないので、強制的に型変更
|
|
8
|
+
const fpe2 = fpe2Module;
|
|
9
|
+
const TRANSACTION_NUMBER_MIN_LENGTH = 17;
|
|
10
|
+
const SEQUENCE_MAX_LENGTH = 2;
|
|
11
|
+
/**
|
|
12
|
+
* 取引番号ファクトリー
|
|
13
|
+
*/
|
|
14
|
+
class TransactionNumberFactory {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
const { fpeSecret, version } = params;
|
|
17
|
+
this.fpeSecret = fpeSecret;
|
|
18
|
+
this.version = version;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 生成: SEQが100を超えると自動で18桁に拡張
|
|
22
|
+
*/
|
|
23
|
+
generate(timestamp, seq) {
|
|
24
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
+
const saltDigit = (0, crypto_1.randomInt)(0, 10);
|
|
26
|
+
const saltStr = saltDigit.toString();
|
|
27
|
+
const cipher = fpe2({ secret: `${this.fpeSecret}${saltStr}` });
|
|
28
|
+
// incrReplyが 0〜99 なら "00"〜"99" になり(15桁)
|
|
29
|
+
// incrReplyが 100〜999 なら "100"〜"999" になる(16桁)
|
|
30
|
+
const zeroPaddingSequence = seq.toString()
|
|
31
|
+
.padStart(SEQUENCE_MAX_LENGTH, '0');
|
|
32
|
+
const rawBody = `${timestamp}${zeroPaddingSequence}`;
|
|
33
|
+
const encryptedBody = cipher.encrypt(rawBody);
|
|
34
|
+
// ソルトを「あえて」2文字目に含める
|
|
35
|
+
const transactionNumber = `${this.version}${saltStr}${encryptedBody}`;
|
|
36
|
+
if (transactionNumber.length < TRANSACTION_NUMBER_MIN_LENGTH) {
|
|
37
|
+
throw new factory.errors.Internal(`transactionNumber length should be >= ${TRANSACTION_NUMBER_MIN_LENGTH}`);
|
|
38
|
+
}
|
|
39
|
+
return transactionNumber;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 復号: 17桁でも18桁でも、2文字目以降をまるごとデコード
|
|
43
|
+
*/
|
|
44
|
+
decrypt(transactionNumber) {
|
|
45
|
+
const saltStr = transactionNumber[1]; // 2文字目からソルト(鍵のヒント)を回収
|
|
46
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
47
|
+
const encryptedBody = transactionNumber.slice(2);
|
|
48
|
+
const cipher = fpe2({
|
|
49
|
+
secret: `${this.fpeSecret}${saltStr}`
|
|
50
|
+
});
|
|
51
|
+
return cipher.decrypt(encryptedBody);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.TransactionNumberFactory = TransactionNumberFactory;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BulkWriteResult } from 'mongodb';
|
|
1
|
+
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
2
|
import { Connection, FilterQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
import { IDocType } from './mongoose/schemas/acceptedPaymentMethod';
|
|
@@ -20,22 +20,55 @@ export declare class AcceptedPaymentMethodRepo {
|
|
|
20
20
|
/**
|
|
21
21
|
* オファーコードと提供リソースIDをキーにして冪等置換
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
$set: Pick<IDocType, 'identifier' | '
|
|
23
|
+
addAcceptedPaymentMethodsByIdentifier(params: {
|
|
24
|
+
$set: Pick<IDocType, 'identifier' | 'acceptedPaymentMethod' | 'validFrom' | 'validThrough'> & {
|
|
25
25
|
id?: never;
|
|
26
26
|
};
|
|
27
27
|
$unset: IUnset;
|
|
28
28
|
}[], options: {
|
|
29
29
|
/**
|
|
30
30
|
* falseの場合setOnInsertのみ
|
|
31
|
-
* trueの場合set
|
|
31
|
+
* trueの場合setOnInsert+set
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
upsert: boolean;
|
|
34
|
+
project: factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer['project'];
|
|
35
|
+
seller: factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer['seller'];
|
|
36
|
+
itemOffered: factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer['itemOffered'];
|
|
34
37
|
}): Promise<{
|
|
35
|
-
bulkWriteResult
|
|
36
|
-
|
|
38
|
+
bulkWriteResult?: BulkWriteResult;
|
|
39
|
+
modifiedOffers: {
|
|
37
40
|
id: string;
|
|
38
41
|
}[];
|
|
39
|
-
}
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* 有効期間を過ぎた対応決済方法オファーを削除する
|
|
45
|
+
*/
|
|
46
|
+
deleteAcceptedPaymentMethodsExpired(params: {
|
|
47
|
+
validThrough: {
|
|
48
|
+
$lte: Date;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<DeleteResult>;
|
|
51
|
+
/**
|
|
52
|
+
* 提供リソースから対応決済方法を削除する
|
|
53
|
+
*/
|
|
54
|
+
deleteAcceptedPaymentMethodsByItemOffered(params: {
|
|
55
|
+
project: {
|
|
56
|
+
id: string;
|
|
57
|
+
};
|
|
58
|
+
itemOffered: {
|
|
59
|
+
id: string;
|
|
60
|
+
};
|
|
61
|
+
}): Promise<DeleteResult>;
|
|
62
|
+
/**
|
|
63
|
+
* 販売者の提供するオファーを削除する
|
|
64
|
+
*/
|
|
65
|
+
deleteAcceptedPaymentMethodsBySeller(params: {
|
|
66
|
+
project: {
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
seller: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
}): Promise<DeleteResult>;
|
|
40
73
|
}
|
|
41
74
|
export {};
|
|
@@ -108,14 +108,15 @@ class AcceptedPaymentMethodRepo {
|
|
|
108
108
|
/**
|
|
109
109
|
* オファーコードと提供リソースIDをキーにして冪等置換
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
// tslint:disable-next-line:max-func-body-length
|
|
112
|
+
addAcceptedPaymentMethodsByIdentifier(params, options) {
|
|
112
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const {
|
|
114
|
+
const { upsert, project, seller, itemOffered } = options;
|
|
114
115
|
const bulkWriteOps = [];
|
|
115
116
|
const queryFilters = [];
|
|
116
117
|
if (Array.isArray(params)) {
|
|
117
118
|
params.forEach(({ $set, $unset }) => {
|
|
118
|
-
const { identifier,
|
|
119
|
+
const { identifier, acceptedPaymentMethod, validFrom, validThrough } = $set;
|
|
119
120
|
if (typeof identifier !== 'string' || identifier === '') {
|
|
120
121
|
throw new factory.errors.ArgumentNull('identifier');
|
|
121
122
|
}
|
|
@@ -133,30 +134,27 @@ class AcceptedPaymentMethodRepo {
|
|
|
133
134
|
'itemOffered.id': { $eq: itemOffered.id },
|
|
134
135
|
identifier: { $eq: identifier }
|
|
135
136
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
const setOnInsert = {
|
|
138
|
+
identifier, itemOffered, project, seller,
|
|
139
|
+
typeOf: factory.offerType.Offer
|
|
140
|
+
};
|
|
141
|
+
const setFields = {
|
|
142
|
+
acceptedPaymentMethod,
|
|
143
|
+
validFrom,
|
|
144
|
+
validThrough
|
|
145
|
+
};
|
|
146
|
+
if (upsert) {
|
|
147
|
+
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
143
148
|
const updateOne = {
|
|
144
149
|
filter,
|
|
145
150
|
update: updateFilter,
|
|
146
|
-
upsert:
|
|
151
|
+
upsert: true
|
|
147
152
|
};
|
|
148
153
|
bulkWriteOps.push({ updateOne });
|
|
149
154
|
}
|
|
150
155
|
else {
|
|
151
|
-
const setOnInsert = {
|
|
152
|
-
itemOffered, identifier, project, seller,
|
|
153
|
-
typeOf: factory.offerType.Offer,
|
|
154
|
-
validFrom,
|
|
155
|
-
validThrough,
|
|
156
|
-
acceptedPaymentMethod
|
|
157
|
-
};
|
|
158
156
|
const updateFilter = {
|
|
159
|
-
$setOnInsert: setOnInsert
|
|
157
|
+
$setOnInsert: Object.assign(Object.assign({}, setOnInsert), setFields) // 存在しなければ追加のみ
|
|
160
158
|
};
|
|
161
159
|
const updateOne = {
|
|
162
160
|
filter,
|
|
@@ -169,15 +167,62 @@ class AcceptedPaymentMethodRepo {
|
|
|
169
167
|
}
|
|
170
168
|
if (bulkWriteOps.length > 0) {
|
|
171
169
|
const bulkWriteResult = yield this.acceptedPaymentMethodModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
// upsert:falseの場合、upsertedIdsのみ返せばよい
|
|
171
|
+
if (!upsert) {
|
|
172
|
+
// BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
|
|
173
|
+
return {
|
|
174
|
+
bulkWriteResult,
|
|
175
|
+
modifiedOffers: Object.values(bulkWriteResult.upsertedIds)
|
|
176
|
+
.map((id) => ({ id: String(id) }))
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
181
|
+
const modifiedOffers = yield this.acceptedPaymentMethodModel.find({ $or: queryFilters }, {
|
|
182
|
+
_id: 0,
|
|
183
|
+
id: { $toString: '$_id' }
|
|
184
|
+
})
|
|
185
|
+
.lean()
|
|
186
|
+
.exec();
|
|
187
|
+
return { bulkWriteResult, modifiedOffers };
|
|
188
|
+
}
|
|
180
189
|
}
|
|
190
|
+
return { modifiedOffers: [] };
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 有効期間を過ぎた対応決済方法オファーを削除する
|
|
195
|
+
*/
|
|
196
|
+
deleteAcceptedPaymentMethodsExpired(params) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
return this.acceptedPaymentMethodModel.deleteMany({
|
|
199
|
+
validThrough: { $lte: params.validThrough.$lte }
|
|
200
|
+
})
|
|
201
|
+
.exec();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 提供リソースから対応決済方法を削除する
|
|
206
|
+
*/
|
|
207
|
+
deleteAcceptedPaymentMethodsByItemOffered(params) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
return this.acceptedPaymentMethodModel.deleteMany({
|
|
210
|
+
'project.id': { $eq: params.project.id },
|
|
211
|
+
'itemOffered.id': { $eq: params.itemOffered.id }
|
|
212
|
+
})
|
|
213
|
+
.exec();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 販売者の提供するオファーを削除する
|
|
218
|
+
*/
|
|
219
|
+
deleteAcceptedPaymentMethodsBySeller(params) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
return this.acceptedPaymentMethodModel.deleteMany({
|
|
222
|
+
'project.id': { $eq: params.project.id },
|
|
223
|
+
'seller.id': { $eq: params.seller.id }
|
|
224
|
+
})
|
|
225
|
+
.exec();
|
|
181
226
|
});
|
|
182
227
|
}
|
|
183
228
|
}
|
|
@@ -74,7 +74,12 @@ export declare class AggregateOfferRepo {
|
|
|
74
74
|
/**
|
|
75
75
|
* コードをキーにして冪等置換(2023-12-13~)
|
|
76
76
|
*/
|
|
77
|
-
upsertByIdentifier(params: Omit<factory.unitPriceOffer.IUnitPriceOffer, 'id'>[]
|
|
77
|
+
upsertByIdentifier(params: Omit<factory.unitPriceOffer.IUnitPriceOffer, 'id'>[], options: {
|
|
78
|
+
/**
|
|
79
|
+
* プロダクトタイプでfilter(2026-01-30~)
|
|
80
|
+
*/
|
|
81
|
+
productType: factory.product.ProductType;
|
|
82
|
+
}): Promise<{
|
|
78
83
|
bulkWriteResult: BulkWriteResult;
|
|
79
84
|
modifiedOffers: {
|
|
80
85
|
id: string;
|
|
@@ -648,22 +648,30 @@ class AggregateOfferRepo {
|
|
|
648
648
|
/**
|
|
649
649
|
* コードをキーにして冪等置換(2023-12-13~)
|
|
650
650
|
*/
|
|
651
|
-
upsertByIdentifier(params) {
|
|
651
|
+
upsertByIdentifier(params, options) {
|
|
652
652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
+
const { productType } = options;
|
|
653
654
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
654
655
|
const insertBulkWriteOps = [];
|
|
655
656
|
// const updateBulkWriteOps: AnyBulkWriteOperation<factory.aggregateOffer.IAggregateOffer>[] = [];
|
|
656
657
|
const queryFilters = [];
|
|
657
658
|
if (Array.isArray(params)) {
|
|
658
659
|
params.forEach((p) => {
|
|
660
|
+
var _a;
|
|
661
|
+
// 指定されたproductTypeを強制する
|
|
662
|
+
if (((_a = p.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) !== productType) {
|
|
663
|
+
throw new factory.errors.Argument('itemOffered.typeOf', `not matched with productType: ${productType}`);
|
|
664
|
+
}
|
|
659
665
|
// リソースのユニークネスを保証するfilter
|
|
660
666
|
const filter = {
|
|
661
667
|
'project.id': { $eq: p.project.id },
|
|
662
|
-
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
668
|
+
'offers.identifier': { $exists: true, $eq: p.identifier },
|
|
669
|
+
'offers.itemOffered.typeOf': { $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
663
670
|
};
|
|
664
671
|
queryFilters.push({
|
|
665
672
|
'project.id': { $eq: p.project.id },
|
|
666
|
-
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
673
|
+
'offers.identifier': { $exists: true, $eq: p.identifier },
|
|
674
|
+
'offers.itemOffered.typeOf': { $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
667
675
|
});
|
|
668
676
|
const newOfferId = uniqid(); // setOnInsert時のみに利用する新ID
|
|
669
677
|
// サブオファー最適化(2023-12-22~)
|
|
@@ -20,99 +20,6 @@ class AggregateOrderRepo {
|
|
|
20
20
|
constructor(connection) {
|
|
21
21
|
this.aggregateOrderModel = connection.model(aggregateOrder_1.modelName, (0, aggregateOrder_1.createSchema)());
|
|
22
22
|
}
|
|
23
|
-
// public static CREATE_MONGO_CONDITIONS(
|
|
24
|
-
// conditions: ISearchConditions
|
|
25
|
-
// ): IMatchStage[] {
|
|
26
|
-
// const matchStages: IMatchStage[] = [];
|
|
27
|
-
// const projectIdEq = conditions.project?.id?.$eq;
|
|
28
|
-
// if (typeof projectIdEq === 'string') {
|
|
29
|
-
// matchStages.push({
|
|
30
|
-
// $match: { 'project.id': { $eq: projectIdEq } }
|
|
31
|
-
// });
|
|
32
|
-
// }
|
|
33
|
-
// const typeOfEq = conditions.reservationFor?.typeOf;
|
|
34
|
-
// if (typeof typeOfEq === 'string') {
|
|
35
|
-
// matchStages.push({
|
|
36
|
-
// $match: { 'reservationFor.typeOf': { $eq: typeOfEq } }
|
|
37
|
-
// });
|
|
38
|
-
// }
|
|
39
|
-
// const idEq = conditions.reservationFor?.id?.$eq;
|
|
40
|
-
// if (typeof idEq === 'string') {
|
|
41
|
-
// matchStages.push({
|
|
42
|
-
// $match: { 'reservationFor.id': { $eq: idEq } }
|
|
43
|
-
// });
|
|
44
|
-
// }
|
|
45
|
-
// const idIn = conditions.reservationFor?.id?.$in;
|
|
46
|
-
// if (Array.isArray(idIn)) {
|
|
47
|
-
// matchStages.push({
|
|
48
|
-
// $match: { 'reservationFor.id': { $in: idIn } }
|
|
49
|
-
// });
|
|
50
|
-
// }
|
|
51
|
-
// const reservationForStartDateGte = conditions.reservationFor?.startFrom;
|
|
52
|
-
// if (reservationForStartDateGte instanceof Date) {
|
|
53
|
-
// matchStages.push({
|
|
54
|
-
// $match: { 'reservationFor.startDate': { $gte: reservationForStartDateGte } }
|
|
55
|
-
// });
|
|
56
|
-
// }
|
|
57
|
-
// const reservationForStartDateLte = conditions.reservationFor?.startThrough;
|
|
58
|
-
// if (reservationForStartDateLte instanceof Date) {
|
|
59
|
-
// matchStages.push({
|
|
60
|
-
// $match: { 'reservationFor.startDate': { $lte: reservationForStartDateLte } }
|
|
61
|
-
// });
|
|
62
|
-
// }
|
|
63
|
-
// return matchStages;
|
|
64
|
-
// }
|
|
65
|
-
// /**
|
|
66
|
-
// * 予約集計を検索する
|
|
67
|
-
// */
|
|
68
|
-
// public async searchWithReservationForId(
|
|
69
|
-
// params: ISearchConditions,
|
|
70
|
-
// inclusion: ('aggregateOffer')[]
|
|
71
|
-
// ): Promise<ISearchWithReservationForIdResult[]> {
|
|
72
|
-
// const matchStages = AggregateReservationRepo.CREATE_MONGO_CONDITIONS(params);
|
|
73
|
-
// let projectStage: { [field in IKeyOfProjection]?: AnyExpression } = {
|
|
74
|
-
// _id: 0,
|
|
75
|
-
// id: '$reservationFor.id'
|
|
76
|
-
// };
|
|
77
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
78
|
-
// inclusion.forEach((field) => {
|
|
79
|
-
// projectStage[field] = { $ifNull: [`$${field}`, '$false'] };
|
|
80
|
-
// // projectStage[field] = 1;
|
|
81
|
-
// });
|
|
82
|
-
// } else {
|
|
83
|
-
// projectStage = {
|
|
84
|
-
// _id: 0,
|
|
85
|
-
// id: '$reservationFor.id',
|
|
86
|
-
// // aggregateEntranceGate: 1, // discontinue(2024-12-23~)
|
|
87
|
-
// aggregateOffer: 1
|
|
88
|
-
// };
|
|
89
|
-
// }
|
|
90
|
-
// const sortByStartDate = params.sort?.['reservationFor.startDate'];
|
|
91
|
-
// const aggregate = this.aggregateReservationModel.aggregate<ISearchWithReservationForIdResult>([
|
|
92
|
-
// ...matchStages,
|
|
93
|
-
// ...(typeof sortByStartDate === 'number')
|
|
94
|
-
// ? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
|
|
95
|
-
// : [],
|
|
96
|
-
// // 現時点でreservationFor.idへのunique indexがないので、重複ドキュメント対応として、$group
|
|
97
|
-
// {
|
|
98
|
-
// $group: {
|
|
99
|
-
// _id: '$reservationFor.id',
|
|
100
|
-
// reservationFor: { $first: '$reservationFor' },
|
|
101
|
-
// aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
|
|
102
|
-
// aggregateOffer: { $first: '$aggregateOffer' }
|
|
103
|
-
// }
|
|
104
|
-
// },
|
|
105
|
-
// { $project: projectStage }
|
|
106
|
-
// ]);
|
|
107
|
-
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
108
|
-
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
109
|
-
// aggregate.limit(params.limit * page)
|
|
110
|
-
// .skip(params.limit * (page - 1));
|
|
111
|
-
// }
|
|
112
|
-
// return aggregate
|
|
113
|
-
// .option({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
114
|
-
// .exec();
|
|
115
|
-
// }
|
|
116
23
|
save(filter, update) {
|
|
117
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
25
|
const { $set } = update;
|
|
@@ -5,7 +5,6 @@ type IMatchStage = PipelineStage.Match;
|
|
|
5
5
|
export interface IUpdateAggregateReservationParams {
|
|
6
6
|
$set: {
|
|
7
7
|
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
8
|
-
aggregateEntranceGate?: factory.event.screeningEvent.IAggregateEntranceGate;
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
10
|
type ISearchWithReservationForIdResult = Pick<IAggregateReservation, 'aggregateOffer'> & {
|
|
@@ -82,7 +82,6 @@ class AggregateReservationRepo {
|
|
|
82
82
|
projectStage = {
|
|
83
83
|
_id: 0,
|
|
84
84
|
id: '$reservationFor.id',
|
|
85
|
-
// aggregateEntranceGate: 1, // discontinue(2024-12-23~)
|
|
86
85
|
aggregateOffer: 1
|
|
87
86
|
};
|
|
88
87
|
}
|
|
@@ -97,7 +96,6 @@ class AggregateReservationRepo {
|
|
|
97
96
|
$group: {
|
|
98
97
|
_id: '$reservationFor.id',
|
|
99
98
|
reservationFor: { $first: '$reservationFor' },
|
|
100
|
-
aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
|
|
101
99
|
aggregateOffer: { $first: '$aggregateOffer' }
|
|
102
100
|
}
|
|
103
101
|
},
|