@chevre/domain 21.34.0-alpha.7 → 21.34.0-alpha.9
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/migrateCheckMovieTicketRecipes.ts +127 -0
- package/lib/chevre/service/assetTransaction/cancelReservationCOA/factory.d.ts +14 -0
- package/lib/chevre/service/assetTransaction/cancelReservationCOA/factory.js +31 -0
- package/lib/chevre/service/assetTransaction/cancelReservationCOA.d.ts +10 -0
- package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +54 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +4 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +47 -37
- package/lib/chevre/service/offer/event/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +24 -38
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +6 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +2 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +30 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +96 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +3 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +1 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +2 -5
- package/lib/chevre/service/offer/eventServiceByCOA.js +3 -10
- package/lib/chevre/service/task/confirmReserveTransaction.js +15 -13
- package/lib/chevre/service/task/returnReserveTransaction.js +22 -40
- package/package.json +2 -2
- package/example/src/chevre/transaction/acceptCOAOffer.ts +0 -78
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +0 -42
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +0 -65
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const cursor = actionRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// _id: { $eq: '665c886886e0ee8ff5f7b3c5' },
|
|
15
|
+
typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
16
|
+
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
17
|
+
startDate: {
|
|
18
|
+
// $lte: moment()
|
|
19
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
20
|
+
// .add(-29, 'days'),
|
|
21
|
+
$gte: moment()
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
.add(-180, 'days')
|
|
24
|
+
},
|
|
25
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('actions found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
let updateCount = 0;
|
|
35
|
+
let saveRecipeCount = 0;
|
|
36
|
+
await cursor.eachAsync(async (doc) => {
|
|
37
|
+
i += 1;
|
|
38
|
+
const checkAction = <Pick<
|
|
39
|
+
chevre.factory.action.check.paymentMethod.movieTicket.IAction,
|
|
40
|
+
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument'
|
|
41
|
+
>>doc.toObject();
|
|
42
|
+
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
|
|
43
|
+
project: { id: checkAction.project.id },
|
|
44
|
+
recipeFor: { id: checkAction.id }
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const purchaseNumberAuthInByCheckAction = (<any>checkAction.result)?.purchaseNumberAuthIn;
|
|
48
|
+
const purchaseNumberAuthResultByCheckAction = (<any>checkAction.result)?.purchaseNumberAuthResult;
|
|
49
|
+
|
|
50
|
+
if (actionRecipe !== null) {
|
|
51
|
+
console.log(
|
|
52
|
+
'actionRecipe already exists. step:',
|
|
53
|
+
actionRecipe.step.length, checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
54
|
+
|
|
55
|
+
// optimize action.result
|
|
56
|
+
if (purchaseNumberAuthInByCheckAction !== undefined || purchaseNumberAuthResultByCheckAction !== undefined) {
|
|
57
|
+
const unsetResult = await actionRepo.unsetUnnecessaryFields({
|
|
58
|
+
filter: { _id: { $eq: checkAction.id } },
|
|
59
|
+
$unset: {
|
|
60
|
+
'result.purchaseNumberAuthIn': 1,
|
|
61
|
+
'result.purchaseNumberAuthResult': 1
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
updateCount += 1;
|
|
65
|
+
console.log(
|
|
66
|
+
'result unset. unsetResult:', unsetResult,
|
|
67
|
+
actionRecipe.step.length, checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
console.log(
|
|
71
|
+
'creating recipe by alterTranResultByPayAction',
|
|
72
|
+
purchaseNumberAuthInByCheckAction?.stCd,
|
|
73
|
+
purchaseNumberAuthResultByCheckAction?.resultInfo.status,
|
|
74
|
+
checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
75
|
+
if (purchaseNumberAuthInByCheckAction === undefined) {
|
|
76
|
+
throw new Error('purchaseNumberAuthInByCheckAction undefined');
|
|
77
|
+
}
|
|
78
|
+
if (purchaseNumberAuthResultByCheckAction === undefined) {
|
|
79
|
+
throw new Error('purchaseNumberAuthResultByCheckAction undefined');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const recipe: chevre.factory.action.check.paymentMethod.movieTicket.IRecipe & {
|
|
83
|
+
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
84
|
+
dateCreated: Date;
|
|
85
|
+
dateModified: Date;
|
|
86
|
+
} = {
|
|
87
|
+
project: { id: checkAction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
88
|
+
typeOf: 'Recipe',
|
|
89
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.checkMovieTicket,
|
|
90
|
+
recipeFor: { id: checkAction.id, typeOf: checkAction.typeOf },
|
|
91
|
+
step: [{
|
|
92
|
+
typeOf: 'HowToSection',
|
|
93
|
+
itemListElement: [
|
|
94
|
+
{
|
|
95
|
+
typeOf: 'HowToStep',
|
|
96
|
+
identifier: chevre.factory.recipe.StepIdentifier.purchaseNumberAuth,
|
|
97
|
+
itemListElement: [{
|
|
98
|
+
typeOf: 'HowToDirection',
|
|
99
|
+
beforeMedia: purchaseNumberAuthInByCheckAction,
|
|
100
|
+
afterMedia: purchaseNumberAuthResultByCheckAction
|
|
101
|
+
}]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}],
|
|
105
|
+
dateCreated: moment(checkAction.endDate)
|
|
106
|
+
.toDate(),
|
|
107
|
+
dateModified: moment(checkAction.endDate)
|
|
108
|
+
.toDate()
|
|
109
|
+
};
|
|
110
|
+
console.log(
|
|
111
|
+
'saving recipe...',
|
|
112
|
+
checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
113
|
+
// console.dir(recipe, { depth: null });
|
|
114
|
+
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
115
|
+
saveRecipeCount += 1;
|
|
116
|
+
console.log('recipe saved.', checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
console.log(i, 'actions checked');
|
|
121
|
+
console.log(updateCount, 'actions updated');
|
|
122
|
+
console.log(saveRecipeCount, 'recipe saved');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main()
|
|
126
|
+
.then()
|
|
127
|
+
.catch(console.error);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as COA from '@motionpicture/coa-service';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
interface IProcessReturnCOAReserveResult {
|
|
4
|
+
stateReserveArgs?: COA.factory.reserve.IStateReserveArgs;
|
|
5
|
+
stateReserveResult?: COA.factory.reserve.IStateReserveResult | null;
|
|
6
|
+
delReserveArgs?: COA.factory.reserve.IDelReserveArgs;
|
|
7
|
+
}
|
|
8
|
+
declare function processReturnCOAReserveResult2recipe(params: {
|
|
9
|
+
processReturnCOAReserveResult: IProcessReturnCOAReserveResult;
|
|
10
|
+
project: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
}): factory.action.transfer.returnAction.reserveTransaction.IReturnCOAReserveRecipe;
|
|
14
|
+
export { IProcessReturnCOAReserveResult, processReturnCOAReserveResult2recipe };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processReturnCOAReserveResult2recipe = void 0;
|
|
4
|
+
const factory = require("../../../factory");
|
|
5
|
+
function processReturnCOAReserveResult2recipe(params) {
|
|
6
|
+
const { processReturnCOAReserveResult, project } = params;
|
|
7
|
+
const { stateReserveArgs, stateReserveResult, delReserveArgs } = processReturnCOAReserveResult;
|
|
8
|
+
return {
|
|
9
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
10
|
+
typeOf: 'Recipe',
|
|
11
|
+
recipeCategory: factory.recipe.RecipeCategory.returnCOAReserve,
|
|
12
|
+
step: [{
|
|
13
|
+
typeOf: 'HowToSection',
|
|
14
|
+
itemListElement: [
|
|
15
|
+
{
|
|
16
|
+
typeOf: 'HowToStep',
|
|
17
|
+
identifier: factory.recipe.StepIdentifier.stateReserve,
|
|
18
|
+
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (stateReserveArgs !== undefined) ? { beforeMedia: stateReserveArgs } : undefined), (stateReserveResult !== undefined && stateReserveResult !== null)
|
|
19
|
+
? { afterMedia: stateReserveResult }
|
|
20
|
+
: undefined)]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
typeOf: 'HowToStep',
|
|
24
|
+
identifier: factory.recipe.StepIdentifier.delReserve,
|
|
25
|
+
itemListElement: [Object.assign({ typeOf: 'HowToDirection' }, (delReserveArgs !== undefined) ? { beforeMedia: delReserveArgs } : undefined)]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.processReturnCOAReserveResult2recipe = processReturnCOAReserveResult2recipe;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COA予約取消取引サービス
|
|
3
|
+
*/
|
|
4
|
+
import * as COA from '@motionpicture/coa-service';
|
|
5
|
+
import { IProcessReturnCOAReserveResult } from './cancelReservationCOA/factory';
|
|
6
|
+
type IConfirmOperation<T> = () => Promise<T>;
|
|
7
|
+
declare function confirm(params: {
|
|
8
|
+
object: COA.factory.reserve.IStateReserveArgs;
|
|
9
|
+
}): IConfirmOperation<IProcessReturnCOAReserveResult>;
|
|
10
|
+
export { confirm };
|
|
@@ -0,0 +1,54 @@
|
|
|
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.confirm = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* COA予約取消取引サービス
|
|
15
|
+
*/
|
|
16
|
+
const COA = require("@motionpicture/coa-service");
|
|
17
|
+
const credentials_1 = require("../../credentials");
|
|
18
|
+
const coaAuthClient = new COA.auth.RefreshToken({
|
|
19
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
20
|
+
refreshToken: credentials_1.credentials.coa.refreshToken,
|
|
21
|
+
useFetch: credentials_1.credentials.coa.useFetch
|
|
22
|
+
});
|
|
23
|
+
function confirm(params) {
|
|
24
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
let stateReserveArgs;
|
|
26
|
+
let stateReserveResult;
|
|
27
|
+
let delReserveArgs;
|
|
28
|
+
const reserveService = new COA.service.Reserve({
|
|
29
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
30
|
+
auth: coaAuthClient
|
|
31
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
32
|
+
stateReserveArgs = params.object;
|
|
33
|
+
stateReserveResult = yield reserveService.stateReserve(stateReserveArgs);
|
|
34
|
+
if (stateReserveResult !== null) {
|
|
35
|
+
delReserveArgs = {
|
|
36
|
+
theaterCode: stateReserveArgs.theaterCode,
|
|
37
|
+
reserveNum: stateReserveArgs.reserveNum,
|
|
38
|
+
telNum: stateReserveArgs.telNum,
|
|
39
|
+
dateJouei: stateReserveResult.dateJouei,
|
|
40
|
+
titleCode: stateReserveResult.titleCode,
|
|
41
|
+
titleBranchNum: stateReserveResult.titleBranchNum,
|
|
42
|
+
timeBegin: stateReserveResult.timeBegin,
|
|
43
|
+
listSeat: stateReserveResult.listTicket
|
|
44
|
+
};
|
|
45
|
+
yield reserveService.delReserve(delReserveArgs);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
stateReserveArgs,
|
|
49
|
+
stateReserveResult,
|
|
50
|
+
delReserveArgs
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.confirm = confirm;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MongoRepository as ActionRepo } from '../../../../repo/action';
|
|
1
2
|
import * as factory from '../../../../factory';
|
|
2
3
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
3
4
|
declare function processVoidTransaction4coa(params: {
|
|
@@ -5,5 +6,7 @@ declare function processVoidTransaction4coa(params: {
|
|
|
5
6
|
}): Promise<void>;
|
|
6
7
|
declare function processVoidTransactionByAcceptAction4coa(params: {
|
|
7
8
|
action: factory.action.accept.coaOffer.IAction;
|
|
8
|
-
}):
|
|
9
|
+
}): (repos: {
|
|
10
|
+
action: ActionRepo;
|
|
11
|
+
}) => Promise<void>;
|
|
9
12
|
export { processVoidTransaction4coa, processVoidTransactionByAcceptAction4coa };
|
|
@@ -82,46 +82,56 @@ function processVoidTransaction4coa(params) {
|
|
|
82
82
|
}
|
|
83
83
|
exports.processVoidTransaction4coa = processVoidTransaction4coa;
|
|
84
84
|
function processVoidTransactionByAcceptAction4coa(params) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
delTmpReserveParams
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
yield reserveService.delTmpReserve(delTmpReserveParams);
|
|
85
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f;
|
|
87
|
+
const recipe = yield repos.action.findRecipeByAction({
|
|
88
|
+
project: { id: params.action.project.id },
|
|
89
|
+
recipeFor: { id: params.action.id }
|
|
90
|
+
});
|
|
91
|
+
if (recipe !== null) {
|
|
92
|
+
let delTmpReserveParams;
|
|
93
|
+
// instrument,resultに連携内容情報が保管されているので、その情報を元に仮予約を取り消す
|
|
94
|
+
// const coaRequestBody = params.action.instrument?.requestBody;
|
|
95
|
+
// const coaResponseBody = params.action.result?.result?.responseBody;
|
|
96
|
+
// recipeから連携情報取得に変更(2024-06-11~)
|
|
97
|
+
const coaRequestBody = (_c = (_b = (_a = recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
|
|
98
|
+
const coaResponseBody = (_f = (_e = (_d = recipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
99
|
+
if (coaRequestBody !== undefined && coaResponseBody !== undefined) {
|
|
100
|
+
delTmpReserveParams = {
|
|
101
|
+
theaterCode: coaRequestBody.theaterCode,
|
|
102
|
+
dateJouei: coaRequestBody.dateJouei,
|
|
103
|
+
titleCode: coaRequestBody.titleCode,
|
|
104
|
+
titleBranchNum: coaRequestBody.titleBranchNum,
|
|
105
|
+
timeBegin: coaRequestBody.timeBegin,
|
|
106
|
+
tmpReserveNum: coaResponseBody.tmpReserveNum
|
|
107
|
+
};
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
if (delTmpReserveParams !== undefined) {
|
|
110
|
+
// COAで仮予約取消
|
|
111
|
+
try {
|
|
112
|
+
const reserveService = new COA.service.Reserve({
|
|
113
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
114
|
+
auth: coaAuthClient
|
|
115
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
116
|
+
yield reserveService.delTmpReserve(delTmpReserveParams);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
let deleted = false;
|
|
120
|
+
// COAサービスエラーの場合ハンドリング
|
|
121
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
122
|
+
/* istanbul ignore if */
|
|
123
|
+
if (error.name === 'COAServiceError') {
|
|
124
|
+
if (typeof error.code === 'number'
|
|
125
|
+
&& error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
126
|
+
// すでに取消済の場合こうなるので、okとする
|
|
127
|
+
if (error.message === '座席取消失敗') {
|
|
128
|
+
deleted = true;
|
|
129
|
+
}
|
|
120
130
|
}
|
|
121
131
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
if (!deleted) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
}
|
|
@@ -151,7 +151,7 @@ function cancelAcceptActions(params) {
|
|
|
151
151
|
}
|
|
152
152
|
yield Promise.all(acceptActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
153
153
|
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id, cancelAction });
|
|
154
|
-
yield (0, processVoidTransaction4coa_1.processVoidTransactionByAcceptAction4coa)({ action });
|
|
154
|
+
yield (0, processVoidTransaction4coa_1.processVoidTransactionByAcceptAction4coa)({ action })(repos);
|
|
155
155
|
})));
|
|
156
156
|
});
|
|
157
157
|
}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.reAcceptOffer = exports.acceptOffer = void 0;
|
|
13
13
|
const errorHandler_1 = require("../../../errorHandler");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
|
-
const settings_1 = require("../../../settings");
|
|
16
15
|
const authorize_1 = require("./acceptOffer/authorize");
|
|
17
16
|
const factory_1 = require("./acceptOffer/factory");
|
|
18
17
|
function findCOAInfo(params) {
|
|
@@ -47,12 +46,14 @@ function acceptOffer(params) {
|
|
|
47
46
|
typeOf: factory.transactionType.PlaceOrder,
|
|
48
47
|
id: params.purpose.id
|
|
49
48
|
}, ['project', 'agent', 'typeOf']);
|
|
50
|
-
const coaInfo = yield findCOAInfo({
|
|
51
|
-
|
|
49
|
+
const coaInfo = yield findCOAInfo({ id: params.object.event.id, project: { id: transaction.project.id } })(repos);
|
|
50
|
+
const updTmpReserveSeatArgs = (0, factory_1.createUpdTmpReserveSeatArgs)({ object: params.object, coaInfo });
|
|
51
|
+
let updTmpReserveSeatResult;
|
|
52
|
+
let recipe = (0, factory_1.processUpdTmpReserveSeatResult2recipe)({
|
|
53
|
+
processUpdTmpReserveSeatResult: { updTmpReserveSeatArgs },
|
|
52
54
|
project: { id: transaction.project.id }
|
|
53
|
-
})
|
|
54
|
-
let
|
|
55
|
-
requestBody = (0, factory_1.createUpdTmpReserveSeatArgs)({ object: params.object, coaInfo });
|
|
55
|
+
});
|
|
56
|
+
let acceptedOffer;
|
|
56
57
|
const actionAttributes = {
|
|
57
58
|
project: transaction.project,
|
|
58
59
|
typeOf: factory.actionType.AcceptAction,
|
|
@@ -61,11 +62,12 @@ function acceptOffer(params) {
|
|
|
61
62
|
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
62
63
|
sameAs: { id: params.sameAs.id, typeOf: 'Task' },
|
|
63
64
|
potentialActions: params.potentialActions,
|
|
64
|
-
instrument: {
|
|
65
|
+
instrument: {
|
|
66
|
+
typeOf: 'COAReserveTransaction'
|
|
67
|
+
// requestBody: updTmpReserveSeatArgs // discontinue(2024-06-11~)
|
|
68
|
+
}
|
|
65
69
|
};
|
|
66
|
-
|
|
67
|
-
let responseBody;
|
|
68
|
-
const action = yield repos.action.start(actionAttributes);
|
|
70
|
+
const action = yield repos.action.start(actionAttributes, { recipe }); // add recipe(2024-06-11~)
|
|
69
71
|
try {
|
|
70
72
|
const acceptedOffersWithoutDetails = yield (0, authorize_1.createAcceptedOffersWithoutDetails)({
|
|
71
73
|
object: params.object,
|
|
@@ -74,14 +76,16 @@ function acceptOffer(params) {
|
|
|
74
76
|
acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
|
|
75
77
|
identifier: params.object.appliesToSurfrock.identifier,
|
|
76
78
|
serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
|
|
77
|
-
},
|
|
78
|
-
// (params.agent.typeOf === factory.personType.Person),
|
|
79
|
-
params.object.flgMember)({
|
|
79
|
+
}, params.object.flgMember)({
|
|
80
80
|
reserveService: repos.reserveService,
|
|
81
81
|
masterService: repos.masterService
|
|
82
82
|
});
|
|
83
83
|
try {
|
|
84
|
-
|
|
84
|
+
updTmpReserveSeatResult = yield repos.reserveService.updTmpReserveSeat(updTmpReserveSeatArgs);
|
|
85
|
+
recipe = (0, factory_1.processUpdTmpReserveSeatResult2recipe)({
|
|
86
|
+
processUpdTmpReserveSeatResult: { updTmpReserveSeatArgs, updTmpReserveSeatResult },
|
|
87
|
+
project: { id: transaction.project.id }
|
|
88
|
+
});
|
|
85
89
|
}
|
|
86
90
|
catch (error) {
|
|
87
91
|
throw (0, errorHandler_1.handleCOAReserveTemporarilyError)(error);
|
|
@@ -96,22 +100,12 @@ function acceptOffer(params) {
|
|
|
96
100
|
}
|
|
97
101
|
throw error;
|
|
98
102
|
}
|
|
99
|
-
const recipe = (0, factory_1.processUpdTmpReserveSeatResult2recipe)({
|
|
100
|
-
processUpdTmpReserveSeatResult: {
|
|
101
|
-
updTmpReserveSeatArgs: requestBody,
|
|
102
|
-
updTmpReserveSeatResult: responseBody
|
|
103
|
-
},
|
|
104
|
-
project: { id: transaction.project.id }
|
|
105
|
-
});
|
|
106
103
|
const result = {
|
|
107
|
-
object: {
|
|
108
|
-
|
|
109
|
-
event: { id: params.object.event.id }
|
|
110
|
-
},
|
|
111
|
-
result: { responseBody },
|
|
104
|
+
object: { acceptedOffer, event: { id: params.object.event.id } },
|
|
105
|
+
result: { responseBody: updTmpReserveSeatResult },
|
|
112
106
|
typeOf: factory.actionType.AuthorizeAction
|
|
113
107
|
};
|
|
114
|
-
yield repos.action.completeWithVoid(
|
|
108
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result, recipe }); // add recipe(2024-06-11~)
|
|
115
109
|
});
|
|
116
110
|
}
|
|
117
111
|
exports.acceptOffer = acceptOffer;
|
|
@@ -131,10 +125,7 @@ function reAcceptOffer(params) {
|
|
|
131
125
|
typeOf: factory.transactionType.PlaceOrder,
|
|
132
126
|
id: params.purpose.id
|
|
133
127
|
}, ['project', 'agent', 'typeOf']);
|
|
134
|
-
const coaInfo = yield findCOAInfo({
|
|
135
|
-
id: params.object.event.id,
|
|
136
|
-
project: { id: transaction.project.id }
|
|
137
|
-
})(repos);
|
|
128
|
+
const coaInfo = yield findCOAInfo({ id: params.object.event.id, project: { id: transaction.project.id } })(repos);
|
|
138
129
|
// 承認アクション存在検証
|
|
139
130
|
yield repos.action.findById({ id: params.potentialActions.id, typeOf: factory.actionType.AuthorizeAction }, ['_id'], []);
|
|
140
131
|
const actionAttributes = {
|
|
@@ -145,10 +136,7 @@ function reAcceptOffer(params) {
|
|
|
145
136
|
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
146
137
|
sameAs: { id: params.sameAs.id, typeOf: 'Task' },
|
|
147
138
|
potentialActions: params.potentialActions,
|
|
148
|
-
instrument: {
|
|
149
|
-
typeOf: 'COAReserveTransaction'
|
|
150
|
-
// requestBody: {}
|
|
151
|
-
}
|
|
139
|
+
instrument: { typeOf: 'COAReserveTransaction' }
|
|
152
140
|
};
|
|
153
141
|
let acceptedOffer;
|
|
154
142
|
const action = yield repos.action.start(actionAttributes);
|
|
@@ -160,9 +148,7 @@ function reAcceptOffer(params) {
|
|
|
160
148
|
acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
|
|
161
149
|
identifier: params.object.appliesToSurfrock.identifier,
|
|
162
150
|
serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
|
|
163
|
-
},
|
|
164
|
-
// (params.agent.typeOf === factory.personType.Person),
|
|
165
|
-
params.object.flgMember)({
|
|
151
|
+
}, params.object.flgMember)({
|
|
166
152
|
reserveService: repos.reserveService,
|
|
167
153
|
masterService: repos.masterService
|
|
168
154
|
});
|
|
@@ -27,6 +27,12 @@ export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function authorize(params: {
|
|
29
29
|
object: {
|
|
30
|
+
acceptAction: {
|
|
31
|
+
/**
|
|
32
|
+
* COA興行オファー採用アクションID(2024-06-11~)
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
30
36
|
acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
|
|
31
37
|
event: {
|
|
32
38
|
id: string;
|
|
@@ -80,6 +80,7 @@ function authorize(params) {
|
|
|
80
80
|
catch (error) {
|
|
81
81
|
// アクション開始前に例外がthrowされてもCOA仮予約を取り消す機会をつくるためにFailedアクションを作成する(2023-09-12~)
|
|
82
82
|
const failedActionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
|
|
83
|
+
acceptAction: params.object.acceptAction,
|
|
83
84
|
acceptedOffers: [],
|
|
84
85
|
event: { id: params.object.event.id, typeOf: factory.eventType.ScreeningEvent },
|
|
85
86
|
transaction,
|
|
@@ -92,6 +93,7 @@ function authorize(params) {
|
|
|
92
93
|
let result;
|
|
93
94
|
// 承認アクションを開始
|
|
94
95
|
const actionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
|
|
96
|
+
acceptAction: params.object.acceptAction,
|
|
95
97
|
acceptedOffers,
|
|
96
98
|
event: screeningEvent,
|
|
97
99
|
transaction,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IAuthorizeOperation } from './authorize';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier.COA>;
|
|
4
|
+
/**
|
|
5
|
+
* 採用アクションからCOA興行オファー承認
|
|
6
|
+
*/
|
|
7
|
+
export declare function authorizeByAcceptAction(params: {
|
|
8
|
+
project: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
object: {
|
|
12
|
+
/**
|
|
13
|
+
* COA興行オファー採用アクションID(2024-06-11~)
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
agent: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
purpose: {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
store: {
|
|
24
|
+
/**
|
|
25
|
+
* 販売アプリケーションID
|
|
26
|
+
*/
|
|
27
|
+
id: string;
|
|
28
|
+
};
|
|
29
|
+
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
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.authorizeByAcceptAction = void 0;
|
|
13
|
+
const authorize_1 = require("./authorize");
|
|
14
|
+
const changeOffers_1 = require("./changeOffers");
|
|
15
|
+
const factory = require("../../../factory");
|
|
16
|
+
/**
|
|
17
|
+
* 採用アクションからCOA興行オファー承認
|
|
18
|
+
*/
|
|
19
|
+
function authorizeByAcceptAction(params) {
|
|
20
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
const acceptAction = (yield repos.action.search({
|
|
23
|
+
limit: 1,
|
|
24
|
+
page: 1,
|
|
25
|
+
project: { id: { $eq: params.project.id } },
|
|
26
|
+
id: { $in: [params.object.id] },
|
|
27
|
+
typeOf: { $eq: factory.actionType.AcceptAction },
|
|
28
|
+
purpose: { id: { $in: [params.purpose.id] } },
|
|
29
|
+
actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }
|
|
30
|
+
}, ['result', 'object', 'potentialActions'], [])).shift();
|
|
31
|
+
if (acceptAction === undefined) {
|
|
32
|
+
throw new factory.errors.NotFound(factory.actionType.AcceptAction);
|
|
33
|
+
}
|
|
34
|
+
const acceptResult = acceptAction.result;
|
|
35
|
+
if (acceptResult === undefined) {
|
|
36
|
+
throw new factory.errors.NotFound(`${factory.actionType.AcceptAction}.result`);
|
|
37
|
+
}
|
|
38
|
+
let action;
|
|
39
|
+
if (typeof acceptAction.potentialActions.id === 'string') {
|
|
40
|
+
// オファー変更
|
|
41
|
+
const changeOfferParams = {
|
|
42
|
+
object: {
|
|
43
|
+
acceptedOffer: acceptResult.object.acceptedOffer,
|
|
44
|
+
event: { id: acceptResult.object.event.id }
|
|
45
|
+
},
|
|
46
|
+
agent: { id: params.agent.id },
|
|
47
|
+
transaction: { id: params.purpose.id },
|
|
48
|
+
id: acceptAction.potentialActions.id,
|
|
49
|
+
options: {
|
|
50
|
+
// useCreateOrderOnOfferAccepted: USE_CREATE_ORDER_ON_OFFER_ACCEPTED // discontinue(2024-05-28~)
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
action = yield (0, changeOffers_1.changeOffers)(changeOfferParams)(repos);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// recipe依存へ変更(2024-06-11~)
|
|
57
|
+
const recipe = yield repos.action.findRecipeByAction({
|
|
58
|
+
project: { id: params.project.id },
|
|
59
|
+
recipeFor: { id: params.object.id }
|
|
60
|
+
});
|
|
61
|
+
const requestBody = (_c = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
|
|
62
|
+
if (requestBody === undefined) {
|
|
63
|
+
throw new factory.errors.NotFound('beforeMedia by recipe');
|
|
64
|
+
}
|
|
65
|
+
const responseBody = (_f = (_e = (_d = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
66
|
+
if (responseBody === undefined) {
|
|
67
|
+
throw new factory.errors.NotFound('afterMedia by recipe');
|
|
68
|
+
}
|
|
69
|
+
// const requestBody = acceptAction.instrument.requestBody;
|
|
70
|
+
// if (requestBody === undefined) {
|
|
71
|
+
// throw new chevre.factory.errors.NotFound(`${chevre.factory.actionType.AcceptAction}.result.requestBody`);
|
|
72
|
+
// }
|
|
73
|
+
// const responseBody = acceptResult.result?.responseBody;
|
|
74
|
+
// if (responseBody === undefined) {
|
|
75
|
+
// throw new chevre.factory.errors.NotFound(`${chevre.factory.actionType.AcceptAction}.result.responseBody`);
|
|
76
|
+
// }
|
|
77
|
+
const authorizeParams = {
|
|
78
|
+
object: {
|
|
79
|
+
acceptAction: { id: params.object.id },
|
|
80
|
+
acceptedOffer: acceptResult.object.acceptedOffer,
|
|
81
|
+
event: { id: acceptResult.object.event.id }
|
|
82
|
+
},
|
|
83
|
+
agent: { id: params.agent.id },
|
|
84
|
+
transaction: { id: params.purpose.id },
|
|
85
|
+
store: { id: params.store.id },
|
|
86
|
+
result: { requestBody, responseBody },
|
|
87
|
+
options: {
|
|
88
|
+
// useCreateOrderOnOfferAccepted: USE_CREATE_ORDER_ON_OFFER_ACCEPTED // discontinue(2024-05-28~)
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
action = yield (0, authorize_1.authorize)(authorizeParams)(repos);
|
|
92
|
+
}
|
|
93
|
+
return action;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.authorizeByAcceptAction = authorizeByAcceptAction;
|
|
@@ -3,6 +3,9 @@ import { IMinimizedIndividualEvent } from '../../../factory/event';
|
|
|
3
3
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
4
4
|
export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>;
|
|
5
5
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
6
|
+
acceptAction: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
6
9
|
acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
|
|
7
10
|
event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id' | 'typeOf'>;
|
|
8
11
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
@@ -22,6 +22,7 @@ function createAuthorizeSeatReservationActionAttributes(params) {
|
|
|
22
22
|
};
|
|
23
23
|
const authorizeObject = {
|
|
24
24
|
typeOf: factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
|
|
25
|
+
id: params.acceptAction.id,
|
|
25
26
|
acceptedOffer: params.acceptedOffers,
|
|
26
27
|
event: authorizeObjectEvent,
|
|
27
28
|
pendingTransaction: params.pendingTransaction,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { authorize } from './eventServiceByCOA/authorize';
|
|
3
|
-
import { cancel } from './eventServiceByCOA/cancel';
|
|
4
|
-
import { changeOffers } from './eventServiceByCOA/changeOffers';
|
|
1
|
+
import { authorizeByAcceptAction } from './eventServiceByCOA/authorizeByAcceptAction';
|
|
5
2
|
import { findAcceptAction } from './eventServiceByCOA/findAcceptAction';
|
|
6
|
-
export {
|
|
3
|
+
export { findAcceptAction, authorizeByAcceptAction };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
Object.defineProperty(exports, "reAcceptOffer", { enumerable: true, get: function () { return acceptOffer_1.reAcceptOffer; } });
|
|
7
|
-
const authorize_1 = require("./eventServiceByCOA/authorize");
|
|
8
|
-
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
|
|
9
|
-
const cancel_1 = require("./eventServiceByCOA/cancel");
|
|
10
|
-
Object.defineProperty(exports, "cancel", { enumerable: true, get: function () { return cancel_1.cancel; } });
|
|
11
|
-
const changeOffers_1 = require("./eventServiceByCOA/changeOffers");
|
|
12
|
-
Object.defineProperty(exports, "changeOffers", { enumerable: true, get: function () { return changeOffers_1.changeOffers; } });
|
|
3
|
+
exports.authorizeByAcceptAction = exports.findAcceptAction = void 0;
|
|
4
|
+
const authorizeByAcceptAction_1 = require("./eventServiceByCOA/authorizeByAcceptAction");
|
|
5
|
+
Object.defineProperty(exports, "authorizeByAcceptAction", { enumerable: true, get: function () { return authorizeByAcceptAction_1.authorizeByAcceptAction; } });
|
|
13
6
|
const findAcceptAction_1 = require("./eventServiceByCOA/findAcceptAction");
|
|
14
7
|
Object.defineProperty(exports, "findAcceptAction", { enumerable: true, get: function () { return findAcceptAction_1.findAcceptAction; } });
|
|
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.confirmReserveTransaction = exports.call = void 0;
|
|
13
|
-
const createDebug = require("debug");
|
|
14
13
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
15
14
|
const util_1 = require("util");
|
|
16
15
|
const factory = require("../../factory");
|
|
17
|
-
const settings_1 = require("../../settings");
|
|
18
16
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
19
17
|
const action_1 = require("../../repo/action");
|
|
20
18
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
@@ -24,7 +22,6 @@ const task_1 = require("../../repo/task");
|
|
|
24
22
|
const ReserveTransactionService = require("../assetTransaction/reserve");
|
|
25
23
|
const COAReserveService = require("../assetTransaction/reserveCOA");
|
|
26
24
|
const factory_1 = require("../assetTransaction/reserveCOA/factory");
|
|
27
|
-
const debug = createDebug('chevre-domain:service:task');
|
|
28
25
|
/**
|
|
29
26
|
* タスク実行関数
|
|
30
27
|
*/
|
|
@@ -134,6 +131,8 @@ function fixOrderAsPurpose(params) {
|
|
|
134
131
|
function confirmReserveTransaction(params, options) {
|
|
135
132
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
136
133
|
let confirmActionObject;
|
|
134
|
+
// let updReserveResult: COA.factory.reserve.IUpdReserveResult | undefined;
|
|
135
|
+
let recipe;
|
|
137
136
|
switch (params.object.typeOf) {
|
|
138
137
|
case 'COAReserveTransaction':
|
|
139
138
|
// 最適化されたタスクに対応するため、ここでIObject4COAを注文から生成する(2024-01-24~)
|
|
@@ -142,20 +141,21 @@ function confirmReserveTransaction(params, options) {
|
|
|
142
141
|
purpose: params.purpose
|
|
143
142
|
})(repos);
|
|
144
143
|
const updReserveArgs = createConfirmObject4COAByOrder({ order, reservationNumber: params.object.transactionNumber });
|
|
145
|
-
debug('confirming coa reserve transaction...', order, updReserveArgs);
|
|
146
144
|
const object4coa = Object.assign(Object.assign({}, updReserveArgs), { transactionNumber: params.object.transactionNumber, typeOf: 'COAReserveTransaction' });
|
|
147
145
|
confirmActionObject = object4coa;
|
|
146
|
+
recipe = (0, factory_1.processConfirmCOAReserveResult2recipe)({
|
|
147
|
+
processConfirmCOAReserveResult: { updReserveArgs: object4coa },
|
|
148
|
+
project: { id: params.project.id }
|
|
149
|
+
});
|
|
148
150
|
break;
|
|
149
151
|
default:
|
|
150
152
|
confirmActionObject = params.object;
|
|
151
153
|
}
|
|
152
154
|
const { agent, project, purpose, typeOf, sameAs } = params;
|
|
153
|
-
const confirmActionAttributes = Object.assign({ agent, project, purpose, typeOf, object: confirmActionObject }, (typeof (sameAs === null || sameAs === void 0 ? void 0 : sameAs.id) === 'string') // link
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
let updReserveResult;
|
|
158
|
-
let recipe;
|
|
155
|
+
const confirmActionAttributes = Object.assign({ agent, project, purpose, typeOf, object: confirmActionObject }, (typeof (sameAs === null || sameAs === void 0 ? void 0 : sameAs.id) === 'string') ? { sameAs: { id: sameAs.id, typeOf: 'Task' } } : undefined // link sameAs(2024-06-10~)
|
|
156
|
+
);
|
|
157
|
+
const action = yield repos.action.start(confirmActionAttributes, Object.assign({}, (recipe !== undefined) ? { recipe } : undefined // add recipe(2024-06-11~)
|
|
158
|
+
));
|
|
159
159
|
try {
|
|
160
160
|
const object = confirmActionAttributes.object;
|
|
161
161
|
switch (object.typeOf) {
|
|
@@ -166,7 +166,7 @@ function confirmReserveTransaction(params, options) {
|
|
|
166
166
|
object: object,
|
|
167
167
|
purpose: confirmActionAttributes.purpose
|
|
168
168
|
})({});
|
|
169
|
-
updReserveResult = processConfirmCOAReserveResult.updReserveResult;
|
|
169
|
+
// updReserveResult = processConfirmCOAReserveResult.updReserveResult;
|
|
170
170
|
recipe = (0, factory_1.processConfirmCOAReserveResult2recipe)({
|
|
171
171
|
processConfirmCOAReserveResult,
|
|
172
172
|
project: { id: confirmActionAttributes.project.id }
|
|
@@ -189,8 +189,10 @@ function confirmReserveTransaction(params, options) {
|
|
|
189
189
|
}
|
|
190
190
|
throw error;
|
|
191
191
|
}
|
|
192
|
-
const result =
|
|
193
|
-
|
|
192
|
+
const result = {
|
|
193
|
+
// ...(updReserveResult !== undefined) ? { updReserveResult } : {} // discontinue(2024-06-11~)
|
|
194
|
+
};
|
|
195
|
+
yield repos.action.completeWithVoid(Object.assign({ typeOf: confirmActionAttributes.typeOf, id: action.id, result }, (recipe !== undefined) ? { recipe } : undefined // add recipe(2024-06-11~)
|
|
194
196
|
));
|
|
195
197
|
// sendOrder連携(2024-01-11~)
|
|
196
198
|
yield onConfirmed(confirmActionAttributes, options)({
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
-
const COA = require("@motionpicture/coa-service");
|
|
14
13
|
const moment = require("moment");
|
|
15
14
|
const factory = require("../../factory");
|
|
16
15
|
const action_1 = require("../../repo/action");
|
|
@@ -19,12 +18,8 @@ const project_1 = require("../../repo/project");
|
|
|
19
18
|
const reservation_1 = require("../../repo/reservation");
|
|
20
19
|
const transactionNumber_1 = require("../../repo/transactionNumber");
|
|
21
20
|
const CancelReservationTransactionService = require("../assetTransaction/cancelReservation");
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
endpoint: credentials_1.credentials.coa.endpoint,
|
|
25
|
-
refreshToken: credentials_1.credentials.coa.refreshToken,
|
|
26
|
-
useFetch: credentials_1.credentials.coa.useFetch
|
|
27
|
-
});
|
|
21
|
+
const CancelReservationCOAService = require("../assetTransaction/cancelReservationCOA");
|
|
22
|
+
const factory_1 = require("../assetTransaction/cancelReservationCOA/factory");
|
|
28
23
|
/**
|
|
29
24
|
* タスク実行関数
|
|
30
25
|
*/
|
|
@@ -33,7 +28,7 @@ function call(params) {
|
|
|
33
28
|
if (settings.redisClient === undefined) {
|
|
34
29
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
35
30
|
}
|
|
36
|
-
yield
|
|
31
|
+
yield returnReserve(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
|
|
37
32
|
action: new action_1.MongoRepository(settings.connection),
|
|
38
33
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
39
34
|
project: new project_1.MongoRepository(settings.connection),
|
|
@@ -46,20 +41,30 @@ exports.call = call;
|
|
|
46
41
|
/**
|
|
47
42
|
* 予約取引返却
|
|
48
43
|
*/
|
|
49
|
-
function
|
|
44
|
+
function returnReserve(params) {
|
|
50
45
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
51
46
|
const { agent, instrument, object, project, purpose, recipient, typeOf, sameAs } = params;
|
|
52
47
|
const returnActionAttributes = Object.assign({ agent, instrument, object, project, purpose, recipient, typeOf }, (typeof (sameAs === null || sameAs === void 0 ? void 0 : sameAs.id) === 'string') ? { sameAs: { id: sameAs.id, typeOf: 'Task' } } : undefined);
|
|
53
|
-
|
|
48
|
+
let recipe;
|
|
49
|
+
if (params.instrument.identifier === factory.service.webAPI.Identifier.COA) {
|
|
50
|
+
recipe = (0, factory_1.processReturnCOAReserveResult2recipe)({
|
|
51
|
+
processReturnCOAReserveResult: { stateReserveArgs: params.object },
|
|
52
|
+
project: { id: project.id }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const action = yield repos.action.start(returnActionAttributes, Object.assign({}, (recipe !== undefined) ? { recipe } : undefined // add recipe(2024-06-11~)
|
|
56
|
+
));
|
|
54
57
|
try {
|
|
55
58
|
switch (params.instrument.identifier) {
|
|
56
59
|
case factory.service.webAPI.Identifier.COA:
|
|
57
|
-
yield
|
|
58
|
-
|
|
60
|
+
const processReturnCOAReserveResult = yield CancelReservationCOAService.confirm({ object: params.object })();
|
|
61
|
+
recipe = (0, factory_1.processReturnCOAReserveResult2recipe)({
|
|
62
|
+
processReturnCOAReserveResult,
|
|
63
|
+
project: { id: project.id }
|
|
59
64
|
});
|
|
60
65
|
break;
|
|
61
66
|
default:
|
|
62
|
-
yield processCancelReservation4chevre(
|
|
67
|
+
yield processCancelReservation4chevre(params)(repos);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
catch (error) {
|
|
@@ -71,39 +76,16 @@ function cancelReservation(params) {
|
|
|
71
76
|
}
|
|
72
77
|
throw error;
|
|
73
78
|
}
|
|
74
|
-
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: {} })
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
function processCancelReservation4coa(params) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const cancelReservationObject = params.cancelReservationObject;
|
|
80
|
-
const reserveService = new COA.service.Reserve({
|
|
81
|
-
endpoint: credentials_1.credentials.coa.endpoint,
|
|
82
|
-
auth: coaAuthClient
|
|
83
|
-
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
84
|
-
const stateReserveResult = yield reserveService.stateReserve(cancelReservationObject);
|
|
85
|
-
if (stateReserveResult !== null) {
|
|
86
|
-
yield reserveService.delReserve({
|
|
87
|
-
theaterCode: cancelReservationObject.theaterCode,
|
|
88
|
-
reserveNum: cancelReservationObject.reserveNum,
|
|
89
|
-
telNum: cancelReservationObject.telNum,
|
|
90
|
-
dateJouei: stateReserveResult.dateJouei,
|
|
91
|
-
titleCode: stateReserveResult.titleCode,
|
|
92
|
-
titleBranchNum: stateReserveResult.titleBranchNum,
|
|
93
|
-
timeBegin: stateReserveResult.timeBegin,
|
|
94
|
-
listSeat: stateReserveResult.listTicket
|
|
95
|
-
});
|
|
96
|
-
}
|
|
79
|
+
yield repos.action.completeWithVoid(Object.assign({ typeOf: action.typeOf, id: action.id, result: {} }, (recipe !== undefined) ? { recipe } : undefined // add recipe(2024-06-11~)
|
|
80
|
+
));
|
|
97
81
|
});
|
|
98
82
|
}
|
|
99
83
|
function processCancelReservation4chevre(params) {
|
|
100
84
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const cancelReservationObject = params.object;
|
|
102
|
-
const project = params.project;
|
|
103
85
|
// まず取引番号発行
|
|
104
86
|
const { transactionNumber } = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
105
87
|
yield CancelReservationTransactionService.startAndConfirm({
|
|
106
|
-
project: { typeOf: factory.organizationType.Project, id: project.id },
|
|
88
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
107
89
|
transactionNumber,
|
|
108
90
|
typeOf: factory.assetTransactionType.CancelReservation,
|
|
109
91
|
agent: {
|
|
@@ -113,7 +95,7 @@ function processCancelReservation4chevre(params) {
|
|
|
113
95
|
},
|
|
114
96
|
object: {
|
|
115
97
|
reservation: {
|
|
116
|
-
reservationNumber:
|
|
98
|
+
reservationNumber: params.object.transactionNumber
|
|
117
99
|
}
|
|
118
100
|
},
|
|
119
101
|
expires: moment()
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.374.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.374.0-alpha.17",
|
|
14
14
|
"@cinerino/sdk": "7.1.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.34.0-alpha.
|
|
113
|
+
"version": "21.34.0-alpha.9"
|
|
114
114
|
}
|
|
@@ -1,78 +0,0 @@
|
|
|
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);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
-
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
3
|
-
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
4
|
-
import * as factory from '../../../factory';
|
|
5
|
-
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
6
|
-
interface ICancelResult {
|
|
7
|
-
theaterCode: string;
|
|
8
|
-
dateJouei: string;
|
|
9
|
-
titleCode: string;
|
|
10
|
-
titleBranchNum: string;
|
|
11
|
-
timeBegin: string;
|
|
12
|
-
tmpReserveNum: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* COA興行オファー承認取消
|
|
16
|
-
*/
|
|
17
|
-
export declare function cancel(params: {
|
|
18
|
-
project: {
|
|
19
|
-
id: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* 承認アクションID
|
|
23
|
-
*/
|
|
24
|
-
id: string;
|
|
25
|
-
/**
|
|
26
|
-
* 取引進行者
|
|
27
|
-
*/
|
|
28
|
-
agent: {
|
|
29
|
-
id: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* 取引
|
|
33
|
-
*/
|
|
34
|
-
transaction: {
|
|
35
|
-
id: string;
|
|
36
|
-
};
|
|
37
|
-
}): (repos: {
|
|
38
|
-
action: ActionRepo;
|
|
39
|
-
orderInTransaction: OrderInTransactionRepo;
|
|
40
|
-
transaction: TransactionRepo;
|
|
41
|
-
}) => Promise<ICancelResult | undefined>;
|
|
42
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
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 = exports.WebAPIIdentifier = void 0;
|
|
13
|
-
const factory = require("../../../factory");
|
|
14
|
-
const any_1 = require("../any");
|
|
15
|
-
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
16
|
-
/**
|
|
17
|
-
* COA興行オファー承認取消
|
|
18
|
-
*/
|
|
19
|
-
function cancel(params) {
|
|
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
|
-
};
|
|
25
|
-
const transaction = yield repos.transaction.findInProgressById({
|
|
26
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
27
|
-
id: params.transaction.id
|
|
28
|
-
}, ['typeOf', 'agent']);
|
|
29
|
-
if (transaction.agent.id !== params.agent.id) {
|
|
30
|
-
throw new factory.errors.Forbidden('Transaction not yours');
|
|
31
|
-
}
|
|
32
|
-
const orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.transaction.id });
|
|
33
|
-
// 取引内のアクションかどうか確認
|
|
34
|
-
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
35
|
-
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
36
|
-
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
37
|
-
}
|
|
38
|
-
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id, cancelAction });
|
|
39
|
-
// add orderInTransaction(2024-01-15~)
|
|
40
|
-
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
41
|
-
// const orderNumberByTransaction = transaction.object.orderNumber;
|
|
42
|
-
const orderNumberByTransaction = orderNumber; // transaction.objectへのアクセス回避(2024-05-30~)
|
|
43
|
-
if (typeof orderNumberByTransaction === 'string') {
|
|
44
|
-
yield (0, any_1.voidAcceptedOffer)({
|
|
45
|
-
// authorizeActions: [action],
|
|
46
|
-
authorizeActionsWithInstrument: [action],
|
|
47
|
-
orderNumber: orderNumberByTransaction
|
|
48
|
-
})(repos);
|
|
49
|
-
}
|
|
50
|
-
let cancelResult;
|
|
51
|
-
const actionResult = action.result;
|
|
52
|
-
if ((actionResult === null || actionResult === void 0 ? void 0 : actionResult.requestBody) !== undefined && actionResult.responseBody !== undefined) {
|
|
53
|
-
cancelResult = {
|
|
54
|
-
theaterCode: actionResult.requestBody.theaterCode,
|
|
55
|
-
dateJouei: actionResult.requestBody.dateJouei,
|
|
56
|
-
titleCode: actionResult.requestBody.titleCode,
|
|
57
|
-
titleBranchNum: actionResult.requestBody.titleBranchNum,
|
|
58
|
-
timeBegin: actionResult.requestBody.timeBegin,
|
|
59
|
-
tmpReserveNum: actionResult.responseBody.tmpReserveNum
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return cancelResult;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.cancel = cancel;
|