@chevre/domain 21.36.0-alpha.5 → 21.36.0
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.d.ts +1 -0
- package/lib/chevre/repo/action.js +4 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +2 -2
- package/lib/chevre/service/order/placeOrder.js +2 -2
- package/lib/chevre/service/order/placeOrderWithoutTransaction.js +2 -2
- package/lib/chevre/service/order/returnOrder.js +2 -2
- package/lib/chevre/service/order/sendOrder.js +2 -2
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +4 -5
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +1 -2
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +8 -16
- package/lib/chevre/service/task/createAccountingReport.js +2 -2
- package/lib/chevre/service/task/returnPayTransaction.js +4 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +0 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +13 -19
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -7
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +7 -8
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.js +9 -4
- package/package.json +3 -3
|
@@ -594,10 +594,14 @@ class MongoRepository {
|
|
|
594
594
|
* アクション失敗
|
|
595
595
|
*/
|
|
596
596
|
giveUp(params) {
|
|
597
|
+
var _a;
|
|
597
598
|
return __awaiter(this, void 0, void 0, function* () {
|
|
598
599
|
const actionError = (Array.isArray(params.error))
|
|
599
600
|
? params.error.map((e) => (Object.assign(Object.assign({}, e), { message: e.message, name: e.name })))
|
|
600
601
|
: Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
|
|
602
|
+
if (((_a = params.recipe) === null || _a === void 0 ? void 0 : _a.typeOf) === 'Recipe') {
|
|
603
|
+
yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
|
|
604
|
+
}
|
|
601
605
|
const doc = yield this.actionModel.findOneAndUpdate({
|
|
602
606
|
typeOf: { $eq: params.typeOf },
|
|
603
607
|
_id: { $eq: params.id }
|
|
@@ -59,8 +59,8 @@ function createNextSendOrderTasks(params) {
|
|
|
59
59
|
// mask
|
|
60
60
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
61
61
|
orderNumber: params.order.orderNumber,
|
|
62
|
-
price: params.order.price,
|
|
63
|
-
priceCurrency: params.order.priceCurrency,
|
|
62
|
+
// price: params.order.price,
|
|
63
|
+
// priceCurrency: params.order.priceCurrency,
|
|
64
64
|
orderDate: params.order.orderDate
|
|
65
65
|
};
|
|
66
66
|
const sendOrderObject = Object.assign(Object.assign({}, simpleOrder), { acceptedOffers: {
|
|
@@ -50,8 +50,8 @@ function createSendOrderTaskIfNotExist(params) {
|
|
|
50
50
|
// mask
|
|
51
51
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
52
52
|
orderNumber: params.order.orderNumber,
|
|
53
|
-
price: params.order.price,
|
|
54
|
-
priceCurrency: params.order.priceCurrency,
|
|
53
|
+
// price: params.order.price,
|
|
54
|
+
// priceCurrency: params.order.priceCurrency,
|
|
55
55
|
orderDate: params.order.orderDate
|
|
56
56
|
};
|
|
57
57
|
const sendOrderObject = Object.assign(Object.assign({}, simpleOrder), { acceptedOffers: {
|
|
@@ -31,8 +31,8 @@ function onOrderPaymentDue(params) {
|
|
|
31
31
|
// }, // 廃止(2024-03-06~)
|
|
32
32
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
33
33
|
orderNumber: params.order.orderNumber,
|
|
34
|
-
price: params.order.price,
|
|
35
|
-
priceCurrency: params.order.priceCurrency,
|
|
34
|
+
// price: params.order.price,
|
|
35
|
+
// priceCurrency: params.order.priceCurrency,
|
|
36
36
|
orderDate: params.order.orderDate
|
|
37
37
|
};
|
|
38
38
|
switch (params.order.orderStatus) {
|
|
@@ -22,8 +22,8 @@ function createSendEmailMessageTaskIfNotExist(params) {
|
|
|
22
22
|
const simpleOrder = {
|
|
23
23
|
typeOf: params.order.typeOf,
|
|
24
24
|
orderNumber: params.order.orderNumber,
|
|
25
|
-
price: params.order.price,
|
|
26
|
-
priceCurrency: params.order.priceCurrency,
|
|
25
|
+
// price: params.order.price,
|
|
26
|
+
// priceCurrency: params.order.priceCurrency,
|
|
27
27
|
orderDate: params.order.orderDate
|
|
28
28
|
};
|
|
29
29
|
const actionAttributes = {
|
|
@@ -37,8 +37,8 @@ function onOrderProcessing(params) {
|
|
|
37
37
|
// }, // 廃止(2024-03-06~)
|
|
38
38
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
39
39
|
orderNumber: params.order.orderNumber,
|
|
40
|
-
price: params.order.price,
|
|
41
|
-
priceCurrency: params.order.priceCurrency,
|
|
40
|
+
// price: params.order.price,
|
|
41
|
+
// priceCurrency: params.order.priceCurrency,
|
|
42
42
|
orderDate: params.order.orderDate
|
|
43
43
|
};
|
|
44
44
|
switch (params.order.orderStatus) {
|
|
@@ -95,8 +95,8 @@ function createOnOrderReturnedTasksByTransaction(params) {
|
|
|
95
95
|
const simpleOrder = {
|
|
96
96
|
typeOf: params.order.typeOf,
|
|
97
97
|
orderNumber: params.order.orderNumber,
|
|
98
|
-
price: params.order.price,
|
|
99
|
-
priceCurrency: params.order.priceCurrency,
|
|
98
|
+
// price: params.order.price,
|
|
99
|
+
// priceCurrency: params.order.priceCurrency,
|
|
100
100
|
orderDate: params.order.orderDate
|
|
101
101
|
};
|
|
102
102
|
sendEmailMessageAttributes.forEach((s) => {
|
|
@@ -34,8 +34,8 @@ function onOrderReturned(params) {
|
|
|
34
34
|
// }, // 廃止(2024-03-06~)
|
|
35
35
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
36
36
|
orderNumber: params.order.orderNumber,
|
|
37
|
-
price: params.order.price,
|
|
38
|
-
priceCurrency: params.order.priceCurrency,
|
|
37
|
+
// price: params.order.price,
|
|
38
|
+
// priceCurrency: params.order.priceCurrency,
|
|
39
39
|
orderDate: params.order.orderDate
|
|
40
40
|
};
|
|
41
41
|
switch (params.order.orderStatus) {
|
|
@@ -44,8 +44,8 @@ function placeOrder(params) {
|
|
|
44
44
|
// }, // 廃止(2024-03-06~)
|
|
45
45
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
46
46
|
orderNumber: order.orderNumber,
|
|
47
|
-
price: order.price,
|
|
48
|
-
priceCurrency: order.priceCurrency,
|
|
47
|
+
// price: order.price,
|
|
48
|
+
// priceCurrency: order.priceCurrency,
|
|
49
49
|
orderDate: order.orderDate
|
|
50
50
|
};
|
|
51
51
|
const orderActionPurpose = {
|
|
@@ -27,8 +27,8 @@ function placeOrderWithoutTransaction(params) {
|
|
|
27
27
|
// }, // 廃止(2024-03-06~)
|
|
28
28
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
29
29
|
orderNumber: order.orderNumber,
|
|
30
|
-
price: order.price,
|
|
31
|
-
priceCurrency: order.priceCurrency,
|
|
30
|
+
// price: order.price,
|
|
31
|
+
// priceCurrency: order.priceCurrency,
|
|
32
32
|
orderDate: order.orderDate
|
|
33
33
|
};
|
|
34
34
|
const orderActionAttributes = {
|
|
@@ -66,8 +66,8 @@ function returnOrder(params) {
|
|
|
66
66
|
// }, // 廃止(2024-03-06~)
|
|
67
67
|
// customer: createMaskedCustomer(order, { noProfile: true }), // 廃止(2024-03-06~)
|
|
68
68
|
orderNumber: order.orderNumber,
|
|
69
|
-
price: order.price,
|
|
70
|
-
priceCurrency: order.priceCurrency,
|
|
69
|
+
// price: order.price,
|
|
70
|
+
// priceCurrency: order.priceCurrency,
|
|
71
71
|
orderDate: order.orderDate,
|
|
72
72
|
dateReturned
|
|
73
73
|
};
|
|
@@ -72,8 +72,8 @@ function sendOrder(params) {
|
|
|
72
72
|
// }, // 廃止(2024-03-06~)
|
|
73
73
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
74
74
|
orderNumber: order.orderNumber,
|
|
75
|
-
price: order.price,
|
|
76
|
-
priceCurrency: order.priceCurrency,
|
|
75
|
+
// price: order.price,
|
|
76
|
+
// priceCurrency: order.priceCurrency,
|
|
77
77
|
orderDate: order.orderDate
|
|
78
78
|
};
|
|
79
79
|
const { limit, page } = params.object.acceptedOffers;
|
|
@@ -65,14 +65,13 @@ function payCreditCard(params) {
|
|
|
65
65
|
}
|
|
66
66
|
})));
|
|
67
67
|
// add recipe(2024-06-03~)
|
|
68
|
-
recipe = (0, factory_1.processAlterTranResult2payRecipe)({
|
|
69
|
-
processAlterTranResults,
|
|
70
|
-
project: { id: params.project.id }
|
|
71
|
-
});
|
|
68
|
+
recipe = (0, factory_1.processAlterTranResult2payRecipe)({ processAlterTranResults, project: { id: params.project.id } });
|
|
72
69
|
}
|
|
73
70
|
catch (error) {
|
|
74
71
|
try {
|
|
75
|
-
|
|
72
|
+
// add recipe(2024-06-29~)
|
|
73
|
+
recipe = (0, factory_1.processAlterTranResult2payRecipe)({ processAlterTranResults, project: { id: params.project.id } });
|
|
74
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error, recipe });
|
|
76
75
|
}
|
|
77
76
|
catch (__) {
|
|
78
77
|
// 失敗したら仕方ない
|
|
@@ -5,7 +5,6 @@ import type { MongoRepository as PaymentServiceProviderRepo } from '../../../rep
|
|
|
5
5
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
6
6
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
7
|
import * as factory from '../../../factory';
|
|
8
|
-
type IRefundAction = factory.action.trade.refund.IAction;
|
|
9
8
|
/**
|
|
10
9
|
* クレジットカード返金
|
|
11
10
|
*/
|
|
@@ -22,5 +21,5 @@ declare function refundCreditCard(params: Omit<factory.task.refund.IData, 'sameA
|
|
|
22
21
|
paymentService: PaymentServiceRepo;
|
|
23
22
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
24
23
|
task: TaskRepo;
|
|
25
|
-
}) => Promise<
|
|
24
|
+
}) => Promise<void>;
|
|
26
25
|
export { refundCreditCard };
|
|
@@ -32,7 +32,7 @@ const getGMOInfoFromSeller_1 = require("./getGMOInfoFromSeller");
|
|
|
32
32
|
*/
|
|
33
33
|
function refundCreditCard(params, options) {
|
|
34
34
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
36
|
const paymentMethodType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.typeOf;
|
|
37
37
|
const paymentMethodId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.paymentMethod.paymentMethodId;
|
|
38
38
|
const paymentServiceId = (_c = params.object[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
@@ -52,10 +52,7 @@ function refundCreditCard(params, options) {
|
|
|
52
52
|
});
|
|
53
53
|
alterTranResultByPayAction = (_f = (_e = (_d = payRecipe === null || payRecipe === void 0 ? void 0 : payRecipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[1]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
54
54
|
}
|
|
55
|
-
const sellerId =
|
|
56
|
-
if (typeof sellerId !== 'string') {
|
|
57
|
-
throw new factory.errors.ArgumentNull('agent.id');
|
|
58
|
-
}
|
|
55
|
+
const sellerId = params.agent.id;
|
|
59
56
|
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
60
57
|
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
61
58
|
project: params.project,
|
|
@@ -63,7 +60,7 @@ function refundCreditCard(params, options) {
|
|
|
63
60
|
id: paymentServiceId
|
|
64
61
|
});
|
|
65
62
|
const { sameAs } = params, startingActionParams = __rest(params, ["sameAs"]);
|
|
66
|
-
let action = yield repos.action.start(Object.assign(Object.assign({}, startingActionParams), (typeof ((
|
|
63
|
+
let action = yield repos.action.start(Object.assign(Object.assign({}, startingActionParams), (typeof ((_g = params.sameAs) === null || _g === void 0 ? void 0 : _g.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined));
|
|
67
64
|
const alterTranResult = [];
|
|
68
65
|
let processAlterTranResult;
|
|
69
66
|
let recipe;
|
|
@@ -74,13 +71,13 @@ function refundCreditCard(params, options) {
|
|
|
74
71
|
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
75
72
|
processAlterTranResult = yield processAlterTran({
|
|
76
73
|
availableChannel,
|
|
77
|
-
// alterTranResultByPayAction: payAction?.result?.creditCardSales?.[0],
|
|
78
74
|
alterTranResultByPayAction,
|
|
79
75
|
paymentMethodId: paymentMethodId,
|
|
80
76
|
shopId: shopId,
|
|
81
77
|
shopPass: shopPass,
|
|
82
|
-
refundFee: (
|
|
78
|
+
refundFee: (_h = params.object[0]) === null || _h === void 0 ? void 0 : _h.refundFee
|
|
83
79
|
})({ creditService });
|
|
80
|
+
recipe = (0, factory_1.processAlterTranResult2refundRecipe)({ processAlterTranResult, project: { id: params.project.id } });
|
|
84
81
|
if (processAlterTranResult.processAlterTranError === undefined) {
|
|
85
82
|
if (processAlterTranResult.alterTranResult !== undefined) {
|
|
86
83
|
alterTranResult.push(processAlterTranResult.alterTranResult);
|
|
@@ -90,15 +87,10 @@ function refundCreditCard(params, options) {
|
|
|
90
87
|
// 代行決済連携中にエラーがあればそのままthrow
|
|
91
88
|
throw processAlterTranResult.processAlterTranError;
|
|
92
89
|
}
|
|
93
|
-
// add recipe(2024-06-04~)
|
|
94
|
-
recipe = (0, factory_1.processAlterTranResult2refundRecipe)({
|
|
95
|
-
processAlterTranResult,
|
|
96
|
-
project: { id: params.project.id }
|
|
97
|
-
});
|
|
98
90
|
}
|
|
99
91
|
catch (error) {
|
|
100
92
|
try {
|
|
101
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
93
|
+
yield repos.action.giveUp(Object.assign({ typeOf: action.typeOf, id: action.id, error }, (recipe !== undefined) ? { recipe } : undefined));
|
|
102
94
|
}
|
|
103
95
|
catch (__) {
|
|
104
96
|
// no op
|
|
@@ -106,9 +98,9 @@ function refundCreditCard(params, options) {
|
|
|
106
98
|
throw error;
|
|
107
99
|
}
|
|
108
100
|
const actionResult = {}; // optimize(2024-06-10~)
|
|
109
|
-
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult, recipe }));
|
|
101
|
+
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult, recipe })); // add recipe(2024-06-04~)
|
|
110
102
|
yield (0, onRefund_1.onRefund)(action)(repos);
|
|
111
|
-
return action;
|
|
103
|
+
// return action;
|
|
112
104
|
});
|
|
113
105
|
}
|
|
114
106
|
exports.refundCreditCard = refundCreditCard;
|
|
@@ -46,8 +46,8 @@ function createAccountingReport(params) {
|
|
|
46
46
|
// }, // 廃止(2024-03-06~)
|
|
47
47
|
// customer: { typeOf: order.customer.typeOf, id: order.customer.id }, // 廃止(2024-03-06~)
|
|
48
48
|
orderNumber: order.orderNumber,
|
|
49
|
-
price: order.price,
|
|
50
|
-
priceCurrency: order.priceCurrency,
|
|
49
|
+
// price: order.price,
|
|
50
|
+
// priceCurrency: order.priceCurrency,
|
|
51
51
|
orderDate: order.orderDate
|
|
52
52
|
};
|
|
53
53
|
const actionAttributes = {
|
|
@@ -54,8 +54,8 @@ function task2actionAttributes(params) {
|
|
|
54
54
|
const purpose = {
|
|
55
55
|
typeOf: order.typeOf,
|
|
56
56
|
orderNumber: order.orderNumber,
|
|
57
|
-
price: order.price,
|
|
58
|
-
priceCurrency: order.priceCurrency,
|
|
57
|
+
// price: order.price,
|
|
58
|
+
// priceCurrency: order.priceCurrency,
|
|
59
59
|
orderDate: order.orderDate
|
|
60
60
|
};
|
|
61
61
|
return Object.assign(Object.assign(Object.assign({ project: order.project, typeOf: factory.actionType.ReturnAction, agent, object, recipient, purpose }, (potentialActions !== undefined) ? { potentialActions } : undefined), (typeof transactionNumber === 'string')
|
|
@@ -241,8 +241,8 @@ function onRefund(params) {
|
|
|
241
241
|
const simpleOrder = {
|
|
242
242
|
typeOf: order.typeOf,
|
|
243
243
|
orderNumber: order.orderNumber,
|
|
244
|
-
price: order.price,
|
|
245
|
-
priceCurrency: order.priceCurrency,
|
|
244
|
+
// price: order.price,
|
|
245
|
+
// priceCurrency: order.priceCurrency,
|
|
246
246
|
orderDate: order.orderDate
|
|
247
247
|
};
|
|
248
248
|
sendEmailMessageByPotentialActions.forEach((s) => {
|
|
@@ -33,11 +33,6 @@ type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
|
|
|
33
33
|
* 同期的にに注文コードを発行する場合に指定
|
|
34
34
|
*/
|
|
35
35
|
publishCodeExpiresInSeconds?: number;
|
|
36
|
-
/**
|
|
37
|
-
* 取引検証時にorderInTransactionからオファーを検索するかどうか
|
|
38
|
-
*/
|
|
39
|
-
useSaveMessages: boolean;
|
|
40
|
-
useOptimizedSendEmailAction: boolean;
|
|
41
36
|
};
|
|
42
37
|
};
|
|
43
38
|
interface IConfirmResult {
|
|
@@ -127,13 +127,9 @@ function confirm(params) {
|
|
|
127
127
|
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order, // createEmailMessageでのorder.acceptedOffersへの依存性を排除したのでこちらでよいはず(2024-02-21~)
|
|
128
128
|
customer,
|
|
129
129
|
seller,
|
|
130
|
-
paymentMethods,
|
|
131
|
-
// order: orderWithAcceptedOffers, // 現時点でcreateEmailMessageでorder.acceptedOffersを使用している(2024-02-06~)
|
|
132
|
-
// transaction: transaction,
|
|
133
|
-
useOptimizedSendEmailAction: params.options.useOptimizedSendEmailAction }, (params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined), (emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined));
|
|
130
|
+
paymentMethods }, (params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined), (emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined));
|
|
134
131
|
// メッセージ保管(2024-04-28~)
|
|
135
132
|
yield saveMessagesIfNeeded({
|
|
136
|
-
options: params.options,
|
|
137
133
|
project: { id: transaction.project.id },
|
|
138
134
|
order: { orderNumber, typeOf: factory.order.OrderType.Order }, seller: { id: seller.id }, emailMessages
|
|
139
135
|
})(repos);
|
|
@@ -164,20 +160,18 @@ function confirm(params) {
|
|
|
164
160
|
exports.confirm = confirm;
|
|
165
161
|
function saveMessagesIfNeeded(params) {
|
|
166
162
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const {
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
debug(emailMessages.length, 'messages saved.', saveMessageResult);
|
|
180
|
-
}
|
|
163
|
+
const { project, order, emailMessages, seller } = params;
|
|
164
|
+
if (emailMessages.length > 0) {
|
|
165
|
+
const { orderNumber, typeOf } = order;
|
|
166
|
+
const saveMessageResult = yield repos.message.upsertByIdentifier(emailMessages.map(({ identifier, name, about, text, toRecipient, sender }) => {
|
|
167
|
+
return {
|
|
168
|
+
identifier, name, about, text, toRecipient, sender,
|
|
169
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
170
|
+
provider: { id: seller.id, typeOf: factory.organizationType.Corporation },
|
|
171
|
+
mainEntity: { orderNumber, typeOf }
|
|
172
|
+
};
|
|
173
|
+
}));
|
|
174
|
+
debug(emailMessages.length, 'messages saved.', saveMessageResult);
|
|
181
175
|
}
|
|
182
176
|
});
|
|
183
177
|
}
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare function createSendEmailMessageActions(params: {
|
|
|
6
6
|
paymentMethods: factory.order.IReferencedInvoice[];
|
|
7
7
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
8
8
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
9
|
-
useOptimizedSendEmailAction: boolean;
|
|
10
9
|
}): Promise<{
|
|
11
10
|
emailMessages: factory.action.transfer.send.message.email.IObjectAsEmailMessage[];
|
|
12
11
|
sendEmailMessageActions: factory.transaction.placeOrder.IPotentialSendEmailMessageAction[];
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js
CHANGED
|
@@ -32,14 +32,11 @@ function createSendEmailMessageActions(params) {
|
|
|
32
32
|
yield Promise.all(sendEmailMessageOnOrderSentParams.map((s, index) => __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
const emailMessage = yield emailMessageBuilder.createSendOrderMessage(Object.assign(Object.assign({ order: orderAsCreateEmailParams, index }, (s.object !== undefined) ? { email: s.object } : undefined), (params.emailMessage !== undefined) ? { emailMessage: params.emailMessage } : undefined));
|
|
34
34
|
emailMessages.push(emailMessage);
|
|
35
|
-
let sendEmailMessageActionObject = emailMessage;
|
|
36
35
|
// 送信アクション最適化に対応(2024-04-29~)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
}
|
|
36
|
+
const sendEmailMessageActionObject = {
|
|
37
|
+
identifier: emailMessage.identifier,
|
|
38
|
+
typeOf: factory.creativeWorkType.EmailMessage
|
|
39
|
+
};
|
|
43
40
|
// optimize(2024-05-07~)
|
|
44
41
|
sendEmailMessageActions.push({
|
|
45
42
|
// project: params.order.project,
|
|
@@ -9,7 +9,6 @@ export declare function createPotentialActions(params: {
|
|
|
9
9
|
paymentMethods: factory.order.IReferencedInvoice[];
|
|
10
10
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
11
11
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
12
|
-
useOptimizedSendEmailAction: boolean;
|
|
13
12
|
}): Promise<{
|
|
14
13
|
potentialActions: factory.transaction.placeOrder.IPotentialActions;
|
|
15
14
|
emailMessages: factory.creativeWork.message.email.ICreativeWork[];
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPotentialActions = void 0;
|
|
13
13
|
const sendEmailMessage_1 = require("./potentialActions/sendEmailMessage");
|
|
14
|
-
const settings_1 = require("../../../settings");
|
|
15
14
|
/**
|
|
16
15
|
* 取引のポストアクションを作成する
|
|
17
16
|
*/
|
|
@@ -19,16 +18,16 @@ function createPotentialActions(params) {
|
|
|
19
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
19
|
// 注文処理開始メール送信設定
|
|
21
20
|
const { emailMessages, sendEmailMessageActions } = yield (0, sendEmailMessage_1.createSendEmailMessageActions)(params);
|
|
22
|
-
const sendOrderActionAttributes = {
|
|
23
|
-
|
|
24
|
-
};
|
|
21
|
+
// const sendOrderActionAttributes: factory.transaction.placeOrder.IPotentialSendOrderAction = {
|
|
22
|
+
// potentialActions: { sendEmailMessage: sendEmailMessageActions }
|
|
23
|
+
// };
|
|
25
24
|
return {
|
|
26
25
|
emailMessages,
|
|
27
26
|
potentialActions: {
|
|
28
|
-
order:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
order: {
|
|
28
|
+
onOrderProcessing: { sendEmailMessage: sendEmailMessageActions } // optimize(2024-06-29~)
|
|
29
|
+
// potentialActions: { sendOrder: sendOrderActionAttributes }
|
|
30
|
+
}
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
});
|
|
@@ -58,8 +58,8 @@ function createReturnPointAwardActions(params) {
|
|
|
58
58
|
// mask
|
|
59
59
|
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
60
60
|
orderNumber: order.orderNumber,
|
|
61
|
-
price: order.price,
|
|
62
|
-
priceCurrency: order.priceCurrency,
|
|
61
|
+
// price: order.price,
|
|
62
|
+
// priceCurrency: order.priceCurrency,
|
|
63
63
|
orderDate: order.orderDate
|
|
64
64
|
};
|
|
65
65
|
const agent = order.project;
|
|
@@ -61,8 +61,8 @@ function createPotentialActions(params) {
|
|
|
61
61
|
// mask
|
|
62
62
|
// customer: createMaskedCustomer(order, { noProfile: true }), // 廃止(2024-03-06~)
|
|
63
63
|
orderNumber: order.orderNumber,
|
|
64
|
-
price: order.price,
|
|
65
|
-
priceCurrency: order.priceCurrency,
|
|
64
|
+
// price: order.price,
|
|
65
|
+
// priceCurrency: order.priceCurrency,
|
|
66
66
|
orderDate: order.orderDate,
|
|
67
67
|
dateReturned: params.dateReturned
|
|
68
68
|
};
|
|
@@ -91,8 +91,12 @@ function preStart(params) {
|
|
|
91
91
|
validateAppliedReturnPolicy({ merchantReturnPolicy: appliedReturnPolicy });
|
|
92
92
|
// アイテム検証
|
|
93
93
|
yield validateItems({ orders, reason: params.object.reason })({ order: repos.order, reservation: repos.reservation });
|
|
94
|
-
const transactionObject =
|
|
95
|
-
|
|
94
|
+
const transactionObject = {
|
|
95
|
+
order: orders.map(({ confirmationNumber, orderNumber }) => ({ confirmationNumber, orderNumber })),
|
|
96
|
+
returnPolicy: appliedReturnPolicy,
|
|
97
|
+
reason: params.object.reason,
|
|
98
|
+
usedReservationExists // for debug(2024-06-26~)
|
|
99
|
+
};
|
|
96
100
|
// fix expiresInSeconds(2022-11-30~)
|
|
97
101
|
let expiresInSeconds;
|
|
98
102
|
if (typeof params.expiresInSeconds === 'number') {
|
|
@@ -402,10 +406,11 @@ function findApplicableReturnPolicy(params) {
|
|
|
402
406
|
let appliedItemCondition;
|
|
403
407
|
const appliedItemConditionId = (_c = appliedReturnPolicy.itemCondition) === null || _c === void 0 ? void 0 : _c.id;
|
|
404
408
|
if (typeof appliedItemConditionId === 'string') {
|
|
405
|
-
|
|
406
|
-
if (
|
|
409
|
+
const appliedItemConditionFromDB = params.offerItemConditions.find((o) => o.id === appliedItemConditionId);
|
|
410
|
+
if (appliedItemConditionFromDB === undefined) {
|
|
407
411
|
throw new factory.errors.NotFound('OfferItemCondition');
|
|
408
412
|
}
|
|
413
|
+
appliedItemCondition = Object.assign({ identifier: appliedItemConditionFromDB.identifier, itemOffered: appliedItemConditionFromDB.itemOffered, typeOf: appliedItemConditionFromDB.typeOf }, (typeof appliedItemConditionFromDB.id === 'string') ? { id: appliedItemConditionFromDB.id } : undefined);
|
|
409
414
|
}
|
|
410
415
|
const { restockingFee, typeOf, identifier, merchantReturnDays } = appliedReturnPolicy;
|
|
411
416
|
return Object.assign(Object.assign(Object.assign({ restockingFee,
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.376.0
|
|
14
|
-
"@cinerino/sdk": "8.0.0
|
|
13
|
+
"@chevre/factory": "4.376.0",
|
|
14
|
+
"@cinerino/sdk": "8.0.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.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.36.0
|
|
113
|
+
"version": "21.36.0"
|
|
114
114
|
}
|