@chevre/domain 21.8.0-alpha.26 → 21.8.0-alpha.28
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/importOffersFromCOA.ts +7 -1
- package/example/src/chevre/syncAggregateOffer.ts +23 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +71 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +42 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +0 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -1
- package/lib/chevre/repo/offer.d.ts +16 -0
- package/lib/chevre/repo/offer.js +69 -1
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +1 -11
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
- package/lib/chevre/service/offer/event/importFromCOA.js +18 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +3 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
- package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
- package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
- package/package.json +2 -2
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
|
@@ -16,6 +16,7 @@ async function main() {
|
|
|
16
16
|
|
|
17
17
|
const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
18
18
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
19
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
20
|
const masterService = new chevre.COA.service.Master(
|
|
20
21
|
{
|
|
21
22
|
endpoint: chevre.credentials.coa.endpoint,
|
|
@@ -27,7 +28,12 @@ async function main() {
|
|
|
27
28
|
await chevre.service.offer.event.importFromCOA({
|
|
28
29
|
project,
|
|
29
30
|
theaterCode: '120'
|
|
30
|
-
})({
|
|
31
|
+
})({
|
|
32
|
+
categoryCode: categoryCodeRepo,
|
|
33
|
+
offer: offerRepo,
|
|
34
|
+
task: taskRepo,
|
|
35
|
+
masterService
|
|
36
|
+
});
|
|
31
37
|
console.log('imported');
|
|
32
38
|
}
|
|
33
39
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as redis from 'redis';
|
|
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 offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const result = await offerRepo.sync2aggregateOffer({
|
|
15
|
+
project: { id: project.id },
|
|
16
|
+
identifier: { $in: ['COA-120-15'] }
|
|
17
|
+
});
|
|
18
|
+
console.log(result);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then(console.log)
|
|
23
|
+
.catch(console.error);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import { Schema } from 'mongoose';
|
|
26
|
+
declare const modelName = "AggregateOffer";
|
|
27
|
+
/**
|
|
28
|
+
* 集計オファースキーマ
|
|
29
|
+
*/
|
|
30
|
+
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
|
+
collection: string;
|
|
32
|
+
id: true;
|
|
33
|
+
read: string;
|
|
34
|
+
writeConcern: import("mongodb").WriteConcern;
|
|
35
|
+
strict: true;
|
|
36
|
+
strictQuery: false;
|
|
37
|
+
timestamps: {
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
};
|
|
41
|
+
toJSON: {
|
|
42
|
+
getters: false;
|
|
43
|
+
virtuals: false;
|
|
44
|
+
minimize: false;
|
|
45
|
+
versionKey: false;
|
|
46
|
+
};
|
|
47
|
+
toObject: {
|
|
48
|
+
getters: false;
|
|
49
|
+
virtuals: true;
|
|
50
|
+
minimize: false;
|
|
51
|
+
versionKey: false;
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
offers: any[];
|
|
55
|
+
_id?: string | undefined;
|
|
56
|
+
typeOf?: string | undefined;
|
|
57
|
+
project?: any;
|
|
58
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
59
|
+
offers: any[];
|
|
60
|
+
_id?: string | undefined;
|
|
61
|
+
typeOf?: string | undefined;
|
|
62
|
+
project?: any;
|
|
63
|
+
}>> & Omit<import("mongoose").FlatRecord<{
|
|
64
|
+
offers: any[];
|
|
65
|
+
_id?: string | undefined;
|
|
66
|
+
typeOf?: string | undefined;
|
|
67
|
+
project?: any;
|
|
68
|
+
}> & Required<{
|
|
69
|
+
_id: string;
|
|
70
|
+
}>, never>>;
|
|
71
|
+
export { modelName, schema };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const modelName = 'AggregateOffer';
|
|
7
|
+
exports.modelName = modelName;
|
|
8
|
+
/**
|
|
9
|
+
* 集計オファースキーマ
|
|
10
|
+
*/
|
|
11
|
+
const schema = new mongoose_1.Schema({
|
|
12
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
_id: String,
|
|
14
|
+
typeOf: String,
|
|
15
|
+
offers: [mongoose_1.SchemaTypes.Mixed]
|
|
16
|
+
}, {
|
|
17
|
+
collection: 'aggregateOffers',
|
|
18
|
+
id: true,
|
|
19
|
+
read: 'primaryPreferred',
|
|
20
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
21
|
+
strict: true,
|
|
22
|
+
strictQuery: false,
|
|
23
|
+
timestamps: {
|
|
24
|
+
createdAt: 'createdAt',
|
|
25
|
+
updatedAt: 'updatedAt'
|
|
26
|
+
},
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
exports.schema = schema;
|
|
41
|
+
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
42
|
+
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
@@ -52,7 +52,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
52
52
|
};
|
|
53
53
|
}, {
|
|
54
54
|
additionalProperty: any[];
|
|
55
|
-
offers: any[];
|
|
56
55
|
addOn: any[];
|
|
57
56
|
availability: string;
|
|
58
57
|
availableAtOrFrom: any[];
|
|
@@ -84,7 +83,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
84
83
|
validRateLimit?: any;
|
|
85
84
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
86
85
|
additionalProperty: any[];
|
|
87
|
-
offers: any[];
|
|
88
86
|
addOn: any[];
|
|
89
87
|
availability: string;
|
|
90
88
|
availableAtOrFrom: any[];
|
|
@@ -116,7 +114,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
116
114
|
validRateLimit?: any;
|
|
117
115
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
118
116
|
additionalProperty: any[];
|
|
119
|
-
offers: any[];
|
|
120
117
|
addOn: any[];
|
|
121
118
|
availability: string;
|
|
122
119
|
availableAtOrFrom: any[];
|
|
@@ -29,7 +29,7 @@ const schema = new mongoose_1.Schema({
|
|
|
29
29
|
availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
|
|
30
30
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
31
31
|
itemOffered: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
-
offers: [
|
|
32
|
+
// offers: [SchemaTypes.Mixed],
|
|
33
33
|
priceCurrency: String,
|
|
34
34
|
priceSpecification: mongoose_1.SchemaTypes.Mixed,
|
|
35
35
|
eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
25
26
|
import { Connection } from 'mongoose';
|
|
26
27
|
import * as factory from '../factory';
|
|
27
28
|
interface IProjection {
|
|
@@ -31,6 +32,7 @@ interface IProjection {
|
|
|
31
32
|
* オファーリポジトリ
|
|
32
33
|
*/
|
|
33
34
|
export declare class MongoRepository {
|
|
35
|
+
private readonly aggregateOfferModel;
|
|
34
36
|
private readonly offerModel;
|
|
35
37
|
private readonly offerCatalogModel;
|
|
36
38
|
constructor(connection: Connection);
|
|
@@ -67,6 +69,9 @@ export declare class MongoRepository {
|
|
|
67
69
|
count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
|
|
68
70
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
69
71
|
save(params: factory.unitPriceOffer.IUnitPriceOffer): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
72
|
+
/**
|
|
73
|
+
* sskts専用オファー保管
|
|
74
|
+
*/
|
|
70
75
|
saveManyByIdentifier(params: {
|
|
71
76
|
attributes: factory.unitPriceOffer.IUnitPriceOffer;
|
|
72
77
|
upsert?: boolean;
|
|
@@ -99,5 +104,16 @@ export declare class MongoRepository {
|
|
|
99
104
|
filter: any;
|
|
100
105
|
$unset: any;
|
|
101
106
|
}): Promise<import("mongodb").UpdateResult>;
|
|
107
|
+
sync2aggregateOffer(params: {
|
|
108
|
+
id?: {
|
|
109
|
+
$in: string[];
|
|
110
|
+
};
|
|
111
|
+
identifier?: {
|
|
112
|
+
$in: string[];
|
|
113
|
+
};
|
|
114
|
+
project: {
|
|
115
|
+
id: string;
|
|
116
|
+
};
|
|
117
|
+
}): Promise<BulkWriteOpResultObject | void>;
|
|
102
118
|
}
|
|
103
119
|
export {};
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
24
|
const uniqid = require("uniqid");
|
|
25
25
|
const factory = require("../factory");
|
|
26
|
+
const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
|
|
26
27
|
const offer_1 = require("./mongoose/schemas/offer");
|
|
27
28
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
28
29
|
const settings_1 = require("../settings");
|
|
@@ -31,6 +32,7 @@ const settings_1 = require("../settings");
|
|
|
31
32
|
*/
|
|
32
33
|
class MongoRepository {
|
|
33
34
|
constructor(connection) {
|
|
35
|
+
this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
|
|
34
36
|
this.offerModel = connection.model(offer_1.modelName, offer_1.schema);
|
|
35
37
|
this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
|
|
36
38
|
}
|
|
@@ -463,6 +465,9 @@ class MongoRepository {
|
|
|
463
465
|
return doc.toObject();
|
|
464
466
|
});
|
|
465
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* sskts専用オファー保管
|
|
470
|
+
*/
|
|
466
471
|
saveManyByIdentifier(params) {
|
|
467
472
|
return __awaiter(this, void 0, void 0, function* () {
|
|
468
473
|
const bulkWriteOps = [];
|
|
@@ -486,7 +491,9 @@ class MongoRepository {
|
|
|
486
491
|
},
|
|
487
492
|
update: {
|
|
488
493
|
$set: $set,
|
|
489
|
-
$setOnInsert: {
|
|
494
|
+
$setOnInsert: {
|
|
495
|
+
_id: id
|
|
496
|
+
}
|
|
490
497
|
},
|
|
491
498
|
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
492
499
|
}
|
|
@@ -544,5 +551,66 @@ class MongoRepository {
|
|
|
544
551
|
.exec();
|
|
545
552
|
});
|
|
546
553
|
}
|
|
554
|
+
sync2aggregateOffer(params) {
|
|
555
|
+
var _a, _b;
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
let unitPriceOffers = [];
|
|
558
|
+
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
559
|
+
if (Array.isArray(idIn) && idIn.length > 0) {
|
|
560
|
+
unitPriceOffers = yield this.offerModel.find({
|
|
561
|
+
'project.id': { $eq: params.project.id },
|
|
562
|
+
_id: { $in: idIn }
|
|
563
|
+
}, {
|
|
564
|
+
__v: 0,
|
|
565
|
+
createdAt: 0,
|
|
566
|
+
updatedAt: 0,
|
|
567
|
+
offers: 0
|
|
568
|
+
})
|
|
569
|
+
.exec()
|
|
570
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
571
|
+
}
|
|
572
|
+
const identifierIn = (_b = params.identifier) === null || _b === void 0 ? void 0 : _b.$in;
|
|
573
|
+
if (Array.isArray(identifierIn) && identifierIn.length > 0) {
|
|
574
|
+
unitPriceOffers = yield this.offerModel.find({
|
|
575
|
+
'project.id': { $eq: params.project.id },
|
|
576
|
+
identifier: { $exists: true, $in: identifierIn }
|
|
577
|
+
}, {
|
|
578
|
+
__v: 0,
|
|
579
|
+
createdAt: 0,
|
|
580
|
+
updatedAt: 0,
|
|
581
|
+
offers: 0
|
|
582
|
+
})
|
|
583
|
+
.exec()
|
|
584
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
585
|
+
}
|
|
586
|
+
const bulkWriteOps = [];
|
|
587
|
+
if (unitPriceOffers.length > 0) {
|
|
588
|
+
unitPriceOffers.forEach((unitPriceOffer) => {
|
|
589
|
+
delete unitPriceOffer._id;
|
|
590
|
+
const $set = {
|
|
591
|
+
project: unitPriceOffer.project,
|
|
592
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
593
|
+
offers: [unitPriceOffer]
|
|
594
|
+
};
|
|
595
|
+
bulkWriteOps.push({
|
|
596
|
+
updateOne: {
|
|
597
|
+
filter: {
|
|
598
|
+
'project.id': { $eq: unitPriceOffer.project.id },
|
|
599
|
+
_id: { $eq: unitPriceOffer.id }
|
|
600
|
+
},
|
|
601
|
+
update: {
|
|
602
|
+
$set,
|
|
603
|
+
$setOnInsert: { _id: unitPriceOffer.id }
|
|
604
|
+
},
|
|
605
|
+
upsert: true
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
if (bulkWriteOps.length > 0) {
|
|
611
|
+
return this.aggregateOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
547
615
|
}
|
|
548
616
|
exports.MongoRepository = MongoRepository;
|
|
@@ -74,7 +74,7 @@ export declare class MongoRepository {
|
|
|
74
74
|
*/
|
|
75
75
|
$nin?: factory.taskName[];
|
|
76
76
|
};
|
|
77
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
77
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncAggregateOffer").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
78
78
|
retry(params: {
|
|
79
79
|
intervalInMinutes: number;
|
|
80
80
|
}): Promise<void>;
|
|
@@ -340,16 +340,6 @@ function coaTicket2offer(params) {
|
|
|
340
340
|
? params.ticketResult.ticketNameEng
|
|
341
341
|
: ''
|
|
342
342
|
};
|
|
343
|
-
const subOfferPriceSpec = {
|
|
344
|
-
price: unitPriceSpec.price,
|
|
345
|
-
typeOf: unitPriceSpec.typeOf
|
|
346
|
-
};
|
|
347
|
-
const subOffers = [{
|
|
348
|
-
typeOf: factory.offerType.Offer,
|
|
349
|
-
identifier: identifier,
|
|
350
|
-
name: offerName,
|
|
351
|
-
priceSpecification: subOfferPriceSpec
|
|
352
|
-
}];
|
|
353
343
|
return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
|
|
354
344
|
ja: '',
|
|
355
345
|
en: ''
|
|
@@ -360,7 +350,7 @@ function coaTicket2offer(params) {
|
|
|
360
350
|
: ''
|
|
361
351
|
}, availability: factory.itemAvailability.InStock, itemOffered: {
|
|
362
352
|
typeOf: factory.product.ProductType.EventService
|
|
363
|
-
},
|
|
353
|
+
}, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
|
|
364
354
|
{ name: 'theaterCode', value: params.theaterCode },
|
|
365
355
|
...Object.keys(params.ticketResult)
|
|
366
356
|
.map((key) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
3
3
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
4
5
|
export declare function importFromCOA(params: {
|
|
5
6
|
project: {
|
|
6
7
|
id: string;
|
|
@@ -9,6 +10,7 @@ export declare function importFromCOA(params: {
|
|
|
9
10
|
}): (repos: {
|
|
10
11
|
categoryCode: CategoryCodeRepo;
|
|
11
12
|
offer: OfferRepo;
|
|
13
|
+
task: TaskRepo;
|
|
12
14
|
masterService: COA.service.Master;
|
|
13
15
|
}) => Promise<void>;
|
|
14
16
|
/**
|
|
@@ -43,6 +43,24 @@ function importFromCOA(params) {
|
|
|
43
43
|
return { attributes: offer, upsert: true };
|
|
44
44
|
});
|
|
45
45
|
yield repos.offer.saveManyByIdentifier(saveParams);
|
|
46
|
+
// 同期タスク作成(2023-09-03~)
|
|
47
|
+
if (saveParams.length > 0) {
|
|
48
|
+
const syncAggregateOfferTask = {
|
|
49
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
50
|
+
name: factory.taskName.SyncAggregateOffer,
|
|
51
|
+
status: factory.taskStatus.Ready,
|
|
52
|
+
runsAt: new Date(),
|
|
53
|
+
remainingNumberOfTries: 3,
|
|
54
|
+
numberOfTried: 0,
|
|
55
|
+
executionResults: [],
|
|
56
|
+
data: {
|
|
57
|
+
project: { id: params.project.id },
|
|
58
|
+
identifier: { $in: saveParams.map((savingOffer) => savingOffer.attributes.identifier) },
|
|
59
|
+
typeOf: factory.offerType.Offer
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
yield repos.task.saveMany([syncAggregateOfferTask], { emitImmediately: true });
|
|
63
|
+
}
|
|
46
64
|
}
|
|
47
65
|
catch (error) {
|
|
48
66
|
let throwsError = true;
|
|
@@ -26,17 +26,17 @@ export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | '
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function createOnOrderSentTasksByTransaction(params: {
|
|
28
28
|
potentialActions?: factory.action.transfer.send.order.IPotentialActions;
|
|
29
|
-
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
29
|
+
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
30
30
|
/**
|
|
31
31
|
* 注文返品後のアクション
|
|
32
32
|
*/
|
|
33
33
|
export declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
34
34
|
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
35
|
-
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
35
|
+
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
36
36
|
/**
|
|
37
37
|
* 注文中止時のアクション
|
|
38
38
|
*/
|
|
39
39
|
export declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
40
40
|
transaction?: factory.transaction.placeOrder.ITransaction;
|
|
41
|
-
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
41
|
+
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
42
42
|
export {};
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const COA = require("@motionpicture/coa-service");
|
|
14
14
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
15
15
|
const offer_1 = require("../../repo/offer");
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
16
17
|
const credentials_1 = require("../../credentials");
|
|
17
18
|
const OfferService = require("../offer");
|
|
18
19
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
@@ -26,6 +27,7 @@ function call(data) {
|
|
|
26
27
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
const categoryCodeRepo = new categoryCode_1.MongoRepository(settings.connection);
|
|
28
29
|
const offerRepo = new offer_1.MongoRepository(settings.connection);
|
|
30
|
+
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
29
31
|
const masterService = new COA.service.Master({
|
|
30
32
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
31
33
|
auth: coaAuthClient
|
|
@@ -33,6 +35,7 @@ function call(data) {
|
|
|
33
35
|
yield OfferService.event.importFromCOA(data)({
|
|
34
36
|
categoryCode: categoryCodeRepo,
|
|
35
37
|
offer: offerRepo,
|
|
38
|
+
task: taskRepo,
|
|
36
39
|
masterService
|
|
37
40
|
});
|
|
38
41
|
yield OfferService.event.importCategoryCodesFromCOA(data)({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.syncAggregateOffer.IData): IOperation<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 offer_1 = require("../../repo/offer");
|
|
14
|
+
/**
|
|
15
|
+
* タスク実行関数
|
|
16
|
+
*/
|
|
17
|
+
function call(data) {
|
|
18
|
+
return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const offerRepo = new offer_1.MongoRepository(connectionSettings.connection);
|
|
20
|
+
yield offerRepo.sync2aggregateOffer(data);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.call = call;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.329.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.329.0-alpha.5",
|
|
13
13
|
"@cinerino/sdk": "3.166.0-alpha.5",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.28"
|
|
121
121
|
}
|
|
@@ -1,83 +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
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = actionRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
19
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
20
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
21
|
-
'result.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
22
|
-
startDate: {
|
|
23
|
-
$gte: moment('2022-08-16T00:00:00Z')
|
|
24
|
-
.toDate()
|
|
25
|
-
// $lte: moment('2023-08-01T00:00:00Z')
|
|
26
|
-
// .toDate()
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
_id: 1,
|
|
31
|
-
typeOf: 1,
|
|
32
|
-
result: 1,
|
|
33
|
-
project: 1,
|
|
34
|
-
startDate: 1,
|
|
35
|
-
actionStatus: 1
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
console.log('actions found');
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
await cursor.eachAsync(async (doc) => {
|
|
43
|
-
i += 1;
|
|
44
|
-
const action: Pick<
|
|
45
|
-
chevre.factory.action.authorize.paymentMethod.any.IAction,
|
|
46
|
-
'id' | 'project' | 'result' | 'typeOf' | 'startDate' | 'actionStatus'
|
|
47
|
-
> = doc.toObject();
|
|
48
|
-
|
|
49
|
-
const oldPaymentMethodType = (<any>action).result?.paymentMethod;
|
|
50
|
-
const paymentMethodType = action.result?.paymentMethodAsObject?.typeOf;
|
|
51
|
-
const alreadyMigrated = typeof paymentMethodType === 'string' && oldPaymentMethodType === paymentMethodType;
|
|
52
|
-
|
|
53
|
-
if (alreadyMigrated) {
|
|
54
|
-
console.log('already exist...', action.project.id, action.id, action.startDate, paymentMethodType, i);
|
|
55
|
-
} else {
|
|
56
|
-
if (typeof oldPaymentMethodType !== 'string') {
|
|
57
|
-
console.error('updating action...', action.project.id, action.id, action.startDate, oldPaymentMethodType, i, updateCount);
|
|
58
|
-
throw new Error('oldPaymentMethodType undefined');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const newPaymentMethodAsObject: chevre.factory.action.authorize.paymentMethod.any.IResultPaymentMethod = {
|
|
62
|
-
typeOf: oldPaymentMethodType
|
|
63
|
-
};
|
|
64
|
-
console.log(
|
|
65
|
-
'updating action...', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
|
|
66
|
-
await actionRepo.updateById({
|
|
67
|
-
id: action.id,
|
|
68
|
-
update: {
|
|
69
|
-
'result.paymentMethodAsObject': newPaymentMethodAsObject
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
updateCount += 1;
|
|
73
|
-
console.log('updated.', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
console.log(i, 'actions checked');
|
|
78
|
-
console.log(updateCount, 'actions updated');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
main()
|
|
82
|
-
.then()
|
|
83
|
-
.catch(console.error);
|