@chevre/domain 21.35.0-alpha.2 → 21.35.0-alpha.3
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.
|
@@ -48,19 +48,17 @@ exports.call = call;
|
|
|
48
48
|
function returnPayTransaction(params) {
|
|
49
49
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
var _a;
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const returnOrderTransactions = yield repos.transaction.search({
|
|
51
|
+
const orderNumber = params.purpose.orderNumber;
|
|
52
|
+
const returnOrderTransaction = (yield repos.transaction.search({
|
|
54
53
|
limit: 1,
|
|
55
54
|
page: 1,
|
|
56
55
|
typeOf: factory.transactionType.ReturnOrder,
|
|
57
56
|
object: { order: { orderNumbers: [orderNumber] } },
|
|
58
|
-
inclusion: [],
|
|
57
|
+
inclusion: ['object', 'project'],
|
|
59
58
|
exclusion: []
|
|
60
|
-
});
|
|
61
|
-
const returnOrderTransaction = returnOrderTransactions.shift();
|
|
59
|
+
})).shift();
|
|
62
60
|
if (returnOrderTransaction === undefined) {
|
|
63
|
-
throw new factory.errors.NotFound(
|
|
61
|
+
throw new factory.errors.NotFound(factory.transactionType.ReturnOrder);
|
|
64
62
|
}
|
|
65
63
|
const paymentServiceType = (_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
66
64
|
if (typeof paymentServiceType !== 'string' || paymentServiceType.length === 0) {
|
|
@@ -72,28 +70,31 @@ function returnPayTransaction(params) {
|
|
|
72
70
|
inclusion: ['seller', 'project', 'dateReturned'],
|
|
73
71
|
exclusion: []
|
|
74
72
|
});
|
|
73
|
+
let transactionNumber; // 返金取引番号
|
|
74
|
+
// すでに返金取引が存在すれば何もしない
|
|
75
|
+
const alreadyExists = yield refundTransactionAlreadyExists(params)({ assetTransaction: repos.assetTransaction });
|
|
76
|
+
if (!alreadyExists) {
|
|
77
|
+
transactionNumber = (yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() })).transactionNumber;
|
|
78
|
+
}
|
|
79
|
+
const refundActionAttributes = Object.assign(Object.assign({}, params), (typeof transactionNumber === 'string')
|
|
80
|
+
? { instrument: { transactionNumber, typeOf: factory.assetTransactionType.Refund } } // add instrument(2024-06-17~)
|
|
81
|
+
: undefined);
|
|
75
82
|
const action = yield repos.action.start(refundActionAttributes);
|
|
76
|
-
let refundTransaction;
|
|
83
|
+
// let refundTransaction: Pick<factory.assetTransaction.refund.ITransaction, 'id' | 'transactionNumber' | 'typeOf'> | undefined;
|
|
77
84
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!alreadyExists) {
|
|
81
|
-
// まず取引番号発行
|
|
82
|
-
const { transactionNumber } = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
83
|
-
// 返品手数料
|
|
84
|
-
const refundFee = transaction2refundFee({ returnOrderTransaction });
|
|
85
|
-
// no op
|
|
85
|
+
if (typeof transactionNumber === 'string') {
|
|
86
|
+
const refundFee = transaction2refundFee({ returnOrderTransaction }); // 返品手数料
|
|
86
87
|
const startRefundTransactionParams = createStartRefundTransactionParams(Object.assign(Object.assign({}, params), { transactionNumber,
|
|
87
88
|
paymentServiceType,
|
|
88
89
|
refundFee, seller: order.seller }));
|
|
89
90
|
const refundPurpose = createRefundPurpose(params, order);
|
|
90
|
-
|
|
91
|
+
yield RefundTransactionService.start(startRefundTransactionParams)({
|
|
91
92
|
action: repos.action,
|
|
92
93
|
paymentService: repos.paymentService,
|
|
93
94
|
product: repos.product,
|
|
94
95
|
assetTransaction: repos.assetTransaction
|
|
95
96
|
});
|
|
96
|
-
refundTransaction = { id, transactionNumber, typeOf };
|
|
97
|
+
// refundTransaction = { id, transactionNumber, typeOf };
|
|
97
98
|
yield RefundTransactionService.confirm({
|
|
98
99
|
transactionNumber,
|
|
99
100
|
potentialActions: { refund: { purpose: refundPurpose } }
|
|
@@ -111,25 +112,17 @@ function returnPayTransaction(params) {
|
|
|
111
112
|
}
|
|
112
113
|
throw error;
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
const result = {
|
|
116
|
+
// ...(typeof refundTransaction?.id === 'string') ? { refundTransaction } : undefined // migrate into instrument(2024-06-17~)
|
|
117
|
+
}; // optimize(2024-04-27~)
|
|
116
118
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
117
|
-
// 潜在アクション
|
|
118
119
|
yield onRefund(refundActionAttributes)({ task: repos.task });
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
function createRefundPurpose(params, order) {
|
|
122
|
-
// const returnOrderRecipient: factory.action.IParticipantAsSeller = {
|
|
123
|
-
// id: order.seller.id,
|
|
124
|
-
// typeOf: order.seller.typeOf,
|
|
125
|
-
// ...(typeof order.seller.name === 'string') ? { name: order.seller.name } : undefined
|
|
126
|
-
// };
|
|
127
123
|
return {
|
|
128
|
-
// project: order.project,
|
|
129
124
|
typeOf: factory.actionType.ReturnAction,
|
|
130
125
|
object: Object.assign(Object.assign({}, params.purpose), { dateReturned: order.dateReturned })
|
|
131
|
-
// agent: order.project,
|
|
132
|
-
// recipient: returnOrderRecipient
|
|
133
126
|
};
|
|
134
127
|
}
|
|
135
128
|
function refundTransactionAlreadyExists(params) {
|
package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare function createReturnPaymentMethodActions(params: {
|
|
|
3
3
|
order: factory.order.IOrder;
|
|
4
4
|
returnOrderActionParams?: factory.transaction.returnOrder.IReturnOrderActionParams;
|
|
5
5
|
transaction: Pick<factory.transaction.returnOrder.ITransaction, 'object'>;
|
|
6
|
-
}): Promise<factory.action.transfer.returnAction.
|
|
6
|
+
}): Promise<factory.action.transfer.returnAction.order.IPotentialReturnInvoiceAction[]>;
|
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.createReturnPaymentMethodActions = void 0;
|
|
24
24
|
const emailMessageBuilder = require("../../../../emailMessageBuilder");
|
|
25
25
|
const factory = require("../../../../factory");
|
|
26
|
-
function
|
|
26
|
+
function createReturnInvoicePotentialActions(params) {
|
|
27
27
|
var _a, _b, _c, _d;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
const order = params.order;
|
|
@@ -77,7 +77,7 @@ function createReturnPaymentMethodPotentialActions(params) {
|
|
|
77
77
|
function createReturnPaymentMethodActions(params) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
79
|
const order = params.order;
|
|
80
|
-
const
|
|
80
|
+
const potentialReturnInvoiceActions = [];
|
|
81
81
|
const returnPaymentMethodPurpose = {
|
|
82
82
|
typeOf: order.typeOf,
|
|
83
83
|
orderNumber: order.orderNumber,
|
|
@@ -92,12 +92,12 @@ function createReturnPaymentMethodActions(params) {
|
|
|
92
92
|
case factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility:
|
|
93
93
|
break;
|
|
94
94
|
default:
|
|
95
|
-
|
|
95
|
+
potentialReturnInvoiceActions.push(...yield Promise.all(params.order.paymentMethods
|
|
96
96
|
.filter((paymentMethod) => {
|
|
97
97
|
return paymentMethod.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
98
98
|
})
|
|
99
99
|
.map((referencedInvoice) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const potentialActionsOnRefund = yield
|
|
100
|
+
const potentialActionsOnRefund = yield createReturnInvoicePotentialActions(Object.assign({ paymentMethod: { paymentMethodId: referencedInvoice.paymentMethodId }, order: params.order }, (params.returnOrderActionParams !== undefined)
|
|
101
101
|
? { returnOrderActionParams: params.returnOrderActionParams }
|
|
102
102
|
: undefined));
|
|
103
103
|
const { paymentStatus } = referencedInvoice, referencedInvoiceAsObject = __rest(referencedInvoice, ["paymentStatus"]);
|
|
@@ -118,8 +118,8 @@ function createReturnPaymentMethodActions(params) {
|
|
|
118
118
|
}))));
|
|
119
119
|
}
|
|
120
120
|
// MovieTicket決済について
|
|
121
|
-
|
|
122
|
-
return
|
|
121
|
+
potentialReturnInvoiceActions.push(...yield createReturnPaymentMethodIssuedThroughMovieTicketActions(params));
|
|
122
|
+
return potentialReturnInvoiceActions;
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
exports.createReturnPaymentMethodActions = createReturnPaymentMethodActions;
|
|
@@ -165,7 +165,7 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
|
165
165
|
return returnPaymentMethod;
|
|
166
166
|
})
|
|
167
167
|
.map((referencedInvoice) => __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const potentialActionsOnRefund = yield
|
|
168
|
+
const potentialActionsOnRefund = yield createReturnInvoicePotentialActions(Object.assign({ paymentMethod: { paymentMethodId: referencedInvoice.paymentMethodId }, order: params.order }, (params.returnOrderActionParams !== undefined)
|
|
169
169
|
? { returnOrderActionParams: params.returnOrderActionParams }
|
|
170
170
|
: undefined));
|
|
171
171
|
const { paymentStatus } = referencedInvoice, referencedInvoiceAsObject = __rest(referencedInvoice, ["paymentStatus"]);
|
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.375.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.375.0-alpha.3",
|
|
14
14
|
"@cinerino/sdk": "7.2.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.35.0-alpha.
|
|
113
|
+
"version": "21.35.0-alpha.3"
|
|
114
114
|
}
|