@chevre/domain 21.20.0-alpha.9 → 21.20.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 (226) hide show
  1. package/example/src/chevre/findTransactionById.ts +21 -0
  2. package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
  3. package/example/src/chevre/importOffersFromCOA.ts +2 -1
  4. package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
  5. package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
  6. package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
  7. package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
  8. package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
  9. package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
  10. package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
  11. package/example/src/chevre/retryTasks.ts +39 -0
  12. package/example/src/chevre/searchActions.ts +13 -7
  13. package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
  14. package/example/src/chevre/searchOrders.ts +13 -15
  15. package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
  16. package/example/src/chevre/sendOrder.ts +37 -0
  17. package/example/src/chevre/transaction/processPlaceOrder.ts +2 -1
  18. package/example/src/verifyToken.ts +44 -0
  19. package/lib/chevre/credentials.d.ts +2 -0
  20. package/lib/chevre/credentials.js +4 -2
  21. package/lib/chevre/errorHandler.js +3 -0
  22. package/lib/chevre/factory/order.d.ts +1 -0
  23. package/lib/chevre/factory/order.js +2 -1
  24. package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
  25. package/lib/chevre/factory/transaction.d.ts +10 -1
  26. package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
  27. package/lib/chevre/repo/acceptedOffer.js +100 -4
  28. package/lib/chevre/repo/accountingReport.d.ts +33 -7
  29. package/lib/chevre/repo/accountingReport.js +157 -5
  30. package/lib/chevre/repo/action.d.ts +32 -8
  31. package/lib/chevre/repo/action.js +114 -54
  32. package/lib/chevre/repo/event.d.ts +20 -0
  33. package/lib/chevre/repo/event.js +22 -0
  34. package/lib/chevre/repo/member.d.ts +8 -1
  35. package/lib/chevre/repo/member.js +7 -1
  36. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
  37. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
  39. package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
  40. package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
  41. package/lib/chevre/repo/offer.d.ts +42 -0
  42. package/lib/chevre/repo/offer.js +35 -0
  43. package/lib/chevre/repo/order.js +43 -20
  44. package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
  45. package/lib/chevre/repo/orderInTransaction.js +164 -0
  46. package/lib/chevre/repo/paymentServiceProvider.js +2 -1
  47. package/lib/chevre/repo/person.js +1 -4
  48. package/lib/chevre/repo/task.d.ts +26 -3
  49. package/lib/chevre/repo/task.js +61 -46
  50. package/lib/chevre/repo/transaction.d.ts +2 -2
  51. package/lib/chevre/repo/transaction.js +13 -36
  52. package/lib/chevre/repository.d.ts +5 -0
  53. package/lib/chevre/repository.js +15 -2
  54. package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
  55. package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
  57. package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
  58. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
  59. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
  60. package/lib/chevre/service/assetTransaction/pay.d.ts +21 -1
  61. package/lib/chevre/service/assetTransaction/pay.js +64 -23
  62. package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
  63. package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
  64. package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
  65. package/lib/chevre/service/code.js +1 -1
  66. package/lib/chevre/service/delivery.js +2 -2
  67. package/lib/chevre/service/event/createEvent.js +1 -1
  68. package/lib/chevre/service/event.js +16 -24
  69. package/lib/chevre/service/moneyTransfer.js +1 -1
  70. package/lib/chevre/service/notification.js +71 -66
  71. package/lib/chevre/service/offer/any.d.ts +35 -0
  72. package/lib/chevre/service/offer/any.js +67 -0
  73. package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
  74. package/lib/chevre/service/offer/event/authorize.js +27 -17
  75. package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
  76. package/lib/chevre/service/offer/event/cancel.js +13 -1
  77. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  78. package/lib/chevre/service/offer/event/factory.js +11 -22
  79. package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
  80. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  81. package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
  82. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
  83. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
  84. package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
  85. package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
  86. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
  87. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
  88. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
  89. package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
  90. package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
  91. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
  92. package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
  93. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
  94. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
  95. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
  96. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  97. package/lib/chevre/service/offer/product/factory.js +2 -5
  98. package/lib/chevre/service/offer/product.d.ts +2 -0
  99. package/lib/chevre/service/offer/product.js +11 -23
  100. package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
  101. package/lib/chevre/service/order/confirmPayTransaction.js +4 -4
  102. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
  103. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
  104. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
  109. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
  110. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
  111. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
  112. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
  113. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
  114. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
  115. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
  116. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
  117. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
  118. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
  119. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
  120. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
  121. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
  122. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
  123. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  124. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
  125. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
  126. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
  127. package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
  128. package/lib/chevre/service/order/placeOrder.d.ts +3 -1
  129. package/lib/chevre/service/order/placeOrder.js +157 -50
  130. package/lib/chevre/service/order/returnOrder.js +25 -16
  131. package/lib/chevre/service/order/sendOrder.d.ts +5 -0
  132. package/lib/chevre/service/order/sendOrder.js +67 -33
  133. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  134. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
  135. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
  136. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
  137. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
  138. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
  139. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  140. package/lib/chevre/service/payment/any.d.ts +6 -2
  141. package/lib/chevre/service/payment/any.js +3 -2
  142. package/lib/chevre/service/payment/creditCard.d.ts +1 -1
  143. package/lib/chevre/service/payment/creditCard.js +62 -68
  144. package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
  145. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  146. package/lib/chevre/service/payment/movieTicket.js +1 -1
  147. package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
  148. package/lib/chevre/service/payment.d.ts +5 -0
  149. package/lib/chevre/service/payment.js +40 -5
  150. package/lib/chevre/service/product.js +1 -1
  151. package/lib/chevre/service/reserve/cancelReservation.js +2 -2
  152. package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
  153. package/lib/chevre/service/reserve/checkInReservation.js +6 -5
  154. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  155. package/lib/chevre/service/reserve/factory.js +0 -8
  156. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
  157. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
  158. package/lib/chevre/service/reserve/searchByOrder.js +2 -1
  159. package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
  160. package/lib/chevre/service/reserve/useReservation.js +10 -9
  161. package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
  162. package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
  163. package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
  164. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
  165. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
  166. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
  167. package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
  168. package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
  169. package/lib/chevre/service/task/createAccountingReport.js +80 -0
  170. package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
  171. package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
  172. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
  173. package/lib/chevre/service/task/pay.js +6 -0
  174. package/lib/chevre/service/task/placeOrder.js +9 -10
  175. package/lib/chevre/service/task/returnOrder.js +0 -3
  176. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  177. package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
  178. package/lib/chevre/service/task/sendOrder.js +8 -4
  179. package/lib/chevre/service/task/useReservation.js +1 -1
  180. package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
  181. package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
  182. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
  183. package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
  184. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
  185. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
  186. package/lib/chevre/service/transaction/placeOrder.js +2 -1
  187. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
  188. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
  189. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  190. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
  191. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  192. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
  193. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
  194. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
  195. package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
  196. package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
  197. package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
  198. package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
  199. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
  200. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
  201. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
  202. package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
  203. package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
  204. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
  205. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
  206. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
  207. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
  208. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
  209. package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
  210. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
  211. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
  212. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
  213. package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
  214. package/lib/chevre/service/transaction/returnOrder.js +3 -10
  215. package/lib/chevre/service.js +0 -10
  216. package/lib/chevre/settings.d.ts +7 -3
  217. package/lib/chevre/settings.js +13 -4
  218. package/package.json +5 -9
  219. package/example/src/chevre/cleanAccountingReports.ts +0 -57
  220. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
  221. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
  222. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
  223. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
  224. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
  225. package/lib/chevre/service/util.d.ts +0 -19
  226. package/lib/chevre/service/util.js +0 -126
@@ -0,0 +1,268 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.confirm = void 0;
24
+ const moment = require("moment");
25
+ const errorHandler_1 = require("../../../errorHandler");
26
+ const factory = require("../../../factory");
27
+ const settings_1 = require("../../../settings");
28
+ const potentialActions_1 = require("./potentialActions");
29
+ const publishCode_1 = require("./publishCode");
30
+ const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
31
+ const publishOrderNumberIfNotExist_1 = require("./publishOrderNumberIfNotExist");
32
+ const result_1 = require("./result");
33
+ const validation_1 = require("./validation");
34
+ /**
35
+ * 注文取引を確定する
36
+ */
37
+ function confirm(params) {
38
+ // tslint:disable-next-line:max-func-body-length
39
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
40
+ var _a;
41
+ // 確認番号を事前発行
42
+ yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
43
+ id: params.id,
44
+ object: { orderDate: params.result.order.orderDate }
45
+ })(repos);
46
+ const transaction = yield repos.transaction.findById({
47
+ typeOf: factory.transactionType.PlaceOrder,
48
+ id: params.id
49
+ });
50
+ if (transaction.status === factory.transactionStatusType.Confirmed) {
51
+ // すでに確定済の場合
52
+ return transaction.result;
53
+ }
54
+ else if (transaction.status === factory.transactionStatusType.Expired) {
55
+ throw new factory.errors.Argument('transactionId', 'Transaction already expired');
56
+ }
57
+ else if (transaction.status === factory.transactionStatusType.Canceled) {
58
+ throw new factory.errors.Argument('transactionId', 'Transaction already canceled');
59
+ }
60
+ if (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.id) === 'string' && transaction.agent.id !== params.agent.id) {
61
+ throw new factory.errors.Forbidden('Transaction not yours');
62
+ }
63
+ // 取引に対する全ての承認アクションをマージ
64
+ const completedAuthorizeActions = yield searchAuthorizeActions(params)(repos);
65
+ // 注文番号を発行
66
+ const orderNumber = yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
67
+ project: { id: transaction.project.id },
68
+ id: transaction.id,
69
+ object: { orderDate: params.result.order.orderDate }
70
+ })(repos);
71
+ // 必要あらば注文コード発行(2024-02-05~)
72
+ let code;
73
+ const publishCodeExpiresInSeconds = params.options.publishCodeExpiresInSeconds;
74
+ if (typeof publishCodeExpiresInSeconds === 'number') {
75
+ code = yield (0, publishCode_1.publishCode)({
76
+ project: { id: transaction.project.id },
77
+ object: { orderNumber },
78
+ validFrom: params.result.order.orderDate,
79
+ expiresInSeconds: publishCodeExpiresInSeconds
80
+ })(repos);
81
+ }
82
+ const { orderWithAcceptedOffers, result, eventId, reservationIds } = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions, code }));
83
+ // デフォルトEメールメッセージを検索
84
+ let emailMessageOnOrderSent;
85
+ if (repos.emailMessage !== undefined) {
86
+ const searchEmailMessagesResult = yield repos.emailMessage.search({
87
+ limit: 1,
88
+ page: 1,
89
+ project: { id: { $eq: transaction.project.id } },
90
+ about: { identifier: { $eq: factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
91
+ });
92
+ emailMessageOnOrderSent = searchEmailMessagesResult.shift();
93
+ }
94
+ // ポストアクションを作成
95
+ const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
96
+ // order: result.order,
97
+ order: orderWithAcceptedOffers,
98
+ potentialActions: params.potentialActions,
99
+ transaction: transaction,
100
+ emailMessage: emailMessageOnOrderSent,
101
+ authorizeActions: completedAuthorizeActions
102
+ });
103
+ // ステータス変更
104
+ try {
105
+ yield repos.transaction.confirm({
106
+ typeOf: transaction.typeOf,
107
+ id: transaction.id,
108
+ result: result,
109
+ potentialActions: potentialActions
110
+ });
111
+ }
112
+ catch (error) {
113
+ if (yield (0, errorHandler_1.isMongoError)(error)) {
114
+ // 万が一同一注文番号で確定しようとすると、MongoDBでE11000 duplicate key errorが発生する
115
+ // message: 'E11000 duplicate key error collection: prodttts.transactions index:result.order.orderNumber_1 dup key:...',
116
+ if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
117
+ throw new factory.errors.AlreadyInUse('transaction', ['result.order.orderNumber']);
118
+ }
119
+ }
120
+ throw error;
121
+ }
122
+ const { order } = result;
123
+ return Object.assign({ order,
124
+ eventId,
125
+ reservationIds }, (typeof code === 'string') ? { code } : undefined);
126
+ });
127
+ }
128
+ exports.confirm = confirm;
129
+ function createReservationIdsResult(order) {
130
+ var _a;
131
+ let eventId = '';
132
+ const reservationIds = [];
133
+ let eventIdsByOrder = (_a = order.orderedItem) === null || _a === void 0 ? void 0 : _a.filter((o) => o.orderedItem.typeOf === factory.product.ProductType.EventService).map((o) => {
134
+ return o.orderedItem.serviceOutput.reservationFor.id;
135
+ });
136
+ if (Array.isArray(eventIdsByOrder)) {
137
+ eventIdsByOrder = [...new Set(eventIdsByOrder)];
138
+ // イベントIDが1つのみに対応
139
+ if (eventIdsByOrder.length === 1) {
140
+ eventId = eventIdsByOrder[0];
141
+ if (Array.isArray(order.acceptedOffers)) {
142
+ order.acceptedOffers.forEach((o) => {
143
+ if (o.itemOffered.typeOf === factory.reservationType.EventReservation
144
+ || o.itemOffered.typeOf === factory.reservationType.BusReservation) {
145
+ reservationIds.push(o.itemOffered.id);
146
+ }
147
+ });
148
+ }
149
+ }
150
+ }
151
+ return { eventId, reservationIds };
152
+ }
153
+ function createResult(params) {
154
+ var _a;
155
+ const transaction = params.transaction;
156
+ // 取引の確定条件が全て整っているかどうか確認
157
+ (0, validation_1.validateTransaction)(transaction, params.authorizeActions);
158
+ // 注文作成
159
+ const order = (0, result_1.createOrder)({
160
+ orderNumber: params.orderNumber,
161
+ transaction: transaction,
162
+ orderDate: params.result.order.orderDate,
163
+ // OrderPaymentDueオプションを追加(2023-08-25~)
164
+ // 注文作成時のステータスとなる
165
+ // orderStatus: (USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
166
+ orderStatus: factory.orderStatus.OrderPaymentDue,
167
+ isGift: false,
168
+ authorizeActions: params.authorizeActions
169
+ });
170
+ (0, validation_1.validateEventOffers)({
171
+ transaction: transaction,
172
+ order: order,
173
+ authorizeActions: params.authorizeActions
174
+ });
175
+ // 注文オファー検証
176
+ (0, validation_1.validateNumItems)({
177
+ order: order,
178
+ result: params.result
179
+ });
180
+ // 注文アイテム検証(2024-01-20~)
181
+ (0, validation_1.validateOrderedItem)({
182
+ order: order,
183
+ result: params.result
184
+ });
185
+ (0, validation_1.validatePaymentMethods)({ order });
186
+ // 確認番号を発行
187
+ const { confirmationNumber, identifier, url } = createConfirmationNumber({
188
+ order: order,
189
+ transaction: transaction,
190
+ result: params.result
191
+ });
192
+ order.confirmationNumber = confirmationNumber;
193
+ order.identifier = identifier;
194
+ order.url = url;
195
+ const authorizeActions = params.authorizeActions.map(({ id }) => ({ id }));
196
+ let orderAsResult;
197
+ if (settings_1.USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT) {
198
+ orderAsResult = order;
199
+ }
200
+ else {
201
+ const { acceptedOffers } = order, orderWithoutAcceptedOffers = __rest(order, ["acceptedOffers"]);
202
+ orderAsResult = orderWithoutAcceptedOffers;
203
+ }
204
+ let eventId;
205
+ let reservationIds;
206
+ if (params.options.expectsReservationIds) {
207
+ // ttts対応として予約IDリストとイベントIDを返却
208
+ const reservationIdsResult = createReservationIdsResult(order);
209
+ eventId = reservationIdsResult.eventId;
210
+ reservationIds = reservationIdsResult.reservationIds;
211
+ }
212
+ return {
213
+ orderWithAcceptedOffers: order,
214
+ result: Object.assign({ order: orderAsResult, authorizeActions, numAcceptedOffers: order.acceptedOffers.length, options: {
215
+ ignoreAccpetedOffersFromResult: ((_a = params.options) === null || _a === void 0 ? void 0 : _a.ignoreAccpetedOffersFromResult) === true
216
+ } }, (typeof params.code === 'string') ? { code: params.code } : undefined),
217
+ eventId,
218
+ reservationIds
219
+ };
220
+ }
221
+ function searchAuthorizeActions(params) {
222
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
223
+ // 取引に対する全ての承認アクションをマージ
224
+ let authorizeActions = yield repos.action.searchByPurpose({
225
+ typeOf: factory.actionType.AuthorizeAction,
226
+ purpose: {
227
+ typeOf: factory.transactionType.PlaceOrder,
228
+ id: params.id
229
+ },
230
+ // Completedに絞る(2023-05-16~)
231
+ actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
232
+ });
233
+ // 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
234
+ authorizeActions = authorizeActions.filter((a) => {
235
+ return (a.endDate instanceof Date) && moment(a.endDate)
236
+ .isBefore(moment(params.result.order.orderDate));
237
+ });
238
+ return authorizeActions;
239
+ });
240
+ }
241
+ function createConfirmationNumber(params) {
242
+ const confirmationNumber = params.transaction.object.confirmationNumber;
243
+ let url = '';
244
+ let identifier = [];
245
+ // 取引に確認番号が保管されていなければ、確認番号を発行
246
+ if (typeof confirmationNumber !== 'string') {
247
+ // 事前に発行済なはずなので、ありえないフロー
248
+ throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
249
+ }
250
+ // URLの指定があれば上書き
251
+ // tslint:disable-next-line:no-single-line-block-comment
252
+ /* istanbul ignore if */
253
+ if (typeof params.result.order.url === 'string') {
254
+ url = params.result.order.url;
255
+ }
256
+ else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
257
+ // tslint:disable-next-line:no-single-line-block-comment
258
+ /* istanbul ignore next */
259
+ url = params.result.order.url(params.order);
260
+ }
261
+ // 識別子の指定があれば上書き
262
+ identifier = [
263
+ ...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
264
+ // 取引に指定があれば追加
265
+ ...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
266
+ ];
267
+ return { confirmationNumber, url, identifier };
268
+ }
@@ -1,2 +1,2 @@
1
1
  import * as factory from '../../../factory';
2
- export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, expiresInSeconds: number, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, broker?: factory.order.IBroker, customerType?: string): factory.transaction.placeOrder.IStartParams;
2
+ export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, expiresInSeconds: number, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, broker?: factory.order.IBroker, customerType?: string, memeberOfPayload?: factory.transaction.placeOrder.IMemberOfPayload): factory.transaction.placeOrder.IStartParams;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createStartParams = void 0;
4
4
  const factory = require("../../../factory");
5
- function createStartParams(params, expiresInSeconds, passport, seller, broker, customerType) {
5
+ function createStartParams(params, expiresInSeconds, passport, seller, broker, customerType, memeberOfPayload) {
6
6
  var _a, _b, _c, _d, _e;
7
7
  const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? { passportToken: params.object.passport.token } : undefined), (typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { passport } : undefined), (typeof ((_b = params.object.clientUser) === null || _b === void 0 ? void 0 : _b.client_id) === 'string') ? { clientUser: params.object.clientUser } : undefined), (typeof ((_c = params.object) === null || _c === void 0 ? void 0 : _c.name) === 'string') ? { name: (_d = params.object) === null || _d === void 0 ? void 0 : _d.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_e = params.object.customer) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string') ? { customer: params.object.customer } : undefined), (typeof customerType === 'string') ? { customerType } : undefined);
8
8
  if (typeof seller.id !== 'string') {
@@ -11,10 +11,11 @@ function createStartParams(params, expiresInSeconds, passport, seller, broker, c
11
11
  if (typeof expiresInSeconds !== 'number') {
12
12
  throw new factory.errors.ArgumentNull('expiresInSeconds');
13
13
  }
14
+ const agent = Object.assign(Object.assign({}, params.agent), (memeberOfPayload !== undefined) ? { memeberOfPayload } : undefined);
14
15
  return {
15
16
  project: { typeOf: seller.project.typeOf, id: seller.project.id },
16
17
  typeOf: factory.transactionType.PlaceOrder,
17
- agent: params.agent,
18
+ agent,
18
19
  seller: {
19
20
  id: seller.id,
20
21
  name: seller.name,
@@ -42,7 +42,7 @@ function createMoneyTransferActions(params) {
42
42
  project: params.transaction.project,
43
43
  typeOf: factory.actionType.ConfirmAction,
44
44
  object: {
45
- pendingTransaction: { id: actionResult.responseBody.id },
45
+ // pendingTransaction: { id: actionResult.responseBody.id },
46
46
  transactionNumber: pendingTransaction.transactionNumber,
47
47
  typeOf: factory.assetTransactionType.MoneyTransfer
48
48
  },
@@ -11,70 +11,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createPotentialActions = void 0;
13
13
  const givePointAward_1 = require("./potentialActions/givePointAward");
14
- const moneyTransfer_1 = require("./potentialActions/moneyTransfer");
15
- const registerService_1 = require("./potentialActions/registerService");
14
+ // import { createMoneyTransferActions } from './potentialActions/moneyTransfer';
15
+ // import { createRegisterServiceActions } from './potentialActions/registerService';
16
16
  const sendEmailMessage_1 = require("./potentialActions/sendEmailMessage");
17
- const factory = require("../../../factory");
18
- const order_1 = require("../../../factory/order");
19
17
  /**
20
18
  * 取引のポストアクションを作成する
21
19
  */
22
20
  function createPotentialActions(params) {
23
21
  return __awaiter(this, void 0, void 0, function* () {
24
- const registerServiceActions = yield (0, registerService_1.createRegisterServiceActions)(params);
22
+ // const registerServiceActions = await createRegisterServiceActions(params);
25
23
  // 通貨転送アクション
26
- const moneyTransferActions = yield (0, moneyTransfer_1.createMoneyTransferActions)(params);
24
+ // const moneyTransferActions = await createMoneyTransferActions(params);
27
25
  // ポイントインセンティブに対する承認アクションの分だけ、ポイントインセンティブ付与アクションを作成する
28
26
  const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
29
27
  // 注文配送メール送信設定
30
28
  const sendEmailMessageActions = yield (0, sendEmailMessage_1.createSendEmailMessageActions)(params);
31
- const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
32
- const simpleOrder = {
33
- typeOf: params.order.typeOf,
34
- seller: {
35
- id: params.order.seller.id,
36
- typeOf: params.order.seller.typeOf,
37
- name: params.order.seller.name
38
- },
39
- // mask
40
- customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
41
- orderNumber: params.order.orderNumber,
42
- price: params.order.price,
43
- priceCurrency: params.order.priceCurrency,
44
- orderDate: params.order.orderDate
45
- };
46
29
  const sendOrderActionAttributes = {
47
- project: params.transaction.project,
48
- typeOf: factory.actionType.SendAction,
49
- // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
50
- object: simpleOrder,
51
- agent: params.transaction.project,
52
- recipient: {
53
- typeOf: params.order.customer.typeOf,
54
- id: params.order.customer.id
55
- },
56
30
  potentialActions: {
57
- moneyTransfer: moneyTransferActions,
58
- registerService: registerServiceActions,
31
+ // moneyTransfer: moneyTransferActions, // 廃止(2024-01-29~)
32
+ // registerService: registerServiceActions, // 廃止(2024-01-30~)
59
33
  sendEmailMessage: sendEmailMessageActions
60
34
  }
61
35
  };
36
+ // optimize(2024-01-22~)
62
37
  return {
38
+ // order: {
39
+ // project: params.transaction.project,
40
+ // typeOf: factory.actionType.OrderAction,
41
+ // object: simpleOrder,
42
+ // agent: params.transaction.project,
43
+ // potentialActions: {
44
+ // givePointAward: givePointAwardActions,
45
+ // sendOrder: sendOrderActionAttributes // optimize(2024-01-16~)
46
+ // },
47
+ // purpose: {
48
+ // typeOf: params.transaction.typeOf,
49
+ // id: params.transaction.id
50
+ // }
51
+ // }
63
52
  order: {
64
- project: params.transaction.project,
65
- typeOf: factory.actionType.OrderAction,
66
- // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
67
- object: simpleOrder,
68
- agent: params.transaction.project,
69
53
  potentialActions: {
70
54
  givePointAward: givePointAwardActions,
71
- // 完全廃止(2023-02-03~)
72
- // pay: confirmPayActions,
73
- sendOrder: sendOrderActionAttributes
74
- },
75
- purpose: {
76
- typeOf: params.transaction.typeOf,
77
- id: params.transaction.id
55
+ sendOrder: sendOrderActionAttributes // optimize(2024-01-16~)
78
56
  }
79
57
  }
80
58
  };
@@ -0,0 +1,14 @@
1
+ import type { MongoRepository as CodeRepo } from '../../../repo/code';
2
+ declare function publishCode(params: {
3
+ project: {
4
+ id: string;
5
+ };
6
+ object: {
7
+ orderNumber: string;
8
+ };
9
+ validFrom: Date;
10
+ expiresInSeconds: number;
11
+ }): (repos: {
12
+ authorization: CodeRepo;
13
+ }) => Promise<string>;
14
+ export { publishCode };
@@ -0,0 +1,41 @@
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.publishCode = void 0;
13
+ const factory = require("../../../factory");
14
+ function publishCode(params) {
15
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ const authorizationObject = {
18
+ typeOf: factory.order.OrderType.Order,
19
+ orderNumber: params.object.orderNumber
20
+ };
21
+ let authorizations;
22
+ try {
23
+ authorizations = yield repos.authorization.publish([{
24
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
25
+ object: authorizationObject,
26
+ validFrom: params.validFrom,
27
+ expiresInSeconds: params.expiresInSeconds
28
+ }]);
29
+ }
30
+ catch (error) {
31
+ throw error;
32
+ }
33
+ const code = (_a = authorizations.shift()) === null || _a === void 0 ? void 0 : _a.code;
34
+ if (typeof code !== 'string') {
35
+ // 基本的にありえないフロー
36
+ throw new factory.errors.ServiceUnavailable('code not published by an unexpected reason');
37
+ }
38
+ return code;
39
+ });
40
+ }
41
+ exports.publishCode = publishCode;
@@ -0,0 +1,18 @@
1
+ import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
2
+ import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
3
+ /**
4
+ * 未発行であれば、注文の確認番号を発行して取引に保管する
5
+ */
6
+ declare function publishConfirmationNumberIfNotExist(params: {
7
+ /**
8
+ * 取引ID
9
+ */
10
+ id: string;
11
+ object: {
12
+ orderDate: Date;
13
+ };
14
+ }): (repos: {
15
+ transaction: TransactionRepo;
16
+ confirmationNumber: ConfirmationNumberRepo;
17
+ }) => Promise<string>;
18
+ export { publishConfirmationNumberIfNotExist };
@@ -0,0 +1,42 @@
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.publishConfirmationNumberIfNotExist = void 0;
13
+ const factory = require("../../../factory");
14
+ /**
15
+ * 未発行であれば、注文の確認番号を発行して取引に保管する
16
+ */
17
+ function publishConfirmationNumberIfNotExist(params) {
18
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ // 最適化(2023-02-03~)
20
+ let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
21
+ // すでに発行済であれば何もしない
22
+ if (typeof confirmationNumber === 'string') {
23
+ return confirmationNumber;
24
+ }
25
+ // 確認番号を発行
26
+ confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
27
+ // 取引に存在しなければ保管
28
+ yield repos.transaction.saveConfirmationNumberIfNotExist({
29
+ id: params.id,
30
+ confirmationNumber
31
+ });
32
+ // 確認番号を取引から再取得
33
+ // 最適化(2023-02-03~)
34
+ confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
35
+ // 万が一処理が想定通りでない場合confirmationNumberが存在しない
36
+ if (typeof confirmationNumber !== 'string') {
37
+ throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
38
+ }
39
+ return confirmationNumber;
40
+ });
41
+ }
42
+ exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
@@ -0,0 +1,23 @@
1
+ import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
2
+ import type { MongoRepository as ProjectRepo } from '../../../repo/project';
3
+ import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
4
+ /**
5
+ * 未発行であれば、注文番号を発行して取引に保管する
6
+ */
7
+ declare function publishOrderNumberIfNotExist(params: {
8
+ project: {
9
+ id: string;
10
+ };
11
+ /**
12
+ * 取引ID
13
+ */
14
+ id: string;
15
+ object: {
16
+ orderDate: Date;
17
+ };
18
+ }): (repos: {
19
+ project: ProjectRepo;
20
+ transaction: TransactionRepo;
21
+ orderNumber: OrderNumberRepo;
22
+ }) => Promise<string>;
23
+ export { publishOrderNumberIfNotExist };
@@ -0,0 +1,46 @@
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.publishOrderNumberIfNotExist = void 0;
13
+ const factory = require("../../../factory");
14
+ /**
15
+ * 未発行であれば、注文番号を発行して取引に保管する
16
+ */
17
+ function publishOrderNumberIfNotExist(params) {
18
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ // 最適化(2023-02-03~)
20
+ let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
21
+ // すでに発行済であれば何もしない
22
+ if (typeof orderNumber === 'string') {
23
+ return orderNumber;
24
+ }
25
+ // 注文番号を発行
26
+ const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
27
+ if (typeof alternateName !== 'string') {
28
+ throw new factory.errors.NotFound('project.alternateName');
29
+ }
30
+ orderNumber = yield repos.orderNumber.publishByTimestamp({
31
+ project: { alternateName },
32
+ orderDate: params.object.orderDate
33
+ });
34
+ // 取引に存在しなければ保管
35
+ yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
36
+ // 注文番号を取引から再取得
37
+ // 最適化(2023-02-03~)
38
+ orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
39
+ // 万が一処理が想定通りでない場合orderNumberが存在しない
40
+ if (typeof orderNumber !== 'string') {
41
+ throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
42
+ }
43
+ return orderNumber;
44
+ });
45
+ }
46
+ exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;