@chevre/domain 24.0.0-alpha.77 → 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 +4 -4
- 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 -51
- package/lib/chevre/repo/assetTransaction.js +51 -51
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/product.d.ts +0 -10
- package/lib/chevre/repo/product.js +28 -22
- 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/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +7 -7
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +18 -16
- package/lib/chevre/service/assetTransaction/refund.js +19 -17
- package/lib/chevre/service/assetTransaction/reserve/start.js +8 -8
- 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/event/authorize.js +7 -32
- 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 +48 -43
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +38 -37
- 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/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- 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/payment/factory/createPayObjectServiceOutput.js +1 -1
- package/lib/chevre/service/payment/factory.js +23 -23
- package/lib/chevre/service/product.js +16 -16
- package/lib/chevre/service/reserve/confirmReservation.js +19 -17
- package/lib/chevre/service/reserve/factory.d.ts +0 -6
- package/lib/chevre/service/reserve/factory.js +0 -59
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +16 -15
- 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 +16 -12
- 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/transaction/returnOrder/potentialActions.js +4 -4
- 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 -21
- package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -171
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -148
- package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
- package/lib/chevre/service/assetTransaction/registerService.js +0 -273
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +0 -15
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +0 -44
- 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
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -8
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +0 -89
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createRegisterServiceStartParams = createRegisterServiceStartParams;
|
|
7
|
-
exports.createActionAttributes = createActionAttributes;
|
|
8
|
-
exports.acceptedOffers2amount = acceptedOffers2amount;
|
|
9
|
-
exports.responseBody2resultAcceptedOffer = responseBody2resultAcceptedOffer;
|
|
10
|
-
exports.createResult = createResult;
|
|
11
|
-
const moment_1 = __importDefault(require("moment"));
|
|
12
|
-
const factory_1 = require("../../../factory");
|
|
13
|
-
function createRegisterServiceStartParams(params) {
|
|
14
|
-
return {
|
|
15
|
-
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
16
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
17
|
-
transactionNumber: params.transactionNumber,
|
|
18
|
-
agent: {
|
|
19
|
-
typeOf: params.transaction.seller.typeOf,
|
|
20
|
-
id: params.transaction.seller.id,
|
|
21
|
-
name: (typeof params.transaction.seller.name === 'string')
|
|
22
|
-
? params.transaction.seller.name
|
|
23
|
-
: String(params.transaction.seller.name?.ja)
|
|
24
|
-
// identifierを廃止(2024-03-05~)
|
|
25
|
-
// identifier: [
|
|
26
|
-
// { name: 'transaction', value: params.transaction.id },
|
|
27
|
-
// {
|
|
28
|
-
// name: 'transactionExpires',
|
|
29
|
-
// value: moment(params.transaction.expires)
|
|
30
|
-
// .toISOString()
|
|
31
|
-
// }
|
|
32
|
-
// ]
|
|
33
|
-
},
|
|
34
|
-
object: params.object.map((o) => {
|
|
35
|
-
// 許可証コードは自動発行されているはず
|
|
36
|
-
const permitIdentifier = o.itemOffered.serviceOutput.identifier;
|
|
37
|
-
if (typeof permitIdentifier !== 'string' || permitIdentifier === '') {
|
|
38
|
-
throw new factory_1.factory.errors.ArgumentNull('itemOffered.serviceOutput.identifier');
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
typeOf: o.typeOf,
|
|
42
|
-
id: String(o.id),
|
|
43
|
-
itemOffered: {
|
|
44
|
-
...o.itemOffered,
|
|
45
|
-
serviceOutput: {
|
|
46
|
-
...o.itemOffered.serviceOutput,
|
|
47
|
-
identifier: permitIdentifier
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}),
|
|
52
|
-
expires: (0, moment_1.default)(params.transaction.expires)
|
|
53
|
-
.add(1, 'day')
|
|
54
|
-
.toDate() // 余裕を持って
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function createActionAttributes(params) {
|
|
58
|
-
const transaction = params.transaction;
|
|
59
|
-
const actionObject = {
|
|
60
|
-
typeOf: factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer,
|
|
61
|
-
itemOffered: {
|
|
62
|
-
id: params.acceptedOffer[0].itemOffered.id,
|
|
63
|
-
typeOf: params.acceptedOffer[0].itemOffered.typeOf
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
project: transaction.project,
|
|
68
|
-
typeOf: factory_1.factory.actionType.AuthorizeAction,
|
|
69
|
-
instrument: {
|
|
70
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
71
|
-
transactionNumber: params.transactionNumber
|
|
72
|
-
},
|
|
73
|
-
// object: params.acceptedOffer,
|
|
74
|
-
object: actionObject, // optimize(2026-03-13~)
|
|
75
|
-
agent: {
|
|
76
|
-
id: transaction.seller.id,
|
|
77
|
-
typeOf: transaction.seller.typeOf,
|
|
78
|
-
name: (typeof transaction.seller.name === 'string')
|
|
79
|
-
? transaction.seller.name
|
|
80
|
-
: String(transaction.seller.name?.ja)
|
|
81
|
-
},
|
|
82
|
-
recipient: {
|
|
83
|
-
id: transaction.agent.id,
|
|
84
|
-
typeOf: transaction.agent.typeOf
|
|
85
|
-
},
|
|
86
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function acceptedOffers2amount(params) {
|
|
90
|
-
const acceptedOffers = params.acceptedOffers;
|
|
91
|
-
// 金額計算
|
|
92
|
-
return acceptedOffers.reduce((a, b) => {
|
|
93
|
-
if (b.priceSpecification === undefined || b.priceSpecification === null) {
|
|
94
|
-
throw new factory_1.factory.errors.Internal('price specification of result accepted offer undefined');
|
|
95
|
-
}
|
|
96
|
-
if (b.priceSpecification.typeOf !== factory_1.factory.priceSpecificationType.CompoundPriceSpecification) {
|
|
97
|
-
throw new factory_1.factory.errors.Internal('price specification of result accepted offer must be CompoundPriceSpecification');
|
|
98
|
-
}
|
|
99
|
-
const priceSpecification = b.priceSpecification;
|
|
100
|
-
return a + priceSpecification.priceComponent.reduce((a2, b2) => a2 + Number(b2.price), 0);
|
|
101
|
-
}, 0);
|
|
102
|
-
}
|
|
103
|
-
function responseBody2resultAcceptedOffer(params) {
|
|
104
|
-
let acceptedOffers = [];
|
|
105
|
-
if (Array.isArray(params.responseBody.object)) {
|
|
106
|
-
acceptedOffers = params.responseBody.object.map((responseBodyObject) => {
|
|
107
|
-
const serviceOutputIdentifier = responseBodyObject.itemOffered?.serviceOutput?.identifier;
|
|
108
|
-
if (serviceOutputIdentifier !== undefined && typeof serviceOutputIdentifier !== 'string') {
|
|
109
|
-
// 基本的にありえないフロー↓
|
|
110
|
-
throw new factory_1.factory.errors.Internal(`invalid type of serviceOutput.identifier: ${typeof serviceOutputIdentifier}`);
|
|
111
|
-
}
|
|
112
|
-
// itemOfferedを最小限に最適化
|
|
113
|
-
const permitByResponse = responseBodyObject.itemOffered.serviceOutput;
|
|
114
|
-
const itemOffered = {
|
|
115
|
-
// 不要なので廃止(2023-07-01~)
|
|
116
|
-
// project: permitByResponse.project,
|
|
117
|
-
typeOf: permitByResponse.typeOf,
|
|
118
|
-
identifier: permitByResponse.identifier,
|
|
119
|
-
issuedThrough: permitByResponse.issuedThrough,
|
|
120
|
-
name: permitByResponse.name,
|
|
121
|
-
// masked accessCode
|
|
122
|
-
// ...(typeof permitByResponse.accessCode === 'string') ? { accessCode: 'xxx' } : undefined,
|
|
123
|
-
...(typeof permitByResponse.validFor === 'string') ? { validFor: permitByResponse.validFor } : undefined,
|
|
124
|
-
...(typeof permitByResponse.amount?.typeOf === 'string') ? { amount: permitByResponse.amount } : undefined
|
|
125
|
-
};
|
|
126
|
-
const offer = params.acceptedOffer.find((o) => o.id === responseBodyObject.id);
|
|
127
|
-
if (offer === undefined) {
|
|
128
|
-
throw new factory_1.factory.errors.Internal(`Offer ${responseBodyObject.id} from registerService not found`);
|
|
129
|
-
}
|
|
130
|
-
if (typeof offer.priceSpecification?.typeOf !== 'string') {
|
|
131
|
-
throw new factory_1.factory.errors.NotFound('acceptedOffer.priceSpecification');
|
|
132
|
-
}
|
|
133
|
-
const priceComponent = [];
|
|
134
|
-
offer.priceSpecification.priceComponent.forEach((component) => {
|
|
135
|
-
if (typeof component.price === 'number') {
|
|
136
|
-
if (component.typeOf === factory_1.factory.priceSpecificationType.UnitPriceSpecification) {
|
|
137
|
-
const unitPriceComponent = {
|
|
138
|
-
accounting: component.accounting,
|
|
139
|
-
name: component.name,
|
|
140
|
-
price: component.price,
|
|
141
|
-
priceCurrency: component.priceCurrency,
|
|
142
|
-
referenceQuantity: component.referenceQuantity,
|
|
143
|
-
typeOf: component.typeOf,
|
|
144
|
-
valueAddedTaxIncluded: component.valueAddedTaxIncluded,
|
|
145
|
-
...(Array.isArray(component.appliesToAddOn))
|
|
146
|
-
? { appliesToAddOn: component.appliesToAddOn }
|
|
147
|
-
: undefined,
|
|
148
|
-
...(Array.isArray(component.appliesToMovieTicket))
|
|
149
|
-
? { appliesToMovieTicket: component.appliesToMovieTicket }
|
|
150
|
-
: undefined,
|
|
151
|
-
...(typeof component.accounting?.typeOf === 'string')
|
|
152
|
-
? {
|
|
153
|
-
accounting: {
|
|
154
|
-
typeOf: component.accounting.typeOf,
|
|
155
|
-
...(typeof component.accounting.accountsReceivable === 'number')
|
|
156
|
-
? { accountsReceivable: component.accounting.accountsReceivable }
|
|
157
|
-
: undefined,
|
|
158
|
-
...(typeof component.accounting.operatingRevenue?.typeOf === 'string')
|
|
159
|
-
? {
|
|
160
|
-
operatingRevenue: {
|
|
161
|
-
// project: component.accounting.operatingRevenue.project, // 削除(2023-12-13~)
|
|
162
|
-
typeOf: component.accounting.operatingRevenue.typeOf,
|
|
163
|
-
codeValue: component.accounting.operatingRevenue.codeValue
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
: undefined
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
: undefined
|
|
170
|
-
};
|
|
171
|
-
priceComponent.push(unitPriceComponent);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
priceComponent.push(component);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
const priceSpecification = {
|
|
179
|
-
typeOf: offer.priceSpecification.typeOf,
|
|
180
|
-
valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded,
|
|
181
|
-
priceCurrency: offer.priceSpecification.priceCurrency,
|
|
182
|
-
priceComponent
|
|
183
|
-
};
|
|
184
|
-
const permitAcceptedOffer = {
|
|
185
|
-
typeOf: responseBodyObject.typeOf,
|
|
186
|
-
id: offer.id,
|
|
187
|
-
// name: offer.name,
|
|
188
|
-
itemOffered,
|
|
189
|
-
priceSpecification,
|
|
190
|
-
serialNumber: params.responseBody.transactionNumber
|
|
191
|
-
};
|
|
192
|
-
return permitAcceptedOffer;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return acceptedOffers;
|
|
196
|
-
}
|
|
197
|
-
function createResult(params) {
|
|
198
|
-
const acceptedOffers4result = responseBody2resultAcceptedOffer(params);
|
|
199
|
-
// 金額計算
|
|
200
|
-
const amount = acceptedOffers2amount({ acceptedOffers: acceptedOffers4result });
|
|
201
|
-
return {
|
|
202
|
-
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
203
|
-
price: amount,
|
|
204
|
-
priceCurrency: factory_1.factory.priceCurrency.JPY,
|
|
205
|
-
// requestBody: params.requestBody, // discontinue(2026-03-13~)
|
|
206
|
-
// responseBody: params.responseBody // discontinue(2026-03-13~)
|
|
207
|
-
};
|
|
208
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.call = call;
|
|
4
|
-
const action_1 = require("../../repo/action");
|
|
5
|
-
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
6
|
-
const task_1 = require("../../repo/task");
|
|
7
|
-
const confirmRegisterServiceTransaction_1 = require("./confirmRegisterServiceTransaction");
|
|
8
|
-
/**
|
|
9
|
-
* タスク実行関数
|
|
10
|
-
*/
|
|
11
|
-
function call(data) {
|
|
12
|
-
return async ({ connection }) => {
|
|
13
|
-
await (0, confirmRegisterServiceTransaction_1.confirmRegisterServiceTransaction)(data)({
|
|
14
|
-
action: new action_1.ActionRepo(connection),
|
|
15
|
-
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
16
|
-
task: new task_1.TaskRepo(connection)
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IOperationExecute } from '../taskHandler';
|
|
2
|
-
import { factory } from '../../factory';
|
|
3
|
-
import { ActionRepo } from '../../repo/action';
|
|
4
|
-
import { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
|
-
import { TaskRepo } from '../../repo/task';
|
|
6
|
-
/**
|
|
7
|
-
* タスク実行関数
|
|
8
|
-
*/
|
|
9
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterServiceTransaction>): IOperationExecute<void>;
|
|
10
|
-
export declare function confirmRegisterServiceTransaction(params: factory.action.interact.confirm.registerService.IAttributes): (repos: {
|
|
11
|
-
action: ActionRepo;
|
|
12
|
-
assetTransaction: AssetTransactionRepo;
|
|
13
|
-
task: TaskRepo;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
export declare function onRegistered(params: factory.action.interact.confirm.registerService.IAttributes): (repos: {
|
|
16
|
-
task: TaskRepo;
|
|
17
|
-
}) => Promise<void>;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.call = call;
|
|
7
|
-
exports.confirmRegisterServiceTransaction = confirmRegisterServiceTransaction;
|
|
8
|
-
exports.onRegistered = onRegistered;
|
|
9
|
-
const moment_1 = __importDefault(require("moment"));
|
|
10
|
-
const factory_1 = require("../../factory");
|
|
11
|
-
const action_1 = require("../../repo/action");
|
|
12
|
-
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
13
|
-
const task_1 = require("../../repo/task");
|
|
14
|
-
const registerService_1 = require("../assetTransaction/registerService");
|
|
15
|
-
/**
|
|
16
|
-
* タスク実行関数
|
|
17
|
-
*/
|
|
18
|
-
function call(data) {
|
|
19
|
-
return async ({ connection }) => {
|
|
20
|
-
await confirmRegisterServiceTransaction(data)({
|
|
21
|
-
action: new action_1.ActionRepo(connection),
|
|
22
|
-
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
23
|
-
task: new task_1.TaskRepo(connection)
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function confirmRegisterServiceTransaction(params) {
|
|
28
|
-
return async (repos) => {
|
|
29
|
-
// アクション開始
|
|
30
|
-
const confirmActionAttributes = params;
|
|
31
|
-
const action = await repos.action.start(confirmActionAttributes);
|
|
32
|
-
try {
|
|
33
|
-
let transactionNumber;
|
|
34
|
-
const serviceOutputIdentifier = params.object.object?.itemOffered?.serviceOutput?.identifier;
|
|
35
|
-
if (typeof serviceOutputIdentifier === 'string') {
|
|
36
|
-
// serviceOutput.identifierで資産取引検索
|
|
37
|
-
const assetTransactions = await repos.assetTransaction.search({
|
|
38
|
-
limit: 1,
|
|
39
|
-
page: 1,
|
|
40
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
41
|
-
object: { itemOffered: { serviceOutput: { identifier: { $eq: serviceOutputIdentifier } } } }
|
|
42
|
-
});
|
|
43
|
-
const assetTransaction = assetTransactions.shift();
|
|
44
|
-
if (assetTransaction === undefined) {
|
|
45
|
-
throw new factory_1.factory.errors.NotFound('AssetTransaction', `AssetTransaction with serviceOutputIdentifier '${serviceOutputIdentifier}' not found`);
|
|
46
|
-
}
|
|
47
|
-
transactionNumber = assetTransaction.transactionNumber;
|
|
48
|
-
}
|
|
49
|
-
else if (typeof params.object.transactionNumber === 'string') {
|
|
50
|
-
transactionNumber = params.object.transactionNumber;
|
|
51
|
-
}
|
|
52
|
-
if (typeof transactionNumber === 'string') {
|
|
53
|
-
await (0, registerService_1.confirm)({
|
|
54
|
-
transactionNumber,
|
|
55
|
-
...(confirmActionAttributes.object.endDate !== undefined)
|
|
56
|
-
? {
|
|
57
|
-
endDate: (0, moment_1.default)(confirmActionAttributes.object.endDate)
|
|
58
|
-
.toDate()
|
|
59
|
-
}
|
|
60
|
-
: undefined
|
|
61
|
-
})(repos);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
throw new factory_1.factory.errors.Argument('transactionNumber not specified');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
try {
|
|
69
|
-
await repos.action.giveUp({ typeOf: confirmActionAttributes.typeOf, id: action.id, error });
|
|
70
|
-
}
|
|
71
|
-
catch (__) {
|
|
72
|
-
// 失敗したら仕方ない
|
|
73
|
-
}
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
// アクション完了
|
|
77
|
-
const result = {};
|
|
78
|
-
await repos.action.completeWithVoid({ typeOf: confirmActionAttributes.typeOf, id: action.id, result: result });
|
|
79
|
-
await onRegistered(confirmActionAttributes)(repos);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function onRegistered(params) {
|
|
83
|
-
return async (repos) => {
|
|
84
|
-
const taskAttributes = [];
|
|
85
|
-
// タスク保管
|
|
86
|
-
await repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
87
|
-
if (params.purpose.typeOf === factory_1.factory.order.OrderType.Order) {
|
|
88
|
-
// タスク冪等作成
|
|
89
|
-
const onAssetTransactionStatusChangedTaskData = {
|
|
90
|
-
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
91
|
-
object: {
|
|
92
|
-
typeOf: params.object.typeOf,
|
|
93
|
-
transactionNumber: params.object.transactionNumber,
|
|
94
|
-
status: factory_1.factory.transactionStatusType.Confirmed
|
|
95
|
-
},
|
|
96
|
-
purpose: {
|
|
97
|
-
confirmationNumber: '', // OnAssetTransactionStatusChanged処理内で使用されないので空文字でok
|
|
98
|
-
orderNumber: params.purpose.orderNumber,
|
|
99
|
-
typeOf: factory_1.factory.order.OrderType.Order
|
|
100
|
-
},
|
|
101
|
-
useOnOrderStatusChanged: true
|
|
102
|
-
};
|
|
103
|
-
const onAssetTransactionStatusChangedTask = {
|
|
104
|
-
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
105
|
-
name: factory_1.factory.taskName.OnAssetTransactionStatusChanged,
|
|
106
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
107
|
-
runsAt: new Date(),
|
|
108
|
-
remainingNumberOfTries: 10,
|
|
109
|
-
numberOfTried: 0,
|
|
110
|
-
executionResults: [],
|
|
111
|
-
data: onAssetTransactionStatusChangedTaskData
|
|
112
|
-
};
|
|
113
|
-
await repos.task.createOnAssetTransactionStatusChangedTaskIfNotExist(onAssetTransactionStatusChangedTask, { emitImmediately: true });
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.call = call;
|
|
4
|
-
// import { ActionRepo } from '../../repo/action';
|
|
5
|
-
const authorizeProductOffer_1 = require("../../repo/action/authorizeProductOffer");
|
|
6
|
-
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
7
|
-
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
8
|
-
const product_1 = require("../offer/product");
|
|
9
|
-
/**
|
|
10
|
-
* タスク実行関数
|
|
11
|
-
*/
|
|
12
|
-
function call(data) {
|
|
13
|
-
return async ({ connection }) => {
|
|
14
|
-
// const actionRepo = new ActionRepo(connection);
|
|
15
|
-
const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
|
|
16
|
-
const placeOrderRepo = new placeOrder_1.PlaceOrderRepo(connection);
|
|
17
|
-
await (0, product_1.voidTransaction)(data)({
|
|
18
|
-
authorizeProductOfferAction: new authorizeProductOffer_1.AuthorizeProductOfferActionRepo(connection),
|
|
19
|
-
assetTransaction: assetTransactionRepo,
|
|
20
|
-
placeOrder: placeOrderRepo
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../../../factory';
|
|
2
|
-
/**
|
|
3
|
-
* ポイント特典返却アクションを作成する
|
|
4
|
-
*/
|
|
5
|
-
export declare function createReturnPointAwardActions(params: {
|
|
6
|
-
order: Pick<factory.order.IOrder, 'identifier' | 'project' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'seller' | 'typeOf'>;
|
|
7
|
-
potentialActions?: factory.transaction.returnOrder.IPotentialActionsParams;
|
|
8
|
-
}): Promise<factory.action.transfer.returnAction.pointAward.IAttributes[]>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createReturnPointAwardActions = createReturnPointAwardActions;
|
|
4
|
-
const factory_1 = require("../../../../factory");
|
|
5
|
-
const order_1 = require("../../../../factory/order");
|
|
6
|
-
/**
|
|
7
|
-
* ポイント特典返却アクションを作成する
|
|
8
|
-
*/
|
|
9
|
-
async function createReturnPointAwardActions(params) {
|
|
10
|
-
const returnPointAwardActions = [];
|
|
11
|
-
// 入金識別子はorder.identifierに保管されている
|
|
12
|
-
let pointAwardIdentifiers = [];
|
|
13
|
-
const pointAwardIdentifierStr = params.order.identifier?.find((i) => i.name === order_1.POINT_AWARD_IDENTIFIER_NAME)?.value;
|
|
14
|
-
if (typeof pointAwardIdentifierStr === 'string') {
|
|
15
|
-
try {
|
|
16
|
-
pointAwardIdentifiers = JSON.parse(pointAwardIdentifierStr);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
console.error('JSON.parse(pointAwardIdentifierStr) throws', error);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// 注文口座番号はorder.identifierに保管されている
|
|
23
|
-
let awardAccountIdentifiers = [];
|
|
24
|
-
const awardAccountsStr = params.order.identifier?.find((i) => i.name === order_1.AWARD_ACCOUNTS_IDENTIFIER_NAME)?.value;
|
|
25
|
-
if (typeof awardAccountsStr === 'string') {
|
|
26
|
-
try {
|
|
27
|
-
const awardAccounts = JSON.parse(awardAccountsStr);
|
|
28
|
-
if (Array.isArray(awardAccounts)) {
|
|
29
|
-
awardAccountIdentifiers = awardAccounts.map((a) => a.accountNumber);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error('JSON.parse(awardAccountsStr) throws', error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const order = params.order;
|
|
37
|
-
// const maskedCustomer = createMaskedCustomer(order, { noProfile: true });
|
|
38
|
-
const purpose = {
|
|
39
|
-
typeOf: order.typeOf,
|
|
40
|
-
// seller: {
|
|
41
|
-
// id: order.seller.id,
|
|
42
|
-
// typeOf: order.seller.typeOf,
|
|
43
|
-
// name: order.seller.name
|
|
44
|
-
// }, // 廃止(2024-03-06~)
|
|
45
|
-
// mask
|
|
46
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
47
|
-
orderNumber: order.orderNumber,
|
|
48
|
-
// price: order.price,
|
|
49
|
-
// priceCurrency: order.priceCurrency,
|
|
50
|
-
orderDate: order.orderDate
|
|
51
|
-
};
|
|
52
|
-
const agent = order.project;
|
|
53
|
-
const recipient = {
|
|
54
|
-
typeOf: order.seller.typeOf,
|
|
55
|
-
id: order.seller.id,
|
|
56
|
-
name: order.seller.name
|
|
57
|
-
};
|
|
58
|
-
// ポイントインセンティブの数だけ、返却アクションを作成
|
|
59
|
-
returnPointAwardActions.push(...pointAwardIdentifiers.map((pointAwardIdentifier) => {
|
|
60
|
-
return {
|
|
61
|
-
project: order.project,
|
|
62
|
-
typeOf: factory_1.factory.actionType.ReturnAction,
|
|
63
|
-
object: {
|
|
64
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
65
|
-
identifier: pointAwardIdentifier
|
|
66
|
-
},
|
|
67
|
-
agent,
|
|
68
|
-
potentialActions: {},
|
|
69
|
-
purpose,
|
|
70
|
-
recipient
|
|
71
|
-
};
|
|
72
|
-
}));
|
|
73
|
-
// 注文口座の数だけ、返却アクションを作成
|
|
74
|
-
returnPointAwardActions.push(...awardAccountIdentifiers.map((awardAccountIdentifier) => {
|
|
75
|
-
return {
|
|
76
|
-
project: order.project,
|
|
77
|
-
typeOf: factory_1.factory.actionType.ReturnAction,
|
|
78
|
-
object: {
|
|
79
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
80
|
-
object: { fromLocation: { identifier: awardAccountIdentifier } }
|
|
81
|
-
},
|
|
82
|
-
agent,
|
|
83
|
-
potentialActions: {},
|
|
84
|
-
purpose,
|
|
85
|
-
recipient
|
|
86
|
-
};
|
|
87
|
-
}));
|
|
88
|
-
return returnPointAwardActions;
|
|
89
|
-
}
|