@chevre/domain 20.2.0-alpha.5 → 20.2.0-alpha.51

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 (134) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +112 -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 +68 -1
  21. package/lib/chevre/repo/action.js +227 -6
  22. package/lib/chevre/repo/aggregation.d.ts +37 -0
  23. package/lib/chevre/repo/aggregation.js +67 -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 +4 -1
  46. package/lib/chevre/repo/project.js +9 -10
  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 +45 -5
  52. package/lib/chevre/repo/transaction.js +187 -29
  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.d.ts +1 -1
  57. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -59
  58. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  59. package/lib/chevre/service/aggregation/system.d.ts +93 -0
  60. package/lib/chevre/service/aggregation/system.js +377 -0
  61. package/lib/chevre/service/aggregation.d.ts +2 -0
  62. package/lib/chevre/service/aggregation.js +3 -1
  63. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  64. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  65. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  66. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  67. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  68. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  69. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  71. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  72. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  73. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  74. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  75. package/lib/chevre/service/code.d.ts +2 -3
  76. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  77. package/lib/chevre/service/delivery/factory.js +1 -0
  78. package/lib/chevre/service/delivery/product/factory.js +9 -3
  79. package/lib/chevre/service/event.d.ts +2 -4
  80. package/lib/chevre/service/event.js +35 -14
  81. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  82. package/lib/chevre/service/offer/event/authorize.js +33 -87
  83. package/lib/chevre/service/offer/event/cancel.js +0 -1
  84. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  85. package/lib/chevre/service/offer/event/factory.js +25 -5
  86. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  87. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  88. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  89. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  90. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  91. package/lib/chevre/service/offer/factory.js +10 -3
  92. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  93. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  94. package/lib/chevre/service/offer/product.d.ts +1 -0
  95. package/lib/chevre/service/offer/product.js +6 -2
  96. package/lib/chevre/service/offer.d.ts +13 -2
  97. package/lib/chevre/service/offer.js +86 -60
  98. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
  99. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  100. package/lib/chevre/service/order/placeOrder.js +16 -0
  101. package/lib/chevre/service/order/returnOrder.js +6 -4
  102. package/lib/chevre/service/order/sendOrder.js +4 -2
  103. package/lib/chevre/service/payment/any.d.ts +5 -0
  104. package/lib/chevre/service/payment/any.js +7 -1
  105. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  106. package/lib/chevre/service/payment/movieTicket.js +8 -2
  107. package/lib/chevre/service/product.js +5 -3
  108. package/lib/chevre/service/report/telemetry.js +1 -1
  109. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  110. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  111. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  112. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  113. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  114. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  115. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  116. package/lib/chevre/service/reserve/useReservation.js +58 -32
  117. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  118. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  119. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  120. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  121. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  122. package/lib/chevre/service/task.js +6 -9
  123. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  124. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  125. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  126. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  127. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  128. package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
  129. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  130. package/lib/chevre/settings.d.ts +2 -0
  131. package/lib/chevre/settings.js +20 -12
  132. package/package.json +3 -3
  133. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  134. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var _a;
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  exports.onReservationUsed = void 0;
14
13
  /**
@@ -20,7 +19,6 @@ const settings_1 = require("../../../settings");
20
19
  const offer_1 = require("../../offer");
21
20
  const factory_1 = require("../factory");
22
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
23
- const informUseReservations = (_a = settings_1.settings.onReservationUsed) === null || _a === void 0 ? void 0 : _a.informAction;
24
22
  const INFORM_TASK_DELAY_IN_SECONDS = 30;
25
23
  /**
26
24
  * 予約使用
@@ -28,41 +26,39 @@ const INFORM_TASK_DELAY_IN_SECONDS = 30;
28
26
  function onReservationUsed(action, attendedReservation) {
29
27
  // tslint:disable-next-line:max-func-body-length
30
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
- // const reservation = action.object[0];
32
29
  const tasks = [];
33
30
  const now = new Date();
31
+ // INFORM_USE_RESERVATION_URL廃止(2023-01-30~)
34
32
  // アクション通知タスク作成
35
- if (Array.isArray(informUseReservations)) {
36
- informUseReservations.filter((informUseReservation) => {
37
- var _a;
38
- return typeof ((_a = informUseReservation.recipient) === null || _a === void 0 ? void 0 : _a.url) === 'string'
39
- && informUseReservation.recipient.url.length > 0;
40
- })
41
- .forEach((informUseReservation) => {
42
- var _a, _b;
43
- const triggerWebhookTask = {
44
- project: action.project,
45
- name: factory.taskName.TriggerWebhook,
46
- status: factory.taskStatus.Ready,
47
- runsAt: now,
48
- remainingNumberOfTries: 3,
49
- numberOfTried: 0,
50
- executionResults: [],
51
- data: {
52
- project: action.project,
53
- typeOf: factory.actionType.InformAction,
54
- agent: action.project,
55
- recipient: {
56
- typeOf: factory.personType.Person,
57
- id: String((_a = informUseReservation.recipient) === null || _a === void 0 ? void 0 : _a.url),
58
- url: String((_b = informUseReservation.recipient) === null || _b === void 0 ? void 0 : _b.url)
59
- },
60
- object: action
61
- }
62
- };
63
- tasks.push(triggerWebhookTask);
64
- });
65
- }
33
+ // if (Array.isArray(informUseReservations)) {
34
+ // informUseReservations.filter((informUseReservation) => {
35
+ // return typeof informUseReservation.recipient?.url === 'string'
36
+ // && informUseReservation.recipient.url.length > 0;
37
+ // })
38
+ // .forEach((informUseReservation) => {
39
+ // const triggerWebhookTask: factory.task.triggerWebhook.IAttributes = {
40
+ // project: action.project,
41
+ // name: factory.taskName.TriggerWebhook,
42
+ // status: factory.taskStatus.Ready,
43
+ // runsAt: now,
44
+ // remainingNumberOfTries: 3,
45
+ // numberOfTried: 0,
46
+ // executionResults: [],
47
+ // data: {
48
+ // project: action.project,
49
+ // typeOf: factory.actionType.InformAction,
50
+ // agent: action.project,
51
+ // recipient: {
52
+ // typeOf: factory.personType.Person,
53
+ // id: String(informUseReservation.recipient?.url),
54
+ // url: String(informUseReservation.recipient?.url)
55
+ // },
56
+ // object: action
57
+ // }
58
+ // };
59
+ // tasks.push(triggerWebhookTask);
60
+ // });
61
+ // }
66
62
  // inform galobally
67
63
  if (Array.isArray(informReservations)) {
68
64
  // やや遅延させる(確定通知が未達の可能性を考慮して)
@@ -134,7 +130,8 @@ function onReservationUsed(action, attendedReservation) {
134
130
  // 冗長な作成を避ける
135
131
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
136
132
  project: attendedReservation.project,
137
- reservationFor: { id: attendedReservation.reservationFor.id }
133
+ reservationFor: [{ id: attendedReservation.reservationFor.id }],
134
+ force: false
138
135
  })({ task: repos.task });
139
136
  });
140
137
  }
@@ -11,9 +11,6 @@ import { IUseReservationAction } from './potentialActions/onReservationUsed';
11
11
  * 予約使用
12
12
  */
13
13
  export declare function useReservation(params: {
14
- project: {
15
- id: string;
16
- };
17
14
  agent: factory.action.consume.use.reservation.IAgent;
18
15
  object: {
19
16
  /**
@@ -15,7 +15,7 @@ exports.useReservation = void 0;
15
15
  */
16
16
  const factory = require("../../factory");
17
17
  const code_1 = require("../code");
18
- const factory_1 = require("./factory");
18
+ // import { maskUnderName } from './factory';
19
19
  const onReservationUsed_1 = require("./potentialActions/onReservationUsed");
20
20
  function verifyToken4reservation(params) {
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -26,8 +26,18 @@ function verifyToken4reservation(params) {
26
26
  })({});
27
27
  switch (payload.typeOf) {
28
28
  case factory.order.OrderType.Order:
29
+ // reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
30
+ const order = yield repos.order.findByOrderNumberAndReservationId({
31
+ orderNumber: payload.orderNumber,
32
+ reservationId: params.reservationId
33
+ });
29
34
  // 注文検索
30
- const order = yield repos.order.findByOrderNumber({ orderNumber: payload.orderNumber });
35
+ // const order: Pick<factory.order.IOrder, 'orderStatus' | 'acceptedOffers'> =
36
+ // await repos.order.findByOrderNumber({
37
+ // orderNumber: payload.orderNumber,
38
+ // inclusion: ['orderStatus', 'acceptedOffers'],
39
+ // exclusion: []
40
+ // });
31
41
  // ステータス検証
32
42
  switch (order.orderStatus) {
33
43
  case factory.orderStatus.OrderDelivered:
@@ -35,14 +45,17 @@ function verifyToken4reservation(params) {
35
45
  default:
36
46
  throw new factory.errors.Argument('token', `invalid orderStatus '${order.orderStatus}'`);
37
47
  }
38
- const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
39
- const reservationExistsInOrder = acceptedOffers.some((offer) => {
40
- return offer.itemOffered.typeOf === factory.reservationType.EventReservation
41
- && offer.itemOffered.id === params.reservationId;
42
- });
43
- if (!reservationExistsInOrder) {
44
- throw new factory.errors.NotFound('AcceptedOffer');
45
- }
48
+ // const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
49
+ // const reservationExistsInOrder = acceptedOffers.some((offer) => {
50
+ // return (
51
+ // offer.itemOffered.typeOf === factory.reservationType.EventReservation
52
+ // || offer.itemOffered.typeOf === factory.reservationType.BusReservation
53
+ // )
54
+ // && offer.itemOffered.id === params.reservationId;
55
+ // });
56
+ // if (!reservationExistsInOrder) {
57
+ // throw new factory.errors.NotFound('AcceptedOffer');
58
+ // }
46
59
  break;
47
60
  default:
48
61
  throw new factory.errors.NotImplemented(`Payload type ${payload.typeOf} not implemented`);
@@ -52,54 +65,67 @@ function verifyToken4reservation(params) {
52
65
  /**
53
66
  * 予約使用
54
67
  */
55
- // export function useReservation(actionAttributes: factory.action.consume.use.reservation.IAttributes) {
68
+ // tslint:disable-next-line:max-func-body-length
56
69
  function useReservation(params) {
57
70
  return (repos) => __awaiter(this, void 0, void 0, function* () {
58
- var _a, _b, _c;
71
+ var _a, _b;
59
72
  const now = new Date();
73
+ const reservationId = params.object.id;
60
74
  // 予約検索
61
- let reservation = yield repos.reservation.findById({ id: params.object.id });
75
+ // 取得属性最適化(2023-01-30~)
76
+ const reservation = yield repos.reservation.findById({
77
+ id: reservationId,
78
+ inclusion: ['id', 'issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
79
+ });
62
80
  // instrument?.tokenを検証
63
81
  const token = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.token;
64
82
  if (typeof token === 'string') {
65
83
  yield verifyToken4reservation({
66
- project: { id: params.project.id },
84
+ project: { id: reservation.project.id },
67
85
  agent: params.agent,
68
- reservationId: params.object.id,
86
+ reservationId,
69
87
  token
70
88
  })({ order: repos.order });
71
89
  }
72
90
  // UseActionを作成する
73
- const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), {
74
- typeOf: factory.action.check.token.ObjectType.Ticket
75
- }),
91
+ const reservationAsObject = {
92
+ id: reservation.id,
93
+ issuedThrough: reservation.issuedThrough,
94
+ reservationFor: reservation.reservationFor,
95
+ reservationNumber: reservation.reservationNumber,
96
+ reservedTicket: reservation.reservedTicket,
97
+ typeOf: reservation.typeOf
98
+ };
99
+ const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }),
100
+ // object最適化(2023-01-30~)
76
101
  // どの予約を
77
102
  // mask
78
- object: [(0, factory_1.maskUnderName)(reservation)] }, (typeof ((_b = params.location) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
103
+ // object: [maskUnderName(reservation)],
104
+ object: [reservationAsObject] }, (typeof ((_b = params.location) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
79
105
  ? {
80
106
  location: {
81
107
  typeOf: factory.placeType.Place,
82
108
  identifier: params.location.identifier
83
109
  }
84
110
  }
85
- : undefined
86
- // purpose: params.purpose
87
- );
111
+ : undefined);
88
112
  let action = yield repos.action.start(actionAttributes);
89
113
  // ひとまず予約数:1に限定する
90
114
  if (actionAttributes.object.length !== 1) {
91
115
  throw new factory.errors.Argument('object', 'number of using reservations must be 1');
92
116
  }
93
- reservation = actionAttributes.object[0];
117
+ let attendedReservation;
94
118
  try {
95
- reservation = (yield repos.reservation.attend({ id: reservation.id, now }));
96
- // 使用日時がなければ追加
97
- if (((_c = reservation.reservedTicket) === null || _c === void 0 ? void 0 : _c.dateUsed) === undefined) {
98
- reservation = yield repos.reservation.updatePartiallyById({
99
- id: reservation.id,
100
- update: { 'reservedTicket.dateUsed': now }
101
- });
102
- }
119
+ // 使用日時と同時更新(2023-01-30~)
120
+ attendedReservation = (yield repos.reservation.attendIfNotAttended({ id: reservationId, now }));
121
+ // attendedReservation = <IEventReservation>await repos.reservation.attend({ id: reservationId, now });
122
+ // // 使用日時がなければ追加
123
+ // if (attendedReservation.reservedTicket?.dateUsed === undefined) {
124
+ // attendedReservation = await repos.reservation.updatePartiallyById({
125
+ // id: attendedReservation.id,
126
+ // update: { 'reservedTicket.dateUsed': now }
127
+ // });
128
+ // }
103
129
  }
104
130
  catch (error) {
105
131
  // actionにエラー結果を追加
@@ -114,7 +140,7 @@ function useReservation(params) {
114
140
  }
115
141
  // アクション完了
116
142
  action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: {} }));
117
- yield (0, onReservationUsed_1.onReservationUsed)(action, reservation)({ task: repos.task });
143
+ yield (0, onReservationUsed_1.onReservationUsed)(action, attendedReservation)({ task: repos.task });
118
144
  return action;
119
145
  });
120
146
  }
@@ -10,9 +10,15 @@ 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 accountingReport_1 = require("../../repo/accountingReport");
13
14
  const action_1 = require("../../repo/action");
14
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const event_1 = require("../../repo/event");
15
17
  const order_1 = require("../../repo/order");
18
+ const product_1 = require("../../repo/product");
19
+ const project_1 = require("../../repo/project");
20
+ const seller_1 = require("../../repo/seller");
21
+ const task_1 = require("../../repo/task");
16
22
  const PayTransactionService = require("../assetTransaction/pay");
17
23
  /**
18
24
  * タスク実行関数
@@ -22,6 +28,12 @@ function call(data) {
22
28
  const actionRepo = new action_1.MongoRepository(settings.connection);
23
29
  const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
24
30
  const orderRepo = new order_1.MongoRepository(settings.connection);
31
+ const accountingReportRepo = new accountingReport_1.MongoRepository(settings.connection);
32
+ const eventRepo = new event_1.MongoRepository(settings.connection);
33
+ const productRepo = new product_1.MongoRepository(settings.connection);
34
+ const projectRepo = new project_1.MongoRepository(settings.connection);
35
+ const sellerRepo = new seller_1.MongoRepository(settings.connection);
36
+ const taskRepo = new task_1.MongoRepository(settings.connection);
25
37
  // アクション開始
26
38
  const action = yield actionRepo.start(data);
27
39
  try {
@@ -38,8 +50,15 @@ function call(data) {
38
50
  }
39
51
  }
40
52
  })({
53
+ action: actionRepo,
54
+ accountingReport: accountingReportRepo,
41
55
  assetTransaction: assetTransactionRepo,
42
- order: orderRepo
56
+ event: eventRepo,
57
+ order: orderRepo,
58
+ product: productRepo,
59
+ project: projectRepo,
60
+ seller: sellerRepo,
61
+ task: taskRepo
43
62
  });
44
63
  }
45
64
  }
@@ -3,6 +3,8 @@ import * as factory from '../../factory';
3
3
  import { MongoRepository as ActionRepo } from '../../repo/action';
4
4
  import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
5
5
  import { MongoRepository as OrderRepo } from '../../repo/order';
6
+ import { MongoRepository as ReservationRepo } from '../../repo/reservation';
7
+ import { MongoRepository as TaskRepo } from '../../repo/task';
6
8
  /**
7
9
  * タスク実行関数
8
10
  */
@@ -14,4 +16,6 @@ export declare function confirmReserveTransaction(params: factory.action.interac
14
16
  action: ActionRepo;
15
17
  assetTransaction: AssetTransactionRepo;
16
18
  order: OrderRepo;
19
+ reservation: ReservationRepo;
20
+ task: TaskRepo;
17
21
  }) => Promise<void>;
@@ -15,6 +15,8 @@ const factory = require("../../factory");
15
15
  const action_1 = require("../../repo/action");
16
16
  const assetTransaction_1 = require("../../repo/assetTransaction");
17
17
  const order_1 = require("../../repo/order");
18
+ const reservation_1 = require("../../repo/reservation");
19
+ const task_1 = require("../../repo/task");
18
20
  const ReserveTransactionService = require("../assetTransaction/reserve");
19
21
  const credentials_1 = require("../../credentials");
20
22
  const coaAuthClient = new COA.auth.RefreshToken({
@@ -29,7 +31,9 @@ function call(data) {
29
31
  yield confirmReserveTransaction(data)({
30
32
  action: new action_1.MongoRepository(settings.connection),
31
33
  assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
32
- order: new order_1.MongoRepository(settings.connection)
34
+ order: new order_1.MongoRepository(settings.connection),
35
+ reservation: new reservation_1.MongoRepository(settings.connection),
36
+ task: new task_1.MongoRepository(settings.connection)
33
37
  });
34
38
  });
35
39
  }
@@ -44,9 +48,6 @@ function confirmReserveTransaction(params) {
44
48
  const action = yield repos.action.start(confirmActionAttributes);
45
49
  try {
46
50
  let object = confirmActionAttributes.object;
47
- // if (params.instrument === undefined) {
48
- // params.instrument = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
49
- // }
50
51
  switch (params.instrument.identifier) {
51
52
  case factory.service.webAPI.Identifier.COA:
52
53
  // COA本予約
@@ -72,7 +73,6 @@ function confirmReserveTransaction(params) {
72
73
  object = object;
73
74
  yield ReserveTransactionService.confirm({
74
75
  transactionNumber: object.transactionNumber,
75
- // object: object.object,
76
76
  potentialActions: object.potentialActions
77
77
  })(repos);
78
78
  }
@@ -14,6 +14,7 @@ const action_1 = require("../../repo/action");
14
14
  const categoryCode_1 = require("../../repo/categoryCode");
15
15
  const event_1 = require("../../repo/event");
16
16
  const place_1 = require("../../repo/place");
17
+ const seller_1 = require("../../repo/seller");
17
18
  const EventService = require("../event");
18
19
  /**
19
20
  * タスク実行関数
@@ -24,7 +25,8 @@ function call(data) {
24
25
  action: new action_1.MongoRepository(settings.connection),
25
26
  categoryCode: new categoryCode_1.MongoRepository(settings.connection),
26
27
  event: new event_1.MongoRepository(settings.connection),
27
- place: new place_1.MongoRepository(settings.connection)
28
+ place: new place_1.MongoRepository(settings.connection),
29
+ seller: new seller_1.MongoRepository(settings.connection)
28
30
  });
29
31
  });
30
32
  }
@@ -64,7 +64,11 @@ function returnPayTransaction(params) {
64
64
  if (typeof paymentServiceType !== 'string' || paymentServiceType.length === 0) {
65
65
  throw new factory.errors.ArgumentNull('object.issuedThrough.typeOf');
66
66
  }
67
- const order = yield repos.order.findByOrderNumber({ orderNumber });
67
+ const order = yield repos.order.findByOrderNumber({
68
+ orderNumber,
69
+ inclusion: ['seller', 'project', 'dateReturned'],
70
+ exclusion: []
71
+ });
68
72
  const action = yield repos.action.start(refundActionAttributes);
69
73
  let refundTransaction;
70
74
  try {
@@ -213,8 +217,10 @@ function onRefund(refundActionAttributes) {
213
217
  });
214
218
  }
215
219
  // タスク保管
216
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
217
- return repos.task.save(taskAttribute);
218
- })));
220
+ // saveManyに変更(2023-02-01~)
221
+ yield repos.task.saveMany(taskAttributes);
222
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
223
+ // return repos.task.save(taskAttribute);
224
+ // }));
219
225
  });
220
226
  }
@@ -113,16 +113,13 @@ function abort(params) {
113
113
  exports.abort = abort;
114
114
  function notifyAbortedTasks(params) {
115
115
  return (repos) => __awaiter(this, void 0, void 0, function* () {
116
- let abortedTasks = yield repos.task.search({
117
- statuses: [factory.taskStatus.Aborted],
118
- dateAborted: {
119
- $gte: params.dateAbortedGte
120
- }
121
- });
116
+ const abortedTasks = yield repos.task.search(Object.assign({ statuses: [factory.taskStatus.Aborted], dateAborted: { $gte: params.dateAbortedGte } }, (settings_1.ABORTED_TASKS_WITHOUT_REPORT.length > 0)
117
+ ? { name: { $nin: settings_1.ABORTED_TASKS_WITHOUT_REPORT } }
118
+ : undefined));
122
119
  // 中止を報告しないタスク以外にフィルター
123
- abortedTasks = abortedTasks.filter((task) => {
124
- return !settings_1.ABORTED_TASKS_WITHOUT_REPORT.includes(task.name);
125
- });
120
+ // abortedTasks = abortedTasks.filter((task) => {
121
+ // return !ABORTED_TASKS_WITHOUT_REPORT.includes(task.name);
122
+ // });
126
123
  if (abortedTasks.length > 0) {
127
124
  // 開発者へ報告
128
125
  const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
@@ -386,6 +386,12 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
386
386
  agent: { id: project.id, typeOf: factory.organizationType.Project },
387
387
  token: fromLocation
388
388
  })({ action: repos.action });
389
+ if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
390
+ throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
391
+ }
392
+ if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
393
+ throw new factory.errors.Argument('fromLocation', 'must be Permit');
394
+ }
389
395
  fromLocation = {
390
396
  typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
391
397
  identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
@@ -576,7 +582,9 @@ function exportTasksById(params) {
576
582
  transaction,
577
583
  runsAt: taskRunsAt
578
584
  });
579
- yield Promise.all(taskAttributes.map((a) => __awaiter(this, void 0, void 0, function* () { return repos.task.save(a); })));
585
+ // saveManyに変更(2023-02-01~)
586
+ yield repos.task.saveMany(taskAttributes);
587
+ // await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
580
588
  });
581
589
  }
582
590
  exports.exportTasksById = exportTasksById;
@@ -23,4 +23,4 @@ export declare function findPaymentCardPermit(params: {
23
23
  }): (repos: {
24
24
  ownershipInfo: OwnershipInfoRepo;
25
25
  product: ProductRepo;
26
- }) => Promise<factory.ownershipInfo.IPermit>;
26
+ }) => Promise<factory.ownershipInfo.IPermitAsGood>;
@@ -218,7 +218,8 @@ function processAuthorizeProductOffer(params) {
218
218
  project: { id: params.project.id },
219
219
  itemOffered: { id: params.product.id },
220
220
  seller: { id: String(seller.id) },
221
- onlyValid: true
221
+ onlyValid: true,
222
+ sort: false // ソート不要(2023-01-27~)
222
223
  })(repos);
223
224
  const acceptedProductOffer = offers.find((o) => o.identifier === acceptedOffer.identifier);
224
225
  if (acceptedProductOffer === undefined) {
@@ -36,9 +36,11 @@ function exportTasksById(params) {
36
36
  transaction,
37
37
  runsAt: taskRunsAt
38
38
  });
39
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
40
- yield repos.task.save(taskAttribute);
41
- })));
39
+ // saveManyに変更(2023-02-01~)
40
+ yield repos.task.saveMany(taskAttributes);
41
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
42
+ // await repos.task.save(taskAttribute);
43
+ // }));
42
44
  });
43
45
  }
44
46
  exports.exportTasksById = exportTasksById;
@@ -35,37 +35,52 @@ function createReservationAcceptedOffers(params) {
35
35
  }
36
36
  exports.createReservationAcceptedOffers = createReservationAcceptedOffers;
37
37
  function reservationOffers2orderedItem(params) {
38
- var _a, _b, _c, _d;
38
+ var _a, _b, _c, _d, _e;
39
39
  const reservationFor = params.reservationFor;
40
40
  const issuedThrough = params.issuedThrough;
41
- if (reservationFor.typeOf !== factory.eventType.ScreeningEvent) {
42
- throw new factory.errors.NotImplemented(`reservationFor.typeOf '${reservationFor.typeOf}' not implemented`);
43
- }
44
- const reservationFor4orderedItem = {
45
- location: {
46
- branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
47
- name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
41
+ if (reservationFor.typeOf === factory.eventType.ScreeningEvent
42
+ && issuedThrough.typeOf === factory.product.ProductType.EventService) {
43
+ const reservationFor4orderedItem = {
44
+ location: {
45
+ branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
46
+ name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
47
+ // 不要なので廃止(2022-12-19~)
48
+ // project: reservationFor.location?.project,
49
+ typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
50
+ },
48
51
  // 不要なので廃止(2022-12-19~)
49
- // project: reservationFor.location?.project,
50
- typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
51
- },
52
- // 不要なので廃止(2022-12-19~)
53
- // project: reservationFor.project,
54
- typeOf: reservationFor.typeOf,
55
- id: reservationFor.id,
56
- name: reservationFor.name,
57
- startDate: reservationFor.startDate,
58
- endDate: reservationFor.endDate
59
- };
60
- if (issuedThrough.typeOf !== factory.product.ProductType.EventService) {
61
- throw new factory.errors.NotImplemented(`issuedThrough.typeOf '${issuedThrough.typeOf}' not implemented`);
52
+ // project: reservationFor.project,
53
+ typeOf: reservationFor.typeOf,
54
+ id: reservationFor.id,
55
+ name: reservationFor.name,
56
+ startDate: reservationFor.startDate,
57
+ endDate: reservationFor.endDate
58
+ };
59
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
60
+ ? { serviceType: issuedThrough.serviceType }
61
+ : undefined), { serviceOutput: {
62
+ typeOf: factory.reservationType.EventReservation,
63
+ reservationFor: reservationFor4orderedItem
64
+ } });
65
+ }
66
+ else if (reservationFor.typeOf === factory.tripType.BusTrip
67
+ && issuedThrough.typeOf === factory.product.ProductType.Transportation) {
68
+ const reservationFor4orderedItem = {
69
+ typeOf: reservationFor.typeOf,
70
+ id: reservationFor.id,
71
+ departureTime: reservationFor.departureTime,
72
+ arrivalTime: reservationFor.arrivalTime
73
+ };
74
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_e = issuedThrough.serviceType) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string')
75
+ ? { serviceType: issuedThrough.serviceType }
76
+ : undefined), { serviceOutput: {
77
+ typeOf: factory.reservationType.ReservationPackage,
78
+ reservationFor: reservationFor4orderedItem
79
+ } });
80
+ }
81
+ else {
82
+ throw new factory.errors.ServiceUnavailable('unexpected params on reservationOffers2orderedItem');
62
83
  }
63
- return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
64
- ? { serviceType: issuedThrough.serviceType }
65
- : undefined), { serviceOutput: {
66
- typeOf: factory.reservationType.EventReservation,
67
- reservationFor: reservationFor4orderedItem
68
- } });
69
84
  }
70
85
  function createProductItems(params) {
71
86
  const acceptedOffers = [];
@@ -68,13 +68,13 @@ exports.start = start;
68
68
  */
69
69
  function confirm(params) {
70
70
  return (repos) => __awaiter(this, void 0, void 0, function* () {
71
- var _a, _b;
71
+ var _a;
72
72
  // 確認番号を事前発行
73
73
  yield publishConfirmationNumberIfNotExist({
74
74
  id: params.id,
75
75
  object: { orderDate: params.result.order.orderDate }
76
76
  })(repos);
77
- let transaction = yield repos.transaction.findById({
77
+ const transaction = yield repos.transaction.findById({
78
78
  typeOf: factory.transactionType.PlaceOrder,
79
79
  id: params.id
80
80
  });
@@ -121,7 +121,7 @@ function confirm(params) {
121
121
  });
122
122
  // ステータス変更
123
123
  try {
124
- transaction = yield repos.transaction.confirm({
124
+ yield repos.transaction.confirm({
125
125
  typeOf: transaction.typeOf,
126
126
  id: transaction.id,
127
127
  authorizeActions: transaction.object.authorizeActions,
@@ -140,10 +140,10 @@ function confirm(params) {
140
140
  throw error;
141
141
  }
142
142
  // 万が一処理が想定通りでない場合orderNumberが存在しない
143
- if (typeof ((_b = transaction.result) === null || _b === void 0 ? void 0 : _b.order.typeOf) !== 'string') {
144
- throw new factory.errors.ServiceUnavailable('transaction.result not found');
145
- }
146
- return transaction.result;
143
+ // if (typeof transaction.result?.order.typeOf !== 'string') {
144
+ // throw new factory.errors.ServiceUnavailable('transaction.result not found');
145
+ // }
146
+ return result;
147
147
  });
148
148
  }
149
149
  exports.confirm = confirm;