@chevre/domain 20.4.0-alpha.2 → 20.4.0-alpha.21
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
- package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
- package/example/src/chevre/searchEventTicketOffers.ts +7 -4
- package/example/src/chevre/searchOffersByCatalog.ts +2 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
- package/lib/chevre/repo/account.d.ts +4 -10
- package/lib/chevre/repo/account.js +72 -60
- package/lib/chevre/repo/assetTransaction.d.ts +1 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/event.d.ts +5 -4
- package/lib/chevre/repo/event.js +12 -30
- package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
- package/lib/chevre/repo/mongoose/model/comments.js +1 -1
- package/lib/chevre/repo/mongoose/model/offer.js +12 -0
- package/lib/chevre/repo/offer.d.ts +17 -2
- package/lib/chevre/repo/offer.js +77 -44
- package/lib/chevre/repo/priceSpecification.d.ts +10 -0
- package/lib/chevre/repo/priceSpecification.js +9 -0
- package/lib/chevre/repo/serviceOutput.d.ts +4 -0
- package/lib/chevre/repo/serviceOutput.js +6 -0
- package/lib/chevre/repository.d.ts +6 -0
- package/lib/chevre/repository.js +8 -1
- package/lib/chevre/service/account.d.ts +0 -8
- package/lib/chevre/service/account.js +16 -10
- package/lib/chevre/service/accountTransaction/deposit.js +2 -1
- package/lib/chevre/service/accountTransaction/factory.js +25 -20
- package/lib/chevre/service/accountTransaction/transfer.js +4 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
- package/lib/chevre/service/assetTransaction/pay.js +19 -14
- package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
- package/lib/chevre/service/assetTransaction/reserve.js +2 -0
- package/lib/chevre/service/delivery.js +12 -3
- package/lib/chevre/service/event.js +3 -23
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +7 -8
- package/lib/chevre/service/offer/event/authorize.js +2 -1
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -6
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +106 -91
- package/lib/chevre/service/offer/factory.d.ts +4 -1
- package/lib/chevre/service/offer/factory.js +57 -26
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +5 -1
- package/lib/chevre/service/payment/any/factory.js +29 -2
- package/lib/chevre/service/payment/any.js +11 -4
- package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
- package/lib/chevre/service/payment/movieTicket.js +17 -8
- package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
- package/lib/chevre/service/payment/paymentCard.js +16 -8
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/settings.d.ts +6 -0
- package/lib/chevre/settings.js +8 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
- package/example/src/chevre/migrateProjectSubscription.ts +0 -51
- package/example/src/chevre/migrateSection.ts +0 -105
|
@@ -17,6 +17,7 @@ const surfrock = require("@surfrock/sdk");
|
|
|
17
17
|
const moment = require("moment-timezone");
|
|
18
18
|
const credentials_1 = require("../../credentials");
|
|
19
19
|
const factory = require("../../factory");
|
|
20
|
+
const settings_1 = require("../../settings");
|
|
20
21
|
const factory_1 = require("./movieTicket/factory");
|
|
21
22
|
const validation_1 = require("../assetTransaction/pay/movieTicket/validation");
|
|
22
23
|
const errorHandler_1 = require("../../errorHandler");
|
|
@@ -258,14 +259,22 @@ function purchaseNumberAuthResult2movieTickets(params) {
|
|
|
258
259
|
}
|
|
259
260
|
return movieTickets;
|
|
260
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* MovieTicket承認
|
|
264
|
+
* オーソリサービスが存在するわけではないので、実質着券する
|
|
265
|
+
*/
|
|
261
266
|
function authorize(params, transaction, paymentServiceId) {
|
|
262
267
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
263
268
|
var _a, _b;
|
|
269
|
+
let accountId;
|
|
264
270
|
let checkResult;
|
|
265
271
|
let payAction;
|
|
266
272
|
try {
|
|
267
|
-
//
|
|
268
|
-
|
|
273
|
+
// オプション追加(2023-02-24~)
|
|
274
|
+
if (settings_1.settings.useCheckMovieTicketBeforePay) {
|
|
275
|
+
// MovieTicket決済の場合、認証
|
|
276
|
+
checkResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId)(repos);
|
|
277
|
+
}
|
|
269
278
|
const paymentMethod = transaction.object.paymentMethod;
|
|
270
279
|
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
|
|
271
280
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
@@ -273,7 +282,10 @@ function authorize(params, transaction, paymentServiceId) {
|
|
|
273
282
|
? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
|
|
274
283
|
: transaction.id;
|
|
275
284
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
276
|
-
|
|
285
|
+
accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
|
|
286
|
+
if (typeof accountId !== 'string' || accountId.length === 0) {
|
|
287
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.movieTickets.identifier');
|
|
288
|
+
}
|
|
277
289
|
const payObject = {
|
|
278
290
|
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
279
291
|
id: paymentServiceId,
|
|
@@ -284,10 +296,7 @@ function authorize(params, transaction, paymentServiceId) {
|
|
|
284
296
|
}, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
|
|
285
297
|
movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
|
|
286
298
|
};
|
|
287
|
-
const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject],
|
|
288
|
-
// agent:Projectに変更(2022-05-19~)
|
|
289
|
-
// agent: transaction.agent,
|
|
290
|
-
agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
|
|
299
|
+
const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
|
|
291
300
|
? { purpose: params.purpose }
|
|
292
301
|
: { purpose: { typeOf: transaction.typeOf, transactionNumber: transaction.transactionNumber, id: transaction.id } });
|
|
293
302
|
// 着券させざるをえないが、informPaymentはしない(注文がまだ存在しないため)
|
|
@@ -296,7 +305,7 @@ function authorize(params, transaction, paymentServiceId) {
|
|
|
296
305
|
catch (error) {
|
|
297
306
|
throw (0, errorHandler_1.handleMvtkReserveError)(error);
|
|
298
307
|
}
|
|
299
|
-
return
|
|
308
|
+
return { accountId, checkResult, payAction };
|
|
300
309
|
});
|
|
301
310
|
}
|
|
302
311
|
exports.authorize = authorize;
|
|
@@ -6,11 +6,15 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
6
6
|
import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
8
|
import { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
|
|
9
|
-
declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | '
|
|
9
|
+
declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'transactionNumber' | 'typeOf'>;
|
|
10
10
|
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
|
|
11
11
|
product: ProductRepo;
|
|
12
12
|
project: ProjectRepo;
|
|
13
|
-
}) => Promise<
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
pendingTransaction: IPendingTransaction;
|
|
15
|
+
currency: string;
|
|
16
|
+
accountNumber: string;
|
|
17
|
+
}>;
|
|
14
18
|
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
15
19
|
product: ProductRepo;
|
|
16
20
|
}) => Promise<void>;
|
|
@@ -29,7 +29,7 @@ function authorize(params, paymentServiceId) {
|
|
|
29
29
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
30
30
|
}
|
|
31
31
|
// 決済方法検証
|
|
32
|
-
const permit = yield validatePaymentMethod(params, paymentServiceId)(repos);
|
|
32
|
+
const { permit, currency } = yield validatePaymentMethod(params, paymentServiceId)(repos);
|
|
33
33
|
const accountNumber = (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber;
|
|
34
34
|
if (typeof accountNumber !== 'string') {
|
|
35
35
|
throw new factory.errors.ArgumentNull('permit.paymentAccount.accountNumber');
|
|
@@ -55,13 +55,13 @@ function authorize(params, paymentServiceId) {
|
|
|
55
55
|
// PecorinoAPIのエラーをハンドリング
|
|
56
56
|
throw (0, errorHandler_1.handlePecorinoError)(error);
|
|
57
57
|
}
|
|
58
|
-
return pendingTransaction;
|
|
58
|
+
return { pendingTransaction, currency, accountNumber };
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
exports.authorize = authorize;
|
|
62
62
|
function validatePaymentMethod(params, paymentServiceId) {
|
|
63
63
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
65
65
|
const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
|
|
66
66
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
67
67
|
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
@@ -74,6 +74,14 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
74
74
|
if (typeof paymentMethodType !== 'string') {
|
|
75
75
|
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
76
76
|
}
|
|
77
|
+
// プロダクトから通貨区分を取得
|
|
78
|
+
const paymentCatdProduct = yield repos.product.findById({
|
|
79
|
+
id: paymentServiceId
|
|
80
|
+
});
|
|
81
|
+
const currency = (_e = (_d = paymentCatdProduct.serviceOutput) === null || _d === void 0 ? void 0 : _d.amount) === null || _e === void 0 ? void 0 : _e.currency;
|
|
82
|
+
if (typeof currency !== 'string') {
|
|
83
|
+
throw new factory.errors.NotFound('product.serviceOutput.amount.currency');
|
|
84
|
+
}
|
|
77
85
|
// プロダクトのavailableChannelを取得する
|
|
78
86
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
79
87
|
project: { id: params.project.id },
|
|
@@ -83,9 +91,9 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
83
91
|
const permitService = new pecorinoapi.service.Permit({
|
|
84
92
|
endpoint: String(availableChannel.serviceUrl),
|
|
85
93
|
auth: new pecorinoapi.auth.ClientCredentials({
|
|
86
|
-
domain: String((
|
|
87
|
-
clientId: String((
|
|
88
|
-
clientSecret: String((
|
|
94
|
+
domain: String((_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.authorizeServerDomain),
|
|
95
|
+
clientId: String((_g = availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.clientId),
|
|
96
|
+
clientSecret: String((_h = availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.clientSecret),
|
|
89
97
|
scopes: [],
|
|
90
98
|
state: ''
|
|
91
99
|
})
|
|
@@ -97,7 +105,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
97
105
|
issuedThrough: { typeOf: factory.product.ProductType.PaymentCard }
|
|
98
106
|
});
|
|
99
107
|
// サービスタイプを確認
|
|
100
|
-
if (((
|
|
108
|
+
if (((_k = (_j = serviceOutput.issuedThrough) === null || _j === void 0 ? void 0 : _j.serviceType) === null || _k === void 0 ? void 0 : _k.codeValue) !== paymentMethodType) {
|
|
101
109
|
throw new factory.errors.Argument('object.paymentMethod.accountId', 'paymentMethodType not matched');
|
|
102
110
|
}
|
|
103
111
|
// 出金金額設定を確認
|
|
@@ -112,7 +120,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
112
120
|
throw new factory.errors.Argument('object.paymentMethod.amount', `maximum payment amount requirement not satisfied`);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
return serviceOutput;
|
|
123
|
+
return { permit: serviceOutput, currency };
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
function processAccountTransaction(params) {
|
|
@@ -30,6 +30,9 @@ export declare function activate(params: {
|
|
|
30
30
|
}): (repos: {
|
|
31
31
|
serviceOutput: ServiceOutputRepo;
|
|
32
32
|
}) => Promise<factory.permit.IPermit>;
|
|
33
|
+
declare type IPermitWithAccountDetail = Omit<factory.permit.IPermit, 'paymentAccount'> & {
|
|
34
|
+
paymentAccount?: factory.permit.IPaymentAccountWithDetail;
|
|
35
|
+
};
|
|
33
36
|
/**
|
|
34
37
|
* プロジェクト指定で、許可証を検索する(ペイメントカードプロダクトの場合、口座詳細込み)
|
|
35
38
|
*/
|
|
@@ -38,4 +41,5 @@ export declare function search(project: {
|
|
|
38
41
|
}, params: factory.product.IServiceOutputSearchConditions, projection?: any): (repos: {
|
|
39
42
|
account: AccountRepo;
|
|
40
43
|
serviceOutput: ServiceOutputRepo;
|
|
41
|
-
}) => Promise<
|
|
44
|
+
}) => Promise<IPermitWithAccountDetail[]>;
|
|
45
|
+
export {};
|
|
@@ -78,33 +78,40 @@ exports.activate = activate;
|
|
|
78
78
|
function search(project, params, projection) {
|
|
79
79
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
var _a, _b;
|
|
81
|
-
let
|
|
81
|
+
let permitsWithAccountDetail;
|
|
82
82
|
// アウトプット検索条件のプロジェクトは強制的に上書き
|
|
83
83
|
const searchConditions = Object.assign(Object.assign({}, params), { project: { id: { $eq: project.id } } });
|
|
84
84
|
const productType = (_b = (_a = params.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
85
85
|
switch (productType) {
|
|
86
86
|
case factory.product.ProductType.PaymentCard:
|
|
87
|
-
|
|
87
|
+
const permits = yield repos.serviceOutput.search(searchConditions, projection);
|
|
88
|
+
permitsWithAccountDetail = permits;
|
|
88
89
|
// 口座詳細取得
|
|
89
|
-
const accountNumbers =
|
|
90
|
-
.filter((
|
|
90
|
+
const accountNumbers = permits.map((permit) => { var _a; return (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
|
|
91
|
+
.filter((accountNumber) => typeof accountNumber === 'string');
|
|
91
92
|
if (accountNumbers.length > 0) {
|
|
92
93
|
const accounts = yield repos.account.search({
|
|
93
94
|
project: { id: { $eq: project.id } },
|
|
94
95
|
accountNumbers: accountNumbers
|
|
95
96
|
});
|
|
96
|
-
|
|
97
|
-
const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a =
|
|
98
|
-
|
|
99
|
-
? {
|
|
100
|
-
|
|
97
|
+
permitsWithAccountDetail = permits.map((permit) => {
|
|
98
|
+
const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
|
|
99
|
+
const paymentAccount = (typeof (account === null || account === void 0 ? void 0 : account.typeOf) === 'string')
|
|
100
|
+
? {
|
|
101
|
+
accountNumber: account.accountNumber,
|
|
102
|
+
availableBalance: account.availableBalance,
|
|
103
|
+
balance: account.balance,
|
|
104
|
+
typeOf: account.typeOf
|
|
105
|
+
}
|
|
106
|
+
: undefined;
|
|
107
|
+
return Object.assign(Object.assign({}, permit), { paymentAccount });
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
110
|
break;
|
|
104
111
|
default:
|
|
105
|
-
|
|
112
|
+
permitsWithAccountDetail = (yield repos.serviceOutput.search(searchConditions, projection));
|
|
106
113
|
}
|
|
107
|
-
return
|
|
114
|
+
return permitsWithAccountDetail;
|
|
108
115
|
});
|
|
109
116
|
}
|
|
110
117
|
exports.search = search;
|
|
@@ -28,37 +28,6 @@ function onReservationUsed(action, attendedReservation) {
|
|
|
28
28
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
const tasks = [];
|
|
30
30
|
const now = new Date();
|
|
31
|
-
// INFORM_USE_RESERVATION_URL廃止(2023-01-30~)
|
|
32
|
-
// アクション通知タスク作成
|
|
33
|
-
// if (Array.isArray(informUseReservations)) {
|
|
34
|
-
// informUseReservations.filter((informUseReservation) => {
|
|
35
|
-
// return typeof informUseReservation.recipient?.url === 'string'
|
|
36
|
-
// && informUseReservation.recipient.url.length > 0;
|
|
37
|
-
// })
|
|
38
|
-
// .forEach((informUseReservation) => {
|
|
39
|
-
// const triggerWebhookTask: factory.task.triggerWebhook.IAttributes = {
|
|
40
|
-
// project: action.project,
|
|
41
|
-
// name: factory.taskName.TriggerWebhook,
|
|
42
|
-
// status: factory.taskStatus.Ready,
|
|
43
|
-
// runsAt: now,
|
|
44
|
-
// remainingNumberOfTries: 3,
|
|
45
|
-
// numberOfTried: 0,
|
|
46
|
-
// executionResults: [],
|
|
47
|
-
// data: {
|
|
48
|
-
// project: action.project,
|
|
49
|
-
// typeOf: factory.actionType.InformAction,
|
|
50
|
-
// agent: action.project,
|
|
51
|
-
// recipient: {
|
|
52
|
-
// typeOf: factory.personType.Person,
|
|
53
|
-
// id: String(informUseReservation.recipient?.url),
|
|
54
|
-
// url: String(informUseReservation.recipient?.url)
|
|
55
|
-
// },
|
|
56
|
-
// object: action
|
|
57
|
-
// }
|
|
58
|
-
// };
|
|
59
|
-
// tasks.push(triggerWebhookTask);
|
|
60
|
-
// });
|
|
61
|
-
// }
|
|
62
31
|
// inform galobally
|
|
63
32
|
if (Array.isArray(informReservations)) {
|
|
64
33
|
// やや遅延させる(確定通知が未達の可能性を考慮して)
|
|
@@ -100,29 +69,32 @@ function onReservationUsed(action, attendedReservation) {
|
|
|
100
69
|
};
|
|
101
70
|
}));
|
|
102
71
|
}
|
|
72
|
+
// projectを限定する(2023-02-21~)
|
|
103
73
|
// 使用アクション集計タスクを作成する(冗長な作成を避ける)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
74
|
+
if (settings_1.settings.useAggregateEntranceGateProjects.includes(action.project.id)) {
|
|
75
|
+
const readyAggregateUseActionsTaskDoc = yield repos.task.taskModel.findOne({
|
|
76
|
+
'project.id': { $eq: action.project.id },
|
|
77
|
+
name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
|
|
78
|
+
status: { $eq: factory.taskStatus.Ready },
|
|
79
|
+
'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }
|
|
80
|
+
}, { _id: 1 })
|
|
81
|
+
.exec();
|
|
82
|
+
if (readyAggregateUseActionsTaskDoc === null) {
|
|
83
|
+
const aggregateUseActionsTask = {
|
|
84
|
+
project: attendedReservation.project,
|
|
85
|
+
name: factory.taskName.AggregateUseActionsOnEvent,
|
|
86
|
+
status: factory.taskStatus.Ready,
|
|
87
|
+
runsAt: now,
|
|
88
|
+
remainingNumberOfTries: 3,
|
|
89
|
+
numberOfTried: 0,
|
|
90
|
+
executionResults: [],
|
|
91
|
+
data: {
|
|
92
|
+
typeOf: attendedReservation.reservationFor.typeOf,
|
|
93
|
+
id: attendedReservation.reservationFor.id
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
tasks.push(aggregateUseActionsTask);
|
|
97
|
+
}
|
|
126
98
|
}
|
|
127
99
|
if (tasks.length > 0) {
|
|
128
100
|
yield repos.task.saveMany(tasks);
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -21,6 +21,12 @@ export declare type ISettings = factory.project.ISettings & {
|
|
|
21
21
|
userPoolIdOld: string;
|
|
22
22
|
userPoolIdNew: string;
|
|
23
23
|
maxNumCreditCardPaymentMethod?: number;
|
|
24
|
+
useEventWorkPerformed: boolean;
|
|
25
|
+
useOffersAppliedToMovieTicketWithoutChargeSpecification: boolean;
|
|
26
|
+
useAggregateEntranceGateProjects: string[];
|
|
27
|
+
useAggregateOfferProjects: string[];
|
|
28
|
+
useOfferRateLimitProjects: string[];
|
|
29
|
+
useCheckMovieTicketBeforePay: boolean;
|
|
24
30
|
};
|
|
25
31
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
26
32
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -54,7 +54,7 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
54
54
|
/**
|
|
55
55
|
* グローバル設定
|
|
56
56
|
*/
|
|
57
|
-
exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
|
|
57
|
+
exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
|
|
58
58
|
informOrder: informOrderUrls
|
|
59
59
|
.filter((url) => url.length > 0)
|
|
60
60
|
.map((url) => {
|
|
@@ -94,4 +94,10 @@ exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged:
|
|
|
94
94
|
timeout: triggerWebhookTimeout
|
|
95
95
|
}, maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, userPoolIdOld: String(process.env.USERPOOL_ID_OLD), userPoolIdNew: String(process.env.USERPOOL_ID_NEW) }, (typeof MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number')
|
|
96
96
|
? { maxNumCreditCardPaymentMethod: MAX_NUM_CREDIT_CARD_PAYMENT_METHOD }
|
|
97
|
-
: undefined)
|
|
97
|
+
: undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1', useOffersAppliedToMovieTicketWithoutChargeSpecification: process.env.USE_OFFERS_APPLIED_TO_MOVIE_TICKET_WITHOUT_PRICE_SPEC === '1', useAggregateEntranceGateProjects: (typeof process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS === 'string')
|
|
98
|
+
? process.env.USE_AGGREGATE_ENTRANCE_GATE_PROJECTS.split(',')
|
|
99
|
+
: [], useAggregateOfferProjects: (typeof process.env.USE_AGGREGATE_OFFER_PROJECTS === 'string')
|
|
100
|
+
? process.env.USE_AGGREGATE_OFFER_PROJECTS.split(',')
|
|
101
|
+
: [], useOfferRateLimitProjects: (typeof process.env.USE_OFFER_RATE_LIMIT_PROJECTS === 'string')
|
|
102
|
+
? process.env.USE_OFFER_RATE_LIMIT_PROJECTS.split(',')
|
|
103
|
+
: [], useCheckMovieTicketBeforePay: process.env.USE_CHECK_MOVIE_TICKET_BEFORE_PAY === '1' });
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.289.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.140.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.289.0-alpha.15",
|
|
13
|
+
"@cinerino/sdk": "3.140.0-alpha.16",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.4.0-alpha.
|
|
123
|
+
"version": "20.4.0-alpha.21"
|
|
124
124
|
}
|
|
@@ -1,157 +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
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
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 accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = accountTitleRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
20
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
-
// starDate: { $gte: new Date() }
|
|
22
|
-
// _id: { $eq: 'al6aff83w' }
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
// _id: 1,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
console.log('accountTitles found');
|
|
29
|
-
|
|
30
|
-
const additionalPropertyNamesOnCategories: string[] = [];
|
|
31
|
-
const additionalPropertyNames: string[] = [];
|
|
32
|
-
const additionalPropertyNamesOnTitles: string[] = [];
|
|
33
|
-
const projectIdsOnCategories: string[] = [];
|
|
34
|
-
const projectIds: string[] = [];
|
|
35
|
-
const projectIdsOnTitles: string[] = [];
|
|
36
|
-
const unexpextedprojectIdsOnCategories: string[] = [];
|
|
37
|
-
const unexpextedprojectIds: string[] = [];
|
|
38
|
-
const unexpextedprojectIdsOnTitles: string[] = [];
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
// tslint:disable-next-line:max-func-body-length
|
|
43
|
-
await cursor.eachAsync(async (doc) => {
|
|
44
|
-
i += 1;
|
|
45
|
-
const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
|
|
46
|
-
|
|
47
|
-
const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
|
|
48
|
-
console.log(
|
|
49
|
-
(Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
|
|
50
|
-
'additionalPropertyNamesOnCategory found',
|
|
51
|
-
accountTitleCategory.project.id,
|
|
52
|
-
accountTitleCategory.codeValue
|
|
53
|
-
);
|
|
54
|
-
if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
|
|
55
|
-
console.log(
|
|
56
|
-
additionalPropertyNamesOnCategory.length,
|
|
57
|
-
'additionalPropertyNamesOnResource found',
|
|
58
|
-
accountTitleCategory.project.id,
|
|
59
|
-
accountTitleCategory.codeValue
|
|
60
|
-
);
|
|
61
|
-
additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
|
|
62
|
-
projectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
63
|
-
additionalPropertyNamesOnCategory.forEach((name) => {
|
|
64
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
65
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
-
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
67
|
-
}
|
|
68
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
69
|
-
if (name.length < 5) {
|
|
70
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
-
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
|
|
77
|
-
accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
|
|
78
|
-
const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
|
|
79
|
-
console.log(
|
|
80
|
-
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
81
|
-
'additionalPropertyNamesOnResource found',
|
|
82
|
-
accountTitleCategory.project.id,
|
|
83
|
-
accountTitleCategory.codeValue
|
|
84
|
-
);
|
|
85
|
-
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
86
|
-
console.log(
|
|
87
|
-
additionalPropertyNamesOnResource.length,
|
|
88
|
-
'additionalPropertyNamesOnResource found',
|
|
89
|
-
accountTitleCategory.project.id,
|
|
90
|
-
accountTitleCategory.codeValue
|
|
91
|
-
);
|
|
92
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
93
|
-
projectIds.push(accountTitleCategory.project.id);
|
|
94
|
-
additionalPropertyNamesOnResource.forEach((name) => {
|
|
95
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
96
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
97
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
98
|
-
}
|
|
99
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
100
|
-
if (name.length < 5) {
|
|
101
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
102
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (Array.isArray(accountTitleSet.hasCategoryCode)) {
|
|
108
|
-
accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
|
|
109
|
-
const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
|
|
110
|
-
console.log(
|
|
111
|
-
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
112
|
-
'additionalPropertyNamesOnSection found',
|
|
113
|
-
accountTitleCategory.project.id,
|
|
114
|
-
accountTitleCategory.codeValue
|
|
115
|
-
);
|
|
116
|
-
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
117
|
-
console.log(
|
|
118
|
-
additionalPropertyNamesOnSection.length,
|
|
119
|
-
'additionalPropertyNamesOnSection found',
|
|
120
|
-
accountTitleCategory.project.id,
|
|
121
|
-
accountTitleCategory.codeValue
|
|
122
|
-
);
|
|
123
|
-
additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
|
|
124
|
-
projectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
125
|
-
additionalPropertyNamesOnSection.forEach((name) => {
|
|
126
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
127
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
128
|
-
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
129
|
-
}
|
|
130
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
131
|
-
if (name.length < 5) {
|
|
132
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
133
|
-
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
console.log(i, 'places checked');
|
|
143
|
-
console.log(updateCount, 'places updated');
|
|
144
|
-
console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
|
|
145
|
-
console.log([...new Set(projectIdsOnCategories)], 'categories');
|
|
146
|
-
console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
|
|
147
|
-
console.log([...new Set(additionalPropertyNames)], 'sets');
|
|
148
|
-
console.log([...new Set(projectIds)], 'sets');
|
|
149
|
-
console.log([...new Set(unexpextedprojectIds)], 'sets');
|
|
150
|
-
console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
|
|
151
|
-
console.log([...new Set(projectIdsOnTitles)], 'titles');
|
|
152
|
-
console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
main()
|
|
156
|
-
.then()
|
|
157
|
-
.catch(console.error);
|
|
@@ -1,51 +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
|
-
// tslint:disable-next-line:max-func-body-length
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const cursor = projectRepo.getCursor(
|
|
14
|
-
{
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
// _id: 1,
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
console.log('projects found');
|
|
21
|
-
|
|
22
|
-
let i = 0;
|
|
23
|
-
let updateCount = 0;
|
|
24
|
-
// tslint:disable-next-line:max-func-body-length
|
|
25
|
-
await cursor.eachAsync(async (doc) => {
|
|
26
|
-
i += 1;
|
|
27
|
-
const project: chevre.factory.project.IProject = doc.toObject();
|
|
28
|
-
|
|
29
|
-
const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
|
|
30
|
-
const alreadyMigrated = useEventServiceAsProduct === true;
|
|
31
|
-
|
|
32
|
-
if (alreadyMigrated) {
|
|
33
|
-
console.log('already migrated.', project.id, i);
|
|
34
|
-
} else {
|
|
35
|
-
console.log(
|
|
36
|
-
'updating product...', project.id, i);
|
|
37
|
-
await projectRepo.findByIdAndIUpdate({
|
|
38
|
-
id: project.id,
|
|
39
|
-
subscription: { useEventServiceAsProduct: true }
|
|
40
|
-
});
|
|
41
|
-
updateCount += 1;
|
|
42
|
-
console.log('updated...', project.id, i);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
console.log(i, 'projects checked');
|
|
46
|
-
console.log(updateCount, 'projects updated');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
main()
|
|
50
|
-
.then()
|
|
51
|
-
.catch(console.error);
|