@chevre/domain 21.35.0-alpha.31 → 21.35.0-alpha.32
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/lib/chevre/factory/taskIdentifier.d.ts +29 -0
- package/lib/chevre/factory/taskIdentifier.js +10 -0
- package/lib/chevre/repo/task.d.ts +12 -0
- package/lib/chevre/repo/task.js +17 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +6 -0
- package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +9 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +27 -3
- package/lib/chevre/service.d.ts +2 -0
- package/lib/chevre/service.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare function createCheckMovieTicketTaskIdentifier(params: {
|
|
2
|
+
project: {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
purpose: {
|
|
6
|
+
/**
|
|
7
|
+
* placeOrder ID
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
object: {
|
|
12
|
+
/**
|
|
13
|
+
* 決済サービスID
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
movieTicket: {
|
|
17
|
+
/**
|
|
18
|
+
* 決済カード識別子
|
|
19
|
+
*/
|
|
20
|
+
identifier: string;
|
|
21
|
+
serviceOutput: {
|
|
22
|
+
reservationFor: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}): string;
|
|
29
|
+
export { createCheckMovieTicketTaskIdentifier };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCheckMovieTicketTaskIdentifier = void 0;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
const factory = require("../factory");
|
|
6
|
+
function createCheckMovieTicketTaskIdentifier(params) {
|
|
7
|
+
const { project, purpose, object } = params;
|
|
8
|
+
return util.format(`%s:%s:%s:%s:%s:%s:%s`, project.id, factory.taskName.CheckMovieTicket, factory.transactionType.PlaceOrder, purpose.id, object.id, object.movieTicket.identifier, object.movieTicket.serviceOutput.reservationFor.id);
|
|
9
|
+
}
|
|
10
|
+
exports.createCheckMovieTicketTaskIdentifier = createCheckMovieTicketTaskIdentifier;
|
|
@@ -64,6 +64,18 @@ export declare class MongoRepository {
|
|
|
64
64
|
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options: IOptionOnCreate): Promise<{
|
|
65
65
|
id: string;
|
|
66
66
|
}[]>;
|
|
67
|
+
/**
|
|
68
|
+
* タスク識別子から検索する
|
|
69
|
+
*/
|
|
70
|
+
findByIdentifier(params: {
|
|
71
|
+
identifier: string;
|
|
72
|
+
name: factory.taskName;
|
|
73
|
+
project: {
|
|
74
|
+
id: string;
|
|
75
|
+
};
|
|
76
|
+
}): Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
} | undefined>;
|
|
67
79
|
/**
|
|
68
80
|
* タスク識別子から冪等作成する
|
|
69
81
|
*/
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -192,6 +192,23 @@ class MongoRepository {
|
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* タスク識別子から検索する
|
|
197
|
+
*/
|
|
198
|
+
findByIdentifier(params) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
const doc = yield this.taskModel.findOne({
|
|
201
|
+
'project.id': { $eq: params.project.id },
|
|
202
|
+
name: { $eq: params.name },
|
|
203
|
+
identifier: { $exists: true, $eq: params.identifier }
|
|
204
|
+
}, { _id: 1 })
|
|
205
|
+
.exec();
|
|
206
|
+
if (doc === null) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
return { id: doc.id };
|
|
210
|
+
});
|
|
211
|
+
}
|
|
195
212
|
/**
|
|
196
213
|
* タスク識別子から冪等作成する
|
|
197
214
|
*/
|
|
@@ -122,6 +122,12 @@ export declare function start(params: factory.assetTransaction.pay.IStartParamsW
|
|
|
122
122
|
*/
|
|
123
123
|
id?: string;
|
|
124
124
|
};
|
|
125
|
+
purpose: {
|
|
126
|
+
/**
|
|
127
|
+
* placeOrder ID
|
|
128
|
+
*/
|
|
129
|
+
id?: string;
|
|
130
|
+
};
|
|
125
131
|
}): IStartOperation<factory.assetTransaction.pay.ITransaction>;
|
|
126
132
|
/**
|
|
127
133
|
* 取引確定
|
|
@@ -221,10 +221,10 @@ function start(params, options) {
|
|
|
221
221
|
: undefined))(repos);
|
|
222
222
|
break;
|
|
223
223
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
224
|
-
transaction =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
transaction = yield processAuthorizeMovieTicket(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.useCheckByIdentifierIfNotYet, {
|
|
225
|
+
executor: (typeof ((_d = options.executor) === null || _d === void 0 ? void 0 : _d.id) === 'string') ? { id: options.executor.id } : {},
|
|
226
|
+
purpose: options.purpose
|
|
227
|
+
})(repos);
|
|
228
228
|
break;
|
|
229
229
|
default:
|
|
230
230
|
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
@@ -384,7 +384,7 @@ function authorize(params) {
|
|
|
384
384
|
location: params.location,
|
|
385
385
|
order: Object.assign({}, (typeof confirmationNumber === 'string') ? { confirmationNumber } : undefined)
|
|
386
386
|
});
|
|
387
|
-
payTransaction = yield PayTransactionService.start(startParams, Object.assign({ useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet, executor: (typeof taskId === 'string') ? { id: taskId } : {} }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined))(repos);
|
|
387
|
+
payTransaction = yield PayTransactionService.start(startParams, Object.assign({ useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet, executor: (typeof taskId === 'string') ? { id: taskId } : {}, purpose: { id: transaction.id } }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined))(repos);
|
|
388
388
|
}
|
|
389
389
|
catch (error) {
|
|
390
390
|
try {
|
|
@@ -26,6 +26,12 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
|
|
|
26
26
|
*/
|
|
27
27
|
id?: string;
|
|
28
28
|
};
|
|
29
|
+
purpose: {
|
|
30
|
+
/**
|
|
31
|
+
* placeOrder ID
|
|
32
|
+
*/
|
|
33
|
+
id?: string;
|
|
34
|
+
};
|
|
29
35
|
}): (repos: {
|
|
30
36
|
action: ActionRepo;
|
|
31
37
|
accountingReport: AccountingReportRepo;
|
|
@@ -26,7 +26,7 @@ function authorize(params, transaction, paymentServiceId, useCheckByIdentifierIf
|
|
|
26
26
|
let accountsReceivablesByServiceType = [];
|
|
27
27
|
try {
|
|
28
28
|
// MovieTicket決済の場合、認証
|
|
29
|
-
const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckByIdentifierIfNotYet)(repos);
|
|
29
|
+
const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckByIdentifierIfNotYet, options.purpose)(repos);
|
|
30
30
|
accountsReceivablesByServiceType = validateMovieTicketResult.accountsReceivablesByServiceType;
|
|
31
31
|
const paymentMethod = transaction.object.paymentMethod;
|
|
32
32
|
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
|
|
@@ -21,11 +21,11 @@ function checkMovieTicket(params) {
|
|
|
21
21
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
var _a, _b, _c, _d, _e, _f;
|
|
23
23
|
// 不要な属性がリクエストに含まれているのでmovieTicketsを最適化(2024-03-15~)
|
|
24
|
-
|
|
25
|
-
if (!Array.isArray(
|
|
24
|
+
const movieTicketsBeforeOptimize = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.movieTickets;
|
|
25
|
+
if (!Array.isArray(movieTicketsBeforeOptimize)) {
|
|
26
26
|
throw new factory.errors.Argument('object.movieTickets must be an array');
|
|
27
27
|
}
|
|
28
|
-
movieTickets =
|
|
28
|
+
const movieTickets = movieTicketsBeforeOptimize.map(({ accessCode, category, identifier, serviceOutput }) => {
|
|
29
29
|
return {
|
|
30
30
|
accessCode, category, identifier,
|
|
31
31
|
serviceOutput: { reservationFor: serviceOutput.reservationFor } // 最適化(2024-03-15~)
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import * as factory from '../../../factory';
|
|
2
1
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
2
|
import type { MongoRepository as EventRepo } from '../../../repo/event';
|
|
4
3
|
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
5
4
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
6
5
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
7
|
-
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
import * as factory from '../../../factory';
|
|
8
|
+
export declare function validateMovieTicket(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, useCheckByIdentifierIfNotYet: boolean, purpose: {
|
|
9
|
+
/**
|
|
10
|
+
* placeOrder ID
|
|
11
|
+
*/
|
|
12
|
+
id?: string;
|
|
13
|
+
}): (repos: {
|
|
8
14
|
action: ActionRepo;
|
|
9
15
|
event: EventRepo;
|
|
10
16
|
paymentAccepted: PaymentAcceptedRepo;
|
|
11
17
|
paymentService: PaymentServiceRepo;
|
|
12
18
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
19
|
+
task: TaskRepo;
|
|
13
20
|
}) => Promise<{
|
|
14
21
|
accountsReceivablesByServiceType: factory.assetTransaction.pay.IAccountsReceivableByServiceType[];
|
|
15
22
|
}>;
|
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.validateMovieTicket = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
|
+
const taskIdentifier_1 = require("../../../factory/taskIdentifier");
|
|
15
16
|
const processPurchaseNumberAuth_1 = require("./processPurchaseNumberAuth");
|
|
16
17
|
const debug = createDebug('chevre-domain:service:payment');
|
|
17
|
-
function validateMovieTicket(params, paymentServiceId, useCheckByIdentifierIfNotYet) {
|
|
18
|
+
function validateMovieTicket(params, paymentServiceId, useCheckByIdentifierIfNotYet, purpose) {
|
|
18
19
|
// tslint:disable-next-line:max-func-body-length
|
|
19
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
var _a, _b, _c;
|
|
@@ -79,7 +80,8 @@ function validateMovieTicket(params, paymentServiceId, useCheckByIdentifierIfNot
|
|
|
79
80
|
seller: { id: sellerId },
|
|
80
81
|
screeningEvent: screeningEvent,
|
|
81
82
|
paymentServiceId,
|
|
82
|
-
useCheckByIdentifierIfNotYet
|
|
83
|
+
useCheckByIdentifierIfNotYet,
|
|
84
|
+
purpose
|
|
83
85
|
})(repos);
|
|
84
86
|
const accountsReceivablesByServiceType = [];
|
|
85
87
|
// 券種ごとに枚数が足りているか
|
|
@@ -114,7 +116,29 @@ function checkByIdentifierIfNotYet(params) {
|
|
|
114
116
|
let checkResult;
|
|
115
117
|
if (params.useCheckByIdentifierIfNotYet === true) {
|
|
116
118
|
// すでにCheckActionが存在すれば認証しない(2023-06-06~)
|
|
117
|
-
|
|
119
|
+
let alreadyCheckedAction;
|
|
120
|
+
// search from checkMovieTicketTask(2024-06-26~)
|
|
121
|
+
const placeOrderId = params.purpose.id;
|
|
122
|
+
if (typeof placeOrderId === 'string') {
|
|
123
|
+
const taskIdentifier = (0, taskIdentifier_1.createCheckMovieTicketTaskIdentifier)({
|
|
124
|
+
project: { id: params.screeningEvent.project.id },
|
|
125
|
+
purpose: { id: placeOrderId },
|
|
126
|
+
object: {
|
|
127
|
+
id: params.paymentServiceId,
|
|
128
|
+
movieTicket: {
|
|
129
|
+
identifier: params.movieTicketIdentifier,
|
|
130
|
+
serviceOutput: { reservationFor: { id: params.screeningEvent.id } }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const existingCheckMovieTicketTask = yield repos.task.findByIdentifier({
|
|
135
|
+
project: { id: params.screeningEvent.project.id },
|
|
136
|
+
name: factory.taskName.CheckMovieTicket,
|
|
137
|
+
identifier: taskIdentifier
|
|
138
|
+
});
|
|
139
|
+
debug('existingCheckMovieTicketTask:', JSON.stringify(existingCheckMovieTicketTask), 'placeOrderId:', placeOrderId);
|
|
140
|
+
}
|
|
141
|
+
alreadyCheckedAction = (yield repos.action.search({
|
|
118
142
|
limit: 1,
|
|
119
143
|
page: 1,
|
|
120
144
|
sort: { startDate: factory.sortType.Descending },
|
package/lib/chevre/service.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as AccountTransactionIdentifierFactory from './factory/accountTransacti
|
|
|
5
5
|
import * as EventFactory from './factory/event';
|
|
6
6
|
import * as OrderFactory from './factory/order';
|
|
7
7
|
import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
|
|
8
|
+
import * as TaskIdentifierFactory from './factory/taskIdentifier';
|
|
8
9
|
import * as TransactionFactory from './factory/transaction';
|
|
9
10
|
import type * as AccountService from './service/account';
|
|
10
11
|
import type * as AccountTransactionService from './service/accountTransaction';
|
|
@@ -85,5 +86,6 @@ export declare namespace factory {
|
|
|
85
86
|
export import event = EventFactory;
|
|
86
87
|
export import order = OrderFactory;
|
|
87
88
|
export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
89
|
+
export import taskIdentifier = TaskIdentifierFactory;
|
|
88
90
|
export import transaction = TransactionFactory;
|
|
89
91
|
}
|
package/lib/chevre/service.js
CHANGED
|
@@ -17,6 +17,7 @@ const AccountTransactionIdentifierFactory = require("./factory/accountTransactio
|
|
|
17
17
|
const EventFactory = require("./factory/event");
|
|
18
18
|
const OrderFactory = require("./factory/order");
|
|
19
19
|
const ReservedAgentIdentifireNamesFactory = require("./factory/reservedAgentIdentifireNames");
|
|
20
|
+
const TaskIdentifierFactory = require("./factory/taskIdentifier");
|
|
20
21
|
const TransactionFactory = require("./factory/transaction");
|
|
21
22
|
// import all lazily(2023-10-11~)
|
|
22
23
|
var account;
|
|
@@ -264,6 +265,7 @@ var factory;
|
|
|
264
265
|
// tslint:disable-next-line:no-shadowed-variable
|
|
265
266
|
factory.order = OrderFactory;
|
|
266
267
|
factory.reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
268
|
+
factory.taskIdentifier = TaskIdentifierFactory;
|
|
267
269
|
// tslint:disable-next-line:no-shadowed-variable
|
|
268
270
|
factory.transaction = TransactionFactory;
|
|
269
271
|
})(factory = exports.factory || (exports.factory = {}));
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.375.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.375.0-alpha.23",
|
|
14
14
|
"@cinerino/sdk": "8.0.0-alpha.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.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.35.0-alpha.
|
|
113
|
+
"version": "21.35.0-alpha.32"
|
|
114
114
|
}
|