@chevre/domain 22.8.0-alpha.9 → 22.8.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/example/src/chevre/adminSellerReturnPolicy.ts +102 -0
- package/example/src/chevre/{searchActions.ts → searchActionsByOrderNumber.ts} +3 -5
- package/example/src/chevre/searchSellersByAggregate.ts +7 -20
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/repo/action.d.ts +5 -1
- package/lib/chevre/repo/action.js +51 -45
- package/lib/chevre/repo/issuer.d.ts +32 -0
- package/lib/chevre/repo/issuer.js +150 -0
- package/lib/chevre/repo/member.d.ts +4 -5
- package/lib/chevre/repo/member.js +19 -9
- package/lib/chevre/repo/memberProgram.d.ts +59 -0
- package/lib/chevre/repo/memberProgram.js +140 -0
- package/lib/chevre/repo/mongoose/schemas/action.js +20 -10
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/issuer.js +56 -0
- package/lib/chevre/repo/mongoose/schemas/seller.js +3 -12
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +0 -66
- package/lib/chevre/repo/projectMakesOffer.d.ts +2 -1
- package/lib/chevre/repo/projectMakesOffer.js +4 -5
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +25 -21
- package/lib/chevre/repo/sellerReturnPolicy.d.ts +36 -0
- package/lib/chevre/repo/sellerReturnPolicy.js +164 -0
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +41 -2
- package/lib/chevre/service/notification.js +3 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +5 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +20 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated/factory.js +1 -0
- package/lib/chevre/service/order/returnOrder.js +16 -11
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +34 -7
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +19 -7
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/package.json +3 -3
- package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -129
|
@@ -23,6 +23,7 @@ setting) {
|
|
|
23
23
|
informTasks.push(...informOrder.map((informOrderParams) => {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
const informActionAttributes = {
|
|
26
|
+
about: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
|
|
26
27
|
object: order4inform,
|
|
27
28
|
recipient: {
|
|
28
29
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
@@ -23,6 +23,7 @@ setting) {
|
|
|
23
23
|
informTasks.push(...informOrder.map((informOrderParams) => {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
const informActionAttributes = {
|
|
26
|
+
about: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
|
|
26
27
|
object: order4inform,
|
|
27
28
|
recipient: {
|
|
28
29
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
@@ -23,13 +23,14 @@ Object.defineProperty(exports, "processOrder", { enumerable: true, get: function
|
|
|
23
23
|
const debug = createDebug('chevre-domain:service:order');
|
|
24
24
|
function onOrderProcessing(params) {
|
|
25
25
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b, _c, _d
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
27
|
const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
|
|
28
28
|
const { numTryConfirmReserveTransaction } = settings;
|
|
29
29
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
30
30
|
let tasks = [];
|
|
31
|
-
const sendEmailMessageByOrderPotentialActions =
|
|
32
|
-
|
|
31
|
+
// const sendEmailMessageByOrderPotentialActions =
|
|
32
|
+
// params.placeOrderTransaction?.potentialActions?.order?.potentialActions?.sendOrder?.potentialActions?.sendEmailMessage;
|
|
33
|
+
const sendEmailMessageByOnOrderProcessing = (_d = (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.onOrderProcessing) === null || _d === void 0 ? void 0 : _d.sendEmailMessage;
|
|
33
34
|
switch (params.order.orderStatus) {
|
|
34
35
|
case factory.orderStatus.OrderProcessing:
|
|
35
36
|
tasks = [
|
|
@@ -53,7 +54,7 @@ function onOrderProcessing(params) {
|
|
|
53
54
|
// OrderProcessingにおけるEメール送信に対応(2024-01-17~)
|
|
54
55
|
yield (0, createSendEmailMessageTaskIfNotExist_1.createSendEmailMessageTaskIfNotExist)({
|
|
55
56
|
sendEmailMessage: [
|
|
56
|
-
...(Array.isArray(sendEmailMessageByOrderPotentialActions)) ? sendEmailMessageByOrderPotentialActions : [],
|
|
57
|
+
// ...(Array.isArray(sendEmailMessageByOrderPotentialActions)) ? sendEmailMessageByOrderPotentialActions : [],
|
|
57
58
|
...(Array.isArray(sendEmailMessageByOnOrderProcessing)) ? sendEmailMessageByOnOrderProcessing : []
|
|
58
59
|
],
|
|
59
60
|
order: params.order
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
2
|
import type { ISetting } from '../../../../repo/setting';
|
|
3
3
|
type IReturnedOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner'>;
|
|
4
|
-
|
|
4
|
+
type IReturnAction = factory.action.transfer.returnAction.order.IAttributes & {
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
declare function createInformTasks(order: IReturnedOrder, returnOrderAction: IReturnAction, setting: Pick<ISetting, 'onOrderStatusChanged'> | null): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
5
8
|
/**
|
|
6
9
|
* 注文返品後のアクション
|
|
7
10
|
*/
|
|
@@ -9,4 +12,4 @@ declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
|
9
12
|
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'customer' | 'price' | 'priceCurrency' | 'orderDate'>;
|
|
10
13
|
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
11
14
|
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deletePerson").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
12
|
-
export { createInformTasks, createOnOrderReturnedTasksByTransaction };
|
|
15
|
+
export { createInformTasks, createOnOrderReturnedTasksByTransaction, IReturnAction };
|
|
@@ -3,26 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createInformTasks = createInformTasks;
|
|
4
4
|
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
5
5
|
const factory = require("../../../../factory");
|
|
6
|
-
function createInformTasks(order,
|
|
7
|
-
|
|
8
|
-
setting) {
|
|
9
|
-
var _a, _b;
|
|
6
|
+
function createInformTasks(order, returnOrderAction, setting) {
|
|
7
|
+
var _a, _b, _c;
|
|
10
8
|
const taskRunsAt = new Date();
|
|
11
|
-
// const informOrder = settings.onOrderStatusChanged?.informOrder;
|
|
12
9
|
const informOrder = (_a = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
|
|
10
|
+
const useInformReturnAction = ((_b = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.useInformReturnAction) === true;
|
|
13
11
|
const informTasks = [];
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// support returnAction4inform(2025-01-22~)
|
|
13
|
+
let informObject;
|
|
14
|
+
const informIdentifier = `${factory.order.OrderType.Order}:${order.orderNumber}:${factory.orderStatus.OrderReturned}`;
|
|
15
|
+
if (useInformReturnAction) {
|
|
16
|
+
informObject = createReturnAction4inform(returnOrderAction);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
informObject = createOrder4inform(order);
|
|
20
|
+
}
|
|
16
21
|
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
17
22
|
let recipientId = '';
|
|
18
23
|
recipientId = order.customer.id;
|
|
19
|
-
if (typeof ((
|
|
24
|
+
if (typeof ((_c = order.returner) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
|
|
20
25
|
recipientId = order.returner.id;
|
|
21
26
|
}
|
|
22
27
|
informTasks.push(...informOrder.map((informOrderParams) => {
|
|
23
28
|
var _a, _b;
|
|
24
29
|
const informActionAttributes = {
|
|
25
|
-
|
|
30
|
+
about: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
|
|
31
|
+
object: informObject,
|
|
26
32
|
recipient: {
|
|
27
33
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
28
34
|
id: recipientId,
|
|
@@ -45,7 +51,11 @@ setting) {
|
|
|
45
51
|
}
|
|
46
52
|
return informTasks;
|
|
47
53
|
}
|
|
48
|
-
function
|
|
54
|
+
function createReturnAction4inform(returnOrderAction) {
|
|
55
|
+
const { id, instrument, object, project, typeOf } = returnOrderAction;
|
|
56
|
+
return Object.assign({ id, object, project, typeOf }, (Array.isArray(instrument)) ? { instrument } : undefined);
|
|
57
|
+
}
|
|
58
|
+
function createOrder4inform(order) {
|
|
49
59
|
return Object.assign(Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: factory.orderStatus.OrderReturned }, (order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
@@ -2,12 +2,14 @@ import type { AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
|
2
2
|
import type { SettingRepo } from '../../../repo/setting';
|
|
3
3
|
import type { TaskRepo } from '../../../repo/task';
|
|
4
4
|
import * as factory from '../../../factory';
|
|
5
|
+
import { IReturnAction } from './onOrderReturned/factory';
|
|
5
6
|
type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
6
7
|
declare function onOrderReturned(params: {
|
|
7
8
|
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
|
|
8
9
|
orderStatus: factory.orderStatus.OrderReturned;
|
|
9
10
|
};
|
|
10
|
-
returnOrderTransaction
|
|
11
|
+
returnOrderTransaction: IReturnOrderTransaction;
|
|
12
|
+
returnOrderAction: IReturnAction;
|
|
11
13
|
}): (repos: {
|
|
12
14
|
acceptedOffer: AcceptedOfferRepo;
|
|
13
15
|
setting: SettingRepo;
|
|
@@ -53,7 +53,7 @@ function onOrderReturned(params) {
|
|
|
53
53
|
const offeredThroughIdentifier = (yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.offeredThrough.identifier'))[0];
|
|
54
54
|
const reservationForSuperEventLocationBranchCodes = yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode');
|
|
55
55
|
tasks = [
|
|
56
|
-
...(0, factory_1.createInformTasks)(params.order, setting),
|
|
56
|
+
...(0, factory_1.createInformTasks)(params.order, params.returnOrderAction, setting),
|
|
57
57
|
...createReturnReserveTransactionTasks(Object.assign(Object.assign({}, params.order), { reservationNumbers,
|
|
58
58
|
offeredThroughIdentifier,
|
|
59
59
|
reservationForSuperEventLocationBranchCodes }), simpleOrder),
|
|
@@ -16,6 +16,7 @@ setting) {
|
|
|
16
16
|
informTasks.push(...informOrder.map((informOrderParams) => {
|
|
17
17
|
var _a, _b;
|
|
18
18
|
const informActionAttributes = {
|
|
19
|
+
about: { orderNumber: order4inform.orderNumber, typeOf: factory.order.OrderType.Order },
|
|
19
20
|
object: order4inform,
|
|
20
21
|
recipient: {
|
|
21
22
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
@@ -16,6 +16,11 @@ const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
|
16
16
|
const factory = require("../../factory");
|
|
17
17
|
// import { Settings } from '../../settings';
|
|
18
18
|
const debug = createDebug('chevre-domain:service:order');
|
|
19
|
+
function createReturnPolicy(params) {
|
|
20
|
+
const { identifier, returnFees, restockingFee, typeOf } = params.returnOrderTransaction.object.returnPolicy;
|
|
21
|
+
return Object.assign(Object.assign({ returnFees,
|
|
22
|
+
typeOf }, (typeof identifier === 'string') ? { identifier } : undefined), (typeof (restockingFee === null || restockingFee === void 0 ? void 0 : restockingFee.value) === 'number') ? { restockingFee } : undefined);
|
|
23
|
+
}
|
|
19
24
|
function returnOrder(params) {
|
|
20
25
|
// tslint:disable-next-line:max-func-body-length
|
|
21
26
|
return (repos
|
|
@@ -54,7 +59,7 @@ function returnOrder(params) {
|
|
|
54
59
|
typeOf: factory.transactionType.ReturnOrder,
|
|
55
60
|
statuses: [factory.transactionStatusType.Confirmed],
|
|
56
61
|
object: { order: { orderNumbers: [orderNumber] } },
|
|
57
|
-
inclusion: ['typeOf', 'potentialActions']
|
|
62
|
+
inclusion: ['typeOf', 'potentialActions', 'object']
|
|
58
63
|
});
|
|
59
64
|
const returnOrderTransaction = returnOrderTransactions.shift();
|
|
60
65
|
if (returnOrderTransaction === undefined) {
|
|
@@ -62,23 +67,22 @@ function returnOrder(params) {
|
|
|
62
67
|
}
|
|
63
68
|
const simpleOrder = {
|
|
64
69
|
typeOf: order.typeOf,
|
|
65
|
-
// seller: {
|
|
66
|
-
// id: order.seller.id,
|
|
67
|
-
// typeOf: order.seller.typeOf,
|
|
68
|
-
// name: order.seller.name
|
|
69
|
-
// }, // 廃止(2024-03-06~)
|
|
70
|
-
// customer: createMaskedCustomer(order, { noProfile: true }), // 廃止(2024-03-06~)
|
|
71
70
|
orderNumber: order.orderNumber,
|
|
72
|
-
// price: order.price,
|
|
73
|
-
// priceCurrency: order.priceCurrency,
|
|
74
71
|
orderDate: order.orderDate,
|
|
75
72
|
dateReturned
|
|
76
73
|
};
|
|
74
|
+
const recipient = {
|
|
75
|
+
id: order.seller.id,
|
|
76
|
+
name: order.seller.name,
|
|
77
|
+
typeOf: order.seller.typeOf
|
|
78
|
+
};
|
|
79
|
+
const returnPolicyAsInstrument = createReturnPolicy({ returnOrderTransaction });
|
|
77
80
|
const returnOrderActionAttributes = {
|
|
78
81
|
agent: returner,
|
|
82
|
+
instrument: [returnPolicyAsInstrument], // add returnPolicy(2025-01-21~)
|
|
79
83
|
object: simpleOrder,
|
|
80
84
|
project: order.project,
|
|
81
|
-
recipient
|
|
85
|
+
recipient,
|
|
82
86
|
typeOf: factory.actionType.ReturnAction
|
|
83
87
|
};
|
|
84
88
|
let returnedOwnershipInfos = [];
|
|
@@ -125,7 +129,8 @@ function returnOrder(params) {
|
|
|
125
129
|
orderDate: returnedOrder.orderDate,
|
|
126
130
|
orderStatus: factory.orderStatus.OrderReturned
|
|
127
131
|
},
|
|
128
|
-
returnOrderTransaction
|
|
132
|
+
returnOrderTransaction,
|
|
133
|
+
returnOrderAction: Object.assign(Object.assign({}, returnOrderActionAttributes), { id: action.id })
|
|
129
134
|
})(repos
|
|
130
135
|
// settings
|
|
131
136
|
);
|
|
@@ -100,7 +100,7 @@ schedule, createDate) {
|
|
|
100
100
|
}
|
|
101
101
|
let existingApplicationMembers = [];
|
|
102
102
|
if (applicationIds.length > 0) {
|
|
103
|
-
existingApplicationMembers =
|
|
103
|
+
existingApplicationMembers = yield repos.member.searchCustomerMembers({
|
|
104
104
|
limit: 100,
|
|
105
105
|
page: 1,
|
|
106
106
|
project: { id: project.id },
|
|
@@ -110,7 +110,7 @@ schedule, createDate) {
|
|
|
110
110
|
// },
|
|
111
111
|
id: { $in: applicationIds }
|
|
112
112
|
}
|
|
113
|
-
})
|
|
113
|
+
});
|
|
114
114
|
}
|
|
115
115
|
// ロールで絞る(customer or pos)
|
|
116
116
|
// existingApplicationMembers = existingApplicationMembers
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { IssuerRepo } from '../../../../repo/issuer';
|
|
1
2
|
import type { MemberRepo } from '../../../../repo/member';
|
|
3
|
+
import type { MemberProgramRepo } from '../../../../repo/memberProgram';
|
|
2
4
|
import type { ProjectMakesOfferRepo } from '../../../../repo/projectMakesOffer';
|
|
3
5
|
import type { ISellerWithId, SellerRepo } from '../../../../repo/seller';
|
|
4
6
|
import * as factory from '../../../../factory';
|
|
@@ -15,9 +17,15 @@ declare function validateStartRequest(params: {
|
|
|
15
17
|
* passportによって決定するカスタマータイプ
|
|
16
18
|
*/
|
|
17
19
|
customerType?: string;
|
|
20
|
+
/**
|
|
21
|
+
* メンバーシップトークン
|
|
22
|
+
* プロジェクトオファーにvalidForMemberTierが存在する場合に必須
|
|
23
|
+
*/
|
|
18
24
|
memberOfToken?: string;
|
|
19
25
|
}): (repos: {
|
|
26
|
+
issuer: IssuerRepo;
|
|
20
27
|
member: MemberRepo;
|
|
28
|
+
memberProgram: MemberProgramRepo;
|
|
21
29
|
projectMakesOffer: ProjectMakesOfferRepo;
|
|
22
30
|
seller: SellerRepo;
|
|
23
31
|
}) => Promise<{
|
|
@@ -49,10 +49,10 @@ function verifyMembershipToken(params) {
|
|
|
49
49
|
return result;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
// tslint:disable-next-line:max-func-body-length
|
|
53
52
|
function validateStartRequest(params) {
|
|
53
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
54
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a, _b, _c
|
|
55
|
+
var _a, _b, _c;
|
|
56
56
|
const clientId = (_a = params.clientUser) === null || _a === void 0 ? void 0 : _a.client_id;
|
|
57
57
|
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
58
58
|
throw new factory.errors.ArgumentNull('client_id');
|
|
@@ -120,13 +120,40 @@ function validateStartRequest(params) {
|
|
|
120
120
|
}
|
|
121
121
|
// メンバーシップトークン検証(2024-01-31~)
|
|
122
122
|
let memeberOfPayload;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
// 適用メンバーシップについてはproject.makesOfferを参照(2025-01-13~)
|
|
124
|
+
const validMemberProgramIdentifier = (_c = projectMakesOffer.validForMemberTier) === null || _c === void 0 ? void 0 : _c.isTierOf.identifier;
|
|
125
|
+
if (typeof validMemberProgramIdentifier === 'string') {
|
|
126
|
+
// メンバープログラムと発行者を参照(2025-01-16~)
|
|
127
|
+
const memberProgram = (yield repos.memberProgram.search({
|
|
128
|
+
limit: 1,
|
|
129
|
+
page: 1,
|
|
130
|
+
project: { id: { $eq: params.project.id } },
|
|
131
|
+
identifier: { $eq: validMemberProgramIdentifier }
|
|
132
|
+
})).shift();
|
|
133
|
+
if (memberProgram === undefined) {
|
|
134
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
128
135
|
}
|
|
136
|
+
const issuer = yield repos.issuer.findByIdentifier({
|
|
137
|
+
project: { id: params.project.id },
|
|
138
|
+
identifier: memberProgram.hostingOrganization.identifier
|
|
139
|
+
});
|
|
140
|
+
if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
141
|
+
throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
142
|
+
}
|
|
143
|
+
memeberOfPayload = yield verifyMembershipToken(Object.assign({ secret: issuer.tokenSecret, issuer: issuer.identifier }, (typeof params.memberOfToken === 'string') ? { token: params.memberOfToken } : undefined));
|
|
129
144
|
}
|
|
145
|
+
// discontinue(2025-01-14~)
|
|
146
|
+
// if (Array.isArray(iamMember.member.member)) {
|
|
147
|
+
// const verifySecret = iamMember.member.member[0]?.memberOf?.secret; // ひとまず1種類のメンバーシップのみ対応
|
|
148
|
+
// const verifyIssuer = iamMember.member.member[0]?.memberOf?.issuer; // ひとまず1種類のメンバーシップのみ対応
|
|
149
|
+
// if (typeof verifySecret === 'string') {
|
|
150
|
+
// memeberOfPayload = await verifyMembershipToken({
|
|
151
|
+
// secret: verifySecret,
|
|
152
|
+
// ...(typeof params.memberOfToken === 'string') ? { token: params.memberOfToken } : undefined,
|
|
153
|
+
// ...(typeof verifyIssuer === 'string') ? { issuer: verifyIssuer } : undefined
|
|
154
|
+
// });
|
|
155
|
+
// }
|
|
156
|
+
// }
|
|
130
157
|
return Object.assign({ sellerMakesOffer,
|
|
131
158
|
seller }, (memeberOfPayload !== undefined) ? { memeberOfPayload } : undefined);
|
|
132
159
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
1
2
|
import type { MemberRepo } from '../../../repo/member';
|
|
3
|
+
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
2
4
|
import type { PassportRepo } from '../../../repo/passport';
|
|
3
5
|
import type { ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
|
|
4
6
|
import type { SellerRepo } from '../../../repo/seller';
|
|
5
7
|
import type { IStartedTransaction, TransactionRepo } from '../../../repo/transaction';
|
|
6
8
|
import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
7
9
|
interface IStartOperationRepos {
|
|
10
|
+
issuer: IssuerRepo;
|
|
8
11
|
member: MemberRepo;
|
|
12
|
+
memberProgram: MemberProgramRepo;
|
|
9
13
|
passport: PassportRepo;
|
|
10
14
|
projectMakesOffer: ProjectMakesOfferRepo;
|
|
11
15
|
seller: SellerRepo;
|
|
@@ -8,6 +8,7 @@ import type { OrderRepo } from '../../../repo/order';
|
|
|
8
8
|
import type { ProjectRepo } from '../../../repo/project';
|
|
9
9
|
import type { ReservationRepo } from '../../../repo/reservation';
|
|
10
10
|
import type { ISellerWithId, SellerRepo } from '../../../repo/seller';
|
|
11
|
+
import type { SellerReturnPolicyRepo } from '../../../repo/sellerReturnPolicy';
|
|
11
12
|
interface IPreStartOperationRepos {
|
|
12
13
|
acceptedOffer: AcceptedOfferRepo;
|
|
13
14
|
event: EventRepo;
|
|
@@ -18,6 +19,7 @@ interface IPreStartOperationRepos {
|
|
|
18
19
|
project: ProjectRepo;
|
|
19
20
|
reservation: ReservationRepo;
|
|
20
21
|
seller: SellerRepo;
|
|
22
|
+
sellerReturnPolicy: SellerReturnPolicyRepo;
|
|
21
23
|
}
|
|
22
24
|
type IPreStartOperation<T> = (repos: IPreStartOperationRepos) => Promise<T>;
|
|
23
25
|
type IFixedSeller = Pick<ISellerWithId, 'id' | 'name' | 'project' | 'hasMerchantReturnPolicy' | 'typeOf'>;
|
|
@@ -24,7 +24,6 @@ exports.preStart = preStart;
|
|
|
24
24
|
const createDebug = require("debug");
|
|
25
25
|
const http_status_1 = require("http-status");
|
|
26
26
|
const moment = require("moment-timezone");
|
|
27
|
-
// import * as request from 'request';
|
|
28
27
|
const factory = require("../../../factory");
|
|
29
28
|
const debug = createDebug('chevre-domain:service');
|
|
30
29
|
/**
|
|
@@ -60,10 +59,18 @@ function preStart(params) {
|
|
|
60
59
|
typeOf: factory.eventType.ScreeningEvent
|
|
61
60
|
}, ['startDate']);
|
|
62
61
|
}
|
|
63
|
-
let returnPolicies =
|
|
64
|
-
if (
|
|
65
|
-
|
|
62
|
+
let returnPolicies = [];
|
|
63
|
+
if (Array.isArray(seller.hasMerchantReturnPolicy)) {
|
|
64
|
+
const sellerReturnPolicyIdentifiers = seller.hasMerchantReturnPolicy.map(({ identifier }) => identifier);
|
|
65
|
+
// support sellerReturnPolicyRepo(2025-01-19~)
|
|
66
|
+
if (sellerReturnPolicyIdentifiers.length > 0) {
|
|
67
|
+
returnPolicies = yield repos.sellerReturnPolicy.projectFields({
|
|
68
|
+
project: { id: { $eq: seller.project.id } },
|
|
69
|
+
identifier: { $in: sellerReturnPolicyIdentifiers }
|
|
70
|
+
}, ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'restockingFee', 'typeOf']);
|
|
71
|
+
}
|
|
66
72
|
}
|
|
73
|
+
debug('returnOrder.preStart: returnPolicies:', JSON.stringify(returnPolicies));
|
|
67
74
|
// アイテムコンディション取得
|
|
68
75
|
let offerItemConditions = [];
|
|
69
76
|
const itemConditionIds = returnPolicies
|
|
@@ -316,11 +323,16 @@ function getReturnPolicyByProject(params) {
|
|
|
316
323
|
throw new factory.errors.Internal('invalid return policy');
|
|
317
324
|
}
|
|
318
325
|
else {
|
|
319
|
-
returnPolicy =
|
|
326
|
+
returnPolicy = {
|
|
327
|
+
typeOf: 'MerchantReturnPolicy',
|
|
328
|
+
restockingFee: {
|
|
320
329
|
currency: factory.priceCurrency.JPY,
|
|
321
330
|
typeOf: 'MonetaryAmount',
|
|
322
331
|
value: body.restockingFee.value
|
|
323
|
-
}
|
|
332
|
+
},
|
|
333
|
+
// keep identifier(2024-06-26~)
|
|
334
|
+
identifier
|
|
335
|
+
};
|
|
324
336
|
}
|
|
325
337
|
break;
|
|
326
338
|
case http_status_1.NOT_FOUND:
|
|
@@ -358,7 +370,7 @@ function findApplicableReturnPolicy(params) {
|
|
|
358
370
|
const returnPolicySameAsByPoject = (_a = params.returnPolicySettingsByProject) === null || _a === void 0 ? void 0 : _a.sameAs;
|
|
359
371
|
if (typeof returnPolicySameAsByPoject === 'string' && returnPolicySameAsByPoject.length > 0) {
|
|
360
372
|
const returnPolicyByProject = yield getReturnPolicyByProject({
|
|
361
|
-
identifier: (_b = params.returnPolicySettingsByProject) === null || _b === void 0 ? void 0 : _b.identifier,
|
|
373
|
+
identifier: String((_b = params.returnPolicySettingsByProject) === null || _b === void 0 ? void 0 : _b.identifier),
|
|
362
374
|
sameAs: returnPolicySameAsByPoject,
|
|
363
375
|
order: Object.assign(Object.assign({}, params.orders[0]), { acceptedOffers: params.acceptedOffers })
|
|
364
376
|
});
|
|
@@ -10,6 +10,7 @@ import type { OrderRepo } from '../../repo/order';
|
|
|
10
10
|
import type { ProjectRepo } from '../../repo/project';
|
|
11
11
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
12
12
|
import type { SellerRepo } from '../../repo/seller';
|
|
13
|
+
import type { SellerReturnPolicyRepo } from '../../repo/sellerReturnPolicy';
|
|
13
14
|
import type { SettingRepo } from '../../repo/setting';
|
|
14
15
|
import type { TaskRepo } from '../../repo/task';
|
|
15
16
|
import type { IStartedTransaction, TransactionRepo } from '../../repo/transaction';
|
|
@@ -24,6 +25,7 @@ interface IStartOperationRepos {
|
|
|
24
25
|
project: ProjectRepo;
|
|
25
26
|
reservation: ReservationRepo;
|
|
26
27
|
seller: SellerRepo;
|
|
28
|
+
sellerReturnPolicy: SellerReturnPolicyRepo;
|
|
27
29
|
transaction: TransactionRepo;
|
|
28
30
|
}
|
|
29
31
|
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.392.0
|
|
15
|
-
"@cinerino/sdk": "10.20.0
|
|
14
|
+
"@chevre/factory": "4.392.0",
|
|
15
|
+
"@cinerino/sdk": "10.20.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.8.0
|
|
115
|
+
"version": "22.8.0"
|
|
116
116
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
const SELLER_ID = '59d20831e53ebc2b4e774466';
|
|
8
|
-
const PAYMENT_METHOD_TYPE = 'Cash';
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const paymentAcceptedRepo = await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
let paymentAccepted = await paymentAcceptedRepo.search({
|
|
16
|
-
project: { id: { $eq: project.id } },
|
|
17
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
18
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
19
|
-
});
|
|
20
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
21
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
await paymentAcceptedRepo.deleteOne({
|
|
25
|
-
codeValue: PAYMENT_METHOD_TYPE,
|
|
26
|
-
project: { id: project.id },
|
|
27
|
-
seller: { id: SELLER_ID }
|
|
28
|
-
});
|
|
29
|
-
console.log('paymentAccepted deleted');
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(error);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
paymentAccepted = await paymentAcceptedRepo.search({
|
|
35
|
-
project: { id: { $eq: project.id } },
|
|
36
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
37
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
38
|
-
});
|
|
39
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
40
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
41
|
-
|
|
42
|
-
await paymentAcceptedRepo.create({
|
|
43
|
-
codeValue: PAYMENT_METHOD_TYPE,
|
|
44
|
-
project: { id: project.id },
|
|
45
|
-
seller: { id: SELLER_ID }
|
|
46
|
-
});
|
|
47
|
-
console.log('paymentAccepted created');
|
|
48
|
-
|
|
49
|
-
paymentAccepted = await paymentAcceptedRepo.search({
|
|
50
|
-
project: { id: { $eq: project.id } },
|
|
51
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
52
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
53
|
-
});
|
|
54
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
55
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
main()
|
|
59
|
-
.then()
|
|
60
|
-
.catch(console.error);
|