@chevre/domain 21.29.0-alpha.5 → 21.29.0-alpha.7
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/unsetUnnecessaryFields.ts +8 -7
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -14
- package/lib/chevre/repo/order.js +1 -1
- package/lib/chevre/repo/transaction.d.ts +6 -0
- package/lib/chevre/repo/transaction.js +6 -7
- package/lib/chevre/service/assetTransaction/reserve/factory.js +10 -2
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/order/placeOrder.js +3 -1
- package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +9 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +4 -2
- package/package.json +2 -2
|
@@ -8,22 +8,23 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
let updateResult: any;
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
updateResult = await
|
|
11
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
12
|
+
updateResult = await orderRepo.unsetUnnecessaryFields({
|
|
13
13
|
filter: {
|
|
14
|
-
|
|
14
|
+
additionalProperty: { $exists: true }
|
|
15
15
|
},
|
|
16
16
|
$unset: {
|
|
17
|
-
|
|
17
|
+
additionalProperty: 1
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
console.log('unset processed.', updateResult);
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
updateResult = await orderRepo.unsetUnnecessaryFields({
|
|
22
23
|
filter: {
|
|
23
|
-
|
|
24
|
+
orderNumber: { $exists: true }
|
|
24
25
|
},
|
|
25
26
|
$unset: {
|
|
26
|
-
|
|
27
|
+
discounts: 1
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
console.log('unset processed.', updateResult);
|
|
@@ -9,10 +9,7 @@ exports.modelName = modelName;
|
|
|
9
9
|
const schemaDefinition = {
|
|
10
10
|
broker: mongoose_1.SchemaTypes.Mixed,
|
|
11
11
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
-
typeOf: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
12
|
+
typeOf: { type: String, required: true },
|
|
16
13
|
identifier: [mongoose_1.SchemaTypes.Mixed],
|
|
17
14
|
name: String,
|
|
18
15
|
seller: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -24,7 +21,7 @@ const schemaDefinition = {
|
|
|
24
21
|
priceCurrency: String,
|
|
25
22
|
acceptedOffers: [mongoose_1.SchemaTypes.Mixed],
|
|
26
23
|
paymentMethods: [mongoose_1.SchemaTypes.Mixed],
|
|
27
|
-
discounts:
|
|
24
|
+
discounts: mongoose_1.SchemaTypes.Mixed,
|
|
28
25
|
url: String,
|
|
29
26
|
orderStatus: String,
|
|
30
27
|
previousOrderStatus: String,
|
|
@@ -455,15 +452,6 @@ const indexes = [
|
|
|
455
452
|
}
|
|
456
453
|
}
|
|
457
454
|
],
|
|
458
|
-
[
|
|
459
|
-
{ additionalProperty: 1, orderDate: -1 },
|
|
460
|
-
{
|
|
461
|
-
name: 'searchByAdditionalProperty',
|
|
462
|
-
partialFilterExpression: {
|
|
463
|
-
additionalProperty: { $exists: true }
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
],
|
|
467
455
|
[
|
|
468
456
|
{ typeOf: 1, orderDate: -1 },
|
|
469
457
|
{ name: 'searchByTypeOf' }
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -1016,7 +1016,7 @@ class MongoRepository {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
unsetUnnecessaryFields(params) {
|
|
1018
1018
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1019
|
-
return this.orderModel.updateMany(params.filter, { $unset: params.$unset })
|
|
1019
|
+
return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
1020
1020
|
.exec();
|
|
1021
1021
|
});
|
|
1022
1022
|
}
|
|
@@ -86,6 +86,9 @@ export declare class MongoRepository {
|
|
|
86
86
|
*/
|
|
87
87
|
findInProgressConfirmationNumberById(params: {
|
|
88
88
|
id: string;
|
|
89
|
+
status: {
|
|
90
|
+
$in: factory.transactionStatusType[];
|
|
91
|
+
};
|
|
89
92
|
}): Promise<string | undefined>;
|
|
90
93
|
/**
|
|
91
94
|
* 取引進行者プロフィールを更新
|
|
@@ -209,6 +212,9 @@ export declare class MongoRepository {
|
|
|
209
212
|
}): Promise<void>;
|
|
210
213
|
saveConfirmationNumberIfNotExist(params: {
|
|
211
214
|
id: string;
|
|
215
|
+
status: {
|
|
216
|
+
$in: factory.transactionStatusType[];
|
|
217
|
+
};
|
|
212
218
|
confirmationNumber: string;
|
|
213
219
|
}): Promise<void>;
|
|
214
220
|
findByIdAndDelete(params: {
|
|
@@ -323,8 +323,7 @@ class MongoRepository {
|
|
|
323
323
|
if (doc === null) {
|
|
324
324
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
325
325
|
}
|
|
326
|
-
|
|
327
|
-
return transaction.object.orderNumber;
|
|
326
|
+
return doc.toObject().object.orderNumber;
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
329
|
/**
|
|
@@ -335,14 +334,13 @@ class MongoRepository {
|
|
|
335
334
|
const doc = yield this.transactionModel.findOne({
|
|
336
335
|
_id: { $eq: params.id },
|
|
337
336
|
typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
338
|
-
status: { $
|
|
337
|
+
status: { $in: params.status.$in }
|
|
339
338
|
}, { 'object.confirmationNumber': 1 })
|
|
340
339
|
.exec();
|
|
341
340
|
if (doc === null) {
|
|
342
341
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
343
342
|
}
|
|
344
|
-
|
|
345
|
-
return transaction.object.confirmationNumber;
|
|
343
|
+
return doc.toObject().object.confirmationNumber;
|
|
346
344
|
});
|
|
347
345
|
}
|
|
348
346
|
/**
|
|
@@ -742,9 +740,10 @@ class MongoRepository {
|
|
|
742
740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
743
741
|
yield this.transactionModel.updateOne({
|
|
744
742
|
_id: { $eq: params.id },
|
|
745
|
-
status: { $eq: factory.transactionStatusType.InProgress },
|
|
743
|
+
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
744
|
+
status: { $in: params.status.$in },
|
|
746
745
|
'object.confirmationNumber': { $exists: false }
|
|
747
|
-
}, { 'object.confirmationNumber': params.confirmationNumber })
|
|
746
|
+
}, { $set: { 'object.confirmationNumber': params.confirmationNumber } })
|
|
748
747
|
.exec();
|
|
749
748
|
});
|
|
750
749
|
}
|
|
@@ -66,10 +66,17 @@ function createPointAward(params) {
|
|
|
66
66
|
}
|
|
67
67
|
exports.createPointAward = createPointAward;
|
|
68
68
|
function createTicketIdentifier(params) {
|
|
69
|
-
var _a;
|
|
70
|
-
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
// チケット識別子の規定値を作成
|
|
71
|
+
let ticketIdentifier = (typeof ((_a = params.ticketedSeat) === null || _a === void 0 ? void 0 : _a.seatNumber) === 'string')
|
|
71
72
|
? util.format('%s:%s:%s', params.reservationFor.id, params.ticketedSeat.seatSection, params.ticketedSeat.seatNumber)
|
|
72
73
|
: util.format('%s:%s', params.reservationFor.id, params.id);
|
|
74
|
+
// 指定があれば採用
|
|
75
|
+
const ticketIdentifierByRequest = (_d = (_c = (_b = params.acceptedOffer.itemOffered) === null || _b === void 0 ? void 0 : _b.serviceOutput) === null || _c === void 0 ? void 0 : _c.reservedTicket) === null || _d === void 0 ? void 0 : _d.identifier;
|
|
76
|
+
if (typeof ticketIdentifierByRequest === 'string' && ticketIdentifierByRequest.length > 0) {
|
|
77
|
+
ticketIdentifier = ticketIdentifierByRequest;
|
|
78
|
+
}
|
|
79
|
+
return ticketIdentifier;
|
|
73
80
|
}
|
|
74
81
|
function createReservedTicket(params) {
|
|
75
82
|
var _a, _b, _c;
|
|
@@ -128,6 +135,7 @@ function createReservedTicket(params) {
|
|
|
128
135
|
const ticketType = createTicketType({ availableOffer: params.availableOffer });
|
|
129
136
|
const issuedBy = createIssuedBy({ acceptedOffer: params.acceptedOffer, availableOffer: params.availableOffer });
|
|
130
137
|
const ticketIdentifier = createTicketIdentifier({
|
|
138
|
+
acceptedOffer: params.acceptedOffer,
|
|
131
139
|
id: params.id,
|
|
132
140
|
reservationFor: params.reservationFor,
|
|
133
141
|
ticketedSeat
|
|
@@ -290,13 +290,13 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
290
290
|
switch (typeOf) {
|
|
291
291
|
case factory.reservationType.BusReservation:
|
|
292
292
|
const serviceOutputAsBusReservation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined), (programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined), (Array.isArray(subReservation)) ? { subReservation } : undefined), (reservedTicket !== undefined) ? {
|
|
293
|
-
reservedTicket: Object.assign({ typeOf: 'Ticket' }, (typeof (ticketedSeat === null || ticketedSeat === void 0 ? void 0 : ticketedSeat.typeOf) === 'string') ? { ticketedSeat } : undefined)
|
|
293
|
+
reservedTicket: Object.assign(Object.assign({ typeOf: 'Ticket' }, (typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined), (typeof (ticketedSeat === null || ticketedSeat === void 0 ? void 0 : ticketedSeat.typeOf) === 'string') ? { ticketedSeat } : undefined)
|
|
294
294
|
} : undefined);
|
|
295
295
|
itemOfferedServiceOutput = serviceOutputAsBusReservation;
|
|
296
296
|
break;
|
|
297
297
|
case factory.reservationType.EventReservation:
|
|
298
298
|
const serviceOutputAsEventReservation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined), (programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined), (Array.isArray(subReservation)) ? { subReservation } : undefined), (reservedTicket !== undefined) ? {
|
|
299
|
-
reservedTicket: Object.assign({ typeOf: 'Ticket' }, (typeof (ticketedSeat === null || ticketedSeat === void 0 ? void 0 : ticketedSeat.typeOf) === 'string') ? { ticketedSeat } : undefined)
|
|
299
|
+
reservedTicket: Object.assign(Object.assign({ typeOf: 'Ticket' }, (typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined), (typeof (ticketedSeat === null || ticketedSeat === void 0 ? void 0 : ticketedSeat.typeOf) === 'string') ? { ticketedSeat } : undefined)
|
|
300
300
|
} : undefined);
|
|
301
301
|
itemOfferedServiceOutput = serviceOutputAsEventReservation;
|
|
302
302
|
break;
|
|
@@ -92,7 +92,9 @@ function placeOrderWithoutTransaction(params) {
|
|
|
92
92
|
};
|
|
93
93
|
const action = yield repos.action.start(orderActionAttributes);
|
|
94
94
|
try {
|
|
95
|
-
yield repos.order.createIfNotExist(Object.assign(Object.assign({}, order), {
|
|
95
|
+
yield repos.order.createIfNotExist(Object.assign(Object.assign({}, order), {
|
|
96
|
+
// discounts: [], // 廃止(2024-04-16~)
|
|
97
|
+
acceptedOffers: [] }));
|
|
96
98
|
}
|
|
97
99
|
catch (error) {
|
|
98
100
|
try {
|
|
@@ -30,7 +30,7 @@ declare function cancelReservation(actionAttributesList: factory.action.cancel.r
|
|
|
30
30
|
declare function processUnlockOfferRateLimit(params: {
|
|
31
31
|
reservation: {
|
|
32
32
|
reservationNumber: string;
|
|
33
|
-
reservedTicket: factory.
|
|
33
|
+
reservedTicket: factory.reservation.ITicket;
|
|
34
34
|
};
|
|
35
35
|
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
36
36
|
}): (repos: {
|
|
@@ -32,6 +32,7 @@ function confirm(params) {
|
|
|
32
32
|
// 確認番号を事前発行
|
|
33
33
|
yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
34
34
|
id: params.id,
|
|
35
|
+
status: { $in: [factory.transactionStatusType.Confirmed, factory.transactionStatusType.InProgress] },
|
|
35
36
|
object: { orderDate: params.result.order.orderDate }
|
|
36
37
|
})(repos);
|
|
37
38
|
const transaction = yield repos.transaction.findById({
|
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
2
2
|
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
3
|
+
import * as factory from '../../../factory';
|
|
3
4
|
/**
|
|
4
5
|
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
5
6
|
*/
|
|
@@ -8,6 +9,9 @@ declare function publishConfirmationNumberIfNotExist(params: {
|
|
|
8
9
|
* 取引ID
|
|
9
10
|
*/
|
|
10
11
|
id: string;
|
|
12
|
+
status: {
|
|
13
|
+
$in: factory.transactionStatusType[];
|
|
14
|
+
};
|
|
11
15
|
object: {
|
|
12
16
|
orderDate: Date;
|
|
13
17
|
};
|
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js
CHANGED
|
@@ -16,8 +16,10 @@ const factory = require("../../../factory");
|
|
|
16
16
|
*/
|
|
17
17
|
function publishConfirmationNumberIfNotExist(params) {
|
|
18
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({
|
|
20
|
+
id: params.id,
|
|
21
|
+
status: { $in: params.status.$in }
|
|
22
|
+
});
|
|
21
23
|
// すでに発行済であれば何もしない
|
|
22
24
|
if (typeof confirmationNumber === 'string') {
|
|
23
25
|
return confirmationNumber;
|
|
@@ -27,11 +29,14 @@ function publishConfirmationNumberIfNotExist(params) {
|
|
|
27
29
|
// 取引に存在しなければ保管
|
|
28
30
|
yield repos.transaction.saveConfirmationNumberIfNotExist({
|
|
29
31
|
id: params.id,
|
|
32
|
+
status: { $in: params.status.$in },
|
|
30
33
|
confirmationNumber
|
|
31
34
|
});
|
|
32
35
|
// 確認番号を取引から再取得
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({
|
|
37
|
+
id: params.id,
|
|
38
|
+
status: { $in: params.status.$in }
|
|
39
|
+
});
|
|
35
40
|
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
36
41
|
if (typeof confirmationNumber !== 'string') {
|
|
37
42
|
throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
|
|
@@ -15,10 +15,12 @@ function createOrder(params) {
|
|
|
15
15
|
const { paymentMethods, price } = createPaymentMethods({
|
|
16
16
|
authorizePaymentActions: params.authorizePaymentActions
|
|
17
17
|
});
|
|
18
|
-
const discounts = [];
|
|
18
|
+
// const discounts: factory.order.IDiscount[] = [];
|
|
19
19
|
const name = (typeof params.transaction.object.name === 'string') ? params.transaction.object.name : undefined;
|
|
20
20
|
const broker = (typeof ((_a = params.transaction.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.transaction.object.broker : undefined;
|
|
21
|
-
return Object.assign(Object.assign({ project: params.transaction.project, typeOf: factory.order.OrderType.Order, seller: seller, customer: customer, price: price, priceCurrency: factory.priceCurrency.JPY, paymentMethods: paymentMethods,
|
|
21
|
+
return Object.assign(Object.assign({ project: params.transaction.project, typeOf: factory.order.OrderType.Order, seller: seller, customer: customer, price: price, priceCurrency: factory.priceCurrency.JPY, paymentMethods: paymentMethods,
|
|
22
|
+
// discounts: discounts, // 廃止(2024-04-16~)
|
|
23
|
+
confirmationNumber: '', orderNumber: params.orderNumber, orderedItem: orderedItems,
|
|
22
24
|
// acceptedOffers: acceptedOffers,
|
|
23
25
|
url: '', orderStatus: params.orderStatus, orderDate: params.orderDate, identifier: [], isGift: params.isGift }, (typeof name === 'string') ? { name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker } : undefined);
|
|
24
26
|
}
|
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.367.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.367.0-alpha.6",
|
|
14
14
|
"@cinerino/sdk": "5.17.1",
|
|
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.29.0-alpha.
|
|
113
|
+
"version": "21.29.0-alpha.7"
|
|
114
114
|
}
|