@chevre/domain 21.37.0-alpha.8 → 21.37.0
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/processOrder.ts +87 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +17 -143
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
- package/lib/chevre/factory/transaction.d.ts +1 -4
- package/lib/chevre/repo/passport.d.ts +39 -0
- package/lib/chevre/repo/passport.js +134 -0
- package/lib/chevre/repo/task.d.ts +9 -0
- package/lib/chevre/repo/task.js +23 -2
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/accountTransaction/deposit.js +0 -1
- package/lib/chevre/service/accountTransaction/transfer.js +0 -1
- package/lib/chevre/service/accountTransaction/withdraw.js +0 -1
- package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/cancel.js +41 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm/factory.d.ts +8 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm/factory.js +94 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm.js +93 -0
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +99 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +28 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +405 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +40 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +54 -0
- package/lib/chevre/service/assetTransaction/reserve/{factory.js → start/factory/createReservation.js} +3 -222
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +90 -0
- package/lib/chevre/service/assetTransaction/reserve/{factory → start/factory}/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/{factory → start/factory}/price.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +74 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +570 -0
- package/lib/chevre/service/assetTransaction/reserve.d.ts +6 -128
- package/lib/chevre/service/assetTransaction/reserve.js +9 -1047
- package/lib/chevre/service/offer/event/{defaultOffer.d.ts → authorize/defaultOffer.d.ts} +1 -1
- package/lib/chevre/service/offer/event/{defaultOffer.js → authorize/defaultOffer.js} +1 -1
- package/lib/chevre/service/offer/event/{factory.d.ts → authorize/factory.d.ts} +13 -20
- package/lib/chevre/service/offer/event/{factory.js → authorize/factory.js} +72 -146
- package/lib/chevre/service/offer/event/{processStartReserve4chevre.d.ts → authorize/processStartReserve4chevre.d.ts} +19 -19
- package/lib/chevre/service/offer/event/{processStartReserve4chevre.js → authorize/processStartReserve4chevre.js} +8 -13
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.js +104 -128
- package/lib/chevre/service/offer/event/importFromCOA/factory.d.ts +9 -0
- package/lib/chevre/service/offer/event/importFromCOA/factory.js +67 -0
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +0 -3
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +3 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.d.ts +16 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +168 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +4 -135
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order.d.ts +2 -2
- package/lib/chevre/service/order.js +2 -1
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +3 -2
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/start/factory.d.ts +10 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start/factory.js +36 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +6 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/start.js +26 -12
- package/lib/chevre/service/validation/validateOrder.js +1 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +5 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizeEventServiceOfferResult.ts +0 -163
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +0 -96
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +0 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +0 -29
- package/lib/chevre/service/transaction/validation.d.ts +0 -14
- package/lib/chevre/service/transaction/validation.js +0 -101
|
@@ -0,0 +1,41 @@
|
|
|
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 = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const cancelReservation_1 = require("../../reserve/cancelReservation");
|
|
15
|
+
/**
|
|
16
|
+
* 取引中止
|
|
17
|
+
*/
|
|
18
|
+
function cancel(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
// まず取引状態変更
|
|
21
|
+
const { id } = yield repos.assetTransaction.cancel({
|
|
22
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
23
|
+
id: params.id,
|
|
24
|
+
transactionNumber: params.transactionNumber
|
|
25
|
+
});
|
|
26
|
+
// 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
|
|
27
|
+
// 同期的にもcancelPendingReservationを実行しておく
|
|
28
|
+
// optimize(2024-07-01~)
|
|
29
|
+
// const cancelActionAttributes = createCancelPendingReservationAction({ transaction });
|
|
30
|
+
// if (cancelActionAttributes !== undefined) {
|
|
31
|
+
// await cancelPendingReservation(cancelActionAttributes)(repos);
|
|
32
|
+
// }
|
|
33
|
+
yield (0, cancelReservation_1.cancelPendingReservation)({
|
|
34
|
+
purpose: {
|
|
35
|
+
id,
|
|
36
|
+
typeOf: factory.assetTransactionType.Reserve
|
|
37
|
+
}
|
|
38
|
+
})(repos);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.cancel = cancel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
declare function createPotentialActions(params: {
|
|
3
|
+
order?: Pick<factory.order.IOrder, 'orderNumber' | 'customer' | 'typeOf'>;
|
|
4
|
+
}): {
|
|
5
|
+
potentialActions: factory.assetTransaction.reserve.IPotentialActions;
|
|
6
|
+
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
7
|
+
};
|
|
8
|
+
export { createPotentialActions };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPotentialActions = void 0;
|
|
4
|
+
// tslint:disable-next-line:max-func-body-length
|
|
5
|
+
function createPotentialActions(params) {
|
|
6
|
+
// const transaction = params.transaction;
|
|
7
|
+
// const reservationFor = transaction.object.reservationFor;
|
|
8
|
+
// if (reservationFor === undefined) {
|
|
9
|
+
// throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
10
|
+
// }
|
|
11
|
+
var _a;
|
|
12
|
+
// discontinue(2024-07-01~)
|
|
13
|
+
// const useOptimizeReservation: boolean = !USE_OPTIMIZE_RESERVATION_EXCEPTIONS.includes(transaction.project.id);
|
|
14
|
+
// 予約アクション属性作成
|
|
15
|
+
// const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
|
|
16
|
+
// let reserveActionAttributes: factory.action.reserve.IAttributes[] = [];
|
|
17
|
+
// let reservationPackage: factory.action.reserve.IObject | undefined;
|
|
18
|
+
let underName;
|
|
19
|
+
// purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
|
|
20
|
+
if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
21
|
+
const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
|
|
22
|
+
underName = ordre2reservationUnderNameResult.underName;
|
|
23
|
+
}
|
|
24
|
+
// if (pendingReservations.length > 0) {
|
|
25
|
+
// const moneyTransferActions: factory.action.transfer.moneyTransfer.IAttributes[] = [];
|
|
26
|
+
// pendingReservations.forEach((reservation) => {
|
|
27
|
+
// const acceptedOffer4reservation = transaction.object.acceptedOffer?.find(
|
|
28
|
+
// (o) => o.itemOffered?.serviceOutput?.id === reservation.id
|
|
29
|
+
// );
|
|
30
|
+
// moneyTransferActions.push(...createMoneyTransferActions({
|
|
31
|
+
// acceptedOffer: acceptedOffer4reservation,
|
|
32
|
+
// reservation,
|
|
33
|
+
// transaction: params.transaction,
|
|
34
|
+
// underName
|
|
35
|
+
// }));
|
|
36
|
+
// });
|
|
37
|
+
// reservationPackage = {
|
|
38
|
+
// reservationFor: {
|
|
39
|
+
// id: String(reservationFor.id),
|
|
40
|
+
// typeOf: reservationFor.typeOf,
|
|
41
|
+
// optimized: true
|
|
42
|
+
// }, // optimize(2024-01-24~)
|
|
43
|
+
// reservationNumber: transaction.object.reservationNumber,
|
|
44
|
+
// reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
|
|
45
|
+
// ? params.transaction.object.reservationStatus
|
|
46
|
+
// : factory.reservationStatusType.ReservationPending,
|
|
47
|
+
// typeOf: factory.reservationType.ReservationPackage
|
|
48
|
+
// };
|
|
49
|
+
// reserveActionAttributes = [{
|
|
50
|
+
// project: transaction.project,
|
|
51
|
+
// typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
|
|
52
|
+
// object: reservationPackage,
|
|
53
|
+
// agent: transaction.project,
|
|
54
|
+
// potentialActions: {
|
|
55
|
+
// moneyTransfer: moneyTransferActions
|
|
56
|
+
// },
|
|
57
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
58
|
+
// }];
|
|
59
|
+
// }
|
|
60
|
+
return {
|
|
61
|
+
potentialActions: {
|
|
62
|
+
// reserve: reserveActionAttributes // discontinue(2024-07-01~)
|
|
63
|
+
},
|
|
64
|
+
// reservationPackage,
|
|
65
|
+
underName
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.createPotentialActions = createPotentialActions;
|
|
69
|
+
/**
|
|
70
|
+
* 予約のunderName.identifierを決定する
|
|
71
|
+
*/
|
|
72
|
+
function createReservationUnderNameIdentifier(params) {
|
|
73
|
+
// 必要最低限の識別子のみ継承する(2024-03-16~)
|
|
74
|
+
let identifiersFromCustomer = (Array.isArray(params.order.customer.identifier)) ? params.order.customer.identifier : [];
|
|
75
|
+
// if (params.useOptimizeReservation) {
|
|
76
|
+
// identifiersFromCustomer = identifiersFromCustomer.filter(({ name }) => name === 'clientId');
|
|
77
|
+
// }
|
|
78
|
+
identifiersFromCustomer = identifiersFromCustomer.filter(({ name }) => name === 'clientId');
|
|
79
|
+
return [
|
|
80
|
+
{ name: 'orderNumber', value: params.order.orderNumber },
|
|
81
|
+
...identifiersFromCustomer
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
function createReservationUnderName(params) {
|
|
85
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: createReservationUnderNameIdentifier({ order: params.order }), name: String(params.order.customer.name), typeOf: params.order.customer.typeOf }, (typeof params.order.customer.address === 'string') ? { address: params.order.customer.address } : undefined), (typeof params.order.customer.age === 'string') ? { age: params.order.customer.age } : undefined), (typeof params.order.customer.email === 'string') ? { email: params.order.customer.email } : undefined), (typeof params.order.customer.familyName === 'string') ? { familyName: params.order.customer.familyName } : undefined), (typeof params.order.customer.gender === 'string') ? { gender: params.order.customer.gender } : undefined), (typeof params.order.customer.givenName === 'string') ? { givenName: params.order.customer.givenName } : undefined), (typeof params.order.customer.id === 'string') ? { id: params.order.customer.id } : undefined), (typeof params.order.customer.telephone === 'string') ? { telephone: params.order.customer.telephone } : undefined), (typeof params.order.customer.url === 'string') ? { url: params.order.customer.url } : undefined);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 注文者情報を予約者情報へ変換する
|
|
89
|
+
*/
|
|
90
|
+
function ordre2reservationUnderName(params) {
|
|
91
|
+
return {
|
|
92
|
+
underName: createReservationUnderName({ order: params.order })
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
+
import type { MongoRepository as OrderRepo } from '../../../repo/order';
|
|
5
|
+
import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
interface IConfirmRepo {
|
|
8
|
+
action: ActionRepo;
|
|
9
|
+
assetTransaction: AssetTransactionRepo;
|
|
10
|
+
order: OrderRepo;
|
|
11
|
+
reservation: ReservationRepo;
|
|
12
|
+
task: TaskRepo;
|
|
13
|
+
}
|
|
14
|
+
type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* 取引確定
|
|
17
|
+
*/
|
|
18
|
+
declare function confirm(params: factory.assetTransaction.reserve.IConfirmParams): IConfirmOperation<void>;
|
|
19
|
+
export { confirm };
|
|
@@ -0,0 +1,93 @@
|
|
|
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 = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const settings_1 = require("../../../settings");
|
|
15
|
+
const confirmReservation_1 = require("../../reserve/confirmReservation");
|
|
16
|
+
const factory_1 = require("./confirm/factory");
|
|
17
|
+
/**
|
|
18
|
+
* 取引確定
|
|
19
|
+
*/
|
|
20
|
+
function confirm(params) {
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let transaction;
|
|
23
|
+
// 取引存在確認
|
|
24
|
+
if (typeof params.id === 'string') {
|
|
25
|
+
transaction = yield repos.assetTransaction.findById({
|
|
26
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
27
|
+
id: params.id
|
|
28
|
+
}, ['project', 'transactionNumber'] // projection(2024-07-01~)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
else if (typeof params.transactionNumber === 'string') {
|
|
32
|
+
transaction = yield repos.assetTransaction.findByTransactionNumber({
|
|
33
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
34
|
+
transactionNumber: params.transactionNumber
|
|
35
|
+
}, ['project', 'transactionNumber'] // projection(2024-07-01~)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
40
|
+
}
|
|
41
|
+
const order = yield fixOrderAsPurpose(params, transaction)(repos);
|
|
42
|
+
const { potentialActions, underName } = (0, factory_1.createPotentialActions)({
|
|
43
|
+
// ...params,
|
|
44
|
+
// transaction,
|
|
45
|
+
order
|
|
46
|
+
});
|
|
47
|
+
// 取引確定
|
|
48
|
+
const result = {};
|
|
49
|
+
yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Reserve, id: transaction.id, result: result,
|
|
50
|
+
// potentialActions: (USE_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
51
|
+
// ? { reserve: [] }
|
|
52
|
+
// : potentialActions, // discontinue(2024-07-01~)
|
|
53
|
+
potentialActions }, (typeof (underName === null || underName === void 0 ? void 0 : underName.typeOf) === 'string')
|
|
54
|
+
? { object: { underName } }
|
|
55
|
+
: undefined));
|
|
56
|
+
if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
57
|
+
// sync対応(2023-01-13~)
|
|
58
|
+
yield (0, confirmReservation_1.confirmReservation)({
|
|
59
|
+
// optimize(2024-07-01~)
|
|
60
|
+
// actionAttributesList: potentialActions.reserve,
|
|
61
|
+
potentialReserveAction: { object: { reservationNumber: transaction.transactionNumber } },
|
|
62
|
+
useOnReservationConfirmed: true,
|
|
63
|
+
byTask: true
|
|
64
|
+
})(repos);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.confirm = confirm;
|
|
69
|
+
function fixOrderAsPurpose(params, transaction) {
|
|
70
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f;
|
|
72
|
+
let order;
|
|
73
|
+
const payPurposeConfirmationNumber = (_c = (_b = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.reserve) === null || _b === void 0 ? void 0 : _b.purpose) === null || _c === void 0 ? void 0 : _c.confirmationNumber;
|
|
74
|
+
const payPurposeOrderNumber = (_f = (_e = (_d = params.potentialActions) === null || _d === void 0 ? void 0 : _d.reserve) === null || _e === void 0 ? void 0 : _e.purpose) === null || _f === void 0 ? void 0 : _f.orderNumber;
|
|
75
|
+
if (typeof payPurposeConfirmationNumber === 'string'
|
|
76
|
+
&& payPurposeConfirmationNumber.length > 0
|
|
77
|
+
&& typeof payPurposeOrderNumber === 'string'
|
|
78
|
+
&& payPurposeOrderNumber.length > 0) {
|
|
79
|
+
const orders = yield repos.order.search({
|
|
80
|
+
limit: 1,
|
|
81
|
+
page: 1,
|
|
82
|
+
project: { id: { $eq: transaction.project.id } },
|
|
83
|
+
confirmationNumbers: [payPurposeConfirmationNumber],
|
|
84
|
+
orderNumbers: [payPurposeOrderNumber]
|
|
85
|
+
}, { customer: 1, orderNumber: 1, typeOf: 1 });
|
|
86
|
+
order = orders.shift();
|
|
87
|
+
if (order === undefined) {
|
|
88
|
+
throw new factory.errors.NotFound('Order as purpose');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return order;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
2
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
3
|
+
type ITaskAndTransactionOperation<T> = (repos: {
|
|
4
|
+
task: TaskRepo;
|
|
5
|
+
assetTransaction: AssetTransactionRepo;
|
|
6
|
+
}) => Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* 取引タスク出力
|
|
9
|
+
*/
|
|
10
|
+
declare function exportTasksById(params: {
|
|
11
|
+
id: string;
|
|
12
|
+
}): ITaskAndTransactionOperation<{
|
|
13
|
+
id: string;
|
|
14
|
+
}[]>;
|
|
15
|
+
export { exportTasksById };
|
|
@@ -0,0 +1,99 @@
|
|
|
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.exportTasksById = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const settings_1 = require("../../../settings");
|
|
15
|
+
/**
|
|
16
|
+
* 取引タスク出力
|
|
17
|
+
*/
|
|
18
|
+
function exportTasksById(params) {
|
|
19
|
+
// tslint:disable-next-line:max-func-body-length
|
|
20
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const transaction = yield repos.assetTransaction.findById({
|
|
22
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
23
|
+
id: params.id
|
|
24
|
+
}, ['status', 'transactionNumber', 'project', 'typeOf'] // projection(2024-07-01~)
|
|
25
|
+
);
|
|
26
|
+
// const potentialActions = transaction.potentialActions;
|
|
27
|
+
const taskAttributes = [];
|
|
28
|
+
let cancelPendingReservationTask;
|
|
29
|
+
switch (transaction.status) {
|
|
30
|
+
case factory.transactionStatusType.Confirmed:
|
|
31
|
+
// potentialActions依存を完全廃止(2024-07-01~)
|
|
32
|
+
// if (potentialActions !== undefined) {
|
|
33
|
+
// if (Array.isArray(potentialActions.reserve) && potentialActions.reserve.length > 0) {
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
37
|
+
const reserveTask = {
|
|
38
|
+
project: transaction.project,
|
|
39
|
+
name: factory.taskName.Reserve,
|
|
40
|
+
status: factory.taskStatus.Ready,
|
|
41
|
+
runsAt: new Date(),
|
|
42
|
+
remainingNumberOfTries: 10,
|
|
43
|
+
numberOfTried: 0,
|
|
44
|
+
executionResults: [],
|
|
45
|
+
data: { object: { reservationNumber: transaction.transactionNumber } } // optimize(2024-07-01~)
|
|
46
|
+
};
|
|
47
|
+
taskAttributes.push(reserveTask);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case factory.transactionStatusType.Canceled:
|
|
51
|
+
// sync対応(2023-01-13~)
|
|
52
|
+
if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
53
|
+
// const cancelActionAttributes4canceled = createCancelPendingReservationAction({ transaction });
|
|
54
|
+
// if (cancelActionAttributes4canceled !== undefined) {
|
|
55
|
+
// }
|
|
56
|
+
cancelPendingReservationTask = {
|
|
57
|
+
project: transaction.project,
|
|
58
|
+
name: factory.taskName.CancelPendingReservation,
|
|
59
|
+
status: factory.taskStatus.Ready,
|
|
60
|
+
runsAt: new Date(),
|
|
61
|
+
remainingNumberOfTries: 10,
|
|
62
|
+
numberOfTried: 0,
|
|
63
|
+
executionResults: [],
|
|
64
|
+
data: {
|
|
65
|
+
// optimize(2024-07-01~)
|
|
66
|
+
// actionAttributes: [cancelActionAttributes4canceled],
|
|
67
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf }
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
taskAttributes.push(cancelPendingReservationTask);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case factory.transactionStatusType.Expired:
|
|
74
|
+
// const cancelActionAttributes = createCancelPendingReservationAction({ transaction });
|
|
75
|
+
// if (cancelActionAttributes !== undefined) {
|
|
76
|
+
// }
|
|
77
|
+
cancelPendingReservationTask = {
|
|
78
|
+
project: transaction.project,
|
|
79
|
+
name: factory.taskName.CancelPendingReservation,
|
|
80
|
+
status: factory.taskStatus.Ready,
|
|
81
|
+
runsAt: new Date(),
|
|
82
|
+
remainingNumberOfTries: 10,
|
|
83
|
+
numberOfTried: 0,
|
|
84
|
+
executionResults: [],
|
|
85
|
+
data: {
|
|
86
|
+
// optimize(2024-07-01~)
|
|
87
|
+
// actionAttributes: [cancelActionAttributes]
|
|
88
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf }
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
taskAttributes.push(cancelPendingReservationTask);
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
95
|
+
}
|
|
96
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.exportTasksById = exportTasksById;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { IMinimizedIndividualEvent } from '../../../../repo/event';
|
|
3
|
+
import type { MongoRepository as OfferRepo } from '../../../../repo/offer';
|
|
4
|
+
import type { MongoRepository as OfferCatalogRepo } from '../../../../repo/offerCatalog';
|
|
5
|
+
import type { MongoRepository as PaymentServiceRepo } from '../../../../repo/paymentService';
|
|
6
|
+
import type { MongoRepository as ProductRepo } from '../../../../repo/product';
|
|
7
|
+
import type { MongoRepository as ProductOfferRepo } from '../../../../repo/productOffer';
|
|
8
|
+
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
9
|
+
declare function createSubReservations(params: {
|
|
10
|
+
acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
|
|
11
|
+
ticketOffers: factory.product.ITicketOffer[];
|
|
12
|
+
availableOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
13
|
+
now: Date;
|
|
14
|
+
event: IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>;
|
|
15
|
+
availableSeatOffers: factory.place.seat.IPlaceWithOffer[];
|
|
16
|
+
reservationNumber: string;
|
|
17
|
+
availableAtOrFrom?: {
|
|
18
|
+
id?: string;
|
|
19
|
+
};
|
|
20
|
+
validateAppliesToMovieTicket: boolean;
|
|
21
|
+
}): (repos: {
|
|
22
|
+
offer: OfferRepo;
|
|
23
|
+
offerCatalog: OfferCatalogRepo;
|
|
24
|
+
paymentService: PaymentServiceRepo;
|
|
25
|
+
product: ProductRepo;
|
|
26
|
+
productOffer: ProductOfferRepo;
|
|
27
|
+
}) => Promise<IObjectSubReservation[]>;
|
|
28
|
+
export { createSubReservations };
|