@chevre/domain 20.2.0-alpha.13 → 20.2.0-alpha.15
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/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
- package/lib/chevre/repo/aggregation.d.ts +8 -0
- package/lib/chevre/repo/aggregation.js +13 -0
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +29 -1
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +33 -51
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +1 -1
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -0,0 +1,77 @@
|
|
|
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 productRepo = new chevre.repository.Product(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = productRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// _id: 1,
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
console.log('products found');
|
|
27
|
+
|
|
28
|
+
let i = 0;
|
|
29
|
+
let updateCount = 0;
|
|
30
|
+
// tslint:disable-next-line:max-func-body-length
|
|
31
|
+
await cursor.eachAsync(async (doc) => {
|
|
32
|
+
i += 1;
|
|
33
|
+
const paymentService: chevre.factory.service.paymentService.IService = doc.toObject();
|
|
34
|
+
|
|
35
|
+
const hasPaymentUrlExpiresInseconds = paymentService.provider?.some((provider) => {
|
|
36
|
+
return typeof (<any>provider).credentials?.paymentUrlExpiresInSeconds === 'number';
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!hasPaymentUrlExpiresInseconds) {
|
|
40
|
+
console.log(
|
|
41
|
+
'no expiresInSeconds', paymentService.project.id, paymentService.id, paymentService.productID, i);
|
|
42
|
+
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const alreadyMigrated = paymentService.provider?.filter((provider) => {
|
|
47
|
+
return typeof (<any>provider).credentials?.paymentUrlExpiresInSeconds === 'number';
|
|
48
|
+
})
|
|
49
|
+
.every((provider) => {
|
|
50
|
+
return typeof provider.credentials?.paymentUrl?.expiresInSeconds === 'number';
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (alreadyMigrated) {
|
|
54
|
+
console.log(
|
|
55
|
+
'already exist...', paymentService.project.id, paymentService.id, paymentService.productID, i);
|
|
56
|
+
} else {
|
|
57
|
+
console.log(
|
|
58
|
+
'updating product...', paymentService.project.id, paymentService.id, paymentService.productID, i);
|
|
59
|
+
// await eventRepo.updatePartiallyById({
|
|
60
|
+
// id: event.id,
|
|
61
|
+
// attributes: <any>{
|
|
62
|
+
// typeOf: event.typeOf,
|
|
63
|
+
// 'offers.itemOffered.availableChannel': newAvailableChannel
|
|
64
|
+
// }
|
|
65
|
+
// });
|
|
66
|
+
updateCount += 1;
|
|
67
|
+
console.log(
|
|
68
|
+
'updated...', paymentService.project.id, paymentService.id, paymentService.productID, i);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
console.log(i, 'products checked');
|
|
72
|
+
console.log(updateCount, 'products updated');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
main()
|
|
76
|
+
.then()
|
|
77
|
+
.catch(console.error);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoRepository = void 0;
|
|
4
|
+
const aggregation_1 = require("./mongoose/model/aggregation");
|
|
5
|
+
/**
|
|
6
|
+
* 集計リポジトリ
|
|
7
|
+
*/
|
|
8
|
+
class MongoRepository {
|
|
9
|
+
constructor(connection) {
|
|
10
|
+
this.aggregationModel = connection.model(aggregation_1.modelName);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as mongoose from 'mongoose';
|
|
2
|
+
declare const modelName = "Aggregation";
|
|
3
|
+
/**
|
|
4
|
+
* 集計スキーマ
|
|
5
|
+
*/
|
|
6
|
+
declare const schema: mongoose.Schema<mongoose.Document<any, any, any>, mongoose.Model<mongoose.Document<any, any, any>, any, any>, undefined, {}>;
|
|
7
|
+
export { modelName, schema };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.modelName = void 0;
|
|
4
|
+
const mongoose = require("mongoose");
|
|
5
|
+
const modelName = 'Aggregation';
|
|
6
|
+
exports.modelName = modelName;
|
|
7
|
+
const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
8
|
+
/**
|
|
9
|
+
* 集計スキーマ
|
|
10
|
+
*/
|
|
11
|
+
const schema = new mongoose.Schema({}, {
|
|
12
|
+
collection: 'aggregations',
|
|
13
|
+
id: true,
|
|
14
|
+
read: 'primaryPreferred',
|
|
15
|
+
writeConcern: writeConcern,
|
|
16
|
+
strict: false,
|
|
17
|
+
useNestedStrict: true,
|
|
18
|
+
timestamps: {
|
|
19
|
+
createdAt: 'createdAt',
|
|
20
|
+
updatedAt: 'updatedAt'
|
|
21
|
+
},
|
|
22
|
+
toJSON: {
|
|
23
|
+
getters: false,
|
|
24
|
+
virtuals: false,
|
|
25
|
+
minimize: false,
|
|
26
|
+
versionKey: false
|
|
27
|
+
},
|
|
28
|
+
toObject: {
|
|
29
|
+
getters: false,
|
|
30
|
+
virtuals: true,
|
|
31
|
+
minimize: false,
|
|
32
|
+
versionKey: false
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
exports.schema = schema;
|
|
36
|
+
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
37
|
+
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
38
|
+
mongoose.model(modelName, schema)
|
|
39
|
+
.on('index',
|
|
40
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
41
|
+
/* istanbul ignore next */
|
|
42
|
+
(error) => {
|
|
43
|
+
if (error !== undefined) {
|
|
44
|
+
// tslint:disable-next-line:no-console
|
|
45
|
+
console.error(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -5,41 +5,17 @@ const mongoose = require("mongoose");
|
|
|
5
5
|
const modelName = 'Telemetry';
|
|
6
6
|
exports.modelName = modelName;
|
|
7
7
|
const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
8
|
-
const purposeSchema = new mongoose.Schema({
|
|
9
|
-
typeOf: String
|
|
10
|
-
}, {
|
|
11
|
-
id: false,
|
|
12
|
-
_id: false,
|
|
13
|
-
strict: false
|
|
14
|
-
});
|
|
15
|
-
const objectSchema = new mongoose.Schema({
|
|
16
|
-
measuredAt: Date
|
|
17
|
-
}, {
|
|
18
|
-
id: false,
|
|
19
|
-
_id: false,
|
|
20
|
-
strict: false
|
|
21
|
-
});
|
|
22
|
-
const resultSchema = new mongoose.Schema({}, {
|
|
23
|
-
id: false,
|
|
24
|
-
_id: false,
|
|
25
|
-
strict: false
|
|
26
|
-
});
|
|
27
|
-
const errorSchema = new mongoose.Schema({}, {
|
|
28
|
-
id: false,
|
|
29
|
-
_id: false,
|
|
30
|
-
strict: false
|
|
31
|
-
});
|
|
32
8
|
/**
|
|
33
9
|
* 測定スキーマ
|
|
34
10
|
*/
|
|
35
11
|
const schema = new mongoose.Schema({
|
|
36
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
37
|
-
result:
|
|
38
|
-
error:
|
|
39
|
-
object:
|
|
13
|
+
result: mongoose.SchemaTypes.Mixed,
|
|
14
|
+
error: mongoose.SchemaTypes.Mixed,
|
|
15
|
+
object: mongoose.SchemaTypes.Mixed,
|
|
40
16
|
startDate: Date,
|
|
41
17
|
endDate: Date,
|
|
42
|
-
purpose:
|
|
18
|
+
purpose: mongoose.SchemaTypes.Mixed
|
|
43
19
|
}, {
|
|
44
20
|
collection: 'telemetries',
|
|
45
21
|
id: true,
|
|
@@ -251,5 +251,10 @@ class MongoRepository {
|
|
|
251
251
|
.exec();
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
+
getCursor(conditions, projection) {
|
|
255
|
+
return this.productModel.find(conditions, projection)
|
|
256
|
+
.sort({ productID: factory.sortType.Ascending })
|
|
257
|
+
.cursor();
|
|
258
|
+
}
|
|
254
259
|
}
|
|
255
260
|
exports.MongoRepository = MongoRepository;
|
|
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
|
7
7
|
import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
|
|
8
8
|
import { MongoRepository as ActionRepo } from './repo/action';
|
|
9
9
|
import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
10
|
+
import { MongoRepository as AggregationRepo } from './repo/aggregation';
|
|
10
11
|
import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
|
|
11
12
|
import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
|
|
12
13
|
import { MongoRepository as CodeRepo } from './repo/code';
|
|
@@ -69,6 +70,8 @@ export declare class Action extends ActionRepo {
|
|
|
69
70
|
*/
|
|
70
71
|
export declare class AdditionalProperty extends AdditionalPropertyRepo {
|
|
71
72
|
}
|
|
73
|
+
export declare class Aggregation extends AggregationRepo {
|
|
74
|
+
}
|
|
72
75
|
export declare namespace action {
|
|
73
76
|
class RegisterServiceInProgress extends RegisterServiceActionInProgress {
|
|
74
77
|
}
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
3
|
+
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
|
|
|
11
11
|
const accountTransaction_1 = require("./repo/accountTransaction");
|
|
12
12
|
const action_1 = require("./repo/action");
|
|
13
13
|
const additionalProperty_1 = require("./repo/additionalProperty");
|
|
14
|
+
const aggregation_1 = require("./repo/aggregation");
|
|
14
15
|
const assetTransaction_1 = require("./repo/assetTransaction");
|
|
15
16
|
const categoryCode_1 = require("./repo/categoryCode");
|
|
16
17
|
const code_1 = require("./repo/code");
|
|
@@ -80,6 +81,9 @@ exports.Action = Action;
|
|
|
80
81
|
class AdditionalProperty extends additionalProperty_1.MongoRepository {
|
|
81
82
|
}
|
|
82
83
|
exports.AdditionalProperty = AdditionalProperty;
|
|
84
|
+
class Aggregation extends aggregation_1.MongoRepository {
|
|
85
|
+
}
|
|
86
|
+
exports.Aggregation = Aggregation;
|
|
83
87
|
var action;
|
|
84
88
|
(function (action) {
|
|
85
89
|
class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
|
|
@@ -70,4 +70,7 @@ export declare function createPotentialActions(params: factory.assetTransaction.
|
|
|
70
70
|
transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
|
|
71
71
|
order?: factory.order.IOrder;
|
|
72
72
|
}): factory.assetTransaction.reserve.IPotentialActions;
|
|
73
|
+
export declare function createPendingReservationAction(params: {
|
|
74
|
+
transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
|
|
75
|
+
}): factory.action.cancel.reservation.IAttributes[];
|
|
73
76
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPotentialActions = exports.createReservation = exports.createReservationFor = exports.createAdditionalTicketText = exports.createAdditionalProperty = exports.validateAppliesToMovieTicket = exports.createReservedTicket = exports.createPointAward = exports.createStartParams = void 0;
|
|
3
|
+
exports.createPendingReservationAction = exports.createPotentialActions = exports.createReservation = exports.createReservationFor = exports.createAdditionalTicketText = exports.createAdditionalProperty = exports.validateAppliesToMovieTicket = exports.createReservedTicket = exports.createPointAward = exports.createStartParams = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約取引ファクトリー
|
|
6
6
|
*/
|
|
@@ -550,3 +550,31 @@ function createMoneyTransferActions(params) {
|
|
|
550
550
|
}
|
|
551
551
|
return moneyTransfer;
|
|
552
552
|
}
|
|
553
|
+
function createPendingReservationAction(params) {
|
|
554
|
+
const transaction = params.transaction;
|
|
555
|
+
const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
|
|
556
|
+
let cancelActionAttributes = [];
|
|
557
|
+
if (pendingReservations.length > 0) {
|
|
558
|
+
const reservationFor = transaction.object.reservationFor;
|
|
559
|
+
if (reservationFor === undefined) {
|
|
560
|
+
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
561
|
+
}
|
|
562
|
+
// ReservationPackageに対応(2022-12-23~)
|
|
563
|
+
const reservationPackage = {
|
|
564
|
+
typeOf: factory.reservationType.ReservationPackage,
|
|
565
|
+
reservationNumber: transaction.transactionNumber,
|
|
566
|
+
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
567
|
+
reservationStatus: pendingReservations[0].reservationStatus
|
|
568
|
+
};
|
|
569
|
+
cancelActionAttributes = [{
|
|
570
|
+
project: transaction.project,
|
|
571
|
+
typeOf: factory.actionType.CancelAction,
|
|
572
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
573
|
+
agent: transaction.project,
|
|
574
|
+
object: reservationPackage,
|
|
575
|
+
potentialActions: {}
|
|
576
|
+
}];
|
|
577
|
+
}
|
|
578
|
+
return cancelActionAttributes;
|
|
579
|
+
}
|
|
580
|
+
exports.createPendingReservationAction = createPendingReservationAction;
|
|
@@ -54,10 +54,14 @@ export declare type ITaskAndTransactionOperation<T> = (repos: {
|
|
|
54
54
|
task: TaskRepo;
|
|
55
55
|
assetTransaction: AssetTransactionRepo;
|
|
56
56
|
}) => Promise<T>;
|
|
57
|
-
|
|
57
|
+
interface IConfirmRepo {
|
|
58
|
+
action: ActionRepo;
|
|
58
59
|
assetTransaction: AssetTransactionRepo;
|
|
59
60
|
order: OrderRepo;
|
|
60
|
-
|
|
61
|
+
reservation: ReservationRepo;
|
|
62
|
+
task: TaskRepo;
|
|
63
|
+
}
|
|
64
|
+
export declare type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
|
|
61
65
|
/**
|
|
62
66
|
* 取引開始
|
|
63
67
|
*/
|
|
@@ -81,3 +85,4 @@ export declare function cancel(params: {
|
|
|
81
85
|
export declare function exportTasksById(params: {
|
|
82
86
|
id: string;
|
|
83
87
|
}): ITaskAndTransactionOperation<factory.task.ITask<factory.taskName>[]>;
|
|
88
|
+
export {};
|
|
@@ -18,6 +18,7 @@ const pecorinoapi = require("../../pecorinoapi");
|
|
|
18
18
|
const factory = require("../../factory");
|
|
19
19
|
const OfferService = require("../offer");
|
|
20
20
|
const cancelReservation_1 = require("../reserve/cancelReservation");
|
|
21
|
+
const confirmReservation_1 = require("../reserve/confirmReservation");
|
|
21
22
|
const settings_1 = require("../../settings");
|
|
22
23
|
const factory_1 = require("./reserve/factory");
|
|
23
24
|
/**
|
|
@@ -571,8 +572,14 @@ function confirm(params) {
|
|
|
571
572
|
typeOf: factory.assetTransactionType.Reserve,
|
|
572
573
|
id: transaction.id,
|
|
573
574
|
result: result,
|
|
574
|
-
potentialActions:
|
|
575
|
+
potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
576
|
+
? { reserve: [] }
|
|
577
|
+
: potentialActions
|
|
575
578
|
});
|
|
579
|
+
if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
580
|
+
// sync対応(2023-01-13~)
|
|
581
|
+
yield (0, confirmReservation_1.confirmReservation)(potentialActions.reserve)(repos);
|
|
582
|
+
}
|
|
576
583
|
});
|
|
577
584
|
}
|
|
578
585
|
exports.confirm = confirm;
|
|
@@ -614,34 +621,9 @@ function cancel(params) {
|
|
|
614
621
|
});
|
|
615
622
|
// 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
|
|
616
623
|
// 同期的にもcancelPendingReservationを実行しておく
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (pendingReservations.length > 0) {
|
|
621
|
-
const reservationFor = transaction.object.reservationFor;
|
|
622
|
-
if (reservationFor === undefined) {
|
|
623
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
624
|
-
}
|
|
625
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
626
|
-
const reservationPackage = {
|
|
627
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
628
|
-
reservationNumber: transaction.transactionNumber,
|
|
629
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
630
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
631
|
-
};
|
|
632
|
-
cancelActionAttributes = [{
|
|
633
|
-
project: transaction.project,
|
|
634
|
-
typeOf: factory.actionType.CancelAction,
|
|
635
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
636
|
-
agent: transaction.project,
|
|
637
|
-
object: reservationPackage,
|
|
638
|
-
potentialActions: {}
|
|
639
|
-
}];
|
|
640
|
-
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
catch (error) {
|
|
644
|
-
// no op
|
|
624
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
625
|
+
if (cancelActionAttributes.length > 0) {
|
|
626
|
+
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
645
627
|
}
|
|
646
628
|
});
|
|
647
629
|
}
|
|
@@ -704,29 +686,29 @@ function exportTasksById(params) {
|
|
|
704
686
|
}
|
|
705
687
|
break;
|
|
706
688
|
case factory.transactionStatusType.Canceled:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (reservationFor === undefined) {
|
|
713
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
714
|
-
}
|
|
715
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
716
|
-
const reservationPackage = {
|
|
717
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
718
|
-
reservationNumber: transaction.transactionNumber,
|
|
719
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
720
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
721
|
-
};
|
|
722
|
-
cancelActionAttributes = [{
|
|
689
|
+
// sync対応(2023-01-13~)
|
|
690
|
+
if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
691
|
+
const cancelActionAttributes4canceled = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
692
|
+
if (cancelActionAttributes4canceled.length > 0) {
|
|
693
|
+
const cancelPendingReservationTask = {
|
|
723
694
|
project: transaction.project,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
695
|
+
name: factory.taskName.CancelPendingReservation,
|
|
696
|
+
status: factory.taskStatus.Ready,
|
|
697
|
+
runsAt: new Date(),
|
|
698
|
+
remainingNumberOfTries: 10,
|
|
699
|
+
numberOfTried: 0,
|
|
700
|
+
executionResults: [],
|
|
701
|
+
data: {
|
|
702
|
+
actionAttributes: cancelActionAttributes4canceled
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
taskAttributes.push(cancelPendingReservationTask);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
break;
|
|
709
|
+
case factory.transactionStatusType.Expired:
|
|
710
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
711
|
+
if (cancelActionAttributes.length > 0) {
|
|
730
712
|
const cancelPendingReservationTask = {
|
|
731
713
|
project: transaction.project,
|
|
732
714
|
name: factory.taskName.CancelPendingReservation,
|
|
@@ -37,7 +37,6 @@ function cancel(params) {
|
|
|
37
37
|
const transactionNumber = (_a = action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
38
38
|
if (typeof transactionNumber === 'string') {
|
|
39
39
|
// すでに取消済であったとしても、すべて取消処理(actionStatusに関係なく)
|
|
40
|
-
// await repos.reserveTransaction.cancel({ transactionNumber: action.object.pendingTransaction?.transactionNumber });
|
|
41
40
|
yield ReserveTransactionService.cancel({ transactionNumber })(repos);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -114,8 +114,6 @@ function processVoidTransaction4chevre(params) {
|
|
|
114
114
|
transactionNumber: { $eq: transactionNumber }
|
|
115
115
|
});
|
|
116
116
|
if (assetTransactions.length > 0) {
|
|
117
|
-
// 予約取引サービスで中止
|
|
118
|
-
// await repos.reserveTransaction.cancel({ transactionNumber });
|
|
119
117
|
yield ReserveTransactionService.cancel({ transactionNumber })(repos);
|
|
120
118
|
}
|
|
121
119
|
}
|
|
@@ -3,6 +3,8 @@ import * as factory from '../../factory';
|
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
5
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
6
|
+
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
7
|
+
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
6
8
|
/**
|
|
7
9
|
* タスク実行関数
|
|
8
10
|
*/
|
|
@@ -14,4 +16,6 @@ export declare function confirmReserveTransaction(params: factory.action.interac
|
|
|
14
16
|
action: ActionRepo;
|
|
15
17
|
assetTransaction: AssetTransactionRepo;
|
|
16
18
|
order: OrderRepo;
|
|
19
|
+
reservation: ReservationRepo;
|
|
20
|
+
task: TaskRepo;
|
|
17
21
|
}) => Promise<void>;
|
|
@@ -15,6 +15,8 @@ const factory = require("../../factory");
|
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
16
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
17
|
const order_1 = require("../../repo/order");
|
|
18
|
+
const reservation_1 = require("../../repo/reservation");
|
|
19
|
+
const task_1 = require("../../repo/task");
|
|
18
20
|
const ReserveTransactionService = require("../assetTransaction/reserve");
|
|
19
21
|
const credentials_1 = require("../../credentials");
|
|
20
22
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
@@ -29,7 +31,9 @@ function call(data) {
|
|
|
29
31
|
yield confirmReserveTransaction(data)({
|
|
30
32
|
action: new action_1.MongoRepository(settings.connection),
|
|
31
33
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
32
|
-
order: new order_1.MongoRepository(settings.connection)
|
|
34
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
35
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
36
|
+
task: new task_1.MongoRepository(settings.connection)
|
|
33
37
|
});
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -44,9 +48,6 @@ function confirmReserveTransaction(params) {
|
|
|
44
48
|
const action = yield repos.action.start(confirmActionAttributes);
|
|
45
49
|
try {
|
|
46
50
|
let object = confirmActionAttributes.object;
|
|
47
|
-
// if (params.instrument === undefined) {
|
|
48
|
-
// params.instrument = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
|
|
49
|
-
// }
|
|
50
51
|
switch (params.instrument.identifier) {
|
|
51
52
|
case factory.service.webAPI.Identifier.COA:
|
|
52
53
|
// COA本予約
|
|
@@ -72,7 +73,6 @@ function confirmReserveTransaction(params) {
|
|
|
72
73
|
object = object;
|
|
73
74
|
yield ReserveTransactionService.confirm({
|
|
74
75
|
transactionNumber: object.transactionNumber,
|
|
75
|
-
// object: object.object,
|
|
76
76
|
potentialActions: object.potentialActions
|
|
77
77
|
})(repos);
|
|
78
78
|
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare type ISettings = factory.project.ISettings & {
|
|
|
23
23
|
maxNumCreditCardPaymentMethod?: number;
|
|
24
24
|
};
|
|
25
25
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
26
|
+
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
26
27
|
/**
|
|
27
28
|
* グローバル設定
|
|
28
29
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
3
|
+
exports.settings = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(',')
|
|
@@ -46,6 +46,7 @@ exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = 365;
|
|
|
46
46
|
exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = 7;
|
|
47
47
|
exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
|
|
48
48
|
exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
|
|
49
|
+
exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
49
50
|
/**
|
|
50
51
|
* グローバル設定
|
|
51
52
|
*/
|
package/package.json
CHANGED
|
@@ -1,162 +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 placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = placeRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
20
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
-
// starDate: { $gte: new Date() }
|
|
22
|
-
// _id: { $eq: 'al6aff83w' }
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
// _id: 1,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
console.log('creativeWorks found');
|
|
29
|
-
|
|
30
|
-
const additionalPropertyNames: string[] = [];
|
|
31
|
-
const additionalPropertyNamesOnSections: string[] = [];
|
|
32
|
-
const additionalPropertyNamesOnSeats: string[] = [];
|
|
33
|
-
const projectIds: string[] = [];
|
|
34
|
-
const unexpextedprojectIds: string[] = [];
|
|
35
|
-
const projectIdsOnSections: string[] = [];
|
|
36
|
-
const unexpextedprojectIdsOnSections: string[] = [];
|
|
37
|
-
const projectIdsOnSeats: string[] = [];
|
|
38
|
-
const unexpextedprojectIdsOnSeats: string[] = [];
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
// tslint:disable-next-line:max-func-body-length
|
|
43
|
-
await cursor.eachAsync(async (doc) => {
|
|
44
|
-
i += 1;
|
|
45
|
-
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
46
|
-
|
|
47
|
-
if (Array.isArray(movieTheater.containsPlace)) {
|
|
48
|
-
movieTheater.containsPlace.forEach((screeningRoom) => {
|
|
49
|
-
const additionalPropertyNamesOnResource = screeningRoom.additionalProperty?.map((p) => p.name);
|
|
50
|
-
console.log(
|
|
51
|
-
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
52
|
-
'additionalPropertyNamesOnResource found',
|
|
53
|
-
movieTheater.project.id,
|
|
54
|
-
movieTheater.id
|
|
55
|
-
);
|
|
56
|
-
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
57
|
-
console.log(
|
|
58
|
-
additionalPropertyNamesOnResource.length,
|
|
59
|
-
'additionalPropertyNamesOnResource found',
|
|
60
|
-
movieTheater.project.id,
|
|
61
|
-
movieTheater.id
|
|
62
|
-
);
|
|
63
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
64
|
-
projectIds.push(movieTheater.project.id);
|
|
65
|
-
additionalPropertyNamesOnResource.forEach((name) => {
|
|
66
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
67
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
68
|
-
unexpextedprojectIds.push(movieTheater.project.id);
|
|
69
|
-
}
|
|
70
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
71
|
-
if (name.length < 5) {
|
|
72
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
73
|
-
unexpextedprojectIds.push(movieTheater.project.id);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (Array.isArray(screeningRoom.containsPlace)) {
|
|
79
|
-
screeningRoom.containsPlace.forEach((section) => {
|
|
80
|
-
const additionalPropertyNamesOnSection = section.additionalProperty?.map((p) => p.name);
|
|
81
|
-
console.log(
|
|
82
|
-
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
83
|
-
'additionalPropertyNamesOnSection found',
|
|
84
|
-
movieTheater.project.id,
|
|
85
|
-
movieTheater.id
|
|
86
|
-
);
|
|
87
|
-
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
88
|
-
console.log(
|
|
89
|
-
additionalPropertyNamesOnSection.length,
|
|
90
|
-
'additionalPropertyNamesOnSection found',
|
|
91
|
-
movieTheater.project.id,
|
|
92
|
-
movieTheater.id
|
|
93
|
-
);
|
|
94
|
-
additionalPropertyNamesOnSections.push(...additionalPropertyNamesOnSection);
|
|
95
|
-
projectIdsOnSections.push(movieTheater.project.id);
|
|
96
|
-
additionalPropertyNamesOnSection.forEach((name) => {
|
|
97
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
98
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
99
|
-
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
100
|
-
}
|
|
101
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
102
|
-
if (name.length < 5) {
|
|
103
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
104
|
-
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (Array.isArray(section.containsPlace)) {
|
|
110
|
-
section.containsPlace.forEach((seat) => {
|
|
111
|
-
const additionalPropertyNamesOnSeat = seat.additionalProperty?.map((p) => p.name);
|
|
112
|
-
console.log(
|
|
113
|
-
(Array.isArray(additionalPropertyNamesOnSeat)) ? additionalPropertyNamesOnSeat.length : 0,
|
|
114
|
-
'additionalPropertyNamesOnSeat found',
|
|
115
|
-
movieTheater.project.id,
|
|
116
|
-
movieTheater.id
|
|
117
|
-
);
|
|
118
|
-
if (Array.isArray(additionalPropertyNamesOnSeat) && additionalPropertyNamesOnSeat.length > 0) {
|
|
119
|
-
console.log(
|
|
120
|
-
additionalPropertyNamesOnSeat.length,
|
|
121
|
-
'additionalPropertyNamesOnSeat found',
|
|
122
|
-
movieTheater.project.id,
|
|
123
|
-
movieTheater.id
|
|
124
|
-
);
|
|
125
|
-
additionalPropertyNamesOnSeats.push(...additionalPropertyNamesOnSeat);
|
|
126
|
-
projectIdsOnSeats.push(movieTheater.project.id);
|
|
127
|
-
additionalPropertyNamesOnSeat.forEach((name) => {
|
|
128
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
129
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
130
|
-
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
131
|
-
}
|
|
132
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
133
|
-
if (name.length < 5) {
|
|
134
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
135
|
-
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
console.log(i, 'places checked');
|
|
148
|
-
console.log(updateCount, 'places updated');
|
|
149
|
-
console.log([...new Set(additionalPropertyNames)], 'screeningRooms');
|
|
150
|
-
console.log([...new Set(projectIds)], 'screeningRooms');
|
|
151
|
-
console.log([...new Set(unexpextedprojectIds)], 'screeningRooms');
|
|
152
|
-
console.log([...new Set(additionalPropertyNamesOnSections)], 'sections');
|
|
153
|
-
console.log([...new Set(projectIdsOnSections)], 'sections');
|
|
154
|
-
console.log([...new Set(unexpextedprojectIdsOnSections)], 'sections');
|
|
155
|
-
console.log([...new Set(additionalPropertyNamesOnSeats)], 'seats');
|
|
156
|
-
console.log([...new Set(projectIdsOnSeats)], 'seats');
|
|
157
|
-
console.log([...new Set(unexpextedprojectIdsOnSeats)], 'seats');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
main()
|
|
161
|
-
.then()
|
|
162
|
-
.catch(console.error);
|