@chevre/domain 21.6.0-alpha.1 → 21.6.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/createManyEventsIfNotExist.ts +0 -2
- package/example/src/chevre/migrateMovieAvailabilityStarts.ts +11 -0
- package/example/src/chevre/searchSellers.ts +28 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +18 -6
- package/lib/chevre/repo/mongoose/schemas/seller.js +12 -0
- package/lib/chevre/repo/seller.js +14 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +33 -29
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +21 -26
- package/lib/chevre/service/assetTransaction/pay.js +0 -3
- package/lib/chevre/service/event.js +3 -7
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -3
- package/lib/chevre/service/order/placeOrder.js +10 -5
- package/lib/chevre/service/order/returnOrder.js +5 -1
- package/lib/chevre/service/order/sendOrder.js +5 -1
- package/lib/chevre/service/payment/any/factory.js +10 -9
- package/lib/chevre/service/payment/movieTicket.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +52 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +15 -15
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +15 -42
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +15 -15
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +5 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +5 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +14 -7
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +10 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +5 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -21
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +5 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +5 -4
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +17 -13
- package/lib/chevre/service/transaction/returnOrder.js +124 -95
- package/package.json +3 -3
|
@@ -105,7 +105,6 @@ async function main() {
|
|
|
105
105
|
},
|
|
106
106
|
offers: {
|
|
107
107
|
typeOf: chevre.factory.offerType.Offer,
|
|
108
|
-
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
109
108
|
availabilityEnds: moment('2023-06-26T14:20:00.000Z')
|
|
110
109
|
.toDate(),
|
|
111
110
|
availabilityStarts: moment('2023-06-23T15:00:00.000Z')
|
|
@@ -275,7 +274,6 @@ async function main() {
|
|
|
275
274
|
},
|
|
276
275
|
offers: {
|
|
277
276
|
typeOf: chevre.factory.offerType.Offer,
|
|
278
|
-
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
279
277
|
availabilityEnds: moment('2023-06-26T14:20:00.000Z')
|
|
280
278
|
.toDate(),
|
|
281
279
|
availabilityStarts: moment('2023-06-23T15:00:00.000Z')
|
|
@@ -24,6 +24,7 @@ async function main() {
|
|
|
24
24
|
let i = 0;
|
|
25
25
|
let updateCount = 0;
|
|
26
26
|
let datePublishedUndefinedCount = 0;
|
|
27
|
+
let datePublishedIsAfterNowCount = 0;
|
|
27
28
|
await cursor.eachAsync(async (doc) => {
|
|
28
29
|
i += 1;
|
|
29
30
|
const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
|
|
@@ -38,6 +39,14 @@ async function main() {
|
|
|
38
39
|
|
|
39
40
|
if (alreadyMigrated) {
|
|
40
41
|
console.log('already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
42
|
+
|
|
43
|
+
if (moment(movie.datePublished)
|
|
44
|
+
.isAfter(moment())) {
|
|
45
|
+
datePublishedIsAfterNowCount += 1;
|
|
46
|
+
// tslint:disable-next-line:max-line-length
|
|
47
|
+
// throw new Error(`movie.datePublished isAfter now ${movie.project.id} ${movie.id} ${movie.identifier} ${movie.datePublished}`);
|
|
48
|
+
|
|
49
|
+
}
|
|
41
50
|
} else {
|
|
42
51
|
if (movie.datePublished === undefined) {
|
|
43
52
|
console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
|
|
@@ -63,6 +72,8 @@ async function main() {
|
|
|
63
72
|
console.log(i, 'creativeWorks checked');
|
|
64
73
|
console.log(updateCount, 'creativeWorks updated');
|
|
65
74
|
console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
|
|
75
|
+
console.log(datePublishedIsAfterNowCount, 'datePublishedIsAfterNowCount');
|
|
76
|
+
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
main()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const sellers = await sellerRepo.search(
|
|
14
|
+
{
|
|
15
|
+
project: { id: { $eq: project.id } },
|
|
16
|
+
paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
17
|
+
hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
18
|
+
},
|
|
19
|
+
['name'],
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
console.log('sellers found', sellers);
|
|
23
|
+
console.log(sellers.length, 'sellers found');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then()
|
|
28
|
+
.catch(console.error);
|
|
@@ -4,16 +4,28 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
6
|
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
13
|
-
filter: { '
|
|
14
|
-
$unset: { '
|
|
12
|
+
updateResult = await eventRepo.unsetUnnecessaryFields({
|
|
13
|
+
filter: { 'offers.acceptedPaymentMethod': { $exists: true } },
|
|
14
|
+
$unset: { 'offers.acceptedPaymentMethod': 1 }
|
|
15
15
|
});
|
|
16
|
-
console.log('
|
|
16
|
+
console.log('events unset', updateResult);
|
|
17
|
+
|
|
18
|
+
updateResult = await eventRepo.unsetUnnecessaryFields({
|
|
19
|
+
filter: { 'offers.project': { $exists: true } },
|
|
20
|
+
$unset: { 'offers.project': 1 }
|
|
21
|
+
});
|
|
22
|
+
console.log('events unset', updateResult);
|
|
23
|
+
|
|
24
|
+
updateResult = await eventRepo.unsetUnnecessaryFields({
|
|
25
|
+
filter: { 'offers.priceCurrency': { $exists: true } },
|
|
26
|
+
$unset: { 'offers.priceCurrency': 1 }
|
|
27
|
+
});
|
|
28
|
+
console.log('events unset', updateResult);
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
main()
|
|
@@ -75,6 +75,18 @@ schema.index({ additionalProperty: 1, branchCode: 1 }, {
|
|
|
75
75
|
additionalProperty: { $exists: true }
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
schema.index({ 'paymentAccepted.paymentMethodType': 1, branchCode: 1 }, {
|
|
79
|
+
name: 'searchByPaymentAccepted',
|
|
80
|
+
partialFilterExpression: {
|
|
81
|
+
'paymentAccepted.paymentMethodType': { $exists: true }
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
schema.index({ 'hasMerchantReturnPolicy.applicablePaymentMethod': 1, branchCode: 1 }, {
|
|
85
|
+
name: 'searchByHasMerchantReturnPolicyApplicablePaymentMethod',
|
|
86
|
+
partialFilterExpression: {
|
|
87
|
+
'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true }
|
|
88
|
+
}
|
|
89
|
+
});
|
|
78
90
|
schema.index({ 'hasMerchantReturnPolicy.itemCondition.id': 1, branchCode: 1 }, {
|
|
79
91
|
name: 'searchByHasMerchantReturnPolicyItemConditionId',
|
|
80
92
|
partialFilterExpression: {
|
|
@@ -34,7 +34,7 @@ class MongoRepository {
|
|
|
34
34
|
}
|
|
35
35
|
// tslint:disable-next-line:max-func-body-length
|
|
36
36
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
37
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
38
38
|
// MongoDB検索条件
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -120,7 +120,19 @@ class MongoRepository {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const paymentAcceptedEq = (_p = (_o = params.paymentAccepted) === null || _o === void 0 ? void 0 : _o.paymentMethodType) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
124
|
+
if (typeof paymentAcceptedEq === 'string') {
|
|
125
|
+
andConditions.push({
|
|
126
|
+
'paymentAccepted.paymentMethodType': { $exists: true, $eq: paymentAcceptedEq }
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const hasMerchantReturnApplicablePaymentMethodEq = (_r = (_q = params.hasMerchantReturnPolicy) === null || _q === void 0 ? void 0 : _q.applicablePaymentMethod) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
130
|
+
if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
|
|
131
|
+
andConditions.push({
|
|
132
|
+
'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const hasMerchantReturnPolicyItemConditionIdEq = (_u = (_t = (_s = params.hasMerchantReturnPolicy) === null || _s === void 0 ? void 0 : _s.itemCondition) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
124
136
|
if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
125
137
|
andConditions.push({
|
|
126
138
|
'hasMerchantReturnPolicy.itemCondition.id': {
|
|
@@ -7,7 +7,7 @@ exports.createStartParams = void 0;
|
|
|
7
7
|
const factory = require("../../../factory");
|
|
8
8
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
9
9
|
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;
|
|
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
11
|
const paymentServiceId = (params.paymentService !== undefined)
|
|
12
12
|
? String(params.paymentService.id)
|
|
13
13
|
: '';
|
|
@@ -36,15 +36,14 @@ function createStartParams(params) {
|
|
|
36
36
|
};
|
|
37
37
|
break;
|
|
38
38
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
39
|
+
const specifiedMovieTickets = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.movieTickets;
|
|
39
40
|
totalPaymentDue = {
|
|
40
41
|
typeOf: 'MonetaryAmount',
|
|
41
42
|
currency: factory.unitCode.C62,
|
|
42
|
-
value: (Array.isArray(
|
|
43
|
-
? (_d = params.object.paymentMethod) === null || _d === void 0 ? void 0 : _d.movieTickets.length
|
|
44
|
-
: 0
|
|
43
|
+
value: (Array.isArray(specifiedMovieTickets)) ? specifiedMovieTickets.length : 0
|
|
45
44
|
};
|
|
46
45
|
// MovieTicketIFの決済取引において最大同時着券数を設定可能にする(2023-03-27~)
|
|
47
|
-
const totalPaymentDueMaxValue = (
|
|
46
|
+
const totalPaymentDueMaxValue = (_f = (_e = (_d = params.paymentService) === null || _d === void 0 ? void 0 : _d.availableChannel) === null || _e === void 0 ? void 0 : _e.totalPaymentDue) === null || _f === void 0 ? void 0 : _f.maxValue;
|
|
48
47
|
const totalPaymentDueValue = totalPaymentDue.value;
|
|
49
48
|
if (typeof totalPaymentDueValue === 'number' && typeof totalPaymentDueMaxValue === 'number') {
|
|
50
49
|
if (totalPaymentDueValue > totalPaymentDueMaxValue) {
|
|
@@ -56,30 +55,35 @@ function createStartParams(params) {
|
|
|
56
55
|
// no op
|
|
57
56
|
}
|
|
58
57
|
const informPaymentParams = createInformPaymentParams({ paymentService: params.paymentService });
|
|
59
|
-
const accountId = (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
58
|
+
const accountId = (_g = params.object.paymentMethod) === null || _g === void 0 ? void 0 : _g.accountId;
|
|
59
|
+
const creditCardAsPaymentServiceOutputCurrency = (_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;
|
|
60
|
+
const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_l = params.object.paymentMethod) === null || _l === void 0 ? void 0 : _l.additionalProperty))
|
|
61
|
+
? (_m = params.object.paymentMethod) === null || _m === void 0 ? void 0 : _m.additionalProperty
|
|
62
|
+
: [], name: (typeof ((_o = params.object.paymentMethod) === null || _o === void 0 ? void 0 : _o.name) === 'string')
|
|
63
|
+
? params.object.paymentMethod.name
|
|
64
|
+
: paymentMethodType, amount: params.amount, paymentMethodId: params.transactionNumber, typeOf: paymentMethodType }, (typeof ((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.description) === 'string')
|
|
65
|
+
? { description: (_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.description }
|
|
66
|
+
: undefined), (totalPaymentDue !== undefined)
|
|
67
|
+
? { totalPaymentDue: totalPaymentDue }
|
|
68
|
+
: undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.method) === 'string')
|
|
69
|
+
? { method: (_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.method }
|
|
70
|
+
: undefined), (((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.creditCard) !== undefined)
|
|
71
|
+
? { creditCard: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.creditCard }
|
|
72
|
+
: undefined), (Array.isArray((_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.movieTickets))
|
|
73
|
+
? { movieTickets: (_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.movieTickets }
|
|
74
|
+
: undefined);
|
|
75
|
+
const serviceOutput = (typeof creditCardAsPaymentServiceOutputCurrency === 'string')
|
|
76
|
+
? {
|
|
77
|
+
amount: {
|
|
78
|
+
currency: creditCardAsPaymentServiceOutputCurrency,
|
|
79
|
+
value: paymentMethod.amount // 通貨区分としての金額
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
: undefined;
|
|
83
|
+
const object = Object.assign({
|
|
84
|
+
// パラメータから必要なもののみ取り込む
|
|
85
|
+
accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: params.transactionNumber, typeOf: params.paymentServiceType, id: paymentServiceId, onPaymentStatusChanged: { informPayment: informPaymentParams }, paymentMethod }, (typeof serviceOutput !== undefined) ? { serviceOutput } : undefined);
|
|
86
|
+
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 ((_x = params.location) === null || _x === void 0 ? void 0 : _x.typeOf) === 'string')
|
|
83
87
|
? { location: params.location }
|
|
84
88
|
: undefined);
|
|
85
89
|
}
|
|
@@ -9,17 +9,6 @@ function createPayActions(params) {
|
|
|
9
9
|
const payObject = createPayObject(params);
|
|
10
10
|
const informPaymentActions = createInformPaymentActions(params);
|
|
11
11
|
if (payObject !== undefined) {
|
|
12
|
-
// const maskedCustomer = createMaskedCustomer(params.order);
|
|
13
|
-
// const simpleOrder: factory.order.ISimpleOrder = {
|
|
14
|
-
// typeOf: params.order.typeOf,
|
|
15
|
-
// seller: params.order.seller,
|
|
16
|
-
// // mask
|
|
17
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
18
|
-
// orderNumber: params.order.orderNumber,
|
|
19
|
-
// price: params.order.price,
|
|
20
|
-
// priceCurrency: params.order.priceCurrency,
|
|
21
|
-
// orderDate: params.order.orderDate
|
|
22
|
-
// };
|
|
23
12
|
const payPurpose = {
|
|
24
13
|
typeOf: params.order.typeOf,
|
|
25
14
|
confirmationNumber: params.order.confirmationNumber,
|
|
@@ -28,10 +17,7 @@ function createPayActions(params) {
|
|
|
28
17
|
const payAction = Object.assign({ project: params.transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: params.transaction.project, potentialActions: {
|
|
29
18
|
add2report: true,
|
|
30
19
|
informPayment: informPaymentActions
|
|
31
|
-
},
|
|
32
|
-
// optimize(2023-03-20~)
|
|
33
|
-
// purpose: simpleOrder,
|
|
34
|
-
purpose: payPurpose, recipient: {
|
|
20
|
+
}, purpose: payPurpose, recipient: {
|
|
35
21
|
id: params.transaction.recipient.id,
|
|
36
22
|
name: params.transaction.recipient.name,
|
|
37
23
|
typeOf: params.transaction.recipient.typeOf
|
|
@@ -42,8 +28,9 @@ function createPayActions(params) {
|
|
|
42
28
|
}
|
|
43
29
|
return payActions;
|
|
44
30
|
}
|
|
31
|
+
// tslint:disable-next-line:cyclomatic-complexity
|
|
45
32
|
function createPayObject(params) {
|
|
46
|
-
var _a
|
|
33
|
+
var _a;
|
|
47
34
|
const transaction = params.transaction;
|
|
48
35
|
const paymentMethod = transaction.object.paymentMethod;
|
|
49
36
|
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
|
|
@@ -81,15 +68,11 @@ function createPayObject(params) {
|
|
|
81
68
|
};
|
|
82
69
|
break;
|
|
83
70
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
84
|
-
payObject = {
|
|
85
|
-
typeOf: transaction.object.typeOf,
|
|
86
|
-
id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
|
|
87
|
-
paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
|
|
71
|
+
payObject = Object.assign({ typeOf: transaction.object.typeOf, id: (typeof transaction.object.id === 'string') ? transaction.object.id : '', paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
|
|
88
72
|
typeOf: 'MonetaryAmount',
|
|
89
73
|
currency: factory.priceCurrency.JPY,
|
|
90
74
|
value: Number(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount)
|
|
91
|
-
}, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined)
|
|
92
|
-
};
|
|
75
|
+
}, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined) }, (paymentServiceOutput !== undefined) ? { serviceOutput: paymentServiceOutput } : undefined);
|
|
93
76
|
break;
|
|
94
77
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
95
78
|
payObject = Object.assign({ typeOf: transaction.object.typeOf, id: (typeof transaction.object.id === 'string') ? transaction.object.id : '', paymentMethod: {
|
|
@@ -100,7 +83,7 @@ function createPayObject(params) {
|
|
|
100
83
|
totalPaymentDue: {
|
|
101
84
|
typeOf: 'MonetaryAmount',
|
|
102
85
|
currency: factory.unitCode.C62,
|
|
103
|
-
value: (
|
|
86
|
+
value: (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? paymentMethod.movieTickets.length : 0
|
|
104
87
|
},
|
|
105
88
|
typeOf: paymentMethodType
|
|
106
89
|
}, movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets }, (Array.isArray(paymentServiceOutput)) ? { serviceOutput: paymentServiceOutput } : undefined);
|
|
@@ -111,6 +94,7 @@ function createPayObject(params) {
|
|
|
111
94
|
return payObject;
|
|
112
95
|
}
|
|
113
96
|
function createPayObjectServiceOutput(params) {
|
|
97
|
+
var _a, _b;
|
|
114
98
|
const transaction = params.transaction;
|
|
115
99
|
const paymentMethod = transaction.object.paymentMethod;
|
|
116
100
|
const order = params.order;
|
|
@@ -118,7 +102,20 @@ function createPayObjectServiceOutput(params) {
|
|
|
118
102
|
switch (transaction.object.typeOf) {
|
|
119
103
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
120
104
|
case factory.service.paymentService.PaymentServiceType.PaymentCard:
|
|
105
|
+
break;
|
|
121
106
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
107
|
+
// CreditCardIFのカード通貨区分を追加(2023-08-07~)
|
|
108
|
+
const creditCardAsPaymentServiceOutput = (typeof ((_b = (_a = transaction.object.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency) === 'string')
|
|
109
|
+
? {
|
|
110
|
+
amount: {
|
|
111
|
+
currency: transaction.object.serviceOutput.amount.currency,
|
|
112
|
+
value: transaction.object.paymentMethod.amount
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
: undefined;
|
|
116
|
+
if (creditCardAsPaymentServiceOutput !== undefined) {
|
|
117
|
+
paymentServiceOutput = creditCardAsPaymentServiceOutput;
|
|
118
|
+
}
|
|
122
119
|
break;
|
|
123
120
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
124
121
|
const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf;
|
|
@@ -129,9 +126,7 @@ function createPayObjectServiceOutput(params) {
|
|
|
129
126
|
const amount = movieTicket2amount(transaction, movieTicket);
|
|
130
127
|
const reservation4invoice = movieTicket2reservation4invoice(movieTicket, order, String(paymentMethodType));
|
|
131
128
|
return Object.assign(Object.assign({ identifier: movieTicket.identifier }, (typeof (amount === null || amount === void 0 ? void 0 : amount.value) === 'number') ? { amount } : undefined), (typeof ((_a = reservation4invoice.priceSpecification) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
132
|
-
? {
|
|
133
|
-
serviceOutput: reservation4invoice
|
|
134
|
-
}
|
|
129
|
+
? { serviceOutput: reservation4invoice }
|
|
135
130
|
: undefined);
|
|
136
131
|
});
|
|
137
132
|
}
|
|
@@ -243,9 +243,6 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
243
243
|
typeOf: 'MonetaryAmount',
|
|
244
244
|
currency,
|
|
245
245
|
value: amount
|
|
246
|
-
// value: (typeof pendingTransaction.object.amount === 'number')
|
|
247
|
-
// ? pendingTransaction.object.amount
|
|
248
|
-
// : pendingTransaction.object.amount.value
|
|
249
246
|
};
|
|
250
247
|
const savingPendingTransaction = {
|
|
251
248
|
typeOf: pendingTransaction.typeOf,
|
|
@@ -455,14 +455,13 @@ function createScreeningEventFromCOA(params) {
|
|
|
455
455
|
.toDate();
|
|
456
456
|
}
|
|
457
457
|
const offers = {
|
|
458
|
-
// 不要なので廃止(2022-12-19~)
|
|
459
|
-
// project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
460
458
|
typeOf: factory.offerType.Offer,
|
|
461
459
|
offeredThrough: {
|
|
462
460
|
typeOf: 'WebAPI',
|
|
463
461
|
identifier: factory.service.webAPI.Identifier.COA
|
|
464
462
|
},
|
|
465
|
-
|
|
463
|
+
// 廃止(2023-08-07~)
|
|
464
|
+
// priceCurrency: factory.priceCurrency.JPY,
|
|
466
465
|
itemOffered: {
|
|
467
466
|
serviceOutput: {
|
|
468
467
|
reservedTicket: {
|
|
@@ -605,10 +604,7 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
605
604
|
endDate: endDate,
|
|
606
605
|
startDate: startDate,
|
|
607
606
|
coaInfo,
|
|
608
|
-
offers: Object.assign({
|
|
609
|
-
// 不要なので廃止(2023-06-09~)
|
|
610
|
-
// project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
611
|
-
typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
|
|
607
|
+
offers: Object.assign({ typeOf: factory.offerType.Offer }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
|
|
612
608
|
additionalProperty
|
|
613
609
|
};
|
|
614
610
|
}
|
|
@@ -27,10 +27,12 @@ function onOrderStatusChanged(params) {
|
|
|
27
27
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
28
28
|
const simpleOrder = {
|
|
29
29
|
typeOf: params.order.typeOf,
|
|
30
|
-
seller:
|
|
30
|
+
seller: {
|
|
31
|
+
id: params.order.seller.id,
|
|
32
|
+
typeOf: params.order.seller.typeOf,
|
|
33
|
+
name: params.order.seller.name
|
|
34
|
+
},
|
|
31
35
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
32
|
-
// IOrderへ移行(2022-11-17~)
|
|
33
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
34
36
|
orderNumber: params.order.orderNumber,
|
|
35
37
|
price: params.order.price,
|
|
36
38
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -107,12 +107,13 @@ function placeOrderWithoutTransaction(params) {
|
|
|
107
107
|
// アクションを作成する(2022-04-11~)
|
|
108
108
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
109
109
|
const simpleOrder = {
|
|
110
|
-
// project: order.project,
|
|
111
110
|
typeOf: order.typeOf,
|
|
112
|
-
seller:
|
|
111
|
+
seller: {
|
|
112
|
+
id: order.seller.id,
|
|
113
|
+
typeOf: order.seller.typeOf,
|
|
114
|
+
name: order.seller.name
|
|
115
|
+
},
|
|
113
116
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
114
|
-
// IOrderへ移行(2022-11-17~)
|
|
115
|
-
// confirmationNumber: order.confirmationNumber,
|
|
116
117
|
orderNumber: order.orderNumber,
|
|
117
118
|
price: order.price,
|
|
118
119
|
priceCurrency: order.priceCurrency,
|
|
@@ -171,7 +172,11 @@ function placeOrder(params) {
|
|
|
171
172
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
172
173
|
const simpleOrder = {
|
|
173
174
|
typeOf: order.typeOf,
|
|
174
|
-
seller:
|
|
175
|
+
seller: {
|
|
176
|
+
id: order.seller.id,
|
|
177
|
+
typeOf: order.seller.typeOf,
|
|
178
|
+
name: order.seller.name
|
|
179
|
+
},
|
|
175
180
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
176
181
|
orderNumber: order.orderNumber,
|
|
177
182
|
price: order.price,
|
|
@@ -49,7 +49,11 @@ function returnOrder(params) {
|
|
|
49
49
|
}
|
|
50
50
|
const simpleOrder = {
|
|
51
51
|
typeOf: order.typeOf,
|
|
52
|
-
seller:
|
|
52
|
+
seller: {
|
|
53
|
+
id: order.seller.id,
|
|
54
|
+
typeOf: order.seller.typeOf,
|
|
55
|
+
name: order.seller.name
|
|
56
|
+
},
|
|
53
57
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
54
58
|
orderNumber: order.orderNumber,
|
|
55
59
|
price: order.price,
|
|
@@ -48,7 +48,11 @@ function sendOrder(params) {
|
|
|
48
48
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
49
49
|
const simpleOrder = {
|
|
50
50
|
typeOf: order.typeOf,
|
|
51
|
-
seller:
|
|
51
|
+
seller: {
|
|
52
|
+
id: order.seller.id,
|
|
53
|
+
typeOf: order.seller.typeOf,
|
|
54
|
+
name: order.seller.name
|
|
55
|
+
},
|
|
52
56
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
53
57
|
orderNumber: order.orderNumber,
|
|
54
58
|
price: order.price,
|
|
@@ -80,27 +80,28 @@ function createMovieTicket(params) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function createAuthorizeResult(params) {
|
|
83
|
-
var _a, _b, _c, _d;
|
|
83
|
+
var _a, _b, _c, _d, _e, _f;
|
|
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 = Object.assign({ typeOf: payTransactionObject.typeOf, id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : '' }, (typeof ((_c = (_b = payTransactionObject.serviceOutput) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency) === 'string')
|
|
90
|
+
? { serviceOutput: payTransactionObject.serviceOutput }
|
|
91
|
+
: undefined);
|
|
89
92
|
return {
|
|
90
|
-
accountId: (typeof ((
|
|
93
|
+
accountId: (typeof ((_d = payTransactionObject.paymentMethod) === null || _d === void 0 ? void 0 : _d.accountId) === 'string')
|
|
91
94
|
? payTransactionObject.paymentMethod.accountId
|
|
92
95
|
: '',
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : ''
|
|
97
|
-
},
|
|
96
|
+
// 廃止(2023-08-07~)
|
|
97
|
+
// amount: params.object.amount,
|
|
98
|
+
issuedThrough,
|
|
98
99
|
paymentMethod: params.object.paymentMethod,
|
|
99
100
|
paymentStatus: factory.paymentStatusType.PaymentDue,
|
|
100
|
-
paymentMethodId: (typeof ((
|
|
101
|
+
paymentMethodId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.paymentMethodId) === 'string')
|
|
101
102
|
? payTransactionObject.paymentMethod.paymentMethodId
|
|
102
103
|
: '',
|
|
103
|
-
name: (typeof ((
|
|
104
|
+
name: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.name) === 'string')
|
|
104
105
|
? payTransactionObject.paymentMethod.name
|
|
105
106
|
: params.object.paymentMethod,
|
|
106
107
|
totalPaymentDue: totalPaymentDue,
|
|
@@ -113,7 +113,7 @@ exports.checkMovieTicket = checkMovieTicket;
|
|
|
113
113
|
*/
|
|
114
114
|
function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
|
|
115
115
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
var _a
|
|
116
|
+
var _a;
|
|
117
117
|
let accountId;
|
|
118
118
|
let payAction;
|
|
119
119
|
let accountsReceivablesByServiceType = [];
|
|
@@ -138,7 +138,7 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
138
138
|
paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
|
|
139
139
|
typeOf: 'MonetaryAmount',
|
|
140
140
|
currency: factory.unitCode.C62,
|
|
141
|
-
value: (
|
|
141
|
+
value: (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? paymentMethod.movieTickets.length : 0
|
|
142
142
|
}, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
|
|
143
143
|
movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
|
|
144
144
|
};
|
|
@@ -53,6 +53,15 @@ function onResourceDeleted(params) {
|
|
|
53
53
|
ids: params.id
|
|
54
54
|
})(repos);
|
|
55
55
|
break;
|
|
56
|
+
case factory.product.ProductType.EventService:
|
|
57
|
+
case factory.product.ProductType.Product:
|
|
58
|
+
case factory.product.ProductType.Transportation:
|
|
59
|
+
yield deleteResourcesByProduct({
|
|
60
|
+
project: { id: params.project.id },
|
|
61
|
+
ids: params.id,
|
|
62
|
+
typeOf: params.typeOf
|
|
63
|
+
})(repos);
|
|
64
|
+
break;
|
|
56
65
|
default:
|
|
57
66
|
// no op
|
|
58
67
|
throw new factory.errors.NotImplemented(`${params.typeOf} onDeleted not implemented`);
|
|
@@ -333,3 +342,46 @@ function deleteResourcesByOfferCatalog(params) {
|
|
|
333
342
|
}
|
|
334
343
|
});
|
|
335
344
|
}
|
|
345
|
+
function deleteResourcesByProduct(params) {
|
|
346
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
347
|
+
if (params.ids.length !== 1) {
|
|
348
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
349
|
+
}
|
|
350
|
+
for (const productId of params.ids) {
|
|
351
|
+
const deleteActionAttributes = {
|
|
352
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
353
|
+
object: { id: productId, typeOf: params.typeOf },
|
|
354
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
355
|
+
typeOf: factory.actionType.DeleteAction
|
|
356
|
+
};
|
|
357
|
+
let deleteResult;
|
|
358
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
359
|
+
try {
|
|
360
|
+
let deleteEventResult;
|
|
361
|
+
let updateOfferResult;
|
|
362
|
+
// 興行を設定されたイベント削除
|
|
363
|
+
deleteEventResult = yield repos.event.deleteManyByItemOfferedId({
|
|
364
|
+
project: { id: params.project.id },
|
|
365
|
+
offers: { itemOffered: { id: { $in: [productId] } } }
|
|
366
|
+
});
|
|
367
|
+
// アドオンから除外
|
|
368
|
+
updateOfferResult = yield repos.offer.pullAddOns({
|
|
369
|
+
project: { id: params.project.id },
|
|
370
|
+
addOn: { itemOffered: { id: { $in: [productId] } } }
|
|
371
|
+
});
|
|
372
|
+
deleteResult = { deleteEventResult, updateOfferResult };
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
try {
|
|
376
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
377
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
378
|
+
}
|
|
379
|
+
catch (_) {
|
|
380
|
+
// no op
|
|
381
|
+
}
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
-
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
|
|
2
|
+
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
|
|
@@ -20,15 +20,12 @@ function createStartParams(params, passport, seller, broker) {
|
|
|
20
20
|
seller: {
|
|
21
21
|
id: seller.id,
|
|
22
22
|
name: seller.name,
|
|
23
|
-
typeOf: seller.typeOf
|
|
23
|
+
typeOf: seller.typeOf,
|
|
24
|
+
// 追加特性を追加(2023-08-08~)
|
|
25
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : []
|
|
24
26
|
},
|
|
25
27
|
object: transactionObject,
|
|
26
|
-
// expires: params.expires,
|
|
27
28
|
expiresInSeconds: params.expiresInSeconds
|
|
28
|
-
// 販売者にexpires設定があれば適用
|
|
29
|
-
// ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
|
|
30
|
-
// ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
|
|
31
|
-
// : undefined
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
31
|
exports.createStartParams = createStartParams;
|