@chevre/domain 24.0.0-alpha.1 → 24.0.0-alpha.11

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 (184) hide show
  1. package/lib/chevre/repo/acceptedPaymentMethod.js +1 -1
  2. package/lib/chevre/repo/additionalProperty.js +1 -1
  3. package/lib/chevre/repo/aggregateOffer.js +1 -1
  4. package/lib/chevre/repo/confirmationNumber.js +2 -4
  5. package/lib/chevre/repo/creativeWork.js +1 -1
  6. package/lib/chevre/repo/eventOffer.js +1 -1
  7. package/lib/chevre/repo/eventSeries.js +1 -1
  8. package/lib/chevre/repo/identity.js +1 -2
  9. package/lib/chevre/repo/issuer.js +2 -4
  10. package/lib/chevre/repo/message.js +1 -1
  11. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  12. package/lib/chevre/repo/note.js +1 -1
  13. package/lib/chevre/repo/noteAboutOrder.js +1 -1
  14. package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
  15. package/lib/chevre/repo/offerItemCondition.js +1 -1
  16. package/lib/chevre/repo/order.js +1 -1
  17. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  18. package/lib/chevre/repo/orderInTransaction.js +17 -4
  19. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  20. package/lib/chevre/repo/orderNumber.js +25 -32
  21. package/lib/chevre/repo/place/movieTheater.js +1 -1
  22. package/lib/chevre/repo/place/seat.js +1 -1
  23. package/lib/chevre/repo/product.js +1 -1
  24. package/lib/chevre/repo/productOffer.js +1 -1
  25. package/lib/chevre/repo/project.js +1 -1
  26. package/lib/chevre/repo/reservation.js +1 -1
  27. package/lib/chevre/repo/role.js +1 -2
  28. package/lib/chevre/repo/seller.js +1 -1
  29. package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
  30. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  31. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  32. package/lib/chevre/repo/transaction/returnOrder.d.ts +23 -0
  33. package/lib/chevre/repo/transaction/returnOrder.js +213 -0
  34. package/lib/chevre/repo/transaction.d.ts +11 -84
  35. package/lib/chevre/repo/transaction.js +331 -270
  36. package/lib/chevre/repo/transactionNumber.js +2 -4
  37. package/lib/chevre/repo/trip.js +1 -2
  38. package/lib/chevre/repository.d.ts +12 -0
  39. package/lib/chevre/repository.js +26 -1
  40. package/lib/chevre/service/account.js +14 -21
  41. package/lib/chevre/service/accountTransaction/deposit.js +2 -8
  42. package/lib/chevre/service/accountTransaction/transfer.js +2 -8
  43. package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
  45. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
  46. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
  47. package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
  48. package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
  49. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  51. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  52. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  53. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  54. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +53 -0
  55. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  56. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  57. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  58. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  59. package/lib/chevre/service/assetTransaction/refund.js +13 -20
  60. package/lib/chevre/service/assetTransaction/registerService.js +1 -7
  61. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
  62. package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
  63. package/lib/chevre/service/delivery/product/factory.js +1 -2
  64. package/lib/chevre/service/delivery/reservation/factory.js +1 -2
  65. package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
  66. package/lib/chevre/service/event.js +0 -1
  67. package/lib/chevre/service/moneyTransfer.js +2 -2
  68. package/lib/chevre/service/notification/factory.js +1 -1
  69. package/lib/chevre/service/notification/notifyByEmail.js +50 -56
  70. package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
  71. package/lib/chevre/service/notification/triggerWebhook.js +32 -37
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  74. package/lib/chevre/service/offer/event/authorize.js +4 -4
  75. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  76. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  77. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  78. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  79. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  80. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  81. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -2
  82. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  83. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
  84. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -2
  85. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +6 -6
  86. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -2
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  88. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +2 -2
  89. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  90. package/lib/chevre/service/offer/moneyTransfer/authorize.js +53 -57
  91. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  92. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  93. package/lib/chevre/service/offer/product.d.ts +3 -3
  94. package/lib/chevre/service/offer/product.js +4 -4
  95. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  96. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  97. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  98. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  99. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +4 -4
  100. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +10 -19
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
  103. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
  104. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +2 -2
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
  109. package/lib/chevre/service/order/onOrderUpdated.js +1 -2
  110. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  111. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  112. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -3
  113. package/lib/chevre/service/order/placeOrder.d.ts +2 -2
  114. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  115. package/lib/chevre/service/order/returnOrder.js +2 -2
  116. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  117. package/lib/chevre/service/order/sendOrder.js +1 -1
  118. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  119. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  120. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  121. package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -2
  122. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -8
  123. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  124. package/lib/chevre/service/payment/any.d.ts +6 -6
  125. package/lib/chevre/service/payment/any.js +10 -11
  126. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
  127. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  128. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
  129. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
  130. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
  131. package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
  132. package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
  133. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
  134. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
  135. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
  136. package/lib/chevre/service/payment/paymentCard.js +2 -4
  137. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  138. package/lib/chevre/service/report/telemetry.js +7 -12
  139. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
  140. package/lib/chevre/service/task/acceptCOAOffer.js +6 -4
  141. package/lib/chevre/service/task/authorizePayment.js +4 -2
  142. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  143. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
  144. package/lib/chevre/service/task/deleteTransaction.js +5 -1
  145. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  146. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
  148. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  149. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  150. package/lib/chevre/service/task/pay.js +1 -2
  151. package/lib/chevre/service/task/placeOrder.js +6 -4
  152. package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
  153. package/lib/chevre/service/task/returnOrder.js +4 -4
  154. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  155. package/lib/chevre/service/task/sendOrder.js +2 -2
  156. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  157. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  158. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  159. package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
  160. package/lib/chevre/service/transaction/deleteTransaction.d.ts +4 -0
  161. package/lib/chevre/service/transaction/deleteTransaction.js +57 -15
  162. package/lib/chevre/service/transaction/moneyTransfer.js +15 -23
  163. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  164. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  165. package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -13
  166. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -2
  167. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  168. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  169. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  170. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  171. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  172. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
  173. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  174. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  175. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  176. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  177. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  178. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  179. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
  180. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
  181. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  182. package/lib/chevre/service/transaction.d.ts +5 -21
  183. package/lib/chevre/service/transaction.js +5 -111
  184. package/package.json +6 -18
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ReturnOrderRepo = void 0;
27
+ // import { transactionEventEmitter } from '../../eventEmitter/transaction';
28
+ const factory = __importStar(require("../../factory"));
29
+ const settings_1 = require("../../settings");
30
+ const transaction_1 = require("../mongoose/schemas/transaction");
31
+ const AVAILABLE_PROJECT_FIELDS = [
32
+ 'project',
33
+ 'status',
34
+ 'typeOf',
35
+ 'agent',
36
+ 'recipient',
37
+ 'seller',
38
+ 'error',
39
+ 'result',
40
+ 'object',
41
+ 'expires',
42
+ 'startDate',
43
+ 'endDate',
44
+ 'tasksExportAction',
45
+ 'potentialActions',
46
+ // 'instrument'
47
+ ];
48
+ // type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
49
+ // export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
50
+ // type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
51
+ // export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
52
+ /**
53
+ * 返品取引リポジトリ
54
+ */
55
+ class ReturnOrderRepo {
56
+ transactionModel;
57
+ constructor(connection) {
58
+ this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
59
+ }
60
+ static CREATE_MONGO_CONDITIONS(params) {
61
+ if (params.typeOf !== factory.transactionType.ReturnOrder) {
62
+ throw new factory.errors.Argument('typeOf', `must be ${factory.transactionType.ReturnOrder}`);
63
+ }
64
+ const andConditions = [];
65
+ const projectIdEq = params.project?.id?.$eq;
66
+ if (typeof projectIdEq === 'string') {
67
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
68
+ }
69
+ if (typeof params.typeOf === 'string') {
70
+ andConditions.push({ typeOf: { $eq: params.typeOf } });
71
+ }
72
+ if (params.startFrom !== undefined) {
73
+ andConditions.push({
74
+ startDate: { $gte: params.startFrom }
75
+ });
76
+ }
77
+ if (params.startThrough !== undefined) {
78
+ andConditions.push({
79
+ startDate: { $lte: params.startThrough }
80
+ });
81
+ }
82
+ if (params.endFrom !== undefined) {
83
+ andConditions.push({
84
+ endDate: {
85
+ $exists: true,
86
+ $gte: params.endFrom
87
+ }
88
+ });
89
+ }
90
+ if (params.endThrough !== undefined) {
91
+ andConditions.push({
92
+ endDate: {
93
+ $exists: true,
94
+ $lt: params.endThrough
95
+ }
96
+ });
97
+ }
98
+ if (Array.isArray(params.ids)) {
99
+ andConditions.push({
100
+ _id: { $in: params.ids }
101
+ });
102
+ }
103
+ if (Array.isArray(params.statuses)) {
104
+ andConditions.push({ status: { $in: params.statuses } });
105
+ }
106
+ const statusIn = params.status?.$in;
107
+ if (Array.isArray(statusIn)) {
108
+ andConditions.push({ status: { $in: statusIn } });
109
+ }
110
+ if (params.agent !== undefined) {
111
+ if (params.agent.typeOf !== undefined) {
112
+ andConditions.push({
113
+ 'agent.typeOf': {
114
+ $exists: true,
115
+ $eq: params.agent.typeOf
116
+ }
117
+ });
118
+ }
119
+ if (Array.isArray(params.agent.ids)) {
120
+ andConditions.push({
121
+ 'agent.id': {
122
+ $exists: true,
123
+ $in: params.agent.ids
124
+ }
125
+ });
126
+ }
127
+ if (Array.isArray(params.agent.identifiers)) {
128
+ andConditions.push({
129
+ 'agent.identifier': {
130
+ $exists: true,
131
+ $in: params.agent.identifiers
132
+ }
133
+ });
134
+ }
135
+ }
136
+ const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
137
+ if (Array.isArray(tasksExportActionStatusIn)) {
138
+ andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
139
+ }
140
+ const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
141
+ if (typeof tasksExportActionStatusEq === 'string') {
142
+ andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
143
+ }
144
+ if (params.object !== undefined) {
145
+ if (params.object.order !== undefined) {
146
+ if (Array.isArray(params.object.order.orderNumbers)) {
147
+ andConditions.push({
148
+ 'object.order.orderNumber': {
149
+ $exists: true,
150
+ $in: params.object.order.orderNumbers
151
+ }
152
+ });
153
+ }
154
+ }
155
+ }
156
+ return andConditions;
157
+ }
158
+ async countReturnOrder(params) {
159
+ const { limit } = params;
160
+ const conditions = ReturnOrderRepo.CREATE_MONGO_CONDITIONS(params);
161
+ const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
162
+ if (typeof limit === 'number' && limit >= 0) {
163
+ query.limit(limit);
164
+ }
165
+ const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
166
+ .exec();
167
+ return { count };
168
+ }
169
+ /**
170
+ * 取引を検索する
171
+ */
172
+ async findReturnOrderTransactions(params) {
173
+ const { inclusion } = params;
174
+ const conditions = ReturnOrderRepo.CREATE_MONGO_CONDITIONS(params);
175
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
176
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
177
+ positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(key));
178
+ }
179
+ const projection = {
180
+ _id: 0,
181
+ id: { $toString: '$_id' },
182
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
183
+ };
184
+ // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
185
+ // if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
186
+ // params.inclusion.forEach((field) => {
187
+ // projection[field] = 1;
188
+ // });
189
+ // } else {
190
+ // projection = {
191
+ // __v: 0,
192
+ // createdAt: 0,
193
+ // updatedAt: 0
194
+ // };
195
+ // }
196
+ const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
197
+ .select(projection);
198
+ if (typeof params.limit === 'number' && params.limit > 0) {
199
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
200
+ query.limit(params.limit)
201
+ .skip(params.limit * (page - 1));
202
+ }
203
+ if (params.sort?.startDate !== undefined) {
204
+ query.sort({ startDate: params.sort.startDate });
205
+ }
206
+ // const explainResult = await (<any>query).explain();
207
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
208
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
209
+ .lean()
210
+ .exec();
211
+ }
212
+ }
213
+ exports.ReturnOrderRepo = ReturnOrderRepo;
@@ -19,7 +19,7 @@ export interface IAggregatePlaceOrder {
19
19
  statuses: IStatus[];
20
20
  }
21
21
  type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
22
- export type ITransactionInProgress<T extends factory.transactionType> = T extends factory.transactionType.MoneyTransfer ? Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.PlaceOrder ? Omit<factory.transaction.placeOrder.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.ReturnOrder ? Omit<factory.transaction.returnOrder.ITransaction, IOmittedFieldsInProgress> : never;
22
+ export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
23
23
  type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
24
24
  export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
25
25
  /**
@@ -28,80 +28,29 @@ export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.
28
28
  export declare class TransactionRepo {
29
29
  private readonly transactionModel;
30
30
  constructor(connection: Connection);
31
- static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType>): FilterQuery<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction>[];
31
+ static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType.MoneyTransfer>): FilterQuery<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction>[];
32
32
  /**
33
33
  * 取引を開始する
34
34
  */
35
- start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T>): Promise<IStartedTransaction>;
35
+ startNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: factory.transaction.IStartParams<T>): Promise<IStartedTransaction>;
36
36
  /**
37
37
  * 特定取引検索
38
38
  */
39
- projectFieldsById<T extends factory.transactionType>(params: {
39
+ projectFieldsByIdNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
40
40
  typeOf: T;
41
41
  id: string;
42
42
  }, inclusion: IKeyOfProjection<T>[]): Promise<factory.transaction.ITransaction<T>>;
43
43
  /**
44
44
  * 進行中の取引を取得する
45
45
  */
46
- projectFieldsInProgressById<T extends factory.transactionType>(params: {
47
- typeOf: T;
48
- id: string;
49
- }, inclusion: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
50
- /**
51
- * 進行中取引に保管された採用済決済方法を検索する
52
- */
53
- findInProgressPaymentMethodId(params: {
54
- id: string;
55
- }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
56
- /**
57
- * 取引の注文番号を検索する
58
- */
59
- findInProgressOrderNumberById(params: {
60
- id: string;
61
- }): Promise<string | undefined>;
62
- /**
63
- * 取引の確認番号を検索する
64
- */
65
- findInProgressConfirmationNumberById(params: {
66
- id: string;
67
- status: {
68
- $in: factory.transactionStatusType[];
69
- };
70
- }): Promise<string | undefined>;
71
- /**
72
- * 取引進行者プロフィールを更新
73
- */
74
- updateAgent<T extends factory.transactionType>(params: {
75
- typeOf: T;
46
+ findMoneyTransferInProgressById(params: {
47
+ typeOf: factory.transactionType.MoneyTransfer;
76
48
  id: string;
77
- agent: Pick<factory.transaction.IAgent, 'id'>;
78
- object?: {
79
- customer?: factory.order.ICustomer;
80
- };
81
- }): Promise<void>;
82
- /**
83
- * 取引期限変更
84
- */
85
- updateExpires<T extends factory.transactionType>(params: {
86
- typeOf: T;
87
- id: string;
88
- expires: Date;
89
- }): Promise<void>;
90
- /**
91
- * 取引オブジェクトを更新
92
- * 注文名称など
93
- */
94
- updateObject<T extends factory.transactionType>(params: {
95
- typeOf: T;
96
- id: string;
97
- object?: {
98
- name?: string;
99
- };
100
- }): Promise<void>;
49
+ }, inclusion: IKeyOfProjection<factory.transactionType.MoneyTransfer>[]): Promise<IMoneyTransferTransactionInProgress>;
101
50
  /**
102
51
  * 取引を確定する
103
52
  */
104
- confirm<T extends factory.transactionType>(params: {
53
+ confirmNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
105
54
  typeOf: T;
106
55
  id: string;
107
56
  result: factory.transaction.IResult<T>;
@@ -195,43 +144,21 @@ export declare class TransactionRepo {
195
144
  /**
196
145
  * 取引を中止する
197
146
  */
198
- cancel<T extends factory.transactionType>(params: {
147
+ cancelNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
199
148
  typeOf: T;
200
149
  id: string;
201
150
  }): Promise<void>;
202
- count<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T>): Promise<{
151
+ countMoneyTransfer<T extends factory.transactionType.MoneyTransfer>(params: factory.transaction.ISearchConditions<T>): Promise<{
203
152
  count: number;
204
153
  }>;
205
154
  /**
206
155
  * 取引を検索する
207
156
  */
208
- projectFields<T extends factory.transactionType, F extends IKeyOfProjection<T>>(params: factory.transaction.ISearchConditions<T> & {
157
+ findMoneyTransferTransactions<T extends factory.transactionType.MoneyTransfer, F extends IKeyOfProjection<T>>(params: factory.transaction.ISearchConditions<T> & {
209
158
  inclusion: F[];
210
159
  }): Promise<(Pick<factory.transaction.ITransaction<T>, F> & {
211
160
  id: string;
212
161
  })[]>;
213
- /**
214
- * 特定の進行中取引を更新する(汎用)
215
- */
216
- findByIdAndUpdateInProgress(params: {
217
- id: string;
218
- update: {
219
- $set?: {
220
- 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
221
- };
222
- };
223
- }): Promise<void>;
224
- saveOrderNumberIfNotExist(params: {
225
- id: string;
226
- orderNumber: string;
227
- }): Promise<void>;
228
- saveConfirmationNumberIfNotExist(params: {
229
- id: string;
230
- status: {
231
- $in: factory.transactionStatusType[];
232
- };
233
- confirmationNumber: string;
234
- }): Promise<void>;
235
162
  findByIdAndDelete(params: {
236
163
  id: string;
237
164
  }): Promise<void>;