@chevre/domain 21.8.0-alpha.2 → 21.8.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/db/stats.ts +22 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/searchTasks.ts +31 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +6 -0
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +34 -1
- package/lib/chevre/repo/task.d.ts +4 -1
- package/lib/chevre/repo/task.js +108 -22
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +5 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/reserve.js +48 -7
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -5
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +73 -87
- package/lib/chevre/service/order/onOrderStatusChanged.js +98 -73
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +12 -11
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +24 -7
- package/lib/chevre/service/payment/any.js +22 -18
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +16 -4
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +1 -2
- package/lib/chevre/settings.js +2 -5
- package/package.json +2 -2
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -122,11 +122,9 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
122
122
|
const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
|
|
123
123
|
accountsReceivablesByServiceType = validateMovieTicketResult.accountsReceivablesByServiceType;
|
|
124
124
|
const paymentMethod = transaction.object.paymentMethod;
|
|
125
|
-
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
125
|
+
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
|
|
126
126
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
127
|
-
const paymentMethodId =
|
|
128
|
-
? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
|
|
129
|
-
: transaction.id;
|
|
127
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
130
128
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
131
129
|
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;
|
|
132
130
|
if (typeof accountId !== 'string' || accountId.length === 0) {
|
|
@@ -157,15 +155,16 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
157
155
|
exports.authorize = authorize;
|
|
158
156
|
function voidTransaction(params) {
|
|
159
157
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var _a, _b, _c
|
|
158
|
+
var _a, _b, _c;
|
|
161
159
|
const transaction = params.object;
|
|
162
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
160
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
163
161
|
if (typeof paymentMethodType !== 'string') {
|
|
164
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
162
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
165
163
|
}
|
|
166
|
-
const paymentMethodId =
|
|
164
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
165
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
167
166
|
if (typeof paymentMethodId !== 'string') {
|
|
168
|
-
throw new factory.errors.ArgumentNull('object.
|
|
167
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
169
168
|
}
|
|
170
169
|
// 決済開始時に着券していれば、取消
|
|
171
170
|
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
@@ -192,14 +191,14 @@ function voidTransaction(params) {
|
|
|
192
191
|
paymentMethod: {
|
|
193
192
|
paymentMethodId: paymentMethodId,
|
|
194
193
|
typeOf: paymentMethodType,
|
|
195
|
-
name: (typeof ((
|
|
194
|
+
name: (typeof ((_b = transaction.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.name) === 'string')
|
|
196
195
|
? transaction.object.paymentMethod.name
|
|
197
196
|
: paymentMethodType,
|
|
198
197
|
additionalProperty: []
|
|
199
198
|
}
|
|
200
199
|
}], agent: {
|
|
201
200
|
id: seller.id,
|
|
202
|
-
name: (typeof seller.name === 'string') ? seller.name : String((
|
|
201
|
+
name: (typeof seller.name === 'string') ? seller.name : String((_c = seller.name) === null || _c === void 0 ? void 0 : _c.ja),
|
|
203
202
|
typeOf: seller.typeOf
|
|
204
203
|
}, recipient: transaction.recipient }, ((payAction === null || payAction === void 0 ? void 0 : payAction.purpose) !== undefined)
|
|
205
204
|
? { purpose: payAction.purpose }
|
|
@@ -68,7 +68,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
68
68
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
69
69
|
const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
|
|
70
70
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
71
|
-
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.
|
|
71
|
+
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
72
72
|
if (typeof serviceOutputIdentifier !== 'string') {
|
|
73
73
|
throw new factory.errors.ArgumentNull('object.paymentMethod.accountId');
|
|
74
74
|
}
|
|
@@ -76,7 +76,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
76
76
|
throw new factory.errors.ArgumentNull('object.paymentMethod.amount');
|
|
77
77
|
}
|
|
78
78
|
if (typeof paymentMethodType !== 'string') {
|
|
79
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
79
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
80
80
|
}
|
|
81
81
|
// プロダクトから通貨区分を取得
|
|
82
82
|
const paymentCatdProduct = yield repos.product.findById({ id: paymentServiceId }, ['serviceOutput'], []);
|
|
@@ -182,15 +182,12 @@ function processAccountTransaction(params) {
|
|
|
182
182
|
}
|
|
183
183
|
function voidTransaction(params) {
|
|
184
184
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
var _a, _b, _c
|
|
185
|
+
var _a, _b, _c;
|
|
186
186
|
const transaction = params.object;
|
|
187
|
-
const
|
|
188
|
-
const paymentMethodId =
|
|
189
|
-
if (typeof paymentMethodType !== 'string') {
|
|
190
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
191
|
-
}
|
|
187
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
188
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
192
189
|
if (typeof paymentMethodId !== 'string') {
|
|
193
|
-
throw new factory.errors.ArgumentNull('object.
|
|
190
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
194
191
|
}
|
|
195
192
|
const paymentServiceId = String(transaction.object.id);
|
|
196
193
|
// アクションステータスに関係なく取消処理実行
|
|
@@ -204,9 +201,9 @@ function voidTransaction(params) {
|
|
|
204
201
|
const accountTransactionService = new pecorinoapi.service.AccountTransaction({
|
|
205
202
|
endpoint: String(availableChannel.serviceUrl),
|
|
206
203
|
auth: new pecorinoapi.auth.ClientCredentials({
|
|
207
|
-
domain: String((
|
|
208
|
-
clientId: String((
|
|
209
|
-
clientSecret: String((
|
|
204
|
+
domain: String((_a = availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.authorizeServerDomain),
|
|
205
|
+
clientId: String((_b = availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.clientId),
|
|
206
|
+
clientSecret: String((_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.clientSecret),
|
|
210
207
|
scopes: [],
|
|
211
208
|
state: ''
|
|
212
209
|
})
|
|
@@ -13,7 +13,6 @@ exports.onReservationCanceled = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -41,9 +40,7 @@ reservationFor) {
|
|
|
41
40
|
if (useInformReservation) {
|
|
42
41
|
if (Array.isArray(informReservations)) {
|
|
43
42
|
// やや遅延させる(確定通知が未達の可能性を考慮して)
|
|
44
|
-
const informTaskRunsAt =
|
|
45
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
46
|
-
.toDate();
|
|
43
|
+
const informTaskRunsAt = now;
|
|
47
44
|
const reservations4inform = canceledReservations.map((r) => {
|
|
48
45
|
return {
|
|
49
46
|
typeOf: r.typeOf,
|
|
@@ -13,7 +13,6 @@ exports.onReservationCheckedIn = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約発券時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -28,10 +27,7 @@ function onReservationCheckedIn(params) {
|
|
|
28
27
|
const project = { id: params.project.id, typeOf: factory.organizationType.Project };
|
|
29
28
|
// inform galobally
|
|
30
29
|
if (Array.isArray(informReservations)) {
|
|
31
|
-
|
|
32
|
-
const informTaskRunsAt = moment(params.now)
|
|
33
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
34
|
-
.toDate();
|
|
30
|
+
const informTaskRunsAt = params.now;
|
|
35
31
|
informReservations.forEach((informReservation) => {
|
|
36
32
|
var _a;
|
|
37
33
|
const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
@@ -13,7 +13,6 @@ exports.onReservationUsed = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約使用時アクション
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
17
16
|
const factory = require("../../../factory");
|
|
18
17
|
const settings_1 = require("../../../settings");
|
|
19
18
|
const offer_1 = require("../../offer");
|
|
@@ -30,9 +29,7 @@ function onReservationUsed(action, attendedReservation) {
|
|
|
30
29
|
// inform galobally
|
|
31
30
|
if (Array.isArray(informReservations)) {
|
|
32
31
|
// やや遅延させる(確定通知が未達の可能性を考慮して)
|
|
33
|
-
const informTaskRunsAt =
|
|
34
|
-
.add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
35
|
-
.toDate();
|
|
32
|
+
const informTaskRunsAt = now;
|
|
36
33
|
const reservation4inform = {
|
|
37
34
|
typeOf: attendedReservation.typeOf,
|
|
38
35
|
project: attendedReservation.project,
|
|
@@ -13,7 +13,6 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
|
-
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
17
16
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
18
17
|
const event_1 = require("../../repo/event");
|
|
19
18
|
const order_1 = require("../../repo/order");
|
|
@@ -41,8 +40,7 @@ function call(data) {
|
|
|
41
40
|
project: new project_1.MongoRepository(settings.connection),
|
|
42
41
|
seller: new seller_1.MongoRepository(settings.connection),
|
|
43
42
|
task: new task_1.MongoRepository(settings.connection),
|
|
44
|
-
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
45
|
-
registerServiceInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient)
|
|
43
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
46
44
|
});
|
|
47
45
|
});
|
|
48
46
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
15
|
+
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const order_1 = require("../../repo/order");
|
|
17
|
+
const task_1 = require("../../repo/task");
|
|
18
|
+
const transaction_1 = require("../../repo/transaction");
|
|
19
|
+
const onAssetTransactionStatusChanged_1 = require("../order/onAssetTransactionStatusChanged");
|
|
20
|
+
/**
|
|
21
|
+
* タスク実行関数
|
|
22
|
+
*/
|
|
23
|
+
function call(data) {
|
|
24
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (settings.redisClient === undefined) {
|
|
26
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
27
|
+
}
|
|
28
|
+
yield (0, onAssetTransactionStatusChanged_1.onAssetTransactionStatusChanged)(data)({
|
|
29
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
30
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
31
|
+
registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
|
|
32
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
33
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.call = call;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
15
|
+
const order_1 = require("../../repo/order");
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
17
|
+
const transaction_1 = require("../../repo/transaction");
|
|
18
|
+
const payOrder_1 = require("../order/payOrder");
|
|
19
|
+
/**
|
|
20
|
+
* タスク実行関数
|
|
21
|
+
*/
|
|
22
|
+
function call(data) {
|
|
23
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (settings.redisClient === undefined) {
|
|
25
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
26
|
+
}
|
|
27
|
+
yield (0, payOrder_1.payOrder)(data)({
|
|
28
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
29
|
+
registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
|
|
30
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
31
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.call = call;
|
|
@@ -159,7 +159,11 @@ function transaction2refundFee(params) {
|
|
|
159
159
|
return refundFee;
|
|
160
160
|
}
|
|
161
161
|
function createStartRefundTransactionParams(params) {
|
|
162
|
-
var _a;
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
164
|
+
if (typeof paymentMethodType !== 'string') {
|
|
165
|
+
throw new factory.errors.NotFound('object.paymentMethod.identifier');
|
|
166
|
+
}
|
|
163
167
|
return {
|
|
164
168
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
165
169
|
typeOf: factory.assetTransactionType.Refund,
|
|
@@ -173,11 +177,12 @@ function createStartRefundTransactionParams(params) {
|
|
|
173
177
|
recipient: { typeOf: params.recipient.typeOf, name: params.recipient.name },
|
|
174
178
|
object: {
|
|
175
179
|
typeOf: params.paymentServiceType,
|
|
176
|
-
id: (typeof ((
|
|
180
|
+
id: (typeof ((_b = params.object.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? params.object.issuedThrough.id : '',
|
|
177
181
|
paymentMethod: {
|
|
178
182
|
additionalProperty: params.object.additionalProperty,
|
|
179
183
|
name: params.object.name,
|
|
180
|
-
typeOf: params.object.typeOf,
|
|
184
|
+
// typeOf: params.object.typeOf,
|
|
185
|
+
typeOf: paymentMethodType,
|
|
181
186
|
paymentMethodId: params.object.paymentMethodId
|
|
182
187
|
},
|
|
183
188
|
refundFee: params.refundFee
|
|
@@ -73,15 +73,27 @@ function createPaymentMethods(params) {
|
|
|
73
73
|
var _a, _b, _c;
|
|
74
74
|
const result = a.result;
|
|
75
75
|
const paymentMethodAmountCurrencyByAuthorizeAction = (_b = (_a = result.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
|
|
76
|
-
const paymentMethodOfInvoice = (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
77
|
-
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
78
|
-
: undefined;
|
|
79
76
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
80
77
|
const paymentMethodType = (_c = result.paymentMethodAsObject) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
81
78
|
if (typeof paymentMethodType !== 'string') {
|
|
82
79
|
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
80
|
}
|
|
84
|
-
|
|
81
|
+
const paymentMethodOfInvoice = Object.assign({ identifier: paymentMethodType }, (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
82
|
+
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
83
|
+
: undefined);
|
|
84
|
+
paymentMethods.push({
|
|
85
|
+
accountId: result.accountId,
|
|
86
|
+
additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [],
|
|
87
|
+
issuedThrough: result.issuedThrough,
|
|
88
|
+
name: result.name,
|
|
89
|
+
paymentMethodId: result.paymentMethodId,
|
|
90
|
+
paymentStatus: result.paymentStatus,
|
|
91
|
+
totalPaymentDue: result.totalPaymentDue,
|
|
92
|
+
typeOf: paymentMethodType,
|
|
93
|
+
// CreditCardIFのカード通貨区分を追加(2023-08-15~)
|
|
94
|
+
// 決済方法区分を保証(2023-08-28~)
|
|
95
|
+
paymentMethod: paymentMethodOfInvoice
|
|
96
|
+
});
|
|
85
97
|
});
|
|
86
98
|
// 決済方法から注文金額の計算
|
|
87
99
|
// price += authorizePaymentActions
|
|
@@ -22,6 +22,7 @@ const validation_1 = require("./placeOrderInProgress/validation");
|
|
|
22
22
|
const validateSeller_1 = require("./placeOrderInProgress/validation/validateSeller");
|
|
23
23
|
const validation_2 = require("./validation");
|
|
24
24
|
const errorHandler_1 = require("../../errorHandler");
|
|
25
|
+
const settings_1 = require("../../settings");
|
|
25
26
|
exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
26
27
|
/**
|
|
27
28
|
* 取引開始
|
|
@@ -226,7 +227,9 @@ function createResult(params) {
|
|
|
226
227
|
orderNumber: params.orderNumber,
|
|
227
228
|
transaction: transaction,
|
|
228
229
|
orderDate: params.result.order.orderDate,
|
|
229
|
-
|
|
230
|
+
// OrderPaymentDueオプションを追加(2023-08-25~)
|
|
231
|
+
// 注文作成時のステータスとなる
|
|
232
|
+
orderStatus: (settings_1.USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
|
|
230
233
|
isGift: false,
|
|
231
234
|
authorizeActions: params.authorizeActions
|
|
232
235
|
});
|
|
@@ -138,18 +138,19 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
|
138
138
|
const order = params.order;
|
|
139
139
|
const returnFeesMovieTicketByTransaction = params.transaction.object.returnPolicy.returnFeesMovieTicket;
|
|
140
140
|
return Promise.all(params.order.paymentMethods
|
|
141
|
-
.filter((
|
|
142
|
-
return
|
|
141
|
+
.filter((invoice) => {
|
|
142
|
+
return invoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
143
143
|
})
|
|
144
144
|
// 決済カード着券取消有無設定を適用
|
|
145
|
-
.filter((
|
|
145
|
+
.filter((invoice) => {
|
|
146
146
|
// デフォルトで実行する
|
|
147
147
|
let returnPaymentMethod = true;
|
|
148
|
-
const movieTicketIdentifier =
|
|
148
|
+
const movieTicketIdentifier = invoice.accountId;
|
|
149
149
|
const returnFeesMovieTicketSettingsByIdentifier = returnFeesMovieTicketByTransaction === null || returnFeesMovieTicketByTransaction === void 0 ? void 0 : returnFeesMovieTicketByTransaction.filter((r) => {
|
|
150
|
-
var _a;
|
|
150
|
+
var _a, _b;
|
|
151
151
|
return r.identifier === String(movieTicketIdentifier)
|
|
152
|
-
&&
|
|
152
|
+
// && r.serviceOutput?.typeOf === invoice.typeOf;
|
|
153
|
+
&& ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === ((_b = invoice.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier);
|
|
153
154
|
});
|
|
154
155
|
// 設定がなければスルー
|
|
155
156
|
if (Array.isArray(returnFeesMovieTicketSettingsByIdentifier) && returnFeesMovieTicketSettingsByIdentifier.length > 0) {
|
|
@@ -356,7 +356,11 @@ function isSellerReturnPolicyApplicable(params) {
|
|
|
356
356
|
if (Array.isArray(applicablePaymentMethod)) {
|
|
357
357
|
const everyOrderApplicable = params.orders.every((order) => {
|
|
358
358
|
// 全決済方法区分がapplicablePaymentMethodに含まれれば適用
|
|
359
|
-
return order.paymentMethods.every((
|
|
359
|
+
return order.paymentMethods.every((invoice) => {
|
|
360
|
+
var _a;
|
|
361
|
+
return typeof ((_a = invoice.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier) === 'string'
|
|
362
|
+
&& applicablePaymentMethod.includes(invoice.paymentMethod.identifier);
|
|
363
|
+
});
|
|
360
364
|
});
|
|
361
365
|
// 全注文について確認ができれば適用
|
|
362
366
|
if (everyOrderApplicable) {
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -36,13 +36,12 @@ export type ISettings = factory.project.ISettings & {
|
|
|
36
36
|
};
|
|
37
37
|
export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
38
38
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
39
|
-
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
40
39
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
41
40
|
export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
42
41
|
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
43
42
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
44
43
|
export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
|
|
45
|
-
export declare const
|
|
44
|
+
export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
|
|
46
45
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
47
46
|
/**
|
|
48
47
|
* グローバル設定
|
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.MONGO_MAX_TIME_MS = exports.
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = 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.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -60,7 +60,6 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSA
|
|
|
60
60
|
exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
|
|
61
61
|
exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
|
|
62
62
|
exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
63
|
-
exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
64
63
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
65
64
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
66
65
|
: moment('2023-08-31T15:00:00Z');
|
|
@@ -74,9 +73,7 @@ exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIR
|
|
|
74
73
|
exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
|
|
75
74
|
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
76
75
|
exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
|
|
77
|
-
exports.
|
|
78
|
-
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
79
|
-
: 0;
|
|
76
|
+
exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
|
|
80
77
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
81
78
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
82
79
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.328.0",
|
|
13
13
|
"@cinerino/sdk": "3.165.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.21"
|
|
121
121
|
}
|
|
@@ -1,154 +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 eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
-
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = eventRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
// 'project.id': { $eq: project.id },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
-
typeOf: {
|
|
22
|
-
$in: [
|
|
23
|
-
// chevre.factory.eventType.ScreeningEvent,
|
|
24
|
-
chevre.factory.eventType.ScreeningEventSeries
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
organizer: { $exists: true },
|
|
28
|
-
startDate: {
|
|
29
|
-
$gte: moment()
|
|
30
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
31
|
-
.add(-3, 'months')
|
|
32
|
-
.toDate()
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
_id: 1,
|
|
37
|
-
project: 1,
|
|
38
|
-
location: 1,
|
|
39
|
-
superEvent: 1,
|
|
40
|
-
startDate: 1,
|
|
41
|
-
typeOf: 1,
|
|
42
|
-
organizer: 1
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
console.log('events found');
|
|
46
|
-
|
|
47
|
-
let i = 0;
|
|
48
|
-
let updateCount = 0;
|
|
49
|
-
let invalidOrganizerCount = 0;
|
|
50
|
-
await cursor.eachAsync(async (doc) => {
|
|
51
|
-
i += 1;
|
|
52
|
-
const event: Pick<
|
|
53
|
-
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
|
|
54
|
-
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer' | 'superEvent'
|
|
55
|
-
> | Pick<
|
|
56
|
-
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEventSeries>,
|
|
57
|
-
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer'
|
|
58
|
-
> = doc.toObject();
|
|
59
|
-
|
|
60
|
-
const organizerId = event.organizer?.id;
|
|
61
|
-
|
|
62
|
-
let movieTheaterId: string;
|
|
63
|
-
let movieTheaterBranchCode: string;
|
|
64
|
-
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
65
|
-
movieTheaterId = event.location.id;
|
|
66
|
-
movieTheaterBranchCode = event.location.branchCode;
|
|
67
|
-
} else {
|
|
68
|
-
movieTheaterId = event.superEvent.location.id;
|
|
69
|
-
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
70
|
-
}
|
|
71
|
-
const movieTheaters = <Pick<
|
|
72
|
-
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
73
|
-
'parentOrganization' | 'branchCode'
|
|
74
|
-
>[]>
|
|
75
|
-
await placeRepo.searchMovieTheaters(
|
|
76
|
-
{
|
|
77
|
-
limit: 1,
|
|
78
|
-
page: 1,
|
|
79
|
-
project: { id: { $eq: event.project.id } },
|
|
80
|
-
id: { $eq: movieTheaterId }
|
|
81
|
-
},
|
|
82
|
-
['parentOrganization', 'branchCode'],
|
|
83
|
-
[]
|
|
84
|
-
);
|
|
85
|
-
const movieTheater = movieTheaters.shift();
|
|
86
|
-
const sellerId = movieTheater?.parentOrganization?.id;
|
|
87
|
-
console.log(
|
|
88
|
-
'movieTheater found',
|
|
89
|
-
event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
|
|
90
|
-
'movieTheaterId:', movieTheaterId,
|
|
91
|
-
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
92
|
-
i
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const alreadyMigrated = typeof organizerId === 'string';
|
|
96
|
-
|
|
97
|
-
if (alreadyMigrated) {
|
|
98
|
-
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
99
|
-
if (organizerId === sellerId) {
|
|
100
|
-
console.log('organizerId is valid', event.project.id, event.id, event.startDate, organizerId, i);
|
|
101
|
-
} else {
|
|
102
|
-
invalidOrganizerCount += 1;
|
|
103
|
-
|
|
104
|
-
// organizerを修正する
|
|
105
|
-
if (typeof sellerId !== 'string') {
|
|
106
|
-
throw new Error('movieTheater not found');
|
|
107
|
-
}
|
|
108
|
-
const fixedOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
|
|
109
|
-
id: sellerId
|
|
110
|
-
};
|
|
111
|
-
console.log('updating event...', event.project.id, event.id, event.startDate, i);
|
|
112
|
-
await eventRepo.updatePartiallyById({
|
|
113
|
-
project: { id: event.project.id },
|
|
114
|
-
id: event.id,
|
|
115
|
-
attributes: <any>{
|
|
116
|
-
typeOf: event.typeOf,
|
|
117
|
-
organizer: fixedOrganizer
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
updateCount += 1;
|
|
121
|
-
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
throw new Error('organizer not found');
|
|
125
|
-
// if (typeof sellerId !== 'string') {
|
|
126
|
-
// throw new Error('movieTheater not found');
|
|
127
|
-
// }
|
|
128
|
-
// if (typeof sellerId === 'string') {
|
|
129
|
-
// const newOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
|
|
130
|
-
// id: sellerId
|
|
131
|
-
// };
|
|
132
|
-
// console.log('updating event...', event.project.id, event.id, event.startDate, i);
|
|
133
|
-
// await eventRepo.updatePartiallyById({
|
|
134
|
-
// project: { id: event.project.id },
|
|
135
|
-
// id: event.id,
|
|
136
|
-
// attributes: <any>{
|
|
137
|
-
// typeOf: event.typeOf,
|
|
138
|
-
// organizer: newOrganizer
|
|
139
|
-
// }
|
|
140
|
-
// });
|
|
141
|
-
// updateCount += 1;
|
|
142
|
-
// console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
143
|
-
// }
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
console.log(i, 'events checked');
|
|
148
|
-
console.log(updateCount, 'events updated');
|
|
149
|
-
console.log(invalidOrganizerCount, 'invalid');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
main()
|
|
153
|
-
.then()
|
|
154
|
-
.catch(console.error);
|