@chevre/domain 24.0.0-alpha.74 → 24.0.0-alpha.76
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/index.d.ts +0 -2
- package/lib/chevre/index.js +0 -8
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +5 -5
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -1
- package/lib/chevre/service/assetTransaction/registerService.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/registerService.js +2 -55
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +35 -69
- package/lib/chevre/service/assetTransaction/reserve/start.js +18 -85
- package/lib/chevre/service/assetTransaction.d.ts +0 -2
- package/lib/chevre/service/assetTransaction.js +1 -10
- package/lib/chevre/service/task/payment/payByTask.js +4 -4
- package/lib/chevre/service/task/payment/refundByTask.js +4 -4
- package/lib/chevre/service/task/payment/voidPaymentByTask.js +4 -4
- package/lib/chevre/service/taskHandler.d.ts +6 -1
- package/lib/chevre/service/taskHandler.js +10 -1
- package/lib/chevre/service.d.ts +0 -4
- package/lib/chevre/service.js +1 -21
- package/package.json +1 -3
- package/lib/chevre/pecorinoapi.d.ts +0 -5
- package/lib/chevre/pecorinoapi.js +0 -9
- package/lib/chevre/service/assetTransaction/moneyTransfer/potentialActions.d.ts +0 -7
- package/lib/chevre/service/assetTransaction/moneyTransfer/potentialActions.js +0 -104
- package/lib/chevre/service/assetTransaction/moneyTransfer.d.ts +0 -51
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +0 -444
- package/lib/chevre/service/assetTransaction/pay/start/account/validation.d.ts +0 -8
- package/lib/chevre/service/assetTransaction/pay/start/account/validation.js +0 -43
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +0 -13
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +0 -72
- package/lib/chevre/service/delivery.d.ts +0 -27
- package/lib/chevre/service/delivery.js +0 -315
- package/lib/chevre/service/moneyTransfer.d.ts +0 -76
- package/lib/chevre/service/moneyTransfer.js +0 -669
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -42
- package/lib/chevre/service/payment/paymentCard.js +0 -452
- package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +0 -6
- package/lib/chevre/service/task/cancelMoneyTransfer.js +0 -19
- package/lib/chevre/service/task/givePointAward.d.ts +0 -6
- package/lib/chevre/service/task/givePointAward.js +0 -65
- package/lib/chevre/service/task/moneyTransfer.d.ts +0 -6
- package/lib/chevre/service/task/moneyTransfer.js +0 -59
- package/lib/chevre/service/task/returnPointAward.d.ts +0 -6
- package/lib/chevre/service/task/returnPointAward.js +0 -65
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAccount = validateAccount;
|
|
4
|
-
const factory_1 = require("../../../../../factory");
|
|
5
|
-
function validateAccount(params) {
|
|
6
|
-
return async (repos) => {
|
|
7
|
-
// 引き出し口座の存在を確認する
|
|
8
|
-
const paymentMethodType = params.object.paymentMethod?.identifier;
|
|
9
|
-
if (typeof paymentMethodType !== 'string') {
|
|
10
|
-
throw new factory_1.factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
11
|
-
}
|
|
12
|
-
const accountNumber = params.object.paymentMethod?.accountId;
|
|
13
|
-
if (typeof accountNumber !== 'string') {
|
|
14
|
-
throw new factory_1.factory.errors.ArgumentNull('object.paymentMethod.accountId');
|
|
15
|
-
}
|
|
16
|
-
// 販売者から決済情報取得
|
|
17
|
-
const sellerId = params.recipient?.id;
|
|
18
|
-
if (typeof sellerId !== 'string') {
|
|
19
|
-
throw new factory_1.factory.errors.ArgumentNull('recipient.id');
|
|
20
|
-
}
|
|
21
|
-
// const sellers = <Pick<factory.seller.ISeller, 'paymentAccepted'>[]>await repos.seller.search(
|
|
22
|
-
// {
|
|
23
|
-
// limit: 1,
|
|
24
|
-
// page: 1,
|
|
25
|
-
// id: { $eq: sellerId }
|
|
26
|
-
// },
|
|
27
|
-
// ['paymentAccepted'],
|
|
28
|
-
// []
|
|
29
|
-
// );
|
|
30
|
-
// const seller = sellers.shift();
|
|
31
|
-
// if (seller === undefined) {
|
|
32
|
-
// throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
33
|
-
// }
|
|
34
|
-
// const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === paymentMethodType);
|
|
35
|
-
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
36
|
-
seller: { id: sellerId },
|
|
37
|
-
codeValue: paymentMethodType
|
|
38
|
-
});
|
|
39
|
-
if (paymentAccepted !== true) {
|
|
40
|
-
throw new factory_1.factory.errors.Argument('recipient', `payment not accepted [${paymentMethodType}]`);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../../../factory';
|
|
2
|
-
import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
|
|
3
|
-
import type { EventRepo } from '../../../../repo/event';
|
|
4
|
-
import type { ProductRepo } from '../../../../repo/product';
|
|
5
|
-
import type { SellerPaymentAcceptedRepo } from '../../../../repo/sellerPaymentAccepted';
|
|
6
|
-
export declare function processAuthorizeAccount(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: {
|
|
7
|
-
id: string;
|
|
8
|
-
}, paymentServiceId: string): (repos: {
|
|
9
|
-
event: EventRepo;
|
|
10
|
-
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
11
|
-
product: ProductRepo;
|
|
12
|
-
assetTransaction: AssetTransactionRepo;
|
|
13
|
-
}) => Promise<factory.assetTransaction.pay.ITransaction>;
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.processAuthorizeAccount = processAuthorizeAccount;
|
|
37
|
-
const factory_1 = require("../../../../factory");
|
|
38
|
-
const PaymentCardPayment = __importStar(require("../../../payment/paymentCard"));
|
|
39
|
-
const validation_1 = require("./account/validation");
|
|
40
|
-
function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
41
|
-
return async (repos) => {
|
|
42
|
-
const amount = params.object.paymentMethod?.amount;
|
|
43
|
-
if (typeof amount !== 'number') {
|
|
44
|
-
throw new factory_1.factory.errors.ArgumentNull('object.paymentMethod?.amount');
|
|
45
|
-
}
|
|
46
|
-
await (0, validation_1.validateAccount)(params)(repos);
|
|
47
|
-
const { pendingTransaction, currency, accountNumber } = await PaymentCardPayment.authorize(params, paymentServiceId)(repos);
|
|
48
|
-
const totalPaymentDue = {
|
|
49
|
-
typeOf: 'MonetaryAmount',
|
|
50
|
-
currency,
|
|
51
|
-
value: amount
|
|
52
|
-
};
|
|
53
|
-
const savingPendingTransaction = {
|
|
54
|
-
typeOf: pendingTransaction.typeOf,
|
|
55
|
-
id: pendingTransaction.id,
|
|
56
|
-
transactionNumber: pendingTransaction.transactionNumber,
|
|
57
|
-
object: { fromLocation: { accountNumber } }
|
|
58
|
-
};
|
|
59
|
-
return saveAuthorizeResult({
|
|
60
|
-
id: transaction.id,
|
|
61
|
-
update: {
|
|
62
|
-
'object.paymentMethod.totalPaymentDue': totalPaymentDue,
|
|
63
|
-
'object.pendingTransaction': savingPendingTransaction
|
|
64
|
-
}
|
|
65
|
-
})(repos);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function saveAuthorizeResult(params) {
|
|
69
|
-
return async (repos) => {
|
|
70
|
-
return repos.assetTransaction.findByIdAndUpdateInProgress(params);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { factory } from '../factory';
|
|
2
|
-
import type { ActionRepo } from '../repo/action';
|
|
3
|
-
import type { AssetTransactionRepo } from '../repo/assetTransaction';
|
|
4
|
-
import type { ProductRepo } from '../repo/product';
|
|
5
|
-
import type { ProjectRepo } from '../repo/project';
|
|
6
|
-
import type { TransactionNumberRepo } from '../repo/transactionNumber';
|
|
7
|
-
/**
|
|
8
|
-
* 特典付与
|
|
9
|
-
*/
|
|
10
|
-
declare function givePointAward(params: factory.task.IData<factory.taskName.GivePointAward>): (repos: {
|
|
11
|
-
action: ActionRepo;
|
|
12
|
-
assetTransaction: AssetTransactionRepo;
|
|
13
|
-
product: ProductRepo;
|
|
14
|
-
project: ProjectRepo;
|
|
15
|
-
transactionNumber: TransactionNumberRepo;
|
|
16
|
-
}) => Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* 特典返却
|
|
19
|
-
*/
|
|
20
|
-
declare function returnPointAward(params: factory.task.IData<factory.taskName.ReturnPointAward>): (repos: {
|
|
21
|
-
action: ActionRepo;
|
|
22
|
-
assetTransaction: AssetTransactionRepo;
|
|
23
|
-
product: ProductRepo;
|
|
24
|
-
project: ProjectRepo;
|
|
25
|
-
transactionNumber: TransactionNumberRepo;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
export { givePointAward, returnPointAward };
|
|
@@ -1,315 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.givePointAward = givePointAward;
|
|
40
|
-
exports.returnPointAward = returnPointAward;
|
|
41
|
-
/**
|
|
42
|
-
* 配送サービス
|
|
43
|
-
* ここでいう「配送」とは、「エンドユーザーが獲得した所有権を利用可能な状態にすること」を指します。
|
|
44
|
-
* 物理的なモノの配送だけに限らず、
|
|
45
|
-
* 所有権コードを発行できること
|
|
46
|
-
* 特典が口座に振り込まれること
|
|
47
|
-
* などが配送処理として考えられます。
|
|
48
|
-
*/
|
|
49
|
-
const moment_1 = __importDefault(require("moment"));
|
|
50
|
-
const factory_1 = require("../factory");
|
|
51
|
-
const MoneyTransferAssetTransactionService = __importStar(require("./assetTransaction/moneyTransfer"));
|
|
52
|
-
const accountTransactionIdentifier_1 = require("../factory/accountTransactionIdentifier");
|
|
53
|
-
/**
|
|
54
|
-
* 特典付与
|
|
55
|
-
*/
|
|
56
|
-
function givePointAward(params) {
|
|
57
|
-
return async (repos) => {
|
|
58
|
-
// 入金識別子が存在する場合、冪等性の確保(2023-08-24~)
|
|
59
|
-
const pendingTransactionIdentifier = params.object.identifier;
|
|
60
|
-
if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
|
|
61
|
-
// すでにConfirmedのMoneyTransfer取引が存在すれば何もしない
|
|
62
|
-
const assetTransactions = await repos.assetTransaction.search({
|
|
63
|
-
limit: 1,
|
|
64
|
-
project: { id: { $eq: params.project.id } },
|
|
65
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
66
|
-
statuses: [factory_1.factory.transactionStatusType.Confirmed],
|
|
67
|
-
object: {
|
|
68
|
-
pendingTransaction: { identifier: { $eq: pendingTransactionIdentifier } }
|
|
69
|
-
}
|
|
70
|
-
}, ['_id']);
|
|
71
|
-
if (assetTransactions.length > 0) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// アクション開始
|
|
76
|
-
const action = await repos.action.start(params);
|
|
77
|
-
try {
|
|
78
|
-
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
79
|
-
const startParams = createGivePointAwardStartParams4moneyTransfer(params, transactionNumber);
|
|
80
|
-
await MoneyTransferAssetTransactionService.start(startParams)(repos);
|
|
81
|
-
await MoneyTransferAssetTransactionService.confirm({ transactionNumber })(repos);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
try {
|
|
85
|
-
await repos.action.giveUp({ typeOf: params.typeOf, id: action.id, error });
|
|
86
|
-
}
|
|
87
|
-
catch (__) {
|
|
88
|
-
// 失敗したら仕方ない
|
|
89
|
-
}
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
// アクション完了
|
|
93
|
-
const actionResult = {};
|
|
94
|
-
await repos.action.completeWithVoid({ typeOf: params.typeOf, id: action.id, result: actionResult });
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function createGivePointAwardStartParams4moneyTransfer(params, transactionNumber) {
|
|
98
|
-
// Sellerに変更(2022-05-30~)
|
|
99
|
-
const agent = {
|
|
100
|
-
typeOf: params.agent.typeOf,
|
|
101
|
-
id: params.agent.id,
|
|
102
|
-
name: String(params.agent.name)
|
|
103
|
-
};
|
|
104
|
-
const recipient = {
|
|
105
|
-
typeOf: params.recipient.typeOf,
|
|
106
|
-
id: params.recipient.id,
|
|
107
|
-
name: String(params.recipient.name)
|
|
108
|
-
};
|
|
109
|
-
const toLocation = {
|
|
110
|
-
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
111
|
-
identifier: params.object.toLocation.accountNumber,
|
|
112
|
-
issuedThrough: { id: params.object.toLocation.issuedThrough?.id },
|
|
113
|
-
hasNoPermit: false // Permitが存在するはず
|
|
114
|
-
};
|
|
115
|
-
return {
|
|
116
|
-
transactionNumber: transactionNumber,
|
|
117
|
-
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
118
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
119
|
-
agent: agent,
|
|
120
|
-
expires: (0, moment_1.default)()
|
|
121
|
-
.add(1, 'minutes')
|
|
122
|
-
.toDate(),
|
|
123
|
-
recipient: recipient,
|
|
124
|
-
object: {
|
|
125
|
-
amount: {
|
|
126
|
-
typeOf: 'MonetaryAmount',
|
|
127
|
-
value: params.object.amount,
|
|
128
|
-
currency: '' // サーバーサイドで自動取得される
|
|
129
|
-
},
|
|
130
|
-
description: (typeof params.object.description === 'string')
|
|
131
|
-
? params.object.description
|
|
132
|
-
: params.purpose.typeOf,
|
|
133
|
-
fromLocation: agent,
|
|
134
|
-
toLocation,
|
|
135
|
-
pendingTransaction: {
|
|
136
|
-
typeOf: factory_1.factory.account.transactionType.Deposit,
|
|
137
|
-
transactionNumber
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
// ユニークネスを保証するために識別子を指定する
|
|
141
|
-
...(typeof params.object.identifier === 'string') ? { identifier: params.object.identifier } : undefined
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 特典返却
|
|
146
|
-
*/
|
|
147
|
-
function returnPointAward(params) {
|
|
148
|
-
return async (repos) => {
|
|
149
|
-
// アクション開始
|
|
150
|
-
const moneyTransferTransactions = [];
|
|
151
|
-
const action = await repos.action.start(params);
|
|
152
|
-
try {
|
|
153
|
-
const moenyTransferAssetTransactionIdentifier = params.object.identifier;
|
|
154
|
-
const moenyTransferAssetTransactionFromLocationIdentifier = params.object
|
|
155
|
-
.object?.fromLocation?.identifier;
|
|
156
|
-
if (typeof moenyTransferAssetTransactionIdentifier === 'string') {
|
|
157
|
-
moneyTransferTransactions.push(await processReturnPointAwardByTransactionIdentifier(params)(repos));
|
|
158
|
-
}
|
|
159
|
-
if (typeof moenyTransferAssetTransactionFromLocationIdentifier === 'string') {
|
|
160
|
-
moneyTransferTransactions.push(...await processReturnPointAwardByTransactionFromLocationIdentifier(params)(repos));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
try {
|
|
165
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
166
|
-
}
|
|
167
|
-
catch (__) {
|
|
168
|
-
// 失敗したら仕方ない
|
|
169
|
-
}
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
// アクション完了
|
|
173
|
-
const actionResult = {
|
|
174
|
-
moneyTransferTransaction: moneyTransferTransactions
|
|
175
|
-
};
|
|
176
|
-
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function processReturnPointAwardByTransactionIdentifier(params) {
|
|
180
|
-
return async (repos) => {
|
|
181
|
-
let moneyTransferTransaction;
|
|
182
|
-
const moenyTransferAssetTransactionIdentifier = params.object.identifier;
|
|
183
|
-
const assetTransactions = await repos.assetTransaction.search({
|
|
184
|
-
limit: 1,
|
|
185
|
-
project: { id: { $eq: params.project.id } },
|
|
186
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
187
|
-
statuses: [factory_1.factory.transactionStatusType.Confirmed],
|
|
188
|
-
object: {
|
|
189
|
-
pendingTransaction: { identifier: { $eq: moenyTransferAssetTransactionIdentifier } }
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
// 資産取引が存在すれば、出金取引を実行
|
|
193
|
-
const depositTransaction = assetTransactions.shift();
|
|
194
|
-
if (depositTransaction !== undefined) {
|
|
195
|
-
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
196
|
-
// 冪等性の確保
|
|
197
|
-
// 入金時の資産取引に対して一意な識別子をMoneyTransfer資産取引指定する
|
|
198
|
-
const identifier2withdrawAssetTransaction = (0, accountTransactionIdentifier_1.createReturnPointAwardIdentifier)({
|
|
199
|
-
project: { id: params.project.id },
|
|
200
|
-
accountTransaction4givePointAward: { transactionNumber: depositTransaction.transactionNumber }
|
|
201
|
-
});
|
|
202
|
-
const fromLocation = {
|
|
203
|
-
typeOf: depositTransaction.object.toLocation.typeOf,
|
|
204
|
-
identifier: depositTransaction.object.toLocation.identifier,
|
|
205
|
-
issuedThrough: depositTransaction.object.toLocation.issuedThrough,
|
|
206
|
-
hasNoPermit: false // Permitが存在するはず
|
|
207
|
-
};
|
|
208
|
-
moneyTransferTransaction = await MoneyTransferAssetTransactionService.start({
|
|
209
|
-
transactionNumber: transactionNumber,
|
|
210
|
-
identifier: identifier2withdrawAssetTransaction,
|
|
211
|
-
project: depositTransaction.project,
|
|
212
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
213
|
-
expires: (0, moment_1.default)()
|
|
214
|
-
.add(1, 'minute')
|
|
215
|
-
.toDate(),
|
|
216
|
-
// Sellerに変更(2022-05-30~)
|
|
217
|
-
agent: {
|
|
218
|
-
typeOf: params.recipient.typeOf,
|
|
219
|
-
id: params.recipient.id,
|
|
220
|
-
name: String(params.recipient.name)
|
|
221
|
-
},
|
|
222
|
-
recipient: depositTransaction.agent, // 入金と逆
|
|
223
|
-
object: {
|
|
224
|
-
amount: depositTransaction.object.amount,
|
|
225
|
-
fromLocation,
|
|
226
|
-
toLocation: depositTransaction.object.fromLocation,
|
|
227
|
-
description: `[Return Award]${depositTransaction.object.description}`,
|
|
228
|
-
pendingTransaction: {
|
|
229
|
-
typeOf: factory_1.factory.account.transactionType.Withdraw,
|
|
230
|
-
transactionNumber
|
|
231
|
-
},
|
|
232
|
-
force: true
|
|
233
|
-
}
|
|
234
|
-
})(repos);
|
|
235
|
-
await MoneyTransferAssetTransactionService.confirm({ transactionNumber })(repos);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
throw new factory_1.factory.errors.NotFound('AssetTransaction', `Deposit transaction '${moenyTransferAssetTransactionIdentifier}' not found`);
|
|
239
|
-
}
|
|
240
|
-
return moneyTransferTransaction;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function processReturnPointAwardByTransactionFromLocationIdentifier(params) {
|
|
244
|
-
return async (repos) => {
|
|
245
|
-
const moneyTransferTransactions = [];
|
|
246
|
-
const moenyTransferAssetTransactionFromLocationIdentifier = params.object
|
|
247
|
-
.object?.fromLocation?.identifier;
|
|
248
|
-
const assetTransactions = await repos.assetTransaction.search({
|
|
249
|
-
// limit: 100,
|
|
250
|
-
project: { id: { $eq: params.project.id } },
|
|
251
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
252
|
-
statuses: [factory_1.factory.transactionStatusType.Confirmed],
|
|
253
|
-
object: {
|
|
254
|
-
fromLocation: { identifier: { $eq: moenyTransferAssetTransactionFromLocationIdentifier } }
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
// 資産取引が存在すれば、逆の取引を実行
|
|
258
|
-
if (assetTransactions.length > 0) {
|
|
259
|
-
// 返却対象取引はTransfer取引(注文口座→Permit)のはず
|
|
260
|
-
const returningTransactions = assetTransactions.filter((d) => d.object.pendingTransaction?.typeOf === factory_1.factory.account.transactionType.Transfer);
|
|
261
|
-
for (const returningTransaction of returningTransactions) {
|
|
262
|
-
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
263
|
-
// 冪等性の確保
|
|
264
|
-
// 入金時の資産取引に対して一意な識別子をMoneyTransfer資産取引指定する
|
|
265
|
-
const identifier2withdrawAssetTransaction = (0, accountTransactionIdentifier_1.createReturnPointAwardIdentifier)({
|
|
266
|
-
project: { id: params.project.id },
|
|
267
|
-
accountTransaction4givePointAward: { transactionNumber: returningTransaction.transactionNumber }
|
|
268
|
-
});
|
|
269
|
-
const fromLocation = {
|
|
270
|
-
typeOf: returningTransaction.object.toLocation.typeOf,
|
|
271
|
-
identifier: returningTransaction.object.toLocation.identifier,
|
|
272
|
-
issuedThrough: returningTransaction.object.toLocation.issuedThrough,
|
|
273
|
-
hasNoPermit: false // Permitが存在するはず
|
|
274
|
-
};
|
|
275
|
-
const toLocation = {
|
|
276
|
-
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
277
|
-
identifier: moenyTransferAssetTransactionFromLocationIdentifier,
|
|
278
|
-
// ↓指定しないとPermitのチェックが実行される(注文口座にはPermitが存在しない)
|
|
279
|
-
hasNoPermit: true,
|
|
280
|
-
issuedThrough: { id: fromLocation.issuedThrough.id }
|
|
281
|
-
};
|
|
282
|
-
const moneyTransferTransaction = await MoneyTransferAssetTransactionService.start({
|
|
283
|
-
transactionNumber: transactionNumber,
|
|
284
|
-
identifier: identifier2withdrawAssetTransaction,
|
|
285
|
-
project: returningTransaction.project,
|
|
286
|
-
typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
|
|
287
|
-
expires: (0, moment_1.default)()
|
|
288
|
-
.add(1, 'minute')
|
|
289
|
-
.toDate(),
|
|
290
|
-
// Sellerに変更(2022-05-30~)
|
|
291
|
-
agent: {
|
|
292
|
-
typeOf: params.recipient.typeOf,
|
|
293
|
-
id: params.recipient.id,
|
|
294
|
-
name: String(params.recipient.name)
|
|
295
|
-
},
|
|
296
|
-
recipient: returningTransaction.agent, // 入金と逆
|
|
297
|
-
object: {
|
|
298
|
-
amount: returningTransaction.object.amount,
|
|
299
|
-
fromLocation,
|
|
300
|
-
toLocation,
|
|
301
|
-
description: `[Return Award]${returningTransaction.object.description}`,
|
|
302
|
-
pendingTransaction: {
|
|
303
|
-
typeOf: factory_1.factory.account.transactionType.Transfer,
|
|
304
|
-
transactionNumber
|
|
305
|
-
},
|
|
306
|
-
force: true
|
|
307
|
-
}
|
|
308
|
-
})(repos);
|
|
309
|
-
await MoneyTransferAssetTransactionService.confirm({ transactionNumber })(repos);
|
|
310
|
-
moneyTransferTransactions.push(moneyTransferTransaction);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return moneyTransferTransactions;
|
|
314
|
-
};
|
|
315
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { factory } from '../factory';
|
|
2
|
-
import type { ActionRepo } from '../repo/action';
|
|
3
|
-
import type { AssetTransactionRepo } from '../repo/assetTransaction';
|
|
4
|
-
import type { ProductRepo } from '../repo/product';
|
|
5
|
-
import type { ProjectRepo } from '../repo/project';
|
|
6
|
-
import type { TransactionNumberRepo } from '../repo/transactionNumber';
|
|
7
|
-
export type IAuthorizeOperation<T> = (repos: {
|
|
8
|
-
product: ProductRepo;
|
|
9
|
-
project: ProjectRepo;
|
|
10
|
-
assetTransaction: AssetTransactionRepo;
|
|
11
|
-
}) => Promise<T>;
|
|
12
|
-
export interface IObject {
|
|
13
|
-
amount: number;
|
|
14
|
-
description?: string;
|
|
15
|
-
fromLocation: {
|
|
16
|
-
identifier?: string;
|
|
17
|
-
hasNoPermit?: boolean;
|
|
18
|
-
issuedThrough?: {
|
|
19
|
-
/**
|
|
20
|
-
* カード発行サービスID
|
|
21
|
-
*/
|
|
22
|
-
id: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
toLocation: {
|
|
26
|
-
identifier?: string;
|
|
27
|
-
hasNoPermit?: boolean;
|
|
28
|
-
issuedThrough?: {
|
|
29
|
-
/**
|
|
30
|
-
* カード発行サービスID
|
|
31
|
-
*/
|
|
32
|
-
id: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
force: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 口座残高差し押さえ
|
|
39
|
-
*/
|
|
40
|
-
export declare function authorize(params: {
|
|
41
|
-
typeOf: factory.account.transactionType;
|
|
42
|
-
identifier?: string;
|
|
43
|
-
transactionNumber: string;
|
|
44
|
-
project: {
|
|
45
|
-
id: string;
|
|
46
|
-
typeOf: factory.organizationType.Project;
|
|
47
|
-
};
|
|
48
|
-
agent: factory.action.transfer.moneyTransfer.IAgent;
|
|
49
|
-
object: IObject;
|
|
50
|
-
recipient: factory.action.transfer.moneyTransfer.IRecipient;
|
|
51
|
-
purpose: {
|
|
52
|
-
typeOf: factory.assetTransactionType;
|
|
53
|
-
id: string;
|
|
54
|
-
};
|
|
55
|
-
}): IAuthorizeOperation<void>;
|
|
56
|
-
/**
|
|
57
|
-
* 口座承認取消
|
|
58
|
-
*/
|
|
59
|
-
export declare function cancelMoneyTransfer(params: {
|
|
60
|
-
purpose: {
|
|
61
|
-
typeOf: factory.assetTransactionType;
|
|
62
|
-
id: string;
|
|
63
|
-
};
|
|
64
|
-
}): (repos: {
|
|
65
|
-
product: ProductRepo;
|
|
66
|
-
assetTransaction: AssetTransactionRepo;
|
|
67
|
-
}) => Promise<void>;
|
|
68
|
-
export declare function moneyTransfer(params: factory.task.moneyTransfer.IData): (repos: {
|
|
69
|
-
action: ActionRepo;
|
|
70
|
-
product: ProductRepo;
|
|
71
|
-
transactionNumber: TransactionNumberRepo;
|
|
72
|
-
}) => Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* 返金後のアクション
|
|
75
|
-
* @param refundActionAttributes 返金アクション属性
|
|
76
|
-
*/
|