@chevre/domain 24.0.0-alpha.78 → 24.0.0-alpha.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/action/actionProcess.d.ts +3 -3
- package/lib/chevre/repo/action/authorizeOffer.d.ts +2 -3
- package/lib/chevre/repo/action/authorizeOffer.js +2 -2
- package/lib/chevre/repo/action.d.ts +2 -2
- package/lib/chevre/repo/assetTransaction.d.ts +3 -27
- package/lib/chevre/repo/assetTransaction.js +21 -21
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +0 -11
- package/lib/chevre/service/assetTransaction.d.ts +0 -2
- package/lib/chevre/service/assetTransaction.js +8 -10
- package/lib/chevre/service/delivery/factory.js +13 -13
- package/lib/chevre/service/offer/any.d.ts +1 -1
- package/lib/chevre/service/offer/product.d.ts +0 -62
- package/lib/chevre/service/offer/product.js +0 -409
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +22 -18
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +20 -20
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -96
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -28
- package/lib/chevre/service/order/placeOrder/factory.js +5 -5
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +4 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +21 -23
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -21
- package/lib/chevre/service/validation/validateOrder.js +11 -10
- package/package.json +2 -2
- package/lib/chevre/repo/action/authorizeProductOffer.d.ts +0 -26
- package/lib/chevre/repo/action/authorizeProductOffer.js +0 -32
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +0 -14
- package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -140
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -120
- package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
- package/lib/chevre/service/assetTransaction/registerService.js +0 -274
- package/lib/chevre/service/delivery/product/factory.d.ts +0 -13
- package/lib/chevre/service/delivery/product/factory.js +0 -81
- package/lib/chevre/service/offer/product/factory.d.ts +0 -37
- package/lib/chevre/service/offer/product/factory.js +0 -208
- package/lib/chevre/service/task/confirmRegisterService.d.ts +0 -6
- package/lib/chevre/service/task/confirmRegisterService.js +0 -19
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +0 -17
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +0 -116
- package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +0 -6
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +0 -23
|
@@ -1,50 +1,8 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
|
|
37
3
|
exports.search = search;
|
|
38
|
-
exports.authorize = authorize;
|
|
39
|
-
exports.voidTransaction = voidTransaction;
|
|
40
4
|
const factory_1 = require("../../factory");
|
|
41
|
-
const availableProductTypes_1 = require("../../factory/availableProductTypes");
|
|
42
|
-
const RegisterServiceTransaction = __importStar(require("../assetTransaction/registerService"));
|
|
43
|
-
const issueOrderNumberIfNotExist_1 = require("../transaction/placeOrder/issueOrderNumberIfNotExist");
|
|
44
|
-
const any_1 = require("./any");
|
|
45
|
-
const factory_2 = require("./product/factory");
|
|
46
5
|
const searchProductOffers_1 = require("./product/searchProductOffers");
|
|
47
|
-
exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
|
|
48
6
|
/**
|
|
49
7
|
* プロダクトオファーを検索する
|
|
50
8
|
*/
|
|
@@ -63,31 +21,6 @@ function search(params) {
|
|
|
63
21
|
if (product === undefined) {
|
|
64
22
|
throw new factory_1.factory.errors.NotFound('Product');
|
|
65
23
|
}
|
|
66
|
-
// 販売者指定の場合、検証
|
|
67
|
-
if (product.typeOf === factory_1.factory.product.ProductType.MembershipService
|
|
68
|
-
|| product.typeOf === factory_1.factory.product.ProductType.PaymentCard) {
|
|
69
|
-
const sellerId = params.seller?.id;
|
|
70
|
-
if (typeof sellerId === 'string') {
|
|
71
|
-
// productsドキュメント参照のoffers検証は廃止(2025-09-22~)
|
|
72
|
-
// const productOffers = await repos.productOffer.search({
|
|
73
|
-
// project: { id: { $eq: params.project.id } },
|
|
74
|
-
// itemOffered: { id: { $eq: params.itemOffered.id } },
|
|
75
|
-
// seller: { id: { $eq: sellerId } }
|
|
76
|
-
// });
|
|
77
|
-
// const hasValidOffer = productOffers.some((o) => {
|
|
78
|
-
// return o.seller?.id === sellerId
|
|
79
|
-
// && o.validFrom !== undefined
|
|
80
|
-
// && moment(o.validFrom)
|
|
81
|
-
// .isSameOrBefore(now)
|
|
82
|
-
// && o.validThrough !== undefined
|
|
83
|
-
// && moment(o.validThrough)
|
|
84
|
-
// .isSameOrAfter(now);
|
|
85
|
-
// });
|
|
86
|
-
// if (!hasValidOffer) {
|
|
87
|
-
// return { offers: [], product };
|
|
88
|
-
// }
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
24
|
const offers = await (0, searchProductOffers_1.searchProductOffers)({
|
|
92
25
|
ids: params.ids,
|
|
93
26
|
itemOffered: { id: params.itemOffered.id },
|
|
@@ -102,345 +35,3 @@ function search(params) {
|
|
|
102
35
|
return { offers, product };
|
|
103
36
|
};
|
|
104
37
|
}
|
|
105
|
-
/**
|
|
106
|
-
* サービス(Chevreプロダクト)オファー承認
|
|
107
|
-
*/
|
|
108
|
-
function authorize(params) {
|
|
109
|
-
return async (repos) => {
|
|
110
|
-
const now = new Date();
|
|
111
|
-
const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
|
|
112
|
-
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
113
|
-
id: params.transaction.id
|
|
114
|
-
}, ['agent', 'project', 'seller', 'typeOf', 'expires']);
|
|
115
|
-
if (transaction.agent.id !== params.agent.id) {
|
|
116
|
-
throw new factory_1.factory.errors.Forbidden('Transaction not yours');
|
|
117
|
-
}
|
|
118
|
-
const { product, availableOffers } = await fixProductAndOffers(params)(repos);
|
|
119
|
-
// 会員の場合のみ既登録か確認
|
|
120
|
-
if (params.agent.typeOf === factory_1.factory.personType.Person) {
|
|
121
|
-
await checkIfRegistered({
|
|
122
|
-
agent: { id: params.agent.id },
|
|
123
|
-
product: { id: String(product.id), typeOf: product.typeOf },
|
|
124
|
-
now: now
|
|
125
|
-
// iss: params.iss
|
|
126
|
-
})(repos);
|
|
127
|
-
}
|
|
128
|
-
// ポイント特典の識別子に利用するため注文番号を先に発行
|
|
129
|
-
const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
|
|
130
|
-
project: { id: transaction.project.id },
|
|
131
|
-
id: transaction.id,
|
|
132
|
-
object: { orderDate: new Date() }
|
|
133
|
-
})(repos);
|
|
134
|
-
let acceptedOffer = await validateAcceptedOffers({
|
|
135
|
-
object: params.object,
|
|
136
|
-
product,
|
|
137
|
-
availableOffers,
|
|
138
|
-
seller: transaction.seller,
|
|
139
|
-
orderNumber
|
|
140
|
-
})({});
|
|
141
|
-
acceptedOffer = await createServiceOutputIdentifier({ acceptedOffer, product })(repos);
|
|
142
|
-
let requestBody;
|
|
143
|
-
let responseBody;
|
|
144
|
-
let result;
|
|
145
|
-
// まず取引番号発行
|
|
146
|
-
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({
|
|
147
|
-
startDate: new Date()
|
|
148
|
-
});
|
|
149
|
-
const actionAttributes = (0, factory_2.createActionAttributes)({
|
|
150
|
-
acceptedOffer: acceptedOffer,
|
|
151
|
-
transaction: transaction,
|
|
152
|
-
transactionNumber: transactionNumber
|
|
153
|
-
});
|
|
154
|
-
const action = await repos.authorizeProductOfferAction.start(actionAttributes);
|
|
155
|
-
try {
|
|
156
|
-
// 会員の場合のみ排他ロック
|
|
157
|
-
// if (params.agent.typeOf === factory.personType.Person) {
|
|
158
|
-
// }
|
|
159
|
-
// サービス登録開始
|
|
160
|
-
const startParams = (0, factory_2.createRegisterServiceStartParams)({
|
|
161
|
-
project: { typeOf: factory_1.factory.organizationType.Project, id: params.project.id },
|
|
162
|
-
object: acceptedOffer,
|
|
163
|
-
transaction: transaction,
|
|
164
|
-
transactionNumber
|
|
165
|
-
});
|
|
166
|
-
requestBody = startParams;
|
|
167
|
-
responseBody = await RegisterServiceTransaction.start(startParams)(repos);
|
|
168
|
-
const acceptedOffers4result = (0, factory_2.responseBody2resultAcceptedOffer)({
|
|
169
|
-
project: actionAttributes.project, responseBody, acceptedOffer
|
|
170
|
-
});
|
|
171
|
-
result = (0, factory_2.createResult)({ project: actionAttributes.project, requestBody, responseBody, acceptedOffer });
|
|
172
|
-
await (0, any_1.acceptOffer)({
|
|
173
|
-
orderNumber,
|
|
174
|
-
project: transaction.project,
|
|
175
|
-
acceptedOffers: acceptedOffers4result
|
|
176
|
-
})(repos);
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
try {
|
|
180
|
-
await repos.authorizeProductOfferAction.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
181
|
-
}
|
|
182
|
-
catch (__) {
|
|
183
|
-
// no op
|
|
184
|
-
}
|
|
185
|
-
throw error;
|
|
186
|
-
}
|
|
187
|
-
await repos.authorizeProductOfferAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
188
|
-
return { id: action.id, result };
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function fixProductAndOffers(params) {
|
|
192
|
-
return async (repos) => {
|
|
193
|
-
const productId = String(params.object[0]?.itemOffered?.id);
|
|
194
|
-
const searchProductsResult = await repos.product.projectFields({
|
|
195
|
-
limit: 1,
|
|
196
|
-
page: 1,
|
|
197
|
-
project: { id: { $eq: params.project.id } },
|
|
198
|
-
id: { $eq: productId }
|
|
199
|
-
}, ['id', 'name', 'productID', 'project', 'serviceOutput', 'serviceType', 'typeOf']
|
|
200
|
-
// []
|
|
201
|
-
);
|
|
202
|
-
const product = searchProductsResult.shift();
|
|
203
|
-
if (product === undefined) {
|
|
204
|
-
throw new factory_1.factory.errors.NotFound('Product');
|
|
205
|
-
}
|
|
206
|
-
if (product.typeOf !== factory_1.factory.product.ProductType.MembershipService
|
|
207
|
-
&& product.typeOf !== factory_1.factory.product.ProductType.PaymentCard) {
|
|
208
|
-
throw new factory_1.factory.errors.Argument('object.itemOffered.id', `invalid product type: ${product.typeOf}`);
|
|
209
|
-
}
|
|
210
|
-
const { offers } = await search({
|
|
211
|
-
ids: params.object.map((o) => String(o.id)),
|
|
212
|
-
project: { id: params.project.id },
|
|
213
|
-
itemOffered: { id: String(product.id) },
|
|
214
|
-
onlyValid: true,
|
|
215
|
-
includedInDataCatalog: { id: '' }, // 承認時はカタログ指定の必要なし
|
|
216
|
-
addSortIndex: false,
|
|
217
|
-
useIncludeInDataCatalog: false,
|
|
218
|
-
// 利用アプリケーションを指定
|
|
219
|
-
...(typeof params.location?.id === 'string') ? { availableAt: { id: params.location.id } } : undefined
|
|
220
|
-
})(repos);
|
|
221
|
-
return { product, availableOffers: offers };
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function voidTransaction(params) {
|
|
225
|
-
return async (repos) => {
|
|
226
|
-
const transaction = await repos.placeOrder.findPlaceOrderById({
|
|
227
|
-
typeOf: params.purpose.typeOf,
|
|
228
|
-
id: params.purpose.id
|
|
229
|
-
}, ['agent', 'status', 'typeOf']);
|
|
230
|
-
if (transaction.status !== factory_1.factory.transactionStatusType.Canceled
|
|
231
|
-
&& transaction.status !== factory_1.factory.transactionStatusType.Expired
|
|
232
|
-
&& transaction.status !== factory_1.factory.transactionStatusType.InProgress) {
|
|
233
|
-
throw new factory_1.factory.errors.Argument('purpose', `invalid transaction status: ${transaction.status}`);
|
|
234
|
-
}
|
|
235
|
-
if (typeof params.agent?.id === 'string') {
|
|
236
|
-
if (transaction.agent.id !== params.agent.id) {
|
|
237
|
-
throw new factory_1.factory.errors.Forbidden('Transaction not yours');
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
let authorizeActions;
|
|
241
|
-
if (typeof params.id === 'string') {
|
|
242
|
-
const action = await repos.authorizeProductOfferAction.findById({ typeOf: factory_1.factory.actionType.AuthorizeAction, id: params.id });
|
|
243
|
-
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
244
|
-
throw new factory_1.factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
245
|
-
}
|
|
246
|
-
authorizeActions = [action];
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
authorizeActions = await repos.authorizeProductOfferAction.findAuthorizeProductOfferActionsByPurpose({
|
|
250
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
251
|
-
purpose: {
|
|
252
|
-
typeOf: params.purpose.typeOf,
|
|
253
|
-
id: params.purpose.id
|
|
254
|
-
}
|
|
255
|
-
})
|
|
256
|
-
.then((actions) => actions
|
|
257
|
-
.filter((a) =>
|
|
258
|
-
// Array.isArray(a.object)
|
|
259
|
-
// && a.object.length > 0
|
|
260
|
-
// && a.object[0].typeOf === factory.offerType.Offer
|
|
261
|
-
// && availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0
|
|
262
|
-
a.object.typeOf === factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer
|
|
263
|
-
&& availableProductTypes_1.availableProductTypes.indexOf(a.object.itemOffered.typeOf) >= 0));
|
|
264
|
-
}
|
|
265
|
-
await Promise.all(authorizeActions.map(async (action) => {
|
|
266
|
-
// const productId = action.object[0]?.itemOffered?.id;
|
|
267
|
-
const productId = action.object?.itemOffered?.id;
|
|
268
|
-
if (typeof productId === 'string') {
|
|
269
|
-
// 廃止(2023-12-07~)
|
|
270
|
-
// await processUnlockRegisterMembershipService({
|
|
271
|
-
// agent: { id: transaction.agent.id },
|
|
272
|
-
// product: { id: productId },
|
|
273
|
-
// purpose: params.purpose
|
|
274
|
-
// })(repos);
|
|
275
|
-
}
|
|
276
|
-
await repos.authorizeProductOfferAction.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
277
|
-
await processVoidRegisterServiceTransaction({
|
|
278
|
-
action,
|
|
279
|
-
project: params.project
|
|
280
|
-
})(repos);
|
|
281
|
-
}));
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Chevre進行中取引を中止する
|
|
286
|
-
*/
|
|
287
|
-
function processVoidRegisterServiceTransaction(params) {
|
|
288
|
-
return async (repos) => {
|
|
289
|
-
const transactionNumber = params.action.instrument?.transactionNumber;
|
|
290
|
-
if (typeof transactionNumber === 'string') {
|
|
291
|
-
// 取引が存在すれば中止
|
|
292
|
-
const searchAssetTransactionsResult = await repos.assetTransaction.search({
|
|
293
|
-
limit: 1,
|
|
294
|
-
page: 1,
|
|
295
|
-
project: { id: { $eq: params.project.id } },
|
|
296
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
297
|
-
transactionNumber: { $eq: transactionNumber }
|
|
298
|
-
});
|
|
299
|
-
if (searchAssetTransactionsResult.length > 0) {
|
|
300
|
-
await RegisterServiceTransaction.cancel({ transactionNumber })(repos);
|
|
301
|
-
// await repos.registerServiceTransaction.cancel({ transactionNumber: transactionNumber });
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* 受け入れらたオファーの内容を検証
|
|
308
|
-
*/
|
|
309
|
-
function validateAcceptedOffers(params) {
|
|
310
|
-
return async (__) => {
|
|
311
|
-
let acceptedOfferWithoutDetail = params.object;
|
|
312
|
-
if (!Array.isArray(acceptedOfferWithoutDetail)) {
|
|
313
|
-
acceptedOfferWithoutDetail = [acceptedOfferWithoutDetail];
|
|
314
|
-
}
|
|
315
|
-
if (acceptedOfferWithoutDetail.length === 0) {
|
|
316
|
-
throw new factory_1.factory.errors.ArgumentNull('object');
|
|
317
|
-
}
|
|
318
|
-
const project = { typeOf: factory_1.factory.organizationType.Project, id: params.product.project.id };
|
|
319
|
-
const issuedBy = {
|
|
320
|
-
id: params.seller.id,
|
|
321
|
-
name: params.seller.name,
|
|
322
|
-
typeOf: params.seller.typeOf
|
|
323
|
-
};
|
|
324
|
-
// 販売者を検証
|
|
325
|
-
// productsドキュメント参照のoffers検証は廃止(2025-09-22~)
|
|
326
|
-
// const productOffers = await repos.productOffer.search({
|
|
327
|
-
// project: { id: { $eq: params.product.project.id } },
|
|
328
|
-
// itemOffered: { id: { $eq: String(params.product.id) } },
|
|
329
|
-
// seller: { id: { $eq: params.seller.id } }
|
|
330
|
-
// });
|
|
331
|
-
// const hasValidOffer = productOffers.some((o) => {
|
|
332
|
-
// return o.seller?.id === params.seller.id;
|
|
333
|
-
// });
|
|
334
|
-
// if (!hasValidOffer) {
|
|
335
|
-
// throw new factory.errors.Argument('Product', 'Product has no valid offer');
|
|
336
|
-
// }
|
|
337
|
-
// 利用可能なチケットオファーであれば受け入れる
|
|
338
|
-
return Promise.all(acceptedOfferWithoutDetail.map((offerWithoutDetail) => {
|
|
339
|
-
const offer = params.availableOffers.find((o) => o.id === offerWithoutDetail.id);
|
|
340
|
-
if (offer === undefined) {
|
|
341
|
-
throw new factory_1.factory.errors.NotFound('Offer', `Offer ${offerWithoutDetail.id} not found`);
|
|
342
|
-
}
|
|
343
|
-
// // ポイント特典入金先の指定があれば入金識別子を発行
|
|
344
|
-
// let pointAward: factory.action.transfer.moneyTransfer.IPointAward | undefined;
|
|
345
|
-
// const pointAwardToLocationIdentifier = offerWithoutDetail.itemOffered?.pointAward?.toLocation?.identifier;
|
|
346
|
-
// const pointAwardToLocationIssuedThroughId = offerWithoutDetail.itemOffered?.pointAward?.toLocation?.issuedThrough.id;
|
|
347
|
-
// if (typeof pointAwardToLocationIdentifier === 'string' && pointAwardToLocationIdentifier.length > 0
|
|
348
|
-
// && typeof pointAwardToLocationIssuedThroughId === 'string' && pointAwardToLocationIssuedThroughId.length > 0) {
|
|
349
|
-
// const pointAwardPurposeIdentifier = createPointAwardIdentifier({
|
|
350
|
-
// project: project,
|
|
351
|
-
// purpose: { orderNumber: params.orderNumber },
|
|
352
|
-
// toLocation: { identifier: pointAwardToLocationIdentifier }
|
|
353
|
-
// });
|
|
354
|
-
// pointAward = {
|
|
355
|
-
// recipient: offerWithoutDetail.itemOffered.pointAward?.recipient,
|
|
356
|
-
// toLocation: {
|
|
357
|
-
// identifier: pointAwardToLocationIdentifier,
|
|
358
|
-
// // toLocation.issuedThroughを保証する
|
|
359
|
-
// issuedThrough: { id: pointAwardToLocationIssuedThroughId },
|
|
360
|
-
// typeOf: factory.permit.PermitType.Permit
|
|
361
|
-
// },
|
|
362
|
-
// typeOf: factory.actionType.MoneyTransfer,
|
|
363
|
-
// purpose: { identifier: pointAwardPurposeIdentifier },
|
|
364
|
-
// ...(typeof offerWithoutDetail.itemOffered.pointAward?.description === 'string')
|
|
365
|
-
// ? { description: offerWithoutDetail.itemOffered.pointAward.description }
|
|
366
|
-
// : undefined
|
|
367
|
-
// };
|
|
368
|
-
// }
|
|
369
|
-
const itemOffered = {
|
|
370
|
-
// project: project,
|
|
371
|
-
typeOf: params.product.typeOf,
|
|
372
|
-
id: params.product.id,
|
|
373
|
-
name: params.product.name,
|
|
374
|
-
serviceOutput: {
|
|
375
|
-
...params.product?.serviceOutput,
|
|
376
|
-
...offerWithoutDetail.itemOffered?.serviceOutput,
|
|
377
|
-
project: project,
|
|
378
|
-
// 発行者は販売者でいったん固定
|
|
379
|
-
issuedBy: issuedBy,
|
|
380
|
-
typeOf: factory_1.factory.permit.PermitType.Permit
|
|
381
|
-
},
|
|
382
|
-
// discontinue(2026-04-18~)
|
|
383
|
-
// ...(pointAward !== undefined) ? { pointAward } : undefined
|
|
384
|
-
};
|
|
385
|
-
return {
|
|
386
|
-
...offerWithoutDetail,
|
|
387
|
-
...offer,
|
|
388
|
-
itemOffered,
|
|
389
|
-
seller: { project: project, typeOf: params.seller.typeOf, id: params.seller.id, name: params.seller.name }
|
|
390
|
-
};
|
|
391
|
-
}));
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function checkIfRegistered(params) {
|
|
395
|
-
return async (repos) => {
|
|
396
|
-
// メンバーシップについては、登録済かどうか確認する
|
|
397
|
-
if (params.product.typeOf === factory_1.factory.product.ProductType.MembershipService) {
|
|
398
|
-
// プロダクトによって発行されたPermitを所有していれば、登録済
|
|
399
|
-
const searchOwnershipInfosResult = await repos.ownershipInfo.projectFields({
|
|
400
|
-
limit: 1,
|
|
401
|
-
page: 1,
|
|
402
|
-
ownedBy: { id: params.agent.id },
|
|
403
|
-
// プロダクトIDで検索
|
|
404
|
-
typeOfGood: {
|
|
405
|
-
issuedThrough: {
|
|
406
|
-
id: { $eq: params.product.id },
|
|
407
|
-
typeOf: { $eq: factory_1.factory.product.ProductType.MembershipService }
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
ownedFrom: params.now,
|
|
411
|
-
ownedThrough: params.now
|
|
412
|
-
}, []);
|
|
413
|
-
const ownershipInfos = searchOwnershipInfosResult;
|
|
414
|
-
if (ownershipInfos.length > 0) {
|
|
415
|
-
// Already registered
|
|
416
|
-
throw new factory_1.factory.errors.Argument('object', exports.ERROR_MESSAGE_ALREADY_REGISTERED);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
function createServiceOutputIdentifier(params) {
|
|
422
|
-
return async (repos) => {
|
|
423
|
-
const publishParams = params.acceptedOffer.map(() => {
|
|
424
|
-
return { project: { id: params.product.project.id } };
|
|
425
|
-
});
|
|
426
|
-
const publishIdentifierResult = await Promise.all(publishParams.map(async () => {
|
|
427
|
-
const identifier = await repos.serviceOutputIdentifier.issueServiceOutputIdentifier({ startDate: new Date() });
|
|
428
|
-
return { identifier };
|
|
429
|
-
}));
|
|
430
|
-
// 識別子を発行
|
|
431
|
-
return Promise.all(params.acceptedOffer.map(async (o, key) => {
|
|
432
|
-
return {
|
|
433
|
-
...o,
|
|
434
|
-
itemOffered: {
|
|
435
|
-
...o.itemOffered,
|
|
436
|
-
serviceOutput: {
|
|
437
|
-
...o.itemOffered?.serviceOutput,
|
|
438
|
-
project: params.product.project,
|
|
439
|
-
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
440
|
-
identifier: publishIdentifierResult[key].identifier
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}));
|
|
445
|
-
};
|
|
446
|
-
}
|
|
@@ -7,7 +7,7 @@ declare function isDeliverable(params: {
|
|
|
7
7
|
id: string;
|
|
8
8
|
};
|
|
9
9
|
orderNumber: string;
|
|
10
|
-
assetTransactionType: factory.assetTransactionType.Reserve
|
|
10
|
+
assetTransactionType: factory.assetTransactionType.Reserve;
|
|
11
11
|
}): (repos: {
|
|
12
12
|
acceptedOffer: AcceptedOfferRepo;
|
|
13
13
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -51,24 +51,28 @@ function isDeliverable(params) {
|
|
|
51
51
|
// } else {
|
|
52
52
|
// allMoneyTransferTransactionConfirmed = true;
|
|
53
53
|
// }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
// } else if (params.assetTransactionType === factory.assetTransactionType.RegisterService) {
|
|
55
|
+
// allReserveTransactionConfirmed = true;
|
|
56
|
+
// allMoneyTransferTransactionConfirmed = true;
|
|
57
|
+
// const registerServiceTransactionNumbers = await repos.acceptedOffer.distinctValues(
|
|
58
|
+
// { orderNumber: { $in: [params.orderNumber] } },
|
|
59
|
+
// 'acceptedOffers.serialNumber'
|
|
60
|
+
// );
|
|
61
|
+
// if (registerServiceTransactionNumbers.length > 0) {
|
|
62
|
+
// const referencedRegisterServiceTransactions = await repos.assetTransaction.search(
|
|
63
|
+
// {
|
|
64
|
+
// project: { id: { $eq: params.project.id } },
|
|
65
|
+
// typeOf: factory.assetTransactionType.RegisterService,
|
|
66
|
+
// transactionNumber: { $in: registerServiceTransactionNumbers }
|
|
67
|
+
// },
|
|
68
|
+
// ['status']
|
|
69
|
+
// ) as Pick<factory.assetTransaction.registerService.ITransaction, 'status'>[];
|
|
70
|
+
// allRegisterServiceTransactionConfirmed =
|
|
71
|
+
// referencedRegisterServiceTransactions.length === registerServiceTransactionNumbers.length
|
|
72
|
+
// && referencedRegisterServiceTransactions.every(({ status }) => status === factory.transactionStatusType.Confirmed);
|
|
73
|
+
// } else {
|
|
74
|
+
// allRegisterServiceTransactionConfirmed = true;
|
|
75
|
+
// }
|
|
72
76
|
}
|
|
73
77
|
return allReserveTransactionConfirmed && allMoneyTransferTransactionConfirmed && allRegisterServiceTransactionConfirmed;
|
|
74
78
|
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processing2inTransit = exports.paymentDue2Processing = void 0;
|
|
4
4
|
exports.onAssetTransactionStatusChanged = onAssetTransactionStatusChanged;
|
|
5
|
-
const isDeliverable_1 = require("./onAssetTransactionStatusChanged/isDeliverable");
|
|
6
5
|
const onPayTransactionCanceled_1 = require("./onAssetTransactionStatusChanged/onPayTransactionCanceled");
|
|
7
6
|
const onPayTransactionConfirmed_1 = require("./onAssetTransactionStatusChanged/onPayTransactionConfirmed");
|
|
8
7
|
const onReserveTransactionConfirmed_1 = require("./onAssetTransactionStatusChanged/onReserveTransactionConfirmed");
|
|
@@ -18,8 +17,8 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
18
17
|
}
|
|
19
18
|
switch (params.object.status) {
|
|
20
19
|
case factory_1.factory.transactionStatusType.Confirmed: {
|
|
21
|
-
const orderNumber = params.purpose?.orderNumber;
|
|
22
|
-
const confirmationNumber = params.purpose?.confirmationNumber;
|
|
20
|
+
// const orderNumber = params.purpose?.orderNumber;
|
|
21
|
+
// const confirmationNumber = params.purpose?.confirmationNumber;
|
|
23
22
|
switch (params.object.typeOf) {
|
|
24
23
|
case factory_1.factory.assetTransactionType.Pay:
|
|
25
24
|
await (0, onPayTransactionConfirmed_1.onPayTransactionConfirmed)({
|
|
@@ -66,23 +65,24 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
66
65
|
// }
|
|
67
66
|
// }
|
|
68
67
|
// break;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
// discontinue(2026-04-19~)
|
|
69
|
+
// case factory.assetTransactionType.RegisterService:
|
|
70
|
+
// if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
|
|
71
|
+
// const deliverable = await isDeliverable({
|
|
72
|
+
// project: { id: params.project.id },
|
|
73
|
+
// orderNumber,
|
|
74
|
+
// assetTransactionType: params.object.typeOf
|
|
75
|
+
// })(repos);
|
|
76
|
+
// if (deliverable) {
|
|
77
|
+
// await processing2inTransit({
|
|
78
|
+
// project: { id: params.project.id },
|
|
79
|
+
// // confirmationNumber,
|
|
80
|
+
// orderNumber,
|
|
81
|
+
// useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
82
|
+
// })(repos, settings);
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
85
|
+
// break;
|
|
86
86
|
default:
|
|
87
87
|
// no op
|
|
88
88
|
}
|
|
@@ -7,5 +7,5 @@ import { factory } from '../../../../factory';
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
9
9
|
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
10
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/
|
|
10
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deletePerson").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
|
|
11
11
|
export { createOnOrderCancelledTasksByTransaction };
|
package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ declare function createInformTasks(params: {
|
|
|
13
13
|
}, setting: Pick<ISetting, 'onOrderStatusChanged'> | null): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
14
14
|
declare function createNextSendOrderTasks(params: {
|
|
15
15
|
order: IInTransitOrder;
|
|
16
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/
|
|
16
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deletePerson").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
|
|
17
17
|
export { createInformTasks, createNextSendOrderTasks, IInTransitOrder };
|