@chevre/domain 21.32.0-alpha.9 → 21.32.0
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/findCheckAction.ts +37 -0
- package/example/src/chevre/investigateCheckMovieTicketActions.ts +60 -0
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +36 -0
- package/example/src/chevre/transaction/acceptCOAOffer.ts +78 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +1 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +11 -5
- package/lib/chevre/errorHandler.d.ts +4 -0
- package/lib/chevre/errorHandler.js +33 -1
- package/lib/chevre/repo/action.d.ts +50 -7
- package/lib/chevre/repo/action.js +111 -11
- package/lib/chevre/repo/aggregation.d.ts +4 -0
- package/lib/chevre/repo/aggregation.js +6 -0
- package/lib/chevre/repo/confirmationNumber.d.ts +1 -1
- package/lib/chevre/repo/confirmationNumber.js +7 -7
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +3 -14
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -12
- package/lib/chevre/repo/task.d.ts +4 -0
- package/lib/chevre/repo/task.js +6 -0
- package/lib/chevre/repository.d.ts +1 -1
- package/lib/chevre/repository.js +1 -1
- package/lib/chevre/service/code.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/event/authorize.js +7 -7
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +24 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +35 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +9 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +130 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +10 -3
- package/lib/chevre/service/offer/event/voidTransaction.js +77 -92
- package/lib/chevre/service/offer/event/{cancel.d.ts → voidTransactionByActionId.d.ts} +8 -22
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +85 -0
- package/lib/chevre/service/offer/event.d.ts +1 -2
- package/lib/chevre/service/offer/event.js +2 -3
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +23 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +258 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +15 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +20 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +33 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +182 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +3 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +5 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +41 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +66 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +6 -1
- package/lib/chevre/service/payment/any.d.ts +8 -0
- package/lib/chevre/service/payment/any.js +36 -9
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +6 -0
- package/lib/chevre/service/task/acceptCOAOffer.js +102 -0
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +34 -13
- package/lib/chevre/service/task.js +2 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +1 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActions.ts +0 -75
- package/lib/chevre/service/offer/event/cancel.js +0 -57
|
@@ -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
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const action = await (await chevre.service.payment.any.createService()).findCheckAction({
|
|
15
|
+
project: {
|
|
16
|
+
id: project.id
|
|
17
|
+
},
|
|
18
|
+
sameAs: {
|
|
19
|
+
id: '664db85f9801179aabb046e5'
|
|
20
|
+
},
|
|
21
|
+
purpose: {
|
|
22
|
+
id: '664db8219801179aabb04624'
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
minimize: true
|
|
26
|
+
}
|
|
27
|
+
})({
|
|
28
|
+
action: actionRepo,
|
|
29
|
+
task: taskRepo
|
|
30
|
+
});
|
|
31
|
+
// tslint:disable-next-line:no-null-keyword
|
|
32
|
+
console.dir(action.result?.purchaseNumberAuthResult, { depth: null });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then()
|
|
37
|
+
.catch(console.error);
|
|
@@ -0,0 +1,60 @@
|
|
|
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = actionRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
18
|
+
'object.typeOf': { $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket },
|
|
19
|
+
startDate: {
|
|
20
|
+
$gte: moment()
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
.add(-30, 'days')
|
|
23
|
+
.toDate()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
project: 1,
|
|
28
|
+
typeOf: 1,
|
|
29
|
+
startDate: 1,
|
|
30
|
+
object: 1
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('actions found');
|
|
34
|
+
|
|
35
|
+
let maxNumMovieTickets: number = 0;
|
|
36
|
+
let i = 0;
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
const checkAction: Pick<
|
|
40
|
+
chevre.factory.action.check.paymentMethod.movieTicket.IAction,
|
|
41
|
+
'project' | 'typeOf' | 'startDate' | 'object'
|
|
42
|
+
> = doc.toObject();
|
|
43
|
+
|
|
44
|
+
const numObject = checkAction.object.length;
|
|
45
|
+
const numMovieTickets = (Array.isArray(checkAction.object[0].movieTickets)) ? checkAction.object[0].movieTickets.length : 0;
|
|
46
|
+
maxNumMovieTickets = Math.max(maxNumMovieTickets, numMovieTickets);
|
|
47
|
+
console.log(
|
|
48
|
+
numObject,
|
|
49
|
+
numMovieTickets,
|
|
50
|
+
maxNumMovieTickets,
|
|
51
|
+
checkAction.project.id, checkAction.startDate, i
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log(i, 'actions checked');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main()
|
|
59
|
+
.then()
|
|
60
|
+
.catch(console.error);
|
|
@@ -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
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const mkknInfos = await actionRepo.searchMkknInfoByCheckMovieTicketResult({
|
|
14
|
+
limit: 10,
|
|
15
|
+
page: 1,
|
|
16
|
+
id: '664db85f9801179aabb046e8',
|
|
17
|
+
project: { id: project.id },
|
|
18
|
+
purpose: { id: '664db8219801179aabb04624' }
|
|
19
|
+
});
|
|
20
|
+
console.log('mkknInfos found', mkknInfos);
|
|
21
|
+
console.log(mkknInfos.length, 'infos found');
|
|
22
|
+
|
|
23
|
+
const ykknInfos = await actionRepo.searchYkknInfoByCheckMovieTicketResult({
|
|
24
|
+
limit: 10,
|
|
25
|
+
page: 1,
|
|
26
|
+
id: '664db85f9801179aabb046e8',
|
|
27
|
+
project: { id: project.id },
|
|
28
|
+
purpose: { id: '664db8219801179aabb04624' }
|
|
29
|
+
});
|
|
30
|
+
console.log('ykknInfos found', ykknInfos);
|
|
31
|
+
console.log(ykknInfos.length, 'infos found');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then()
|
|
36
|
+
.catch(console.error);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as COA from '@motionpicture/coa-service';
|
|
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 coaAuthClient = new COA.auth.RefreshToken({
|
|
14
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
15
|
+
refreshToken: chevre.credentials.coa.refreshToken,
|
|
16
|
+
useFetch: true
|
|
17
|
+
});
|
|
18
|
+
const acceptAction = await (await chevre.service.offer.createService()).eventServiceByCOA.acceptOffer({
|
|
19
|
+
object: {
|
|
20
|
+
event: { id: '120162210202405231201850' },
|
|
21
|
+
acceptedOffer: [
|
|
22
|
+
{
|
|
23
|
+
seatSection: ' ',
|
|
24
|
+
seatNumber: 'b-36',
|
|
25
|
+
ticketInfo: {
|
|
26
|
+
ticketCode: '10',
|
|
27
|
+
mvtkAppPrice: 0,
|
|
28
|
+
ticketCount: 1,
|
|
29
|
+
addGlasses: 0,
|
|
30
|
+
kbnEisyahousiki: '00',
|
|
31
|
+
mvtkNum: '',
|
|
32
|
+
mvtkKbnDenshiken: '00',
|
|
33
|
+
mvtkKbnMaeuriken: '00',
|
|
34
|
+
mvtkKbnKensyu: '00',
|
|
35
|
+
mvtkSalesPrice: 0,
|
|
36
|
+
kbnMgtk: ''
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
appliesToSurfrock: {
|
|
41
|
+
identifier: '',
|
|
42
|
+
serviceOutput: { typeOf: '' }
|
|
43
|
+
},
|
|
44
|
+
flgMember: COA.factory.reserve.FlgMember.NonMember,
|
|
45
|
+
typeOf: chevre.factory.offerType.AggregateOffer
|
|
46
|
+
},
|
|
47
|
+
// agent: {
|
|
48
|
+
// id: 'xxx',
|
|
49
|
+
// typeOf: chevre.factory.creativeWorkType.WebApplication
|
|
50
|
+
// },
|
|
51
|
+
purpose: { id: '664e80c79801179aabb0476f', typeOf: chevre.factory.transactionType.PlaceOrder },
|
|
52
|
+
sameAs: { id: 'xxx' },
|
|
53
|
+
potentialActions: { typeOf: chevre.factory.actionType.AuthorizeAction }
|
|
54
|
+
})({
|
|
55
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
56
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
57
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection),
|
|
58
|
+
reserveService: new COA.service.Reserve(
|
|
59
|
+
{
|
|
60
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
61
|
+
auth: coaAuthClient
|
|
62
|
+
},
|
|
63
|
+
{ timeout: chevre.credentials.coa.timeout }
|
|
64
|
+
),
|
|
65
|
+
masterService: new COA.service.Master(
|
|
66
|
+
{
|
|
67
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
68
|
+
auth: coaAuthClient
|
|
69
|
+
},
|
|
70
|
+
{ timeout: chevre.credentials.coa.timeout }
|
|
71
|
+
)
|
|
72
|
+
});
|
|
73
|
+
console.log('acceptAction:', acceptAction);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then(console.log)
|
|
78
|
+
.catch(console.error);
|
|
@@ -123,6 +123,7 @@ async function main() {
|
|
|
123
123
|
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
124
124
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
125
125
|
authorization: await chevre.repository.Code.createInstance(mongoose.connection),
|
|
126
|
+
confirmationNumber: await chevre.repository.ConfirmationNumber.createInstance(client),
|
|
126
127
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
127
128
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
128
129
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
2
3
|
import * as mongoose from 'mongoose';
|
|
3
4
|
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
@@ -8,10 +9,10 @@ async function main() {
|
|
|
8
9
|
|
|
9
10
|
let updateResult: any;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
12
|
+
const aggregationRepo = await chevre.repository.Aggregation.createInstance(mongoose.connection);
|
|
13
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
14
|
|
|
14
|
-
updateResult = await
|
|
15
|
+
updateResult = await aggregationRepo.unsetUnnecessaryFields({
|
|
15
16
|
filter: {
|
|
16
17
|
_id: { $exists: true }
|
|
17
18
|
},
|
|
@@ -23,9 +24,14 @@ async function main() {
|
|
|
23
24
|
});
|
|
24
25
|
console.log('unset processed.', updateResult);
|
|
25
26
|
|
|
26
|
-
updateResult = await
|
|
27
|
+
updateResult = await taskRepo.unsetUnnecessaryFields({
|
|
27
28
|
filter: {
|
|
28
|
-
_id: { $exists: true }
|
|
29
|
+
// _id: { $exists: true },
|
|
30
|
+
runsAt: {
|
|
31
|
+
$gte: moment()
|
|
32
|
+
.add(-1, 'days')
|
|
33
|
+
.toDate()
|
|
34
|
+
}
|
|
29
35
|
},
|
|
30
36
|
$unset: {
|
|
31
37
|
__v: 1,
|
|
@@ -9,6 +9,10 @@ export declare function handleMongoError(error: unknown): Promise<unknown>;
|
|
|
9
9
|
* 汎用的なCOAエラーハンドリング
|
|
10
10
|
*/
|
|
11
11
|
export declare function handleCOAError(error: any): Error;
|
|
12
|
+
/**
|
|
13
|
+
* COA仮予約エラーハンドリング
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleCOAReserveTemporarilyError(error: any): Error;
|
|
12
16
|
/**
|
|
13
17
|
* Pecorinoサービスエラーをハンドリングする
|
|
14
18
|
* 可能であればChevreエラーへ変換します
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.handleAWSError = exports.handleMvtkReserveError = exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = exports.handlePecorinoError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
12
|
+
exports.handleAWSError = exports.handleMvtkReserveError = exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = exports.handlePecorinoError = exports.handleCOAReserveTemporarilyError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* エラーハンドラー
|
|
15
15
|
* 外部サービスと連携している場合に、サービス(API)のエラーを本ドメインのエラーに変換する責任を担います。
|
|
@@ -81,6 +81,38 @@ function handleCOAError(error) {
|
|
|
81
81
|
return handledError;
|
|
82
82
|
}
|
|
83
83
|
exports.handleCOAError = handleCOAError;
|
|
84
|
+
/**
|
|
85
|
+
* COA仮予約エラーハンドリング
|
|
86
|
+
*/
|
|
87
|
+
// tslint:disable-next-line:no-any
|
|
88
|
+
function handleCOAReserveTemporarilyError(error) {
|
|
89
|
+
var _a;
|
|
90
|
+
let handledError = error;
|
|
91
|
+
// if (error.message === '座席取得失敗') {
|
|
92
|
+
// }
|
|
93
|
+
// メッセージ「既に予約済みです」の場合は、座席の重複とみなす
|
|
94
|
+
if (error.message === '既に予約済みです') {
|
|
95
|
+
handledError = new factory_1.errors.AlreadyInUse('offer', ['seatNumber'], 'Seat not available');
|
|
96
|
+
}
|
|
97
|
+
// Chevreが500未満であればクライアントエラーとみなす
|
|
98
|
+
const reserveServiceHttpStatusCode = error.code;
|
|
99
|
+
if (Number.isInteger(reserveServiceHttpStatusCode)) {
|
|
100
|
+
if (reserveServiceHttpStatusCode < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
101
|
+
handledError = new factory_1.errors.Argument('Event', error.message);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const uri = (_a = error.requestOptions) === null || _a === void 0 ? void 0 : _a.uri;
|
|
105
|
+
if (error.message === 'ETIMEDOUT' || error.message === 'ESOCKETTIMEDOUT') {
|
|
106
|
+
handledError = new factory_1.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} code:${error.code} message:${error.message} uri:${uri}`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
handledError = new factory_1.errors.ServiceUnavailable(`Reserve service temporarily unavailable. name:${error.name} code:${error.code} message:${error.message} uri:${uri}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return handledError;
|
|
114
|
+
}
|
|
115
|
+
exports.handleCOAReserveTemporarilyError = handleCOAReserveTemporarilyError;
|
|
84
116
|
/**
|
|
85
117
|
* Pecorinoサービスエラーをハンドリングする
|
|
86
118
|
* 可能であればChevreエラーへ変換します
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import
|
|
25
|
+
import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
26
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
26
27
|
import * as factory from '../factory';
|
|
27
28
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
28
29
|
export type IPayAction = factory.action.trade.pay.IAction;
|
|
@@ -48,6 +49,16 @@ interface IStatus {
|
|
|
48
49
|
interface IAggregateAction {
|
|
49
50
|
statuses: IStatus[];
|
|
50
51
|
}
|
|
52
|
+
export interface ICancelActionAction {
|
|
53
|
+
typeOf: factory.actionType.CancelAction;
|
|
54
|
+
agent: factory.action.IParticipantAsPerson | factory.action.IParticipantAsProject | factory.action.IParticipantAsWebApplication;
|
|
55
|
+
endTime: Date;
|
|
56
|
+
startTime: Date;
|
|
57
|
+
sameAs?: {
|
|
58
|
+
id: string;
|
|
59
|
+
typeOf: 'Task';
|
|
60
|
+
};
|
|
61
|
+
}
|
|
51
62
|
/**
|
|
52
63
|
* アクションリポジトリ
|
|
53
64
|
*/
|
|
@@ -80,8 +91,9 @@ export declare class MongoRepository {
|
|
|
80
91
|
* アクション取消
|
|
81
92
|
*/
|
|
82
93
|
cancelWithVoid(params: {
|
|
83
|
-
typeOf: factory.actionType;
|
|
94
|
+
typeOf: factory.actionType.AcceptAction | factory.actionType.AuthorizeAction;
|
|
84
95
|
id: string;
|
|
96
|
+
cancelAction?: Pick<ICancelActionAction, 'agent' | 'sameAs' | 'startTime'>;
|
|
85
97
|
}): Promise<void>;
|
|
86
98
|
/**
|
|
87
99
|
* アクション失敗
|
|
@@ -120,7 +132,7 @@ export declare class MongoRepository {
|
|
|
120
132
|
findById<T extends factory.actionType>(params: {
|
|
121
133
|
typeOf: T;
|
|
122
134
|
id: string;
|
|
123
|
-
}): Promise<IAction<T>>;
|
|
135
|
+
}, inclusion?: KeyOfAction[], exclusion?: KeyOfAction[]): Promise<IAction<T>>;
|
|
124
136
|
findPayAction(params: {
|
|
125
137
|
project: {
|
|
126
138
|
id: string;
|
|
@@ -131,10 +143,9 @@ export declare class MongoRepository {
|
|
|
131
143
|
};
|
|
132
144
|
}): Promise<IPayAction | undefined>;
|
|
133
145
|
/**
|
|
134
|
-
*
|
|
135
|
-
* 取引に対するアクション検索時などに使用
|
|
146
|
+
* 取引に対するアクションを検索する
|
|
136
147
|
*/
|
|
137
|
-
searchByPurpose<T extends factory.actionType>(params: {
|
|
148
|
+
searchByPurpose<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction>(params: {
|
|
138
149
|
typeOf?: T;
|
|
139
150
|
purpose: {
|
|
140
151
|
typeOf: factory.transactionType;
|
|
@@ -142,7 +153,7 @@ export declare class MongoRepository {
|
|
|
142
153
|
};
|
|
143
154
|
object?: {
|
|
144
155
|
typeOf?: {
|
|
145
|
-
$eq?: factory.action.authorize.offer.eventService.ObjectType.SeatReservation | factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
156
|
+
$eq?: factory.action.authorize.offer.eventService.ObjectType.SeatReservation | factory.action.authorize.paymentMethod.any.ResultType.Payment | factory.offerType.AggregateOffer;
|
|
146
157
|
};
|
|
147
158
|
paymentMethodId?: {
|
|
148
159
|
$eq?: string;
|
|
@@ -202,6 +213,38 @@ export declare class MongoRepository {
|
|
|
202
213
|
};
|
|
203
214
|
entranceGateIdentifier: string;
|
|
204
215
|
}): Promise<IUseActionCountByOffer[]>;
|
|
216
|
+
searchYkknInfoByCheckMovieTicketResult(filter: {
|
|
217
|
+
limit: number;
|
|
218
|
+
page: number;
|
|
219
|
+
/**
|
|
220
|
+
* 認証アクションID
|
|
221
|
+
*/
|
|
222
|
+
id: string;
|
|
223
|
+
project: {
|
|
224
|
+
id: string;
|
|
225
|
+
};
|
|
226
|
+
purpose: {
|
|
227
|
+
id: string;
|
|
228
|
+
};
|
|
229
|
+
}): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.IValidTicket & {
|
|
230
|
+
knyknrNo: string;
|
|
231
|
+
})[]>;
|
|
232
|
+
searchMkknInfoByCheckMovieTicketResult(filter: {
|
|
233
|
+
limit: number;
|
|
234
|
+
page: number;
|
|
235
|
+
/**
|
|
236
|
+
* 認証アクションID
|
|
237
|
+
*/
|
|
238
|
+
id: string;
|
|
239
|
+
project: {
|
|
240
|
+
id: string;
|
|
241
|
+
};
|
|
242
|
+
purpose: {
|
|
243
|
+
id: string;
|
|
244
|
+
};
|
|
245
|
+
}): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.INvalidTicket & {
|
|
246
|
+
knyknrNo: string;
|
|
247
|
+
})[]>;
|
|
205
248
|
/**
|
|
206
249
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
207
250
|
*/
|
|
@@ -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 mongoose_1 = require("mongoose");
|
|
13
14
|
const factory = require("../factory");
|
|
14
15
|
const action_1 = require("./mongoose/schemas/action");
|
|
15
16
|
const settings_1 = require("../settings");
|
|
@@ -504,19 +505,30 @@ class MongoRepository {
|
|
|
504
505
|
*/
|
|
505
506
|
cancelWithVoid(params) {
|
|
506
507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
+
const cancelDate = new Date();
|
|
509
|
+
const cancelAction = (params.cancelAction !== undefined)
|
|
510
|
+
? Object.assign(Object.assign({}, params.cancelAction), { endTime: cancelDate, typeOf: factory.actionType.CancelAction }) : undefined;
|
|
507
511
|
const doc = yield this.actionModel.findOneAndUpdate({
|
|
508
512
|
_id: { $eq: params.id },
|
|
509
|
-
typeOf: { $eq: params.typeOf }
|
|
510
|
-
|
|
513
|
+
typeOf: { $eq: params.typeOf },
|
|
514
|
+
actionStatus: { $ne: factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
|
|
515
|
+
}, {
|
|
516
|
+
$set: Object.assign({ actionStatus: factory.actionStatusType.CanceledActionStatus }, (cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
|
|
517
|
+
)
|
|
518
|
+
}, { new: false, projection: { _id: 1 } })
|
|
511
519
|
.exec();
|
|
512
520
|
if (doc === null) {
|
|
513
|
-
|
|
521
|
+
// 既にCanceledActionStatusであればok
|
|
522
|
+
const existingAction = yield this.findById({ id: params.id, typeOf: params.typeOf }, ['actionStatus'], []);
|
|
523
|
+
if (existingAction.actionStatus !== factory.actionStatusType.CanceledActionStatus) {
|
|
524
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
525
|
+
}
|
|
514
526
|
}
|
|
515
527
|
// endDateが存在しなければセット(2024-04-22~)
|
|
516
528
|
yield this.actionModel.updateOne({
|
|
517
529
|
_id: { $eq: params.id },
|
|
518
530
|
endDate: { $exists: false }
|
|
519
|
-
}, { $set: { endDate:
|
|
531
|
+
}, { $set: { endDate: cancelDate } })
|
|
520
532
|
.exec();
|
|
521
533
|
});
|
|
522
534
|
}
|
|
@@ -608,13 +620,30 @@ class MongoRepository {
|
|
|
608
620
|
.exec();
|
|
609
621
|
});
|
|
610
622
|
}
|
|
611
|
-
findById(params) {
|
|
623
|
+
findById(params, inclusion, exclusion) {
|
|
612
624
|
return __awaiter(this, void 0, void 0, function* () {
|
|
625
|
+
let projection = {};
|
|
626
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
627
|
+
inclusion.forEach((field) => {
|
|
628
|
+
projection[field] = 1;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
projection = {
|
|
633
|
+
__v: 0,
|
|
634
|
+
createdAt: 0,
|
|
635
|
+
updatedAt: 0
|
|
636
|
+
};
|
|
637
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
638
|
+
exclusion.forEach((field) => {
|
|
639
|
+
projection[field] = 0;
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
613
643
|
const doc = yield this.actionModel.findOne({
|
|
614
|
-
typeOf: params.typeOf,
|
|
615
|
-
_id: params.id
|
|
616
|
-
})
|
|
617
|
-
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
644
|
+
typeOf: { $eq: params.typeOf },
|
|
645
|
+
_id: { $eq: params.id }
|
|
646
|
+
}, projection)
|
|
618
647
|
.exec();
|
|
619
648
|
if (doc === null) {
|
|
620
649
|
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
@@ -639,8 +668,7 @@ class MongoRepository {
|
|
|
639
668
|
});
|
|
640
669
|
}
|
|
641
670
|
/**
|
|
642
|
-
*
|
|
643
|
-
* 取引に対するアクション検索時などに使用
|
|
671
|
+
* 取引に対するアクションを検索する
|
|
644
672
|
*/
|
|
645
673
|
searchByPurpose(params) {
|
|
646
674
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -799,6 +827,78 @@ class MongoRepository {
|
|
|
799
827
|
.exec();
|
|
800
828
|
});
|
|
801
829
|
}
|
|
830
|
+
searchYkknInfoByCheckMovieTicketResult(filter) {
|
|
831
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
832
|
+
const filterQuery = {
|
|
833
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(filter.id) },
|
|
834
|
+
'project.id': { $eq: filter.project.id },
|
|
835
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
836
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
837
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
838
|
+
};
|
|
839
|
+
const projectStage = {
|
|
840
|
+
_id: 0,
|
|
841
|
+
knyknrNo: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.knyknrNo',
|
|
842
|
+
ykknshTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.ykknshTyp',
|
|
843
|
+
eishhshkTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.eishhshkTyp',
|
|
844
|
+
ykknKnshbtsmiNum: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.ykknKnshbtsmiNum',
|
|
845
|
+
knshknhmbiUnip: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.knshknhmbiUnip',
|
|
846
|
+
kijUnip: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.kijUnip'
|
|
847
|
+
};
|
|
848
|
+
const aggregate = this.actionModel.aggregate([
|
|
849
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut' },
|
|
850
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo' },
|
|
851
|
+
{ $match: filterQuery },
|
|
852
|
+
{ $project: projectStage }
|
|
853
|
+
]);
|
|
854
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
855
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
856
|
+
aggregate.limit(filter.limit * page)
|
|
857
|
+
.skip(filter.limit * (page - 1));
|
|
858
|
+
}
|
|
859
|
+
return aggregate
|
|
860
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
861
|
+
.exec();
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
searchMkknInfoByCheckMovieTicketResult(filter) {
|
|
865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
866
|
+
const filterQuery = {
|
|
867
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(filter.id) },
|
|
868
|
+
'project.id': { $eq: filter.project.id },
|
|
869
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
870
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
871
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
872
|
+
};
|
|
873
|
+
const projectStage = {
|
|
874
|
+
_id: 0,
|
|
875
|
+
knyknrNo: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.knyknrNo',
|
|
876
|
+
mkknshTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkknshTyp',
|
|
877
|
+
mkknKnshbtsmiNum: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkknKnshbtsmiNum',
|
|
878
|
+
mkjyTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkjyTyp',
|
|
879
|
+
yykDt: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.yykDt',
|
|
880
|
+
shyJeiDt: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyJeiDt',
|
|
881
|
+
shyStCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyStCd',
|
|
882
|
+
shyScrnCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyScrnCd',
|
|
883
|
+
shySkhnCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shySkhnCd',
|
|
884
|
+
shySkhnNm: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shySkhnNm'
|
|
885
|
+
};
|
|
886
|
+
const aggregate = this.actionModel.aggregate([
|
|
887
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut' },
|
|
888
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo' },
|
|
889
|
+
{ $match: filterQuery },
|
|
890
|
+
{ $project: projectStage }
|
|
891
|
+
]);
|
|
892
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
893
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
894
|
+
aggregate.limit(filter.limit * page)
|
|
895
|
+
.skip(filter.limit * (page - 1));
|
|
896
|
+
}
|
|
897
|
+
return aggregate
|
|
898
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
899
|
+
.exec();
|
|
900
|
+
});
|
|
901
|
+
}
|
|
802
902
|
/**
|
|
803
903
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
804
904
|
*/
|
|
@@ -38,4 +38,8 @@ export declare class MongoRepository {
|
|
|
38
38
|
readonly aggregationModel: typeof Model;
|
|
39
39
|
constructor(connection: Connection);
|
|
40
40
|
saveAggregation(params: IAggregation): Promise<any>;
|
|
41
|
+
unsetUnnecessaryFields(params: {
|
|
42
|
+
filter: any;
|
|
43
|
+
$unset: any;
|
|
44
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
41
45
|
}
|
|
@@ -67,5 +67,11 @@ class MongoRepository {
|
|
|
67
67
|
return doc.toObject();
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
+
unsetUnnecessaryFields(params) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return this.aggregationModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
73
|
+
.exec();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
70
76
|
}
|
|
71
77
|
exports.MongoRepository = MongoRepository;
|
|
@@ -2,7 +2,7 @@ import { RedisClientType } from 'redis';
|
|
|
2
2
|
/**
|
|
3
3
|
* 確認番号リポジトリ
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class ConfirmationNumberRepo {
|
|
6
6
|
private static readonly REDIS_KEY_PREFIX_NEW;
|
|
7
7
|
private readonly redisClient;
|
|
8
8
|
constructor(redisClient: RedisClientType);
|