@chevre/domain 21.18.0-alpha.2 → 21.18.0-alpha.20
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/aggreateOwnershipInfosByOrder.ts +24 -0
- package/example/src/chevre/searchAcceptedOfferIds.ts +57 -0
- package/example/src/chevre/searchOrderAcceptedOffers.ts +12 -12
- package/example/src/chevre/searchOrders.ts +36 -19
- package/example/src/chevre/searchReservationsByOrder.ts +30 -0
- package/example/src/chevre/searchTransactions.ts +41 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/example/src/chevre/upsertMoviesByIdentifier.ts +57 -0
- package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +141 -0
- package/example/src/duration.ts +22 -0
- package/lib/chevre/repo/acceptedOffer.d.ts +60 -0
- package/lib/chevre/repo/acceptedOffer.js +158 -0
- package/lib/chevre/repo/creativeWork.d.ts +5 -1
- package/lib/chevre/repo/creativeWork.js +42 -22
- package/lib/chevre/repo/event.d.ts +12 -0
- package/lib/chevre/repo/event.js +61 -0
- package/lib/chevre/repo/offerCatalog.d.ts +8 -2
- package/lib/chevre/repo/offerCatalog.js +8 -8
- package/lib/chevre/repo/order.d.ts +14 -54
- package/lib/chevre/repo/order.js +46 -180
- package/lib/chevre/repo/place.js +14 -10
- package/lib/chevre/repo/transaction.d.ts +5 -4
- package/lib/chevre/repository.d.ts +5 -7
- package/lib/chevre/repository.js +14 -17
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/pay.js +10 -6
- package/lib/chevre/service/delivery/factory.d.ts +3 -1
- package/lib/chevre/service/delivery/factory.js +4 -2
- package/lib/chevre/service/delivery.d.ts +1 -2
- package/lib/chevre/service/delivery.js +1 -3
- package/lib/chevre/service/offer/product.d.ts +0 -14
- package/lib/chevre/service/offer/product.js +59 -42
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +2 -0
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
- package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +15 -4
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +15 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +54 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +38 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +111 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +64 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +103 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +30 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +227 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +216 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +110 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +164 -0
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +9 -15
- package/lib/chevre/service/order/onOrderStatusChanged.js +11 -446
- package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +6 -0
- package/lib/chevre/service/order/onOrderUpdated/factory.js +45 -0
- package/lib/chevre/service/order/onOrderUpdated.js +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder.d.ts +2 -3
- package/lib/chevre/service/order/placeOrder.js +65 -22
- package/lib/chevre/service/order/returnOrder.d.ts +2 -2
- package/lib/chevre/service/order/returnOrder.js +34 -13
- package/lib/chevre/service/order/sendOrder.d.ts +2 -2
- package/lib/chevre/service/order/sendOrder.js +19 -6
- package/lib/chevre/service/order.d.ts +2 -2
- package/lib/chevre/service/order.js +2 -2
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
- package/lib/chevre/service/reserve/searchByOrder.js +113 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
- package/lib/chevre/service/reserve.d.ts +2 -1
- package/lib/chevre/service/reserve.js +3 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +5 -6
- package/lib/chevre/service/task/onAuthorizationCreated.js +9 -18
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +5 -6
- package/lib/chevre/service/task/placeOrder.js +10 -17
- package/lib/chevre/service/task/returnOrder.js +10 -17
- package/lib/chevre/service/task/sendOrder.js +10 -17
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.d.ts +3 -0
- package/lib/chevre/service/transaction/returnOrder.js +73 -55
- package/package.json +2 -2
- package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
- package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -42
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +0 -467
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
type IReturnedOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner'>;
|
|
3
|
+
declare function createInformTasks(order: IReturnedOrder): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
4
|
+
/**
|
|
5
|
+
* 注文返品後のアクション
|
|
6
|
+
*/
|
|
7
|
+
declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
8
|
+
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
9
|
+
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
10
|
+
export { createInformTasks, createOnOrderReturnedTasksByTransaction };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createOnOrderReturnedTasksByTransaction = exports.createInformTasks = void 0;
|
|
5
|
+
const factory = require("../../../../factory");
|
|
6
|
+
const settings_1 = require("../../../../settings");
|
|
7
|
+
const informOrder = (_a = settings_1.settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
|
|
8
|
+
function createInformTasks(order) {
|
|
9
|
+
var _a;
|
|
10
|
+
const taskRunsAt = new Date();
|
|
11
|
+
let informTasks = [];
|
|
12
|
+
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
13
|
+
const order4inform = creteOrder4inform(order);
|
|
14
|
+
let recipientId = '';
|
|
15
|
+
recipientId = order.customer.id;
|
|
16
|
+
if (typeof ((_a = order.returner) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
17
|
+
recipientId = order.returner.id;
|
|
18
|
+
}
|
|
19
|
+
informTasks = informOrder.map((informOrderParams) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const informActionAttributes = {
|
|
22
|
+
agent: order.project,
|
|
23
|
+
object: order4inform,
|
|
24
|
+
project: order.project,
|
|
25
|
+
recipient: {
|
|
26
|
+
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
27
|
+
id: recipientId,
|
|
28
|
+
name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
|
|
29
|
+
typeOf: factory.creativeWorkType.WebApplication
|
|
30
|
+
},
|
|
31
|
+
typeOf: factory.actionType.InformAction
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
project: order.project,
|
|
35
|
+
name: factory.taskName.TriggerWebhook,
|
|
36
|
+
status: factory.taskStatus.Ready,
|
|
37
|
+
runsAt: taskRunsAt,
|
|
38
|
+
remainingNumberOfTries: 10,
|
|
39
|
+
numberOfTried: 0,
|
|
40
|
+
executionResults: [],
|
|
41
|
+
data: informActionAttributes
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return informTasks;
|
|
46
|
+
}
|
|
47
|
+
exports.createInformTasks = createInformTasks;
|
|
48
|
+
function creteOrder4inform(order) {
|
|
49
|
+
return Object.assign(Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: factory.orderStatus.OrderReturned }, (order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 注文返品後のアクション
|
|
53
|
+
*/
|
|
54
|
+
function createOnOrderReturnedTasksByTransaction(params) {
|
|
55
|
+
const now = new Date();
|
|
56
|
+
const taskAttributes = [];
|
|
57
|
+
const potentialActions = params.potentialActions;
|
|
58
|
+
// 入金返却タスク
|
|
59
|
+
const returnMoneyTransferAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnMoneyTransfer;
|
|
60
|
+
if (Array.isArray(returnMoneyTransferAttributes)) {
|
|
61
|
+
taskAttributes.push(...returnMoneyTransferAttributes.map((a) => {
|
|
62
|
+
return {
|
|
63
|
+
project: a.project,
|
|
64
|
+
name: factory.taskName.ReturnMoneyTransfer,
|
|
65
|
+
status: factory.taskStatus.Ready,
|
|
66
|
+
runsAt: now,
|
|
67
|
+
remainingNumberOfTries: 10,
|
|
68
|
+
numberOfTried: 0,
|
|
69
|
+
executionResults: [],
|
|
70
|
+
data: a
|
|
71
|
+
};
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
// ポイント特典返却タスク
|
|
75
|
+
const returnPointAwardAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnPointAward;
|
|
76
|
+
if (Array.isArray(returnPointAwardAttributes)) {
|
|
77
|
+
taskAttributes.push(...returnPointAwardAttributes.map((a) => {
|
|
78
|
+
return {
|
|
79
|
+
project: a.project,
|
|
80
|
+
name: factory.taskName.ReturnPointAward,
|
|
81
|
+
status: factory.taskStatus.Ready,
|
|
82
|
+
runsAt: now,
|
|
83
|
+
remainingNumberOfTries: 10,
|
|
84
|
+
numberOfTried: 0,
|
|
85
|
+
executionResults: [],
|
|
86
|
+
data: a
|
|
87
|
+
};
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
const sendEmailMessageAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.sendEmailMessage;
|
|
91
|
+
if (Array.isArray(sendEmailMessageAttributes)) {
|
|
92
|
+
sendEmailMessageAttributes.forEach((s) => {
|
|
93
|
+
const sendEmailMessageTask = {
|
|
94
|
+
project: s.project,
|
|
95
|
+
name: factory.taskName.SendEmailMessage,
|
|
96
|
+
status: factory.taskStatus.Ready,
|
|
97
|
+
runsAt: now,
|
|
98
|
+
remainingNumberOfTries: 3,
|
|
99
|
+
numberOfTried: 0,
|
|
100
|
+
executionResults: [],
|
|
101
|
+
data: {
|
|
102
|
+
actionAttributes: s
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return taskAttributes;
|
|
109
|
+
}
|
|
110
|
+
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
2
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
3
|
+
import * as factory from '../../../factory';
|
|
4
|
+
type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
5
|
+
declare function onOrderReturned(params: {
|
|
6
|
+
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
|
|
7
|
+
orderStatus: factory.orderStatus.OrderReturned;
|
|
8
|
+
};
|
|
9
|
+
returnOrderTransaction?: IReturnOrderTransaction;
|
|
10
|
+
}): (repos: {
|
|
11
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
12
|
+
task: TaskRepo;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
export { onOrderReturned };
|
|
@@ -0,0 +1,164 @@
|
|
|
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.onOrderReturned = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 注文返品時処理
|
|
15
|
+
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
17
|
+
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
18
|
+
const factory = require("../../../factory");
|
|
19
|
+
const order_1 = require("../../../factory/order");
|
|
20
|
+
const factory_1 = require("./onOrderReturned/factory");
|
|
21
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
22
|
+
function onOrderReturned(params) {
|
|
23
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
26
|
+
let tasks = [];
|
|
27
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
28
|
+
const simpleOrder = {
|
|
29
|
+
typeOf: params.order.typeOf,
|
|
30
|
+
seller: {
|
|
31
|
+
id: params.order.seller.id,
|
|
32
|
+
typeOf: params.order.seller.typeOf,
|
|
33
|
+
name: params.order.seller.name
|
|
34
|
+
},
|
|
35
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
36
|
+
orderNumber: params.order.orderNumber,
|
|
37
|
+
price: params.order.price,
|
|
38
|
+
priceCurrency: params.order.priceCurrency,
|
|
39
|
+
orderDate: params.order.orderDate
|
|
40
|
+
};
|
|
41
|
+
switch (params.order.orderStatus) {
|
|
42
|
+
case factory.orderStatus.OrderReturned:
|
|
43
|
+
const potentialActionsByTransaction = (_d = (_c = (_b = (_a = params.returnOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.returnOrder) === null || _c === void 0 ? void 0 : _c.find((returnOrderActionByTransaction) => {
|
|
44
|
+
return returnOrderActionByTransaction.object.orderNumber === params.order.orderNumber;
|
|
45
|
+
})) === null || _d === void 0 ? void 0 : _d.potentialActions;
|
|
46
|
+
const reservationNumbers = yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.itemOffered.reservationNumber');
|
|
47
|
+
const offeredThroughIdentifier = (yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.offeredThrough.identifier'))[0];
|
|
48
|
+
const reservationForSuperEventLocationBranchCodes = yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode');
|
|
49
|
+
tasks = [
|
|
50
|
+
...(0, factory_1.createInformTasks)(params.order),
|
|
51
|
+
...createReturnReserveTransactionTasks(Object.assign(Object.assign({}, params.order), { reservationNumbers,
|
|
52
|
+
offeredThroughIdentifier,
|
|
53
|
+
reservationForSuperEventLocationBranchCodes }), simpleOrder),
|
|
54
|
+
// 決済取引返却タスクを作成(2022-06-09~)
|
|
55
|
+
...createReturnPayTransactionTasks({ orderNumber: params.order.orderNumber }, params.returnOrderTransaction),
|
|
56
|
+
// 取引のpotentialActionsを適用(2023-08-19~)
|
|
57
|
+
...(0, factory_1.createOnOrderReturnedTasksByTransaction)({ potentialActions: potentialActionsByTransaction })
|
|
58
|
+
];
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
throw new factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
62
|
+
}
|
|
63
|
+
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.onOrderReturned = onOrderReturned;
|
|
67
|
+
function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
68
|
+
debug('onOrderReturn.createReturnReserveTransactionTasks processing...', 'project:', order.project.id, 'orderNumber:', simpleOrder.orderNumber, 'reservationNumbers:', order.reservationNumbers, 'offeredThroughIdentifier:', order.offeredThroughIdentifier, 'reservationForSuperEventLocationBranchCodes:', order.reservationForSuperEventLocationBranchCodes);
|
|
69
|
+
const taskRunsAt = new Date();
|
|
70
|
+
const taskRunsAt4coa = new Date();
|
|
71
|
+
const tasks = [];
|
|
72
|
+
const returnActionRecipient = {
|
|
73
|
+
typeOf: order.seller.typeOf,
|
|
74
|
+
id: order.seller.id,
|
|
75
|
+
name: order.seller.name
|
|
76
|
+
};
|
|
77
|
+
// 注文アイテムから返却アクションを作成する
|
|
78
|
+
for (const reservationNumber of order.reservationNumbers) {
|
|
79
|
+
// const reservation = acceptedOffer.itemOffered;
|
|
80
|
+
// 予約番号ごとに返却アクションを作成する
|
|
81
|
+
let returnReserveTransactionAction;
|
|
82
|
+
switch (order.offeredThroughIdentifier) {
|
|
83
|
+
case factory.service.webAPI.Identifier.COA:
|
|
84
|
+
// const superEventLocationBranchCode =
|
|
85
|
+
// (<factory.order.IEventReservation>reservation).reservationFor?.superEvent.location.branchCode;
|
|
86
|
+
// ↓1注文に複数施設はない想定なので、これで問題ない
|
|
87
|
+
const superEventLocationBranchCode = order.reservationForSuperEventLocationBranchCodes[0];
|
|
88
|
+
if (typeof superEventLocationBranchCode !== 'string') {
|
|
89
|
+
throw new factory.errors.ArgumentNull('order.reservationForSuperEventLocationBranchCodes');
|
|
90
|
+
}
|
|
91
|
+
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
|
92
|
+
const phoneNumber = phoneUtil.parse(order.customer.telephone, 'JP');
|
|
93
|
+
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
94
|
+
// COAでは数字のみ受け付けるので数字以外を除去
|
|
95
|
+
telNum = telNum.replace(/[^\d]/g, '');
|
|
96
|
+
returnReserveTransactionAction = {
|
|
97
|
+
project: order.project,
|
|
98
|
+
typeOf: factory.actionType.ReturnAction,
|
|
99
|
+
object: {
|
|
100
|
+
theaterCode: superEventLocationBranchCode,
|
|
101
|
+
reserveNum: reservationNumber,
|
|
102
|
+
telNum: telNum,
|
|
103
|
+
typeOf: 'COAReserveTransaction'
|
|
104
|
+
},
|
|
105
|
+
agent: order.project,
|
|
106
|
+
purpose: simpleOrder,
|
|
107
|
+
instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.COA },
|
|
108
|
+
recipient: returnActionRecipient
|
|
109
|
+
};
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
returnReserveTransactionAction = {
|
|
113
|
+
project: order.project,
|
|
114
|
+
typeOf: factory.actionType.ReturnAction,
|
|
115
|
+
object: {
|
|
116
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
117
|
+
transactionNumber: reservationNumber
|
|
118
|
+
},
|
|
119
|
+
agent: order.project,
|
|
120
|
+
purpose: simpleOrder,
|
|
121
|
+
instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre },
|
|
122
|
+
recipient: returnActionRecipient
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
tasks.push({
|
|
126
|
+
project: order.project,
|
|
127
|
+
name: factory.taskName.ReturnReserveTransaction,
|
|
128
|
+
status: factory.taskStatus.Ready,
|
|
129
|
+
runsAt: (returnReserveTransactionAction.object.typeOf === 'COAReserveTransaction')
|
|
130
|
+
? taskRunsAt4coa
|
|
131
|
+
: taskRunsAt,
|
|
132
|
+
remainingNumberOfTries: 10,
|
|
133
|
+
numberOfTried: 0,
|
|
134
|
+
executionResults: [],
|
|
135
|
+
data: returnReserveTransactionAction
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return tasks;
|
|
139
|
+
}
|
|
140
|
+
function createReturnPayTransactionTasks(order, returnOrderTransaction) {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
const taskRunsAt = new Date();
|
|
143
|
+
// const taskRunsAt = moment(order.dateReturned)
|
|
144
|
+
// .add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
145
|
+
// .toDate();
|
|
146
|
+
const tasks = [];
|
|
147
|
+
const returnOrderPotentialActions = (_b = (_a = returnOrderTransaction === null || returnOrderTransaction === void 0 ? void 0 : returnOrderTransaction.potentialActions) === null || _a === void 0 ? void 0 : _a.returnOrder.find((action) => action.object.orderNumber === order.orderNumber)) === null || _b === void 0 ? void 0 : _b.potentialActions;
|
|
148
|
+
const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions === null || returnOrderPotentialActions === void 0 ? void 0 : returnOrderPotentialActions.returnPaymentMethod;
|
|
149
|
+
if (Array.isArray(returnPayActionsByReturnOrderTransaction)) {
|
|
150
|
+
tasks.push(...returnPayActionsByReturnOrderTransaction.map((a) => {
|
|
151
|
+
return {
|
|
152
|
+
project: a.project,
|
|
153
|
+
name: factory.taskName.ReturnPayTransaction,
|
|
154
|
+
status: factory.taskStatus.Ready,
|
|
155
|
+
runsAt: taskRunsAt,
|
|
156
|
+
remainingNumberOfTries: 10,
|
|
157
|
+
numberOfTried: 0,
|
|
158
|
+
executionResults: [],
|
|
159
|
+
data: a
|
|
160
|
+
};
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
return tasks;
|
|
164
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
returnOrderTransaction?: IReturnOrderTransaction;
|
|
11
|
-
}): (repos: {
|
|
12
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
13
|
-
task: TaskRepo;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
export { IExternalOrder };
|
|
1
|
+
/**
|
|
2
|
+
* 注文ステータス変更時処理
|
|
3
|
+
*/
|
|
4
|
+
import { onOrderCancelled } from './onOrderStatusChanged/onOrderCancelled';
|
|
5
|
+
import { onOrderDelivered } from './onOrderStatusChanged/onOrderDelivered';
|
|
6
|
+
import { onOrderPaymentDue } from './onOrderStatusChanged/onOrderPaymentDue';
|
|
7
|
+
import { IExternalOrder, onOrderProcessing } from './onOrderStatusChanged/onOrderProcessing';
|
|
8
|
+
import { onOrderReturned } from './onOrderStatusChanged/onOrderReturned';
|
|
9
|
+
export { IExternalOrder, onOrderCancelled, onOrderDelivered, onOrderPaymentDue, onOrderProcessing, onOrderReturned };
|