@chevre/domain 21.33.0-alpha.9 → 21.33.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/findTransactionById.ts +8 -5
- package/example/src/chevre/migratePayCreditCardRecipes.ts +104 -0
- package/example/src/chevre/migratePayMovieTicketRecipes.ts +100 -0
- package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +147 -0
- package/example/src/chevre/reexportTasksByExportAction.ts +37 -0
- package/example/src/chevre/searchActionsBySameAs.ts +2 -1
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +26 -6
- package/example/src/chevre/searchTransactions.ts +1 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +3 -18
- package/lib/chevre/repo/action.d.ts +51 -0
- package/lib/chevre/repo/action.js +122 -2
- package/lib/chevre/repo/assetTransaction.d.ts +9 -2
- package/lib/chevre/repo/assetTransaction.js +48 -3
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +89 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +23 -25
- package/lib/chevre/repo/mongoose/schemas/transaction.js +5 -52
- package/lib/chevre/repo/transaction.d.ts +26 -11
- package/lib/chevre/repo/transaction.js +89 -17
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -2
- package/lib/chevre/service/assetTransaction/pay.js +49 -5
- package/lib/chevre/service/offer/event/voidTransaction.js +4 -6
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +23 -0
- package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +155 -0
- package/lib/chevre/service/payment/any.d.ts +10 -2
- package/lib/chevre/service/payment/any.js +83 -114
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +41 -0
- package/lib/chevre/service/payment/creditCard/authorize.js +216 -0
- package/lib/chevre/service/payment/creditCard/factory.d.ts +35 -0
- package/lib/chevre/service/payment/creditCard/factory.js +57 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +20 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +47 -0
- package/lib/chevre/service/payment/creditCard/gmoError.d.ts +34 -0
- package/lib/chevre/service/payment/creditCard/gmoError.js +8 -0
- package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +20 -0
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +151 -0
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +26 -0
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +196 -0
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +13 -0
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +62 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +13 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +90 -0
- package/lib/chevre/service/payment/creditCard.d.ts +7 -106
- package/lib/chevre/service/payment/creditCard.js +12 -638
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +38 -0
- package/lib/chevre/service/payment/movieTicket/authorize.js +71 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +22 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +109 -0
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +52 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +114 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +24 -0
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +157 -0
- package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.d.ts → processPurchaseNumberAuth.d.ts} +5 -6
- package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js} +4 -8
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +21 -0
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +248 -0
- package/lib/chevre/service/payment/movieTicket/validation.js +3 -3
- package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +12 -0
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +74 -0
- package/lib/chevre/service/payment/movieTicket.d.ts +7 -75
- package/lib/chevre/service/payment/movieTicket.js +11 -567
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
- package/lib/chevre/service/payment.d.ts +9 -1
- package/lib/chevre/service/payment.js +2 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +2 -1
- package/lib/chevre/service/task/authorizePayment.js +2 -1
- package/lib/chevre/service/task/checkMovieTicket.js +1 -1
- package/lib/chevre/service/task/pay.d.ts +2 -2
- package/lib/chevre/service/task/pay.js +3 -2
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -1
- package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidPayTransaction.js +2 -4
- package/lib/chevre/service/task/voidPayment.js +0 -1
- package/lib/chevre/service/task.js +2 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +2 -2
- package/lib/chevre/service/transaction/placeOrder.js +2 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +4 -3
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +2 -2
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +0 -152
- package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +0 -95
|
@@ -45,7 +45,7 @@ function call(params) {
|
|
|
45
45
|
catch (error) {
|
|
46
46
|
let throwsError = true;
|
|
47
47
|
// アクションが存在すればタスクを実行済扱いにする
|
|
48
|
-
const action = (yield actionRepo.searchBySameAs(Object.assign({ sameAs: { id: { $eq: params.id } } }, (typeof ((_a = params.data.purpose) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
48
|
+
const action = (yield actionRepo.searchBySameAs(Object.assign({ sameAs: { id: { $eq: params.id } }, typeOf: { $eq: factory.actionType.CheckAction } }, (typeof ((_a = params.data.purpose) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
49
49
|
? { purpose: { id: { $eq: params.data.purpose.id } } }
|
|
50
50
|
: undefined))).shift();
|
|
51
51
|
if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(params: Pick<factory.task.pay.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -26,9 +26,10 @@ const PaymentService = require("../payment");
|
|
|
26
26
|
/**
|
|
27
27
|
* タスク実行関数
|
|
28
28
|
*/
|
|
29
|
-
function call(
|
|
29
|
+
function call(params) {
|
|
30
30
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
yield PaymentService.pay(data)(
|
|
31
|
+
yield PaymentService.pay(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~)
|
|
32
|
+
}))({
|
|
32
33
|
acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
|
|
33
34
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
34
35
|
action: new action_1.MongoRepository(settings.connection),
|
|
@@ -50,7 +50,8 @@ function call(params) {
|
|
|
50
50
|
// アクションが存在すればタスクを実行済扱いにする
|
|
51
51
|
const action = (yield actionRepo.searchBySameAs({
|
|
52
52
|
sameAs: { id: { $eq: params.id } },
|
|
53
|
-
purpose: { id: { $eq: params.data.purpose.id } }
|
|
53
|
+
purpose: { id: { $eq: params.data.purpose.id } },
|
|
54
|
+
typeOf: { $eq: factory.actionType.AcceptAction }
|
|
54
55
|
})).shift();
|
|
55
56
|
if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
|
|
56
57
|
throwsError = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(params: Pick<factory.task.ITask<factory.taskName.VoidPayTransaction>, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -15,7 +15,6 @@ const action_1 = require("../../repo/action");
|
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
16
|
const paymentService_1 = require("../../repo/paymentService");
|
|
17
17
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
18
|
-
// import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
19
18
|
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
20
19
|
const task_1 = require("../../repo/task");
|
|
21
20
|
const transaction_1 = require("../../repo/transaction");
|
|
@@ -23,16 +22,15 @@ const AnyPaymentService = require("../payment/any");
|
|
|
23
22
|
/**
|
|
24
23
|
* タスク実行関数
|
|
25
24
|
*/
|
|
26
|
-
function call(
|
|
25
|
+
function call(params) {
|
|
27
26
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
yield AnyPaymentService.voidPayTransaction(data)({
|
|
27
|
+
yield AnyPaymentService.voidPayTransaction(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
|
|
29
28
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
30
29
|
action: new action_1.MongoRepository(settings.connection),
|
|
31
30
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
32
31
|
paymentAccepted: new sellerPaymentAccepted_1.MongoRepository(settings.connection),
|
|
33
32
|
paymentService: new paymentService_1.MongoRepository(settings.connection),
|
|
34
33
|
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(settings.connection),
|
|
35
|
-
// project: new ProjectRepo(settings.connection),
|
|
36
34
|
task: new task_1.MongoRepository(settings.connection),
|
|
37
35
|
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
38
36
|
});
|
|
@@ -32,7 +32,6 @@ function call(data) {
|
|
|
32
32
|
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(settings.connection),
|
|
33
33
|
product: new product_1.MongoRepository(settings.connection),
|
|
34
34
|
project: new project_1.MongoRepository(settings.connection),
|
|
35
|
-
// seller: new SellerRepo(settings.connection),
|
|
36
35
|
task: new task_1.MongoRepository(settings.connection)
|
|
37
36
|
});
|
|
38
37
|
});
|
|
@@ -107,8 +107,10 @@ function execute(task) {
|
|
|
107
107
|
case factory.taskName.AcceptCOAOffer:
|
|
108
108
|
case factory.taskName.AuthorizePayment:
|
|
109
109
|
case factory.taskName.CheckMovieTicket:
|
|
110
|
+
case factory.taskName.Pay:
|
|
110
111
|
case factory.taskName.PublishPaymentUrl:
|
|
111
112
|
case factory.taskName.Refund:
|
|
113
|
+
case factory.taskName.VoidPayTransaction:
|
|
112
114
|
case factory.taskName.VoidReserveTransaction:
|
|
113
115
|
callResult = yield call(task)(settings, options);
|
|
114
116
|
break;
|
|
@@ -3,6 +3,6 @@ import * as factory from '../../../../factory';
|
|
|
3
3
|
* 取引のタスクを作成する
|
|
4
4
|
*/
|
|
5
5
|
export declare function createTasks(params: {
|
|
6
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>;
|
|
6
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'id' | 'endDate' | 'status' | 'project' | 'startDate' | 'typeOf' | 'object' | 'potentialActions'>;
|
|
7
7
|
runsAt: Date;
|
|
8
8
|
}): factory.task.IAttributes<factory.taskName>[];
|
|
@@ -5,5 +5,5 @@ export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyT
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function createPotentialActions(params: {
|
|
7
7
|
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
8
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>;
|
|
8
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'id' | 'typeOf' | 'project'>;
|
|
9
9
|
}): Promise<factory.transaction.IPotentialActions<factory.transactionType.MoneyTransfer>>;
|
|
@@ -502,7 +502,7 @@ function confirm(params) {
|
|
|
502
502
|
const transaction = yield repos.transaction.findById({
|
|
503
503
|
typeOf: factory.transactionType.MoneyTransfer,
|
|
504
504
|
id: params.id
|
|
505
|
-
});
|
|
505
|
+
}, ['typeOf', 'status', 'project']);
|
|
506
506
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
507
507
|
// すでに確定済の場合
|
|
508
508
|
return;
|
|
@@ -560,7 +560,7 @@ function exportTasksById(params) {
|
|
|
560
560
|
const transaction = yield repos.transaction.findById({
|
|
561
561
|
typeOf: factory.transactionType.MoneyTransfer,
|
|
562
562
|
id: params.id
|
|
563
|
-
});
|
|
563
|
+
}, ['endDate', 'status', 'project', 'startDate', 'typeOf', 'object', 'potentialActions']);
|
|
564
564
|
// タスク実行日時バッファの指定があれば調整
|
|
565
565
|
let taskRunsAt = new Date();
|
|
566
566
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
|
@@ -23,9 +23,8 @@ function exportTasksById(params) {
|
|
|
23
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
const transaction = yield repos.transaction.findById({
|
|
25
25
|
typeOf: factory.transactionType.PlaceOrder,
|
|
26
|
-
id: params.id
|
|
27
|
-
|
|
28
|
-
});
|
|
26
|
+
id: params.id
|
|
27
|
+
}, ['endDate', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']);
|
|
29
28
|
// タスク実行日時バッファの指定があれば調整
|
|
30
29
|
let taskRunsAt = new Date();
|
|
31
30
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
|
@@ -38,7 +38,7 @@ function confirm(params) {
|
|
|
38
38
|
const transaction = yield repos.transaction.findById({
|
|
39
39
|
typeOf: factory.transactionType.PlaceOrder,
|
|
40
40
|
id: params.id
|
|
41
|
-
});
|
|
41
|
+
}, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
|
|
42
42
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
43
43
|
// すでに確定済の場合
|
|
44
44
|
return transaction.result;
|
|
@@ -103,7 +103,8 @@ function confirm(params) {
|
|
|
103
103
|
// ポストアクションを作成
|
|
104
104
|
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order,
|
|
105
105
|
// order: orderWithAcceptedOffers, // 現時点でcreateEmailMessageでorder.acceptedOffersを使用している(2024-02-06~)
|
|
106
|
-
transaction: transaction,
|
|
106
|
+
// transaction: transaction,
|
|
107
|
+
useOptimizedSendEmailAction: params.options.useOptimizedSendEmailAction }, (params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined), (emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined));
|
|
107
108
|
// メッセージ保管(2024-04-28~)
|
|
108
109
|
yield saveMessagesIfNeeded({ options: params.options }, result.order, emailMessages)(repos);
|
|
109
110
|
// ステータス変更
|
|
@@ -5,7 +5,6 @@ import * as factory from '../../../factory';
|
|
|
5
5
|
export declare function createPotentialActions(params: {
|
|
6
6
|
order: factory.order.IOrder;
|
|
7
7
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
8
|
-
transaction: factory.transaction.placeOrder.ITransaction;
|
|
9
8
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
10
9
|
useOptimizedSendEmailAction: boolean;
|
|
11
10
|
}): Promise<{
|
|
@@ -4,7 +4,7 @@ import * as factory from '../../../factory';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function createOrder(params: {
|
|
6
6
|
orderNumber: string;
|
|
7
|
-
transaction: factory.transaction.placeOrder.ITransaction
|
|
7
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'object' | 'seller' | 'project'>;
|
|
8
8
|
orderDate: Date;
|
|
9
9
|
orderStatus: factory.orderStatus;
|
|
10
10
|
isGift: boolean;
|
|
@@ -7,7 +7,7 @@ export type IAuthorizePaymentAction = factory.action.authorize.paymentMethod.any
|
|
|
7
7
|
/**
|
|
8
8
|
* 取引が確定可能な状態かどうかをチェックする
|
|
9
9
|
*/
|
|
10
|
-
export declare function validateTransaction(transaction: factory.transaction.placeOrder.ITransaction, authorizePaymentActions: IAuthorizePaymentAction[], authorizeEventServiceOfferActions: IAuthorizeEventServiceOffer[], authorizeMoneyTansferActions: IAuthorizeMoneyTransferOffer[], authorizeProductOfferActions: IAuthorizeProductOffer[], eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[]): void;
|
|
10
|
+
export declare function validateTransaction(transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'object'>, authorizePaymentActions: IAuthorizePaymentAction[], authorizeEventServiceOfferActions: IAuthorizeEventServiceOffer[], authorizeMoneyTansferActions: IAuthorizeMoneyTransferOffer[], authorizeProductOfferActions: IAuthorizeProductOffer[], eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[]): void;
|
|
11
11
|
export type IOrderURLGenerator = (order: factory.order.IOrder) => string;
|
|
12
12
|
/**
|
|
13
13
|
* 注文オファー数検証
|
|
@@ -127,12 +127,13 @@ function validatePrice(authorizePaymentActions, authorizeEventServiceOfferAction
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
function validatePaymentUrl(transaction, authorizePaymentActions) {
|
|
130
|
-
var _a
|
|
130
|
+
var _a;
|
|
131
131
|
// 決済URLが発行されている場合、検証
|
|
132
132
|
const paymentMethodId = (_a = transaction.object.paymentMethods) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
|
|
133
|
-
const paymentUrl =
|
|
133
|
+
// const paymentUrl = transaction.object.paymentMethods?.paymentUrl;
|
|
134
134
|
if (typeof paymentMethodId === 'string' && paymentMethodId.length > 0
|
|
135
|
-
|
|
135
|
+
// && typeof paymentUrl === 'string' && paymentUrl.length > 0
|
|
136
|
+
) {
|
|
136
137
|
// 発行された決済URLに対する決済承認を確認する
|
|
137
138
|
const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some(({ result }) => {
|
|
138
139
|
const resultAsInvoice = (Array.isArray(result))
|
|
@@ -3,6 +3,6 @@ import * as factory from '../../../../factory';
|
|
|
3
3
|
* 取引のタスクを作成する
|
|
4
4
|
*/
|
|
5
5
|
export declare function createTasks(params: {
|
|
6
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.ReturnOrder>;
|
|
6
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.ReturnOrder>, 'endDate' | 'status' | 'id' | 'project' | 'typeOf' | 'startDate' | 'object' | 'potentialActions'>;
|
|
7
7
|
runsAt: Date;
|
|
8
8
|
}): factory.task.IAttributes<factory.taskName>[];
|
package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import * as factory from '../../../../factory';
|
|
|
2
2
|
export declare function createReturnPaymentMethodActions(params: {
|
|
3
3
|
order: factory.order.IOrder;
|
|
4
4
|
returnOrderActionParams?: factory.transaction.returnOrder.IReturnOrderActionParams;
|
|
5
|
-
transaction: factory.transaction.returnOrder.ITransaction
|
|
5
|
+
transaction: Pick<factory.transaction.returnOrder.ITransaction, 'object'>;
|
|
6
6
|
}): Promise<factory.action.transfer.returnAction.paymentMethod.IAttributes[]>;
|
|
@@ -7,6 +7,6 @@ export declare function createPotentialActions(params: {
|
|
|
7
7
|
dateReturned: Date;
|
|
8
8
|
orders: factory.order.IOrder[];
|
|
9
9
|
potentialActions?: factory.transaction.returnOrder.IPotentialActionsParams;
|
|
10
|
-
transaction: factory.transaction.returnOrder.ITransaction
|
|
10
|
+
transaction: Pick<factory.transaction.returnOrder.ITransaction, 'agent' | 'object'>;
|
|
11
11
|
emailMessageOnOrderReturned?: factory.creativeWork.message.email.ICreativeWork;
|
|
12
12
|
}): Promise<factory.transaction.returnOrder.IPotentialActions>;
|
|
@@ -65,7 +65,7 @@ exports.start = start;
|
|
|
65
65
|
function confirm(params) {
|
|
66
66
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
var _a;
|
|
68
|
-
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
|
|
68
|
+
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id }, ['typeOf', 'status', 'project', 'agent', 'object', 'result']);
|
|
69
69
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
70
70
|
// すでに確定済の場合
|
|
71
71
|
return transaction.result;
|
|
@@ -124,7 +124,7 @@ exports.confirm = confirm;
|
|
|
124
124
|
*/
|
|
125
125
|
function exportTasksById(params) {
|
|
126
126
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
|
|
127
|
+
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id }, ['typeOf', 'status', 'project', 'endDate', 'startDate', 'object', 'potentialActions']);
|
|
128
128
|
// タスク実行日時バッファの指定があれば調整
|
|
129
129
|
let taskRunsAt = new Date();
|
|
130
130
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const USE_CHECK_RESOURCE_TASK: boolean;
|
|
|
40
40
|
export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
|
|
41
41
|
export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
|
|
42
42
|
export declare const USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER: boolean;
|
|
43
|
+
export declare const USE_EXPERIMENTAL_FEATURE: boolean;
|
|
43
44
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
44
45
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
45
46
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_EXPERIMENTAL_FEATURE = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -63,6 +63,7 @@ exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_R
|
|
|
63
63
|
: [];
|
|
64
64
|
exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
|
|
65
65
|
exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = process.env.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER === '1';
|
|
66
|
+
exports.USE_EXPERIMENTAL_FEATURE = process.env.USE_EXPERIMENTAL_FEATURE === '1';
|
|
66
67
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
67
68
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
68
69
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
14
|
-
"@cinerino/sdk": "7.
|
|
13
|
+
"@chevre/factory": "4.374.0-alpha.8",
|
|
14
|
+
"@cinerino/sdk": "7.1.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.33.0
|
|
113
|
+
"version": "21.33.0"
|
|
114
114
|
}
|
|
@@ -1,152 +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
|
-
import { migrateUser } from './migrateCognitoUser';
|
|
7
|
-
|
|
8
|
-
// export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
|
|
9
|
-
export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
10
|
-
export const ISS_PREFIX = 'https://cognito-idp.ap-northeast-1.amazonaws.com/';
|
|
11
|
-
|
|
12
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
13
|
-
const PRODUCT_TYPE = chevre.factory.product.ProductType.EventService;
|
|
14
|
-
|
|
15
|
-
// tslint:disable-next-line:max-func-body-length
|
|
16
|
-
async function main() {
|
|
17
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
18
|
-
|
|
19
|
-
const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
|
|
20
|
-
|
|
21
|
-
const now = new Date();
|
|
22
|
-
const cursor = ownershipInfoRepo.getCursor(
|
|
23
|
-
{
|
|
24
|
-
// 'ownedBy.id': {
|
|
25
|
-
// $exists: true,
|
|
26
|
-
// $eq: 'bec066cd-2e82-4857-8ac2-b8b25a6947e8'
|
|
27
|
-
// },
|
|
28
|
-
ownedFrom: {
|
|
29
|
-
// $gte: moment('2022-01-01T00:00:00+09:00')
|
|
30
|
-
// .toDate(),
|
|
31
|
-
$lte: now
|
|
32
|
-
// $lte: moment('2021-12-25T22:53:09.579Z')
|
|
33
|
-
// .toDate()
|
|
34
|
-
},
|
|
35
|
-
// ownedThrough: {
|
|
36
|
-
// $gte: now
|
|
37
|
-
// },
|
|
38
|
-
'ownedBy.typeOf': {
|
|
39
|
-
$exists: true,
|
|
40
|
-
$eq: chevre.factory.personType.Person
|
|
41
|
-
},
|
|
42
|
-
'typeOfGood.issuedThrough.typeOf': {
|
|
43
|
-
$exists: true,
|
|
44
|
-
$eq: PRODUCT_TYPE
|
|
45
|
-
},
|
|
46
|
-
'project.id': { $eq: project.id }
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
// _id: 1,
|
|
50
|
-
// ownedFrom: 1,
|
|
51
|
-
// typeOfGood: 1
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
console.log('ownershipInfos found');
|
|
55
|
-
|
|
56
|
-
let i = 0;
|
|
57
|
-
let notFoundCount = 0;
|
|
58
|
-
let updateCount = 0;
|
|
59
|
-
await cursor.eachAsync(async (doc) => {
|
|
60
|
-
i += 1;
|
|
61
|
-
const ownershipInfo = <chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IPermitAsGood>>doc.toObject();
|
|
62
|
-
|
|
63
|
-
const owner = <chevre.factory.person.IPerson>ownershipInfo.ownedBy;
|
|
64
|
-
let iss =
|
|
65
|
-
(<chevre.factory.propertyValue.IPropertyValue<string>[] | undefined>owner.identifier)?.find((p) => p.name === 'iss')?.value;
|
|
66
|
-
if (typeof iss === 'string') {
|
|
67
|
-
iss = iss.replace(ISS_PREFIX, '');
|
|
68
|
-
}
|
|
69
|
-
console.log('iss:', iss);
|
|
70
|
-
|
|
71
|
-
// 新会員ならok
|
|
72
|
-
if (iss === USERPOOL_ID_NEW) {
|
|
73
|
-
console.log('already new userPool', ownershipInfo.typeOfGood.identifier, ownershipInfo.ownedFrom, i, notFoundCount);
|
|
74
|
-
} else {
|
|
75
|
-
// 旧会員の場合、新会員の存在確認
|
|
76
|
-
console.log(
|
|
77
|
-
'checking...',
|
|
78
|
-
ownershipInfo.typeOfGood.identifier,
|
|
79
|
-
ownershipInfo.ownedFrom,
|
|
80
|
-
owner.id, owner.memberOf?.membershipNumber, i, notFoundCount);
|
|
81
|
-
const personRepo = await chevre.repository.Person.createInstance({ userPoolId: USERPOOL_ID_NEW });
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const newUserAttributes = await personRepo.getUserAttributes({ username: `SSKTS_${owner.id}` });
|
|
85
|
-
const newUserId = newUserAttributes.additionalProperty?.find((p) => p.name === 'sub')?.value;
|
|
86
|
-
const person = await personRepo.findById({ userId: String(newUserId) });
|
|
87
|
-
console.log(
|
|
88
|
-
'found',
|
|
89
|
-
ownershipInfo.typeOfGood.identifier,
|
|
90
|
-
ownershipInfo.ownedFrom,
|
|
91
|
-
owner.id,
|
|
92
|
-
owner.memberOf?.membershipNumber,
|
|
93
|
-
person.id, i, notFoundCount);
|
|
94
|
-
|
|
95
|
-
// 所有権の所有者を新会員に置換
|
|
96
|
-
const newOwner: chevre.factory.person.IPerson = {
|
|
97
|
-
...owner,
|
|
98
|
-
id: person.id,
|
|
99
|
-
identifier: [
|
|
100
|
-
...(Array.isArray(person.identifier)) ? person.identifier : [],
|
|
101
|
-
// 手動移行した証拠を残す
|
|
102
|
-
{ name: 'ownedByMigratedManually', value: '1' }
|
|
103
|
-
],
|
|
104
|
-
memberOf: person.memberOf
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
updateCount += 1;
|
|
108
|
-
console.log(
|
|
109
|
-
'updating ownedBy...',
|
|
110
|
-
ownershipInfo.typeOfGood.identifier,
|
|
111
|
-
ownershipInfo.ownedFrom,
|
|
112
|
-
newOwner.id,
|
|
113
|
-
newOwner.memberOf?.membershipNumber,
|
|
114
|
-
i, notFoundCount, updateCount);
|
|
115
|
-
// const result = await ownershipInfoRepo.ownershipInfoModel.updateOne(
|
|
116
|
-
// { _id: ownershipInfo.id },
|
|
117
|
-
// { ownedBy: newOwner }
|
|
118
|
-
// )
|
|
119
|
-
// .exec();
|
|
120
|
-
// console.log(
|
|
121
|
-
// 'ownedBy updated',
|
|
122
|
-
// ownershipInfo.typeOfGood.identifier,
|
|
123
|
-
// ownershipInfo.ownedFrom,
|
|
124
|
-
// newOwner.id,
|
|
125
|
-
// newOwner.memberOf?.membershipNumber,
|
|
126
|
-
// i, notFoundCount, updateCount,
|
|
127
|
-
// result);
|
|
128
|
-
|
|
129
|
-
} catch (error) {
|
|
130
|
-
// NotFoundエラーは、新ユーザープールでのユーザーがまだ存在しないだけ
|
|
131
|
-
if (error.code === 'UserNotFoundException') {
|
|
132
|
-
notFoundCount += 1;
|
|
133
|
-
console.log(
|
|
134
|
-
'not found', ownershipInfo.typeOfGood.identifier, ownershipInfo.ownedFrom,
|
|
135
|
-
owner.id, owner.memberOf?.membershipNumber, i, notFoundCount);
|
|
136
|
-
// migrateUser
|
|
137
|
-
await migrateUser({ id: owner.id });
|
|
138
|
-
} else {
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
console.log(i, 'infos checked', PRODUCT_TYPE);
|
|
146
|
-
console.log(notFoundCount, 'people not found', PRODUCT_TYPE);
|
|
147
|
-
console.log(updateCount, 'ownershipInfos updated', PRODUCT_TYPE);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
main()
|
|
151
|
-
.then()
|
|
152
|
-
.catch(console.error);
|
|
@@ -1,95 +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(movieTicket: chevre.factory.action.trade.pay.IMovieTicket) {
|
|
10
|
-
return `${movieTicket.serviceOutput.reservationFor.id}:${movieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection}:${movieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber}`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function main() {
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
-
|
|
16
|
-
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
17
|
-
|
|
18
|
-
const cursor = assetTransactionRepo.getCursor(
|
|
19
|
-
{
|
|
20
|
-
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
21
|
-
startDate: {
|
|
22
|
-
$gte: moment()
|
|
23
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
.add(-3, 'months')
|
|
25
|
-
.toDate()
|
|
26
|
-
}
|
|
27
|
-
// 'project.id': { $eq: project.id },
|
|
28
|
-
// transactionNumber: { $exists: true, $eq: '642463069394964' }
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
startDate: 1,
|
|
32
|
-
transactionNumber: 1,
|
|
33
|
-
project: 1,
|
|
34
|
-
object: 1
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
console.log('transactions found');
|
|
38
|
-
|
|
39
|
-
let i = 0;
|
|
40
|
-
let updateCount = 0;
|
|
41
|
-
await cursor.eachAsync(async (doc) => {
|
|
42
|
-
i += 1;
|
|
43
|
-
const payTransaction: Pick<
|
|
44
|
-
chevre.factory.assetTransaction.pay.ITransaction,
|
|
45
|
-
'startDate' | 'transactionNumber' | 'project' | 'object'
|
|
46
|
-
> = doc.toObject();
|
|
47
|
-
|
|
48
|
-
const movieTicketsInTransaction = payTransaction.object.paymentMethod.movieTickets;
|
|
49
|
-
const alreadyMigrated = (!Array.isArray(movieTicketsInTransaction)) || movieTicketsInTransaction.every((movieTicket) => {
|
|
50
|
-
const reservedTicketIdentifierShouldBe = createReservedTicketIdentifier(movieTicket);
|
|
51
|
-
|
|
52
|
-
return typeof movieTicket.serviceOutput.reservedTicket.identifier === 'string'
|
|
53
|
-
&& movieTicket.serviceOutput.reservedTicket.identifier.length > 0
|
|
54
|
-
&& movieTicket.serviceOutput.reservedTicket.identifier === reservedTicketIdentifierShouldBe;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (alreadyMigrated) {
|
|
58
|
-
console.log('already exist.', payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
59
|
-
} else {
|
|
60
|
-
const newMovieTickets: chevre.factory.action.trade.pay.IMovieTicket[] = movieTicketsInTransaction.map((movieTicket) => {
|
|
61
|
-
return {
|
|
62
|
-
...movieTicket,
|
|
63
|
-
serviceOutput: {
|
|
64
|
-
...movieTicket.serviceOutput,
|
|
65
|
-
reservedTicket: {
|
|
66
|
-
...movieTicket.serviceOutput.reservedTicket,
|
|
67
|
-
identifier: createReservedTicketIdentifier(movieTicket)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
console.log(
|
|
73
|
-
'updating...',
|
|
74
|
-
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate,
|
|
75
|
-
newMovieTickets, i);
|
|
76
|
-
// console.dir(newMovieTickets, { depth: null });
|
|
77
|
-
await assetTransactionRepo.fixReservedTicketIdentifier({
|
|
78
|
-
project: { id: payTransaction.project.id },
|
|
79
|
-
transactionNumber: payTransaction.transactionNumber,
|
|
80
|
-
object: {
|
|
81
|
-
paymentMethod: { movieTickets: newMovieTickets }
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
updateCount += 1;
|
|
85
|
-
console.log('updated.', payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
console.log(i, 'transactions checked');
|
|
90
|
-
console.log(updateCount, 'transactions updated');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
main()
|
|
94
|
-
.then()
|
|
95
|
-
.catch(console.error);
|