@chevre/domain 21.8.0-alpha.2 → 21.8.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/db/stats.ts +22 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/searchTasks.ts +31 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +6 -0
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +34 -1
- package/lib/chevre/repo/task.d.ts +4 -1
- package/lib/chevre/repo/task.js +108 -22
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +5 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/reserve.js +48 -7
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -5
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +73 -87
- package/lib/chevre/service/order/onOrderStatusChanged.js +98 -73
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +12 -11
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +24 -7
- package/lib/chevre/service/payment/any.js +22 -18
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +16 -4
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +1 -2
- package/lib/chevre/settings.js +2 -5
- package/package.json +2 -2
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
const KILO_BYTES = 1024;
|
|
5
|
+
async function main() {
|
|
6
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
7
|
+
|
|
8
|
+
const stats = await mongoose.connection.db.collection('tasks')
|
|
9
|
+
.stats({
|
|
10
|
+
scale: KILO_BYTES * KILO_BYTES
|
|
11
|
+
});
|
|
12
|
+
console.log('scaleFactor:', stats.scaleFactor);
|
|
13
|
+
console.log('avgObjSize:', stats.avgObjSize);
|
|
14
|
+
console.log('count:', stats.count);
|
|
15
|
+
console.log('size:', stats.size);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main()
|
|
19
|
+
.then(() => {
|
|
20
|
+
console.log('success!');
|
|
21
|
+
})
|
|
22
|
+
.catch(console.error);
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
// 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
|
+
|
|
13
|
+
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = orderRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
// 'project.id': { $eq: project.id },
|
|
18
|
+
// orderNumber: { $eq: 'KNR1-3961294-9087043' },
|
|
19
|
+
orderDate: {
|
|
20
|
+
$gte: moment()
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
.add(-12, 'months')
|
|
23
|
+
.toDate()
|
|
24
|
+
// $lte: moment()
|
|
25
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
26
|
+
// .add(-6, 'months')
|
|
27
|
+
// .toDate()
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
orderDate: 1,
|
|
32
|
+
orderNumber: 1,
|
|
33
|
+
project: 1,
|
|
34
|
+
paymentMethods: 1
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
console.log('orders found');
|
|
38
|
+
|
|
39
|
+
let i = 0;
|
|
40
|
+
let updateCount = 0;
|
|
41
|
+
await cursor.eachAsync(async (doc) => {
|
|
42
|
+
i += 1;
|
|
43
|
+
const order: Pick<
|
|
44
|
+
chevre.factory.order.IOrder,
|
|
45
|
+
'orderDate' | 'orderNumber' | 'project' | 'paymentMethods'
|
|
46
|
+
> = doc.toObject();
|
|
47
|
+
|
|
48
|
+
const noPayment = order.paymentMethods.length === 0;
|
|
49
|
+
const alreadyMigrated = order.paymentMethods.every((invoice) => {
|
|
50
|
+
return typeof invoice.paymentMethod?.identifier === 'string'
|
|
51
|
+
&& invoice.paymentMethod.identifier === invoice.typeOf;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (noPayment) {
|
|
55
|
+
console.log('noPayment.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
56
|
+
} else if (alreadyMigrated) {
|
|
57
|
+
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
58
|
+
} else {
|
|
59
|
+
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i);
|
|
60
|
+
for (const invoice of order.paymentMethods) {
|
|
61
|
+
await orderRepo.fixPaymentMethodIdentifier({
|
|
62
|
+
project: { id: order.project.id },
|
|
63
|
+
orderNumber: order.orderNumber,
|
|
64
|
+
invoice: {
|
|
65
|
+
paymentMethodId: invoice.paymentMethodId,
|
|
66
|
+
paymentMethod: { identifier: invoice.typeOf }
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
updateCount += 1;
|
|
71
|
+
console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
console.log(i, 'orders checked');
|
|
76
|
+
console.log(updateCount, 'orders updated');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
main()
|
|
80
|
+
.then()
|
|
81
|
+
.catch(console.error);
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
// 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
|
+
|
|
13
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
18
|
+
// 'object.paymentMethodId': { $exists: false },
|
|
19
|
+
// 'project.id': { $eq: project.id },
|
|
20
|
+
startDate: {
|
|
21
|
+
$gte: moment()
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
.add(-12, 'months')
|
|
24
|
+
.toDate()
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
typeOf: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
object: 1,
|
|
31
|
+
transactionNumber: 1,
|
|
32
|
+
startDate: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('transactions found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
let updateCount = 0;
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const payTransaction: Pick<
|
|
42
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
43
|
+
'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
|
|
44
|
+
> = doc.toObject();
|
|
45
|
+
|
|
46
|
+
const alreadyMigrated = typeof payTransaction.object.paymentMethodId === 'string'
|
|
47
|
+
&& payTransaction.object.paymentMethodId === (<any>payTransaction.object.paymentMethod).paymentMethodId;
|
|
48
|
+
|
|
49
|
+
if (alreadyMigrated) {
|
|
50
|
+
console.log(
|
|
51
|
+
'already exist.',
|
|
52
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
53
|
+
} else {
|
|
54
|
+
const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
|
|
55
|
+
console.log(
|
|
56
|
+
'updating...',
|
|
57
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
58
|
+
paymentMethodIdentifier);
|
|
59
|
+
updateCount += 1;
|
|
60
|
+
console.log(
|
|
61
|
+
'updated.',
|
|
62
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
console.log(i, 'transactions checked');
|
|
67
|
+
console.log(updateCount, 'transactions updated');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main()
|
|
71
|
+
.then()
|
|
72
|
+
.catch(console.error);
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
// 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
|
+
|
|
13
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
startDate: {
|
|
20
|
+
$gte: moment('2023-05-08T00:00:00Z')
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
// .add(-12, 'months')
|
|
23
|
+
.toDate(),
|
|
24
|
+
$lte: moment('2023-08-30T21:00:00Z')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
typeOf: 1,
|
|
30
|
+
project: 1,
|
|
31
|
+
object: 1,
|
|
32
|
+
transactionNumber: 1,
|
|
33
|
+
startDate: 1
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
console.log('transactions found');
|
|
37
|
+
|
|
38
|
+
let i = 0;
|
|
39
|
+
let updateCount = 0;
|
|
40
|
+
await cursor.eachAsync(async (doc) => {
|
|
41
|
+
i += 1;
|
|
42
|
+
const payTransaction: Pick<
|
|
43
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
44
|
+
'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
|
|
45
|
+
> = doc.toObject();
|
|
46
|
+
|
|
47
|
+
const alreadyMigrated = payTransaction.object.paymentMethod.identifier
|
|
48
|
+
=== (<any>payTransaction.object.paymentMethod).typeOf;
|
|
49
|
+
|
|
50
|
+
if (alreadyMigrated) {
|
|
51
|
+
console.log(
|
|
52
|
+
'already exist.',
|
|
53
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate,
|
|
54
|
+
i, updateCount);
|
|
55
|
+
} else {
|
|
56
|
+
const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
|
|
57
|
+
console.log(
|
|
58
|
+
'updating...',
|
|
59
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
60
|
+
paymentMethodIdentifier);
|
|
61
|
+
await assetTransactionRepo.migratePaymentMethodIdentifier({
|
|
62
|
+
transactionNumber: payTransaction.transactionNumber,
|
|
63
|
+
object: { paymentMethod: { identifier: paymentMethodIdentifier } }
|
|
64
|
+
});
|
|
65
|
+
updateCount += 1;
|
|
66
|
+
console.log(
|
|
67
|
+
'updated.',
|
|
68
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(i, 'transactions checked');
|
|
73
|
+
console.log(updateCount, 'transactions updated');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then()
|
|
78
|
+
.catch(console.error);
|
|
@@ -43,14 +43,13 @@ async function main() {
|
|
|
43
43
|
.toDate(),
|
|
44
44
|
object: {
|
|
45
45
|
typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
46
|
-
id: '
|
|
46
|
+
id: 'xxx',
|
|
47
47
|
paymentMethod: {
|
|
48
48
|
amount: 1,
|
|
49
|
-
|
|
50
|
-
typeOf: 'CreditCard',
|
|
49
|
+
identifier: 'CreditCard',
|
|
51
50
|
method: '1',
|
|
52
51
|
creditCard: {
|
|
53
|
-
memberId: '
|
|
52
|
+
memberId: 'xxx',
|
|
54
53
|
cardSeq: 91
|
|
55
54
|
// cardPass?: string;
|
|
56
55
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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, { autoIndex: true });
|
|
10
|
+
|
|
11
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const tasks = await taskRepo.search(
|
|
14
|
+
{
|
|
15
|
+
limit: 1,
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
name: { $in: [chevre.factory.taskName.SendOrder] },
|
|
18
|
+
data: {
|
|
19
|
+
object: {
|
|
20
|
+
orderNumber: { $eq: 'xxx' }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('tasks found', tasks);
|
|
26
|
+
console.log(tasks.length, 'tasks found');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main()
|
|
30
|
+
.then()
|
|
31
|
+
.catch(console.error);
|
|
@@ -78,7 +78,14 @@ export declare class MongoRepository {
|
|
|
78
78
|
confirm<T extends factory.assetTransactionType>(params: {
|
|
79
79
|
typeOf: T;
|
|
80
80
|
id: string;
|
|
81
|
-
object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'
|
|
81
|
+
object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'> & {
|
|
82
|
+
/**
|
|
83
|
+
* 決済取引における決済方法区分指定
|
|
84
|
+
*/
|
|
85
|
+
paymentMethod?: {
|
|
86
|
+
identifier?: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
82
89
|
result: factory.assetTransaction.IResult<T>;
|
|
83
90
|
potentialActions: factory.assetTransaction.IPotentialActions<T>;
|
|
84
91
|
}): Promise<void>;
|
|
@@ -182,6 +189,14 @@ export declare class MongoRepository {
|
|
|
182
189
|
id: string;
|
|
183
190
|
update: any;
|
|
184
191
|
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
192
|
+
migratePaymentMethodIdentifier(params: {
|
|
193
|
+
transactionNumber: string;
|
|
194
|
+
object: {
|
|
195
|
+
paymentMethod: {
|
|
196
|
+
identifier: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
}): Promise<any>;
|
|
185
200
|
findByIdAndDelete(params: {
|
|
186
201
|
id: string;
|
|
187
202
|
}): Promise<void>;
|
|
@@ -344,14 +344,16 @@ class MongoRepository {
|
|
|
344
344
|
* 取引を確定する
|
|
345
345
|
*/
|
|
346
346
|
confirm(params) {
|
|
347
|
-
var _a, _b;
|
|
347
|
+
var _a, _b, _c, _d;
|
|
348
348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
349
349
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
350
350
|
_id: { $eq: params.id },
|
|
351
351
|
typeOf: { $eq: params.typeOf },
|
|
352
352
|
status: { $eq: factory.transactionStatusType.InProgress }
|
|
353
|
-
}, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
353
|
+
}, Object.assign(Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
354
354
|
? { 'object.underName': params.object.underName }
|
|
355
|
+
: undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethod) === null || _d === void 0 ? void 0 : _d.identifier) === 'string')
|
|
356
|
+
? { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }
|
|
355
357
|
: undefined), {
|
|
356
358
|
new: true,
|
|
357
359
|
projection: { _id: 1 }
|
|
@@ -704,6 +706,55 @@ class MongoRepository {
|
|
|
704
706
|
});
|
|
705
707
|
});
|
|
706
708
|
}
|
|
709
|
+
migratePaymentMethodIdentifier(params) {
|
|
710
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
return this.transactionModel.findOneAndUpdate({
|
|
712
|
+
typeOf: { $eq: factory.assetTransactionType.Pay },
|
|
713
|
+
transactionNumber: { $exists: true, $eq: params.transactionNumber }
|
|
714
|
+
}, { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }, {
|
|
715
|
+
new: true,
|
|
716
|
+
projection: { _id: 1 }
|
|
717
|
+
})
|
|
718
|
+
.exec()
|
|
719
|
+
.then((doc) => {
|
|
720
|
+
if (doc === null) {
|
|
721
|
+
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
722
|
+
}
|
|
723
|
+
return doc.toObject();
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
// public async migratePaymentMethodIdentifierMany() {
|
|
728
|
+
// // return this.transactionModel.updateMany(
|
|
729
|
+
// // {
|
|
730
|
+
// // typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
731
|
+
// // // 'object.paymentMethod.identifier': { $exists: false }
|
|
732
|
+
// // },
|
|
733
|
+
// // { $set: { 'object.paymentMethod.identifier': '$object.paymentMethod.typeOf' } }
|
|
734
|
+
// // )
|
|
735
|
+
// // .exec();
|
|
736
|
+
// return this.transactionModel.aggregate([
|
|
737
|
+
// {
|
|
738
|
+
// $match: {
|
|
739
|
+
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
740
|
+
// }
|
|
741
|
+
// },
|
|
742
|
+
// {
|
|
743
|
+
// $project: {
|
|
744
|
+
// paymentMethodIdentifier: '$object.paymentMethod.typeOf'
|
|
745
|
+
// }
|
|
746
|
+
// },
|
|
747
|
+
// {
|
|
748
|
+
// $unset: ['object.paymentMethod.identifier']
|
|
749
|
+
// }
|
|
750
|
+
// // {
|
|
751
|
+
// // $set: {
|
|
752
|
+
// // 'object.paymentMethod.identifier': '$paymentMethodIdentifier'
|
|
753
|
+
// // }
|
|
754
|
+
// // }
|
|
755
|
+
// ])
|
|
756
|
+
// .exec();
|
|
757
|
+
// }
|
|
707
758
|
findByIdAndDelete(params) {
|
|
708
759
|
return __awaiter(this, void 0, void 0, function* () {
|
|
709
760
|
yield this.transactionModel.findByIdAndDelete(params.id)
|
|
@@ -713,6 +764,7 @@ class MongoRepository {
|
|
|
713
764
|
getCursor(conditions, projection) {
|
|
714
765
|
return this.transactionModel.find(conditions, projection)
|
|
715
766
|
.sort({ startDate: factory.sortType.Ascending })
|
|
767
|
+
// .sort({ startDate: factory.sortType.Descending })
|
|
716
768
|
.cursor();
|
|
717
769
|
}
|
|
718
770
|
aggregateAssetTransaction(params) {
|
|
@@ -72,6 +72,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
72
72
|
customer?: any;
|
|
73
73
|
returner?: any;
|
|
74
74
|
orderStatus?: string | undefined;
|
|
75
|
+
previousOrderStatus?: string | undefined;
|
|
75
76
|
isGift?: boolean | undefined;
|
|
76
77
|
dateReturned?: Date | undefined;
|
|
77
78
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
@@ -95,6 +96,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
95
96
|
customer?: any;
|
|
96
97
|
returner?: any;
|
|
97
98
|
orderStatus?: string | undefined;
|
|
99
|
+
previousOrderStatus?: string | undefined;
|
|
98
100
|
isGift?: boolean | undefined;
|
|
99
101
|
dateReturned?: Date | undefined;
|
|
100
102
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
@@ -118,6 +120,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
118
120
|
customer?: any;
|
|
119
121
|
returner?: any;
|
|
120
122
|
orderStatus?: string | undefined;
|
|
123
|
+
previousOrderStatus?: string | undefined;
|
|
121
124
|
isGift?: boolean | undefined;
|
|
122
125
|
dateReturned?: Date | undefined;
|
|
123
126
|
}> & {
|
|
@@ -83,6 +83,12 @@ schema.index({ 'data.object.itemOffered.membershipFor.id': 1, runsAt: -1 }, {
|
|
|
83
83
|
'data.object.itemOffered.membershipFor.id': { $exists: true }
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
+
schema.index({ 'data.object.orderNumber': 1, runsAt: -1 }, {
|
|
87
|
+
name: 'searchByDataObjectOrderNumber',
|
|
88
|
+
partialFilterExpression: {
|
|
89
|
+
'data.object.orderNumber': { $exists: true }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
86
92
|
schema.index({ 'data.object.transactionNumber': 1, runsAt: -1 }, {
|
|
87
93
|
name: 'searchByDataObjectTransactionNumber',
|
|
88
94
|
partialFilterExpression: {
|
|
@@ -70,6 +70,21 @@ export declare class MongoRepository {
|
|
|
70
70
|
}): Promise<{
|
|
71
71
|
updatedAt: Date;
|
|
72
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* 注文後に決済方法区分を確定する
|
|
75
|
+
*/
|
|
76
|
+
fixPaymentMethodIdentifier(params: {
|
|
77
|
+
project: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
orderNumber: string;
|
|
81
|
+
invoice: {
|
|
82
|
+
paymentMethodId: string;
|
|
83
|
+
paymentMethod: {
|
|
84
|
+
identifier: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}): Promise<void>;
|
|
73
88
|
findById(params: {
|
|
74
89
|
id: string;
|
|
75
90
|
inclusion: string[];
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -681,7 +681,10 @@ class MongoRepository {
|
|
|
681
681
|
orderNumber: { $eq: params.orderNumber },
|
|
682
682
|
orderStatus: { $eq: params.previousOrderStatus },
|
|
683
683
|
'project.id': { $eq: params.project.id }
|
|
684
|
-
}, {
|
|
684
|
+
}, {
|
|
685
|
+
previousOrderStatus: params.previousOrderStatus,
|
|
686
|
+
orderStatus: params.orderStatus
|
|
687
|
+
}, {
|
|
685
688
|
new: true,
|
|
686
689
|
projection: {
|
|
687
690
|
__v: 0,
|
|
@@ -723,6 +726,7 @@ class MongoRepository {
|
|
|
723
726
|
orderStatus: { $eq: factory.orderStatus.OrderDelivered },
|
|
724
727
|
'project.id': { $eq: params.project.id }
|
|
725
728
|
}, {
|
|
729
|
+
previousOrderStatus: factory.orderStatus.OrderDelivered,
|
|
726
730
|
orderStatus: factory.orderStatus.OrderReturned,
|
|
727
731
|
dateReturned: params.dateReturned,
|
|
728
732
|
returner: params.returner
|
|
@@ -782,6 +786,35 @@ class MongoRepository {
|
|
|
782
786
|
return { updatedAt: doc.updatedAt };
|
|
783
787
|
});
|
|
784
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* 注文後に決済方法区分を確定する
|
|
791
|
+
*/
|
|
792
|
+
fixPaymentMethodIdentifier(params) {
|
|
793
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
794
|
+
const doc = yield this.orderModel.findOneAndUpdate({
|
|
795
|
+
orderNumber: { $eq: params.orderNumber },
|
|
796
|
+
'project.id': { $eq: params.project.id },
|
|
797
|
+
'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
|
|
798
|
+
}, {
|
|
799
|
+
$set: {
|
|
800
|
+
'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
|
|
801
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
802
|
+
// TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
|
|
803
|
+
'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
|
|
804
|
+
}
|
|
805
|
+
}, {
|
|
806
|
+
arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
|
|
807
|
+
new: true,
|
|
808
|
+
projection: {
|
|
809
|
+
_id: 1
|
|
810
|
+
}
|
|
811
|
+
})
|
|
812
|
+
.exec();
|
|
813
|
+
if (doc === null) {
|
|
814
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
785
818
|
findById(params) {
|
|
786
819
|
return __awaiter(this, void 0, void 0, function* () {
|
|
787
820
|
let projection = {};
|
|
@@ -35,6 +35,9 @@ export declare class MongoRepository {
|
|
|
35
35
|
* 取引削除タスク冪等作成
|
|
36
36
|
*/
|
|
37
37
|
createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
38
|
+
createConfirmReserveTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
39
|
+
createOnAssetTransactionStatusChangedTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.OnAssetTransactionStatusChanged>, options: IOptionOnCreate): Promise<void>;
|
|
40
|
+
createSendOrderTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.SendOrder>, options: IOptionOnCreate): Promise<void>;
|
|
38
41
|
executeById(params: {
|
|
39
42
|
id: string;
|
|
40
43
|
executor: {
|
|
@@ -67,7 +70,7 @@ export declare class MongoRepository {
|
|
|
67
70
|
*/
|
|
68
71
|
$nin?: factory.taskName[];
|
|
69
72
|
};
|
|
70
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
73
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
71
74
|
retry(params: {
|
|
72
75
|
intervalInMinutes: number;
|
|
73
76
|
}): Promise<void>;
|