@chevre/domain 21.20.0-alpha.13 → 21.20.0-alpha.14
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/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +109 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +82 -0
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +3 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +41 -2
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
(await chevre.service.order.createService())
|
|
12
|
+
.onAssetTransactionStatusChanged({
|
|
13
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
14
|
+
object: {
|
|
15
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
16
|
+
transactionNumber: '863918387495116',
|
|
17
|
+
status: chevre.factory.transactionStatusType.Confirmed
|
|
18
|
+
},
|
|
19
|
+
purpose: {
|
|
20
|
+
confirmationNumber: '',
|
|
21
|
+
orderNumber: 'CIN1-3748070-2008463',
|
|
22
|
+
typeOf: chevre.factory.order.OrderType.Order
|
|
23
|
+
},
|
|
24
|
+
useOnOrderStatusChanged: true
|
|
25
|
+
})({
|
|
26
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
27
|
+
acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
|
|
28
|
+
order: await chevre.repository.Order.createInstance(mongoose.connection),
|
|
29
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
30
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then(console.log)
|
|
36
|
+
.catch(console.error);
|
|
@@ -74,7 +74,7 @@ function onConfirmed(params) {
|
|
|
74
74
|
purpose: {
|
|
75
75
|
confirmationNumber: params.purpose.confirmationNumber,
|
|
76
76
|
orderNumber: params.purpose.orderNumber,
|
|
77
|
-
typeOf:
|
|
77
|
+
typeOf: factory.order.OrderType.Order
|
|
78
78
|
},
|
|
79
79
|
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
80
80
|
};
|
|
@@ -24,4 +24,14 @@ declare function paymentDue2Processing(params: {
|
|
|
24
24
|
task: TaskRepo;
|
|
25
25
|
transaction: TransactionRepo;
|
|
26
26
|
}) => Promise<void>;
|
|
27
|
-
|
|
27
|
+
declare function processing2inTransit(params: {
|
|
28
|
+
project: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
orderNumber: string;
|
|
32
|
+
useOnOrderStatusChanged: boolean;
|
|
33
|
+
}): (repos: {
|
|
34
|
+
order: OrderRepo;
|
|
35
|
+
task: TaskRepo;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
export { onAssetTransactionStatusChanged, paymentDue2Processing, processing2inTransit };
|
|
@@ -9,10 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.paymentDue2Processing = exports.onAssetTransactionStatusChanged = void 0;
|
|
12
|
+
exports.processing2inTransit = exports.paymentDue2Processing = exports.onAssetTransactionStatusChanged = void 0;
|
|
13
13
|
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
14
14
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
15
15
|
const factory = require("../../factory");
|
|
16
|
+
// tslint:disable-next-line:max-func-body-length
|
|
16
17
|
function onAssetTransactionStatusChanged(params) {
|
|
17
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
var _a, _b, _c, _d, _e;
|
|
@@ -21,10 +22,10 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
21
22
|
}
|
|
22
23
|
switch (params.object.status) {
|
|
23
24
|
case factory.transactionStatusType.Confirmed:
|
|
25
|
+
const orderNumber = (_a = params.purpose) === null || _a === void 0 ? void 0 : _a.orderNumber;
|
|
26
|
+
const confirmationNumber = (_b = params.purpose) === null || _b === void 0 ? void 0 : _b.confirmationNumber;
|
|
24
27
|
switch (params.object.typeOf) {
|
|
25
28
|
case factory.assetTransactionType.Pay:
|
|
26
|
-
const orderNumber = (_a = params.purpose) === null || _a === void 0 ? void 0 : _a.orderNumber;
|
|
27
|
-
const confirmationNumber = (_b = params.purpose) === null || _b === void 0 ? void 0 : _b.confirmationNumber;
|
|
28
29
|
// 確定時の決済方法区分指定(2023-08-29~)
|
|
29
30
|
const specifiedPaymentMethodIdentifire = (_e = (_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.paymentMethod) === null || _e === void 0 ? void 0 : _e.identifier;
|
|
30
31
|
if (typeof specifiedPaymentMethodIdentifire === 'string' && specifiedPaymentMethodIdentifire.length > 0) {
|
|
@@ -48,6 +49,34 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
break;
|
|
52
|
+
case 'COAReserveTransaction':
|
|
53
|
+
if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
|
|
54
|
+
// 基本的に1注文に1予約番号なのでdeliverable = true
|
|
55
|
+
const deliverable = true;
|
|
56
|
+
if (deliverable) {
|
|
57
|
+
yield processing2inTransit({
|
|
58
|
+
project: { id: params.project.id },
|
|
59
|
+
// confirmationNumber,
|
|
60
|
+
orderNumber,
|
|
61
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
62
|
+
})(repos);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case factory.assetTransactionType.Reserve:
|
|
67
|
+
if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
|
|
68
|
+
// ReserveTransactionのステータス検証
|
|
69
|
+
const deliverable = yield isDeliverable({ project: { id: params.project.id }, orderNumber })(repos);
|
|
70
|
+
if (deliverable) {
|
|
71
|
+
yield processing2inTransit({
|
|
72
|
+
project: { id: params.project.id },
|
|
73
|
+
// confirmationNumber,
|
|
74
|
+
orderNumber,
|
|
75
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
76
|
+
})(repos);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
51
80
|
default:
|
|
52
81
|
// no op
|
|
53
82
|
}
|
|
@@ -230,3 +259,80 @@ function cancelOrderIfExist(params) {
|
|
|
230
259
|
}
|
|
231
260
|
});
|
|
232
261
|
}
|
|
262
|
+
function isDeliverable(params) {
|
|
263
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
264
|
+
// 注文のreservationNumberを取得
|
|
265
|
+
const reservationNumbers = yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.orderNumber] } }, 'acceptedOffers.itemOffered.reservationNumber');
|
|
266
|
+
// ReserveTransactionのステータス検証
|
|
267
|
+
let allReserveTransactionConfirmed = false;
|
|
268
|
+
if (reservationNumbers.length > 0) {
|
|
269
|
+
// console.log('is deliverable?...', params.orderNumber, reservationNumbers);
|
|
270
|
+
const referencedReserveTransactions = yield repos.assetTransaction.search({
|
|
271
|
+
project: { id: { $eq: params.project.id } },
|
|
272
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
273
|
+
transactionNumber: { $in: reservationNumbers }
|
|
274
|
+
}, ['status']);
|
|
275
|
+
// console.log('referencedReserveTransactions:', referencedReserveTransactions);
|
|
276
|
+
allReserveTransactionConfirmed =
|
|
277
|
+
referencedReserveTransactions.length === reservationNumbers.length
|
|
278
|
+
&& referencedReserveTransactions.every(({ status }) => status === factory.transactionStatusType.Confirmed);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
allReserveTransactionConfirmed = true;
|
|
282
|
+
}
|
|
283
|
+
return allReserveTransactionConfirmed;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function processing2inTransit(params) {
|
|
287
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
// const placeOrderTransaction = await findPlaceOrderTransaction({
|
|
289
|
+
// project: { id: params.project.id },
|
|
290
|
+
// confirmationNumber: params.confirmationNumber,
|
|
291
|
+
// orderNumber: params.orderNumber
|
|
292
|
+
// })({ transaction: repos.transaction });
|
|
293
|
+
const order = yield repos.order.findByOrderNumber({
|
|
294
|
+
orderNumber: params.orderNumber,
|
|
295
|
+
project: { id: params.project.id },
|
|
296
|
+
inclusion: [],
|
|
297
|
+
exclusion: ['acceptedOffers']
|
|
298
|
+
});
|
|
299
|
+
try {
|
|
300
|
+
// console.log('OrderProcessing -> OrderInTransit');
|
|
301
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
302
|
+
// TODO OrderInTransitへの変更を保留
|
|
303
|
+
// order = await repos.order.changeStatus({
|
|
304
|
+
// project: { id: order.project.id },
|
|
305
|
+
// orderNumber: params.orderNumber,
|
|
306
|
+
// orderStatus: factory.orderStatus.OrderInTransit,
|
|
307
|
+
// previousOrderStatus: factory.orderStatus.OrderProcessing
|
|
308
|
+
// });
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
const throwsError = true;
|
|
312
|
+
// すでにステータスが煤でいた場合、OrderPaymentDue->OrderProcessingの処理自体は成功しているので、後処理を続行する
|
|
313
|
+
// order = await repos.order.findByOrderNumber({
|
|
314
|
+
// orderNumber: params.orderNumber,
|
|
315
|
+
// project: { id: params.project.id },
|
|
316
|
+
// inclusion: [],
|
|
317
|
+
// exclusion: ['acceptedOffers']
|
|
318
|
+
// });
|
|
319
|
+
// if (order.orderStatus === factory.orderStatus.OrderDelivered
|
|
320
|
+
// || order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
321
|
+
// throwsError = false;
|
|
322
|
+
// }
|
|
323
|
+
if (throwsError) {
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (params.useOnOrderStatusChanged) {
|
|
328
|
+
yield (0, onOrderStatusChanged_1.onOrderInTransit)({
|
|
329
|
+
order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderProcessing // 強制的にOrderProcessingとして処理する
|
|
330
|
+
})
|
|
331
|
+
// placeOrderTransaction
|
|
332
|
+
})({
|
|
333
|
+
task: repos.task
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
exports.processing2inTransit = processing2inTransit;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
declare function onOrderInTransit(params: {
|
|
4
|
+
order: Omit<factory.order.IOrder, 'orderStatus'> & {
|
|
5
|
+
orderStatus: factory.orderStatus.OrderProcessing;
|
|
6
|
+
};
|
|
7
|
+
}): (repos: {
|
|
8
|
+
task: TaskRepo;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export { onOrderInTransit };
|
|
@@ -0,0 +1,82 @@
|
|
|
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.onOrderInTransit = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 注文処理時処理
|
|
15
|
+
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
17
|
+
const factory = require("../../../factory");
|
|
18
|
+
const order_1 = require("../../../factory/order");
|
|
19
|
+
const settings_1 = require("../../../settings");
|
|
20
|
+
// import {
|
|
21
|
+
// IExternalOrder
|
|
22
|
+
// } from './onOrderProcessing/factory';
|
|
23
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
24
|
+
// type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
25
|
+
function onOrderInTransit(params) {
|
|
26
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
28
|
+
// let tasks: factory.task.IAttributes<factory.taskName>[] = [];
|
|
29
|
+
// await repos.task.saveMany(tasks, { emitImmediately: true });
|
|
30
|
+
switch (params.order.orderStatus) {
|
|
31
|
+
case factory.orderStatus.OrderProcessing:
|
|
32
|
+
// 冗長なsendOrderタスク作成を回避(2023-08-25~)
|
|
33
|
+
yield createSendOrderTransactionTaskIfNotExist({
|
|
34
|
+
order: params.order
|
|
35
|
+
// potentialActions: params.placeOrderTransaction?.potentialActions?.order?.potentialActions
|
|
36
|
+
})(repos);
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.onOrderInTransit = onOrderInTransit;
|
|
43
|
+
function createSendOrderTransactionTaskIfNotExist(params) {
|
|
44
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const now = new Date();
|
|
46
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)({ customer: params.order.customer }, { noProfile: true });
|
|
47
|
+
const simpleOrder = {
|
|
48
|
+
typeOf: params.order.typeOf,
|
|
49
|
+
seller: {
|
|
50
|
+
id: params.order.seller.id,
|
|
51
|
+
typeOf: params.order.seller.typeOf,
|
|
52
|
+
name: params.order.seller.name
|
|
53
|
+
},
|
|
54
|
+
// mask
|
|
55
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
56
|
+
orderNumber: params.order.orderNumber,
|
|
57
|
+
price: params.order.price,
|
|
58
|
+
priceCurrency: params.order.priceCurrency,
|
|
59
|
+
orderDate: params.order.orderDate
|
|
60
|
+
};
|
|
61
|
+
const sendOrderObject = Object.assign(Object.assign({}, simpleOrder), { acceptedOffers: {
|
|
62
|
+
limit: settings_1.DELIVER_ORDER_LIMIT,
|
|
63
|
+
page: 1 // page1から配送
|
|
64
|
+
} });
|
|
65
|
+
const sendOrderTaskData = {
|
|
66
|
+
project: params.order.project,
|
|
67
|
+
object: Object.assign(Object.assign({}, sendOrderObject), { confirmationNumber: params.order.confirmationNumber })
|
|
68
|
+
};
|
|
69
|
+
const sendOrderTask = {
|
|
70
|
+
project: params.order.project,
|
|
71
|
+
name: factory.taskName.SendOrder,
|
|
72
|
+
status: factory.taskStatus.Ready,
|
|
73
|
+
runsAt: now,
|
|
74
|
+
remainingNumberOfTries: 10,
|
|
75
|
+
numberOfTried: 0,
|
|
76
|
+
executionResults: [],
|
|
77
|
+
data: sendOrderTaskData
|
|
78
|
+
};
|
|
79
|
+
debug('processing createSendOrderTaskIfNotExist...', sendOrderTask);
|
|
80
|
+
yield repos.task.createSendOrderTaskIfNotExist(sendOrderTask, { emitImmediately: true });
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { onOrderCancelled } from './onOrderStatusChanged/onOrderCancelled';
|
|
5
5
|
import { onOrderDelivered } from './onOrderStatusChanged/onOrderDelivered';
|
|
6
6
|
import { onOrderDeliveredPartially } from './onOrderStatusChanged/onOrderDeliveredPartially';
|
|
7
|
+
import { onOrderInTransit } from './onOrderStatusChanged/onOrderInTransit';
|
|
7
8
|
import { onOrderPaymentDue } from './onOrderStatusChanged/onOrderPaymentDue';
|
|
8
9
|
import { IExternalOrder, onOrderProcessing } from './onOrderStatusChanged/onOrderProcessing';
|
|
9
10
|
import { onOrderReturned } from './onOrderStatusChanged/onOrderReturned';
|
|
10
|
-
export { IExternalOrder, onOrderCancelled, onOrderDelivered, onOrderDeliveredPartially, onOrderPaymentDue, onOrderProcessing, onOrderReturned };
|
|
11
|
+
export { IExternalOrder, onOrderCancelled, onOrderDelivered, onOrderDeliveredPartially, onOrderInTransit, onOrderPaymentDue, onOrderProcessing, onOrderReturned };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onOrderReturned = exports.onOrderProcessing = exports.onOrderPaymentDue = exports.onOrderDeliveredPartially = exports.onOrderDelivered = exports.onOrderCancelled = void 0;
|
|
3
|
+
exports.onOrderReturned = exports.onOrderProcessing = exports.onOrderPaymentDue = exports.onOrderInTransit = exports.onOrderDeliveredPartially = exports.onOrderDelivered = exports.onOrderCancelled = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文ステータス変更時処理
|
|
6
6
|
*/
|
|
@@ -10,6 +10,8 @@ const onOrderDelivered_1 = require("./onOrderStatusChanged/onOrderDelivered");
|
|
|
10
10
|
Object.defineProperty(exports, "onOrderDelivered", { enumerable: true, get: function () { return onOrderDelivered_1.onOrderDelivered; } });
|
|
11
11
|
const onOrderDeliveredPartially_1 = require("./onOrderStatusChanged/onOrderDeliveredPartially");
|
|
12
12
|
Object.defineProperty(exports, "onOrderDeliveredPartially", { enumerable: true, get: function () { return onOrderDeliveredPartially_1.onOrderDeliveredPartially; } });
|
|
13
|
+
const onOrderInTransit_1 = require("./onOrderStatusChanged/onOrderInTransit");
|
|
14
|
+
Object.defineProperty(exports, "onOrderInTransit", { enumerable: true, get: function () { return onOrderInTransit_1.onOrderInTransit; } });
|
|
13
15
|
const onOrderPaymentDue_1 = require("./onOrderStatusChanged/onOrderPaymentDue");
|
|
14
16
|
Object.defineProperty(exports, "onOrderPaymentDue", { enumerable: true, get: function () { return onOrderPaymentDue_1.onOrderPaymentDue; } });
|
|
15
17
|
const onOrderProcessing_1 = require("./onOrderStatusChanged/onOrderProcessing");
|
|
@@ -12,7 +12,10 @@ export declare function call(data: factory.task.IData<factory.taskName.ConfirmRe
|
|
|
12
12
|
/**
|
|
13
13
|
* 予約を確定する
|
|
14
14
|
*/
|
|
15
|
-
export declare function confirmReserveTransaction(params: factory.action.interact.confirm.reservation.IAttributes<factory.service.webAPI.Identifier
|
|
15
|
+
export declare function confirmReserveTransaction(params: factory.action.interact.confirm.reservation.IAttributes<factory.service.webAPI.Identifier>, options: {
|
|
16
|
+
sendOrder: boolean;
|
|
17
|
+
useOnOrderStatusChanged: boolean;
|
|
18
|
+
}): (repos: {
|
|
16
19
|
action: ActionRepo;
|
|
17
20
|
assetTransaction: AssetTransactionRepo;
|
|
18
21
|
order: OrderRepo;
|
|
@@ -28,7 +28,10 @@ const coaAuthClient = new COA.auth.RefreshToken({
|
|
|
28
28
|
*/
|
|
29
29
|
function call(data) {
|
|
30
30
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
yield confirmReserveTransaction(data
|
|
31
|
+
yield confirmReserveTransaction(data, {
|
|
32
|
+
sendOrder: true,
|
|
33
|
+
useOnOrderStatusChanged: true
|
|
34
|
+
})({
|
|
32
35
|
action: new action_1.MongoRepository(settings.connection),
|
|
33
36
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
34
37
|
order: new order_1.MongoRepository(settings.connection),
|
|
@@ -41,7 +44,7 @@ exports.call = call;
|
|
|
41
44
|
/**
|
|
42
45
|
* 予約を確定する
|
|
43
46
|
*/
|
|
44
|
-
function confirmReserveTransaction(params) {
|
|
47
|
+
function confirmReserveTransaction(params, options) {
|
|
45
48
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
46
49
|
// アクション開始
|
|
47
50
|
const confirmActionAttributes = params;
|
|
@@ -89,6 +92,42 @@ function confirmReserveTransaction(params) {
|
|
|
89
92
|
// アクション完了
|
|
90
93
|
const result = {};
|
|
91
94
|
yield repos.action.completeWithVoid({ typeOf: confirmActionAttributes.typeOf, id: action.id, result: result });
|
|
95
|
+
// sendOrder連携(2024-01-11~)
|
|
96
|
+
yield onConfirmed(params, options)({
|
|
97
|
+
task: repos.task
|
|
98
|
+
});
|
|
92
99
|
});
|
|
93
100
|
}
|
|
94
101
|
exports.confirmReserveTransaction = confirmReserveTransaction;
|
|
102
|
+
function onConfirmed(params, options) {
|
|
103
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
if (options.sendOrder === true) {
|
|
105
|
+
// タスク冪等作成
|
|
106
|
+
const onAssetTransactionStatusChangedTaskData = {
|
|
107
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
108
|
+
object: {
|
|
109
|
+
typeOf: params.object.typeOf,
|
|
110
|
+
transactionNumber: params.object.transactionNumber,
|
|
111
|
+
status: factory.transactionStatusType.Confirmed
|
|
112
|
+
},
|
|
113
|
+
purpose: {
|
|
114
|
+
confirmationNumber: '',
|
|
115
|
+
orderNumber: params.purpose.orderNumber,
|
|
116
|
+
typeOf: factory.order.OrderType.Order
|
|
117
|
+
},
|
|
118
|
+
useOnOrderStatusChanged: options.useOnOrderStatusChanged === true
|
|
119
|
+
};
|
|
120
|
+
const onAssetTransactionStatusChangedTask = {
|
|
121
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
122
|
+
name: factory.taskName.OnAssetTransactionStatusChanged,
|
|
123
|
+
status: factory.taskStatus.Ready,
|
|
124
|
+
runsAt: new Date(),
|
|
125
|
+
remainingNumberOfTries: 10,
|
|
126
|
+
numberOfTried: 0,
|
|
127
|
+
executionResults: [],
|
|
128
|
+
data: onAssetTransactionStatusChangedTaskData
|
|
129
|
+
};
|
|
130
|
+
yield repos.task.createOnAssetTransactionStatusChangedTaskIfNotExist(onAssetTransactionStatusChangedTask, { emitImmediately: true });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.351.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.351.0-alpha.7",
|
|
14
14
|
"@cinerino/sdk": "5.8.0-alpha.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "21.20.0-alpha.
|
|
118
|
+
"version": "21.20.0-alpha.14"
|
|
119
119
|
}
|