@chevre/domain 21.37.0-alpha.1 → 21.37.0-alpha.10
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/assetTransaction/processReserve.ts +79 -0
- package/lib/chevre/repo/assetTransaction.d.ts +9 -8
- package/lib/chevre/repo/assetTransaction.js +74 -29
- package/lib/chevre/repo/mongoose/schemas/action.js +9 -9
- package/lib/chevre/repo/mongoose/schemas/reservation.js +7 -4
- package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund/potentialActions.js +6 -8
- package/lib/chevre/service/assetTransaction/refund.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/cancel.js +41 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm/factory.d.ts +8 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm/factory.js +94 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserve/confirm.js +93 -0
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +99 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +28 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +405 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +40 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +54 -0
- package/lib/chevre/service/assetTransaction/reserve/{factory.js → start/factory/createReservation.js} +3 -292
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +91 -0
- package/lib/chevre/service/assetTransaction/reserve/{factory → start/factory}/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/{factory → start/factory}/price.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +73 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +567 -0
- package/lib/chevre/service/assetTransaction/reserve.d.ts +6 -132
- package/lib/chevre/service/assetTransaction/reserve.js +9 -1036
- package/lib/chevre/service/notification.d.ts +5 -1
- package/lib/chevre/service/notification.js +5 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -3
- package/lib/chevre/service/offer/event/authorize.js +48 -37
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +2 -2
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +0 -3
- package/lib/chevre/service/offer/event/processStartReserve4chevre.js +7 -4
- package/lib/chevre/service/offer/onEventChanged.js +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +4 -4
- package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -4
- package/lib/chevre/service/payment/any/onPaid.d.ts +1 -3
- package/lib/chevre/service/payment/any/onPaid.js +7 -4
- package/lib/chevre/service/payment/any/onRefund.js +6 -3
- package/lib/chevre/service/payment/factory.js +6 -8
- package/lib/chevre/service/reserve/cancelReservation.js +1 -1
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/factory.d.ts +18 -1
- package/lib/chevre/service/reserve/factory.js +74 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +8 -8
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +4 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +4 -4
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +4 -4
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +4 -4
- package/lib/chevre/service/task/onResourceUpdated.js +24 -24
- package/lib/chevre/service/task/triggerWebhook.d.ts +2 -2
- package/lib/chevre/service/task/triggerWebhook.js +3 -3
- package/lib/chevre/service/task.js +1 -0
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -2
- package/package.json +3 -3
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +0 -105
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
12
|
+
socket: {
|
|
13
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
14
|
+
host: <string>process.env.REDIS_HOST
|
|
15
|
+
},
|
|
16
|
+
password: <string>process.env.REDIS_KEY
|
|
17
|
+
});
|
|
18
|
+
await redisClient.connect();
|
|
19
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
20
|
+
|
|
21
|
+
const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance(redisClient);
|
|
22
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
23
|
+
|
|
24
|
+
const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() });
|
|
25
|
+
const provider: chevre.factory.reservation.IProvider = {
|
|
26
|
+
id: '59d20831e53ebc2b4e774466',
|
|
27
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
28
|
+
};
|
|
29
|
+
const reserveTransaction = await assetTransactionRepo.start<chevre.factory.assetTransactionType.Reserve>({
|
|
30
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
31
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
32
|
+
transactionNumber,
|
|
33
|
+
agent: { ...provider, name: 'sample agent name' },
|
|
34
|
+
object: {
|
|
35
|
+
provider,
|
|
36
|
+
reservationNumber: transactionNumber,
|
|
37
|
+
reservationStatus: chevre.factory.reservationStatusType.ReservationPending,
|
|
38
|
+
disablePendingReservations: true,
|
|
39
|
+
useHoldStockByTransactionNumber: true,
|
|
40
|
+
typeOf: chevre.factory.reservationType.ReservationPackage
|
|
41
|
+
},
|
|
42
|
+
expires: moment()
|
|
43
|
+
.add(1, 'minute')
|
|
44
|
+
.toDate()
|
|
45
|
+
});
|
|
46
|
+
let cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
|
|
47
|
+
typeOf: reserveTransaction.typeOf,
|
|
48
|
+
id: reserveTransaction.id
|
|
49
|
+
});
|
|
50
|
+
console.log('cancelResult:', cancelResult);
|
|
51
|
+
cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
|
|
52
|
+
typeOf: reserveTransaction.typeOf,
|
|
53
|
+
id: reserveTransaction.id
|
|
54
|
+
});
|
|
55
|
+
console.log('cancelResult:', cancelResult);
|
|
56
|
+
|
|
57
|
+
let transaction = await assetTransactionRepo.findById<chevre.factory.assetTransactionType.Reserve>(
|
|
58
|
+
{
|
|
59
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
60
|
+
id: reserveTransaction.id
|
|
61
|
+
},
|
|
62
|
+
['status', 'transactionNumber', 'project', 'typeOf']
|
|
63
|
+
);
|
|
64
|
+
console.log('transaction:', transaction);
|
|
65
|
+
|
|
66
|
+
transaction = await assetTransactionRepo.findByTransactionNumber<chevre.factory.assetTransactionType.Reserve>(
|
|
67
|
+
{
|
|
68
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
69
|
+
transactionNumber
|
|
70
|
+
},
|
|
71
|
+
['status']
|
|
72
|
+
);
|
|
73
|
+
console.log('transaction:', transaction);
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main()
|
|
78
|
+
.then(console.log)
|
|
79
|
+
.catch(console.error);
|
|
@@ -45,6 +45,7 @@ interface IStatus {
|
|
|
45
45
|
export interface IAggregateReserve {
|
|
46
46
|
statuses: IStatus[];
|
|
47
47
|
}
|
|
48
|
+
type IKeyOfProjection<T extends factory.assetTransactionType> = keyof Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'agent' | 'endDate' | 'expires' | 'project' | 'startDate' | 'status' | 'typeOf' | 'transactionNumber'> | Exclude<keyof factory.assetTransaction.ITransaction<T>, 'id'>;
|
|
48
49
|
/**
|
|
49
50
|
* 資産取引リポジトリ
|
|
50
51
|
*/
|
|
@@ -56,22 +57,20 @@ export declare class MongoRepository {
|
|
|
56
57
|
* 取引を開始する
|
|
57
58
|
*/
|
|
58
59
|
start<T extends factory.assetTransactionType>(params: factory.assetTransaction.IStartParams<T>): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
60
|
+
startWithMinimalResponse<T extends factory.assetTransactionType>(params: factory.assetTransaction.IStartParams<T>): Promise<Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id'>>;
|
|
59
61
|
findById<T extends factory.assetTransactionType>(params: {
|
|
60
62
|
typeOf: T;
|
|
61
63
|
id: string;
|
|
62
|
-
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
64
|
+
}, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
63
65
|
findByTransactionNumber<T extends factory.assetTransactionType>(params: {
|
|
64
66
|
typeOf: T;
|
|
65
67
|
transactionNumber: string;
|
|
66
|
-
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
68
|
+
}, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
67
69
|
addReservations(params: {
|
|
68
70
|
typeOf: factory.assetTransactionType.Reserve;
|
|
69
71
|
id: string;
|
|
70
|
-
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | '
|
|
71
|
-
|
|
72
|
-
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
73
|
-
};
|
|
74
|
-
}): Promise<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
|
|
72
|
+
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'subReservation'>;
|
|
73
|
+
}): Promise<void>;
|
|
75
74
|
/**
|
|
76
75
|
* 取引を確定する
|
|
77
76
|
*/
|
|
@@ -147,7 +146,9 @@ export declare class MongoRepository {
|
|
|
147
146
|
typeOf: T;
|
|
148
147
|
id?: string;
|
|
149
148
|
transactionNumber?: string;
|
|
150
|
-
}): Promise<
|
|
149
|
+
}): Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
}>;
|
|
151
152
|
count<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>): Promise<number>;
|
|
152
153
|
/**
|
|
153
154
|
* 取引を検索する
|
|
@@ -299,7 +299,9 @@ class MongoRepository {
|
|
|
299
299
|
/**
|
|
300
300
|
* 取引を開始する
|
|
301
301
|
*/
|
|
302
|
-
start(params
|
|
302
|
+
start(params
|
|
303
|
+
// ): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id'>> {
|
|
304
|
+
) {
|
|
303
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
306
|
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
305
307
|
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
@@ -307,12 +309,38 @@ class MongoRepository {
|
|
|
307
309
|
.then((doc) => doc.toObject());
|
|
308
310
|
});
|
|
309
311
|
}
|
|
310
|
-
|
|
312
|
+
startWithMinimalResponse(params) {
|
|
313
|
+
var _a, _b;
|
|
311
314
|
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
const { typeOf } = params;
|
|
316
|
+
const creatingTransaction = Object.assign(Object.assign({}, params), { typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(),
|
|
317
|
+
// endDate: undefined,
|
|
318
|
+
tasksExportAction: {
|
|
319
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
320
|
+
} });
|
|
321
|
+
const result = yield this.transactionModel.insertMany(creatingTransaction, { ordered: false, rawResult: true });
|
|
322
|
+
const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
323
|
+
if (typeof id !== 'string') {
|
|
324
|
+
throw new factory.errors.Internal('assetTransaction not saved');
|
|
325
|
+
}
|
|
326
|
+
return { id };
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
findById(params, inclusion) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
let projection = {};
|
|
332
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
333
|
+
inclusion.forEach((field) => {
|
|
334
|
+
projection[field] = 1;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
projection = {};
|
|
339
|
+
}
|
|
312
340
|
const doc = yield this.transactionModel.findOne({
|
|
313
|
-
_id: params.id,
|
|
314
|
-
typeOf: params.typeOf
|
|
315
|
-
})
|
|
341
|
+
_id: { $eq: params.id },
|
|
342
|
+
typeOf: { $eq: params.typeOf }
|
|
343
|
+
}, projection)
|
|
316
344
|
.exec();
|
|
317
345
|
if (doc === null) {
|
|
318
346
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -320,12 +348,21 @@ class MongoRepository {
|
|
|
320
348
|
return doc.toObject();
|
|
321
349
|
});
|
|
322
350
|
}
|
|
323
|
-
findByTransactionNumber(params) {
|
|
351
|
+
findByTransactionNumber(params, inclusion) {
|
|
324
352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
+
let projection = {};
|
|
354
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
355
|
+
inclusion.forEach((field) => {
|
|
356
|
+
projection[field] = 1;
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
projection = {};
|
|
361
|
+
}
|
|
325
362
|
const doc = yield this.transactionModel.findOne({
|
|
326
363
|
transactionNumber: { $eq: params.transactionNumber },
|
|
327
|
-
typeOf: params.typeOf
|
|
328
|
-
})
|
|
364
|
+
typeOf: { $eq: params.typeOf }
|
|
365
|
+
}, projection)
|
|
329
366
|
.exec();
|
|
330
367
|
if (doc === null) {
|
|
331
368
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -340,16 +377,18 @@ class MongoRepository {
|
|
|
340
377
|
typeOf: { $eq: params.typeOf },
|
|
341
378
|
status: { $eq: factory.transactionStatusType.InProgress }
|
|
342
379
|
}, {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
380
|
+
$set: {
|
|
381
|
+
'object.acceptedOffer': params.object.acceptedOffer,
|
|
382
|
+
// 'object.issuedThrough': params.object.issuedThrough, // start時保管へ移行(2024-07-01~)
|
|
383
|
+
// 'object.reservationFor': params.object.reservationFor, // start時保管へ移行(2024-07-01~)
|
|
384
|
+
'object.subReservation': params.object.subReservation
|
|
385
|
+
}
|
|
386
|
+
}, { new: false, projection: { _id: 1 } })
|
|
348
387
|
.exec();
|
|
349
388
|
if (doc === null) {
|
|
350
389
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
351
390
|
}
|
|
352
|
-
return doc.toObject();
|
|
391
|
+
// return doc.toObject();
|
|
353
392
|
});
|
|
354
393
|
}
|
|
355
394
|
/**
|
|
@@ -373,15 +412,15 @@ class MongoRepository {
|
|
|
373
412
|
.exec();
|
|
374
413
|
// NotFoundであれば取引状態確認
|
|
375
414
|
if (doc === null) {
|
|
376
|
-
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
415
|
+
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
|
|
377
416
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
378
417
|
// すでに確定済の場合スルー
|
|
379
418
|
}
|
|
380
419
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
381
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${
|
|
420
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already expired`);
|
|
382
421
|
}
|
|
383
422
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
384
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${
|
|
423
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already canceled`);
|
|
385
424
|
}
|
|
386
425
|
else {
|
|
387
426
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -593,26 +632,31 @@ class MongoRepository {
|
|
|
593
632
|
*/
|
|
594
633
|
cancel(params) {
|
|
595
634
|
return __awaiter(this, void 0, void 0, function* () {
|
|
596
|
-
const endDate = new Date();
|
|
597
635
|
// 進行中ステータスの取引を中止する
|
|
598
636
|
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
|
|
599
637
|
? { transactionNumber: { $eq: params.transactionNumber } }
|
|
600
638
|
: undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
639
|
+
$set: {
|
|
640
|
+
status: factory.transactionStatusType.Canceled,
|
|
641
|
+
endDate: new Date()
|
|
642
|
+
}
|
|
643
|
+
}, {
|
|
644
|
+
new: true,
|
|
645
|
+
projection: { _id: 1 }
|
|
646
|
+
})
|
|
604
647
|
.exec();
|
|
605
|
-
let
|
|
648
|
+
let result;
|
|
606
649
|
// NotFoundであれば取引状態確認
|
|
607
650
|
if (doc === null) {
|
|
651
|
+
let transaction;
|
|
608
652
|
if (typeof params.id === 'string') {
|
|
609
|
-
transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
653
|
+
transaction = yield this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
|
|
610
654
|
}
|
|
611
655
|
else if (typeof params.transactionNumber === 'string') {
|
|
612
656
|
transaction = yield this.findByTransactionNumber({
|
|
613
657
|
typeOf: params.typeOf,
|
|
614
658
|
transactionNumber: params.transactionNumber
|
|
615
|
-
});
|
|
659
|
+
}, ['status']);
|
|
616
660
|
}
|
|
617
661
|
else {
|
|
618
662
|
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
@@ -621,24 +665,25 @@ class MongoRepository {
|
|
|
621
665
|
// すでに中止済の場合スルー
|
|
622
666
|
}
|
|
623
667
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
624
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${
|
|
668
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${transaction.id} already expired`);
|
|
625
669
|
}
|
|
626
670
|
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
627
|
-
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${
|
|
671
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${params.typeOf} ${transaction.id} unable to cancel`);
|
|
628
672
|
}
|
|
629
673
|
else {
|
|
630
674
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
631
675
|
}
|
|
676
|
+
result = { id: transaction.id };
|
|
632
677
|
}
|
|
633
678
|
else {
|
|
634
|
-
|
|
679
|
+
result = { id: doc.toObject().id };
|
|
635
680
|
}
|
|
636
681
|
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
637
|
-
id:
|
|
682
|
+
id: result.id,
|
|
638
683
|
typeOf: params.typeOf,
|
|
639
684
|
status: factory.transactionStatusType.Canceled
|
|
640
685
|
});
|
|
641
|
-
return
|
|
686
|
+
return result;
|
|
642
687
|
});
|
|
643
688
|
}
|
|
644
689
|
count(params) {
|
|
@@ -226,15 +226,15 @@ const indexes = [
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
],
|
|
229
|
-
[
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
],
|
|
229
|
+
// [
|
|
230
|
+
// { 'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': 1, startDate: -1 },
|
|
231
|
+
// {
|
|
232
|
+
// name: 'searchByObjectAcceptedOfferItemOfferedServiceOutputSeatNumber',
|
|
233
|
+
// partialFilterExpression: {
|
|
234
|
+
// 'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': { $exists: true }
|
|
235
|
+
// }
|
|
236
|
+
// }
|
|
237
|
+
// ], // discontinue(2024-07-02~)
|
|
238
238
|
[
|
|
239
239
|
{ 'object.orderNumber': 1, startDate: -1 },
|
|
240
240
|
{
|
|
@@ -60,10 +60,13 @@ const schemaOptions = {
|
|
|
60
60
|
writeConcern: writeConcern_1.writeConcern,
|
|
61
61
|
strict: true,
|
|
62
62
|
strictQuery: false,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
// discontinue(2024-07-02~)
|
|
64
|
+
// timestamps: {
|
|
65
|
+
// createdAt: 'createdAt',
|
|
66
|
+
// updatedAt: 'updatedAt'
|
|
67
|
+
// },
|
|
68
|
+
timestamps: false,
|
|
69
|
+
versionKey: false,
|
|
67
70
|
toJSON: {
|
|
68
71
|
getters: false,
|
|
69
72
|
virtuals: false,
|
|
@@ -22,7 +22,7 @@ export declare function start(params: factory.assetTransaction.cancelReservation
|
|
|
22
22
|
seller: {
|
|
23
23
|
id?: string;
|
|
24
24
|
};
|
|
25
|
-
}): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction
|
|
25
|
+
}): IStartOperation<Pick<factory.assetTransaction.cancelReservation.ITransaction, 'id'>>;
|
|
26
26
|
/**
|
|
27
27
|
* 取引確定
|
|
28
28
|
*/
|
|
@@ -50,17 +50,15 @@ function createInformPaymentActions(params) {
|
|
|
50
50
|
: String(transaction.agent.id),
|
|
51
51
|
url: String((_c = a.recipient) === null || _c === void 0 ? void 0 : _c.url)
|
|
52
52
|
};
|
|
53
|
+
// optimize(2024-07-01~)
|
|
53
54
|
return {
|
|
54
|
-
project: transaction.project,
|
|
55
|
-
typeOf: factory.actionType.InformAction,
|
|
56
|
-
agent: transaction.project,
|
|
55
|
+
// project: transaction.project,
|
|
56
|
+
// typeOf: factory.actionType.InformAction,
|
|
57
|
+
// agent: transaction.project,
|
|
57
58
|
recipient,
|
|
58
59
|
// 実際にタスクが生成される直前にactionに置き換える
|
|
59
|
-
object: {},
|
|
60
|
-
purpose: {
|
|
61
|
-
typeOf: transaction.typeOf,
|
|
62
|
-
id: transaction.id
|
|
63
|
-
}
|
|
60
|
+
// object: {},
|
|
61
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
64
62
|
};
|
|
65
63
|
}));
|
|
66
64
|
}
|
|
@@ -24,7 +24,7 @@ export type IExportTasksOperation<T> = (repos: {
|
|
|
24
24
|
/**
|
|
25
25
|
* 取引開始
|
|
26
26
|
*/
|
|
27
|
-
export declare function start(params: factory.assetTransaction.refund.IStartParamsWithoutDetail): IStartOperation<factory.assetTransaction.refund.ITransaction
|
|
27
|
+
export declare function start(params: factory.assetTransaction.refund.IStartParamsWithoutDetail): IStartOperation<Pick<factory.assetTransaction.refund.ITransaction, 'id'>>;
|
|
28
28
|
/**
|
|
29
29
|
* 取引確定
|
|
30
30
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
3
|
+
import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
4
|
+
import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
5
|
+
import type { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
type ICancelOperation<T> = (repos: {
|
|
8
|
+
action: ActionRepo;
|
|
9
|
+
stockHolder: StockHolderRepo;
|
|
10
|
+
offerRateLimit: OfferRateLimitRepo;
|
|
11
|
+
reservation: ReservationRepo;
|
|
12
|
+
task: TaskRepo;
|
|
13
|
+
assetTransaction: AssetTransactionRepo;
|
|
14
|
+
}) => Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* 取引中止
|
|
17
|
+
*/
|
|
18
|
+
declare function cancel(params: {
|
|
19
|
+
id?: string;
|
|
20
|
+
transactionNumber?: string;
|
|
21
|
+
}): ICancelOperation<void>;
|
|
22
|
+
export { cancel };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.cancel = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const cancelReservation_1 = require("../../reserve/cancelReservation");
|
|
15
|
+
/**
|
|
16
|
+
* 取引中止
|
|
17
|
+
*/
|
|
18
|
+
function cancel(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
// まず取引状態変更
|
|
21
|
+
const { id } = yield repos.assetTransaction.cancel({
|
|
22
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
23
|
+
id: params.id,
|
|
24
|
+
transactionNumber: params.transactionNumber
|
|
25
|
+
});
|
|
26
|
+
// 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
|
|
27
|
+
// 同期的にもcancelPendingReservationを実行しておく
|
|
28
|
+
// optimize(2024-07-01~)
|
|
29
|
+
// const cancelActionAttributes = createCancelPendingReservationAction({ transaction });
|
|
30
|
+
// if (cancelActionAttributes !== undefined) {
|
|
31
|
+
// await cancelPendingReservation(cancelActionAttributes)(repos);
|
|
32
|
+
// }
|
|
33
|
+
yield (0, cancelReservation_1.cancelPendingReservation)({
|
|
34
|
+
purpose: {
|
|
35
|
+
id,
|
|
36
|
+
typeOf: factory.assetTransactionType.Reserve
|
|
37
|
+
}
|
|
38
|
+
})(repos);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.cancel = cancel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
declare function createPotentialActions(params: {
|
|
3
|
+
order?: Pick<factory.order.IOrder, 'orderNumber' | 'customer' | 'typeOf'>;
|
|
4
|
+
}): {
|
|
5
|
+
potentialActions: factory.assetTransaction.reserve.IPotentialActions;
|
|
6
|
+
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
7
|
+
};
|
|
8
|
+
export { createPotentialActions };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPotentialActions = void 0;
|
|
4
|
+
// tslint:disable-next-line:max-func-body-length
|
|
5
|
+
function createPotentialActions(params) {
|
|
6
|
+
// const transaction = params.transaction;
|
|
7
|
+
// const reservationFor = transaction.object.reservationFor;
|
|
8
|
+
// if (reservationFor === undefined) {
|
|
9
|
+
// throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
10
|
+
// }
|
|
11
|
+
var _a;
|
|
12
|
+
// discontinue(2024-07-01~)
|
|
13
|
+
// const useOptimizeReservation: boolean = !USE_OPTIMIZE_RESERVATION_EXCEPTIONS.includes(transaction.project.id);
|
|
14
|
+
// 予約アクション属性作成
|
|
15
|
+
// const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
|
|
16
|
+
// let reserveActionAttributes: factory.action.reserve.IAttributes[] = [];
|
|
17
|
+
// let reservationPackage: factory.action.reserve.IObject | undefined;
|
|
18
|
+
let underName;
|
|
19
|
+
// purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
|
|
20
|
+
if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
21
|
+
const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
|
|
22
|
+
underName = ordre2reservationUnderNameResult.underName;
|
|
23
|
+
}
|
|
24
|
+
// if (pendingReservations.length > 0) {
|
|
25
|
+
// const moneyTransferActions: factory.action.transfer.moneyTransfer.IAttributes[] = [];
|
|
26
|
+
// pendingReservations.forEach((reservation) => {
|
|
27
|
+
// const acceptedOffer4reservation = transaction.object.acceptedOffer?.find(
|
|
28
|
+
// (o) => o.itemOffered?.serviceOutput?.id === reservation.id
|
|
29
|
+
// );
|
|
30
|
+
// moneyTransferActions.push(...createMoneyTransferActions({
|
|
31
|
+
// acceptedOffer: acceptedOffer4reservation,
|
|
32
|
+
// reservation,
|
|
33
|
+
// transaction: params.transaction,
|
|
34
|
+
// underName
|
|
35
|
+
// }));
|
|
36
|
+
// });
|
|
37
|
+
// reservationPackage = {
|
|
38
|
+
// reservationFor: {
|
|
39
|
+
// id: String(reservationFor.id),
|
|
40
|
+
// typeOf: reservationFor.typeOf,
|
|
41
|
+
// optimized: true
|
|
42
|
+
// }, // optimize(2024-01-24~)
|
|
43
|
+
// reservationNumber: transaction.object.reservationNumber,
|
|
44
|
+
// reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
|
|
45
|
+
// ? params.transaction.object.reservationStatus
|
|
46
|
+
// : factory.reservationStatusType.ReservationPending,
|
|
47
|
+
// typeOf: factory.reservationType.ReservationPackage
|
|
48
|
+
// };
|
|
49
|
+
// reserveActionAttributes = [{
|
|
50
|
+
// project: transaction.project,
|
|
51
|
+
// typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
|
|
52
|
+
// object: reservationPackage,
|
|
53
|
+
// agent: transaction.project,
|
|
54
|
+
// potentialActions: {
|
|
55
|
+
// moneyTransfer: moneyTransferActions
|
|
56
|
+
// },
|
|
57
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
58
|
+
// }];
|
|
59
|
+
// }
|
|
60
|
+
return {
|
|
61
|
+
potentialActions: {
|
|
62
|
+
// reserve: reserveActionAttributes // discontinue(2024-07-01~)
|
|
63
|
+
},
|
|
64
|
+
// reservationPackage,
|
|
65
|
+
underName
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.createPotentialActions = createPotentialActions;
|
|
69
|
+
/**
|
|
70
|
+
* 予約のunderName.identifierを決定する
|
|
71
|
+
*/
|
|
72
|
+
function createReservationUnderNameIdentifier(params) {
|
|
73
|
+
// 必要最低限の識別子のみ継承する(2024-03-16~)
|
|
74
|
+
let identifiersFromCustomer = (Array.isArray(params.order.customer.identifier)) ? params.order.customer.identifier : [];
|
|
75
|
+
// if (params.useOptimizeReservation) {
|
|
76
|
+
// identifiersFromCustomer = identifiersFromCustomer.filter(({ name }) => name === 'clientId');
|
|
77
|
+
// }
|
|
78
|
+
identifiersFromCustomer = identifiersFromCustomer.filter(({ name }) => name === 'clientId');
|
|
79
|
+
return [
|
|
80
|
+
{ name: 'orderNumber', value: params.order.orderNumber },
|
|
81
|
+
...identifiersFromCustomer
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
function createReservationUnderName(params) {
|
|
85
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: createReservationUnderNameIdentifier({ order: params.order }), name: String(params.order.customer.name), typeOf: params.order.customer.typeOf }, (typeof params.order.customer.address === 'string') ? { address: params.order.customer.address } : undefined), (typeof params.order.customer.age === 'string') ? { age: params.order.customer.age } : undefined), (typeof params.order.customer.email === 'string') ? { email: params.order.customer.email } : undefined), (typeof params.order.customer.familyName === 'string') ? { familyName: params.order.customer.familyName } : undefined), (typeof params.order.customer.gender === 'string') ? { gender: params.order.customer.gender } : undefined), (typeof params.order.customer.givenName === 'string') ? { givenName: params.order.customer.givenName } : undefined), (typeof params.order.customer.id === 'string') ? { id: params.order.customer.id } : undefined), (typeof params.order.customer.telephone === 'string') ? { telephone: params.order.customer.telephone } : undefined), (typeof params.order.customer.url === 'string') ? { url: params.order.customer.url } : undefined);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 注文者情報を予約者情報へ変換する
|
|
89
|
+
*/
|
|
90
|
+
function ordre2reservationUnderName(params) {
|
|
91
|
+
return {
|
|
92
|
+
underName: createReservationUnderName({ order: params.order })
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
+
import type { MongoRepository as OrderRepo } from '../../../repo/order';
|
|
5
|
+
import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
interface IConfirmRepo {
|
|
8
|
+
action: ActionRepo;
|
|
9
|
+
assetTransaction: AssetTransactionRepo;
|
|
10
|
+
order: OrderRepo;
|
|
11
|
+
reservation: ReservationRepo;
|
|
12
|
+
task: TaskRepo;
|
|
13
|
+
}
|
|
14
|
+
type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* 取引確定
|
|
17
|
+
*/
|
|
18
|
+
declare function confirm(params: factory.assetTransaction.reserve.IConfirmParams): IConfirmOperation<void>;
|
|
19
|
+
export { confirm };
|