@chevre/domain 21.20.0-alpha.2 → 21.20.0-alpha.22
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/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processAcceptOffer.ts +48 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
- package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
- package/lib/chevre/repo/acceptedOffer.js +32 -2
- package/lib/chevre/repo/action.d.ts +13 -7
- package/lib/chevre/repo/action.js +33 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
- package/lib/chevre/repo/order.js +28 -9
- package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
- package/lib/chevre/repo/orderInTransaction.js +77 -0
- package/lib/chevre/repo/task.d.ts +0 -2
- package/lib/chevre/repo/task.js +56 -46
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/any.d.ts +29 -0
- package/lib/chevre/service/offer/any.js +55 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +11 -0
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +12 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +48 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +133 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +58 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +156 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +51 -36
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.js +28 -29
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +68 -30
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard.js +102 -133
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +18 -13
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
(await chevre.service.order.createService())
|
|
12
|
+
.onAssetTransactionStatusChanged({
|
|
13
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
14
|
+
object: {
|
|
15
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
16
|
+
transactionNumber: '863918387495116',
|
|
17
|
+
status: chevre.factory.transactionStatusType.Confirmed
|
|
18
|
+
},
|
|
19
|
+
purpose: {
|
|
20
|
+
confirmationNumber: '',
|
|
21
|
+
orderNumber: 'CIN1-3748070-2008463',
|
|
22
|
+
typeOf: chevre.factory.order.OrderType.Order
|
|
23
|
+
},
|
|
24
|
+
useOnOrderStatusChanged: true
|
|
25
|
+
})({
|
|
26
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
27
|
+
acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
|
|
28
|
+
order: await chevre.repository.Order.createInstance(mongoose.connection),
|
|
29
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
30
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then(console.log)
|
|
36
|
+
.catch(console.error);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
import * as mongoose from 'mongoose';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
const result = await taskRepo.taskModel.updateMany(
|
|
14
|
+
{
|
|
15
|
+
status: { $eq: chevre.factory.taskStatus.Aborted },
|
|
16
|
+
lastTriedAt: {
|
|
17
|
+
$gt: moment()
|
|
18
|
+
.add(-1, 'day')
|
|
19
|
+
.toDate()
|
|
20
|
+
},
|
|
21
|
+
name: { $eq: chevre.factory.taskName.TriggerWebhook },
|
|
22
|
+
'project.id': { $eq: project.id }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$set: {
|
|
26
|
+
status: chevre.factory.taskStatus.Ready,
|
|
27
|
+
remainingNumberOfTries: 20
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
.exec();
|
|
32
|
+
console.log('result:', result);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then(() => {
|
|
37
|
+
console.log('success!');
|
|
38
|
+
})
|
|
39
|
+
.catch(console.error);
|
|
@@ -5,21 +5,19 @@ import { chevre } from '../../../lib/index';
|
|
|
5
5
|
|
|
6
6
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
async function main() {
|
|
9
13
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
14
|
|
|
11
|
-
const
|
|
15
|
+
const indexes = await mongoose.connection.db.collection('orders')
|
|
16
|
+
.indexes();
|
|
17
|
+
// console.log(indexes);
|
|
18
|
+
console.log(indexes.length, 'indexes found');
|
|
12
19
|
|
|
13
|
-
const
|
|
14
|
-
orderNumber: 'CIN4-3943271-4221863',
|
|
15
|
-
project: { id: project.id },
|
|
16
|
-
inclusion: [
|
|
17
|
-
// 'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
|
|
18
|
-
// 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
|
|
19
|
-
],
|
|
20
|
-
exclusion: ['acceptedOffers']
|
|
21
|
-
});
|
|
22
|
-
console.log(order);
|
|
20
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
23
21
|
|
|
24
22
|
const orders = await orderRepo.search(
|
|
25
23
|
{
|
|
@@ -30,10 +28,10 @@ async function main() {
|
|
|
30
28
|
// itemOffered: {
|
|
31
29
|
// issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.MembershipService } }
|
|
32
30
|
// }
|
|
33
|
-
},
|
|
34
|
-
orderedItem: {
|
|
35
|
-
$size: 3
|
|
36
31
|
}
|
|
32
|
+
// orderedItem: {
|
|
33
|
+
// $size: 3
|
|
34
|
+
// }
|
|
37
35
|
// paymentMethods: {
|
|
38
36
|
// paymentMethod: { identifier: { $in: ['Cash'] } }
|
|
39
37
|
// additionalProperty: {
|
|
@@ -49,7 +47,7 @@ async function main() {
|
|
|
49
47
|
customer: 1
|
|
50
48
|
}
|
|
51
49
|
);
|
|
52
|
-
console.log('orders found', orders);
|
|
50
|
+
// console.log('orders found', orders);
|
|
53
51
|
console.log(orders.length, 'orders found');
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -0,0 +1,28 @@
|
|
|
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);
|
|
8
|
+
|
|
9
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const result = await acceptedOfferRepo.searchSlicedAcceptedOffersByOrderNumber(
|
|
12
|
+
{
|
|
13
|
+
orderNumber: { $eq: 'CIN1-3748070-2008463' },
|
|
14
|
+
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
15
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
16
|
+
$slice: [0, 2]
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
console.log(result);
|
|
20
|
+
console.log(result.acceptedOffers.map((offer) => {
|
|
21
|
+
return `${(<any>offer.itemOffered).id}`;
|
|
22
|
+
}));
|
|
23
|
+
console.log(result.acceptedOffers.length);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then(console.log)
|
|
28
|
+
.catch(console.error);
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
(await chevre.service.order.createService())
|
|
12
|
+
.sendOrder({
|
|
13
|
+
agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
14
|
+
project: { id: project.id },
|
|
15
|
+
object: {
|
|
16
|
+
confirmationNumber: '57761',
|
|
17
|
+
orderNumber: 'CIN1-3748070-2008463',
|
|
18
|
+
previousOrderStatus: chevre.factory.orderStatus.OrderInTransit,
|
|
19
|
+
acceptedOffers: {
|
|
20
|
+
limit: 1,
|
|
21
|
+
page: 1
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
useOnOrderStatusChanged: false
|
|
25
|
+
})({
|
|
26
|
+
acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
|
|
27
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
28
|
+
order: await chevre.repository.Order.createInstance(mongoose.connection),
|
|
29
|
+
ownershipInfo: await chevre.repository.OwnershipInfo.createInstance(mongoose.connection),
|
|
30
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
31
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then(console.log)
|
|
37
|
+
.catch(console.error);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
13
|
+
socket: {
|
|
14
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
15
|
+
host: <string>process.env.REDIS_HOST
|
|
16
|
+
},
|
|
17
|
+
password: <string>process.env.REDIS_KEY
|
|
18
|
+
});
|
|
19
|
+
await client.connect();
|
|
20
|
+
|
|
21
|
+
const orderInTransactionRepo = await chevre.repository.OrderInTransaction.createInstance(mongoose.connection);
|
|
22
|
+
|
|
23
|
+
const orderNumber: string = 'sampleOrderNumber';
|
|
24
|
+
const reservationNumber: string = 'sampleReservationNumber';
|
|
25
|
+
const acceptedOffers: chevre.factory.order.IAcceptedOffer<chevre.factory.order.IReservation>[] = [
|
|
26
|
+
{
|
|
27
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
28
|
+
id: 'xxx',
|
|
29
|
+
itemOffered: <any>{ reservationNumber },
|
|
30
|
+
priceSpecification: <any>{}
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
let result: any = await orderInTransactionRepo.acceptOffer({
|
|
34
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
35
|
+
orderNumber,
|
|
36
|
+
acceptedOffers
|
|
37
|
+
});
|
|
38
|
+
console.log(result);
|
|
39
|
+
result = await orderInTransactionRepo.voidAcceptedOfferByReservationNumber({
|
|
40
|
+
orderNumber,
|
|
41
|
+
acceptedOffers: { reservationNumber: { $in: [reservationNumber] } }
|
|
42
|
+
});
|
|
43
|
+
console.log(result);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main()
|
|
47
|
+
.then(console.log)
|
|
48
|
+
.catch(console.error);
|
|
@@ -11,6 +11,13 @@ const paymentMethodType = 'CreditCard';
|
|
|
11
11
|
const paymentServiceId = '5f9a4fed4f3709000abe6415';
|
|
12
12
|
// const paymentMethodType = 'PayPay';
|
|
13
13
|
// const paymentServiceId = '60e9560176a391000b23e20b';
|
|
14
|
+
const AMOUNT: number = 1;
|
|
15
|
+
const creditCard: chevre.factory.paymentMethod.paymentCard.creditCard.IUncheckedCardRaw = {
|
|
16
|
+
cardNo: '4100000000000100',
|
|
17
|
+
expire: '2812',
|
|
18
|
+
cardPass: '123',
|
|
19
|
+
holderName: 'AA AA'
|
|
20
|
+
};
|
|
14
21
|
|
|
15
22
|
// tslint:disable-next-line:max-func-body-length
|
|
16
23
|
async function main() {
|
|
@@ -43,16 +50,13 @@ async function main() {
|
|
|
43
50
|
agent: { id: CLIENT_ID },
|
|
44
51
|
object: {
|
|
45
52
|
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
46
|
-
amount:
|
|
53
|
+
amount: AMOUNT,
|
|
47
54
|
paymentMethod: paymentMethodType,
|
|
48
55
|
issuedThrough: { id: paymentServiceId },
|
|
49
56
|
method: '1',
|
|
50
57
|
creditCard: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
expire: '2812',
|
|
54
|
-
cardPass: '123',
|
|
55
|
-
holderName: 'AA AA'
|
|
58
|
+
...creditCard,
|
|
59
|
+
retUrl: String(process.env.SECURE_TRAN_RET_URL)
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
@@ -61,75 +65,100 @@ async function main() {
|
|
|
61
65
|
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
62
66
|
id: CLIENT_ID
|
|
63
67
|
}
|
|
64
|
-
// options: {
|
|
65
|
-
// use3DS: true
|
|
66
|
-
// }
|
|
67
68
|
})({
|
|
68
69
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
69
70
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
70
71
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
71
72
|
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
72
73
|
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
73
|
-
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
74
74
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
75
75
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
76
76
|
});
|
|
77
77
|
console.log(publishPaymentUrlResult);
|
|
78
78
|
|
|
79
79
|
// wait callback...
|
|
80
|
+
// tslint:disable-next-line:max-func-body-length
|
|
80
81
|
await new Promise<void>((resolve, reject) => {
|
|
81
82
|
const rl = readline.createInterface({
|
|
82
83
|
input: process.stdin,
|
|
83
84
|
output: process.stdout
|
|
84
85
|
});
|
|
85
86
|
|
|
87
|
+
// tslint:disable-next-line:max-func-body-length
|
|
86
88
|
rl.question('callback received?:\n', async () => {
|
|
87
89
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
await new Promise<void>(async (resolve2, reject2) => {
|
|
91
|
+
const rl2 = readline.createInterface({
|
|
92
|
+
input: process.stdin,
|
|
93
|
+
output: process.stdout
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
rl2.question('VOID or AUTH?:\n', async (jobCd) => {
|
|
97
|
+
if (jobCd === 'AUTH') {
|
|
98
|
+
const authorizeResult = await (await chevre.service.payment.any.createService()).authorize({
|
|
99
|
+
project: { id: project.id },
|
|
100
|
+
agent: { id: CLIENT_ID },
|
|
101
|
+
object: {
|
|
102
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
103
|
+
amount: AMOUNT,
|
|
104
|
+
paymentMethodId: publishPaymentUrlResult.paymentMethodId,
|
|
105
|
+
paymentMethod: paymentMethodType,
|
|
106
|
+
issuedThrough: { id: paymentServiceId },
|
|
107
|
+
method: '1',
|
|
108
|
+
creditCard
|
|
109
|
+
},
|
|
110
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
111
|
+
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
112
|
+
location: {
|
|
113
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
114
|
+
id: CLIENT_ID
|
|
115
|
+
},
|
|
116
|
+
options: {
|
|
117
|
+
useCancelPayTransactionOnFailed: false,
|
|
118
|
+
useCheckMovieTicketBeforePay: false,
|
|
119
|
+
useCheckByIdentifierIfNotYet: false,
|
|
120
|
+
useSearchTrade4accountId: false
|
|
121
|
+
}
|
|
122
|
+
})({
|
|
123
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
124
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
125
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
126
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
127
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
128
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
129
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
130
|
+
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
131
|
+
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
132
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
133
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
134
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
135
|
+
});
|
|
136
|
+
console.log('payment authorized.', authorizeResult.id);
|
|
137
|
+
} else if (jobCd === 'VOID') {
|
|
138
|
+
await (await chevre.service.payment.any.createService()).invalidatePaymentUrl({
|
|
139
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
140
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf }
|
|
141
|
+
})({
|
|
142
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
143
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
144
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
145
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
146
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
147
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
148
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
149
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
150
|
+
});
|
|
151
|
+
console.log('payment voided.');
|
|
152
|
+
} else {
|
|
153
|
+
reject2(`jobCd ${jobCd} not implemented`);
|
|
154
|
+
|
|
155
|
+
return;
|
|
103
156
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
109
|
-
id: CLIENT_ID
|
|
110
|
-
},
|
|
111
|
-
options: {
|
|
112
|
-
useCancelPayTransactionOnFailed: false,
|
|
113
|
-
useCheckMovieTicketBeforePay: false,
|
|
114
|
-
useCheckByIdentifierIfNotYet: false,
|
|
115
|
-
useSearchTrade4accountId: false
|
|
116
|
-
}
|
|
117
|
-
})({
|
|
118
|
-
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
119
|
-
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
120
|
-
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
121
|
-
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
122
|
-
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
123
|
-
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
124
|
-
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
125
|
-
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
126
|
-
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
127
|
-
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
128
|
-
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
129
|
-
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
130
|
-
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
157
|
+
|
|
158
|
+
// rl.close();
|
|
159
|
+
resolve2();
|
|
160
|
+
});
|
|
131
161
|
});
|
|
132
|
-
console.log(authorizeResult);
|
|
133
162
|
|
|
134
163
|
resolve();
|
|
135
164
|
} catch (error) {
|
|
@@ -6,6 +6,11 @@ type IProjection4searchWithUnwoundAcceptedOffers = {
|
|
|
6
6
|
_id?: 0 | 1;
|
|
7
7
|
};
|
|
8
8
|
type IDistinctField = 'acceptedOffers.id' | 'acceptedOffers.itemOffered.reservationNumber' | 'acceptedOffers.itemOffered.reservationFor.id' | 'acceptedOffers.itemOffered.issuedThrough.id' | 'acceptedOffers.offeredThrough.identifier' | 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode';
|
|
9
|
+
type IAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IItemOffered>;
|
|
10
|
+
interface ISearchSlicedAcceptedOffersResult {
|
|
11
|
+
acceptedOffers: IAcceptedOffer[];
|
|
12
|
+
numAcceptedOffers: number;
|
|
13
|
+
}
|
|
9
14
|
/**
|
|
10
15
|
* 注文オファーリポジトリ
|
|
11
16
|
*/
|
|
@@ -29,6 +34,7 @@ export declare class MongoRepository {
|
|
|
29
34
|
searchAcceptedOffersByOrderNumber(filter: {
|
|
30
35
|
limit?: number;
|
|
31
36
|
page?: number;
|
|
37
|
+
$slice?: [number, number];
|
|
32
38
|
orderNumber: {
|
|
33
39
|
$eq: string;
|
|
34
40
|
};
|
|
@@ -47,7 +53,21 @@ export declare class MongoRepository {
|
|
|
47
53
|
};
|
|
48
54
|
};
|
|
49
55
|
};
|
|
50
|
-
}, inclusion?: (keyof
|
|
56
|
+
}, inclusion?: (keyof IAcceptedOffer)[]): Promise<IAcceptedOffer[]>;
|
|
57
|
+
/**
|
|
58
|
+
* 注文オファーをsliceして検索する(2024-01-10~)
|
|
59
|
+
*/
|
|
60
|
+
searchSlicedAcceptedOffersByOrderNumber(filter: {
|
|
61
|
+
$slice: [number, number];
|
|
62
|
+
orderNumber: {
|
|
63
|
+
$eq: string;
|
|
64
|
+
};
|
|
65
|
+
project: {
|
|
66
|
+
id: {
|
|
67
|
+
$eq: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}): Promise<ISearchSlicedAcceptedOffersResult>;
|
|
51
71
|
/**
|
|
52
72
|
* 特定のフィールド値リストを検索する
|
|
53
73
|
*/
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
13
14
|
const order_1 = require("./mongoose/schemas/order");
|
|
14
15
|
const order_2 = require("./order");
|
|
15
16
|
const settings_1 = require("../settings");
|
|
@@ -61,6 +62,7 @@ class MongoRepository {
|
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
{ $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
|
|
65
|
+
{ $match: { typeOf: { $eq: factory.order.OrderType.Order } } },
|
|
64
66
|
{
|
|
65
67
|
$project: {
|
|
66
68
|
_id: 0,
|
|
@@ -86,8 +88,9 @@ class MongoRepository {
|
|
|
86
88
|
var _a, _b, _c;
|
|
87
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
90
|
const matchStages = [
|
|
91
|
+
{ $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
|
|
89
92
|
{ $match: { 'project.id': { $eq: filter.project.id.$eq } } },
|
|
90
|
-
{ $match: {
|
|
93
|
+
{ $match: { typeOf: { $eq: factory.order.OrderType.Order } } }
|
|
91
94
|
];
|
|
92
95
|
const itemOfferedTypeOfIn = (_c = (_b = (_a = filter.acceptedOffers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.typeOf) === null || _c === void 0 ? void 0 : _c.$in;
|
|
93
96
|
if (Array.isArray(itemOfferedTypeOfIn)) {
|
|
@@ -137,6 +140,32 @@ class MongoRepository {
|
|
|
137
140
|
.exec();
|
|
138
141
|
});
|
|
139
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* 注文オファーをsliceして検索する(2024-01-10~)
|
|
145
|
+
*/
|
|
146
|
+
searchSlicedAcceptedOffersByOrderNumber(filter) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const aggregate = this.orderModel.aggregate([
|
|
149
|
+
{ $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
|
|
150
|
+
{ $match: { 'project.id': { $eq: filter.project.id.$eq } } },
|
|
151
|
+
{ $match: { typeOf: { $eq: factory.order.OrderType.Order } } },
|
|
152
|
+
{
|
|
153
|
+
$project: {
|
|
154
|
+
_id: 0,
|
|
155
|
+
acceptedOffers: { $slice: ['$acceptedOffers', ...filter.$slice] },
|
|
156
|
+
numAcceptedOffers: { $size: '$acceptedOffers' }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
]);
|
|
160
|
+
const result = (yield aggregate
|
|
161
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
162
|
+
.exec()).shift();
|
|
163
|
+
if (result === undefined) {
|
|
164
|
+
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
140
169
|
/**
|
|
141
170
|
* 特定のフィールド値リストを検索する
|
|
142
171
|
*/
|
|
@@ -146,7 +175,8 @@ class MongoRepository {
|
|
|
146
175
|
return [];
|
|
147
176
|
}
|
|
148
177
|
const filterQuery = {
|
|
149
|
-
orderNumber: { $in: filter.orderNumber.$in }
|
|
178
|
+
orderNumber: { $in: filter.orderNumber.$in },
|
|
179
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
150
180
|
};
|
|
151
181
|
filterQuery[field] = { $exists: true };
|
|
152
182
|
return this.orderModel.distinct(field, filterQuery)
|
|
@@ -78,10 +78,10 @@ export declare class MongoRepository {
|
|
|
78
78
|
/**
|
|
79
79
|
* アクション取消
|
|
80
80
|
*/
|
|
81
|
-
|
|
82
|
-
typeOf:
|
|
81
|
+
cancelWithVoid(params: {
|
|
82
|
+
typeOf: factory.actionType;
|
|
83
83
|
id: string;
|
|
84
|
-
}): Promise<
|
|
84
|
+
}): Promise<void>;
|
|
85
85
|
/**
|
|
86
86
|
* アクション失敗
|
|
87
87
|
*/
|
|
@@ -90,6 +90,12 @@ export declare class MongoRepository {
|
|
|
90
90
|
id: string;
|
|
91
91
|
error: Error;
|
|
92
92
|
}): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* アクション再開
|
|
95
|
+
*/
|
|
96
|
+
reStart(params: {
|
|
97
|
+
id: string;
|
|
98
|
+
}): Promise<void>;
|
|
93
99
|
/**
|
|
94
100
|
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
95
101
|
*/
|
|
@@ -150,11 +156,11 @@ export declare class MongoRepository {
|
|
|
150
156
|
id: string;
|
|
151
157
|
};
|
|
152
158
|
}): Promise<void>;
|
|
153
|
-
updateAuthorizeEventOfferAction
|
|
159
|
+
updateAuthorizeEventOfferAction(params: {
|
|
154
160
|
id: string;
|
|
155
|
-
object: factory.action.authorize.offer.eventService.IObject<
|
|
156
|
-
result: factory.action.authorize.offer.eventService.IResult<
|
|
157
|
-
}): Promise<factory.action.authorize.offer.eventService.IAction<
|
|
161
|
+
object: factory.action.authorize.offer.eventService.IObject<factory.service.webAPI.Identifier.COA>;
|
|
162
|
+
result: factory.action.authorize.offer.eventService.IResult<factory.service.webAPI.Identifier.COA>;
|
|
163
|
+
}): Promise<factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier.COA>>;
|
|
158
164
|
updateById(params: {
|
|
159
165
|
id: string;
|
|
160
166
|
update: any;
|
|
@@ -511,18 +511,16 @@ class MongoRepository {
|
|
|
511
511
|
/**
|
|
512
512
|
* アクション取消
|
|
513
513
|
*/
|
|
514
|
-
|
|
514
|
+
cancelWithVoid(params) {
|
|
515
515
|
return __awaiter(this, void 0, void 0, function* () {
|
|
516
516
|
const doc = yield this.actionModel.findOneAndUpdate({
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}, { actionStatus: factory.actionStatusType.CanceledActionStatus }, { new:
|
|
520
|
-
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
517
|
+
_id: { $eq: params.id },
|
|
518
|
+
typeOf: { $eq: params.typeOf }
|
|
519
|
+
}, { actionStatus: factory.actionStatusType.CanceledActionStatus }, { new: false, projection: { _id: 1 } })
|
|
521
520
|
.exec();
|
|
522
521
|
if (doc === null) {
|
|
523
522
|
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
524
523
|
}
|
|
525
|
-
return doc.toObject();
|
|
526
524
|
});
|
|
527
525
|
}
|
|
528
526
|
/**
|
|
@@ -551,6 +549,24 @@ class MongoRepository {
|
|
|
551
549
|
// return doc.toObject();
|
|
552
550
|
});
|
|
553
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* アクション再開
|
|
554
|
+
*/
|
|
555
|
+
reStart(params) {
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
const doc = yield this.actionModel.findOneAndUpdate({
|
|
558
|
+
_id: { $eq: params.id },
|
|
559
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
560
|
+
}, {
|
|
561
|
+
$set: { actionStatus: factory.actionStatusType.ActiveActionStatus },
|
|
562
|
+
$unset: { endDate: 1 }
|
|
563
|
+
}, { new: false, projection: { _id: 1 } })
|
|
564
|
+
.exec();
|
|
565
|
+
if (doc === null) {
|
|
566
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
554
570
|
/**
|
|
555
571
|
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
556
572
|
*/
|
|
@@ -648,12 +664,18 @@ class MongoRepository {
|
|
|
648
664
|
updateAuthorizeEventOfferAction(params) {
|
|
649
665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
650
666
|
return this.actionModel.findOneAndUpdate({
|
|
651
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
652
|
-
_id: params.id,
|
|
653
|
-
|
|
667
|
+
// typeOf: factory.actionType.AuthorizeAction,
|
|
668
|
+
_id: { $eq: params.id },
|
|
669
|
+
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
670
|
+
// actionStatus: factory.actionStatusType.CompletedActionStatus
|
|
671
|
+
actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus }
|
|
654
672
|
}, {
|
|
655
|
-
|
|
656
|
-
|
|
673
|
+
$set: {
|
|
674
|
+
actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
675
|
+
object: params.object,
|
|
676
|
+
result: params.result,
|
|
677
|
+
endDate: new Date()
|
|
678
|
+
}
|
|
657
679
|
}, { new: true })
|
|
658
680
|
.exec()
|
|
659
681
|
.then((doc) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Order";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|