@chevre/domain 22.8.0-alpha.7 → 22.8.0-alpha.8
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/lib/chevre/repo/action.d.ts +1 -3
- package/lib/chevre/repo/action.js +41 -27
- package/package.json +1 -1
- package/example/src/chevre/migrateCheckMovieTicketRecipes.ts +0 -127
- package/example/src/chevre/migratePayCreditCardRecipes.ts +0 -110
- package/example/src/chevre/migratePayMovieTicketRecipes.ts +0 -110
- package/example/src/chevre/saveRecipe.ts +0 -54
|
@@ -227,6 +227,7 @@ export declare class ActionRepo {
|
|
|
227
227
|
}): Promise<any>;
|
|
228
228
|
/**
|
|
229
229
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
230
|
+
* 作成日時を一定期間過ぎたアクションレシピも削除する
|
|
230
231
|
*/
|
|
231
232
|
deleteEndDatePassedCertainPeriod(params: {
|
|
232
233
|
$lt: Date;
|
|
@@ -248,9 +249,6 @@ export declare class ActionRepo {
|
|
|
248
249
|
}): Promise<{
|
|
249
250
|
deletedCount?: number;
|
|
250
251
|
} | null>;
|
|
251
|
-
saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
|
|
252
|
-
dateModified: Date;
|
|
253
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
254
252
|
saveActionWithEndDate(savingAction: Omit<factory.action.authorize.invoice.IAction, 'id'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
255
253
|
findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
|
|
256
254
|
project: {
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.ActionRepo = void 0;
|
|
24
|
+
const moment = require("moment");
|
|
24
25
|
const factory = require("../factory");
|
|
25
26
|
const settings_1 = require("../settings");
|
|
26
27
|
const action_1 = require("./mongoose/schemas/action");
|
|
@@ -1021,17 +1022,26 @@ class ActionRepo {
|
|
|
1021
1022
|
}
|
|
1022
1023
|
/**
|
|
1023
1024
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
1025
|
+
* 作成日時を一定期間過ぎたアクションレシピも削除する
|
|
1024
1026
|
*/
|
|
1025
1027
|
deleteEndDatePassedCertainPeriod(params) {
|
|
1026
1028
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
$
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1029
|
+
const { $lt } = params;
|
|
1030
|
+
if ($lt instanceof Date) {
|
|
1031
|
+
yield this.actionModel.deleteMany({
|
|
1032
|
+
// 終了日時を一定期間過ぎたもの
|
|
1033
|
+
endDate: { $exists: true, $lt }
|
|
1034
|
+
})
|
|
1035
|
+
.exec();
|
|
1036
|
+
// clean actionRecipes(2025-01-10~)
|
|
1037
|
+
const dateCreatedLt = moment($lt)
|
|
1038
|
+
.add(-1, 'day') // レシピ作成とアクション終了の時間差を考慮
|
|
1039
|
+
.toDate();
|
|
1040
|
+
yield this.actionRecipeModel.deleteMany({
|
|
1041
|
+
dateCreated: { $lt: dateCreatedLt }
|
|
1042
|
+
})
|
|
1043
|
+
.exec();
|
|
1044
|
+
}
|
|
1035
1045
|
});
|
|
1036
1046
|
}
|
|
1037
1047
|
/**
|
|
@@ -1057,25 +1067,29 @@ class ActionRepo {
|
|
|
1057
1067
|
});
|
|
1058
1068
|
});
|
|
1059
1069
|
}
|
|
1060
|
-
saveRecipeWithDateCreated(savingRecipe
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1070
|
+
// public async saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
|
|
1071
|
+
// dateModified: Date;
|
|
1072
|
+
// }) {
|
|
1073
|
+
// const { typeOf, project, recipeCategory, recipeFor, step, dateCreated, dateModified } = savingRecipe;
|
|
1074
|
+
// const filter: FilterQuery<factory.recipe.IRecipe> = {
|
|
1075
|
+
// 'recipeFor.id': { $eq: recipeFor.id }
|
|
1076
|
+
// };
|
|
1077
|
+
// const setOnInsert: AnyKeys<IRecipeAsDocument> = { project, typeOf, recipeCategory, recipeFor, dateCreated };
|
|
1078
|
+
// const setKeys: AnyKeys<IRecipeAsDocument> = { step, dateModified };
|
|
1079
|
+
// const update: UpdateQuery<IRecipeAsDocument> = {
|
|
1080
|
+
// $setOnInsert: setOnInsert,
|
|
1081
|
+
// $set: setKeys
|
|
1082
|
+
// };
|
|
1083
|
+
// return this.actionRecipeModel.updateOne<HydratedDocument<IRecipeAsDocument>>(
|
|
1084
|
+
// filter,
|
|
1085
|
+
// update,
|
|
1086
|
+
// {
|
|
1087
|
+
// upsert: true,
|
|
1088
|
+
// includeResultMetadata: true
|
|
1089
|
+
// }
|
|
1090
|
+
// )
|
|
1091
|
+
// .exec();
|
|
1092
|
+
// }
|
|
1079
1093
|
saveActionWithEndDate(savingAction) {
|
|
1080
1094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1081
1095
|
const { sameAs, typeOf, project, agent, object } = savingAction, updateFields = __rest(savingAction, ["sameAs", "typeOf", "project", "agent", "object"]);
|
package/package.json
CHANGED
|
@@ -1,127 +0,0 @@
|
|
|
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(-178, 'days'),
|
|
21
|
-
$gte: moment()
|
|
22
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
-
.add(-365, '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, updateCount, saveRecipeCount);
|
|
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);
|
|
@@ -1,110 +0,0 @@
|
|
|
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
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
11
|
-
const cursor = actionRepo.getCursor(
|
|
12
|
-
{
|
|
13
|
-
typeOf: { $eq: chevre.factory.actionType.PayAction },
|
|
14
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
15
|
-
startDate: {
|
|
16
|
-
$gte: moment()
|
|
17
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
18
|
-
.add(-30, 'days')
|
|
19
|
-
},
|
|
20
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
console.log('actions found');
|
|
27
|
-
|
|
28
|
-
let i = 0;
|
|
29
|
-
const updateCount = 0;
|
|
30
|
-
let saveRecipeCount = 0;
|
|
31
|
-
await cursor.eachAsync(async (doc) => {
|
|
32
|
-
i += 1;
|
|
33
|
-
const payAction = <Pick<
|
|
34
|
-
chevre.factory.action.trade.pay.IAction,
|
|
35
|
-
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus'
|
|
36
|
-
>>doc.toObject();
|
|
37
|
-
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.payCreditCard>({
|
|
38
|
-
project: { id: payAction.project.id },
|
|
39
|
-
recipeFor: { id: payAction.id }
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (actionRecipe !== null) {
|
|
43
|
-
console.log(
|
|
44
|
-
'actionRecipe already exists. step:',
|
|
45
|
-
actionRecipe.step.length, payAction.project.id, payAction.id, payAction.startDate, i);
|
|
46
|
-
} else {
|
|
47
|
-
const alterTranResultByPayAction = (<any>payAction.result)?.creditCardSales?.[0];
|
|
48
|
-
console.log(
|
|
49
|
-
'creating recipe by alterTranResultByPayAction',
|
|
50
|
-
alterTranResultByPayAction?.tranId,
|
|
51
|
-
payAction.project.id, payAction.id, payAction.startDate, i);
|
|
52
|
-
if (alterTranResultByPayAction === undefined) {
|
|
53
|
-
throw new Error('alterTranResultByPayAction undefined');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & {
|
|
57
|
-
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
58
|
-
dateCreated: Date;
|
|
59
|
-
dateModified: Date;
|
|
60
|
-
} = {
|
|
61
|
-
project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
62
|
-
typeOf: 'Recipe',
|
|
63
|
-
recipeCategory: chevre.factory.recipe.RecipeCategory.payCreditCard,
|
|
64
|
-
recipeFor: { id: payAction.id, typeOf: payAction.typeOf },
|
|
65
|
-
step: [{
|
|
66
|
-
typeOf: 'HowToSection',
|
|
67
|
-
itemListElement: [
|
|
68
|
-
{
|
|
69
|
-
typeOf: 'HowToStep',
|
|
70
|
-
identifier: chevre.factory.recipe.StepIdentifier.searchTrade,
|
|
71
|
-
itemListElement: [{
|
|
72
|
-
typeOf: 'HowToDirection'
|
|
73
|
-
// beforeMedia: (<any>paymentMethodsByTransaction).entryTranArgs,
|
|
74
|
-
// afterMedia: (<any>paymentMethodsByTransaction).entryTranResult
|
|
75
|
-
}]
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
typeOf: 'HowToStep',
|
|
79
|
-
identifier: chevre.factory.recipe.StepIdentifier.alterTran,
|
|
80
|
-
itemListElement: [{
|
|
81
|
-
typeOf: 'HowToDirection',
|
|
82
|
-
// beforeMedia: (<any>paymentMethodsByTransaction).execTranArgs,
|
|
83
|
-
...(alterTranResultByPayAction !== undefined) ? { afterMedia: alterTranResultByPayAction } : undefined
|
|
84
|
-
}]
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}],
|
|
88
|
-
dateCreated: moment(payAction.endDate)
|
|
89
|
-
.toDate(),
|
|
90
|
-
dateModified: moment(payAction.endDate)
|
|
91
|
-
.toDate()
|
|
92
|
-
};
|
|
93
|
-
console.log(
|
|
94
|
-
'saving recipe...',
|
|
95
|
-
payAction.project.id, payAction.id, payAction.startDate, i);
|
|
96
|
-
// console.dir(recipe, { depth: null });
|
|
97
|
-
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
98
|
-
saveRecipeCount += 1;
|
|
99
|
-
console.log('recipe saved.', payAction.project.id, payAction.id, payAction.startDate, i);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
console.log(i, 'transactions checked');
|
|
104
|
-
console.log(updateCount, 'transactions updated');
|
|
105
|
-
console.log(saveRecipeCount, 'recipe saved');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
main()
|
|
109
|
-
.then()
|
|
110
|
-
.catch(console.error);
|
|
@@ -1,110 +0,0 @@
|
|
|
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
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
11
|
-
const cursor = actionRepo.getCursor(
|
|
12
|
-
{
|
|
13
|
-
// _id: { $eq: '665c886886e0ee8ff5f7b3c5' },
|
|
14
|
-
typeOf: { $eq: chevre.factory.actionType.PayAction },
|
|
15
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
16
|
-
startDate: {
|
|
17
|
-
$lte: moment()
|
|
18
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
-
.add(-29, 'days'),
|
|
20
|
-
$gte: moment()
|
|
21
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
-
.add(-180, 'days')
|
|
23
|
-
},
|
|
24
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
console.log('actions found');
|
|
31
|
-
|
|
32
|
-
let i = 0;
|
|
33
|
-
const updateCount = 0;
|
|
34
|
-
let saveRecipeCount = 0;
|
|
35
|
-
await cursor.eachAsync(async (doc) => {
|
|
36
|
-
i += 1;
|
|
37
|
-
const payAction = <Pick<
|
|
38
|
-
chevre.factory.action.trade.pay.IAction,
|
|
39
|
-
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument'
|
|
40
|
-
>>doc.toObject();
|
|
41
|
-
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.payMovieTicket>({
|
|
42
|
-
project: { id: payAction.project.id },
|
|
43
|
-
recipeFor: { id: payAction.id }
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (actionRecipe !== null) {
|
|
47
|
-
console.log(
|
|
48
|
-
'actionRecipe already exists. step:',
|
|
49
|
-
actionRecipe.step.length, payAction.project.id, payAction.id, payAction.startDate, i);
|
|
50
|
-
} else {
|
|
51
|
-
const seatInfoSyncInByPayAction = (<any>payAction.instrument)?.seatInfoSyncIn;
|
|
52
|
-
const seatInfoSyncResultByPayAction = (<any>payAction.result)?.seatInfoSyncResult;
|
|
53
|
-
console.log(
|
|
54
|
-
'creating recipe by alterTranResultByPayAction',
|
|
55
|
-
seatInfoSyncInByPayAction?.stCd,
|
|
56
|
-
seatInfoSyncResultByPayAction?.resultInfo.status,
|
|
57
|
-
payAction.project.id, payAction.id, payAction.startDate, i);
|
|
58
|
-
if (seatInfoSyncInByPayAction === undefined) {
|
|
59
|
-
throw new Error('seatInfoSyncInByPayAction undefined');
|
|
60
|
-
}
|
|
61
|
-
if (seatInfoSyncResultByPayAction === undefined) {
|
|
62
|
-
throw new Error('seatInfoSyncResultByPayAction undefined');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const recipe: chevre.factory.action.trade.pay.IPayMovieTicketRecipe & {
|
|
66
|
-
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
67
|
-
dateCreated: Date;
|
|
68
|
-
dateModified: Date;
|
|
69
|
-
} = {
|
|
70
|
-
project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
71
|
-
typeOf: 'Recipe',
|
|
72
|
-
recipeCategory: chevre.factory.recipe.RecipeCategory.payMovieTicket,
|
|
73
|
-
recipeFor: { id: payAction.id, typeOf: payAction.typeOf },
|
|
74
|
-
step: [{
|
|
75
|
-
typeOf: 'HowToSection',
|
|
76
|
-
itemListElement: [
|
|
77
|
-
{
|
|
78
|
-
typeOf: 'HowToStep',
|
|
79
|
-
identifier: chevre.factory.recipe.StepIdentifier.seatInfoSync,
|
|
80
|
-
itemListElement: [{
|
|
81
|
-
typeOf: 'HowToDirection',
|
|
82
|
-
beforeMedia: seatInfoSyncInByPayAction,
|
|
83
|
-
afterMedia: seatInfoSyncResultByPayAction
|
|
84
|
-
}]
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}],
|
|
88
|
-
dateCreated: moment(payAction.endDate)
|
|
89
|
-
.toDate(),
|
|
90
|
-
dateModified: moment(payAction.endDate)
|
|
91
|
-
.toDate()
|
|
92
|
-
};
|
|
93
|
-
console.log(
|
|
94
|
-
'saving recipe...',
|
|
95
|
-
payAction.project.id, payAction.id, payAction.startDate, i);
|
|
96
|
-
// console.dir(recipe, { depth: null });
|
|
97
|
-
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
98
|
-
saveRecipeCount += 1;
|
|
99
|
-
console.log('recipe saved.', payAction.project.id, payAction.id, payAction.startDate, i);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
console.log(i, 'transactions checked');
|
|
104
|
-
console.log(updateCount, 'transactions updated');
|
|
105
|
-
console.log(saveRecipeCount, 'recipe saved');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
main()
|
|
109
|
-
.then()
|
|
110
|
-
.catch(console.error);
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const now = new Date();
|
|
13
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
-
const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & {
|
|
15
|
-
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
16
|
-
dateCreated: Date;
|
|
17
|
-
dateModified: Date;
|
|
18
|
-
} = {
|
|
19
|
-
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
20
|
-
typeOf: 'Recipe',
|
|
21
|
-
recipeCategory: chevre.factory.recipe.RecipeCategory.payCreditCard,
|
|
22
|
-
recipeFor: { id: 'xxxx', typeOf: chevre.factory.actionType.PayAction },
|
|
23
|
-
step: [{
|
|
24
|
-
typeOf: 'HowToSection',
|
|
25
|
-
itemListElement: [
|
|
26
|
-
{
|
|
27
|
-
typeOf: 'HowToStep',
|
|
28
|
-
identifier: chevre.factory.recipe.StepIdentifier.searchTrade,
|
|
29
|
-
itemListElement: [{
|
|
30
|
-
typeOf: 'HowToDirection'
|
|
31
|
-
// beforeMedia: (<any>paymentMethodsByTransaction).entryTranArgs,
|
|
32
|
-
// afterMedia: (<any>paymentMethodsByTransaction).entryTranResult
|
|
33
|
-
}]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
typeOf: 'HowToStep',
|
|
37
|
-
identifier: chevre.factory.recipe.StepIdentifier.alterTran,
|
|
38
|
-
itemListElement: [{
|
|
39
|
-
typeOf: 'HowToDirection'
|
|
40
|
-
// beforeMedia: (<any>paymentMethodsByTransaction).execTranArgs,
|
|
41
|
-
}]
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}],
|
|
45
|
-
dateCreated: now,
|
|
46
|
-
dateModified: now
|
|
47
|
-
};
|
|
48
|
-
const result = await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
49
|
-
console.log(result);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
main()
|
|
53
|
-
.then()
|
|
54
|
-
.catch(console.error);
|