@chevre/domain 21.24.1 → 21.25.0-alpha.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/migrateDeleteTransactionTasks.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +4 -1
- package/lib/chevre/repo/ownershipInfo.js +4 -5
- package/lib/chevre/service/delivery/factory.js +0 -8
- package/lib/chevre/service/order/returnOrder.js +1 -3
- package/lib/chevre/service/order/sendOrder.js +21 -9
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -13,7 +13,10 @@ const schemaDefinition = {
|
|
|
13
13
|
type: String,
|
|
14
14
|
required: true
|
|
15
15
|
},
|
|
16
|
-
identifier:
|
|
16
|
+
identifier: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
17
20
|
ownedBy: mongoose_1.SchemaTypes.Mixed,
|
|
18
21
|
acquiredFrom: mongoose_1.SchemaTypes.Mixed,
|
|
19
22
|
ownedFrom: Date,
|
|
@@ -225,9 +225,8 @@ class MongoRepository {
|
|
|
225
225
|
let doc;
|
|
226
226
|
let duplicate = false;
|
|
227
227
|
try {
|
|
228
|
-
doc = yield this.ownershipInfoModel.findOneAndUpdate({ identifier: ownershipInfo.identifier }, {
|
|
229
|
-
// insert
|
|
230
|
-
// $set: ownershipInfo,
|
|
228
|
+
doc = yield this.ownershipInfoModel.findOneAndUpdate({ identifier: { $eq: ownershipInfo.identifier } }, {
|
|
229
|
+
// insert時以外は何もしなくてもよい
|
|
231
230
|
$setOnInsert: Object.assign(Object.assign({}, ownershipInfo), { _id: uuid.v4() // 新規作成時は所有権ID発行
|
|
232
231
|
})
|
|
233
232
|
}, {
|
|
@@ -254,7 +253,7 @@ class MongoRepository {
|
|
|
254
253
|
}
|
|
255
254
|
if (duplicate) {
|
|
256
255
|
// 重複の場合、再度取得
|
|
257
|
-
doc = yield this.ownershipInfoModel.findOne({ identifier: ownershipInfo.identifier }, {
|
|
256
|
+
doc = yield this.ownershipInfoModel.findOne({ identifier: { $eq: ownershipInfo.identifier } }, {
|
|
258
257
|
__v: 0,
|
|
259
258
|
createdAt: 0,
|
|
260
259
|
updatedAt: 0
|
|
@@ -313,7 +312,7 @@ class MongoRepository {
|
|
|
313
312
|
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
314
313
|
.exec()
|
|
315
314
|
.then((doc) => {
|
|
316
|
-
//
|
|
315
|
+
// 存在しない場合も正常にハンドルする
|
|
317
316
|
if (doc === null) {
|
|
318
317
|
return;
|
|
319
318
|
}
|
|
@@ -85,8 +85,6 @@ function createOwnedby(params) {
|
|
|
85
85
|
// 個人情報排除するように
|
|
86
86
|
typeOf: customer.typeOf,
|
|
87
87
|
id: customer.id
|
|
88
|
-
// project: customer.project,
|
|
89
|
-
// ...(Array.isArray(customer.identifier)) ? { identifier: customer.identifier } : undefined
|
|
90
88
|
};
|
|
91
89
|
owner = ownerAsOrganization;
|
|
92
90
|
}
|
|
@@ -95,10 +93,6 @@ function createOwnedby(params) {
|
|
|
95
93
|
// 個人情報排除するように
|
|
96
94
|
typeOf: customer.typeOf,
|
|
97
95
|
id: customer.id
|
|
98
|
-
// ...(Array.isArray(customer.identifier)) ? { identifier: customer.identifier } : undefined,
|
|
99
|
-
// ...(customer.typeOf === factory.personType.Person && typeof customer.memberOf?.typeOf === 'string')
|
|
100
|
-
// ? { memberOf: customer.memberOf }
|
|
101
|
-
// : undefined
|
|
102
96
|
};
|
|
103
97
|
owner = ownerAsPerson;
|
|
104
98
|
}
|
|
@@ -107,8 +101,6 @@ function createOwnedby(params) {
|
|
|
107
101
|
// 個人情報排除するように
|
|
108
102
|
typeOf: customer.typeOf,
|
|
109
103
|
id: customer.id
|
|
110
|
-
// ↓不要なので廃止(2022-07-28~)
|
|
111
|
-
// ...(Array.isArray(customer.identifier)) ? { identifier: customer.identifier } : undefined
|
|
112
104
|
};
|
|
113
105
|
}
|
|
114
106
|
return [owner];
|
|
@@ -139,8 +139,6 @@ function processReturnOrder(order, dateReturned) {
|
|
|
139
139
|
// 所有権の所有期間変更
|
|
140
140
|
// 注文オファーリポジトリから所有権識別子を検索する(2023-12-07~)
|
|
141
141
|
const ownershipInfos = yield repos.acceptedOffer.aggreateOwnershipInfosByOrder({ orderNumber: { $eq: order.orderNumber } });
|
|
142
|
-
// const ownershipInfos = createOwnershipInfosFromOrder({ order });
|
|
143
|
-
debug('processing findByIdentifierAndUpdateOwnedThrough...', ownershipInfos);
|
|
144
142
|
if (Array.isArray(ownershipInfos)) {
|
|
145
143
|
yield Promise.all(ownershipInfos.map((ownershipInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
146
144
|
const ownershipInfoReturned = yield repos.ownershipInfo.findByIdentifierAndUpdateOwnedThrough({
|
|
@@ -149,7 +147,7 @@ function processReturnOrder(order, dateReturned) {
|
|
|
149
147
|
ownedThrough: dateReturned
|
|
150
148
|
})
|
|
151
149
|
.then((ownershipInfoByDB) => {
|
|
152
|
-
//
|
|
150
|
+
// 存在しない場合は識別子のみ保管(customer.typeOfによって存在しないこともありうる)
|
|
153
151
|
if (ownershipInfoByDB === undefined) {
|
|
154
152
|
return ownershipInfo;
|
|
155
153
|
}
|
|
@@ -16,6 +16,7 @@ const factory_1 = require("../delivery/factory");
|
|
|
16
16
|
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
17
17
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
18
18
|
const factory = require("../../factory");
|
|
19
|
+
const settings_1 = require("../../settings");
|
|
19
20
|
const debug = createDebug('chevre-domain:service:order');
|
|
20
21
|
/**
|
|
21
22
|
* 注文を配送する
|
|
@@ -87,9 +88,20 @@ function sendOrder(params) {
|
|
|
87
88
|
typeOf: factory.actionType.SendAction
|
|
88
89
|
};
|
|
89
90
|
const action = yield repos.action.start(sendOrderActionAttributes);
|
|
90
|
-
let ownershipInfos;
|
|
91
|
+
let ownershipInfos = [];
|
|
91
92
|
let allOffersDelivered = false;
|
|
92
93
|
let acceptedOffers;
|
|
94
|
+
// 所有権生成を最小化(2024-03-01~)
|
|
95
|
+
let createOwnerships = false;
|
|
96
|
+
switch (order.customer.typeOf) {
|
|
97
|
+
case factory.creativeWorkType.WebApplication:
|
|
98
|
+
if (settings_1.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION) {
|
|
99
|
+
createOwnerships = true;
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
createOwnerships = true;
|
|
104
|
+
}
|
|
93
105
|
try {
|
|
94
106
|
const searchSlicedAcceptedOffersResult = yield repos.acceptedOffer.searchSlicedAcceptedOffersByOrderNumber({
|
|
95
107
|
$slice: [limit * (page - 1), limit],
|
|
@@ -97,15 +109,15 @@ function sendOrder(params) {
|
|
|
97
109
|
project: { id: { $eq: order.project.id } }
|
|
98
110
|
});
|
|
99
111
|
acceptedOffers = searchSlicedAcceptedOffersResult.acceptedOffers;
|
|
100
|
-
debug('delivering...', order.orderNumber, acceptedOffers.map((offer) => `${offer.itemOffered.id}`), params.object.acceptedOffers);
|
|
101
112
|
// 所有権作成
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
113
|
+
if (createOwnerships) {
|
|
114
|
+
ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({ order: Object.assign(Object.assign({}, order), { acceptedOffers }) });
|
|
115
|
+
ownershipInfos = yield Promise.all(ownershipInfos.map((ownershipInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return repos.ownershipInfo.createIfNotExistByIdentifier(ownershipInfo);
|
|
117
|
+
})));
|
|
118
|
+
}
|
|
119
|
+
// const deliveredCount = limit * page;
|
|
120
|
+
// debug(deliveredCount, 'delivered.', order.orderNumber, params.object.acceptedOffers);
|
|
109
121
|
if (acceptedOffers.length === 0) {
|
|
110
122
|
order = yield repos.order.changeStatus({
|
|
111
123
|
project: { id: order.project.id },
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
|
|
|
43
43
|
export declare const USE_MINIMIZED_PAY_TASK: boolean;
|
|
44
44
|
export declare const USE_KANA_NAME_IN_ACCEPTED_OFFER: boolean;
|
|
45
45
|
export declare const USE_VALIDATE_PROJECT_MAKES_OFFER: boolean;
|
|
46
|
+
export declare const USE_OWNERSHIP_INFO_BY_WEB_APPLICATION: boolean;
|
|
46
47
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
47
48
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
48
49
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -67,6 +67,7 @@ exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = process.env.USE_SEND_EMAIL_
|
|
|
67
67
|
exports.USE_MINIMIZED_PAY_TASK = process.env.USE_MINIMIZED_PAY_TASK === '1';
|
|
68
68
|
exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = process.env.USE_KANA_NAME_IN_ACCEPTED_OFFER === '1';
|
|
69
69
|
exports.USE_VALIDATE_PROJECT_MAKES_OFFER = process.env.USE_VALIDATE_PROJECT_MAKES_OFFER === '1';
|
|
70
|
+
exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = process.env.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION === '1';
|
|
70
71
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
71
72
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
72
73
|
// tslint:disable-next-line:no-magic-numbers
|
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.
|
|
13
|
+
"@chevre/factory": "4.359.0",
|
|
14
14
|
"@cinerino/sdk": "5.12.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.3.0-alpha.5",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.4",
|
|
@@ -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.
|
|
113
|
+
"version": "21.25.0-alpha.0"
|
|
114
114
|
}
|