@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,182 @@
|
|
|
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.reAcceptOffer = exports.acceptOffer = void 0;
|
|
13
|
+
const errorHandler_1 = require("../../../errorHandler");
|
|
14
|
+
const factory = require("../../../factory");
|
|
15
|
+
const authorize_1 = require("./acceptOffer/authorize");
|
|
16
|
+
const factory_1 = require("./acceptOffer/factory");
|
|
17
|
+
function findCOAInfo(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const searchConditions = {
|
|
20
|
+
project: { id: { $eq: params.project.id } },
|
|
21
|
+
limit: 1,
|
|
22
|
+
page: 1,
|
|
23
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
24
|
+
id: { $eq: params.id }
|
|
25
|
+
};
|
|
26
|
+
const event = (yield repos.event.search(searchConditions, ['coaInfo'], [])).shift();
|
|
27
|
+
if (event === undefined) {
|
|
28
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEvent);
|
|
29
|
+
}
|
|
30
|
+
if (event.coaInfo === undefined) {
|
|
31
|
+
throw new factory.errors.NotFound('coaInfo');
|
|
32
|
+
}
|
|
33
|
+
const { theaterCode, dateJouei, titleCode, titleBranchNum, timeBegin, timeEnd, screenCode } = event.coaInfo;
|
|
34
|
+
return { theaterCode, dateJouei, titleCode, titleBranchNum, timeBegin, timeEnd, screenCode };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* COA興行オファー採用
|
|
39
|
+
*/
|
|
40
|
+
function acceptOffer(params) {
|
|
41
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (typeof params.sameAs.id !== 'string' || params.sameAs.id === '') {
|
|
43
|
+
throw new factory.errors.ArgumentNull('sameAs.id');
|
|
44
|
+
}
|
|
45
|
+
const transaction = yield repos.transaction.findInProgressById({
|
|
46
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
47
|
+
id: params.purpose.id
|
|
48
|
+
});
|
|
49
|
+
const coaInfo = yield findCOAInfo({
|
|
50
|
+
id: params.object.event.id,
|
|
51
|
+
project: { id: transaction.project.id }
|
|
52
|
+
})(repos);
|
|
53
|
+
let requestBody;
|
|
54
|
+
requestBody = (0, factory_1.createUpdTmpReserveSeatArgs)({ object: params.object, coaInfo });
|
|
55
|
+
const actionAttributes = {
|
|
56
|
+
project: transaction.project,
|
|
57
|
+
typeOf: factory.actionType.AcceptAction,
|
|
58
|
+
object: params.object,
|
|
59
|
+
agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
|
|
60
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
61
|
+
sameAs: { id: params.sameAs.id, typeOf: 'Task' },
|
|
62
|
+
potentialActions: params.potentialActions,
|
|
63
|
+
instrument: { typeOf: 'COAReserveTransaction', requestBody }
|
|
64
|
+
};
|
|
65
|
+
let acceptedOffer;
|
|
66
|
+
let responseBody;
|
|
67
|
+
const action = yield repos.action.start(actionAttributes);
|
|
68
|
+
try {
|
|
69
|
+
const acceptedOffersWithoutDetails = yield (0, authorize_1.createAcceptedOffersWithoutDetails)({
|
|
70
|
+
object: params.object,
|
|
71
|
+
coaInfo
|
|
72
|
+
})({ reserveService: repos.reserveService });
|
|
73
|
+
acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
|
|
74
|
+
identifier: params.object.appliesToSurfrock.identifier,
|
|
75
|
+
serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
|
|
76
|
+
},
|
|
77
|
+
// (params.agent.typeOf === factory.personType.Person),
|
|
78
|
+
params.object.flgMember)({
|
|
79
|
+
reserveService: repos.reserveService,
|
|
80
|
+
masterService: repos.masterService
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
responseBody = yield repos.reserveService.updTmpReserveSeat(requestBody);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw (0, errorHandler_1.handleCOAReserveTemporarilyError)(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
try {
|
|
91
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
92
|
+
}
|
|
93
|
+
catch (__) {
|
|
94
|
+
// no op
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
const result = {
|
|
99
|
+
object: {
|
|
100
|
+
acceptedOffer,
|
|
101
|
+
event: { id: params.object.event.id }
|
|
102
|
+
},
|
|
103
|
+
result: { responseBody },
|
|
104
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
105
|
+
};
|
|
106
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.acceptOffer = acceptOffer;
|
|
110
|
+
/**
|
|
111
|
+
* COA興行オファー採用変更
|
|
112
|
+
*/
|
|
113
|
+
function reAcceptOffer(params) {
|
|
114
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a;
|
|
116
|
+
if (typeof params.sameAs.id !== 'string' || params.sameAs.id === '') {
|
|
117
|
+
throw new factory.errors.ArgumentNull('sameAs.id');
|
|
118
|
+
}
|
|
119
|
+
if (typeof ((_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.potentialActions.id === '') {
|
|
120
|
+
throw new factory.errors.ArgumentNull('potentialActions.id');
|
|
121
|
+
}
|
|
122
|
+
const transaction = yield repos.transaction.findInProgressById({
|
|
123
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
124
|
+
id: params.purpose.id
|
|
125
|
+
});
|
|
126
|
+
const coaInfo = yield findCOAInfo({
|
|
127
|
+
id: params.object.event.id,
|
|
128
|
+
project: { id: transaction.project.id }
|
|
129
|
+
})(repos);
|
|
130
|
+
// 承認アクション存在検証
|
|
131
|
+
yield repos.action.findById({ id: params.potentialActions.id, typeOf: factory.actionType.AuthorizeAction }, ['_id'], []);
|
|
132
|
+
const actionAttributes = {
|
|
133
|
+
project: transaction.project,
|
|
134
|
+
typeOf: factory.actionType.AcceptAction,
|
|
135
|
+
object: params.object,
|
|
136
|
+
agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
|
|
137
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
138
|
+
sameAs: { id: params.sameAs.id, typeOf: 'Task' },
|
|
139
|
+
potentialActions: params.potentialActions,
|
|
140
|
+
instrument: {
|
|
141
|
+
typeOf: 'COAReserveTransaction'
|
|
142
|
+
// requestBody: {}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
let acceptedOffer;
|
|
146
|
+
const action = yield repos.action.start(actionAttributes);
|
|
147
|
+
try {
|
|
148
|
+
const acceptedOffersWithoutDetails = params.object.acceptedOffer.map((offer) => {
|
|
149
|
+
return Object.assign(Object.assign({}, offer), { ticketInfo: Object.assign(Object.assign({}, offer.ticketInfo), { spseatAdd1: 0, spseatAdd2: 0, spseatKbn: '' // 承認時に上書きされるので問題なし
|
|
150
|
+
}) });
|
|
151
|
+
});
|
|
152
|
+
acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
|
|
153
|
+
identifier: params.object.appliesToSurfrock.identifier,
|
|
154
|
+
serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
|
|
155
|
+
},
|
|
156
|
+
// (params.agent.typeOf === factory.personType.Person),
|
|
157
|
+
params.object.flgMember)({
|
|
158
|
+
reserveService: repos.reserveService,
|
|
159
|
+
masterService: repos.masterService
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
try {
|
|
164
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
165
|
+
}
|
|
166
|
+
catch (__) {
|
|
167
|
+
// no op
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
const result = {
|
|
172
|
+
id: params.potentialActions.id,
|
|
173
|
+
object: {
|
|
174
|
+
acceptedOffer,
|
|
175
|
+
event: { id: params.object.event.id }
|
|
176
|
+
},
|
|
177
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
178
|
+
};
|
|
179
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
exports.reAcceptOffer = reAcceptOffer;
|
|
@@ -48,7 +48,5 @@ export declare function authorize(params: {
|
|
|
48
48
|
requestBody: factory.action.authorize.offer.eventService.IRequestBody<WebAPIIdentifier.COA>;
|
|
49
49
|
responseBody: factory.action.authorize.offer.eventService.IResponseBody<WebAPIIdentifier.COA>;
|
|
50
50
|
};
|
|
51
|
-
options: {
|
|
52
|
-
useCreateOrderOnOfferAccepted: boolean;
|
|
53
|
-
};
|
|
51
|
+
options: {};
|
|
54
52
|
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|
|
@@ -116,13 +116,13 @@ function authorize(params) {
|
|
|
116
116
|
acceptedOffers: []
|
|
117
117
|
};
|
|
118
118
|
// add orderInTransaction(2024-01-15~)
|
|
119
|
-
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
119
|
+
// if (params.options.useCreateOrderOnOfferAccepted) {
|
|
120
|
+
yield (0, any_1.acceptOffer)({
|
|
121
|
+
project: transaction.project,
|
|
122
|
+
purpose: { id: transaction.id },
|
|
123
|
+
acceptedOffers: acceptedOffers4result
|
|
124
|
+
})(repos);
|
|
125
|
+
// }
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
128
|
try {
|
|
@@ -18,6 +18,10 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
|
18
18
|
*/
|
|
19
19
|
function cancel(params) {
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const cancelAction = {
|
|
22
|
+
startTime: new Date(),
|
|
23
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project }
|
|
24
|
+
};
|
|
21
25
|
const transaction = yield repos.transaction.findInProgressById({
|
|
22
26
|
typeOf: factory.transactionType.PlaceOrder,
|
|
23
27
|
id: params.transaction.id
|
|
@@ -30,7 +34,7 @@ function cancel(params) {
|
|
|
30
34
|
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
31
35
|
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
32
36
|
}
|
|
33
|
-
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
37
|
+
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id, cancelAction });
|
|
34
38
|
// add orderInTransaction(2024-01-15~)
|
|
35
39
|
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
36
40
|
const orderNumberByTransaction = transaction.object.orderNumber;
|
|
@@ -106,13 +106,13 @@ function changeOffers(params) {
|
|
|
106
106
|
})(repos);
|
|
107
107
|
}
|
|
108
108
|
// add orderInTransaction(2024-01-15~)
|
|
109
|
-
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
109
|
+
// if (params.options.useCreateOrderOnOfferAccepted) {
|
|
110
|
+
yield (0, any_1.acceptOffer)({
|
|
111
|
+
project: transaction.project,
|
|
112
|
+
purpose: { id: transaction.id },
|
|
113
|
+
acceptedOffers: acceptedOffers4result
|
|
114
|
+
})(repos);
|
|
115
|
+
// }
|
|
116
116
|
}
|
|
117
117
|
catch (error) {
|
|
118
118
|
try {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
4
|
+
interface IFindAcceptActionResult {
|
|
5
|
+
/**
|
|
6
|
+
* アクションID
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* アクションスタータス
|
|
11
|
+
*/
|
|
12
|
+
actionStatus: factory.actionStatusType;
|
|
13
|
+
/**
|
|
14
|
+
* エラー
|
|
15
|
+
*/
|
|
16
|
+
error?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
declare function findAcceptAction(params: {
|
|
22
|
+
project: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
sameAs: {
|
|
26
|
+
/**
|
|
27
|
+
* task ID
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
purpose: {
|
|
32
|
+
/**
|
|
33
|
+
* transaction ID
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
}): (repos: {
|
|
38
|
+
action: ActionRepo;
|
|
39
|
+
task: TaskRepo;
|
|
40
|
+
}) => Promise<IFindAcceptActionResult>;
|
|
41
|
+
export { findAcceptAction };
|
|
@@ -0,0 +1,66 @@
|
|
|
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.findAcceptAction = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
function findAcceptAction(params) {
|
|
15
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
// タスク検索
|
|
18
|
+
const task = (yield repos.task.search({
|
|
19
|
+
limit: 1,
|
|
20
|
+
page: 1,
|
|
21
|
+
id: { $eq: params.sameAs.id },
|
|
22
|
+
project: { id: { $eq: params.project.id } },
|
|
23
|
+
name: factory.taskName.AcceptCOAOffer
|
|
24
|
+
}, {
|
|
25
|
+
status: 1,
|
|
26
|
+
executionResults: 1
|
|
27
|
+
})).shift();
|
|
28
|
+
if (task === undefined) {
|
|
29
|
+
throw new factory.errors.NotFound(factory.taskName.AcceptCOAOffer);
|
|
30
|
+
}
|
|
31
|
+
const errorByTask = (_a = task.executionResults.shift()) === null || _a === void 0 ? void 0 : _a.error;
|
|
32
|
+
let defaultActionError;
|
|
33
|
+
if (typeof errorByTask === 'string') {
|
|
34
|
+
defaultActionError = { message: errorByTask };
|
|
35
|
+
}
|
|
36
|
+
else if (typeof (errorByTask === null || errorByTask === void 0 ? void 0 : errorByTask.message) === 'string') {
|
|
37
|
+
defaultActionError = { message: errorByTask.message, name: errorByTask.name };
|
|
38
|
+
}
|
|
39
|
+
let action = Object.assign({ actionStatus: factory.actionStatusType.PotentialActionStatus }, (defaultActionError !== undefined) ? { error: defaultActionError } : undefined);
|
|
40
|
+
switch (task.status) {
|
|
41
|
+
case factory.taskStatus.Ready:
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
// タスクがReadyでなければアクション検索
|
|
45
|
+
const acceptAction = (yield repos.action.searchBySameAs({
|
|
46
|
+
sameAs: { id: { $eq: task.id } }
|
|
47
|
+
// purpose: { id: { $eq: String(params.purpose.id) } }
|
|
48
|
+
})).shift();
|
|
49
|
+
if (acceptAction !== undefined) {
|
|
50
|
+
// purpose検証
|
|
51
|
+
if (((_b = acceptAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
52
|
+
throw new factory.errors.NotFound('Action');
|
|
53
|
+
}
|
|
54
|
+
action = Object.assign({ id: acceptAction.id, actionStatus: acceptAction.actionStatus }, (acceptAction.error !== undefined)
|
|
55
|
+
? {
|
|
56
|
+
error: (Array.isArray(acceptAction.error))
|
|
57
|
+
? acceptAction.error[0]
|
|
58
|
+
: acceptAction.error
|
|
59
|
+
}
|
|
60
|
+
: undefined);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return action;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.findAcceptAction = findAcceptAction;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { acceptOffer, reAcceptOffer } from './eventServiceByCOA/acceptOffer';
|
|
1
2
|
import { authorize } from './eventServiceByCOA/authorize';
|
|
2
3
|
import { cancel } from './eventServiceByCOA/cancel';
|
|
3
4
|
import { changeOffers } from './eventServiceByCOA/changeOffers';
|
|
4
|
-
|
|
5
|
+
import { findAcceptAction } from './eventServiceByCOA/findAcceptAction';
|
|
6
|
+
export { acceptOffer, reAcceptOffer, findAcceptAction, authorize, cancel, changeOffers };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeOffers = exports.cancel = exports.authorize = void 0;
|
|
3
|
+
exports.changeOffers = exports.cancel = exports.authorize = exports.findAcceptAction = exports.reAcceptOffer = exports.acceptOffer = void 0;
|
|
4
|
+
const acceptOffer_1 = require("./eventServiceByCOA/acceptOffer");
|
|
5
|
+
Object.defineProperty(exports, "acceptOffer", { enumerable: true, get: function () { return acceptOffer_1.acceptOffer; } });
|
|
6
|
+
Object.defineProperty(exports, "reAcceptOffer", { enumerable: true, get: function () { return acceptOffer_1.reAcceptOffer; } });
|
|
4
7
|
const authorize_1 = require("./eventServiceByCOA/authorize");
|
|
5
8
|
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
|
|
6
9
|
const cancel_1 = require("./eventServiceByCOA/cancel");
|
|
7
10
|
Object.defineProperty(exports, "cancel", { enumerable: true, get: function () { return cancel_1.cancel; } });
|
|
8
11
|
const changeOffers_1 = require("./eventServiceByCOA/changeOffers");
|
|
9
12
|
Object.defineProperty(exports, "changeOffers", { enumerable: true, get: function () { return changeOffers_1.changeOffers; } });
|
|
13
|
+
const findAcceptAction_1 = require("./eventServiceByCOA/findAcceptAction");
|
|
14
|
+
Object.defineProperty(exports, "findAcceptAction", { enumerable: true, get: function () { return findAcceptAction_1.findAcceptAction; } });
|
|
@@ -6,6 +6,7 @@ import type { MongoRepository as AccountingReportRepo } from '../../repo/account
|
|
|
6
6
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
7
7
|
import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
8
8
|
import type { AuthorizationRepo } from '../../repo/code';
|
|
9
|
+
import type { ConfirmationNumberRepo } from '../../repo/confirmationNumber';
|
|
9
10
|
import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
10
11
|
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
11
12
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
@@ -59,6 +60,7 @@ interface IAuthorizeRepos {
|
|
|
59
60
|
action: ActionRepo;
|
|
60
61
|
assetTransaction: AssetTransactionRepo;
|
|
61
62
|
authorization: AuthorizationRepo;
|
|
63
|
+
confirmationNumber: ConfirmationNumberRepo;
|
|
62
64
|
event: EventRepo;
|
|
63
65
|
paymentAccepted: PaymentAcceptedRepo;
|
|
64
66
|
paymentService: PaymentServiceRepo;
|
|
@@ -229,6 +231,12 @@ declare function findCheckAction(params: {
|
|
|
229
231
|
*/
|
|
230
232
|
id: string;
|
|
231
233
|
};
|
|
234
|
+
options: {
|
|
235
|
+
/**
|
|
236
|
+
* 最小化すると、ykknInfo,mkknInfoを返さない
|
|
237
|
+
*/
|
|
238
|
+
minimize: boolean;
|
|
239
|
+
};
|
|
232
240
|
}): (repos: {
|
|
233
241
|
action: ActionRepo;
|
|
234
242
|
task: TaskRepo;
|
|
@@ -16,6 +16,7 @@ exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2u
|
|
|
16
16
|
const factory = require("../../factory");
|
|
17
17
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
18
18
|
const code_1 = require("../code");
|
|
19
|
+
const publishConfirmationNumberIfNotExist_1 = require("../transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist");
|
|
19
20
|
const factory_1 = require("./any/factory");
|
|
20
21
|
const onPaymentStatusChanged_1 = require("./any/onPaymentStatusChanged");
|
|
21
22
|
Object.defineProperty(exports, "onPaymentStatusChanged", { enumerable: true, get: function () { return onPaymentStatusChanged_1.onPaymentStatusChanged; } });
|
|
@@ -286,6 +287,17 @@ function authorize(params) {
|
|
|
286
287
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
287
288
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
288
289
|
var _a, _b, _c;
|
|
290
|
+
// MovieTicketの場合、確認番号を発行(着券に連携するため)(2024-05-27~)
|
|
291
|
+
if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
292
|
+
yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
293
|
+
id: params.purpose.id,
|
|
294
|
+
status: { $in: [factory.transactionStatusType.InProgress] },
|
|
295
|
+
object: { orderDate: new Date() }
|
|
296
|
+
})({
|
|
297
|
+
confirmationNumber: repos.confirmationNumber,
|
|
298
|
+
transaction: repos.transaction
|
|
299
|
+
});
|
|
300
|
+
}
|
|
289
301
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
290
302
|
const paymentServiceType = params.paymentServiceType;
|
|
291
303
|
// 取引番号生成
|
|
@@ -562,20 +574,35 @@ function findCheckAction(params) {
|
|
|
562
574
|
if (((_b = authorizeAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
563
575
|
throw new factory.errors.NotFound('Action');
|
|
564
576
|
}
|
|
565
|
-
const authorizeActionWithResult =
|
|
577
|
+
const authorizeActionWithResult = yield repos.action.findById({ id: authorizeAction.id, typeOf: factory.actionType.CheckAction }, [], [
|
|
578
|
+
'agent',
|
|
579
|
+
'purpose',
|
|
580
|
+
'object',
|
|
581
|
+
'startDate',
|
|
582
|
+
'endDate',
|
|
583
|
+
'actionStatus',
|
|
584
|
+
'typeOf',
|
|
585
|
+
'project',
|
|
586
|
+
'sameAs',
|
|
587
|
+
'_id',
|
|
588
|
+
...(params.options.minimize === true)
|
|
589
|
+
? [
|
|
590
|
+
'result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo',
|
|
591
|
+
'result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo'
|
|
592
|
+
]
|
|
593
|
+
: []
|
|
594
|
+
]);
|
|
595
|
+
let purchaseNumberAuthResult;
|
|
596
|
+
if ((authorizeActionWithResult === null || authorizeActionWithResult === void 0 ? void 0 : authorizeActionWithResult.result) !== undefined) {
|
|
597
|
+
purchaseNumberAuthResult = authorizeActionWithResult.result.purchaseNumberAuthResult;
|
|
598
|
+
}
|
|
566
599
|
action = Object.assign(Object.assign({ id: authorizeAction.id, actionStatus: authorizeAction.actionStatus }, (authorizeAction.error !== undefined)
|
|
567
600
|
? {
|
|
568
601
|
error: (Array.isArray(authorizeAction.error))
|
|
569
602
|
? authorizeAction.error[0]
|
|
570
603
|
: authorizeAction.error
|
|
571
604
|
}
|
|
572
|
-
: undefined), (
|
|
573
|
-
? {
|
|
574
|
-
result: {
|
|
575
|
-
purchaseNumberAuthResult: authorizeActionWithResult.result.purchaseNumberAuthResult
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
: undefined);
|
|
605
|
+
: undefined), (purchaseNumberAuthResult !== undefined) ? { result: { purchaseNumberAuthResult } } : undefined);
|
|
579
606
|
}
|
|
580
607
|
}
|
|
581
608
|
return action;
|
|
@@ -622,7 +649,7 @@ function findAcceptAction(params) {
|
|
|
622
649
|
if (((_b = acceptAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
623
650
|
throw new factory.errors.NotFound('Action');
|
|
624
651
|
}
|
|
625
|
-
const acceptActionWithResult =
|
|
652
|
+
const acceptActionWithResult = yield repos.action.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result'], []);
|
|
626
653
|
action = Object.assign(Object.assign({ id: acceptAction.id, actionStatus: acceptAction.actionStatus }, (acceptAction.error !== undefined)
|
|
627
654
|
? {
|
|
628
655
|
error: (Array.isArray(acceptAction.error))
|
|
@@ -0,0 +1,102 @@
|
|
|
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.call = void 0;
|
|
13
|
+
const COA = require("@motionpicture/coa-service");
|
|
14
|
+
const factory = require("../../factory");
|
|
15
|
+
const action_1 = require("../../repo/action");
|
|
16
|
+
const event_1 = require("../../repo/event");
|
|
17
|
+
const transaction_1 = require("../../repo/transaction");
|
|
18
|
+
const transactionProcess_1 = require("../../repo/transactionProcess");
|
|
19
|
+
const credentials_1 = require("../../credentials");
|
|
20
|
+
const acceptOffer_1 = require("../offer/eventServiceByCOA/acceptOffer");
|
|
21
|
+
let coaAuthClient;
|
|
22
|
+
/**
|
|
23
|
+
* タスク実行関数
|
|
24
|
+
*/
|
|
25
|
+
function call(params) {
|
|
26
|
+
return (settings, options) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (settings.redisClient === undefined) {
|
|
28
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
29
|
+
}
|
|
30
|
+
// 遅延実行(executeByName)には対応しない
|
|
31
|
+
if (!options.executeById) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (coaAuthClient === undefined) {
|
|
35
|
+
coaAuthClient = new COA.auth.RefreshToken({
|
|
36
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
37
|
+
refreshToken: credentials_1.credentials.coa.refreshToken,
|
|
38
|
+
useFetch: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
42
|
+
const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepository(settings.redisClient, { lockExpiresInSeconds: 120 });
|
|
43
|
+
try {
|
|
44
|
+
const reserveService = new COA.service.Reserve({
|
|
45
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
46
|
+
auth: coaAuthClient
|
|
47
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
48
|
+
const masterService = new COA.service.Master({
|
|
49
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
50
|
+
auth: coaAuthClient
|
|
51
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
52
|
+
const { object, potentialActions, purpose } = params.data;
|
|
53
|
+
if (typeof potentialActions.id === 'string') {
|
|
54
|
+
yield (0, acceptOffer_1.reAcceptOffer)({
|
|
55
|
+
object,
|
|
56
|
+
purpose,
|
|
57
|
+
potentialActions: Object.assign(Object.assign({}, potentialActions), { id: potentialActions.id }),
|
|
58
|
+
sameAs: { id: params.id }
|
|
59
|
+
})({
|
|
60
|
+
action: actionRepo,
|
|
61
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
62
|
+
transaction: new transaction_1.MongoRepository(settings.connection),
|
|
63
|
+
reserveService,
|
|
64
|
+
masterService
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
yield (0, acceptOffer_1.acceptOffer)({
|
|
69
|
+
object,
|
|
70
|
+
potentialActions,
|
|
71
|
+
purpose,
|
|
72
|
+
sameAs: { id: params.id }
|
|
73
|
+
})({
|
|
74
|
+
action: actionRepo,
|
|
75
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
76
|
+
transaction: new transaction_1.MongoRepository(settings.connection),
|
|
77
|
+
reserveService,
|
|
78
|
+
masterService
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
let throwsError = true;
|
|
84
|
+
// アクションが存在すればタスクを実行済扱いにする
|
|
85
|
+
const action = (yield actionRepo.searchBySameAs({
|
|
86
|
+
sameAs: { id: { $eq: params.id } },
|
|
87
|
+
purpose: { id: { $eq: params.data.purpose.id } }
|
|
88
|
+
})).shift();
|
|
89
|
+
if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
|
|
90
|
+
throwsError = false;
|
|
91
|
+
}
|
|
92
|
+
if (throwsError) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
// 取引プロセスロック解除
|
|
98
|
+
yield transactionProcessRepo.unlock({ typeOf: factory.transactionType.PlaceOrder, id: params.data.purpose.id });
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.call = call;
|
|
@@ -15,6 +15,7 @@ const accountingReport_1 = require("../../repo/accountingReport");
|
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
16
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
17
|
const code_1 = require("../../repo/code");
|
|
18
|
+
const confirmationNumber_1 = require("../../repo/confirmationNumber");
|
|
18
19
|
const event_1 = require("../../repo/event");
|
|
19
20
|
const paymentService_1 = require("../../repo/paymentService");
|
|
20
21
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -47,6 +48,7 @@ function call(params) {
|
|
|
47
48
|
action: actionRepo,
|
|
48
49
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
49
50
|
authorization: new code_1.AuthorizationRepo(settings.connection),
|
|
51
|
+
confirmationNumber: new confirmationNumber_1.ConfirmationNumberRepo(settings.redisClient),
|
|
50
52
|
event: new event_1.MongoRepository(settings.connection),
|
|
51
53
|
paymentAccepted: new sellerPaymentAccepted_1.MongoRepository(settings.connection),
|
|
52
54
|
paymentService: new paymentService_1.MongoRepository(settings.connection),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IOperationExecute } from '../task';
|
|
1
|
+
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(params: Pick<factory.task.ITask<factory.taskName.VoidReserveTransaction>, IExecutableTaskKeys>): IOperationExecute<void>;
|