@chevre/domain 26.0.0-alpha.23 → 26.0.0-alpha.25
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/acceptedOffer.d.ts +0 -7
- package/lib/chevre/repo/acceptedOffer.js +27 -27
- package/lib/chevre/repo/authorization.js +15 -15
- package/lib/chevre/repo/mongoose/schemas/action.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
- package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -146
- package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
- package/lib/chevre/repo/ownershipInfo.d.ts +6 -108
- package/lib/chevre/repo/ownershipInfo.js +59 -395
- package/lib/chevre/repo/task.d.ts +25 -4
- package/lib/chevre/repo/task.js +1 -0
- package/lib/chevre/service/order/deleteOrder.js +0 -1
- package/lib/chevre/service/order/returnOrder.d.ts +0 -2
- package/lib/chevre/service/order/returnOrder.js +8 -40
- package/lib/chevre/service/order/sendOrder.d.ts +0 -2
- package/lib/chevre/service/order/sendOrder.js +41 -55
- package/lib/chevre/service/task/onAuthorizationCreated.js +2 -2
- package/lib/chevre/service/task/returnOrder.js +2 -5
- package/lib/chevre/service/task/sendOrder.js +2 -2
- package/package.json +2 -2
|
@@ -5,33 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.sendOrder = sendOrder;
|
|
7
7
|
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
// import {
|
|
9
|
-
const factory_1 = require("../delivery/factory");
|
|
10
|
-
// import { findPlaceOrderTransaction } from './findPlaceOrderTransaction';
|
|
8
|
+
// import { createOwnershipInfosFromOrder } from '../delivery/factory';
|
|
11
9
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
12
|
-
const
|
|
10
|
+
const factory_1 = require("../../factory");
|
|
13
11
|
const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
14
12
|
/**
|
|
15
13
|
* 注文を配送する
|
|
16
14
|
*/
|
|
17
15
|
function sendOrder(params) {
|
|
18
|
-
return async (repos
|
|
19
|
-
// settings: Settings
|
|
20
|
-
) => {
|
|
16
|
+
return async (repos) => {
|
|
21
17
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
22
|
-
throw new
|
|
18
|
+
throw new factory_1.factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
23
19
|
}
|
|
24
20
|
if (typeof params.object.acceptedOffers?.limit !== 'number') {
|
|
25
|
-
throw new
|
|
21
|
+
throw new factory_1.factory.errors.Argument('object.acceptedOffers.limit', 'must be number');
|
|
26
22
|
}
|
|
27
23
|
if (typeof params.object.acceptedOffers?.page !== 'number') {
|
|
28
|
-
throw new
|
|
24
|
+
throw new factory_1.factory.errors.Argument('object.acceptedOffers.page', 'must be number');
|
|
29
25
|
}
|
|
30
26
|
if (params.object.acceptedOffers.limit <= 0) {
|
|
31
|
-
throw new
|
|
27
|
+
throw new factory_1.factory.errors.Argument('object.acceptedOffers.limit', 'must be greater than 1');
|
|
32
28
|
}
|
|
33
29
|
if (params.object.acceptedOffers.page <= 0) {
|
|
34
|
-
throw new
|
|
30
|
+
throw new factory_1.factory.errors.Argument('object.acceptedOffers.page', 'must be greater than 1');
|
|
35
31
|
}
|
|
36
32
|
try {
|
|
37
33
|
const orderNumber = params.object.orderNumber;
|
|
@@ -49,24 +45,16 @@ function sendOrder(params) {
|
|
|
49
45
|
});
|
|
50
46
|
// プロジェクト条件検証
|
|
51
47
|
if (order.project.id !== params.project.id) {
|
|
52
|
-
throw new
|
|
48
|
+
throw new factory_1.factory.errors.NotFound('Order');
|
|
53
49
|
}
|
|
54
50
|
// 確認番号検証
|
|
55
51
|
if (order.confirmationNumber !== confirmationNumber) {
|
|
56
|
-
throw new
|
|
52
|
+
throw new factory_1.factory.errors.NotFound('Order');
|
|
57
53
|
}
|
|
58
54
|
// const maskedCustomer = createMaskedCustomer(order, { noProfile: true });
|
|
59
55
|
const simpleOrder = {
|
|
60
56
|
typeOf: order.typeOf,
|
|
61
|
-
// seller: {
|
|
62
|
-
// id: order.seller.id,
|
|
63
|
-
// typeOf: order.seller.typeOf,
|
|
64
|
-
// name: order.seller.name
|
|
65
|
-
// }, // 廃止(2024-03-06~)
|
|
66
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
67
57
|
orderNumber: order.orderNumber,
|
|
68
|
-
// price: order.price,
|
|
69
|
-
// priceCurrency: order.priceCurrency,
|
|
70
58
|
orderDate: order.orderDate
|
|
71
59
|
};
|
|
72
60
|
const { limit, page } = params.object.acceptedOffers;
|
|
@@ -77,24 +65,24 @@ function sendOrder(params) {
|
|
|
77
65
|
const sendOrderActionAttributes = {
|
|
78
66
|
agent: (typeof params.agent?.typeOf === 'string') ? params.agent : order.project,
|
|
79
67
|
object: sendOrderObject,
|
|
80
|
-
// potentialActions: {},
|
|
81
68
|
project: order.project,
|
|
82
69
|
recipient: { id: order.customer.id, typeOf: order.customer.typeOf },
|
|
83
|
-
typeOf:
|
|
70
|
+
typeOf: factory_1.factory.actionType.SendAction
|
|
84
71
|
};
|
|
85
72
|
const action = await repos.action.start(sendOrderActionAttributes);
|
|
86
|
-
let creatingOwnershipInfos = [];
|
|
87
|
-
|
|
73
|
+
// let creatingOwnershipInfos: IOwnershipInfo[] = [];
|
|
74
|
+
const createdOwnershipInfos = [];
|
|
88
75
|
let allOffersDelivered = false;
|
|
89
76
|
let acceptedOffers;
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
// 所有権管理はひとまず廃止(2026-08-10~)
|
|
78
|
+
// // 所有権生成を最小化(2024-03-01~)
|
|
79
|
+
// let createOwnerships = false;
|
|
80
|
+
// switch (order.customer.typeOf) {
|
|
81
|
+
// case factory.personType.Person:
|
|
82
|
+
// createOwnerships = true; // Personのみに限定(2026-03-15~)
|
|
83
|
+
// break;
|
|
84
|
+
// default:
|
|
85
|
+
// }
|
|
98
86
|
try {
|
|
99
87
|
const offerIndexBase = (limit * (page - 1));
|
|
100
88
|
const searchSlicedAcceptedOffersResult = await repos.acceptedOffer.searchSlicedAcceptedOffersByOrderNumber({
|
|
@@ -104,29 +92,27 @@ function sendOrder(params) {
|
|
|
104
92
|
});
|
|
105
93
|
acceptedOffers = searchSlicedAcceptedOffersResult.acceptedOffers;
|
|
106
94
|
debug('delivering...', order.orderNumber, params.object.acceptedOffers, 'offerIndexBase:', offerIndexBase);
|
|
107
|
-
//
|
|
108
|
-
if (createOwnerships) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
// const deliveredCount = limit * page;
|
|
124
|
-
// debug(deliveredCount, 'delivered.', order.orderNumber, params.object.acceptedOffers);
|
|
95
|
+
// 所有権管理はひとまず廃止(2026-08-10~)
|
|
96
|
+
// if (createOwnerships) {
|
|
97
|
+
// creatingOwnershipInfos = createOwnershipInfosFromOrder({
|
|
98
|
+
// order: { ...order, acceptedOffers },
|
|
99
|
+
// offerIndexBase
|
|
100
|
+
// });
|
|
101
|
+
// createdOwnershipInfos = await Promise.all(creatingOwnershipInfos.map(async (creatingOwnershipInfo) => {
|
|
102
|
+
// const { id } = await repos.ownershipInfo.createIfNotExistByIdentifier(creatingOwnershipInfo);
|
|
103
|
+
// return {
|
|
104
|
+
// id,
|
|
105
|
+
// ...(typeof creatingOwnershipInfo.identifier === 'string')
|
|
106
|
+
// ? { identifier: creatingOwnershipInfo.identifier }
|
|
107
|
+
// : undefined
|
|
108
|
+
// };
|
|
109
|
+
// }));
|
|
110
|
+
// }
|
|
125
111
|
if (acceptedOffers.length === 0) {
|
|
126
112
|
order = await repos.order.changeStatus({
|
|
127
113
|
project: { id: order.project.id },
|
|
128
114
|
orderNumber,
|
|
129
|
-
orderStatus:
|
|
115
|
+
orderStatus: factory_1.factory.orderStatus.OrderDelivered,
|
|
130
116
|
previousOrderStatus: params.object.previousOrderStatus
|
|
131
117
|
});
|
|
132
118
|
allOffersDelivered = true;
|
|
@@ -154,7 +140,7 @@ function sendOrder(params) {
|
|
|
154
140
|
orderNumber: order.orderNumber,
|
|
155
141
|
project: order.project,
|
|
156
142
|
typeOf: order.typeOf,
|
|
157
|
-
orderStatus:
|
|
143
|
+
orderStatus: factory_1.factory.orderStatus.OrderDelivered,
|
|
158
144
|
price: order.price,
|
|
159
145
|
priceCurrency: order.priceCurrency
|
|
160
146
|
}
|
|
@@ -180,7 +166,7 @@ function sendOrder(params) {
|
|
|
180
166
|
project: { id: params.project.id },
|
|
181
167
|
inclusion: ['orderStatus']
|
|
182
168
|
});
|
|
183
|
-
if (currentOrder?.orderStatus ===
|
|
169
|
+
if (currentOrder?.orderStatus === factory_1.factory.orderStatus.OrderReturned) {
|
|
184
170
|
throwsError = false;
|
|
185
171
|
}
|
|
186
172
|
if (throwsError) {
|
|
@@ -7,7 +7,7 @@ const action_1 = require("../../repo/action");
|
|
|
7
7
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
8
8
|
const authorization_1 = require("../../repo/authorization");
|
|
9
9
|
const order_1 = require("../../repo/order");
|
|
10
|
-
|
|
10
|
+
// import { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
11
11
|
const reservation_1 = require("../../repo/reservation");
|
|
12
12
|
const setting_1 = require("../../repo/setting");
|
|
13
13
|
const task_1 = require("../../repo/task");
|
|
@@ -23,7 +23,7 @@ function call(params) {
|
|
|
23
23
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
24
24
|
code: new authorization_1.AuthorizationRepo(connection),
|
|
25
25
|
order: new order_1.OrderRepo(connection),
|
|
26
|
-
ownershipInfo: new
|
|
26
|
+
// ownershipInfo: new OwnershipInfoRepo(connection),
|
|
27
27
|
reservation: new reservation_1.ReservationRepo(connection),
|
|
28
28
|
setting: new setting_1.SettingRepo(connection),
|
|
29
29
|
task: new task_1.TaskRepo(connection)
|
|
@@ -4,7 +4,6 @@ exports.call = call;
|
|
|
4
4
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
5
5
|
const action_1 = require("../../repo/action");
|
|
6
6
|
const order_1 = require("../../repo/order");
|
|
7
|
-
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
8
7
|
const setting_1 = require("../../repo/setting");
|
|
9
8
|
const task_1 = require("../../repo/task");
|
|
10
9
|
const returnOrder_1 = require("../../repo/transaction/returnOrder");
|
|
@@ -22,12 +21,10 @@ function call(params) {
|
|
|
22
21
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
23
22
|
action: new action_1.ActionRepo(connection),
|
|
24
23
|
order: new order_1.OrderRepo(connection),
|
|
25
|
-
ownershipInfo: new
|
|
24
|
+
// ownershipInfo: new OwnershipInfoRepo(connection),
|
|
26
25
|
setting: new setting_1.SettingRepo(connection),
|
|
27
26
|
task: new task_1.TaskRepo(connection),
|
|
28
27
|
returnOrder: new returnOrder_1.ReturnOrderRepo(connection)
|
|
29
|
-
}
|
|
30
|
-
// settings
|
|
31
|
-
);
|
|
28
|
+
});
|
|
32
29
|
};
|
|
33
30
|
}
|
|
@@ -5,7 +5,7 @@ const factory_1 = require("../../factory");
|
|
|
5
5
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
6
6
|
const action_1 = require("../../repo/action");
|
|
7
7
|
const order_1 = require("../../repo/order");
|
|
8
|
-
|
|
8
|
+
// import { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
9
9
|
const setting_1 = require("../../repo/setting");
|
|
10
10
|
const task_1 = require("../../repo/task");
|
|
11
11
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
@@ -32,7 +32,7 @@ function call(params) {
|
|
|
32
32
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
33
33
|
action: new action_1.ActionRepo(connection),
|
|
34
34
|
order: new order_1.OrderRepo(connection),
|
|
35
|
-
ownershipInfo: new
|
|
35
|
+
// ownershipInfo: new OwnershipInfoRepo(connection),
|
|
36
36
|
setting: new setting_1.SettingRepo(connection),
|
|
37
37
|
task: new task_1.TaskRepo(connection),
|
|
38
38
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "10.3.0-alpha.
|
|
14
|
+
"@chevre/factory": "10.3.0-alpha.2",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "26.0.0-alpha.
|
|
91
|
+
"version": "26.0.0-alpha.25"
|
|
92
92
|
}
|