@chevre/domain 22.8.0-alpha.1 → 22.8.0-alpha.2
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/migrateAuthorizeEventServiceOfferChevre.ts +1 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +0 -17
- package/lib/chevre/repo/acceptedOffer.js +0 -31
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/service/offer/any.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize/factory.js +1 -3
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +1 -2
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -2
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +2 -3
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +1 -3
- package/lib/chevre/service/offer/event/voidTransaction.js +9 -5
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +4 -4
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +3 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +1 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +0 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +0 -6
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +4 -2
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +4 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +4 -0
- package/lib/chevre/service/reserve/useReservation.js +5 -6
- package/lib/chevre/service/task/returnReserveTransaction.js +5 -5
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +1 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizeEventServiceOfferCOA.ts +0 -84
- package/example/src/chevre/migrateAuthorizeEventServiceOfferInstrument.ts +0 -128
- package/example/src/chevre/migrateOrderAcceptedOfferReservedTicketIdentifier.ts +0 -94
|
@@ -37,7 +37,7 @@ async function main() {
|
|
|
37
37
|
await cursor.eachAsync(async (doc) => {
|
|
38
38
|
i += 1;
|
|
39
39
|
const authorizeAction = <Pick<
|
|
40
|
-
chevre.factory.action.authorize.offer.eventService.IAction
|
|
40
|
+
chevre.factory.action.authorize.offer.eventService.IAction,
|
|
41
41
|
'id' | 'startDate' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
|
|
42
42
|
>>doc.toObject();
|
|
43
43
|
|
|
@@ -103,22 +103,5 @@ export declare class AcceptedOfferRepo {
|
|
|
103
103
|
$in: string[];
|
|
104
104
|
};
|
|
105
105
|
}, field: IDistinctField): Promise<string[]>;
|
|
106
|
-
/**
|
|
107
|
-
* 互換性維持対応専用
|
|
108
|
-
*/
|
|
109
|
-
fixReservedTicketIdentifier(params: {
|
|
110
|
-
project: {
|
|
111
|
-
id: string;
|
|
112
|
-
};
|
|
113
|
-
orderNumber: string;
|
|
114
|
-
acceptedOffers: {
|
|
115
|
-
itemOffered: {
|
|
116
|
-
id: string;
|
|
117
|
-
reservedTicket: {
|
|
118
|
-
identifier: string;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
}): Promise<void>;
|
|
123
106
|
}
|
|
124
107
|
export {};
|
|
@@ -227,36 +227,5 @@ class AcceptedOfferRepo {
|
|
|
227
227
|
.exec();
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
-
/**
|
|
231
|
-
* 互換性維持対応専用
|
|
232
|
-
*/
|
|
233
|
-
fixReservedTicketIdentifier(params) {
|
|
234
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
const doc = yield this.orderModel.findOneAndUpdate({
|
|
236
|
-
orderNumber: { $eq: params.orderNumber },
|
|
237
|
-
'project.id': { $eq: params.project.id },
|
|
238
|
-
typeOf: { $eq: factory.order.OrderType.Order },
|
|
239
|
-
'acceptedOffers.itemOffered.id': { $exists: true, $eq: params.acceptedOffers.itemOffered.id }
|
|
240
|
-
}, {
|
|
241
|
-
$set: {
|
|
242
|
-
'acceptedOffers.$[offer].itemOffered.reservedTicket.identifier': params.acceptedOffers.itemOffered.reservedTicket.identifier
|
|
243
|
-
}
|
|
244
|
-
}, {
|
|
245
|
-
timestamps: false,
|
|
246
|
-
arrayFilters: [{
|
|
247
|
-
'offer.itemOffered.typeOf': { $eq: factory.reservationType.EventReservation },
|
|
248
|
-
'offer.itemOffered.id': { $eq: params.acceptedOffers.itemOffered.id }
|
|
249
|
-
}],
|
|
250
|
-
new: true,
|
|
251
|
-
projection: {
|
|
252
|
-
_id: 1
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
.exec();
|
|
256
|
-
if (doc === null) {
|
|
257
|
-
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
230
|
}
|
|
262
231
|
exports.AcceptedOfferRepo = AcceptedOfferRepo;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
26
26
|
import { Connection, FilterQuery, UpdateQuery } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
|
-
export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction
|
|
28
|
+
export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction | factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.paymentMethod.any.IAction) : never;
|
|
29
29
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction<factory.action.update.replace.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
30
30
|
interface IAggregationByStatus {
|
|
31
31
|
actionCount: number;
|
|
@@ -10,7 +10,7 @@ interface IAcceptOfferOperationRepos {
|
|
|
10
10
|
transaction: TransactionRepo;
|
|
11
11
|
}
|
|
12
12
|
type IAcceptOfferOperation<T> = (repos: IAcceptOfferOperationRepos) => Promise<T>;
|
|
13
|
-
export type IAuthorizeActionWithInstrument = Pick<factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.offer.eventService.IAction
|
|
13
|
+
export type IAuthorizeActionWithInstrument = Pick<factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.offer.eventService.IAction, 'instrument'>;
|
|
14
14
|
export declare function acceptOffer(params: {
|
|
15
15
|
project: {
|
|
16
16
|
id: string;
|
|
@@ -21,7 +21,7 @@ declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
21
21
|
transactionNumber: string;
|
|
22
22
|
};
|
|
23
23
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
24
|
-
}): factory.action.authorize.offer.eventService.IAttributes
|
|
24
|
+
}): factory.action.authorize.offer.eventService.IAttributes;
|
|
25
25
|
declare function acceptedOffers2amount(params: {
|
|
26
26
|
acceptedOffers: IResultAcceptedOffer[];
|
|
27
27
|
}): number;
|
|
@@ -57,11 +57,9 @@ function createReserveTransactionStartParams(params) {
|
|
|
57
57
|
exports.createReserveTransactionStartParams = createReserveTransactionStartParams;
|
|
58
58
|
function createAuthorizeSeatReservationActionAttributes(params) {
|
|
59
59
|
var _a;
|
|
60
|
-
// const acceptedOffers = params.acceptedOffers;
|
|
61
60
|
const { event, transaction } = params;
|
|
62
61
|
const authorizeObjectEvent = {
|
|
63
62
|
id: event.id,
|
|
64
|
-
// イベント提供サービスを識別できるようにするために追加(2022-06-04~)
|
|
65
63
|
// offers: { // discontinue(2024-06-22~)
|
|
66
64
|
// offeredThrough: {
|
|
67
65
|
// identifier: factory.service.webAPI.Identifier.Chevre,
|
|
@@ -82,7 +80,7 @@ function createAuthorizeSeatReservationActionAttributes(params) {
|
|
|
82
80
|
const instrument = {
|
|
83
81
|
// typeOf: 'WebAPI',
|
|
84
82
|
typeOf: factory.assetTransactionType.Reserve,
|
|
85
|
-
identifier: factory.service.webAPI.Identifier.Chevre,
|
|
83
|
+
// identifier: factory.service.webAPI.Identifier.Chevre, // discontinue(2025-01-02~)
|
|
86
84
|
transactionNumber: params.instrument.transactionNumber
|
|
87
85
|
};
|
|
88
86
|
const agent = {
|
|
@@ -49,7 +49,7 @@ interface IAuthorizeRepos {
|
|
|
49
49
|
transactionNumber: TransactionNumberRepo;
|
|
50
50
|
}
|
|
51
51
|
type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings) => Promise<T>;
|
|
52
|
-
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction
|
|
52
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
53
53
|
type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail;
|
|
54
54
|
interface IAuthorizeOptions {
|
|
55
55
|
/**
|
|
@@ -9,7 +9,6 @@ import type { SettingRepo } from '../../../../repo/setting';
|
|
|
9
9
|
import type { StockHolderRepo } from '../../../../repo/stockHolder';
|
|
10
10
|
import type { TaskRepo } from '../../../../repo/task';
|
|
11
11
|
import type { TransactionRepo } from '../../../../repo/transaction';
|
|
12
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
13
12
|
interface IVoidTransactionRepos {
|
|
14
13
|
action: ActionRepo;
|
|
15
14
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -22,6 +21,6 @@ interface IVoidTransactionRepos {
|
|
|
22
21
|
transaction: TransactionRepo;
|
|
23
22
|
}
|
|
24
23
|
declare function processVoidTransaction4chevre(params: {
|
|
25
|
-
action: factory.action.authorize.offer.eventService.IAction
|
|
24
|
+
action: factory.action.authorize.offer.eventService.IAction;
|
|
26
25
|
}): (repos: IVoidTransactionRepos, settings: Settings) => Promise<void>;
|
|
27
26
|
export { processVoidTransaction4chevre };
|
|
@@ -9,10 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.processVoidTransaction4chevre =
|
|
12
|
+
exports.processVoidTransaction4chevre = void 0;
|
|
13
13
|
const factory = require("../../../../factory");
|
|
14
14
|
const reserve_1 = require("../../../assetTransaction/reserve");
|
|
15
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
16
15
|
function processVoidTransaction4chevre(params) {
|
|
17
16
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
18
17
|
// const transactionNumber = params.action.object.pendingTransaction?.transactionNumber;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type * as COA from '@motionpicture/coa-service';
|
|
2
|
-
import { ActionRepo } from '../../../../repo/action';
|
|
3
2
|
import * as factory from '../../../../factory';
|
|
4
|
-
|
|
3
|
+
import { ActionRepo } from '../../../../repo/action';
|
|
5
4
|
declare function processVoidTransaction4coa(params: {
|
|
6
|
-
action: factory.action.authorize.offer.eventService.IAction
|
|
5
|
+
action: factory.action.authorize.offer.eventService.IAction;
|
|
7
6
|
}): (repos: {
|
|
8
7
|
reserveService: COA.service.Reserve;
|
|
9
8
|
}) => Promise<void>;
|
|
@@ -9,10 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.processVoidTransactionByAcceptAction4coa = exports.processVoidTransaction4coa =
|
|
12
|
+
exports.processVoidTransactionByAcceptAction4coa = exports.processVoidTransaction4coa = void 0;
|
|
13
13
|
const http_status_1 = require("http-status");
|
|
14
|
-
const factory = require("../../../../factory");
|
|
15
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
16
14
|
function processVoidTransaction4coa(params) {
|
|
17
15
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
16
|
// object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
|
|
@@ -15,12 +15,13 @@ const any_1 = require("../any");
|
|
|
15
15
|
const processVoidTransaction4chevre_1 = require("./voidTransaction/processVoidTransaction4chevre");
|
|
16
16
|
const processVoidTransaction4coa_1 = require("./voidTransaction/processVoidTransaction4coa");
|
|
17
17
|
const voidTransactionByActionId_1 = require("./voidTransactionByActionId");
|
|
18
|
-
var WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
19
18
|
/**
|
|
20
19
|
* 興行オファー承認取消(タスクから実行 or apiから実行))
|
|
21
20
|
* 取引中の承認アクション全てについて処理する or 特定の承認アクションについて処理する
|
|
22
21
|
*/
|
|
22
|
+
// tslint:disable-next-line:max-func-body-length
|
|
23
23
|
function voidTransaction(params) {
|
|
24
|
+
// tslint:disable-next-line:max-func-body-length
|
|
24
25
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
26
|
var _a, _b, _c;
|
|
26
27
|
// support void by action ID(2024-05-26~)
|
|
@@ -74,19 +75,22 @@ function voidTransaction(params) {
|
|
|
74
75
|
}
|
|
75
76
|
yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
76
77
|
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id, cancelAction });
|
|
77
|
-
switch (action.instrument.
|
|
78
|
-
case WebAPIIdentifier.COA:
|
|
78
|
+
switch (action.instrument.typeOf) {
|
|
79
|
+
// case WebAPIIdentifier.COA:
|
|
80
|
+
case factory.assetTransactionType.COAReserveTransaction:
|
|
79
81
|
const { reserveService } = repos;
|
|
80
82
|
if (reserveService === undefined) {
|
|
81
83
|
throw new factory.errors.Internal('repos.reserveService required');
|
|
82
84
|
}
|
|
83
85
|
yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
|
|
84
|
-
action: action
|
|
86
|
+
// action: <factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.COA>>action
|
|
87
|
+
action
|
|
85
88
|
})({ reserveService });
|
|
86
89
|
break;
|
|
87
90
|
default:
|
|
88
91
|
yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
|
|
89
|
-
action: action
|
|
92
|
+
// action: <factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.Chevre>>action
|
|
93
|
+
action
|
|
90
94
|
})(repos, settings);
|
|
91
95
|
}
|
|
92
96
|
})));
|
|
@@ -51,19 +51,19 @@ function voidTransactionByActionId(params) {
|
|
|
51
51
|
orderNumber: orderNumberByTransaction
|
|
52
52
|
})(repos);
|
|
53
53
|
}
|
|
54
|
-
switch (action.instrument.
|
|
55
|
-
case factory.
|
|
54
|
+
switch (action.instrument.typeOf) {
|
|
55
|
+
case factory.assetTransactionType.COAReserveTransaction:
|
|
56
56
|
const { reserveService } = repos;
|
|
57
57
|
if (reserveService === undefined) {
|
|
58
58
|
throw new factory.errors.Internal('repos.reserveService required');
|
|
59
59
|
}
|
|
60
60
|
yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
|
|
61
|
-
action
|
|
61
|
+
action
|
|
62
62
|
})({ reserveService });
|
|
63
63
|
break;
|
|
64
64
|
default:
|
|
65
65
|
yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
|
|
66
|
-
action
|
|
66
|
+
action
|
|
67
67
|
})(repos, settings);
|
|
68
68
|
// const transactionNumber = action.object.pendingTransaction?.transactionNumber;
|
|
69
69
|
// if (typeof transactionNumber === 'string') {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import { IAcceptedOfferWithoutDetail } from './factory';
|
|
3
3
|
import * as factory from '../../../../factory';
|
|
4
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
5
4
|
export interface IAppliesToSurfrock {
|
|
6
5
|
identifier: string;
|
|
7
6
|
serviceOutput: {
|
|
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validateOffers = exports.createAcceptedOffersWithoutDetails =
|
|
12
|
+
exports.validateOffers = exports.createAcceptedOffersWithoutDetails = void 0;
|
|
13
13
|
const COA = require("@motionpicture/coa-service");
|
|
14
14
|
const http_status_1 = require("http-status");
|
|
15
15
|
const errorHandler_1 = require("../../../../errorHandler");
|
|
16
16
|
const factory = require("../../../../factory");
|
|
17
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
18
17
|
function createAcceptedOffersWithoutDetails(params) {
|
|
19
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
19
|
const { listSeat } = yield repos.reserveService.stateReserveSeat(params.coaInfo);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type * as COAService from '@motionpicture/coa-service';
|
|
2
2
|
import * as factory from '../../../../factory';
|
|
3
3
|
import { IMinimizedIndividualEvent } from '../../../../factory/event';
|
|
4
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
5
4
|
export type IAcceptedOffer4COA = factory.action.accept.coaOffer.IAcceptedOffer4COA;
|
|
6
5
|
export type IRequestBody = COAService.factory.reserve.IUpdTmpReserveSeatArgs;
|
|
7
6
|
export type IResponseBody = COAService.factory.reserve.IUpdTmpReserveSeatResult;
|
|
@@ -16,7 +15,7 @@ export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
16
15
|
};
|
|
17
16
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
18
17
|
pendingTransaction: factory.action.authorize.offer.eventService.ICOAPendingTransaction;
|
|
19
|
-
}): factory.action.authorize.offer.eventService.IAttributes
|
|
18
|
+
}): factory.action.authorize.offer.eventService.IAttributes;
|
|
20
19
|
/**
|
|
21
20
|
* 供給情報から承認アクションの価格を導き出す
|
|
22
21
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.responseBody2acceptedOffers4result = exports.offers2resultPrice = exports.createAuthorizeSeatReservationActionAttributes =
|
|
3
|
+
exports.responseBody2acceptedOffers4result = exports.offers2resultPrice = exports.createAuthorizeSeatReservationActionAttributes = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const util = require("util");
|
|
6
6
|
const factory = require("../../../../factory");
|
|
7
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
8
7
|
function createAuthorizeSeatReservationActionAttributes(params) {
|
|
9
8
|
var _a;
|
|
10
9
|
const transaction = params.transaction;
|
|
@@ -31,7 +30,7 @@ function createAuthorizeSeatReservationActionAttributes(params) {
|
|
|
31
30
|
const instrument = {
|
|
32
31
|
// typeOf: 'WebAPI',
|
|
33
32
|
typeOf: factory.assetTransactionType.COAReserveTransaction,
|
|
34
|
-
identifier: factory.service.webAPI.Identifier.COA
|
|
33
|
+
// identifier: factory.service.webAPI.Identifier.COA,// discontinue(2025-01-02~)
|
|
35
34
|
transactionNumber: params.pendingTransaction.transactionNumber
|
|
36
35
|
};
|
|
37
36
|
return {
|
|
@@ -164,7 +163,7 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
164
163
|
const additionalTicketText = (_d = (_c = requestedOffer.itemOffered) === null || _c === void 0 ? void 0 : _c.serviceOutput) === null || _d === void 0 ? void 0 : _d.additionalTicketText;
|
|
165
164
|
const issuedThrough = {
|
|
166
165
|
typeOf: factory.product.ProductType.EventService,
|
|
167
|
-
id: '',
|
|
166
|
+
// id: '', // discontinue(2025-01-02~)
|
|
168
167
|
availableChannel: {
|
|
169
168
|
typeOf: 'ServiceChannel',
|
|
170
169
|
serviceLocation: {
|
|
@@ -10,7 +10,6 @@ import { IRequestBody, IResponseBody } from './authorize/factory';
|
|
|
10
10
|
import { IAcceptedOfferBeforeAuthorize4COA } from './authorize/validateAcceptedOffers';
|
|
11
11
|
import * as factory from '../../../factory';
|
|
12
12
|
export { IRequestBody, IResponseBody };
|
|
13
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
14
13
|
export type IAuthorizeActionResult = factory.action.authorize.offer.eventService.IResult;
|
|
15
14
|
export interface IAuthorizeRepos {
|
|
16
15
|
action: ActionRepo;
|
|
@@ -23,7 +22,7 @@ export interface IAuthorizeRepos {
|
|
|
23
22
|
transaction: TransactionRepo;
|
|
24
23
|
}
|
|
25
24
|
export type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
|
|
26
|
-
export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction
|
|
25
|
+
export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
27
26
|
/**
|
|
28
27
|
* COA興行オファー承認
|
|
29
28
|
*/
|
|
@@ -9,13 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.authorize =
|
|
12
|
+
exports.authorize = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const any_1 = require("../any");
|
|
15
15
|
const factory_1 = require("./authorize/factory");
|
|
16
16
|
const validateAcceptedOffers_1 = require("./authorize/validateAcceptedOffers");
|
|
17
17
|
const factory = require("../../../factory");
|
|
18
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
19
18
|
/**
|
|
20
19
|
* COA興行オファー承認
|
|
21
20
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IAuthorizeOperation } from './authorize';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction
|
|
3
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
4
4
|
/**
|
|
5
5
|
* 採用アクションからCOA興行オファー承認
|
|
6
6
|
*/
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { IAuthorizeOfferAction, IAuthorizeOperation } from './authorize';
|
|
2
2
|
import { IAcceptedOfferBeforeAuthorize4COA } from './authorize/validateAcceptedOffers';
|
|
3
|
-
import * as factory from '../../../factory';
|
|
4
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
5
3
|
/**
|
|
6
4
|
* COA興行オファー承認のオファーを変更
|
|
7
5
|
*/
|
|
@@ -9,13 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.changeOffers =
|
|
12
|
+
exports.changeOffers = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const any_1 = require("../any");
|
|
15
15
|
const factory_1 = require("./authorize/factory");
|
|
16
16
|
const validateAcceptedOffers_1 = require("./authorize/validateAcceptedOffers");
|
|
17
17
|
const factory = require("../../../factory");
|
|
18
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
19
18
|
/**
|
|
20
19
|
* COA興行オファー承認のオファーを変更
|
|
21
20
|
*/
|
|
@@ -9,7 +9,7 @@ declare function createConfirmReservationActionObject4ChevreByOrder(params: {
|
|
|
9
9
|
order: Pick<factory.order.IOrder, 'confirmationNumber' | 'orderNumber'> & {
|
|
10
10
|
serialNumbers: string[];
|
|
11
11
|
};
|
|
12
|
-
}): factory.action.interact.confirm.reservation.
|
|
12
|
+
}): factory.action.interact.confirm.reservation.IObject4Chevre[];
|
|
13
13
|
declare function createConfirmReservationActionObject4COAByOrder(params: {
|
|
14
14
|
order: {
|
|
15
15
|
serialNumbers: string[];
|
|
@@ -67,12 +67,6 @@ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder, opti
|
|
|
67
67
|
agent: order.project,
|
|
68
68
|
purpose: simpleOrder
|
|
69
69
|
// instrument廃止(2024-03-13~)
|
|
70
|
-
// instrument: {
|
|
71
|
-
// typeOf: 'WebAPI',
|
|
72
|
-
// identifier: (confirmObject.typeOf === factory.assetTransactionType.COAReserveTransaction)
|
|
73
|
-
// ? factory.service.webAPI.Identifier.COA
|
|
74
|
-
// : factory.service.webAPI.Identifier.Chevre
|
|
75
|
-
// }
|
|
76
70
|
};
|
|
77
71
|
const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', data.project.id, factory.taskName.ConfirmReserveTransaction, data.purpose.typeOf, data.purpose.orderNumber, data.object.typeOf, data.object.transactionNumber);
|
|
78
72
|
const confirmReserveTransactionTask = {
|
|
@@ -113,7 +113,8 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
|
113
113
|
},
|
|
114
114
|
agent: order.project,
|
|
115
115
|
purpose: simpleOrder,
|
|
116
|
-
|
|
116
|
+
// discontinue(2025-01-02~)
|
|
117
|
+
// instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.COA },
|
|
117
118
|
recipient: returnActionRecipient
|
|
118
119
|
};
|
|
119
120
|
break;
|
|
@@ -127,7 +128,8 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
|
127
128
|
},
|
|
128
129
|
agent: order.project,
|
|
129
130
|
purpose: simpleOrder,
|
|
130
|
-
|
|
131
|
+
// discontinue(2025-01-02~)
|
|
132
|
+
// instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre },
|
|
131
133
|
recipient: returnActionRecipient
|
|
132
134
|
};
|
|
133
135
|
}
|
|
@@ -51,12 +51,12 @@ function reservationOffers2orderedItem(params) {
|
|
|
51
51
|
startDate: reservationFor.startDate,
|
|
52
52
|
endDate: reservationFor.endDate
|
|
53
53
|
};
|
|
54
|
-
return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf,
|
|
55
|
-
? { serviceType: issuedThrough.serviceType }
|
|
56
|
-
: undefined), { serviceOutput: {
|
|
54
|
+
return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf, serviceOutput: {
|
|
57
55
|
typeOf: factory.reservationType.EventReservation,
|
|
58
56
|
reservationFor: reservationFor4orderedItem
|
|
59
|
-
} })
|
|
57
|
+
} }, (typeof issuedThrough.id === 'string') ? { id: issuedThrough.id } : undefined), (typeof ((_a = issuedThrough.serviceType) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
58
|
+
? { serviceType: issuedThrough.serviceType }
|
|
59
|
+
: undefined);
|
|
60
60
|
}
|
|
61
61
|
else if (reservationFor.typeOf === factory.tripType.BusTrip
|
|
62
62
|
&& issuedThrough.typeOf === factory.product.ProductType.Transportation) {
|
|
@@ -76,6 +76,10 @@ function onReservationConfirmed(confirmedReservations) {
|
|
|
76
76
|
typeOf,
|
|
77
77
|
reservedTicket }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined), (modifiedTime instanceof Date) ? { modifiedTime } : undefined), (price !== undefined) ? { price } : undefined), (programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined), (Array.isArray(subReservation)) ? { subReservation } : undefined);
|
|
78
78
|
});
|
|
79
|
+
if (typeof issuedThrough.id !== 'string') {
|
|
80
|
+
// COA予約では予約アクションを想定していないので、興行idは必ず存在するはず
|
|
81
|
+
throw new factory.errors.Internal('reservation.issuedThrough.id must be string');
|
|
82
|
+
}
|
|
79
83
|
const informObject = Object.assign({ bookingTime,
|
|
80
84
|
issuedThrough,
|
|
81
85
|
project,
|
|
@@ -36,13 +36,12 @@ function useReservation(params) {
|
|
|
36
36
|
id: reservationId,
|
|
37
37
|
inclusion: ['issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// reservationNumber: reservation.reservationNumber, reservedTicket: reservation.reservedTicket, typeOf: reservation.typeOf
|
|
44
|
-
// };
|
|
39
|
+
if (typeof reservation.issuedThrough.id !== 'string') {
|
|
40
|
+
// COA予約では予約使用アクションを想定していないので、興行idは必ず存在するはず
|
|
41
|
+
throw new factory.errors.Internal('reservation.issuedThrough.id must be string');
|
|
42
|
+
}
|
|
45
43
|
const { reservedTicket } = reservation;
|
|
44
|
+
// optimize(2024-05-07~)
|
|
46
45
|
const reservationAsObject = {
|
|
47
46
|
id: reservation.id,
|
|
48
47
|
reservationNumber: reservation.reservationNumber,
|
|
@@ -66,10 +66,10 @@ exports.call = call;
|
|
|
66
66
|
*/
|
|
67
67
|
function returnReserve(params) {
|
|
68
68
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const { agent,
|
|
70
|
-
const returnActionAttributes = Object.assign({ agent,
|
|
69
|
+
const { agent, object, project, purpose, recipient, typeOf, sameAs } = params;
|
|
70
|
+
const returnActionAttributes = Object.assign({ agent, object, project, purpose, recipient, typeOf }, (typeof (sameAs === null || sameAs === void 0 ? void 0 : sameAs.id) === 'string') ? { sameAs: { id: sameAs.id, typeOf: 'Task' } } : undefined);
|
|
71
71
|
let recipe;
|
|
72
|
-
if (params.
|
|
72
|
+
if (params.object.typeOf === factory.assetTransactionType.COAReserveTransaction) {
|
|
73
73
|
recipe = (0, factory_1.processReturnCOAReserveResult2recipe)({
|
|
74
74
|
processReturnCOAReserveResult: { stateReserveArgs: params.object },
|
|
75
75
|
project: { id: project.id }
|
|
@@ -78,8 +78,8 @@ function returnReserve(params) {
|
|
|
78
78
|
const action = yield repos.action.start(returnActionAttributes, Object.assign({}, (recipe !== undefined) ? { recipe } : undefined // add recipe(2024-06-11~)
|
|
79
79
|
));
|
|
80
80
|
try {
|
|
81
|
-
switch (params.
|
|
82
|
-
case factory.
|
|
81
|
+
switch (params.object.typeOf) {
|
|
82
|
+
case factory.assetTransactionType.COAReserveTransaction:
|
|
83
83
|
const processReturnCOAReserveResult = yield CancelReservationCOAService.confirm({ object: params.object })({
|
|
84
84
|
reserveService: repos.reserveService
|
|
85
85
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
2
|
import { placeOrder as PlaceOrderFactory } from '../../../../factory/transaction';
|
|
3
|
-
export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction
|
|
3
|
+
export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction;
|
|
4
4
|
export type IAuthorizeProductOffer = factory.action.authorize.offer.product.IAction;
|
|
5
5
|
export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyTransfer.IAction;
|
|
6
6
|
export type IAuthorizePaymentAction = Pick<factory.action.authorize.paymentMethod.any.IAction, 'id' | 'result' | 'endDate' | 'instrument'> & {
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.392.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.19.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.392.0-alpha.2",
|
|
15
|
+
"@cinerino/sdk": "10.19.0-alpha.3",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.8.0-alpha.
|
|
115
|
+
"version": "22.8.0-alpha.2"
|
|
116
116
|
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
// tslint:disable-next-line:max-func-body-length
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
11
|
-
const cursor = actionRepo.getCursor(
|
|
12
|
-
{
|
|
13
|
-
// _id: { $eq: '66697991037c9d7243208261' },
|
|
14
|
-
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
15
|
-
// actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
16
|
-
// startDate: {
|
|
17
|
-
// $lte: moment()
|
|
18
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
19
|
-
// .add(-180, 'days'),
|
|
20
|
-
// $gte: moment()
|
|
21
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
22
|
-
// .add(-180, 'days')
|
|
23
|
-
// },
|
|
24
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
|
|
25
|
-
'instrument.typeOf': { $exists: true, $eq: chevre.factory.assetTransactionType.COAReserveTransaction }
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
__id: 1, startDate: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
console.log('actions found');
|
|
32
|
-
|
|
33
|
-
let i = 0;
|
|
34
|
-
let updateCount = 0;
|
|
35
|
-
const saveResultCount = 0;
|
|
36
|
-
// tslint:disable-next-line:max-func-body-length
|
|
37
|
-
await cursor.eachAsync(async (doc) => {
|
|
38
|
-
i += 1;
|
|
39
|
-
const authorizeAction = <Pick<
|
|
40
|
-
chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
|
|
41
|
-
'id' | 'startDate' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
|
|
42
|
-
>>doc.toObject();
|
|
43
|
-
|
|
44
|
-
let migrated = false;
|
|
45
|
-
if (authorizeAction.instrument.typeOf === chevre.factory.assetTransactionType.Reserve) {
|
|
46
|
-
migrated = true;
|
|
47
|
-
} else {
|
|
48
|
-
const acceptedOffers = (<any>authorizeAction.object).acceptedOffer;
|
|
49
|
-
if (acceptedOffers === undefined) {
|
|
50
|
-
migrated = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (migrated) {
|
|
55
|
-
console.log(
|
|
56
|
-
'already migrated.',
|
|
57
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate,
|
|
58
|
-
i, updateCount, saveResultCount);
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
// optimize action
|
|
62
|
-
let unsetResult: any;
|
|
63
|
-
unsetResult = await actionRepo.unsetUnnecessaryFields({
|
|
64
|
-
filter: { _id: { $eq: authorizeAction.id } },
|
|
65
|
-
$unset: {
|
|
66
|
-
'object.acceptedOffer': 1
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
updateCount += 1;
|
|
70
|
-
console.log(
|
|
71
|
-
'result unset. unsetResult:', unsetResult,
|
|
72
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate, i,
|
|
73
|
-
updateCount, saveResultCount);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
console.log(i, 'actions checked');
|
|
78
|
-
console.log(updateCount, 'actions updated');
|
|
79
|
-
console.log(saveResultCount, 'result saved');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
main()
|
|
83
|
-
.then()
|
|
84
|
-
.catch(console.error);
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
type IInstrumentAsAssetTransaction =
|
|
8
|
-
chevre.factory.action.authorize.offer.eventService.IInstrumentAsAssetTransaction<chevre.factory.service.webAPI.Identifier>;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
15
|
-
const cursor = actionRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
// _id: { $eq: '65eb218c1fb66e469cb2ba7e' },
|
|
18
|
-
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
19
|
-
// actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
20
|
-
startDate: {
|
|
21
|
-
// $lte: moment()
|
|
22
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
23
|
-
// .add(-90, 'days'),
|
|
24
|
-
$lte: moment('2023-07-22T01:17:42.541Z')
|
|
25
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
26
|
-
.toDate()
|
|
27
|
-
// $gte: moment()
|
|
28
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
29
|
-
// .add(-180, 'days')
|
|
30
|
-
},
|
|
31
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
|
|
32
|
-
'project.id': { $ne: 'sskts-production' }
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
console.log('actions found');
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
let saveResultCount = 0;
|
|
43
|
-
// tslint:disable-next-line:max-func-body-length
|
|
44
|
-
await cursor.eachAsync(async (doc) => {
|
|
45
|
-
i += 1;
|
|
46
|
-
const authorizeAction = <Pick<
|
|
47
|
-
chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
|
|
48
|
-
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
|
|
49
|
-
>>doc.toObject();
|
|
50
|
-
const { instrument } = authorizeAction;
|
|
51
|
-
|
|
52
|
-
let migrated = false;
|
|
53
|
-
if ((instrument.typeOf === chevre.factory.assetTransactionType.COAReserveTransaction
|
|
54
|
-
|| instrument.typeOf === chevre.factory.assetTransactionType.Reserve)
|
|
55
|
-
&& typeof instrument.transactionNumber === 'string'
|
|
56
|
-
) {
|
|
57
|
-
migrated = true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (migrated) {
|
|
61
|
-
console.log(
|
|
62
|
-
'already migrated.',
|
|
63
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
64
|
-
} else {
|
|
65
|
-
console.log(
|
|
66
|
-
'redefining instrument as AssetTransaction...',
|
|
67
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
68
|
-
if ((<any>instrument).typeOf !== 'WebAPI') {
|
|
69
|
-
throw new Error(`instrument.typeOf must be WebAPI [${authorizeAction.id}]`);
|
|
70
|
-
}
|
|
71
|
-
const pendingTransaction = (authorizeAction.object).pendingTransaction;
|
|
72
|
-
const transactionNumber = pendingTransaction?.transactionNumber;
|
|
73
|
-
let newInstrument: IInstrumentAsAssetTransaction;
|
|
74
|
-
if (pendingTransaction?.typeOf === chevre.factory.assetTransactionType.COAReserveTransaction) {
|
|
75
|
-
newInstrument = {
|
|
76
|
-
typeOf: chevre.factory.assetTransactionType.COAReserveTransaction,
|
|
77
|
-
identifier: chevre.factory.service.webAPI.Identifier.COA,
|
|
78
|
-
...(typeof transactionNumber === 'string') ? { transactionNumber } : { transactionNumber: '' }
|
|
79
|
-
};
|
|
80
|
-
} else if (pendingTransaction?.typeOf === chevre.factory.assetTransactionType.Reserve) {
|
|
81
|
-
if (typeof transactionNumber !== 'string' || transactionNumber === '') {
|
|
82
|
-
throw new Error(`pendingTransaction must exist [${authorizeAction.id}]`);
|
|
83
|
-
}
|
|
84
|
-
newInstrument = {
|
|
85
|
-
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
86
|
-
identifier: chevre.factory.service.webAPI.Identifier.Chevre,
|
|
87
|
-
transactionNumber
|
|
88
|
-
};
|
|
89
|
-
} else {
|
|
90
|
-
if (instrument.identifier === chevre.factory.service.webAPI.Identifier.COA) {
|
|
91
|
-
newInstrument = {
|
|
92
|
-
typeOf: chevre.factory.assetTransactionType.COAReserveTransaction,
|
|
93
|
-
identifier: chevre.factory.service.webAPI.Identifier.COA,
|
|
94
|
-
...(typeof transactionNumber === 'string') ? { transactionNumber } : { transactionNumber: '' }
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
throw new Error(`invalid pendingTransaction [${(<any>pendingTransaction)?.typeOf}] [${authorizeAction.id}]`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
console.log(
|
|
102
|
-
'saving action...',
|
|
103
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
104
|
-
// tslint:disable-next-line:no-null-keyword
|
|
105
|
-
console.dir({ instrument, newInstrument }, { depth: null });
|
|
106
|
-
await actionRepo.findByIdAndUpdate({
|
|
107
|
-
id: authorizeAction.id,
|
|
108
|
-
update: {
|
|
109
|
-
$set: {
|
|
110
|
-
instrument: newInstrument
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
saveResultCount += 1;
|
|
115
|
-
console.log(
|
|
116
|
-
'action saved.',
|
|
117
|
-
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
console.log(i, 'actions checked');
|
|
122
|
-
console.log(updateCount, 'actions updated');
|
|
123
|
-
console.log(saveResultCount, 'result saved');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
main()
|
|
127
|
-
.then()
|
|
128
|
-
.catch(console.error);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
function createReservedTicketIdentifier(offer: chevre.factory.order.IAcceptedOffer<chevre.factory.order.IReservation>) {
|
|
10
|
-
let reservedTicketIdentifierShouldBe = `${offer.itemOffered.reservationFor.id}:${offer.itemOffered.id}`;
|
|
11
|
-
if (typeof offer.itemOffered.reservedTicket.ticketedSeat?.seatNumber === 'string') {
|
|
12
|
-
reservedTicketIdentifierShouldBe = `${offer.itemOffered.reservationFor.id}:${offer.itemOffered.reservedTicket.ticketedSeat.seatSection}:${offer.itemOffered.reservedTicket.ticketedSeat.seatNumber}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return reservedTicketIdentifierShouldBe;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function main() {
|
|
19
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
20
|
-
|
|
21
|
-
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
22
|
-
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
23
|
-
|
|
24
|
-
const cursor = orderRepo.getCursor(
|
|
25
|
-
{
|
|
26
|
-
'acceptedOffers.itemOffered.typeOf': { $exists: true, $eq: chevre.factory.reservationType.EventReservation },
|
|
27
|
-
// 'project.id': { $eq: project.id },
|
|
28
|
-
// orderNumber: { $eq: 'ASK8-6367700-4398526' },
|
|
29
|
-
orderDate: {
|
|
30
|
-
$gte: moment()
|
|
31
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
32
|
-
.add(-13, 'months')
|
|
33
|
-
.toDate()
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
orderDate: 1,
|
|
38
|
-
orderNumber: 1,
|
|
39
|
-
project: 1,
|
|
40
|
-
acceptedOffers: 1
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
console.log('orders found');
|
|
44
|
-
|
|
45
|
-
let i = 0;
|
|
46
|
-
let updateCount = 0;
|
|
47
|
-
await cursor.eachAsync(async (doc) => {
|
|
48
|
-
i += 1;
|
|
49
|
-
const order: Pick<
|
|
50
|
-
chevre.factory.order.IOrder,
|
|
51
|
-
'orderDate' | 'orderNumber' | 'project'
|
|
52
|
-
> & {
|
|
53
|
-
acceptedOffers: chevre.factory.order.IAcceptedOffer<chevre.factory.order.IReservation>[];
|
|
54
|
-
} = doc.toObject();
|
|
55
|
-
|
|
56
|
-
const alreadyMigrated = order.acceptedOffers.every((offer) => {
|
|
57
|
-
const reservedTicketIdentifierShouldBe = createReservedTicketIdentifier(offer);
|
|
58
|
-
|
|
59
|
-
return typeof offer.itemOffered.reservedTicket.identifier === 'string'
|
|
60
|
-
&& offer.itemOffered.reservedTicket.identifier.length > 0
|
|
61
|
-
&& offer.itemOffered.reservedTicket.identifier === reservedTicketIdentifierShouldBe;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (alreadyMigrated) {
|
|
65
|
-
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
66
|
-
} else {
|
|
67
|
-
for (const offer of order.acceptedOffers) {
|
|
68
|
-
const reservedTicketIdentifierShouldBe = createReservedTicketIdentifier(offer);
|
|
69
|
-
console.log(
|
|
70
|
-
'updating...',
|
|
71
|
-
order.project.id, order.orderNumber, order.orderDate, offer.itemOffered.id, reservedTicketIdentifierShouldBe, i);
|
|
72
|
-
await acceptedOfferRepo.fixReservedTicketIdentifier({
|
|
73
|
-
project: { id: order.project.id },
|
|
74
|
-
orderNumber: order.orderNumber,
|
|
75
|
-
acceptedOffers: {
|
|
76
|
-
itemOffered: {
|
|
77
|
-
id: offer.itemOffered.id,
|
|
78
|
-
reservedTicket: { identifier: reservedTicketIdentifierShouldBe }
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
updateCount += 1;
|
|
84
|
-
console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
console.log(i, 'orders checked');
|
|
89
|
-
console.log(updateCount, 'orders updated');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
main()
|
|
93
|
-
.then()
|
|
94
|
-
.catch(console.error);
|