@chevre/domain 21.35.0-alpha.2 → 21.35.0-alpha.21
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/checkReserveTransactionSizes.ts +46 -0
- package/example/src/chevre/findCustomerByOrderNumber.ts +19 -0
- package/example/src/chevre/findTransactionById.ts +2 -3
- package/example/src/chevre/findTransactionInProgressById.ts +1 -1
- package/example/src/chevre/migrateAuthorizeEventServiceOfferResult.ts +162 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +1 -2
- package/example/src/chevre/searchTransactions.ts +3 -3
- package/example/src/chevre/unsetUnnecessaryFields.ts +12 -5
- package/lib/chevre/repo/action.d.ts +4 -4
- package/lib/chevre/repo/action.js +30 -29
- package/lib/chevre/repo/assetTransaction.js +10 -8
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +0 -25
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +2 -19
- package/lib/chevre/repo/mongoose/schemas/order.js +3 -15
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -28
- package/lib/chevre/repo/order.d.ts +0 -2
- package/lib/chevre/repo/order.js +16 -19
- package/lib/chevre/repo/orderInTransaction.d.ts +12 -1
- package/lib/chevre/repo/orderInTransaction.js +38 -0
- package/lib/chevre/repo/transaction.d.ts +8 -8
- package/lib/chevre/repo/transaction.js +26 -29
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -1
- package/lib/chevre/service/offer/event/authorize.js +2 -7
- package/lib/chevre/service/offer/event/factory.d.ts +6 -2
- package/lib/chevre/service/offer/event/factory.js +34 -3
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.js +1 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +34 -16
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -2
- package/lib/chevre/service/offer/product/factory.js +1 -1
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +5 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -63
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +11 -11
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +1 -8
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +4 -6
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +2 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +21 -0
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +97 -0
- package/lib/chevre/service/order/placeOrder/factory.d.ts +10 -0
- package/lib/chevre/service/order/placeOrder/factory.js +65 -0
- package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.d.ts +10 -0
- package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.js +34 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -17
- package/lib/chevre/service/order/placeOrder.js +11 -185
- package/lib/chevre/service/order/placeOrderWithoutTransaction.d.ts +22 -0
- package/lib/chevre/service/order/placeOrderWithoutTransaction.js +60 -0
- package/lib/chevre/service/order/returnOrder.js +2 -4
- package/lib/chevre/service/order/sendOrder.js +3 -5
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +2 -1
- package/lib/chevre/service/payment/any.d.ts +8 -1
- package/lib/chevre/service/payment/any.js +33 -39
- package/lib/chevre/service/report/telemetry.js +2 -4
- package/lib/chevre/service/task/createAccountingReport.js +1 -2
- package/lib/chevre/service/task/returnPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/returnPayTransaction.js +74 -45
- package/lib/chevre/service/task.js +1 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +2 -4
- package/lib/chevre/service/transaction/moneyTransfer.js +3 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +8 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +90 -62
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +10 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +37 -20
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +9 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +91 -22
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +52 -48
- package/lib/chevre/service/transaction.d.ts +12 -1
- package/lib/chevre/service/transaction.js +36 -12
- package/lib/chevre/service/validation/validateOrder.js +1 -2
- package/lib/chevre/settings.d.ts +0 -1
- package/lib/chevre/settings.js +1 -2
- package/package.json +3 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
12
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
15
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
16
|
+
startDate: {
|
|
17
|
+
// $lte: moment()
|
|
18
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
// .add(-28, 'days'),
|
|
20
|
+
$gte: moment()
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
.add(-180, 'days')
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('transactions found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
// tslint:disable-next-line:max-func-body-length
|
|
32
|
+
await cursor.eachAsync(async (doc) => {
|
|
33
|
+
i += 1;
|
|
34
|
+
const reserveTransaction = <chevre.factory.assetTransaction.reserve.ITransaction>doc.toObject();
|
|
35
|
+
console.log(
|
|
36
|
+
'size:', JSON.stringify(reserveTransaction).length,
|
|
37
|
+
reserveTransaction.typeOf, reserveTransaction.project.id, reserveTransaction.transactionNumber,
|
|
38
|
+
reserveTransaction.startDate, i);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(i, 'transactions checked');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main()
|
|
45
|
+
.then()
|
|
46
|
+
.catch(console.error);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const orderInTransactionRepo = await chevre.repository.OrderInTransaction.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const customer = await orderInTransactionRepo.findCustomerByOrderNumber({
|
|
12
|
+
orderNumber: { $eq: 'SSK3-0708814-6653130' }
|
|
13
|
+
});
|
|
14
|
+
console.log(customer);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
main()
|
|
18
|
+
.then(console.log)
|
|
19
|
+
.catch(console.error);
|
|
@@ -11,10 +11,9 @@ async function main() {
|
|
|
11
11
|
const transaction = await transactionRepo.findById(
|
|
12
12
|
{
|
|
13
13
|
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
14
|
-
id: '
|
|
14
|
+
id: '666e59edbf16a7761d26f8f4'
|
|
15
15
|
},
|
|
16
|
-
['status']
|
|
17
|
-
['typeOf', 'object', 'seller', 'agent', 'tasksExportAction']
|
|
16
|
+
['status']
|
|
18
17
|
);
|
|
19
18
|
console.log('transaction:', transaction);
|
|
20
19
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
type IUnitPriceSpecification =
|
|
8
|
+
chevre.factory.priceSpecification.IPriceSpecification<chevre.factory.priceSpecificationType.UnitPriceSpecification>;
|
|
9
|
+
type IAuthorizeAction4chevre = chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier.Chevre>;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
16
|
+
const cursor = actionRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// _id: { $eq: '66697991037c9d7243208261' },
|
|
19
|
+
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
20
|
+
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
21
|
+
startDate: {
|
|
22
|
+
// $lte: moment()
|
|
23
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
// .add(-178, 'days'),
|
|
25
|
+
$gte: moment()
|
|
26
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
+
.add(-180, 'days')
|
|
28
|
+
},
|
|
29
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('actions found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
let updateCount = 0;
|
|
39
|
+
let saveResultCount = 0;
|
|
40
|
+
// tslint:disable-next-line:max-func-body-length
|
|
41
|
+
await cursor.eachAsync(async (doc) => {
|
|
42
|
+
i += 1;
|
|
43
|
+
const authorizeAction = <Pick<
|
|
44
|
+
chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
|
|
45
|
+
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
|
|
46
|
+
>>doc.toObject();
|
|
47
|
+
const result = authorizeAction.result;
|
|
48
|
+
if (result === undefined) {
|
|
49
|
+
throw new Error(`result undefined [${authorizeAction.id}]`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let migrated = false;
|
|
53
|
+
if (authorizeAction.instrument.typeOf === 'COAReserveTransaction'
|
|
54
|
+
|| authorizeAction.instrument.identifier === chevre.factory.service.webAPI.Identifier.COA) {
|
|
55
|
+
migrated = true;
|
|
56
|
+
} else {
|
|
57
|
+
if (result.typeOf === chevre.factory.offerType.AggregateOffer && Array.isArray(result.offers)) {
|
|
58
|
+
migrated = true;
|
|
59
|
+
}
|
|
60
|
+
if (typeof result.price !== 'number') {
|
|
61
|
+
migrated = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (migrated) {
|
|
66
|
+
console.log(
|
|
67
|
+
'already migrated.',
|
|
68
|
+
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
69
|
+
|
|
70
|
+
// optimize action
|
|
71
|
+
if (Array.isArray(authorizeAction.object.acceptedOffer)) {
|
|
72
|
+
let unsetResult: any;
|
|
73
|
+
// unsetResult = await actionRepo.unsetUnnecessaryFields({
|
|
74
|
+
// filter: { _id: { $eq: authorizeAction.id } },
|
|
75
|
+
// $unset: {
|
|
76
|
+
// 'object.acceptedOffer': 1
|
|
77
|
+
// }
|
|
78
|
+
// });
|
|
79
|
+
// updateCount += 1;
|
|
80
|
+
// console.log(
|
|
81
|
+
// 'result unset. unsetResult:', unsetResult,
|
|
82
|
+
// authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
console.log(
|
|
86
|
+
'redefining result as AggreagteOffer...',
|
|
87
|
+
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
88
|
+
const acceptedOffers = (<IAuthorizeAction4chevre>authorizeAction).object.acceptedOffer;
|
|
89
|
+
if (!Array.isArray(acceptedOffers)) {
|
|
90
|
+
throw new Error(`acceptedOffer undefined [${authorizeAction.id}]`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let offers: chevre.factory.action.authorize.offer.eventService.IAcceptedOfferInResult[] | undefined;
|
|
94
|
+
if (typeof result.price === 'number') {
|
|
95
|
+
// オファーIDごとに集計
|
|
96
|
+
const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
|
|
97
|
+
offers = offerIds.map<chevre.factory.action.authorize.offer.eventService.IAcceptedOfferInResult>((offerId) => {
|
|
98
|
+
const acceptedOfferInObject = acceptedOffers.find(({ id }) => id === offerId);
|
|
99
|
+
if (acceptedOfferInObject === undefined) {
|
|
100
|
+
throw new Error(`acceptedOffer not found [id:${offerId}]`);
|
|
101
|
+
}
|
|
102
|
+
const amountOfThisGood: number = acceptedOffers.filter(({ id }) => id === offerId).length;
|
|
103
|
+
const { acceptedPaymentMethod, priceSpecification } = acceptedOfferInObject;
|
|
104
|
+
|
|
105
|
+
const unitPriceSpec = <IUnitPriceSpecification | undefined>priceSpecification.priceComponent.find(
|
|
106
|
+
(spec) => spec.typeOf === chevre.factory.priceSpecificationType.UnitPriceSpecification
|
|
107
|
+
&& (!Array.isArray(spec.appliesToAddOn)) // アドオン単価ではない
|
|
108
|
+
);
|
|
109
|
+
if (unitPriceSpec === undefined) {
|
|
110
|
+
throw new Error(`unitPriceSpec not found [id:${offerId}]`);
|
|
111
|
+
}
|
|
112
|
+
const { eligibleQuantity, eligibleTransactionVolume } = unitPriceSpec;
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id: offerId,
|
|
116
|
+
includesObject: { amountOfThisGood },
|
|
117
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
118
|
+
priceSpecification: {
|
|
119
|
+
...(eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined,
|
|
120
|
+
...(eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined
|
|
121
|
+
},
|
|
122
|
+
...(acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const resultAsAggregateOffer: chevre.factory.action.authorize.offer.eventService.IResultAsAggregateOffer = {
|
|
127
|
+
typeOf: chevre.factory.offerType.AggregateOffer,
|
|
128
|
+
offers
|
|
129
|
+
};
|
|
130
|
+
// const newResult: chevre.factory.action.authorize.offer.eventService.IResult = {
|
|
131
|
+
// ...result,
|
|
132
|
+
// ...resultAsAggregateOffer
|
|
133
|
+
// };
|
|
134
|
+
console.log(
|
|
135
|
+
'saving action...',
|
|
136
|
+
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
137
|
+
// tslint:disable-next-line:no-null-keyword
|
|
138
|
+
console.dir(resultAsAggregateOffer, { depth: null });
|
|
139
|
+
await actionRepo.findByIdAndUpdate({
|
|
140
|
+
id: authorizeAction.id,
|
|
141
|
+
update: {
|
|
142
|
+
$set: {
|
|
143
|
+
'result.typeOf': resultAsAggregateOffer.typeOf,
|
|
144
|
+
'result.offers': resultAsAggregateOffer.offers
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
saveResultCount += 1;
|
|
149
|
+
console.log(
|
|
150
|
+
'action saved.',
|
|
151
|
+
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
console.log(i, 'actions checked');
|
|
156
|
+
console.log(updateCount, 'actions updated');
|
|
157
|
+
console.log(saveResultCount, 'result saved');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main()
|
|
161
|
+
.then()
|
|
162
|
+
.catch(console.error);
|
|
@@ -73,8 +73,7 @@ async function main() {
|
|
|
73
73
|
page: 1,
|
|
74
74
|
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
75
75
|
ids: [placeOrderTransactionId],
|
|
76
|
-
inclusion: ['endDate', 'status']
|
|
77
|
-
exclusion: []
|
|
76
|
+
inclusion: ['endDate', 'status']
|
|
78
77
|
})).shift();
|
|
79
78
|
if (placeOrderTransaction !== undefined) {
|
|
80
79
|
const { endDate, status } = placeOrderTransaction;
|
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
|
|
15
15
|
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
16
16
|
|
|
17
|
-
const transactions = await transactionRepo.search<chevre.factory.transactionType.PlaceOrder>({
|
|
17
|
+
const transactions = await transactionRepo.search<chevre.factory.transactionType.PlaceOrder, 'status' | 'startDate'>({
|
|
18
18
|
limit: 1,
|
|
19
19
|
page: 1,
|
|
20
20
|
project: { id: { $eq: project.id } },
|
|
@@ -27,10 +27,10 @@ async function main() {
|
|
|
27
27
|
// }
|
|
28
28
|
// },
|
|
29
29
|
// tasksExportAction: { actionStatus: { $eq: chevre.factory.actionStatusType.PotentialActionStatus } },
|
|
30
|
-
inclusion: ['
|
|
31
|
-
exclusion: []
|
|
30
|
+
inclusion: ['status', 'startDate']
|
|
32
31
|
});
|
|
33
32
|
console.log('transactions found', transactions);
|
|
33
|
+
console.log('transactions found', transactions.map((transaction) => `${transaction.id} ${transaction.status}`));
|
|
34
34
|
console.log(transactions.length, 'transactions found');
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -11,14 +11,16 @@ async function main() {
|
|
|
11
11
|
const now = new Date();
|
|
12
12
|
let updateResult: any;
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
15
15
|
|
|
16
16
|
// tslint:disable-next-line:no-magic-numbers
|
|
17
17
|
const hours = DAYS * 24;
|
|
18
18
|
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
19
19
|
for (let index = 0; index < hours; index++) {
|
|
20
|
-
updateResult = await
|
|
20
|
+
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
21
21
|
filter: {
|
|
22
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
23
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
22
24
|
startDate: {
|
|
23
25
|
$gte: moment(now)
|
|
24
26
|
.add(-(index + 1), 'hours')
|
|
@@ -29,9 +31,14 @@ async function main() {
|
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
$unset: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
'result.order.broker': 1,
|
|
35
|
+
'result.order.name': 1,
|
|
36
|
+
'result.order.seller': 1,
|
|
37
|
+
'result.order.isGift': 1,
|
|
38
|
+
'result.order.project': 1,
|
|
39
|
+
'result.order.customer': 1,
|
|
40
|
+
'result.order.paymentMethods': 1,
|
|
41
|
+
'result.order.orderedItem': 1
|
|
35
42
|
}
|
|
36
43
|
});
|
|
37
44
|
console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
26
|
-
import { Connection, FilterQuery, QueryOptions } from 'mongoose';
|
|
26
|
+
import { Connection, FilterQuery, QueryOptions, UpdateQuery } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
28
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
29
29
|
export type IPayAction = factory.action.trade.pay.IAction;
|
|
@@ -226,10 +226,10 @@ export declare class MongoRepository {
|
|
|
226
226
|
id: string;
|
|
227
227
|
update: any;
|
|
228
228
|
}): Promise<void>;
|
|
229
|
-
findByIdAndUpdate
|
|
229
|
+
findByIdAndUpdate(params: {
|
|
230
230
|
id: string;
|
|
231
|
-
update:
|
|
232
|
-
}): Promise<
|
|
231
|
+
update: UpdateQuery<IAction<factory.actionType>>;
|
|
232
|
+
}): Promise<void>;
|
|
233
233
|
/**
|
|
234
234
|
* イベントと入場ゲート指定で予約使用アクションを集計する
|
|
235
235
|
*/
|
|
@@ -35,7 +35,7 @@ class MongoRepository {
|
|
|
35
35
|
}
|
|
36
36
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
37
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68;
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
41
41
|
if (Array.isArray(idIn)) {
|
|
@@ -250,16 +250,18 @@ class MongoRepository {
|
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
253
|
+
// discontinue(2024-06-18~)
|
|
254
|
+
// const objectAcceptedOfferSeatNumberIn =
|
|
255
|
+
// params.object?.acceptedOffer?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.seatNumber?.$in;
|
|
256
|
+
// if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
|
|
257
|
+
// andConditions.push({
|
|
258
|
+
// 'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
|
|
259
|
+
// $exists: true,
|
|
260
|
+
// $in: objectAcceptedOfferSeatNumberIn
|
|
261
|
+
// }
|
|
262
|
+
// });
|
|
263
|
+
// }
|
|
264
|
+
const objectTransactionNumberEq = (_38 = (_37 = params.object) === null || _37 === void 0 ? void 0 : _37.transactionNumber) === null || _38 === void 0 ? void 0 : _38.$eq;
|
|
263
265
|
if (typeof objectTransactionNumberEq === 'string') {
|
|
264
266
|
andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
|
|
265
267
|
}
|
|
@@ -269,14 +271,14 @@ class MongoRepository {
|
|
|
269
271
|
});
|
|
270
272
|
}
|
|
271
273
|
else {
|
|
272
|
-
const typeOfEq = (
|
|
274
|
+
const typeOfEq = (_39 = params.typeOf) === null || _39 === void 0 ? void 0 : _39.$eq;
|
|
273
275
|
if (typeof typeOfEq === 'string') {
|
|
274
276
|
andConditions.push({
|
|
275
277
|
typeOf: { $eq: typeOfEq }
|
|
276
278
|
});
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
|
-
const actionStatusIn = (
|
|
281
|
+
const actionStatusIn = (_40 = params.actionStatus) === null || _40 === void 0 ? void 0 : _40.$in;
|
|
280
282
|
if (Array.isArray(actionStatusIn)) {
|
|
281
283
|
andConditions.push({
|
|
282
284
|
actionStatus: { $in: actionStatusIn }
|
|
@@ -299,7 +301,7 @@ class MongoRepository {
|
|
|
299
301
|
startDate: { $lte: startDateLte }
|
|
300
302
|
});
|
|
301
303
|
}
|
|
302
|
-
const fromLocationTypeOfIn = (
|
|
304
|
+
const fromLocationTypeOfIn = (_42 = (_41 = params.fromLocation) === null || _41 === void 0 ? void 0 : _41.typeOf) === null || _42 === void 0 ? void 0 : _42.$in;
|
|
303
305
|
if (Array.isArray(fromLocationTypeOfIn)) {
|
|
304
306
|
andConditions.push({
|
|
305
307
|
'fromLocation.typeOf': {
|
|
@@ -308,7 +310,7 @@ class MongoRepository {
|
|
|
308
310
|
}
|
|
309
311
|
});
|
|
310
312
|
}
|
|
311
|
-
const fromLocationAccountNumberIn = (
|
|
313
|
+
const fromLocationAccountNumberIn = (_44 = (_43 = params.fromLocation) === null || _43 === void 0 ? void 0 : _43.accountNumber) === null || _44 === void 0 ? void 0 : _44.$in;
|
|
312
314
|
if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
313
315
|
andConditions.push({
|
|
314
316
|
'fromLocation.accountNumber': {
|
|
@@ -317,7 +319,7 @@ class MongoRepository {
|
|
|
317
319
|
}
|
|
318
320
|
});
|
|
319
321
|
}
|
|
320
|
-
const fromLocationAccountTypeIn = (
|
|
322
|
+
const fromLocationAccountTypeIn = (_46 = (_45 = params.fromLocation) === null || _45 === void 0 ? void 0 : _45.accountType) === null || _46 === void 0 ? void 0 : _46.$in;
|
|
321
323
|
if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
322
324
|
andConditions.push({
|
|
323
325
|
'fromLocation.accountType': {
|
|
@@ -326,7 +328,7 @@ class MongoRepository {
|
|
|
326
328
|
}
|
|
327
329
|
});
|
|
328
330
|
}
|
|
329
|
-
const toLocationTypeOfIn = (
|
|
331
|
+
const toLocationTypeOfIn = (_48 = (_47 = params.toLocation) === null || _47 === void 0 ? void 0 : _47.typeOf) === null || _48 === void 0 ? void 0 : _48.$in;
|
|
330
332
|
if (Array.isArray(toLocationTypeOfIn)) {
|
|
331
333
|
andConditions.push({
|
|
332
334
|
'toLocation.typeOf': {
|
|
@@ -335,7 +337,7 @@ class MongoRepository {
|
|
|
335
337
|
}
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
|
-
const toLocationAccountNumberIn = (
|
|
340
|
+
const toLocationAccountNumberIn = (_50 = (_49 = params.toLocation) === null || _49 === void 0 ? void 0 : _49.accountNumber) === null || _50 === void 0 ? void 0 : _50.$in;
|
|
339
341
|
if (Array.isArray(toLocationAccountNumberIn)) {
|
|
340
342
|
andConditions.push({
|
|
341
343
|
'toLocation.accountNumber': {
|
|
@@ -344,7 +346,7 @@ class MongoRepository {
|
|
|
344
346
|
}
|
|
345
347
|
});
|
|
346
348
|
}
|
|
347
|
-
const toLocationAccountTypeIn = (
|
|
349
|
+
const toLocationAccountTypeIn = (_52 = (_51 = params.toLocation) === null || _51 === void 0 ? void 0 : _51.accountType) === null || _52 === void 0 ? void 0 : _52.$in;
|
|
348
350
|
if (Array.isArray(toLocationAccountTypeIn)) {
|
|
349
351
|
andConditions.push({
|
|
350
352
|
'toLocation.accountType': {
|
|
@@ -353,7 +355,7 @@ class MongoRepository {
|
|
|
353
355
|
}
|
|
354
356
|
});
|
|
355
357
|
}
|
|
356
|
-
const purposeTypeOfIn = (
|
|
358
|
+
const purposeTypeOfIn = (_54 = (_53 = params.purpose) === null || _53 === void 0 ? void 0 : _53.typeOf) === null || _54 === void 0 ? void 0 : _54.$in;
|
|
357
359
|
if (Array.isArray(purposeTypeOfIn)) {
|
|
358
360
|
andConditions.push({
|
|
359
361
|
'purpose.typeOf': {
|
|
@@ -362,7 +364,7 @@ class MongoRepository {
|
|
|
362
364
|
}
|
|
363
365
|
});
|
|
364
366
|
}
|
|
365
|
-
const purposeIdIn = (
|
|
367
|
+
const purposeIdIn = (_56 = (_55 = params.purpose) === null || _55 === void 0 ? void 0 : _55.id) === null || _56 === void 0 ? void 0 : _56.$in;
|
|
366
368
|
if (Array.isArray(purposeIdIn)) {
|
|
367
369
|
andConditions.push({
|
|
368
370
|
'purpose.id': {
|
|
@@ -371,7 +373,7 @@ class MongoRepository {
|
|
|
371
373
|
}
|
|
372
374
|
});
|
|
373
375
|
}
|
|
374
|
-
const purposeOrderNumberIn = (
|
|
376
|
+
const purposeOrderNumberIn = (_58 = (_57 = params.purpose) === null || _57 === void 0 ? void 0 : _57.orderNumber) === null || _58 === void 0 ? void 0 : _58.$in;
|
|
375
377
|
if (Array.isArray(purposeOrderNumberIn)) {
|
|
376
378
|
andConditions.push({
|
|
377
379
|
'purpose.orderNumber': {
|
|
@@ -380,7 +382,7 @@ class MongoRepository {
|
|
|
380
382
|
}
|
|
381
383
|
});
|
|
382
384
|
}
|
|
383
|
-
const resultTypeOfIn = (
|
|
385
|
+
const resultTypeOfIn = (_60 = (_59 = params.result) === null || _59 === void 0 ? void 0 : _59.typeOf) === null || _60 === void 0 ? void 0 : _60.$in;
|
|
384
386
|
if (Array.isArray(resultTypeOfIn)) {
|
|
385
387
|
andConditions.push({
|
|
386
388
|
'result.typeOf': {
|
|
@@ -389,7 +391,7 @@ class MongoRepository {
|
|
|
389
391
|
}
|
|
390
392
|
});
|
|
391
393
|
}
|
|
392
|
-
const resultIdIn = (
|
|
394
|
+
const resultIdIn = (_62 = (_61 = params.result) === null || _61 === void 0 ? void 0 : _61.id) === null || _62 === void 0 ? void 0 : _62.$in;
|
|
393
395
|
if (Array.isArray(resultIdIn)) {
|
|
394
396
|
andConditions.push({
|
|
395
397
|
'result.id': {
|
|
@@ -398,7 +400,7 @@ class MongoRepository {
|
|
|
398
400
|
}
|
|
399
401
|
});
|
|
400
402
|
}
|
|
401
|
-
const resultOrderNumberIn = (
|
|
403
|
+
const resultOrderNumberIn = (_64 = (_63 = params.result) === null || _63 === void 0 ? void 0 : _63.orderNumber) === null || _64 === void 0 ? void 0 : _64.$in;
|
|
402
404
|
if (Array.isArray(resultOrderNumberIn)) {
|
|
403
405
|
andConditions.push({
|
|
404
406
|
'result.orderNumber': {
|
|
@@ -407,7 +409,7 @@ class MongoRepository {
|
|
|
407
409
|
}
|
|
408
410
|
});
|
|
409
411
|
}
|
|
410
|
-
const resultCodeIn = (
|
|
412
|
+
const resultCodeIn = (_66 = (_65 = params.result) === null || _65 === void 0 ? void 0 : _65.code) === null || _66 === void 0 ? void 0 : _66.$in;
|
|
411
413
|
if (Array.isArray(resultCodeIn)) {
|
|
412
414
|
andConditions.push({
|
|
413
415
|
'result.code': {
|
|
@@ -417,7 +419,7 @@ class MongoRepository {
|
|
|
417
419
|
});
|
|
418
420
|
}
|
|
419
421
|
// sameAs(2024-04-23~)
|
|
420
|
-
const sameAsIdEq = (
|
|
422
|
+
const sameAsIdEq = (_68 = (_67 = params.sameAs) === null || _67 === void 0 ? void 0 : _67.id) === null || _68 === void 0 ? void 0 : _68.$eq;
|
|
421
423
|
if (typeof sameAsIdEq === 'string') {
|
|
422
424
|
andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
|
|
423
425
|
}
|
|
@@ -795,13 +797,12 @@ class MongoRepository {
|
|
|
795
797
|
}
|
|
796
798
|
findByIdAndUpdate(params) {
|
|
797
799
|
return __awaiter(this, void 0, void 0, function* () {
|
|
798
|
-
|
|
800
|
+
yield this.actionModel.findOneAndUpdate({ _id: { $eq: params.id } }, params.update, { projection: { _id: 1 } })
|
|
799
801
|
.exec()
|
|
800
802
|
.then((doc) => {
|
|
801
803
|
if (doc === null) {
|
|
802
804
|
throw new factory.errors.ArgumentNull(this.actionModel.modelName);
|
|
803
805
|
}
|
|
804
|
-
return doc.toObject();
|
|
805
806
|
});
|
|
806
807
|
});
|
|
807
808
|
}
|
|
@@ -303,7 +303,7 @@ class MongoRepository {
|
|
|
303
303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
304
|
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
305
305
|
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
306
|
-
}
|
|
306
|
+
} }))
|
|
307
307
|
.then((doc) => doc.toObject());
|
|
308
308
|
});
|
|
309
309
|
}
|
|
@@ -402,7 +402,9 @@ class MongoRepository {
|
|
|
402
402
|
const startDate = new Date();
|
|
403
403
|
const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
|
|
404
404
|
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
405
|
-
},
|
|
405
|
+
},
|
|
406
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, // discontinue(2024-06-20~)
|
|
407
|
+
endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
|
|
406
408
|
.then((doc) => doc.toObject());
|
|
407
409
|
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
408
410
|
id: params.id,
|
|
@@ -434,8 +436,8 @@ class MongoRepository {
|
|
|
434
436
|
} }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
435
437
|
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
436
438
|
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
437
|
-
'tasksExportAction.startDate': new Date()
|
|
438
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
439
|
+
'tasksExportAction.startDate': new Date()
|
|
440
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting // discontinue(2024-06-20~)
|
|
439
441
|
}, { new: true })
|
|
440
442
|
.select({
|
|
441
443
|
_id: 1,
|
|
@@ -473,8 +475,8 @@ class MongoRepository {
|
|
|
473
475
|
}, {
|
|
474
476
|
tasksExportAction: {
|
|
475
477
|
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
476
|
-
}
|
|
477
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
478
|
+
}
|
|
479
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
|
|
478
480
|
})
|
|
479
481
|
.exec();
|
|
480
482
|
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
@@ -541,8 +543,8 @@ class MongoRepository {
|
|
|
541
543
|
$eq: factory.actionStatusType.ActiveActionStatus
|
|
542
544
|
}
|
|
543
545
|
}, {
|
|
544
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
545
|
-
tasksExportedAt: endDate,
|
|
546
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exported, // discontinue(2024-06-20~)
|
|
547
|
+
// tasksExportedAt: endDate, // discontinue(2024-06-20~)
|
|
546
548
|
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
547
549
|
'tasksExportAction.endDate': endDate
|
|
548
550
|
})
|
|
@@ -126,19 +126,6 @@ const indexes = [
|
|
|
126
126
|
{ expires: 1, startDate: -1 },
|
|
127
127
|
{ name: 'searchByExpiresAndStartDate' }
|
|
128
128
|
],
|
|
129
|
-
[
|
|
130
|
-
{ tasksExportationStatus: 1, startDate: -1 },
|
|
131
|
-
{ name: 'searchByTasksExportationStatusAndStartDate' }
|
|
132
|
-
],
|
|
133
|
-
[
|
|
134
|
-
{ tasksExportedAt: 1, startDate: -1 },
|
|
135
|
-
{
|
|
136
|
-
name: 'searchByTasksExportedAtAndStartDate',
|
|
137
|
-
partialFilterExpression: {
|
|
138
|
-
tasksExportedAt: { $exists: true }
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
],
|
|
142
129
|
[
|
|
143
130
|
{ 'object.fromLocation.accountNumber': 1, startDate: -1 },
|
|
144
131
|
{
|
|
@@ -157,18 +144,6 @@ const indexes = [
|
|
|
157
144
|
}
|
|
158
145
|
}
|
|
159
146
|
],
|
|
160
|
-
[
|
|
161
|
-
{ typeOf: 1, status: 1, tasksExportationStatus: 1 },
|
|
162
|
-
{
|
|
163
|
-
name: 'startExportTasks'
|
|
164
|
-
}
|
|
165
|
-
],
|
|
166
|
-
[
|
|
167
|
-
{ tasksExportationStatus: 1, updatedAt: 1 },
|
|
168
|
-
{
|
|
169
|
-
name: 'reexportTasks'
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
147
|
[
|
|
173
148
|
{ status: 1, expires: 1 },
|
|
174
149
|
{
|