@chevre/domain 21.7.0-alpha.1 → 21.7.0-alpha.10
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/migrateAuthorizePaymentActionResult.ts +83 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +17 -11
- package/lib/chevre/emailMessageBuilder.d.ts +1 -1
- package/lib/chevre/repo/action.d.ts +4 -0
- package/lib/chevre/repo/action.js +6 -0
- package/lib/chevre/repo/event.d.ts +12 -0
- package/lib/chevre/repo/event.js +11 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/offer.js +5 -6
- package/lib/chevre/repo/product.d.ts +1 -1
- package/lib/chevre/repo/product.js +1 -0
- package/lib/chevre/repo/transaction.d.ts +4 -1
- package/lib/chevre/repo/transaction.js +7 -1
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/factory.js +49 -27
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +39 -18
- package/lib/chevre/service/assetTransaction/refund/factory.js +2 -2
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +42 -0
- package/lib/chevre/service/payment/any/factory.js +18 -7
- package/lib/chevre/service/payment/creditCard.js +3 -1
- package/lib/chevre/service/payment/paymentCard.js +6 -2
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +0 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +11 -9
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +6 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +6 -20
- package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -3
- package/lib/chevre/service/transaction/returnOrder.js +0 -1
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +3 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateReservationProvider.ts +0 -119
|
@@ -0,0 +1,83 @@
|
|
|
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 = 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);
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
2
3
|
import * as mongoose from 'mongoose';
|
|
3
4
|
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
5
6
|
|
|
7
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
+
|
|
6
9
|
async function main() {
|
|
7
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
11
|
|
|
9
|
-
const
|
|
12
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
13
|
|
|
11
14
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
13
|
-
filter: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
16
|
+
filter: {
|
|
17
|
+
'project.id': { $eq: PROJECT_ID },
|
|
18
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
19
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
20
|
+
startDate: {
|
|
21
|
+
$lte: moment('2023-08-16T07:26:00Z')
|
|
22
|
+
.toDate()
|
|
23
|
+
},
|
|
24
|
+
'object.authorizeActions': { $exists: true }
|
|
25
|
+
},
|
|
26
|
+
$unset: { 'object.authorizeActions': 1 }
|
|
21
27
|
});
|
|
22
|
-
console.log('unset processed.', updateResult);
|
|
28
|
+
console.log('unset processed.', updateResult, 'PROJECT_ID:', PROJECT_ID);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
main()
|
|
@@ -24,6 +24,6 @@ export declare function createReturnOrderMessage(params: {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function createRefundMessage(params: {
|
|
26
26
|
order: factory.order.IOrder;
|
|
27
|
-
paymentMethods: factory.order.
|
|
27
|
+
paymentMethods: factory.order.IReferencedInvoice[];
|
|
28
28
|
email?: factory.creativeWork.message.email.ICustomization;
|
|
29
29
|
}): Promise<factory.creativeWork.message.email.ICreativeWork>;
|
|
@@ -150,6 +150,10 @@ export declare class MongoRepository {
|
|
|
150
150
|
object: factory.action.authorize.offer.seatReservation.IObject<T>;
|
|
151
151
|
result: factory.action.authorize.offer.seatReservation.IResult<T>;
|
|
152
152
|
}): Promise<factory.action.authorize.offer.seatReservation.IAction<T>>;
|
|
153
|
+
updateById(params: {
|
|
154
|
+
id: string;
|
|
155
|
+
update: any;
|
|
156
|
+
}): Promise<void>;
|
|
153
157
|
findByIdAndUpdate<T extends factory.actionType>(params: {
|
|
154
158
|
id: string;
|
|
155
159
|
update: any;
|
|
@@ -643,6 +643,12 @@ class MongoRepository {
|
|
|
643
643
|
});
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
+
updateById(params) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
yield this.actionModel.updateOne({ _id: { $eq: params.id } }, params.update)
|
|
649
|
+
.exec();
|
|
650
|
+
});
|
|
651
|
+
}
|
|
646
652
|
findByIdAndUpdate(params) {
|
|
647
653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
648
654
|
return this.actionModel.findOneAndUpdate({ _id: params.id }, params.update, { new: true })
|
|
@@ -252,6 +252,18 @@ export declare class MongoRepository {
|
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
254
|
}): Promise<import("mongodb").DeleteResult>;
|
|
255
|
+
deleteManyEndedByIds(params: {
|
|
256
|
+
typeOf: {
|
|
257
|
+
$in: factory.eventType[];
|
|
258
|
+
};
|
|
259
|
+
project: {
|
|
260
|
+
id: string;
|
|
261
|
+
};
|
|
262
|
+
ids: string[];
|
|
263
|
+
endDate: {
|
|
264
|
+
$lte: Date;
|
|
265
|
+
};
|
|
266
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
255
267
|
deleteByProject(params: {
|
|
256
268
|
project: {
|
|
257
269
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -966,6 +966,17 @@ class MongoRepository {
|
|
|
966
966
|
.exec();
|
|
967
967
|
});
|
|
968
968
|
}
|
|
969
|
+
deleteManyEndedByIds(params) {
|
|
970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
971
|
+
return this.eventModel.deleteMany({
|
|
972
|
+
typeOf: { $in: params.typeOf.$in },
|
|
973
|
+
'project.id': { $eq: params.project.id },
|
|
974
|
+
_id: { $in: params.ids },
|
|
975
|
+
endDate: { $lte: params.endDate.$lte }
|
|
976
|
+
})
|
|
977
|
+
.exec();
|
|
978
|
+
});
|
|
979
|
+
}
|
|
969
980
|
deleteByProject(params) {
|
|
970
981
|
return __awaiter(this, void 0, void 0, function* () {
|
|
971
982
|
yield this.eventModel.deleteMany({
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Schema } from 'mongoose';
|
|
26
26
|
declare const modelName = "Offer";
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 単価オファースキーマ
|
|
29
29
|
*/
|
|
30
30
|
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
31
|
collection: string;
|
|
@@ -53,6 +53,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
53
53
|
}, {
|
|
54
54
|
additionalProperty: any[];
|
|
55
55
|
addOn: any[];
|
|
56
|
+
availability: string;
|
|
56
57
|
availableAtOrFrom: any[];
|
|
57
58
|
_id?: string | undefined;
|
|
58
59
|
name?: any;
|
|
@@ -68,7 +69,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
68
69
|
validFrom?: Date | undefined;
|
|
69
70
|
category?: any;
|
|
70
71
|
advanceBookingRequirement?: any;
|
|
71
|
-
availability?: string | undefined;
|
|
72
72
|
hasMerchantReturnPolicy?: any;
|
|
73
73
|
priceSpecification?: any;
|
|
74
74
|
eligibleCustomerType?: any;
|
|
@@ -84,6 +84,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
84
84
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
85
85
|
additionalProperty: any[];
|
|
86
86
|
addOn: any[];
|
|
87
|
+
availability: string;
|
|
87
88
|
availableAtOrFrom: any[];
|
|
88
89
|
_id?: string | undefined;
|
|
89
90
|
name?: any;
|
|
@@ -99,7 +100,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
99
100
|
validFrom?: Date | undefined;
|
|
100
101
|
category?: any;
|
|
101
102
|
advanceBookingRequirement?: any;
|
|
102
|
-
availability?: string | undefined;
|
|
103
103
|
hasMerchantReturnPolicy?: any;
|
|
104
104
|
priceSpecification?: any;
|
|
105
105
|
eligibleCustomerType?: any;
|
|
@@ -115,6 +115,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
115
115
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
116
116
|
additionalProperty: any[];
|
|
117
117
|
addOn: any[];
|
|
118
|
+
availability: string;
|
|
118
119
|
availableAtOrFrom: any[];
|
|
119
120
|
_id?: string | undefined;
|
|
120
121
|
name?: any;
|
|
@@ -130,7 +131,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
130
131
|
validFrom?: Date | undefined;
|
|
131
132
|
category?: any;
|
|
132
133
|
advanceBookingRequirement?: any;
|
|
133
|
-
availability?: string | undefined;
|
|
134
134
|
hasMerchantReturnPolicy?: any;
|
|
135
135
|
priceSpecification?: any;
|
|
136
136
|
eligibleCustomerType?: any;
|
|
@@ -6,7 +6,7 @@ const writeConcern_1 = require("../writeConcern");
|
|
|
6
6
|
const modelName = 'Offer';
|
|
7
7
|
exports.modelName = modelName;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 単価オファースキーマ
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose_1.Schema({
|
|
12
12
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -22,14 +22,13 @@ const schema = new mongoose_1.Schema({
|
|
|
22
22
|
alternateName: mongoose_1.SchemaTypes.Mixed,
|
|
23
23
|
// acceptedPaymentMethod: SchemaTypes.Mixed, // 削除(2023-02-27~)
|
|
24
24
|
addOn: [mongoose_1.SchemaTypes.Mixed],
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
availability: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
29
|
availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
|
|
30
30
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
31
31
|
itemOffered: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
-
// price: Number, // 削除(2023-02-27~)
|
|
33
32
|
priceCurrency: String,
|
|
34
33
|
priceSpecification: mongoose_1.SchemaTypes.Mixed,
|
|
35
34
|
eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
export type IProduct = factory.product.IProduct | factory.service.paymentService.IService;
|
|
28
|
-
export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'additionalProperty'> & {
|
|
28
|
+
export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'serviceOutput' | 'additionalProperty'> & {
|
|
29
29
|
provider?: Pick<factory.service.paymentService.IProvider, 'credentials'>;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
@@ -98,7 +98,6 @@ export declare class MongoRepository {
|
|
|
98
98
|
confirm<T extends factory.transactionType>(params: {
|
|
99
99
|
typeOf: T;
|
|
100
100
|
id: string;
|
|
101
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
102
101
|
result: factory.transaction.IResult<T>;
|
|
103
102
|
potentialActions: factory.transaction.IPotentialActions<T>;
|
|
104
103
|
}): Promise<void>;
|
|
@@ -190,6 +189,10 @@ export declare class MongoRepository {
|
|
|
190
189
|
findByIdAndDelete(params: {
|
|
191
190
|
id: string;
|
|
192
191
|
}): Promise<void>;
|
|
192
|
+
unsetUnnecessaryFields(params: {
|
|
193
|
+
filter: any;
|
|
194
|
+
$unset: any;
|
|
195
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
193
196
|
aggregatePlaceOrder(params: {
|
|
194
197
|
project?: {
|
|
195
198
|
id?: {
|
|
@@ -438,7 +438,7 @@ class MongoRepository {
|
|
|
438
438
|
}, {
|
|
439
439
|
status: factory.transactionStatusType.Confirmed,
|
|
440
440
|
endDate: new Date(),
|
|
441
|
-
'object.authorizeActions': params.authorizeActions,
|
|
441
|
+
// 'object.authorizeActions': params.authorizeActions,
|
|
442
442
|
result: params.result,
|
|
443
443
|
potentialActions: params.potentialActions // resultを更新
|
|
444
444
|
}, {
|
|
@@ -770,6 +770,12 @@ class MongoRepository {
|
|
|
770
770
|
.exec();
|
|
771
771
|
});
|
|
772
772
|
}
|
|
773
|
+
unsetUnnecessaryFields(params) {
|
|
774
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
775
|
+
return this.transactionModel.updateMany(params.filter, { $unset: params.$unset })
|
|
776
|
+
.exec();
|
|
777
|
+
});
|
|
778
|
+
}
|
|
773
779
|
aggregatePlaceOrder(params) {
|
|
774
780
|
return __awaiter(this, void 0, void 0, function* () {
|
|
775
781
|
const statuses = yield Promise.all([
|
|
@@ -6,6 +6,6 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
|
|
|
6
6
|
transactionNumber: string;
|
|
7
7
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
8
8
|
amount: number;
|
|
9
|
-
paymentService?: factory.service.paymentService.IService;
|
|
9
|
+
paymentService?: factory.service.paymentService.IService | factory.product.IProduct;
|
|
10
10
|
location?: factory.action.trade.pay.ILocation;
|
|
11
11
|
}): factory.assetTransaction.IStartParams<factory.assetTransactionType.Pay>;
|
|
@@ -5,9 +5,10 @@ exports.createStartParams = void 0;
|
|
|
5
5
|
* 決済取引ファクトリー
|
|
6
6
|
*/
|
|
7
7
|
const factory = require("../../../factory");
|
|
8
|
+
const settings_1 = require("../../../settings");
|
|
8
9
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
9
10
|
function createStartParams(params) {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
11
12
|
const paymentServiceId = (params.paymentService !== undefined)
|
|
12
13
|
? String(params.paymentService.id)
|
|
13
14
|
: '';
|
|
@@ -25,14 +26,14 @@ function createStartParams(params) {
|
|
|
25
26
|
totalPaymentDue = {
|
|
26
27
|
typeOf: 'MonetaryAmount',
|
|
27
28
|
currency: factory.priceCurrency.JPY,
|
|
28
|
-
value:
|
|
29
|
+
value: params.amount
|
|
29
30
|
};
|
|
30
31
|
break;
|
|
31
32
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
32
33
|
totalPaymentDue = {
|
|
33
34
|
typeOf: 'MonetaryAmount',
|
|
34
35
|
currency: factory.priceCurrency.JPY,
|
|
35
|
-
value:
|
|
36
|
+
value: params.amount
|
|
36
37
|
};
|
|
37
38
|
break;
|
|
38
39
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
@@ -54,36 +55,57 @@ function createStartParams(params) {
|
|
|
54
55
|
default:
|
|
55
56
|
// no op
|
|
56
57
|
}
|
|
57
|
-
const informPaymentParams = createInformPaymentParams({
|
|
58
|
+
const informPaymentParams = createInformPaymentParams({
|
|
59
|
+
paymentService: params.paymentService
|
|
60
|
+
});
|
|
58
61
|
const accountId = (_g = params.object.paymentMethod) === null || _g === void 0 ? void 0 : _g.accountId;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
// currencyはデフォルトでJPY
|
|
63
|
+
let paymentMethodCurrency = factory.priceCurrency.JPY;
|
|
64
|
+
if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.PaymentCard) {
|
|
65
|
+
const paymentCardServiceOutputCurrency = (_k = (_j = (_h = params.paymentService) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.amount) === null || _k === void 0 ? void 0 : _k.currency;
|
|
66
|
+
if (typeof paymentCardServiceOutputCurrency === 'string') {
|
|
67
|
+
paymentMethodCurrency = paymentCardServiceOutputCurrency;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
71
|
+
// カード通貨区分が存在すれば適用
|
|
72
|
+
const creditCardAsPaymentServiceOutputCurrency = (_p = (_o = (_m = (_l = params.paymentService) === null || _l === void 0 ? void 0 : _l.serviceOutput) === null || _m === void 0 ? void 0 : _m.paymentMethod) === null || _o === void 0 ? void 0 : _o.amount) === null || _p === void 0 ? void 0 : _p.currency;
|
|
73
|
+
if (typeof creditCardAsPaymentServiceOutputCurrency === 'string') {
|
|
74
|
+
paymentMethodCurrency = creditCardAsPaymentServiceOutputCurrency;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const paymentMethodAmount = {
|
|
78
|
+
typeOf: 'MonetaryAmount',
|
|
79
|
+
currency: paymentMethodCurrency,
|
|
80
|
+
value: params.amount
|
|
81
|
+
};
|
|
82
|
+
const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.additionalProperty))
|
|
83
|
+
? (_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.additionalProperty
|
|
84
|
+
: [], name: (typeof ((_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.name) === 'string')
|
|
63
85
|
? params.object.paymentMethod.name
|
|
64
|
-
: paymentMethodType,
|
|
65
|
-
|
|
86
|
+
: paymentMethodType,
|
|
87
|
+
// MonetaryAmount対応(2023-08-14~)
|
|
88
|
+
amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount, paymentMethodId: params.transactionNumber, typeOf: paymentMethodType }, (typeof ((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.description) === 'string')
|
|
89
|
+
? { description: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.description }
|
|
66
90
|
: undefined), (totalPaymentDue !== undefined)
|
|
67
91
|
? { totalPaymentDue: totalPaymentDue }
|
|
68
|
-
: undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((
|
|
69
|
-
? { method: (
|
|
70
|
-
: undefined), (((
|
|
71
|
-
? { creditCard: (
|
|
72
|
-
: undefined), (Array.isArray((
|
|
73
|
-
? { movieTickets: (
|
|
92
|
+
: undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.method) === 'string')
|
|
93
|
+
? { method: (_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.method }
|
|
94
|
+
: undefined), (((_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.creditCard) !== undefined)
|
|
95
|
+
? { creditCard: (_y = params.object.paymentMethod) === null || _y === void 0 ? void 0 : _y.creditCard }
|
|
96
|
+
: undefined), (Array.isArray((_z = params.object.paymentMethod) === null || _z === void 0 ? void 0 : _z.movieTickets))
|
|
97
|
+
? { movieTickets: (_0 = params.object.paymentMethod) === null || _0 === void 0 ? void 0 : _0.movieTickets }
|
|
74
98
|
: undefined);
|
|
75
|
-
const
|
|
76
|
-
? {
|
|
77
|
-
amount: {
|
|
78
|
-
currency: creditCardAsPaymentServiceOutputCurrency,
|
|
79
|
-
value: paymentMethod.amount // 通貨区分としての金額
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
: undefined;
|
|
83
|
-
const object = Object.assign({
|
|
99
|
+
const object = {
|
|
84
100
|
// パラメータから必要なもののみ取り込む
|
|
85
|
-
accountId: (typeof accountId === 'string') ? accountId : '',
|
|
86
|
-
|
|
101
|
+
accountId: (typeof accountId === 'string') ? accountId : '',
|
|
102
|
+
paymentMethodId: params.transactionNumber,
|
|
103
|
+
typeOf: params.paymentServiceType,
|
|
104
|
+
id: paymentServiceId,
|
|
105
|
+
onPaymentStatusChanged: { informPayment: informPaymentParams },
|
|
106
|
+
paymentMethod
|
|
107
|
+
};
|
|
108
|
+
return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_1 = params.location) === null || _1 === void 0 ? void 0 : _1.typeOf) === 'string')
|
|
87
109
|
? { location: params.location }
|
|
88
110
|
: undefined);
|
|
89
111
|
}
|
|
@@ -28,7 +28,7 @@ function createPayActions(params) {
|
|
|
28
28
|
}
|
|
29
29
|
return payActions;
|
|
30
30
|
}
|
|
31
|
-
// tslint:disable-next-line:cyclomatic-complexity
|
|
31
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
32
32
|
function createPayObject(params) {
|
|
33
33
|
var _a;
|
|
34
34
|
const transaction = params.transaction;
|
|
@@ -37,12 +37,20 @@ function createPayObject(params) {
|
|
|
37
37
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
38
38
|
const paymentMethodId = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId : transaction.id;
|
|
39
39
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
40
|
+
// MonetaryAmount対応(2023-08-13~)
|
|
41
|
+
const paymentMethodAmountValue = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount) === 'number')
|
|
42
|
+
? paymentMethod.amount
|
|
43
|
+
: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount.value;
|
|
40
44
|
const paymentServiceOutput = createPayObjectServiceOutput(params);
|
|
41
45
|
let payObject;
|
|
42
46
|
switch (transaction.object.typeOf) {
|
|
43
47
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
44
48
|
// 対面決済ではとりあえず問答無用にJPY
|
|
45
|
-
const totalPaymentDue4faceToFace = {
|
|
49
|
+
const totalPaymentDue4faceToFace = {
|
|
50
|
+
typeOf: 'MonetaryAmount',
|
|
51
|
+
currency: factory.priceCurrency.JPY,
|
|
52
|
+
value: paymentMethodAmountValue
|
|
53
|
+
};
|
|
46
54
|
payObject = {
|
|
47
55
|
typeOf: transaction.object.typeOf,
|
|
48
56
|
id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
|
|
@@ -52,7 +60,11 @@ function createPayObject(params) {
|
|
|
52
60
|
case factory.service.paymentService.PaymentServiceType.PaymentCard:
|
|
53
61
|
const totalPaymentDue = (typeof ((_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
54
62
|
? paymentMethod.totalPaymentDue
|
|
55
|
-
: {
|
|
63
|
+
: {
|
|
64
|
+
typeOf: 'MonetaryAmount',
|
|
65
|
+
currency: factory.priceCurrency.JPY,
|
|
66
|
+
value: paymentMethodAmountValue
|
|
67
|
+
};
|
|
56
68
|
payObject = {
|
|
57
69
|
typeOf: transaction.object.typeOf,
|
|
58
70
|
id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
|
|
@@ -68,11 +80,17 @@ function createPayObject(params) {
|
|
|
68
80
|
};
|
|
69
81
|
break;
|
|
70
82
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
71
|
-
payObject =
|
|
83
|
+
payObject = {
|
|
84
|
+
typeOf: transaction.object.typeOf,
|
|
85
|
+
id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
|
|
86
|
+
paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
|
|
72
87
|
typeOf: 'MonetaryAmount',
|
|
73
88
|
currency: factory.priceCurrency.JPY,
|
|
74
|
-
value:
|
|
75
|
-
}, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined)
|
|
89
|
+
value: paymentMethodAmountValue
|
|
90
|
+
}, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined)
|
|
91
|
+
// CreditCardIFのカード通貨区分を追加(2023-08-07~)
|
|
92
|
+
// ...(paymentServiceOutput !== undefined) ? { serviceOutput: paymentServiceOutput } : undefined
|
|
93
|
+
};
|
|
76
94
|
break;
|
|
77
95
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
78
96
|
payObject = Object.assign({ typeOf: transaction.object.typeOf, id: (typeof transaction.object.id === 'string') ? transaction.object.id : '', paymentMethod: {
|
|
@@ -94,7 +112,6 @@ function createPayObject(params) {
|
|
|
94
112
|
return payObject;
|
|
95
113
|
}
|
|
96
114
|
function createPayObjectServiceOutput(params) {
|
|
97
|
-
var _a, _b;
|
|
98
115
|
const transaction = params.transaction;
|
|
99
116
|
const paymentMethod = transaction.object.paymentMethod;
|
|
100
117
|
const order = params.order;
|
|
@@ -105,17 +122,21 @@ function createPayObjectServiceOutput(params) {
|
|
|
105
122
|
break;
|
|
106
123
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
107
124
|
// CreditCardIFのカード通貨区分を追加(2023-08-07~)
|
|
108
|
-
const creditCardAsPaymentServiceOutput
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
125
|
+
// const creditCardAsPaymentServiceOutput: factory.order.IOrderPaymentMethodIssuedThroughServiceOutput | undefined =
|
|
126
|
+
// (typeof transaction.object.paymentMethod?.amount !== 'number'
|
|
127
|
+
// && typeof transaction.object.paymentMethod?.amount?.currency === 'string')
|
|
128
|
+
// ? {
|
|
129
|
+
// paymentMethod: {
|
|
130
|
+
// amount: {
|
|
131
|
+
// currency: transaction.object.paymentMethod.amount.currency,
|
|
132
|
+
// value: transaction.object.paymentMethod.amount.value
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
// }
|
|
136
|
+
// : undefined;
|
|
137
|
+
// if (creditCardAsPaymentServiceOutput !== undefined) {
|
|
138
|
+
// paymentServiceOutput = creditCardAsPaymentServiceOutput;
|
|
139
|
+
// }
|
|
119
140
|
break;
|
|
120
141
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
121
142
|
const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf;
|
|
@@ -6,7 +6,7 @@ exports.createStartParams = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
const factory = require("../../../factory");
|
|
8
8
|
function createStartParams(params) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
10
10
|
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
11
11
|
if (typeof paymentMethodType !== 'string') {
|
|
12
12
|
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
@@ -23,7 +23,7 @@ function createStartParams(params) {
|
|
|
23
23
|
let refundFee;
|
|
24
24
|
if (((_g = params.paymentService) === null || _g === void 0 ? void 0 : _g.typeOf) === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
25
25
|
// カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
|
|
26
|
-
const paymentServiceOutputAmountCurrency = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.
|
|
26
|
+
const paymentServiceOutputAmountCurrency = (_k = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.paymentMethod) === null || _j === void 0 ? void 0 : _j.amount) === null || _k === void 0 ? void 0 : _k.currency;
|
|
27
27
|
if (typeof paymentServiceOutputAmountCurrency !== 'string') {
|
|
28
28
|
if (typeof params.object.refundFee === 'number') {
|
|
29
29
|
refundFee = params.object.refundFee;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
2
3
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
4
|
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
4
5
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
@@ -11,6 +12,7 @@ declare function deleteOrder(params: {
|
|
|
11
12
|
object: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'confirmationNumber' | 'orderDate' | 'orderNumber'>;
|
|
12
13
|
}): (repos: {
|
|
13
14
|
accountingReport: AccountingReportRepo;
|
|
15
|
+
event: EventRepo;
|
|
14
16
|
order: OrderRepo;
|
|
15
17
|
ownershipInfo: OwnershipInfoRepo;
|
|
16
18
|
reservation: ReservationRepo;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.deleteOrder = void 0;
|
|
13
13
|
const factory_1 = require("../delivery/factory");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
|
+
const settings_1 = require("../../settings");
|
|
15
16
|
/**
|
|
16
17
|
* 注文に関わるリソースを削除する
|
|
17
18
|
* 冪等性を確保すること
|
|
@@ -38,6 +39,10 @@ function deleteOrder(params) {
|
|
|
38
39
|
}
|
|
39
40
|
// 経理レポート削除
|
|
40
41
|
yield repos.accountingReport.deleteByOrderNumber({ mainEntity: { orderNumber: order.orderNumber } });
|
|
42
|
+
// 終了済の関連イベントを削除(2023-08-16~)
|
|
43
|
+
if (settings_1.USE_DELETE_EVENT_BY_ORDER) {
|
|
44
|
+
yield deleteEventsByOrder(order)(repos);
|
|
45
|
+
}
|
|
41
46
|
// 注文削除
|
|
42
47
|
yield repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
43
48
|
});
|
|
@@ -73,3 +78,40 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
73
78
|
}
|
|
74
79
|
});
|
|
75
80
|
}
|
|
81
|
+
function deleteEventsByOrder(order) {
|
|
82
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
85
|
+
const reservationForIds = acceptedOffers.filter((o) => {
|
|
86
|
+
return (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
87
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
88
|
+
&& typeof o.itemOffered.reservationFor.id === 'string';
|
|
89
|
+
})
|
|
90
|
+
.map((o) => {
|
|
91
|
+
return String(o.itemOffered.reservationFor.id);
|
|
92
|
+
});
|
|
93
|
+
if (reservationForIds.length > 0) {
|
|
94
|
+
for (const reservationForId of reservationForIds) {
|
|
95
|
+
// 関連注文が存在しなければ削除
|
|
96
|
+
const relatedOrders = yield repos.order.search({
|
|
97
|
+
limit: 1,
|
|
98
|
+
page: 1,
|
|
99
|
+
project: { id: { $eq: order.project.id } },
|
|
100
|
+
acceptedOffers: {
|
|
101
|
+
itemOffered: {
|
|
102
|
+
reservationFor: { ids: [reservationForId] }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, { _id: 1 });
|
|
106
|
+
if (relatedOrders.length === 0) {
|
|
107
|
+
yield repos.event.deleteManyEndedByIds({
|
|
108
|
+
typeOf: { $in: [factory.eventType.Event, factory.eventType.ScreeningEvent] },
|
|
109
|
+
project: { id: order.project.id },
|
|
110
|
+
ids: [reservationForId],
|
|
111
|
+
endDate: { $lte: now }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -80,28 +80,39 @@ function createMovieTicket(params) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function createAuthorizeResult(params) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f;
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
84
84
|
const payTransactionObject = params.payTransaction.object;
|
|
85
85
|
const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
|
|
86
86
|
if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
|
|
87
87
|
throw new factory.errors.ServiceUnavailable('payTransaction.object.paymentMethod.totalPaymentDue undefined');
|
|
88
88
|
}
|
|
89
|
-
const issuedThrough =
|
|
90
|
-
|
|
89
|
+
const issuedThrough = {
|
|
90
|
+
typeOf: payTransactionObject.typeOf,
|
|
91
|
+
id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : ''
|
|
92
|
+
};
|
|
93
|
+
// 決済取引から決済カード通貨区分を取り出す
|
|
94
|
+
const paymentMethodAmountCurrencyByPayTransaction = (typeof ((_b = payTransactionObject.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount) !== 'number')
|
|
95
|
+
? (_d = (_c = payTransactionObject.paymentMethod) === null || _c === void 0 ? void 0 : _c.amount) === null || _d === void 0 ? void 0 : _d.currency
|
|
96
|
+
: undefined;
|
|
97
|
+
const paymentMethodAsObject = Object.assign({ typeOf: params.object.paymentMethod }, (payTransactionObject.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
98
|
+
&& typeof paymentMethodAmountCurrencyByPayTransaction === 'string')
|
|
99
|
+
? { amount: { currency: paymentMethodAmountCurrencyByPayTransaction } }
|
|
91
100
|
: undefined);
|
|
92
101
|
return {
|
|
93
|
-
accountId: (typeof ((
|
|
102
|
+
accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
|
|
94
103
|
? payTransactionObject.paymentMethod.accountId
|
|
95
104
|
: '',
|
|
96
105
|
// 廃止(2023-08-07~)
|
|
97
106
|
// amount: params.object.amount,
|
|
98
107
|
issuedThrough,
|
|
99
|
-
|
|
108
|
+
// 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
|
|
109
|
+
// paymentMethod: params.object.paymentMethod,
|
|
110
|
+
paymentMethodAsObject,
|
|
100
111
|
paymentStatus: factory.paymentStatusType.PaymentDue,
|
|
101
|
-
paymentMethodId: (typeof ((
|
|
112
|
+
paymentMethodId: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.paymentMethodId) === 'string')
|
|
102
113
|
? payTransactionObject.paymentMethod.paymentMethodId
|
|
103
114
|
: '',
|
|
104
|
-
name: (typeof ((
|
|
115
|
+
name: (typeof ((_g = payTransactionObject.paymentMethod) === null || _g === void 0 ? void 0 : _g.name) === 'string')
|
|
105
116
|
? payTransactionObject.paymentMethod.name
|
|
106
117
|
: params.object.paymentMethod,
|
|
107
118
|
totalPaymentDue: totalPaymentDue,
|
|
@@ -114,7 +114,9 @@ function processAuthorizeCreditCard(params) {
|
|
|
114
114
|
shopPass: params.shopPass,
|
|
115
115
|
orderId: params.orderId,
|
|
116
116
|
jobCd: GMO.utils.util.JobCd.Auth,
|
|
117
|
-
amount: params.object.amount
|
|
117
|
+
amount: (typeof params.object.amount === 'number')
|
|
118
|
+
? params.object.amount
|
|
119
|
+
: params.object.amount.value,
|
|
118
120
|
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
119
121
|
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
120
122
|
};
|
|
@@ -127,7 +127,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
127
127
|
}
|
|
128
128
|
function processAccountTransaction(params) {
|
|
129
129
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f;
|
|
130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
131
|
let pendingTransaction;
|
|
132
132
|
const defaultName = `${factory.assetTransactionType.Pay} Transaction ${params.transactionNumber}`;
|
|
133
133
|
const agent = Object.assign(Object.assign({}, params.agent), { name: (typeof params.agent.name === 'string') ? params.agent.name : defaultName });
|
|
@@ -165,7 +165,11 @@ function processAccountTransaction(params) {
|
|
|
165
165
|
expires: params.expires,
|
|
166
166
|
recipient: recipient,
|
|
167
167
|
object: {
|
|
168
|
-
amount: {
|
|
168
|
+
amount: {
|
|
169
|
+
value: (typeof ((_f = params.paymentMethod) === null || _f === void 0 ? void 0 : _f.amount) === 'number')
|
|
170
|
+
? (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.amount
|
|
171
|
+
: (_h = params.paymentMethod) === null || _h === void 0 ? void 0 : _h.amount.value
|
|
172
|
+
},
|
|
169
173
|
description: description,
|
|
170
174
|
fromLocation: {
|
|
171
175
|
accountNumber: accountNumber
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const event_1 = require("../../repo/event");
|
|
16
17
|
const order_1 = require("../../repo/order");
|
|
17
18
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
18
19
|
const reservation_1 = require("../../repo/reservation");
|
|
@@ -28,6 +29,7 @@ function call(data) {
|
|
|
28
29
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
29
30
|
action: new action_1.MongoRepository(settings.connection),
|
|
30
31
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
32
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
31
33
|
order: new order_1.MongoRepository(settings.connection),
|
|
32
34
|
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
33
35
|
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
@@ -2,6 +2,7 @@ import * as factory from '../../factory';
|
|
|
2
2
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
5
6
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
6
7
|
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
8
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
@@ -15,6 +16,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
|
|
|
15
16
|
accountingReport: AccountingReportRepo;
|
|
16
17
|
action: ActionRepo;
|
|
17
18
|
assetTransaction: AssetTransactionRepo;
|
|
19
|
+
event: EventRepo;
|
|
18
20
|
order: OrderRepo;
|
|
19
21
|
ownershipInfo: OwnershipInfoRepo;
|
|
20
22
|
reservation: ReservationRepo;
|
|
@@ -14,12 +14,8 @@ function createStartParams(params, passport, seller, amount, fromLocation, toLoc
|
|
|
14
14
|
id: String(seller.id),
|
|
15
15
|
name: seller.name,
|
|
16
16
|
typeOf: seller.typeOf
|
|
17
|
-
// ↓最適化(2022-05-24~)
|
|
18
|
-
// ...{ project: seller.project }
|
|
19
17
|
},
|
|
20
|
-
object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation,
|
|
21
|
-
// authorizeActions: [],
|
|
22
|
-
pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
|
|
18
|
+
object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation, pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
|
|
23
19
|
? { identifier: params.object.pendingTransaction.identifier }
|
|
24
20
|
: undefined) }, (passport !== undefined) ? { passport } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined),
|
|
25
21
|
expires: params.expires
|
|
@@ -117,10 +117,6 @@ function createProductItems(params) {
|
|
|
117
117
|
exports.createProductItems = createProductItems;
|
|
118
118
|
function createMoneyTransferAcceptedOffers(params) {
|
|
119
119
|
// 通貨転送承認アクション
|
|
120
|
-
// const authorizeMoneyTansferActions = (<IAuthorizeMoneyTransferOffer[]>params.transaction.object.authorizeActions)
|
|
121
|
-
// .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
122
|
-
// .filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
123
|
-
// .filter((a) => a.object.itemOffered?.typeOf === factory.actionType.MoneyTransfer);
|
|
124
120
|
const authorizeMoneyTansferActions = params.authorizeActions
|
|
125
121
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
126
122
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
@@ -70,16 +70,18 @@ function createPaymentMethods(params) {
|
|
|
70
70
|
});
|
|
71
71
|
// 決済方法をセット
|
|
72
72
|
authorizePaymentActions.forEach((a) => {
|
|
73
|
+
var _a, _b, _c;
|
|
73
74
|
const result = a.result;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
75
|
+
const paymentMethodAmountCurrencyByAuthorizeAction = (_b = (_a = result.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
|
|
76
|
+
const paymentMethodOfInvoice = (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
77
|
+
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
78
|
+
: undefined;
|
|
79
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
80
|
+
const paymentMethodType = (_c = result.paymentMethodAsObject) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
81
|
+
if (typeof paymentMethodType !== 'string') {
|
|
82
|
+
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
|
+
}
|
|
84
|
+
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
83
85
|
});
|
|
84
86
|
// 決済方法から注文金額の計算
|
|
85
87
|
// price += authorizePaymentActions
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -11,14 +11,16 @@ const debug = createDebug('cinerino-domain:service:validateMovieTicket');
|
|
|
11
11
|
* 座席予約オファー承認に対してムビチケ承認条件が整っているかどうか検証する
|
|
12
12
|
*/
|
|
13
13
|
function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
|
|
14
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
15
14
|
const authorizeMovieTicketActions = authorizeActions.filter((a) => {
|
|
16
|
-
var _a, _b, _c;
|
|
15
|
+
var _a, _b, _c, _d;
|
|
17
16
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
18
17
|
&& ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
19
18
|
&& ((_b = a.result) === null || _b === void 0 ? void 0 : _b.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
20
|
+
&& ((_d = (_c = a.result) === null || _c === void 0 ? void 0 : _c.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf) === paymentMethodType;
|
|
21
|
+
}
|
|
22
|
+
// && a.result?.paymentMethod === paymentMethodType
|
|
23
|
+
);
|
|
22
24
|
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
23
25
|
&& a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
24
26
|
// 予約によって必要とされるMovieTicket
|
|
@@ -38,10 +38,7 @@ function validateTransaction(transaction, authorizeActions) {
|
|
|
38
38
|
validatePaymentUrl(transaction, authorizeActions);
|
|
39
39
|
}
|
|
40
40
|
exports.validateTransaction = validateTransaction;
|
|
41
|
-
function findMovieTicketPaymentMethodTypesFromTransaction(
|
|
42
|
-
// transaction: factory.transaction.placeOrder.ITransaction,
|
|
43
|
-
authorizeActions) {
|
|
44
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
41
|
+
function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
|
|
45
42
|
const authorizeMovieTicketPaymentActions = authorizeActions.filter((a) => {
|
|
46
43
|
var _a, _b;
|
|
47
44
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
@@ -55,9 +52,6 @@ authorizeActions) {
|
|
|
55
52
|
seatReservationAuthorizeActions.forEach((action) => {
|
|
56
53
|
var _a;
|
|
57
54
|
// a.objectではなくa.resultを使用する(2022-06-04~)
|
|
58
|
-
// const acceptedOffer =
|
|
59
|
-
// tslint:disable-next-line:max-line-length
|
|
60
|
-
// (<factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.Chevre>>action.object).acceptedOffer;
|
|
61
55
|
const acceptedOffers = (_a = action.result) === null || _a === void 0 ? void 0 : _a.acceptedOffers;
|
|
62
56
|
acceptedOffers === null || acceptedOffers === void 0 ? void 0 : acceptedOffers.forEach((offer) => {
|
|
63
57
|
var _a;
|
|
@@ -72,14 +66,15 @@ authorizeActions) {
|
|
|
72
66
|
});
|
|
73
67
|
});
|
|
74
68
|
const paymentMethodTypes = [
|
|
75
|
-
|
|
69
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
70
|
+
...authorizeMovieTicketPaymentActions.map((a) => { var _a, _b; return String((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf); }),
|
|
71
|
+
// ...authorizeMovieTicketPaymentActions.map((a) => String(a.result?.paymentMethod)),
|
|
76
72
|
...requiredMovieTicketPaymentMethodTypes
|
|
77
73
|
];
|
|
78
74
|
return [...new Set(paymentMethodTypes)];
|
|
79
75
|
}
|
|
80
76
|
function validateProfile(transaction) {
|
|
81
77
|
// object.customerで検証(2022-05-26~)
|
|
82
|
-
// const profile = transaction.agent;
|
|
83
78
|
const profile = transaction.object.customer;
|
|
84
79
|
if (typeof (profile === null || profile === void 0 ? void 0 : profile.email) !== 'string' || (profile === null || profile === void 0 ? void 0 : profile.email.length) === 0
|
|
85
80
|
|| typeof (profile === null || profile === void 0 ? void 0 : profile.familyName) !== 'string' || (profile === null || profile === void 0 ? void 0 : profile.familyName.length) === 0
|
|
@@ -89,7 +84,6 @@ function validateProfile(transaction) {
|
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
function validatePrice(transaction, authorizeActions) {
|
|
92
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
93
87
|
let priceByAgent = 0;
|
|
94
88
|
let priceBySeller = 0;
|
|
95
89
|
// 決済承認を確認
|
|
@@ -121,7 +115,6 @@ function validatePrice(transaction, authorizeActions) {
|
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
function validatePaymentUrl(transaction, authorizeActions) {
|
|
124
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
125
118
|
var _a, _b;
|
|
126
119
|
// 決済URLが発行されている場合、検証
|
|
127
120
|
const paymentMethodId = (_a = transaction.object.paymentMethods) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
|
|
@@ -145,10 +138,7 @@ function validatePaymentUrl(transaction, authorizeActions) {
|
|
|
145
138
|
/**
|
|
146
139
|
* JPY以外の通貨について取引を検証する
|
|
147
140
|
*/
|
|
148
|
-
function validateMonetaryAmount(
|
|
149
|
-
// transaction: factory.transaction.placeOrder.ITransaction,
|
|
150
|
-
authorizeActions) {
|
|
151
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
141
|
+
function validateMonetaryAmount(authorizeActions) {
|
|
152
142
|
const authorizeMonetaryAmountActions = authorizeActions
|
|
153
143
|
.filter((a) => {
|
|
154
144
|
var _a, _b;
|
|
@@ -216,7 +206,7 @@ function validatePaymentMethods(params) {
|
|
|
216
206
|
const creditCardPaymentMethodCount = params.order.paymentMethods.filter((p) => {
|
|
217
207
|
var _a, _b;
|
|
218
208
|
// カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
|
|
219
|
-
const serviceOutputAmountCurrency = (_b = (_a = p.
|
|
209
|
+
const serviceOutputAmountCurrency = (_b = (_a = p.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
|
|
220
210
|
return p.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
221
211
|
&& typeof serviceOutputAmountCurrency !== 'string';
|
|
222
212
|
}).length;
|
|
@@ -230,10 +220,6 @@ exports.validatePaymentMethods = validatePaymentMethods;
|
|
|
230
220
|
* イベントオファー適用条件確認
|
|
231
221
|
*/
|
|
232
222
|
function validateEventOffers(params) {
|
|
233
|
-
// const seatReservationAuthorizeActions = <IAuthorizeSeatReservationOffer[]>
|
|
234
|
-
// params.transaction.object.authorizeActions
|
|
235
|
-
// .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
236
|
-
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
237
223
|
const seatReservationAuthorizeActions = params.authorizeActions
|
|
238
224
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
239
225
|
.filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
@@ -102,7 +102,6 @@ function confirm(params) {
|
|
|
102
102
|
}
|
|
103
103
|
// 取引に対する全ての承認アクションをマージ
|
|
104
104
|
const authorizeActions = yield searchAuthorizeActions(params)(repos);
|
|
105
|
-
// transaction.object.authorizeActions = authorizeActions;
|
|
106
105
|
// 注文番号を発行
|
|
107
106
|
const orderNumber = yield publishOrderNumberIfNotExist({
|
|
108
107
|
project: { id: transaction.project.id },
|
|
@@ -134,8 +133,6 @@ function confirm(params) {
|
|
|
134
133
|
yield repos.transaction.confirm({
|
|
135
134
|
typeOf: transaction.typeOf,
|
|
136
135
|
id: transaction.id,
|
|
137
|
-
// 保管有無を設定化(2023-05-16~)
|
|
138
|
-
authorizeActions: [],
|
|
139
136
|
result: result,
|
|
140
137
|
potentialActions: potentialActions
|
|
141
138
|
});
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
|
40
40
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
41
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
42
42
|
export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
43
|
+
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
44
|
+
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
43
45
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
44
46
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
45
47
|
/**
|
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.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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 = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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 = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -72,6 +72,8 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
72
72
|
// ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
73
73
|
// : [];
|
|
74
74
|
exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
|
|
75
|
+
exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
|
|
76
|
+
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
75
77
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
76
78
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
77
79
|
: 0;
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.325.0-alpha.5",
|
|
13
|
+
"@cinerino/sdk": "3.164.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.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.7.0-alpha.
|
|
120
|
+
"version": "21.7.0-alpha.10"
|
|
121
121
|
}
|
|
@@ -1,119 +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 reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
15
|
-
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = reservationRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
typeOf: {
|
|
20
|
-
$in: [
|
|
21
|
-
chevre.factory.reservationType.EventReservation
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
|
-
// bookingTime: {
|
|
25
|
-
// $gte: moment('2022-07-01T00:00:00Z')
|
|
26
|
-
// .toDate(),
|
|
27
|
-
// $lte: moment('2022-03-01T00:00:00Z')
|
|
28
|
-
// .toDate()
|
|
29
|
-
// },
|
|
30
|
-
'provider.id': { $exists: false }
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
_id: 1,
|
|
34
|
-
project: 1,
|
|
35
|
-
provider: 1,
|
|
36
|
-
bookingTime: 1,
|
|
37
|
-
reservationFor: 1
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
console.log('reservations found');
|
|
41
|
-
|
|
42
|
-
let i = 0;
|
|
43
|
-
let updateCount = 0;
|
|
44
|
-
await cursor.eachAsync(async (doc) => {
|
|
45
|
-
i += 1;
|
|
46
|
-
const reservation: Pick<
|
|
47
|
-
chevre.factory.reservation.IReservation<chevre.factory.reservationType.EventReservation>,
|
|
48
|
-
'id' | 'project' | 'provider' | 'bookingTime' | 'reservationFor'
|
|
49
|
-
> = doc.toObject();
|
|
50
|
-
|
|
51
|
-
const providerId = reservation.provider?.id;
|
|
52
|
-
const alreadyMigrated = typeof providerId === 'string';
|
|
53
|
-
|
|
54
|
-
if (alreadyMigrated) {
|
|
55
|
-
console.log('already exist...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
56
|
-
} else {
|
|
57
|
-
const movieTheaterId: string = reservation.reservationFor.superEvent.location.id;
|
|
58
|
-
const movieTheaterBranchCode: string = reservation.reservationFor.superEvent.location.branchCode;
|
|
59
|
-
const movieTheaters = <Pick<
|
|
60
|
-
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
61
|
-
'parentOrganization' | 'branchCode'
|
|
62
|
-
>[]>
|
|
63
|
-
await placeRepo.searchMovieTheaters(
|
|
64
|
-
{
|
|
65
|
-
limit: 1,
|
|
66
|
-
page: 1,
|
|
67
|
-
project: { id: { $eq: reservation.project.id } },
|
|
68
|
-
id: { $eq: movieTheaterId }
|
|
69
|
-
},
|
|
70
|
-
['parentOrganization', 'branchCode'],
|
|
71
|
-
[]
|
|
72
|
-
);
|
|
73
|
-
const movieTheater = movieTheaters.shift();
|
|
74
|
-
const sellerId = movieTheater?.parentOrganization?.id;
|
|
75
|
-
console.log(
|
|
76
|
-
'movieTheater found',
|
|
77
|
-
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
78
|
-
'movieTheaterId:', movieTheaterId,
|
|
79
|
-
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
80
|
-
i
|
|
81
|
-
);
|
|
82
|
-
if (typeof sellerId !== 'string') {
|
|
83
|
-
console.error(
|
|
84
|
-
'movieTheater not found',
|
|
85
|
-
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
86
|
-
'movieTheaterId:', movieTheaterId,
|
|
87
|
-
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
88
|
-
i
|
|
89
|
-
);
|
|
90
|
-
throw new Error('movieTheater not found');
|
|
91
|
-
|
|
92
|
-
// return;
|
|
93
|
-
}
|
|
94
|
-
if (typeof sellerId === 'string') {
|
|
95
|
-
const newProvider: chevre.factory.reservation.IProvider = {
|
|
96
|
-
id: sellerId,
|
|
97
|
-
typeOf: chevre.factory.organizationType.Corporation
|
|
98
|
-
};
|
|
99
|
-
console.log(
|
|
100
|
-
'updating reservation...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
101
|
-
await reservationRepo.updatePartiallyById({
|
|
102
|
-
id: reservation.id,
|
|
103
|
-
update: <any>{
|
|
104
|
-
provider: newProvider
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
updateCount += 1;
|
|
108
|
-
console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
console.log(i, 'reservations checked');
|
|
114
|
-
console.log(updateCount, 'reservations updated');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
main()
|
|
118
|
-
.then()
|
|
119
|
-
.catch(console.error);
|