@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.61
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/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 -18
- package/lib/chevre/repo/event.js +94 -83
- package/lib/chevre/repo/eventOffer.d.ts +8 -0
- package/lib/chevre/repo/eventOffer.js +11 -0
- package/lib/chevre/repo/eventSeries.d.ts +17 -30
- package/lib/chevre/repo/eventSeries.js +204 -146
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +20 -5
- 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 +6 -0
- package/lib/chevre/repo/orderNumber.js +110 -35
- 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/fixInformAction.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/fixInformAction.js +3 -0
- package/lib/chevre/service/assetTransaction/pay/cancel.d.ts +12 -0
- package/lib/chevre/service/assetTransaction/pay/cancel.js +25 -0
- package/lib/chevre/service/assetTransaction/pay/check.d.ts +23 -0
- package/lib/chevre/service/assetTransaction/pay/check.js +37 -0
- package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +24 -0
- package/lib/chevre/service/assetTransaction/pay/confirm.js +72 -0
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.d.ts +18 -0
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +111 -0
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +48 -0
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +164 -0
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +20 -0
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +59 -0
- package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/{factory.d.ts → start/factory.d.ts} +1 -1
- package/lib/chevre/service/assetTransaction/pay/{factory.js → start/factory.js} +1 -1
- package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.d.ts → start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts} +4 -4
- package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.js → start/preStart/validateAcceptedPaymentMethodIfNeeded.js} +1 -4
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +8 -0
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +54 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +13 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +49 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +29 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +37 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +42 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +31 -0
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +60 -0
- package/lib/chevre/service/assetTransaction/pay/start.js +145 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +8 -170
- package/lib/chevre/service/assetTransaction/pay.js +16 -623
- 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/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 +9 -9
- 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/createEvent/createEvent.d.ts +0 -25
- package/lib/chevre/service/task/createEvent/createEvent.js +0 -45
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +0 -22
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +0 -188
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +0 -15
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +0 -116
- package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +0 -25
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +0 -107
- package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +0 -13
- package/lib/chevre/service/task/createEvent/createEventSeries.js +0 -118
- package/lib/chevre/service/task/createEvent.d.ts +0 -6
- package/lib/chevre/service/task/createEvent.js +0 -46
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
|
@@ -10,60 +10,75 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ServiceOutputIdentifierRepo = void 0;
|
|
13
|
-
|
|
13
|
+
// import * as cdigit from 'cdigit';
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
-
// import { RedisClientType } from 'redis';
|
|
16
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
17
|
-
const fpe = require('node-fpe');
|
|
18
|
-
|
|
19
|
-
const transactionNumber_1 = require("
|
|
16
|
+
// const fpe = require('node-fpe-v1');
|
|
17
|
+
const factory = require("../factory");
|
|
18
|
+
const transactionNumber_1 = require("../factory/transactionNumber");
|
|
19
|
+
const setting_1 = require("./mongoose/schemas/setting");
|
|
20
|
+
const transactionNumber_2 = require("./mongoose/schemas/transactionNumber");
|
|
20
21
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
21
22
|
/**
|
|
22
23
|
* サービスアウトプット識別子リポジトリ
|
|
23
24
|
*/
|
|
24
25
|
class ServiceOutputIdentifierRepo {
|
|
25
26
|
constructor(params) {
|
|
26
|
-
// const { connection } = params;
|
|
27
|
-
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
28
27
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
28
|
+
this.settingModel = params.connection.model(setting_1.modelName, (0, setting_1.createSchema)());
|
|
29
29
|
}
|
|
30
|
-
// private static createKey(params: {
|
|
31
|
-
// startDate: Date;
|
|
32
|
-
// timestamp: string;
|
|
33
|
-
// }): string {
|
|
34
|
-
// return util.format(
|
|
35
|
-
// '%s:%s',
|
|
36
|
-
// ServiceOutputIdentifierRepo.REDIS_KEY_PREFIX,
|
|
37
|
-
// params.timestamp
|
|
38
|
-
// );
|
|
39
|
-
// }
|
|
40
30
|
/**
|
|
41
31
|
* タイムスタンプから発行する
|
|
42
32
|
*/
|
|
43
|
-
|
|
33
|
+
issueServiceOutputIdentifier(params) {
|
|
44
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const { fpeSecret, version } = yield this.findSetting();
|
|
45
36
|
const timestamp = moment(params.startDate)
|
|
46
37
|
.valueOf()
|
|
47
38
|
.toString();
|
|
48
39
|
let dataFeedExpires;
|
|
49
40
|
const dataFeedIdentifier = timestamp;
|
|
50
41
|
let incrReply;
|
|
51
|
-
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
52
42
|
dataFeedExpires = moment(params.startDate)
|
|
53
43
|
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
54
44
|
.toDate();
|
|
55
45
|
incrReply = yield this.counterRepo.incrementByMongo({
|
|
56
46
|
identifier: dataFeedIdentifier,
|
|
57
|
-
includedInDataCatalog: { identifier:
|
|
47
|
+
includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.serviceOutputIdentifier },
|
|
58
48
|
expires: dataFeedExpires
|
|
59
49
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
identifier =
|
|
66
|
-
|
|
50
|
+
const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
|
|
51
|
+
return transactionFactory.generate(timestamp, incrReply);
|
|
52
|
+
// let identifier: string = `${timestamp}${incrReply}`;
|
|
53
|
+
// // checkdigit
|
|
54
|
+
// const cd = cdigit.luhn.compute(identifier);
|
|
55
|
+
// identifier = fpe({ password: cd })
|
|
56
|
+
// .encrypt(identifier);
|
|
57
|
+
// identifier = `${cd}${identifier}`;
|
|
58
|
+
// return identifier;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
findSetting() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const filterQuery = { 'project.id': { $eq: '*' } };
|
|
64
|
+
const projection = {
|
|
65
|
+
_id: 0,
|
|
66
|
+
serviceOutputIdentifier: 1
|
|
67
|
+
};
|
|
68
|
+
const setting = yield this.settingModel.findOne(filterQuery, projection)
|
|
69
|
+
.lean()
|
|
70
|
+
.exec();
|
|
71
|
+
if (setting === null || setting.serviceOutputIdentifier === undefined) {
|
|
72
|
+
throw new factory.errors.NotFound('setting.serviceOutputIdentifier');
|
|
73
|
+
}
|
|
74
|
+
const { fpeSecret, version } = setting.serviceOutputIdentifier;
|
|
75
|
+
if (typeof fpeSecret !== 'string' || fpeSecret === '') {
|
|
76
|
+
throw new factory.errors.NotFound('setting.serviceOutputIdentifier.secret');
|
|
77
|
+
}
|
|
78
|
+
if (typeof version !== 'string' || version === '') {
|
|
79
|
+
throw new factory.errors.NotFound('setting.serviceOutputIdentifier.version');
|
|
80
|
+
}
|
|
81
|
+
return { fpeSecret, version };
|
|
67
82
|
});
|
|
68
83
|
}
|
|
69
84
|
}
|
|
@@ -22,7 +22,7 @@ export declare class SettingRepo {
|
|
|
22
22
|
$eq: string;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onTaskStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota' | 'triggerWebhook' | 'waiter'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
25
|
+
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onTaskStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota' | 'triggerWebhook' | 'waiter' | 'orderNumber' | 'transactionNumber'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
26
26
|
unsetUnnecessaryFields(params: {
|
|
27
27
|
filter: FilterQuery<ISetting>;
|
|
28
28
|
$unset: any;
|
|
@@ -49,9 +49,9 @@ class SettingRepo {
|
|
|
49
49
|
}
|
|
50
50
|
updateByProject(filter, update) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { onEventChanged, onReservationStatusChanged, onTaskStatusChanged, onResourceUpdated, defaultSenderEmail, useInformResourceTypes, userPoolIdNew, userPoolIdOld, storage, quota, triggerWebhook, waiter } = update;
|
|
52
|
+
const { onEventChanged, onReservationStatusChanged, onTaskStatusChanged, onResourceUpdated, defaultSenderEmail, useInformResourceTypes, userPoolIdNew, userPoolIdOld, storage, quota, triggerWebhook, waiter, orderNumber, transactionNumber } = update;
|
|
53
53
|
return this.settingModel.updateOne({ 'project.id': { $eq: filter.project.id.$eq } }, {
|
|
54
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (onEventChanged !== undefined) ? { onEventChanged } : undefined), (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onTaskStatusChanged !== undefined) ? { onTaskStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined), (defaultSenderEmail !== undefined) ? { defaultSenderEmail } : undefined), (useInformResourceTypes !== undefined) ? { useInformResourceTypes } : undefined), (userPoolIdNew !== undefined) ? { userPoolIdNew } : undefined), (userPoolIdOld !== undefined) ? { userPoolIdOld } : undefined), (storage !== undefined) ? { storage } : undefined), (quota !== undefined) ? { quota } : undefined), (triggerWebhook !== undefined) ? { triggerWebhook } : undefined), (waiter !== undefined) ? { waiter } : undefined)
|
|
54
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (onEventChanged !== undefined) ? { onEventChanged } : undefined), (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onTaskStatusChanged !== undefined) ? { onTaskStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined), (defaultSenderEmail !== undefined) ? { defaultSenderEmail } : undefined), (useInformResourceTypes !== undefined) ? { useInformResourceTypes } : undefined), (userPoolIdNew !== undefined) ? { userPoolIdNew } : undefined), (userPoolIdOld !== undefined) ? { userPoolIdOld } : undefined), (storage !== undefined) ? { storage } : undefined), (quota !== undefined) ? { quota } : undefined), (triggerWebhook !== undefined) ? { triggerWebhook } : undefined), (waiter !== undefined) ? { waiter } : undefined), (orderNumber !== undefined) ? { orderNumber } : undefined), (transactionNumber !== undefined) ? { transactionNumber } : undefined)
|
|
55
55
|
})
|
|
56
56
|
.exec();
|
|
57
57
|
});
|
|
@@ -34,7 +34,7 @@ type ICreatingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | '
|
|
|
34
34
|
export declare class TaskRepo {
|
|
35
35
|
readonly taskModel: IModel;
|
|
36
36
|
constructor(connection: Connection);
|
|
37
|
-
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createAccountingReport").ITask | import("@chevre/factory/lib/task/
|
|
37
|
+
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createAccountingReport").ITask | import("@chevre/factory/lib/task/deletePerson").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceDeleted").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask>[];
|
|
38
38
|
runImmediately(params: Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'expires' | 'name' | 'project' | 'remainingNumberOfTries' | 'runsAt'> & {
|
|
39
39
|
alternateName?: never;
|
|
40
40
|
identifier?: never;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
interface IPublishResult {
|
|
3
3
|
transactionNumber: string;
|
|
4
|
+
timestamp: string;
|
|
5
|
+
incrReply: number;
|
|
4
6
|
}
|
|
5
7
|
/**
|
|
6
8
|
* 取引番号リポジトリ
|
|
7
9
|
*/
|
|
8
10
|
export declare class TransactionNumberRepo {
|
|
9
11
|
private readonly counterRepo;
|
|
12
|
+
private readonly settingModel;
|
|
10
13
|
constructor(params: {
|
|
11
14
|
connection: Connection;
|
|
12
15
|
});
|
|
@@ -16,5 +19,7 @@ export declare class TransactionNumberRepo {
|
|
|
16
19
|
publishByTimestamp(params: {
|
|
17
20
|
startDate: Date;
|
|
18
21
|
}): Promise<IPublishResult>;
|
|
22
|
+
decrypt(id: string): Promise<string>;
|
|
23
|
+
private findSetting;
|
|
19
24
|
}
|
|
20
25
|
export {};
|
|
@@ -10,60 +10,96 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TransactionNumberRepo = void 0;
|
|
13
|
-
const cdigit = require("cdigit");
|
|
14
13
|
const moment = require("moment-timezone");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const transactionNumber_1 = require("../factory/transactionNumber");
|
|
16
|
+
const setting_1 = require("./mongoose/schemas/setting");
|
|
17
|
+
const transactionNumber_2 = require("./mongoose/schemas/transactionNumber");
|
|
20
18
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
21
19
|
/**
|
|
22
20
|
* 取引番号リポジトリ
|
|
23
21
|
*/
|
|
24
22
|
class TransactionNumberRepo {
|
|
25
23
|
constructor(params) {
|
|
26
|
-
// const { connection } = params;
|
|
27
|
-
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
28
24
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
25
|
+
this.settingModel = params.connection.model(setting_1.modelName, (0, setting_1.createSchema)());
|
|
29
26
|
}
|
|
30
|
-
// private static createKey(params: {
|
|
31
|
-
// startDate: Date;
|
|
32
|
-
// timestamp: string;
|
|
33
|
-
// }): string {
|
|
34
|
-
// return util.format(
|
|
35
|
-
// '%s:%s',
|
|
36
|
-
// TransactionNumberRepo.REDIS_KEY_PREFIX,
|
|
37
|
-
// params.timestamp
|
|
38
|
-
// );
|
|
39
|
-
// }
|
|
40
27
|
/**
|
|
41
28
|
* タイムスタンプから発行する
|
|
42
29
|
*/
|
|
43
30
|
publishByTimestamp(params) {
|
|
44
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { fpeSecret, version, validFrom } = yield this.findSetting();
|
|
45
33
|
const timestamp = moment(params.startDate)
|
|
46
34
|
.valueOf()
|
|
47
35
|
.toString();
|
|
48
36
|
let dataFeedExpires;
|
|
49
37
|
const dataFeedIdentifier = timestamp;
|
|
50
38
|
let incrReply;
|
|
51
|
-
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
52
39
|
dataFeedExpires = moment(params.startDate)
|
|
53
40
|
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
54
41
|
.toDate();
|
|
55
42
|
incrReply = yield this.counterRepo.incrementByMongo({
|
|
56
43
|
identifier: dataFeedIdentifier,
|
|
57
|
-
includedInDataCatalog: { identifier:
|
|
44
|
+
includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.transactionNumber },
|
|
58
45
|
expires: dataFeedExpires
|
|
59
46
|
});
|
|
60
|
-
let transactionNumber
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
let transactionNumber;
|
|
48
|
+
const useVersioning = validFrom instanceof Date && moment(validFrom)
|
|
49
|
+
.isSameOrBefore(params.startDate);
|
|
50
|
+
if (typeof fpeSecret === 'string' && typeof version === 'string' && useVersioning) {
|
|
51
|
+
const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
|
|
52
|
+
transactionNumber = transactionFactory.generate(timestamp, incrReply);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// discontinue version0(2026-02-10~)
|
|
56
|
+
throw new factory.errors.NotImplemented('transactionNumber with no version discontinued');
|
|
57
|
+
// transactionNumber = `${timestamp}${incrReply}`;
|
|
58
|
+
// // checkdigit
|
|
59
|
+
// const cd = cdigit.luhn.compute(transactionNumber);
|
|
60
|
+
// transactionNumber = fpe1({ password: cd })
|
|
61
|
+
// .encrypt(transactionNumber);
|
|
62
|
+
// transactionNumber = `${cd}${transactionNumber}`;
|
|
63
|
+
}
|
|
64
|
+
return { transactionNumber, timestamp, incrReply };
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
decrypt(id) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const { fpeSecret, version } = yield this.findSetting();
|
|
70
|
+
if (typeof fpeSecret === 'string' && typeof version === 'string') {
|
|
71
|
+
const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
|
|
72
|
+
return transactionFactory.decrypt(id);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new factory.errors.NotImplemented('no version not implemented');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
findSetting() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const filterQuery = { 'project.id': { $eq: '*' } };
|
|
82
|
+
const projection = {
|
|
83
|
+
_id: 0,
|
|
84
|
+
transactionNumber: 1
|
|
85
|
+
};
|
|
86
|
+
const setting = yield this.settingModel.findOne(filterQuery, projection)
|
|
87
|
+
.lean()
|
|
88
|
+
.exec();
|
|
89
|
+
if (setting === null || setting.transactionNumber === undefined) {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
const { fpeSecret, version, validFrom } = setting.transactionNumber;
|
|
93
|
+
if (typeof fpeSecret !== 'string' || fpeSecret === '') {
|
|
94
|
+
throw new factory.errors.NotFound('setting.transactionNumber.secret');
|
|
95
|
+
}
|
|
96
|
+
if (typeof version !== 'string' || version === '') {
|
|
97
|
+
throw new factory.errors.NotFound('setting.transactionNumber.version');
|
|
98
|
+
}
|
|
99
|
+
if (!(validFrom instanceof Date)) {
|
|
100
|
+
throw new factory.errors.NotFound('setting.transactionNumber.validFrom must be Date');
|
|
101
|
+
}
|
|
102
|
+
return { fpeSecret, version, validFrom };
|
|
67
103
|
});
|
|
68
104
|
}
|
|
69
105
|
}
|
|
@@ -51,6 +51,7 @@ import type { PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
|
|
|
51
51
|
import type { PendingReservationRepo } from './repo/pendingReservation';
|
|
52
52
|
import type { PermitRepo } from './repo/permit';
|
|
53
53
|
import type { BusStopRepo } from './repo/place/busStop';
|
|
54
|
+
import type { EntranceGateRepo } from './repo/place/entranceGate';
|
|
54
55
|
import type { HasPOSRepo } from './repo/place/hasPOS';
|
|
55
56
|
import type { MovieTheaterRepo } from './repo/place/movieTheater';
|
|
56
57
|
import type { ScreeningRoomRepo } from './repo/place/screeningRoom';
|
|
@@ -316,6 +317,13 @@ export declare namespace place {
|
|
|
316
317
|
namespace BusStop {
|
|
317
318
|
function createInstance(...params: ConstructorParameters<typeof BusStopRepo>): Promise<BusStopRepo>;
|
|
318
319
|
}
|
|
320
|
+
type EntranceGate = EntranceGateRepo;
|
|
321
|
+
/**
|
|
322
|
+
* 施設の入場ゲートリポジトリ
|
|
323
|
+
*/
|
|
324
|
+
namespace EntranceGate {
|
|
325
|
+
function createInstance(...params: ConstructorParameters<typeof EntranceGateRepo>): Promise<EntranceGateRepo>;
|
|
326
|
+
}
|
|
319
327
|
type HasPOS = HasPOSRepo;
|
|
320
328
|
/**
|
|
321
329
|
* 施設PointOfSalesリポジトリ
|
package/lib/chevre/repository.js
CHANGED
|
@@ -721,6 +721,22 @@ var place;
|
|
|
721
721
|
}
|
|
722
722
|
BusStop.createInstance = createInstance;
|
|
723
723
|
})(BusStop = place.BusStop || (place.BusStop = {}));
|
|
724
|
+
/**
|
|
725
|
+
* 施設の入場ゲートリポジトリ
|
|
726
|
+
*/
|
|
727
|
+
let EntranceGate;
|
|
728
|
+
(function (EntranceGate) {
|
|
729
|
+
let repo;
|
|
730
|
+
function createInstance(...params) {
|
|
731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
if (repo === undefined) {
|
|
733
|
+
repo = (yield Promise.resolve().then(() => require('./repo/place/entranceGate'))).EntranceGateRepo;
|
|
734
|
+
}
|
|
735
|
+
return new repo(...params);
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
EntranceGate.createInstance = createInstance;
|
|
739
|
+
})(EntranceGate = place.EntranceGate || (place.EntranceGate = {}));
|
|
724
740
|
/**
|
|
725
741
|
* 施設PointOfSalesリポジトリ
|
|
726
742
|
*/
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import type { PotentialActionRepo } from '../../repo/potentialAction';
|
|
3
|
+
/**
|
|
4
|
+
* 決済取引あるいは返金取引の通知アクションを決定する
|
|
5
|
+
*/
|
|
3
6
|
declare function fixInformAction(params: {
|
|
4
7
|
paymentService?: Pick<factory.product.IProduct, 'availableChannel' | 'potentialAction'> | Pick<factory.service.paymentService.IService, 'availableChannel' | 'potentialAction'>;
|
|
5
8
|
project: {
|
|
@@ -11,6 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fixInformAction = fixInformAction;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 決済取引あるいは返金取引の通知アクションを決定する
|
|
16
|
+
*/
|
|
14
17
|
function fixInformAction(params) {
|
|
15
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
19
|
var _a, _b;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
2
|
+
export interface ICancelRepos {
|
|
3
|
+
assetTransaction: AssetTransactionRepo;
|
|
4
|
+
}
|
|
5
|
+
export type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
|
|
6
|
+
/**
|
|
7
|
+
* 取引中止
|
|
8
|
+
*/
|
|
9
|
+
export declare function cancel(params: {
|
|
10
|
+
id?: string;
|
|
11
|
+
transactionNumber?: string;
|
|
12
|
+
}): ICancelOperation<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.cancel = cancel;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 取引中止
|
|
16
|
+
*/
|
|
17
|
+
function cancel(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
yield repos.assetTransaction.cancel({
|
|
20
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
21
|
+
id: params.id,
|
|
22
|
+
transactionNumber: params.transactionNumber
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import { Settings } from '../../../settings';
|
|
3
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
4
|
+
import type { CredentialsRepo } from '../../../repo/credentials';
|
|
5
|
+
import type { EventRepo } from '../../../repo/event';
|
|
6
|
+
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
7
|
+
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
8
|
+
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
9
|
+
import * as MovieTicketPayment from '../../payment/movieTicket';
|
|
10
|
+
export type ICheckOperation<T> = (repos: {
|
|
11
|
+
action: ActionRepo;
|
|
12
|
+
credentials: CredentialsRepo;
|
|
13
|
+
event: EventRepo;
|
|
14
|
+
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
15
|
+
paymentService: PaymentServiceRepo;
|
|
16
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
17
|
+
}, settings: Settings) => Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* 決済方法認証
|
|
20
|
+
*/
|
|
21
|
+
export declare function check(params: factory.action.check.paymentMethod.movieTicket.IAttributes): ICheckOperation<{
|
|
22
|
+
result: MovieTicketPayment.ICheckResult;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
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.check = check;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const MovieTicketPayment = require("../../payment/movieTicket");
|
|
15
|
+
/**
|
|
16
|
+
* 決済方法認証
|
|
17
|
+
*/
|
|
18
|
+
function check(params) {
|
|
19
|
+
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a;
|
|
21
|
+
let action;
|
|
22
|
+
const paymentServiceType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
23
|
+
try {
|
|
24
|
+
switch (paymentServiceType) {
|
|
25
|
+
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
26
|
+
action = yield MovieTicketPayment.checkMovieTicket(params)(repos, settings);
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
return action;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
3
|
+
import type { AccountingReportRepo } from '../../../repo/accountingReport';
|
|
4
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
5
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
6
|
+
import type { EventRepo } from '../../../repo/event';
|
|
7
|
+
import type { OrderRepo } from '../../../repo/order';
|
|
8
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
9
|
+
export interface IConfirmRepos {
|
|
10
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
11
|
+
action: ActionRepo;
|
|
12
|
+
accountingReport: AccountingReportRepo;
|
|
13
|
+
assetTransaction: AssetTransactionRepo;
|
|
14
|
+
event: EventRepo;
|
|
15
|
+
order: OrderRepo;
|
|
16
|
+
task: TaskRepo;
|
|
17
|
+
}
|
|
18
|
+
export type IConfirmOperation<T> = (repos: IConfirmRepos) => Promise<T>;
|
|
19
|
+
/**
|
|
20
|
+
* 取引確定
|
|
21
|
+
*/
|
|
22
|
+
export declare function confirm(params: factory.assetTransaction.pay.IConfirmParams & {
|
|
23
|
+
options: {};
|
|
24
|
+
}): IConfirmOperation<void>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.confirm = confirm;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 取引確定
|
|
16
|
+
*/
|
|
17
|
+
function confirm(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
|
+
let transaction;
|
|
21
|
+
// 取引存在確認
|
|
22
|
+
if (typeof params.id === 'string') {
|
|
23
|
+
transaction = yield repos.assetTransaction.findById({
|
|
24
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
25
|
+
id: params.id
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else if (typeof params.transactionNumber === 'string') {
|
|
29
|
+
transaction = yield repos.assetTransaction.findByTransactionNumber({
|
|
30
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
31
|
+
transactionNumber: params.transactionNumber
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
36
|
+
}
|
|
37
|
+
let overwritingPaymentMethodIdentifier;
|
|
38
|
+
if (transaction.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
39
|
+
const specifiedPaymentMethodIdentifire = (_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
40
|
+
if (typeof specifiedPaymentMethodIdentifire === 'string' && specifiedPaymentMethodIdentifire.length > 0) {
|
|
41
|
+
overwritingPaymentMethodIdentifier = specifiedPaymentMethodIdentifire;
|
|
42
|
+
transaction.object.paymentMethod.identifier = overwritingPaymentMethodIdentifier;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const confirmationNumber = (_e = (_d = (_c = params.potentialActions) === null || _c === void 0 ? void 0 : _c.pay) === null || _d === void 0 ? void 0 : _d.purpose) === null || _e === void 0 ? void 0 : _e.confirmationNumber;
|
|
46
|
+
const orderNumber = (_h = (_g = (_f = params.potentialActions) === null || _f === void 0 ? void 0 : _f.pay) === null || _g === void 0 ? void 0 : _g.purpose) === null || _h === void 0 ? void 0 : _h.orderNumber;
|
|
47
|
+
if (typeof confirmationNumber !== 'string' || confirmationNumber.length === 0
|
|
48
|
+
|| typeof orderNumber !== 'string' || orderNumber.length === 0) {
|
|
49
|
+
throw new factory.errors.ArgumentNull('potentialActions.pay.purpose');
|
|
50
|
+
}
|
|
51
|
+
let potentialActions;
|
|
52
|
+
// 注文検証
|
|
53
|
+
const existingOrders = yield repos.order.projectFields({
|
|
54
|
+
limit: 1,
|
|
55
|
+
page: 1,
|
|
56
|
+
project: { id: { $eq: transaction.project.id } },
|
|
57
|
+
confirmationNumbers: [confirmationNumber],
|
|
58
|
+
orderNumbers: [orderNumber]
|
|
59
|
+
}, { inclusion: ['orderNumber'] });
|
|
60
|
+
if (existingOrders.length === 0) {
|
|
61
|
+
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
62
|
+
}
|
|
63
|
+
const payActionData4order = {
|
|
64
|
+
object: { paymentMethod: { paymentMethodId: transaction.transactionNumber } },
|
|
65
|
+
purpose: { confirmationNumber, orderNumber, typeOf: factory.order.OrderType.Order }
|
|
66
|
+
};
|
|
67
|
+
potentialActions = { pay: [payActionData4order] };
|
|
68
|
+
yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Pay, id: transaction.id, result: {}, potentialActions: potentialActions }, (typeof overwritingPaymentMethodIdentifier === 'string')
|
|
69
|
+
? { object: { paymentMethod: { identifier: overwritingPaymentMethodIdentifier } } }
|
|
70
|
+
: undefined));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
2
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
3
|
+
export type IExportTasksOperation<T> = (repos: {
|
|
4
|
+
task: TaskRepo;
|
|
5
|
+
assetTransaction: AssetTransactionRepo;
|
|
6
|
+
}) => Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* 取引のタスク出力
|
|
9
|
+
*/
|
|
10
|
+
export declare function exportTasksById(params: {
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* タスク実行日時バッファ
|
|
14
|
+
*/
|
|
15
|
+
runsTasksAfterInSeconds?: number;
|
|
16
|
+
}): IExportTasksOperation<{
|
|
17
|
+
id: string;
|
|
18
|
+
}[]>;
|