@chevre/domain 20.2.0-alpha.8 → 20.2.0

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.
Files changed (140) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
  3. package/example/src/chevre/attendIfNotAttended.ts +22 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
  5. package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  8. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  9. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
  10. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  11. package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
  12. package/example/src/chevre/processReserve.ts +2 -0
  13. package/example/src/chevre/searchEventIds.ts +24 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -4
  15. package/example/src/chevre/searchEvents.ts +20 -41
  16. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  17. package/example/src/chevre/updateTransaction.ts +38 -0
  18. package/lib/chevre/factory/event.d.ts +2 -0
  19. package/lib/chevre/factory/event.js +2 -0
  20. package/lib/chevre/repo/action.d.ts +77 -1
  21. package/lib/chevre/repo/action.js +249 -6
  22. package/lib/chevre/repo/aggregation.d.ts +38 -0
  23. package/lib/chevre/repo/aggregation.js +68 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  25. package/lib/chevre/repo/assetTransaction.js +148 -0
  26. package/lib/chevre/repo/code.d.ts +13 -16
  27. package/lib/chevre/repo/code.js +33 -19
  28. package/lib/chevre/repo/creativeWork.js +13 -12
  29. package/lib/chevre/repo/event.d.ts +64 -17
  30. package/lib/chevre/repo/event.js +456 -156
  31. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  32. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  33. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  34. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  35. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  36. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  37. package/lib/chevre/repo/offer.d.ts +10 -0
  38. package/lib/chevre/repo/offer.js +47 -16
  39. package/lib/chevre/repo/order.d.ts +6 -0
  40. package/lib/chevre/repo/order.js +53 -7
  41. package/lib/chevre/repo/place.d.ts +26 -1
  42. package/lib/chevre/repo/place.js +216 -12
  43. package/lib/chevre/repo/product.d.ts +1 -0
  44. package/lib/chevre/repo/product.js +5 -0
  45. package/lib/chevre/repo/project.d.ts +7 -1
  46. package/lib/chevre/repo/project.js +15 -6
  47. package/lib/chevre/repo/reservation.d.ts +7 -8
  48. package/lib/chevre/repo/reservation.js +181 -76
  49. package/lib/chevre/repo/task.d.ts +31 -4
  50. package/lib/chevre/repo/task.js +146 -33
  51. package/lib/chevre/repo/transaction.d.ts +57 -5
  52. package/lib/chevre/repo/transaction.js +228 -34
  53. package/lib/chevre/repo/trip.js +33 -27
  54. package/lib/chevre/repository.d.ts +3 -0
  55. package/lib/chevre/repository.js +5 -1
  56. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -68
  57. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  58. package/lib/chevre/service/aggregation/system.d.ts +100 -0
  59. package/lib/chevre/service/aggregation/system.js +409 -0
  60. package/lib/chevre/service/aggregation.d.ts +2 -0
  61. package/lib/chevre/service/aggregation.js +3 -1
  62. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  63. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  64. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  65. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  66. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  67. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  68. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  69. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  71. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  72. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  73. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  74. package/lib/chevre/service/code.d.ts +2 -3
  75. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  76. package/lib/chevre/service/delivery/product/factory.js +9 -3
  77. package/lib/chevre/service/event.d.ts +2 -4
  78. package/lib/chevre/service/event.js +35 -14
  79. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  80. package/lib/chevre/service/offer/event/authorize.js +33 -87
  81. package/lib/chevre/service/offer/event/cancel.js +0 -1
  82. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  83. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  84. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  85. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  86. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  87. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  88. package/lib/chevre/service/offer/factory.js +10 -3
  89. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  90. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  91. package/lib/chevre/service/offer/product.d.ts +1 -0
  92. package/lib/chevre/service/offer/product.js +7 -2
  93. package/lib/chevre/service/offer.d.ts +13 -2
  94. package/lib/chevre/service/offer.js +68 -46
  95. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
  96. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  97. package/lib/chevre/service/order/placeOrder.js +16 -0
  98. package/lib/chevre/service/order/returnOrder.js +6 -4
  99. package/lib/chevre/service/order/sendOrder.js +4 -2
  100. package/lib/chevre/service/payment/any.d.ts +9 -0
  101. package/lib/chevre/service/payment/any.js +16 -1
  102. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  103. package/lib/chevre/service/payment/movieTicket.js +8 -2
  104. package/lib/chevre/service/product.js +5 -3
  105. package/lib/chevre/service/report/telemetry.js +1 -1
  106. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  107. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  108. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  109. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  110. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  111. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  112. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  113. package/lib/chevre/service/reserve/useReservation.js +58 -32
  114. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  115. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  116. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  117. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  118. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  119. package/lib/chevre/service/task.js +6 -9
  120. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  121. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  122. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
  123. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  124. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  125. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
  126. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
  127. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
  128. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
  129. package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
  130. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  131. package/lib/chevre/settings.d.ts +2 -0
  132. package/lib/chevre/settings.js +20 -12
  133. package/package.json +3 -3
  134. package/CHANGELOG.md +0 -2030
  135. package/example/.gitignore +0 -1
  136. package/example/src/chevre/.gitignore +0 -1
  137. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  138. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
  139. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
  140. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
@@ -0,0 +1,409 @@
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.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregatePayMovieTicketAction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = 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
+ function aggregateEvent(params) {
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a;
21
+ const aggregateDate = new Date();
22
+ const aggregateDuration = moment.duration(1, 'days')
23
+ .toISOString();
24
+ let i = -1;
25
+ while (i < params.aggregationDays) {
26
+ i += 1;
27
+ const startFrom = moment()
28
+ .utc()
29
+ // .tz('Asia/Tokyo')
30
+ .add(-i, 'days')
31
+ .startOf('day')
32
+ .toDate();
33
+ const startThrough = moment()
34
+ .utc()
35
+ // .tz('Asia/Tokyo')
36
+ .add(-i, 'days')
37
+ .endOf('day')
38
+ .toDate();
39
+ const aggregateResult = yield repos.event.aggregateEvent({
40
+ project: { id: { $ne: params.excludedProjectId } },
41
+ startFrom,
42
+ startThrough,
43
+ typeOf: factory.eventType.ScreeningEvent
44
+ });
45
+ debug('aggregateEvent:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesRemainingCapacityRate, startFrom);
46
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateEvent, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
47
+ }
48
+ });
49
+ }
50
+ exports.aggregateEvent = aggregateEvent;
51
+ /**
52
+ * 注文取引集計
53
+ */
54
+ function aggregatePlaceOrder(params) {
55
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
56
+ var _a, _b;
57
+ const aggregateDate = new Date();
58
+ const aggregateDuration = moment.duration(1, 'days')
59
+ .toISOString();
60
+ let i = -1;
61
+ while (i < params.aggregationDays) {
62
+ i += 1;
63
+ const startFrom = moment()
64
+ .utc()
65
+ // .tz('Asia/Tokyo')
66
+ .add(-i, 'days')
67
+ .startOf('day')
68
+ .toDate();
69
+ const startThrough = moment()
70
+ .utc()
71
+ // .tz('Asia/Tokyo')
72
+ .add(-i, 'days')
73
+ .endOf('day')
74
+ .toDate();
75
+ const aggregateResult = yield repos.transaction.aggregatePlaceOrder({
76
+ project: { id: { $ne: params.excludedProjectId } },
77
+ startFrom,
78
+ startThrough,
79
+ typeOf: factory.transactionType.PlaceOrder
80
+ });
81
+ debug('aggregatePlaceOrder:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
82
+ const aggregateResultsByClientId = [];
83
+ if (Array.isArray(params.clientIds)) {
84
+ for (const clientId of params.clientIds) {
85
+ const aggregateResultByClientId = yield repos.transaction.aggregatePlaceOrder({
86
+ project: { id: { $ne: params.excludedProjectId } },
87
+ startFrom,
88
+ startThrough,
89
+ typeOf: factory.transactionType.PlaceOrder,
90
+ clientId
91
+ });
92
+ debug('aggregateResultByClientId', aggregateResultByClientId, (_b = aggregateResultByClientId.statuses[0]) === null || _b === void 0 ? void 0 : _b.aggregation, clientId, startFrom);
93
+ aggregateResultsByClientId.push({
94
+ clientId,
95
+ aggregation: aggregateResultByClientId
96
+ });
97
+ }
98
+ }
99
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePlaceOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate, aggregationByClient: aggregateResultsByClientId }, aggregateResult));
100
+ }
101
+ });
102
+ }
103
+ exports.aggregatePlaceOrder = aggregatePlaceOrder;
104
+ /**
105
+ * 興行オファー承認アクション集計
106
+ */
107
+ function aggregateAuthorizeEventServiceOfferAction(params) {
108
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
109
+ var _a;
110
+ const aggregateDate = new Date();
111
+ const aggregateDuration = moment.duration(1, 'days')
112
+ .toISOString();
113
+ let i = -1;
114
+ while (i < params.aggregationDays) {
115
+ i += 1;
116
+ const startFrom = moment()
117
+ .utc()
118
+ // .tz('Asia/Tokyo')
119
+ .add(-i, 'days')
120
+ .startOf('day')
121
+ .toDate();
122
+ const startThrough = moment()
123
+ .utc()
124
+ // .tz('Asia/Tokyo')
125
+ .add(-i, 'days')
126
+ .endOf('day')
127
+ .toDate();
128
+ const aggregateResult = yield repos.action.aggregateAuthorizeEventServiceOfferAction({
129
+ project: { id: { $ne: params.excludedProjectId } },
130
+ startFrom,
131
+ startThrough,
132
+ typeOf: factory.actionType.AuthorizeAction
133
+ });
134
+ debug('aggregateAuthorizeEventServiceOfferAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
135
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeEventServiceOfferAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
136
+ }
137
+ });
138
+ }
139
+ exports.aggregateAuthorizeEventServiceOfferAction = aggregateAuthorizeEventServiceOfferAction;
140
+ /**
141
+ * 決済承認アクション集計
142
+ */
143
+ function aggregateAuthorizePaymentAction(params) {
144
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
145
+ var _a;
146
+ const aggregateDate = new Date();
147
+ const aggregateDuration = moment.duration(1, 'days')
148
+ .toISOString();
149
+ let i = -1;
150
+ while (i < params.aggregationDays) {
151
+ i += 1;
152
+ const startFrom = moment()
153
+ .utc()
154
+ // .tz('Asia/Tokyo')
155
+ .add(-i, 'days')
156
+ .startOf('day')
157
+ .toDate();
158
+ const startThrough = moment()
159
+ .utc()
160
+ // .tz('Asia/Tokyo')
161
+ .add(-i, 'days')
162
+ .endOf('day')
163
+ .toDate();
164
+ const aggregateResult = yield repos.action.aggregateAuthorizePaymentAction({
165
+ project: { id: { $ne: params.excludedProjectId } },
166
+ startFrom,
167
+ startThrough,
168
+ typeOf: factory.actionType.AuthorizeAction
169
+ });
170
+ debug('aggregateAuthorizePaymentAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
171
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizePaymentAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
172
+ }
173
+ });
174
+ }
175
+ exports.aggregateAuthorizePaymentAction = aggregateAuthorizePaymentAction;
176
+ function aggregateAuthorizeOrderAction(params) {
177
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
178
+ var _a;
179
+ const aggregateDate = new Date();
180
+ const aggregateDuration = moment.duration(1, 'days')
181
+ .toISOString();
182
+ let i = -1;
183
+ while (i < params.aggregationDays) {
184
+ i += 1;
185
+ const startFrom = moment()
186
+ .utc()
187
+ // .tz('Asia/Tokyo')
188
+ .add(-i, 'days')
189
+ .startOf('day')
190
+ .toDate();
191
+ const startThrough = moment()
192
+ .utc()
193
+ // .tz('Asia/Tokyo')
194
+ .add(-i, 'days')
195
+ .endOf('day')
196
+ .toDate();
197
+ const aggregateResult = yield repos.action.aggregateAuthorizeOrderAction({
198
+ project: { id: { $ne: params.excludedProjectId } },
199
+ startFrom,
200
+ startThrough,
201
+ typeOf: factory.actionType.AuthorizeAction
202
+ });
203
+ debug('aggregateAuthorizeOrderAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
204
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeOrderAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
205
+ }
206
+ });
207
+ }
208
+ exports.aggregateAuthorizeOrderAction = aggregateAuthorizeOrderAction;
209
+ /**
210
+ * 使用アクション集計
211
+ */
212
+ function aggregateUseAction(params) {
213
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
214
+ var _a;
215
+ const aggregateDate = new Date();
216
+ const aggregateDuration = moment.duration(1, 'days')
217
+ .toISOString();
218
+ let i = -1;
219
+ while (i < params.aggregationDays) {
220
+ i += 1;
221
+ const startFrom = moment()
222
+ .utc()
223
+ // .tz('Asia/Tokyo')
224
+ .add(-i, 'days')
225
+ .startOf('day')
226
+ .toDate();
227
+ const startThrough = moment()
228
+ .utc()
229
+ // .tz('Asia/Tokyo')
230
+ .add(-i, 'days')
231
+ .endOf('day')
232
+ .toDate();
233
+ const aggregateResult = yield repos.action.aggregateUseAction({
234
+ project: { id: { $ne: params.excludedProjectId } },
235
+ startFrom,
236
+ startThrough,
237
+ typeOf: factory.actionType.UseAction
238
+ });
239
+ debug('aggregateUseAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
240
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateUseAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
241
+ }
242
+ });
243
+ }
244
+ exports.aggregateUseAction = aggregateUseAction;
245
+ function aggregateCheckMovieTicketAction(params) {
246
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
247
+ var _a;
248
+ const aggregateDate = new Date();
249
+ const aggregateDuration = moment.duration(1, 'days')
250
+ .toISOString();
251
+ let i = -1;
252
+ while (i < params.aggregationDays) {
253
+ i += 1;
254
+ const startFrom = moment()
255
+ .utc()
256
+ // .tz('Asia/Tokyo')
257
+ .add(-i, 'days')
258
+ .startOf('day')
259
+ .toDate();
260
+ const startThrough = moment()
261
+ .utc()
262
+ // .tz('Asia/Tokyo')
263
+ .add(-i, 'days')
264
+ .endOf('day')
265
+ .toDate();
266
+ const aggregateResult = yield repos.action.aggregateCheckMovieTicketAction({
267
+ project: { id: { $ne: params.excludedProjectId } },
268
+ startFrom,
269
+ startThrough
270
+ });
271
+ debug('aggregateCheckMovieTicketAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
272
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateCheckMovieTicketAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
273
+ }
274
+ });
275
+ }
276
+ exports.aggregateCheckMovieTicketAction = aggregateCheckMovieTicketAction;
277
+ function aggregatePayMovieTicketAction(params) {
278
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
279
+ var _a;
280
+ const aggregateDate = new Date();
281
+ const aggregateDuration = moment.duration(1, 'days')
282
+ .toISOString();
283
+ let i = -1;
284
+ while (i < params.aggregationDays) {
285
+ i += 1;
286
+ const startFrom = moment()
287
+ .utc()
288
+ // .tz('Asia/Tokyo')
289
+ .add(-i, 'days')
290
+ .startOf('day')
291
+ .toDate();
292
+ const startThrough = moment()
293
+ .utc()
294
+ // .tz('Asia/Tokyo')
295
+ .add(-i, 'days')
296
+ .endOf('day')
297
+ .toDate();
298
+ const aggregateResult = yield repos.action.aggregatePayMovieTicketAction({
299
+ project: { id: { $ne: params.excludedProjectId } },
300
+ startFrom,
301
+ startThrough
302
+ });
303
+ debug('aggregatePayMovieTicketAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
304
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePayMovieTicketAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
305
+ }
306
+ });
307
+ }
308
+ exports.aggregatePayMovieTicketAction = aggregatePayMovieTicketAction;
309
+ function aggregatePayTransaction(params) {
310
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
311
+ var _a;
312
+ const aggregateDate = new Date();
313
+ const aggregateDuration = moment.duration(1, 'days')
314
+ .toISOString();
315
+ let i = -1;
316
+ while (i < params.aggregationDays) {
317
+ i += 1;
318
+ const startFrom = moment()
319
+ .utc()
320
+ // .tz('Asia/Tokyo')
321
+ .add(-i, 'days')
322
+ .startOf('day')
323
+ .toDate();
324
+ const startThrough = moment()
325
+ .utc()
326
+ // .tz('Asia/Tokyo')
327
+ .add(-i, 'days')
328
+ .endOf('day')
329
+ .toDate();
330
+ const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
331
+ project: { id: { $ne: params.excludedProjectId } },
332
+ startFrom,
333
+ startThrough,
334
+ typeOf: factory.assetTransactionType.Pay
335
+ });
336
+ debug('aggregatePayTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
337
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePay, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
338
+ }
339
+ });
340
+ }
341
+ exports.aggregatePayTransaction = aggregatePayTransaction;
342
+ /**
343
+ * 予約集計
344
+ */
345
+ function aggregateReserveTransaction(params) {
346
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
347
+ var _a;
348
+ const aggregateDate = new Date();
349
+ const aggregateDuration = moment.duration(1, 'days')
350
+ .toISOString();
351
+ let i = -1;
352
+ while (i < params.aggregationDays) {
353
+ i += 1;
354
+ const startFrom = moment()
355
+ .utc()
356
+ // .tz('Asia/Tokyo')
357
+ .add(-i, 'days')
358
+ .startOf('day')
359
+ .toDate();
360
+ const startThrough = moment()
361
+ .utc()
362
+ // .tz('Asia/Tokyo')
363
+ .add(-i, 'days')
364
+ .endOf('day')
365
+ .toDate();
366
+ const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
367
+ project: { id: { $ne: params.excludedProjectId } },
368
+ startFrom,
369
+ startThrough,
370
+ typeOf: factory.assetTransactionType.Reserve
371
+ });
372
+ debug('aggregateReserveTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
373
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReserve, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
374
+ }
375
+ });
376
+ }
377
+ exports.aggregateReserveTransaction = aggregateReserveTransaction;
378
+ function aggregateTask(params) {
379
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
380
+ var _a;
381
+ const aggregateDate = new Date();
382
+ const aggregateDuration = moment.duration(1, 'days')
383
+ .toISOString();
384
+ let i = -1;
385
+ while (i < params.aggregationDays) {
386
+ i += 1;
387
+ const runsFrom = moment()
388
+ .utc()
389
+ // .tz('Asia/Tokyo')
390
+ .add(-i, 'days')
391
+ .startOf('day')
392
+ .toDate();
393
+ const runsThrough = moment()
394
+ .utc()
395
+ // .tz('Asia/Tokyo')
396
+ .add(-i, 'days')
397
+ .endOf('day')
398
+ .toDate();
399
+ const aggregateResult = yield repos.task.aggregateTask({
400
+ project: { id: { $ne: params.excludedProjectId } },
401
+ runsFrom,
402
+ runsThrough
403
+ });
404
+ debug('aggregateTask:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, runsFrom);
405
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateTask, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: runsFrom, aggregateDate }, aggregateResult));
406
+ }
407
+ });
408
+ }
409
+ exports.aggregateTask = aggregateTask;
@@ -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;
@@ -38,7 +38,11 @@ function validateMovieTicket(params, paymentServiceId) {
38
38
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
39
39
  }
40
40
  // イベント情報取得
41
- const screeningEvent = yield repos.event.findById({
41
+ // イベント取得属性最適化(2023-01-23~)
42
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({
43
+ // id: eventIds[0]
44
+ // });
45
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
42
46
  id: eventIds[0]
43
47
  });
44
48
  // 販売者からムビチケ決済情報取得
@@ -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 declare type ICancelOperation<T> = (repos: {
28
+ export interface ICancelRepos {
29
+ action: ActionRepo;
30
+ accountingReport: AccountingReportRepo;
29
31
  assetTransaction: AssetTransactionRepo;
30
- }) => Promise<T>;
31
- export declare type IConfirmOperation<T> = (repos: {
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
- }) => Promise<T>;
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
- potentialActions: potentialActions
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
- // tslint:disable-next-line:no-single-line-block-comment
394
- /* istanbul ignore else */
395
- if (potentialActions !== undefined) {
396
- // tslint:disable-next-line:no-single-line-block-comment
397
- /* istanbul ignore else */
398
- if (potentialActions.pay !== undefined) {
399
- const payTasks = potentialActions.pay.map((a) => {
400
- return {
401
- project: transaction.project,
402
- name: factory.taskName.Pay,
403
- status: factory.taskStatus.Ready,
404
- runsAt: taskRunsAt,
405
- remainingNumberOfTries: 10,
406
- numberOfTried: 0,
407
- executionResults: [],
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:
@@ -93,7 +93,10 @@ exports.start = start;
93
93
  function createTransactionObject(params) {
94
94
  return (repos) => __awaiter(this, void 0, void 0, function* () {
95
95
  // オファー検索
96
- const offers = yield (0, searchProductOffers_1.searchProductOffers)({ itemOffered: { id: String(params.product.id) } })(repos);
96
+ const offers = yield (0, searchProductOffers_1.searchProductOffers)({
97
+ itemOffered: { id: String(params.product.id) },
98
+ sort: false // ソート不要(2023-01-27~)
99
+ })(repos);
97
100
  const transactionObject = [];
98
101
  for (const acceptedOffer of params.acceptedOffers) {
99
102
  const offer = offers.find((o) => o.id === acceptedOffer.id);
@@ -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 {};