@chevre/domain 21.7.0 → 21.8.0-alpha.1
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/emailMessageBuilder.js +2 -1
- package/lib/chevre/repo/assetTransaction.js +22 -23
- package/lib/chevre/service/order/onOrderStatusChanged.js +19 -4
- package/lib/chevre/service/order/payOrder.d.ts +23 -0
- package/lib/chevre/service/order/payOrder.js +74 -0
- package/lib/chevre/service/order/placeOrder.js +20 -4
- package/lib/chevre/service/payment/any/factory.js +1 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +56 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +1 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -115,7 +115,8 @@ function createEmailMessageSender(params) {
|
|
|
115
115
|
: (typeof params.order.seller.name === 'string')
|
|
116
116
|
? params.order.seller.name
|
|
117
117
|
: String(params.order.seller.id),
|
|
118
|
-
|
|
118
|
+
// sender.email指定を非推奨化(2023-08-23~)
|
|
119
|
+
email: (settings_1.USE_CUSTOM_SENDER_EMAIL && typeof ((_d = (_c = params.email) === null || _c === void 0 ? void 0 : _c.sender) === null || _d === void 0 ? void 0 : _d.email) === 'string')
|
|
119
120
|
? params.email.sender.email
|
|
120
121
|
: settings_1.DEFAULT_SENDER_EMAIL
|
|
121
122
|
};
|
|
@@ -24,7 +24,7 @@ class MongoRepository {
|
|
|
24
24
|
}
|
|
25
25
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
26
26
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
28
28
|
const andConditions = [
|
|
29
29
|
{
|
|
30
30
|
typeOf: params.typeOf
|
|
@@ -97,12 +97,11 @@ class MongoRepository {
|
|
|
97
97
|
}
|
|
98
98
|
const transactionNumberEq = (_c = params.transactionNumber) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
99
99
|
if (typeof transactionNumberEq === 'string') {
|
|
100
|
-
andConditions.push({
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
100
|
+
andConditions.push({ transactionNumber: { $exists: true, $eq: transactionNumberEq } });
|
|
101
|
+
}
|
|
102
|
+
const transactionNumberIn = (_d = params.transactionNumber) === null || _d === void 0 ? void 0 : _d.$in;
|
|
103
|
+
if (Array.isArray(transactionNumberIn)) {
|
|
104
|
+
andConditions.push({ transactionNumber: { $exists: true, $in: transactionNumberIn } });
|
|
106
105
|
}
|
|
107
106
|
if (Array.isArray(params.tasksExportationStatuses)) {
|
|
108
107
|
andConditions.push({
|
|
@@ -111,7 +110,7 @@ class MongoRepository {
|
|
|
111
110
|
}
|
|
112
111
|
switch (params.typeOf) {
|
|
113
112
|
case factory.assetTransactionType.Pay:
|
|
114
|
-
const objectAccountIdEq = (
|
|
113
|
+
const objectAccountIdEq = (_f = (_e = params.object) === null || _e === void 0 ? void 0 : _e.accountId) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
115
114
|
if (typeof objectAccountIdEq === 'string') {
|
|
116
115
|
andConditions.push({
|
|
117
116
|
'object.accountId': {
|
|
@@ -122,7 +121,7 @@ class MongoRepository {
|
|
|
122
121
|
}
|
|
123
122
|
break;
|
|
124
123
|
case factory.assetTransactionType.Refund:
|
|
125
|
-
const objectAccountIdEq4refund = (
|
|
124
|
+
const objectAccountIdEq4refund = (_h = (_g = params.object) === null || _g === void 0 ? void 0 : _g.accountId) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
126
125
|
if (typeof objectAccountIdEq4refund === 'string') {
|
|
127
126
|
andConditions.push({
|
|
128
127
|
'object.accountId': {
|
|
@@ -131,13 +130,13 @@ class MongoRepository {
|
|
|
131
130
|
}
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
|
-
const objectPaymentMethodIdEq4refund = (
|
|
133
|
+
const objectPaymentMethodIdEq4refund = (_k = (_j = params.object) === null || _j === void 0 ? void 0 : _j.paymentMethodId) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
135
134
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
136
135
|
andConditions.push({
|
|
137
136
|
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
|
-
const objectPaymentMethodIdIn4refund = (
|
|
139
|
+
const objectPaymentMethodIdIn4refund = (_m = (_l = params.object) === null || _l === void 0 ? void 0 : _l.paymentMethodId) === null || _m === void 0 ? void 0 : _m.$in;
|
|
141
140
|
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
142
141
|
andConditions.push({
|
|
143
142
|
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
@@ -145,7 +144,7 @@ class MongoRepository {
|
|
|
145
144
|
}
|
|
146
145
|
break;
|
|
147
146
|
case factory.assetTransactionType.MoneyTransfer:
|
|
148
|
-
const fromLocationIdentifierEq = (
|
|
147
|
+
const fromLocationIdentifierEq = (_q = (_p = (_o = params.object) === null || _o === void 0 ? void 0 : _o.fromLocation) === null || _p === void 0 ? void 0 : _p.identifier) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
149
148
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
150
149
|
andConditions.push({
|
|
151
150
|
'object.fromLocation.identifier': {
|
|
@@ -154,7 +153,7 @@ class MongoRepository {
|
|
|
154
153
|
}
|
|
155
154
|
});
|
|
156
155
|
}
|
|
157
|
-
const toLocationIdentifierEq = (
|
|
156
|
+
const toLocationIdentifierEq = (_t = (_s = (_r = params.object) === null || _r === void 0 ? void 0 : _r.toLocation) === null || _s === void 0 ? void 0 : _s.identifier) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
158
157
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
159
158
|
andConditions.push({
|
|
160
159
|
'object.toLocation.identifier': {
|
|
@@ -163,7 +162,7 @@ class MongoRepository {
|
|
|
163
162
|
}
|
|
164
163
|
});
|
|
165
164
|
}
|
|
166
|
-
const pendingTransactionIdentifierEq = (
|
|
165
|
+
const pendingTransactionIdentifierEq = (_w = (_v = (_u = params.object) === null || _u === void 0 ? void 0 : _u.pendingTransaction) === null || _v === void 0 ? void 0 : _v.identifier) === null || _w === void 0 ? void 0 : _w.$eq;
|
|
167
166
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
168
167
|
andConditions.push({
|
|
169
168
|
'object.pendingTransaction.identifier': {
|
|
@@ -176,11 +175,11 @@ class MongoRepository {
|
|
|
176
175
|
case factory.assetTransactionType.CancelReservation:
|
|
177
176
|
break;
|
|
178
177
|
case factory.assetTransactionType.Reserve:
|
|
179
|
-
const objectProviderIdEq = (
|
|
178
|
+
const objectProviderIdEq = (_z = (_y = (_x = params.object) === null || _x === void 0 ? void 0 : _x.provider) === null || _y === void 0 ? void 0 : _y.id) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
180
179
|
if (typeof objectProviderIdEq === 'string') {
|
|
181
180
|
andConditions.push({ 'object.provider.id': { $exists: true, $eq: objectProviderIdEq } });
|
|
182
181
|
}
|
|
183
|
-
const objectReservationForIdEq = (
|
|
182
|
+
const objectReservationForIdEq = (_2 = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.reservationFor) === null || _1 === void 0 ? void 0 : _1.id) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
184
183
|
if (typeof objectReservationForIdEq === 'string') {
|
|
185
184
|
andConditions.push({
|
|
186
185
|
'object.reservationFor.id': {
|
|
@@ -189,7 +188,7 @@ class MongoRepository {
|
|
|
189
188
|
}
|
|
190
189
|
});
|
|
191
190
|
}
|
|
192
|
-
const objectReservationNumberIn = (
|
|
191
|
+
const objectReservationNumberIn = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservationNumber) === null || _4 === void 0 ? void 0 : _4.$in;
|
|
193
192
|
if (Array.isArray(objectReservationNumberIn)) {
|
|
194
193
|
andConditions.push({
|
|
195
194
|
'object.reservationNumber': {
|
|
@@ -198,7 +197,7 @@ class MongoRepository {
|
|
|
198
197
|
}
|
|
199
198
|
});
|
|
200
199
|
}
|
|
201
|
-
const objectReservationNumberEq = (
|
|
200
|
+
const objectReservationNumberEq = (_6 = (_5 = params.object) === null || _5 === void 0 ? void 0 : _5.reservationNumber) === null || _6 === void 0 ? void 0 : _6.$eq;
|
|
202
201
|
if (typeof objectReservationNumberEq === 'string') {
|
|
203
202
|
andConditions.push({
|
|
204
203
|
'object.reservationNumber': {
|
|
@@ -207,7 +206,7 @@ class MongoRepository {
|
|
|
207
206
|
}
|
|
208
207
|
});
|
|
209
208
|
}
|
|
210
|
-
const objectSubReservationIdIn = (
|
|
209
|
+
const objectSubReservationIdIn = (_9 = (_8 = (_7 = params.object) === null || _7 === void 0 ? void 0 : _7.reservations) === null || _8 === void 0 ? void 0 : _8.id) === null || _9 === void 0 ? void 0 : _9.$in;
|
|
211
210
|
if (Array.isArray(objectSubReservationIdIn)) {
|
|
212
211
|
andConditions.push({
|
|
213
212
|
'object.subReservation.id': {
|
|
@@ -242,7 +241,7 @@ class MongoRepository {
|
|
|
242
241
|
}
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
|
-
const objectUnderNameIdEq = (
|
|
244
|
+
const objectUnderNameIdEq = (_12 = (_11 = (_10 = params.object) === null || _10 === void 0 ? void 0 : _10.underName) === null || _11 === void 0 ? void 0 : _11.id) === null || _12 === void 0 ? void 0 : _12.$eq;
|
|
246
245
|
if (typeof objectUnderNameIdEq === 'string') {
|
|
247
246
|
andConditions.push({
|
|
248
247
|
'object.underName.id': {
|
|
@@ -251,7 +250,7 @@ class MongoRepository {
|
|
|
251
250
|
}
|
|
252
251
|
});
|
|
253
252
|
}
|
|
254
|
-
const objectSubReservationSeatNumberEq = (_16 = (_15 = (_14 = (_13 =
|
|
253
|
+
const objectSubReservationSeatNumberEq = (_17 = (_16 = (_15 = (_14 = (_13 = params.object) === null || _13 === void 0 ? void 0 : _13.reservations) === null || _14 === void 0 ? void 0 : _14.reservedTicket) === null || _15 === void 0 ? void 0 : _15.ticketedSeat) === null || _16 === void 0 ? void 0 : _16.seatNumber) === null || _17 === void 0 ? void 0 : _17.$eq;
|
|
255
254
|
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
256
255
|
andConditions.push({
|
|
257
256
|
'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
@@ -262,7 +261,7 @@ class MongoRepository {
|
|
|
262
261
|
}
|
|
263
262
|
break;
|
|
264
263
|
case factory.assetTransactionType.RegisterService:
|
|
265
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
264
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_21 = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$eq;
|
|
266
265
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
267
266
|
andConditions.push({
|
|
268
267
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -271,7 +270,7 @@ class MongoRepository {
|
|
|
271
270
|
}
|
|
272
271
|
});
|
|
273
272
|
}
|
|
274
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
273
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_25 = (_24 = (_23 = (_22 = params.object) === null || _22 === void 0 ? void 0 : _22.itemOffered) === null || _23 === void 0 ? void 0 : _23.serviceOutput) === null || _24 === void 0 ? void 0 : _24.identifier) === null || _25 === void 0 ? void 0 : _25.$in;
|
|
275
274
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
276
275
|
andConditions.push({
|
|
277
276
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -22,6 +22,7 @@ const factory_1 = require("./onOrderStatusChanged/factory");
|
|
|
22
22
|
const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTER_SERVICE_TRANSACTION === '1';
|
|
23
23
|
const TOKEN_EXPIRES_IN = 604800;
|
|
24
24
|
function onOrderStatusChanged(params) {
|
|
25
|
+
// tslint:disable-next-line:max-func-body-length
|
|
25
26
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
27
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
27
28
|
let tasks = [];
|
|
@@ -76,6 +77,12 @@ function onOrderStatusChanged(params) {
|
|
|
76
77
|
throw error;
|
|
77
78
|
}
|
|
78
79
|
break;
|
|
80
|
+
// OrderPaymentDueを追加(2023-08-23~)
|
|
81
|
+
case factory.orderStatus.OrderPaymentDue:
|
|
82
|
+
tasks = [
|
|
83
|
+
...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos)
|
|
84
|
+
];
|
|
85
|
+
break;
|
|
79
86
|
case factory.orderStatus.OrderProcessing:
|
|
80
87
|
const orderWithToken = yield (0, factory_1.getOrderWithToken)({ order: params.order, expiresIn: TOKEN_EXPIRES_IN });
|
|
81
88
|
tasks = [
|
|
@@ -116,7 +123,13 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
116
123
|
const taskRunsAt = moment(order.orderDate)
|
|
117
124
|
.toDate();
|
|
118
125
|
const tasks = [];
|
|
119
|
-
yield Promise.all(order.paymentMethods.map((
|
|
126
|
+
yield Promise.all(order.paymentMethods.map((invoice) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
128
|
+
// TODO 注文にpaymentStatusを保証した後に実装する
|
|
129
|
+
// PaymentAutomaticallyAppliedであれば、自動決済処理を実行
|
|
130
|
+
// if (invoice.paymentStatus !== factory.paymentStatusType.PaymentAutomaticallyApplied) {
|
|
131
|
+
// return;
|
|
132
|
+
// }
|
|
120
133
|
// 冗長なタスク作成を回避
|
|
121
134
|
const existingTasks = yield repos.task.search({
|
|
122
135
|
limit: 1,
|
|
@@ -124,7 +137,7 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
124
137
|
project: { id: { $eq: order.project.id } },
|
|
125
138
|
name: factory.taskName.ConfirmPayTransaction,
|
|
126
139
|
data: {
|
|
127
|
-
object: { transactionNumber: { $eq:
|
|
140
|
+
object: { transactionNumber: { $eq: invoice.paymentMethodId } },
|
|
128
141
|
purpose: { orderNumber: { $eq: order.orderNumber } }
|
|
129
142
|
}
|
|
130
143
|
}, {
|
|
@@ -135,13 +148,15 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
135
148
|
const data = {
|
|
136
149
|
project: order.project,
|
|
137
150
|
typeOf: factory.actionType.ConfirmAction,
|
|
138
|
-
object: [{ typeOf: factory.assetTransactionType.Pay, transactionNumber:
|
|
151
|
+
object: [{ typeOf: factory.assetTransactionType.Pay, transactionNumber: invoice.paymentMethodId }],
|
|
139
152
|
agent: order.project,
|
|
140
153
|
purpose: Object.assign(Object.assign({}, simpleOrder), { confirmationNumber: order.confirmationNumber }),
|
|
141
154
|
instrument: {
|
|
142
155
|
typeOf: 'WebAPI',
|
|
143
156
|
identifier: factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre
|
|
144
|
-
}
|
|
157
|
+
},
|
|
158
|
+
processOrder: order.orderStatus === factory.orderStatus.OrderPaymentDue,
|
|
159
|
+
useOnOrderStatusChanged: true
|
|
145
160
|
};
|
|
146
161
|
tasks.push({
|
|
147
162
|
project: order.project,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
2
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
|
+
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
4
|
+
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
5
|
+
/**
|
|
6
|
+
* 注文を決済する
|
|
7
|
+
*/
|
|
8
|
+
declare function payOrder(params: {
|
|
9
|
+
project: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
object: {
|
|
13
|
+
confirmationNumber: string;
|
|
14
|
+
orderNumber: string;
|
|
15
|
+
};
|
|
16
|
+
useOnOrderStatusChanged: boolean;
|
|
17
|
+
}): (repos: {
|
|
18
|
+
order: OrderRepo;
|
|
19
|
+
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
20
|
+
task: TaskRepo;
|
|
21
|
+
transaction: TransactionRepo;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
export { payOrder };
|
|
@@ -0,0 +1,74 @@
|
|
|
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.payOrder = void 0;
|
|
13
|
+
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
14
|
+
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
15
|
+
const factory = require("../../factory");
|
|
16
|
+
/**
|
|
17
|
+
* 注文を決済する
|
|
18
|
+
*/
|
|
19
|
+
function payOrder(params) {
|
|
20
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
22
|
+
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
23
|
+
}
|
|
24
|
+
const orderNumber = params.object.orderNumber;
|
|
25
|
+
const confirmationNumber = params.object.confirmationNumber;
|
|
26
|
+
const placeOrderTransaction = yield (0, findPlaceOrderTransaction_1.findPlaceOrderTransaction)({
|
|
27
|
+
project: { id: params.project.id },
|
|
28
|
+
confirmationNumber,
|
|
29
|
+
orderNumber
|
|
30
|
+
})({ transaction: repos.transaction });
|
|
31
|
+
let order = yield repos.order.findByOrderNumber({
|
|
32
|
+
orderNumber,
|
|
33
|
+
project: { id: params.project.id },
|
|
34
|
+
inclusion: [],
|
|
35
|
+
exclusion: []
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
order = yield repos.order.changeStatus({
|
|
39
|
+
project: { id: order.project.id },
|
|
40
|
+
orderNumber,
|
|
41
|
+
orderStatus: factory.orderStatus.OrderProcessing,
|
|
42
|
+
previousOrderStatus: factory.orderStatus.OrderPaymentDue
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
let throwsError = true;
|
|
47
|
+
// すでにステータスが煤でいた場合、OrderPaymentDue->OrderProcessingの処理自体は成功しているので、後処理を続行する
|
|
48
|
+
order = yield repos.order.findByOrderNumber({
|
|
49
|
+
orderNumber: params.object.orderNumber,
|
|
50
|
+
project: { id: params.project.id },
|
|
51
|
+
inclusion: [],
|
|
52
|
+
exclusion: []
|
|
53
|
+
});
|
|
54
|
+
if (order.orderStatus === factory.orderStatus.OrderDelivered
|
|
55
|
+
|| order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
56
|
+
throwsError = false;
|
|
57
|
+
}
|
|
58
|
+
if (throwsError) {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (params.useOnOrderStatusChanged) {
|
|
63
|
+
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({
|
|
64
|
+
order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderProcessing // 強制的にOrderProcessingとして処理する
|
|
65
|
+
}),
|
|
66
|
+
placeOrderTransaction
|
|
67
|
+
})({
|
|
68
|
+
registerActionInProgress: repos.registerActionInProgress,
|
|
69
|
+
task: repos.task
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.payOrder = payOrder;
|
|
@@ -15,6 +15,7 @@ const order_1 = require("../../factory/order");
|
|
|
15
15
|
const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
|
|
16
16
|
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
17
17
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
18
|
+
const payOrder_1 = require("./payOrder");
|
|
18
19
|
const factory = require("../../factory");
|
|
19
20
|
function createOrder(params) {
|
|
20
21
|
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
@@ -151,6 +152,7 @@ exports.placeOrderWithoutTransaction = placeOrderWithoutTransaction;
|
|
|
151
152
|
*/
|
|
152
153
|
// tslint:disable-next-line:max-func-body-length
|
|
153
154
|
function placeOrder(params) {
|
|
155
|
+
// tslint:disable-next-line:max-func-body-length
|
|
154
156
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
155
157
|
var _a;
|
|
156
158
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
@@ -222,10 +224,24 @@ function placeOrder(params) {
|
|
|
222
224
|
if (params.useOnOrderStatusChanged) {
|
|
223
225
|
// 経理レポートを保管
|
|
224
226
|
yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(order)({ accountingReport: repos.accountingReport });
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
// PaymentDueであればonOrderStatusChangedを実行(2023-08-23~)
|
|
228
|
+
if (order.orderStatus === factory.orderStatus.OrderPaymentDue) {
|
|
229
|
+
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({ order, placeOrderTransaction })({
|
|
230
|
+
registerActionInProgress: repos.registerActionInProgress,
|
|
231
|
+
task: repos.task
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else if (order.orderStatus === factory.orderStatus.OrderProcessing) {
|
|
235
|
+
// OrderPaymentDueをスキップしてOrderProcessingから開始する場合(2023-08-23~)
|
|
236
|
+
yield (0, payOrder_1.payOrder)({
|
|
237
|
+
project: { id: order.project.id },
|
|
238
|
+
object: {
|
|
239
|
+
confirmationNumber: order.confirmationNumber,
|
|
240
|
+
orderNumber: order.orderNumber
|
|
241
|
+
},
|
|
242
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
243
|
+
})(repos);
|
|
244
|
+
}
|
|
229
245
|
}
|
|
230
246
|
// onOrderStatusChangedへ移行(2023-08-17~)
|
|
231
247
|
// await onPlaceOrder({
|
|
@@ -108,7 +108,7 @@ function createAuthorizeResult(params) {
|
|
|
108
108
|
// 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
|
|
109
109
|
// paymentMethod: params.object.paymentMethod,
|
|
110
110
|
paymentMethodAsObject,
|
|
111
|
-
paymentStatus: factory.paymentStatusType.
|
|
111
|
+
paymentStatus: factory.paymentStatusType.PaymentAutomaticallyApplied,
|
|
112
112
|
paymentMethodId: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.paymentMethodId) === 'string')
|
|
113
113
|
? payTransactionObject.paymentMethod.paymentMethodId
|
|
114
114
|
: '',
|
|
@@ -10,8 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
13
14
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
14
15
|
const action_1 = require("../../repo/action");
|
|
16
|
+
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
15
17
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
18
|
const event_1 = require("../../repo/event");
|
|
17
19
|
const order_1 = require("../../repo/order");
|
|
@@ -19,12 +21,17 @@ const product_1 = require("../../repo/product");
|
|
|
19
21
|
const project_1 = require("../../repo/project");
|
|
20
22
|
const seller_1 = require("../../repo/seller");
|
|
21
23
|
const task_1 = require("../../repo/task");
|
|
24
|
+
const transaction_1 = require("../../repo/transaction");
|
|
22
25
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
26
|
+
const payOrder_1 = require("../order/payOrder");
|
|
23
27
|
/**
|
|
24
28
|
* タスク実行関数
|
|
25
29
|
*/
|
|
26
30
|
function call(data) {
|
|
27
31
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (settings.redisClient === undefined) {
|
|
33
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
34
|
+
}
|
|
28
35
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
29
36
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
30
37
|
const orderRepo = new order_1.MongoRepository(settings.connection);
|
|
@@ -34,6 +41,8 @@ function call(data) {
|
|
|
34
41
|
const projectRepo = new project_1.MongoRepository(settings.connection);
|
|
35
42
|
const sellerRepo = new seller_1.MongoRepository(settings.connection);
|
|
36
43
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
44
|
+
const transactionRepo = new transaction_1.MongoRepository(settings.connection);
|
|
45
|
+
const registerServiceInProgressRepo = new registerServiceInProgress_1.RedisRepository(settings.redisClient);
|
|
37
46
|
// アクション開始
|
|
38
47
|
const action = yield actionRepo.start(data);
|
|
39
48
|
try {
|
|
@@ -76,6 +85,53 @@ function call(data) {
|
|
|
76
85
|
// アクション完了
|
|
77
86
|
const actionResult = {};
|
|
78
87
|
yield actionRepo.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
88
|
+
// processOrder連携(2023-08-23~)
|
|
89
|
+
yield onConfirmed(data)({
|
|
90
|
+
assetTransaction: assetTransactionRepo,
|
|
91
|
+
order: orderRepo,
|
|
92
|
+
registerActionInProgress: registerServiceInProgressRepo,
|
|
93
|
+
task: taskRepo,
|
|
94
|
+
transaction: transactionRepo
|
|
95
|
+
});
|
|
79
96
|
});
|
|
80
97
|
}
|
|
81
98
|
exports.call = call;
|
|
99
|
+
function onConfirmed(params) {
|
|
100
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
if (params.processOrder === true) {
|
|
102
|
+
// 注文のpaymentMethodIdを取得
|
|
103
|
+
const order = yield repos.order.findByOrderNumber({
|
|
104
|
+
orderNumber: params.purpose.orderNumber,
|
|
105
|
+
project: { id: params.project.id },
|
|
106
|
+
inclusion: ['paymentMethods'],
|
|
107
|
+
exclusion: []
|
|
108
|
+
});
|
|
109
|
+
// PayTransactionのステータス検証
|
|
110
|
+
let allPayTransactionConfirmed = false;
|
|
111
|
+
const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
|
|
112
|
+
.map((invoice) => invoice.paymentMethodId);
|
|
113
|
+
if (paymentMethodIds.length > 0) {
|
|
114
|
+
const referencedPayTransactions = yield repos.assetTransaction.search({
|
|
115
|
+
project: { id: { $eq: params.project.id } },
|
|
116
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
117
|
+
transactionNumber: { $in: paymentMethodIds }
|
|
118
|
+
}, ['status']);
|
|
119
|
+
allPayTransactionConfirmed =
|
|
120
|
+
referencedPayTransactions.every((payTransation) => payTransation.status === factory.transactionStatusType.Confirmed);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
allPayTransactionConfirmed = true;
|
|
124
|
+
}
|
|
125
|
+
if (allPayTransactionConfirmed) {
|
|
126
|
+
yield (0, payOrder_1.payOrder)({
|
|
127
|
+
project: { id: params.project.id },
|
|
128
|
+
object: {
|
|
129
|
+
confirmationNumber: params.purpose.confirmationNumber,
|
|
130
|
+
orderNumber: params.purpose.orderNumber
|
|
131
|
+
},
|
|
132
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
133
|
+
})(repos);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
@@ -81,7 +81,7 @@ function createPaymentMethods(params) {
|
|
|
81
81
|
if (typeof paymentMethodType !== 'string') {
|
|
82
82
|
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
83
|
}
|
|
84
|
-
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
84
|
+
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, paymentStatus: result.paymentStatus, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
85
85
|
});
|
|
86
86
|
// 決済方法から注文金額の計算
|
|
87
87
|
// price += authorizePaymentActions
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
|
41
41
|
export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
42
42
|
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
43
43
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
44
|
+
export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
|
|
44
45
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
45
46
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
46
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.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = 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_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = 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;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = 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_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = 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')
|
|
@@ -73,6 +73,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
73
73
|
exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
|
|
74
74
|
exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
|
|
75
75
|
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
76
|
+
exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
|
|
76
77
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
77
78
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
78
79
|
: 0;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.327.0-alpha.1",
|
|
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.
|
|
120
|
+
"version": "21.8.0-alpha.1"
|
|
121
121
|
}
|