@chevre/domain 20.2.0-alpha.2 → 20.2.0-alpha.20
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 +37 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +80 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +90 -0
- package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
- package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
- package/lib/chevre/repo/action.d.ts +58 -0
- package/lib/chevre/repo/action.js +187 -0
- package/lib/chevre/repo/aggregation.d.ts +29 -0
- package/lib/chevre/repo/aggregation.js +64 -0
- package/lib/chevre/repo/event.d.ts +0 -1
- package/lib/chevre/repo/event.js +124 -105
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/event.js +2 -2
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/order.d.ts +9 -0
- package/lib/chevre/repo/order.js +49 -0
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +205 -52
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/reservation.js +64 -29
- package/lib/chevre/repo/transaction.d.ts +28 -0
- package/lib/chevre/repo/transaction.js +125 -0
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
- package/lib/chevre/service/aggregation/system.d.ts +73 -0
- package/lib/chevre/service/aggregation/system.js +251 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
- package/lib/chevre/service/assetTransaction/pay.js +65 -32
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +29 -1
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +33 -51
- package/lib/chevre/service/delivery/factory.js +1 -0
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +21 -10
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.js +25 -5
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer.js +28 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/payment/any.d.ts +5 -0
- package/lib/chevre/service/reserve/useReservation.js +2 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -0,0 +1,251 @@
|
|
|
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.aggregateUseAction = exports.aggregateReservation = exports.aggregatePlaceOrder = exports.aggregateOrder = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
14
|
+
const moment = require("moment-timezone");
|
|
15
|
+
const factory = require("../../factory");
|
|
16
|
+
const aggregation_1 = require("../../repo/aggregation");
|
|
17
|
+
const debug = createDebug('chevre-domain:service:aggregation:system');
|
|
18
|
+
/**
|
|
19
|
+
* 注文取引集計
|
|
20
|
+
*/
|
|
21
|
+
function aggregatePlaceOrder(params) {
|
|
22
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
24
|
+
const aggregateDate = new Date();
|
|
25
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
26
|
+
.toISOString();
|
|
27
|
+
let i = -1;
|
|
28
|
+
while (i < params.aggregationDays) {
|
|
29
|
+
i += 1;
|
|
30
|
+
const startFrom = moment()
|
|
31
|
+
// .tz('Asia/Tokyo')
|
|
32
|
+
.add(-i, 'days')
|
|
33
|
+
.startOf('day')
|
|
34
|
+
.toDate();
|
|
35
|
+
const startThrough = moment()
|
|
36
|
+
// .tz('Asia/Tokyo')
|
|
37
|
+
.add(-i, 'days')
|
|
38
|
+
.endOf('day')
|
|
39
|
+
.toDate();
|
|
40
|
+
const aggregateResult = yield repos.transaction.aggregatePlaceOrder({
|
|
41
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
42
|
+
startFrom,
|
|
43
|
+
startThrough,
|
|
44
|
+
typeOf: factory.transactionType.PlaceOrder
|
|
45
|
+
});
|
|
46
|
+
debug('aggregatePlaceOrder:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
47
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePlaceOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.aggregatePlaceOrder = aggregatePlaceOrder;
|
|
52
|
+
/**
|
|
53
|
+
* 興行オファー承認アクション集計
|
|
54
|
+
*/
|
|
55
|
+
function aggregateAuthorizeEventServiceOfferAction(params) {
|
|
56
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
const aggregateDate = new Date();
|
|
59
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
60
|
+
.toISOString();
|
|
61
|
+
let i = -1;
|
|
62
|
+
while (i < params.aggregationDays) {
|
|
63
|
+
i += 1;
|
|
64
|
+
const startFrom = moment()
|
|
65
|
+
// .tz('Asia/Tokyo')
|
|
66
|
+
.add(-i, 'days')
|
|
67
|
+
.startOf('day')
|
|
68
|
+
.toDate();
|
|
69
|
+
const startThrough = moment()
|
|
70
|
+
// .tz('Asia/Tokyo')
|
|
71
|
+
.add(-i, 'days')
|
|
72
|
+
.endOf('day')
|
|
73
|
+
.toDate();
|
|
74
|
+
const aggregateResult = yield repos.action.aggregateAuthorizeEventServiceOfferAction({
|
|
75
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
76
|
+
startFrom,
|
|
77
|
+
startThrough,
|
|
78
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
79
|
+
});
|
|
80
|
+
debug('aggregateAuthorizeEventServiceOfferAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
81
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeEventServiceOfferAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.aggregateAuthorizeEventServiceOfferAction = aggregateAuthorizeEventServiceOfferAction;
|
|
86
|
+
/**
|
|
87
|
+
* 決済承認アクション集計
|
|
88
|
+
*/
|
|
89
|
+
function aggregateAuthorizePaymentAction(params) {
|
|
90
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
var _a;
|
|
92
|
+
const aggregateDate = new Date();
|
|
93
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
94
|
+
.toISOString();
|
|
95
|
+
let i = -1;
|
|
96
|
+
while (i < params.aggregationDays) {
|
|
97
|
+
i += 1;
|
|
98
|
+
const startFrom = moment()
|
|
99
|
+
// .tz('Asia/Tokyo')
|
|
100
|
+
.add(-i, 'days')
|
|
101
|
+
.startOf('day')
|
|
102
|
+
.toDate();
|
|
103
|
+
const startThrough = moment()
|
|
104
|
+
// .tz('Asia/Tokyo')
|
|
105
|
+
.add(-i, 'days')
|
|
106
|
+
.endOf('day')
|
|
107
|
+
.toDate();
|
|
108
|
+
const aggregateResult = yield repos.action.aggregateAuthorizePaymentAction({
|
|
109
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
110
|
+
startFrom,
|
|
111
|
+
startThrough,
|
|
112
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
113
|
+
});
|
|
114
|
+
debug('aggregateAuthorizePaymentAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
115
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizePaymentAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.aggregateAuthorizePaymentAction = aggregateAuthorizePaymentAction;
|
|
120
|
+
function aggregateAuthorizeOrderAction(params) {
|
|
121
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var _a;
|
|
123
|
+
const aggregateDate = new Date();
|
|
124
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
125
|
+
.toISOString();
|
|
126
|
+
let i = -1;
|
|
127
|
+
while (i < params.aggregationDays) {
|
|
128
|
+
i += 1;
|
|
129
|
+
const startFrom = moment()
|
|
130
|
+
// .tz('Asia/Tokyo')
|
|
131
|
+
.add(-i, 'days')
|
|
132
|
+
.startOf('day')
|
|
133
|
+
.toDate();
|
|
134
|
+
const startThrough = moment()
|
|
135
|
+
// .tz('Asia/Tokyo')
|
|
136
|
+
.add(-i, 'days')
|
|
137
|
+
.endOf('day')
|
|
138
|
+
.toDate();
|
|
139
|
+
const aggregateResult = yield repos.action.aggregateAuthorizeOrderAction({
|
|
140
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
141
|
+
startFrom,
|
|
142
|
+
startThrough,
|
|
143
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
144
|
+
});
|
|
145
|
+
debug('aggregateAuthorizeOrderAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
146
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeOrderAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.aggregateAuthorizeOrderAction = aggregateAuthorizeOrderAction;
|
|
151
|
+
/**
|
|
152
|
+
* 使用アクション集計
|
|
153
|
+
*/
|
|
154
|
+
function aggregateUseAction(params) {
|
|
155
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
var _a;
|
|
157
|
+
const aggregateDate = new Date();
|
|
158
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
159
|
+
.toISOString();
|
|
160
|
+
let i = -1;
|
|
161
|
+
while (i < params.aggregationDays) {
|
|
162
|
+
i += 1;
|
|
163
|
+
const startFrom = moment()
|
|
164
|
+
// .tz('Asia/Tokyo')
|
|
165
|
+
.add(-i, 'days')
|
|
166
|
+
.startOf('day')
|
|
167
|
+
.toDate();
|
|
168
|
+
const startThrough = moment()
|
|
169
|
+
// .tz('Asia/Tokyo')
|
|
170
|
+
.add(-i, 'days')
|
|
171
|
+
.endOf('day')
|
|
172
|
+
.toDate();
|
|
173
|
+
const aggregateResult = yield repos.action.aggregateUseAction({
|
|
174
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
175
|
+
startFrom,
|
|
176
|
+
startThrough,
|
|
177
|
+
typeOf: factory.actionType.UseAction
|
|
178
|
+
});
|
|
179
|
+
debug('aggregateUseAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
180
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateUseAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
exports.aggregateUseAction = aggregateUseAction;
|
|
185
|
+
/**
|
|
186
|
+
* 注文集計
|
|
187
|
+
*/
|
|
188
|
+
function aggregateOrder(params) {
|
|
189
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const aggregateDate = new Date();
|
|
191
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
192
|
+
.toISOString();
|
|
193
|
+
let i = -1;
|
|
194
|
+
while (i < params.aggregationDays) {
|
|
195
|
+
i += 1;
|
|
196
|
+
const orderDateFrom = moment()
|
|
197
|
+
// .tz('Asia/Tokyo')
|
|
198
|
+
.add(-i, 'days')
|
|
199
|
+
.startOf('day')
|
|
200
|
+
.toDate();
|
|
201
|
+
const orderDateThrough = moment()
|
|
202
|
+
// .tz('Asia/Tokyo')
|
|
203
|
+
.add(-i, 'days')
|
|
204
|
+
.endOf('day')
|
|
205
|
+
.toDate();
|
|
206
|
+
const aggregateResult = yield repos.order.aggregateOrder({
|
|
207
|
+
orderDate: {
|
|
208
|
+
$gte: orderDateFrom,
|
|
209
|
+
$lte: orderDateThrough
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
debug('aggregateOrder:result', aggregateResult);
|
|
213
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: orderDateFrom, aggregateDate }, aggregateResult));
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
exports.aggregateOrder = aggregateOrder;
|
|
218
|
+
/**
|
|
219
|
+
* 予約集計
|
|
220
|
+
*/
|
|
221
|
+
function aggregateReservation(params) {
|
|
222
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const aggregateDate = new Date();
|
|
224
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
225
|
+
.toISOString();
|
|
226
|
+
let i = -1;
|
|
227
|
+
while (i < params.aggregationDays) {
|
|
228
|
+
i += 1;
|
|
229
|
+
const bookingFrom = moment()
|
|
230
|
+
// .tz('Asia/Tokyo')
|
|
231
|
+
.add(-i, 'days')
|
|
232
|
+
.startOf('day')
|
|
233
|
+
.toDate();
|
|
234
|
+
const bookingThrough = moment()
|
|
235
|
+
// .tz('Asia/Tokyo')
|
|
236
|
+
.add(-i, 'days')
|
|
237
|
+
.endOf('day')
|
|
238
|
+
.toDate();
|
|
239
|
+
// i日前の予約検索
|
|
240
|
+
const reservationCount = yield repos.reservation.count({
|
|
241
|
+
typeOf: factory.reservationType.EventReservation,
|
|
242
|
+
reservationStatus: { $eq: factory.reservationStatusType.ReservationConfirmed },
|
|
243
|
+
bookingFrom,
|
|
244
|
+
bookingThrough
|
|
245
|
+
});
|
|
246
|
+
const aggregateResult = { reservationCount };
|
|
247
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReservation, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: bookingFrom, aggregateDate }, aggregateResult));
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
exports.aggregateReservation = aggregateReservation;
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as EventAggregation from './aggregation/event';
|
|
5
5
|
import * as ProjectAggregation from './aggregation/project';
|
|
6
|
+
import * as SystemAggregation from './aggregation/system';
|
|
6
7
|
export import event = EventAggregation;
|
|
7
8
|
export import project = ProjectAggregation;
|
|
9
|
+
export import system = SystemAggregation;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.project = exports.event = void 0;
|
|
3
|
+
exports.system = exports.project = exports.event = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 集計サービス
|
|
6
6
|
*/
|
|
7
7
|
const EventAggregation = require("./aggregation/event");
|
|
8
8
|
const ProjectAggregation = require("./aggregation/project");
|
|
9
|
+
const SystemAggregation = require("./aggregation/system");
|
|
9
10
|
exports.event = EventAggregation;
|
|
10
11
|
exports.project = ProjectAggregation;
|
|
12
|
+
exports.system = SystemAggregation;
|
|
@@ -11,13 +11,10 @@ function createPayActions(params) {
|
|
|
11
11
|
if (payObject !== undefined) {
|
|
12
12
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order);
|
|
13
13
|
const simpleOrder = {
|
|
14
|
-
// project: params.order.project,
|
|
15
14
|
typeOf: params.order.typeOf,
|
|
16
15
|
seller: params.order.seller,
|
|
17
16
|
// mask
|
|
18
17
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
19
|
-
// IOrderへ移行(2022-11-17~)
|
|
20
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
21
18
|
orderNumber: params.order.orderNumber,
|
|
22
19
|
price: params.order.price,
|
|
23
20
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -162,7 +159,8 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
|
|
|
162
159
|
}
|
|
163
160
|
});
|
|
164
161
|
}
|
|
165
|
-
return o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
162
|
+
return (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
163
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
166
164
|
&& mvtkUnitPriceSpec !== undefined
|
|
167
165
|
&& o.itemOffered.reservationFor.id === movieTicket.serviceOutput.reservationFor.id
|
|
168
166
|
&& ((_d = o.itemOffered.reservedTicket.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatNumber) === movieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
|
|
@@ -25,13 +25,28 @@ export interface IStartOperationRepos {
|
|
|
25
25
|
task: TaskRepo;
|
|
26
26
|
}
|
|
27
27
|
export declare type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
28
|
-
export
|
|
28
|
+
export interface ICancelRepos {
|
|
29
|
+
action: ActionRepo;
|
|
30
|
+
accountingReport: AccountingReportRepo;
|
|
29
31
|
assetTransaction: AssetTransactionRepo;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
product: ProductRepo;
|
|
33
|
+
project: ProjectRepo;
|
|
34
|
+
seller: SellerRepo;
|
|
35
|
+
task: TaskRepo;
|
|
36
|
+
}
|
|
37
|
+
export declare type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
|
|
38
|
+
export interface IConfirmRepos {
|
|
39
|
+
action: ActionRepo;
|
|
40
|
+
accountingReport: AccountingReportRepo;
|
|
32
41
|
assetTransaction: AssetTransactionRepo;
|
|
42
|
+
event: EventRepo;
|
|
33
43
|
order: OrderRepo;
|
|
34
|
-
|
|
44
|
+
product: ProductRepo;
|
|
45
|
+
project: ProjectRepo;
|
|
46
|
+
seller: SellerRepo;
|
|
47
|
+
task: TaskRepo;
|
|
48
|
+
}
|
|
49
|
+
export declare type IConfirmOperation<T> = (repos: IConfirmRepos) => Promise<T>;
|
|
35
50
|
export declare type IExportTasksOperation<T> = (repos: {
|
|
36
51
|
task: TaskRepo;
|
|
37
52
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -13,6 +13,7 @@ exports.searchGMOTrade = exports.exportTasksById = exports.cancel = exports.conf
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
15
|
const settings_1 = require("../../settings");
|
|
16
|
+
const payment_1 = require("../payment");
|
|
16
17
|
const CreditCardPayment = require("../payment/creditCard");
|
|
17
18
|
const MovieTicketPayment = require("../payment/movieTicket");
|
|
18
19
|
const PaymentCardPayment = require("../payment/paymentCard");
|
|
@@ -307,8 +308,19 @@ function confirm(params) {
|
|
|
307
308
|
typeOf: factory.assetTransactionType.Pay,
|
|
308
309
|
id: transaction.id,
|
|
309
310
|
result: {},
|
|
310
|
-
|
|
311
|
+
// sync対応(2023-01-14~)
|
|
312
|
+
potentialActions: (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
313
|
+
? { pay: [] }
|
|
314
|
+
: potentialActions
|
|
311
315
|
});
|
|
316
|
+
// sync対応(2023-01-14~)
|
|
317
|
+
if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
318
|
+
if (Array.isArray(potentialActions.pay)) {
|
|
319
|
+
for (const payAction of potentialActions.pay) {
|
|
320
|
+
yield (0, payment_1.pay)(payAction)(repos);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
312
324
|
});
|
|
313
325
|
}
|
|
314
326
|
exports.confirm = confirm;
|
|
@@ -341,11 +353,23 @@ function fixOrderAsPurpose(params, transaction) {
|
|
|
341
353
|
*/
|
|
342
354
|
function cancel(params) {
|
|
343
355
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
344
|
-
yield repos.assetTransaction.cancel({
|
|
356
|
+
const transaction = yield repos.assetTransaction.cancel({
|
|
345
357
|
typeOf: factory.assetTransactionType.Pay,
|
|
346
358
|
id: params.id,
|
|
347
359
|
transactionNumber: params.transactionNumber
|
|
348
360
|
});
|
|
361
|
+
// sync対応(2023-01-14~)
|
|
362
|
+
if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
363
|
+
const payTransactionAsObject = {
|
|
364
|
+
project: transaction.project,
|
|
365
|
+
typeOf: transaction.typeOf,
|
|
366
|
+
id: transaction.id,
|
|
367
|
+
transactionNumber: transaction.transactionNumber,
|
|
368
|
+
object: transaction.object,
|
|
369
|
+
recipient: transaction.recipient
|
|
370
|
+
};
|
|
371
|
+
yield (0, payment_1.voidPayment)({ object: payTransactionAsObject })(repos);
|
|
372
|
+
}
|
|
349
373
|
});
|
|
350
374
|
}
|
|
351
375
|
exports.cancel = cancel;
|
|
@@ -353,6 +377,7 @@ exports.cancel = cancel;
|
|
|
353
377
|
* 取引のタスク出力
|
|
354
378
|
*/
|
|
355
379
|
function exportTasksById(params) {
|
|
380
|
+
// tslint:disable-next-line:max-func-body-length
|
|
356
381
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
357
382
|
const transaction = yield repos.assetTransaction.findById({
|
|
358
383
|
typeOf: factory.assetTransactionType.Pay,
|
|
@@ -388,42 +413,50 @@ function exportTasksById(params) {
|
|
|
388
413
|
.add(params.runsTasksAfterInSeconds, 'seconds')
|
|
389
414
|
.toDate();
|
|
390
415
|
}
|
|
416
|
+
const payTransactionAsObject = {
|
|
417
|
+
project: transaction.project,
|
|
418
|
+
typeOf: transaction.typeOf,
|
|
419
|
+
id: transaction.id,
|
|
420
|
+
transactionNumber: transaction.transactionNumber,
|
|
421
|
+
object: transaction.object,
|
|
422
|
+
recipient: transaction.recipient
|
|
423
|
+
};
|
|
424
|
+
const voidPaymentTasks = {
|
|
425
|
+
project: transaction.project,
|
|
426
|
+
name: factory.taskName.VoidPayment,
|
|
427
|
+
status: factory.taskStatus.Ready,
|
|
428
|
+
runsAt: taskRunsAt,
|
|
429
|
+
remainingNumberOfTries: 10,
|
|
430
|
+
numberOfTried: 0,
|
|
431
|
+
executionResults: [],
|
|
432
|
+
data: { object: payTransactionAsObject }
|
|
433
|
+
};
|
|
391
434
|
switch (transaction.status) {
|
|
392
435
|
case factory.transactionStatusType.Confirmed:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
data: a
|
|
409
|
-
};
|
|
410
|
-
});
|
|
411
|
-
taskAttributes.push(...payTasks);
|
|
412
|
-
}
|
|
436
|
+
const payActions = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.pay;
|
|
437
|
+
if (Array.isArray(payActions) && payActions.length > 0) {
|
|
438
|
+
const payTasks = payActions.map((a) => {
|
|
439
|
+
return {
|
|
440
|
+
project: transaction.project,
|
|
441
|
+
name: factory.taskName.Pay,
|
|
442
|
+
status: factory.taskStatus.Ready,
|
|
443
|
+
runsAt: taskRunsAt,
|
|
444
|
+
remainingNumberOfTries: 10,
|
|
445
|
+
numberOfTried: 0,
|
|
446
|
+
executionResults: [],
|
|
447
|
+
data: a
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
taskAttributes.push(...payTasks);
|
|
413
451
|
}
|
|
414
452
|
break;
|
|
415
453
|
case factory.transactionStatusType.Canceled:
|
|
454
|
+
// sync対応(2023-01-14~)
|
|
455
|
+
if (!settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
456
|
+
taskAttributes.push(voidPaymentTasks);
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
416
459
|
case factory.transactionStatusType.Expired:
|
|
417
|
-
const voidPaymentTasks = {
|
|
418
|
-
project: transaction.project,
|
|
419
|
-
name: factory.taskName.VoidPayment,
|
|
420
|
-
status: factory.taskStatus.Ready,
|
|
421
|
-
runsAt: taskRunsAt,
|
|
422
|
-
remainingNumberOfTries: 10,
|
|
423
|
-
numberOfTried: 0,
|
|
424
|
-
executionResults: [],
|
|
425
|
-
data: { object: transaction }
|
|
426
|
-
};
|
|
427
460
|
taskAttributes.push(voidPaymentTasks);
|
|
428
461
|
break;
|
|
429
462
|
default:
|
|
@@ -70,4 +70,7 @@ export declare function createPotentialActions(params: factory.assetTransaction.
|
|
|
70
70
|
transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
|
|
71
71
|
order?: factory.order.IOrder;
|
|
72
72
|
}): factory.assetTransaction.reserve.IPotentialActions;
|
|
73
|
+
export declare function createPendingReservationAction(params: {
|
|
74
|
+
transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
|
|
75
|
+
}): factory.action.cancel.reservation.IAttributes[];
|
|
73
76
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPotentialActions = exports.createReservation = exports.createReservationFor = exports.createAdditionalTicketText = exports.createAdditionalProperty = exports.validateAppliesToMovieTicket = exports.createReservedTicket = exports.createPointAward = exports.createStartParams = void 0;
|
|
3
|
+
exports.createPendingReservationAction = exports.createPotentialActions = exports.createReservation = exports.createReservationFor = exports.createAdditionalTicketText = exports.createAdditionalProperty = exports.validateAppliesToMovieTicket = exports.createReservedTicket = exports.createPointAward = exports.createStartParams = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約取引ファクトリー
|
|
6
6
|
*/
|
|
@@ -550,3 +550,31 @@ function createMoneyTransferActions(params) {
|
|
|
550
550
|
}
|
|
551
551
|
return moneyTransfer;
|
|
552
552
|
}
|
|
553
|
+
function createPendingReservationAction(params) {
|
|
554
|
+
const transaction = params.transaction;
|
|
555
|
+
const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
|
|
556
|
+
let cancelActionAttributes = [];
|
|
557
|
+
if (pendingReservations.length > 0) {
|
|
558
|
+
const reservationFor = transaction.object.reservationFor;
|
|
559
|
+
if (reservationFor === undefined) {
|
|
560
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
561
|
+
}
|
|
562
|
+
// ReservationPackageに対応(2022-12-23~)
|
|
563
|
+
const reservationPackage = {
|
|
564
|
+
typeOf: factory.reservationType.ReservationPackage,
|
|
565
|
+
reservationNumber: transaction.transactionNumber,
|
|
566
|
+
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
567
|
+
reservationStatus: pendingReservations[0].reservationStatus
|
|
568
|
+
};
|
|
569
|
+
cancelActionAttributes = [{
|
|
570
|
+
project: transaction.project,
|
|
571
|
+
typeOf: factory.actionType.CancelAction,
|
|
572
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
573
|
+
agent: transaction.project,
|
|
574
|
+
object: reservationPackage,
|
|
575
|
+
potentialActions: {}
|
|
576
|
+
}];
|
|
577
|
+
}
|
|
578
|
+
return cancelActionAttributes;
|
|
579
|
+
}
|
|
580
|
+
exports.createPendingReservationAction = createPendingReservationAction;
|
|
@@ -54,10 +54,14 @@ export declare type ITaskAndTransactionOperation<T> = (repos: {
|
|
|
54
54
|
task: TaskRepo;
|
|
55
55
|
assetTransaction: AssetTransactionRepo;
|
|
56
56
|
}) => Promise<T>;
|
|
57
|
-
|
|
57
|
+
interface IConfirmRepo {
|
|
58
|
+
action: ActionRepo;
|
|
58
59
|
assetTransaction: AssetTransactionRepo;
|
|
59
60
|
order: OrderRepo;
|
|
60
|
-
|
|
61
|
+
reservation: ReservationRepo;
|
|
62
|
+
task: TaskRepo;
|
|
63
|
+
}
|
|
64
|
+
export declare type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
|
|
61
65
|
/**
|
|
62
66
|
* 取引開始
|
|
63
67
|
*/
|
|
@@ -81,3 +85,4 @@ export declare function cancel(params: {
|
|
|
81
85
|
export declare function exportTasksById(params: {
|
|
82
86
|
id: string;
|
|
83
87
|
}): ITaskAndTransactionOperation<factory.task.ITask<factory.taskName>[]>;
|
|
88
|
+
export {};
|
|
@@ -18,6 +18,7 @@ const pecorinoapi = require("../../pecorinoapi");
|
|
|
18
18
|
const factory = require("../../factory");
|
|
19
19
|
const OfferService = require("../offer");
|
|
20
20
|
const cancelReservation_1 = require("../reserve/cancelReservation");
|
|
21
|
+
const confirmReservation_1 = require("../reserve/confirmReservation");
|
|
21
22
|
const settings_1 = require("../../settings");
|
|
22
23
|
const factory_1 = require("./reserve/factory");
|
|
23
24
|
/**
|
|
@@ -571,8 +572,14 @@ function confirm(params) {
|
|
|
571
572
|
typeOf: factory.assetTransactionType.Reserve,
|
|
572
573
|
id: transaction.id,
|
|
573
574
|
result: result,
|
|
574
|
-
potentialActions:
|
|
575
|
+
potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
576
|
+
? { reserve: [] }
|
|
577
|
+
: potentialActions
|
|
575
578
|
});
|
|
579
|
+
if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
580
|
+
// sync対応(2023-01-13~)
|
|
581
|
+
yield (0, confirmReservation_1.confirmReservation)(potentialActions.reserve)(repos);
|
|
582
|
+
}
|
|
576
583
|
});
|
|
577
584
|
}
|
|
578
585
|
exports.confirm = confirm;
|
|
@@ -614,34 +621,9 @@ function cancel(params) {
|
|
|
614
621
|
});
|
|
615
622
|
// 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
|
|
616
623
|
// 同期的にもcancelPendingReservationを実行しておく
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (pendingReservations.length > 0) {
|
|
621
|
-
const reservationFor = transaction.object.reservationFor;
|
|
622
|
-
if (reservationFor === undefined) {
|
|
623
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
624
|
-
}
|
|
625
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
626
|
-
const reservationPackage = {
|
|
627
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
628
|
-
reservationNumber: transaction.transactionNumber,
|
|
629
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
630
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
631
|
-
};
|
|
632
|
-
cancelActionAttributes = [{
|
|
633
|
-
project: transaction.project,
|
|
634
|
-
typeOf: factory.actionType.CancelAction,
|
|
635
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
636
|
-
agent: transaction.project,
|
|
637
|
-
object: reservationPackage,
|
|
638
|
-
potentialActions: {}
|
|
639
|
-
}];
|
|
640
|
-
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
catch (error) {
|
|
644
|
-
// no op
|
|
624
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
625
|
+
if (cancelActionAttributes.length > 0) {
|
|
626
|
+
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
645
627
|
}
|
|
646
628
|
});
|
|
647
629
|
}
|
|
@@ -704,29 +686,29 @@ function exportTasksById(params) {
|
|
|
704
686
|
}
|
|
705
687
|
break;
|
|
706
688
|
case factory.transactionStatusType.Canceled:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (reservationFor === undefined) {
|
|
713
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
714
|
-
}
|
|
715
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
716
|
-
const reservationPackage = {
|
|
717
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
718
|
-
reservationNumber: transaction.transactionNumber,
|
|
719
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
720
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
721
|
-
};
|
|
722
|
-
cancelActionAttributes = [{
|
|
689
|
+
// sync対応(2023-01-13~)
|
|
690
|
+
if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
691
|
+
const cancelActionAttributes4canceled = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
692
|
+
if (cancelActionAttributes4canceled.length > 0) {
|
|
693
|
+
const cancelPendingReservationTask = {
|
|
723
694
|
project: transaction.project,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
695
|
+
name: factory.taskName.CancelPendingReservation,
|
|
696
|
+
status: factory.taskStatus.Ready,
|
|
697
|
+
runsAt: new Date(),
|
|
698
|
+
remainingNumberOfTries: 10,
|
|
699
|
+
numberOfTried: 0,
|
|
700
|
+
executionResults: [],
|
|
701
|
+
data: {
|
|
702
|
+
actionAttributes: cancelActionAttributes4canceled
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
taskAttributes.push(cancelPendingReservationTask);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
break;
|
|
709
|
+
case factory.transactionStatusType.Expired:
|
|
710
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
711
|
+
if (cancelActionAttributes.length > 0) {
|
|
730
712
|
const cancelPendingReservationTask = {
|
|
731
713
|
project: transaction.project,
|
|
732
714
|
name: factory.taskName.CancelPendingReservation,
|