@chevre/domain 21.20.0-alpha.2 → 21.20.0-alpha.22
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/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processAcceptOffer.ts +48 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
- package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
- package/lib/chevre/repo/acceptedOffer.js +32 -2
- package/lib/chevre/repo/action.d.ts +13 -7
- package/lib/chevre/repo/action.js +33 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
- package/lib/chevre/repo/order.js +28 -9
- package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
- package/lib/chevre/repo/orderInTransaction.js +77 -0
- package/lib/chevre/repo/task.d.ts +0 -2
- package/lib/chevre/repo/task.js +56 -46
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/any.d.ts +29 -0
- package/lib/chevre/service/offer/any.js +55 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +11 -0
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +12 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +48 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +133 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +58 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +156 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +51 -36
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.js +28 -29
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +68 -30
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard.js +102 -133
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +18 -13
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
3
|
+
import type { RedisRepository as OrderNumberRepo } from '../../repo/orderNumber';
|
|
4
|
+
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
5
|
+
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
|
+
interface IAcceptOfferOperationRepos {
|
|
7
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
8
|
+
orderNumber: OrderNumberRepo;
|
|
9
|
+
project: ProjectRepo;
|
|
10
|
+
transaction: TransactionRepo;
|
|
11
|
+
}
|
|
12
|
+
type IAcceptOfferOperation<T> = (repos: IAcceptOfferOperationRepos) => Promise<T>;
|
|
13
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
|
|
14
|
+
export declare function acceptOffer(params: {
|
|
15
|
+
project: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
purpose: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
22
|
+
}): IAcceptOfferOperation<void>;
|
|
23
|
+
export declare function voidAcceptedOffer(params: {
|
|
24
|
+
authorizeActions: IAuthorizeOfferAction[];
|
|
25
|
+
orderNumber: string;
|
|
26
|
+
}): (repos: {
|
|
27
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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.voidAcceptedOffer = exports.acceptOffer = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
14
|
+
const factory = require("../../factory");
|
|
15
|
+
const placeOrderInProgress_1 = require("../transaction/placeOrderInProgress");
|
|
16
|
+
const debug = createDebug('chevre-domain:service:offer');
|
|
17
|
+
function acceptOffer(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const now = new Date();
|
|
20
|
+
const orderNumber = yield (0, placeOrderInProgress_1.publishOrderNumberIfNotExist)({
|
|
21
|
+
project: { id: params.project.id },
|
|
22
|
+
id: params.purpose.id,
|
|
23
|
+
object: { orderDate: now }
|
|
24
|
+
})(repos);
|
|
25
|
+
yield repos.orderInTransaction.acceptOffer({
|
|
26
|
+
orderNumber,
|
|
27
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
28
|
+
acceptedOffers: params.acceptedOffers
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.acceptOffer = acceptOffer;
|
|
33
|
+
function voidAcceptedOffer(params) {
|
|
34
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const { authorizeActions, orderNumber } = params;
|
|
36
|
+
let reservationNumbers = [];
|
|
37
|
+
authorizeActions.forEach((authorizeAction) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const reserveTransactionNumberByAction = (_a = authorizeAction.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
40
|
+
if (typeof reserveTransactionNumberByAction === 'string') {
|
|
41
|
+
reservationNumbers.push(reserveTransactionNumberByAction);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
reservationNumbers = [...new Set(reservationNumbers)];
|
|
45
|
+
debug('removing acceptedOffers from PlaceOrder...', orderNumber, reservationNumbers);
|
|
46
|
+
if (reservationNumbers.length > 0) {
|
|
47
|
+
const result = yield repos.orderInTransaction.voidAcceptedOfferByReservationNumber({
|
|
48
|
+
orderNumber,
|
|
49
|
+
acceptedOffers: { reservationNumber: { $in: reservationNumbers } }
|
|
50
|
+
});
|
|
51
|
+
debug('acceptedOffers removed from PlaceOrder.', result);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.voidAcceptedOffer = voidAcceptedOffer;
|
|
@@ -5,6 +5,8 @@ import type { MongoRepository as EventRepo } from '../../../repo/event';
|
|
|
5
5
|
import type { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
6
6
|
import type { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
7
7
|
import type { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
8
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
9
|
+
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
8
10
|
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
9
11
|
import type { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
10
12
|
import type { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
@@ -27,6 +29,8 @@ interface IAuthorizeRepos {
|
|
|
27
29
|
offerCatalog: OfferCatalogRepo;
|
|
28
30
|
offerCatalogItem: OfferCatalogItemRepo;
|
|
29
31
|
offerRateLimit: OfferRateLimitRepo;
|
|
32
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
33
|
+
orderNumber: OrderNumberRepo;
|
|
30
34
|
paymentService: PaymentServiceRepo;
|
|
31
35
|
place: PlaceRepo;
|
|
32
36
|
priceSpecification: PriceSpecificationRepo;
|
|
@@ -69,5 +73,8 @@ declare function authorize(params: {
|
|
|
69
73
|
* オファーID指定なしに座席をおさえる場合true
|
|
70
74
|
*/
|
|
71
75
|
noOfferSpecified: boolean;
|
|
76
|
+
options: {
|
|
77
|
+
useCreateOrderOnOfferAccepted: boolean;
|
|
78
|
+
};
|
|
72
79
|
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|
|
73
80
|
export { authorize };
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.authorize = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
|
+
const any_1 = require("../any");
|
|
14
15
|
const defaultOffer_1 = require("./defaultOffer");
|
|
15
16
|
const processStartReserve4chevre_1 = require("./processStartReserve4chevre");
|
|
16
17
|
const searchEventTicketOffers_1 = require("./searchEventTicketOffers");
|
|
@@ -73,6 +74,16 @@ function authorize(params) {
|
|
|
73
74
|
stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
|
|
74
75
|
})(repos);
|
|
75
76
|
acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
|
|
77
|
+
// add orderInTransaction(2024-01-15~)
|
|
78
|
+
if (!noOfferSpecified) {
|
|
79
|
+
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
80
|
+
yield (0, any_1.acceptOffer)({
|
|
81
|
+
project: transaction.project,
|
|
82
|
+
purpose: { id: transaction.id },
|
|
83
|
+
acceptedOffers: acceptedOffers4result
|
|
84
|
+
})(repos);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
76
87
|
break;
|
|
77
88
|
default:
|
|
78
89
|
throw new factory.errors.Argument('Event', `Unknown booking service '${bookingServiceIdentifire}'`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
4
5
|
import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
5
6
|
import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
7
|
import type { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
@@ -11,6 +12,7 @@ interface ICancelRepos {
|
|
|
11
12
|
assetTransaction: AssetTransactionRepo;
|
|
12
13
|
stockHolder: StockHolderRepo;
|
|
13
14
|
offerRateLimit: OfferRateLimitRepo;
|
|
15
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
14
16
|
reservation: ReservationRepo;
|
|
15
17
|
task: TaskRepo;
|
|
16
18
|
transaction: TransactionRepo;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.cancel = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
14
|
const ReserveTransactionService = require("../../assetTransaction/reserve");
|
|
15
|
+
const any_1 = require("../any");
|
|
15
16
|
/**
|
|
16
17
|
* イベントオファー承認取消(apiから実行)
|
|
17
18
|
* 特定の承認アクションについて処理する
|
|
@@ -28,12 +29,22 @@ function cancel(params) {
|
|
|
28
29
|
}
|
|
29
30
|
// MongoDBでcompleteステータスであるにも関わらず、Chevreでは削除されている、というのが最悪の状況
|
|
30
31
|
// それだけは回避するためにMongoDBを先に変更
|
|
31
|
-
|
|
32
|
+
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
33
|
+
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
32
34
|
switch (action.instrument.identifier) {
|
|
33
35
|
case factory.service.webAPI.Identifier.COA:
|
|
34
36
|
// 実質使用する予定なしなので廃止(2022-05-12~)
|
|
35
37
|
throw new factory.errors.NotImplemented(`booking service '${action.instrument.identifier}' not implemented`);
|
|
36
38
|
default:
|
|
39
|
+
// add orderInTransaction(2024-01-15~)
|
|
40
|
+
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
41
|
+
const orderNumberByTransaction = transaction.object.orderNumber;
|
|
42
|
+
if (typeof orderNumberByTransaction === 'string') {
|
|
43
|
+
yield (0, any_1.voidAcceptedOffer)({
|
|
44
|
+
authorizeActions: [action],
|
|
45
|
+
orderNumber: orderNumberByTransaction
|
|
46
|
+
})(repos);
|
|
47
|
+
}
|
|
37
48
|
const transactionNumber = (_a = action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
38
49
|
if (typeof transactionNumber === 'string') {
|
|
39
50
|
// すでに取消済であったとしても、すべて取消処理(actionStatusに関係なく)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
4
5
|
import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
5
6
|
import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
7
|
import type { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
@@ -12,6 +13,7 @@ interface IVoidTransactionRepos {
|
|
|
12
13
|
assetTransaction: AssetTransactionRepo;
|
|
13
14
|
stockHolder: StockHolderRepo;
|
|
14
15
|
offerRateLimit: OfferRateLimitRepo;
|
|
16
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
15
17
|
reservation: ReservationRepo;
|
|
16
18
|
task: TaskRepo;
|
|
17
19
|
transaction: TransactionRepo;
|
|
@@ -15,6 +15,7 @@ const http_status_1 = require("http-status");
|
|
|
15
15
|
const credentials_1 = require("../../../credentials");
|
|
16
16
|
const factory = require("../../../factory");
|
|
17
17
|
const ReserveTransactionService = require("../../assetTransaction/reserve");
|
|
18
|
+
const any_1 = require("../any");
|
|
18
19
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
19
20
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
20
21
|
refreshToken: credentials_1.credentials.coa.refreshToken
|
|
@@ -30,7 +31,7 @@ function voidTransaction(params) {
|
|
|
30
31
|
const transaction = yield repos.transaction.findById({
|
|
31
32
|
typeOf: params.purpose.typeOf,
|
|
32
33
|
id: params.purpose.id,
|
|
33
|
-
inclusion: ['_id', 'typeOf', 'status']
|
|
34
|
+
inclusion: ['_id', 'typeOf', 'status', 'object.orderNumber']
|
|
34
35
|
});
|
|
35
36
|
// 興行オファー承認アクション検索
|
|
36
37
|
let authorizeActions = yield repos.action.searchByPurpose({
|
|
@@ -41,9 +42,6 @@ function voidTransaction(params) {
|
|
|
41
42
|
},
|
|
42
43
|
object: { typeOf: { $eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation } }
|
|
43
44
|
});
|
|
44
|
-
// .then((actions) => actions
|
|
45
|
-
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation)
|
|
46
|
-
// );
|
|
47
45
|
switch (transaction.status) {
|
|
48
46
|
case factory.transactionStatusType.InProgress:
|
|
49
47
|
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
@@ -59,8 +57,17 @@ function voidTransaction(params) {
|
|
|
59
57
|
default:
|
|
60
58
|
// no op
|
|
61
59
|
}
|
|
60
|
+
// add orderInTransaction(2024-01-15~)
|
|
61
|
+
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
62
|
+
const orderNumberByTransaction = transaction.object.orderNumber;
|
|
63
|
+
if (typeof orderNumberByTransaction === 'string') {
|
|
64
|
+
yield (0, any_1.voidAcceptedOffer)({
|
|
65
|
+
authorizeActions,
|
|
66
|
+
orderNumber: orderNumberByTransaction
|
|
67
|
+
})(repos);
|
|
68
|
+
}
|
|
62
69
|
yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
yield repos.action.
|
|
70
|
+
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
64
71
|
switch (action.instrument.identifier) {
|
|
65
72
|
case exports.WebAPIIdentifier.COA:
|
|
66
73
|
yield processVoidTransaction4coa({
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
3
|
+
import type { MongoRepository as EventRepo } from '../../../repo/event';
|
|
4
|
+
import type { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
5
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
6
|
+
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
7
|
+
import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
8
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
9
|
+
import { IAcceptedOfferBeforeAuthorize4COA } from './validateAcceptedOffers';
|
|
10
|
+
import * as factory from '../../../factory';
|
|
11
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
12
|
+
export type IAuthorizeActionResult = factory.action.authorize.offer.eventService.IResult<WebAPIIdentifier.COA>;
|
|
13
|
+
export interface IAuthorizeRepos {
|
|
14
|
+
action: ActionRepo;
|
|
15
|
+
categoryCode: CategoryCodeRepo;
|
|
16
|
+
event: EventRepo;
|
|
17
|
+
offer: OfferRepo;
|
|
18
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
19
|
+
orderNumber: OrderNumberRepo;
|
|
20
|
+
project: ProjectRepo;
|
|
21
|
+
transaction: TransactionRepo;
|
|
22
|
+
}
|
|
23
|
+
export type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
|
|
24
|
+
export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.COA>;
|
|
25
|
+
/**
|
|
26
|
+
* COA興行オファー承認
|
|
27
|
+
*/
|
|
28
|
+
export declare function authorize(params: {
|
|
29
|
+
object: {
|
|
30
|
+
acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
|
|
31
|
+
event: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
agent: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
transaction: {
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
result: {
|
|
42
|
+
requestBody: factory.action.authorize.offer.eventService.IRequestBody<WebAPIIdentifier.COA>;
|
|
43
|
+
responseBody: factory.action.authorize.offer.eventService.IResponseBody<WebAPIIdentifier.COA>;
|
|
44
|
+
};
|
|
45
|
+
options: {
|
|
46
|
+
useCreateOrderOnOfferAccepted: boolean;
|
|
47
|
+
};
|
|
48
|
+
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|
|
@@ -0,0 +1,133 @@
|
|
|
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.authorize = exports.WebAPIIdentifier = void 0;
|
|
13
|
+
const moment = require("moment");
|
|
14
|
+
const any_1 = require("../any");
|
|
15
|
+
const factory_1 = require("./factory");
|
|
16
|
+
const validateAcceptedOffers_1 = require("./validateAcceptedOffers");
|
|
17
|
+
const factory = require("../../../factory");
|
|
18
|
+
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
19
|
+
/**
|
|
20
|
+
* COA興行オファー承認
|
|
21
|
+
*/
|
|
22
|
+
function authorize(params) {
|
|
23
|
+
// tslint:disable-next-line:max-func-body-length
|
|
24
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const transaction = yield repos.transaction.findInProgressById({
|
|
26
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
27
|
+
id: params.transaction.id
|
|
28
|
+
});
|
|
29
|
+
if (transaction.agent.id !== params.agent.id) {
|
|
30
|
+
throw new factory.errors.Forbidden('Transaction not yours');
|
|
31
|
+
}
|
|
32
|
+
let screeningEvent;
|
|
33
|
+
let acceptedOffers;
|
|
34
|
+
const pendingTransaction = {
|
|
35
|
+
theaterCode: params.result.requestBody.theaterCode,
|
|
36
|
+
dateJouei: params.result.requestBody.dateJouei,
|
|
37
|
+
titleCode: params.result.requestBody.titleCode,
|
|
38
|
+
titleBranchNum: params.result.requestBody.titleBranchNum,
|
|
39
|
+
timeBegin: params.result.requestBody.timeBegin,
|
|
40
|
+
tmpReserveNum: params.result.responseBody.tmpReserveNum,
|
|
41
|
+
transactionNumber: params.result.responseBody.tmpReserveNum,
|
|
42
|
+
typeOf: 'COAReserveTransaction'
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
46
|
+
screeningEvent =
|
|
47
|
+
yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id });
|
|
48
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
49
|
+
project: { id: { $eq: transaction.project.id } },
|
|
50
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
51
|
+
}, [], []);
|
|
52
|
+
const seatingTypes = yield repos.categoryCode.search({
|
|
53
|
+
project: { id: { $eq: transaction.project.id } },
|
|
54
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
55
|
+
}, [], []);
|
|
56
|
+
const videoFormatTypes = yield repos.categoryCode.search({
|
|
57
|
+
project: { id: { $eq: transaction.project.id } },
|
|
58
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
|
|
59
|
+
}, [], []);
|
|
60
|
+
// COA仮予約後にリクエストが来る前提
|
|
61
|
+
const validateAcceptedOffersResult = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
62
|
+
object: params.object,
|
|
63
|
+
project: { id: transaction.project.id },
|
|
64
|
+
screeningEvent,
|
|
65
|
+
availablePaymentMethodTypes,
|
|
66
|
+
seatingTypes,
|
|
67
|
+
videoFormatTypes
|
|
68
|
+
})(repos);
|
|
69
|
+
acceptedOffers = validateAcceptedOffersResult.acceptedOffers;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// アクション開始前に例外がthrowされてもCOA仮予約を取り消す機会をつくるためにFailedアクションを作成する(2023-09-12~)
|
|
73
|
+
const failedActionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
|
|
74
|
+
acceptedOffers: [],
|
|
75
|
+
event: { id: params.object.event.id, typeOf: factory.eventType.ScreeningEvent },
|
|
76
|
+
transaction,
|
|
77
|
+
pendingTransaction
|
|
78
|
+
});
|
|
79
|
+
const failedAction = yield repos.action.start(failedActionAttributes);
|
|
80
|
+
yield repos.action.giveUp({ typeOf: failedAction.typeOf, id: failedAction.id, error });
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
let result;
|
|
84
|
+
// 承認アクションを開始
|
|
85
|
+
const actionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
|
|
86
|
+
acceptedOffers,
|
|
87
|
+
event: screeningEvent,
|
|
88
|
+
transaction,
|
|
89
|
+
pendingTransaction
|
|
90
|
+
});
|
|
91
|
+
const action = yield repos.action.start(actionAttributes);
|
|
92
|
+
try {
|
|
93
|
+
// 座席仮予約からオファー情報を生成する
|
|
94
|
+
const { price, eligibleMonetaryAmount } = (0, factory_1.offers2resultPrice)(acceptedOffers);
|
|
95
|
+
const acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
|
|
96
|
+
responseBody: params.result.responseBody,
|
|
97
|
+
object: action.object,
|
|
98
|
+
event: screeningEvent,
|
|
99
|
+
seller: transaction.seller,
|
|
100
|
+
bookingTime: moment(action.startDate)
|
|
101
|
+
.toDate(),
|
|
102
|
+
totalPrice: price
|
|
103
|
+
});
|
|
104
|
+
result = {
|
|
105
|
+
price: price,
|
|
106
|
+
priceCurrency: factory.priceCurrency.JPY,
|
|
107
|
+
amount: eligibleMonetaryAmount,
|
|
108
|
+
requestBody: params.result.requestBody,
|
|
109
|
+
responseBody: params.result.responseBody,
|
|
110
|
+
acceptedOffers: acceptedOffers4result
|
|
111
|
+
};
|
|
112
|
+
// add orderInTransaction(2024-01-15~)
|
|
113
|
+
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
114
|
+
yield (0, any_1.acceptOffer)({
|
|
115
|
+
project: transaction.project,
|
|
116
|
+
purpose: { id: transaction.id },
|
|
117
|
+
acceptedOffers: acceptedOffers4result
|
|
118
|
+
})(repos);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
try {
|
|
123
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
124
|
+
}
|
|
125
|
+
catch (__) {
|
|
126
|
+
// no op
|
|
127
|
+
}
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
exports.authorize = authorize;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
3
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
4
|
+
import * as factory from '../../../factory';
|
|
5
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
6
|
+
interface ICancelResult {
|
|
7
|
+
theaterCode: string;
|
|
8
|
+
dateJouei: string;
|
|
9
|
+
titleCode: string;
|
|
10
|
+
titleBranchNum: string;
|
|
11
|
+
timeBegin: string;
|
|
12
|
+
tmpReserveNum: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* COA興行オファー承認取消
|
|
16
|
+
*/
|
|
17
|
+
export declare function cancel(params: {
|
|
18
|
+
/**
|
|
19
|
+
* 承認アクションID
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/**
|
|
23
|
+
* 取引進行者
|
|
24
|
+
*/
|
|
25
|
+
agent: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 取引
|
|
30
|
+
*/
|
|
31
|
+
transaction: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
}): (repos: {
|
|
35
|
+
action: ActionRepo;
|
|
36
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
37
|
+
transaction: TransactionRepo;
|
|
38
|
+
}) => Promise<ICancelResult | undefined>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 = exports.WebAPIIdentifier = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const any_1 = require("../any");
|
|
15
|
+
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
16
|
+
/**
|
|
17
|
+
* COA興行オファー承認取消
|
|
18
|
+
*/
|
|
19
|
+
function cancel(params) {
|
|
20
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const transaction = yield repos.transaction.findInProgressById({
|
|
22
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
23
|
+
id: params.transaction.id
|
|
24
|
+
});
|
|
25
|
+
if (transaction.agent.id !== params.agent.id) {
|
|
26
|
+
throw new factory.errors.Forbidden('Transaction not yours');
|
|
27
|
+
}
|
|
28
|
+
// 取引内のアクションかどうか確認
|
|
29
|
+
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
30
|
+
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
31
|
+
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
32
|
+
}
|
|
33
|
+
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
34
|
+
// add orderInTransaction(2024-01-15~)
|
|
35
|
+
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
36
|
+
const orderNumberByTransaction = transaction.object.orderNumber;
|
|
37
|
+
if (typeof orderNumberByTransaction === 'string') {
|
|
38
|
+
yield (0, any_1.voidAcceptedOffer)({
|
|
39
|
+
authorizeActions: [action],
|
|
40
|
+
orderNumber: orderNumberByTransaction
|
|
41
|
+
})(repos);
|
|
42
|
+
}
|
|
43
|
+
let cancelResult;
|
|
44
|
+
const actionResult = action.result;
|
|
45
|
+
if ((actionResult === null || actionResult === void 0 ? void 0 : actionResult.requestBody) !== undefined && actionResult.responseBody !== undefined) {
|
|
46
|
+
cancelResult = {
|
|
47
|
+
theaterCode: actionResult.requestBody.theaterCode,
|
|
48
|
+
dateJouei: actionResult.requestBody.dateJouei,
|
|
49
|
+
titleCode: actionResult.requestBody.titleCode,
|
|
50
|
+
titleBranchNum: actionResult.requestBody.titleBranchNum,
|
|
51
|
+
timeBegin: actionResult.requestBody.timeBegin,
|
|
52
|
+
tmpReserveNum: actionResult.responseBody.tmpReserveNum
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return cancelResult;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.cancel = cancel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IAuthorizeOfferAction, IAuthorizeOperation } from './authorize';
|
|
2
|
+
import { IAcceptedOfferBeforeAuthorize4COA } from './validateAcceptedOffers';
|
|
3
|
+
import * as factory from '../../../factory';
|
|
4
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
5
|
+
/**
|
|
6
|
+
* COA興行オファー承認のオファーを変更
|
|
7
|
+
*/
|
|
8
|
+
export declare function changeOffers(params: {
|
|
9
|
+
id: string;
|
|
10
|
+
object: {
|
|
11
|
+
acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
|
|
12
|
+
event: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
agent: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
transaction: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
options: {
|
|
23
|
+
useCreateOrderOnOfferAccepted: boolean;
|
|
24
|
+
};
|
|
25
|
+
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|