@chevre/domain 20.1.0-alpha.2 → 20.1.0-alpha.21
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/deleteEvents.ts +9 -1
- package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +139 -0
- package/example/src/chevre/migrateEventSeriesAdditionalProperties.ts +96 -0
- package/example/src/chevre/migrateSellerMakesOfferTransactionDuration.ts +71 -0
- package/example/src/chevre/searchEvents.ts +36 -16
- package/lib/chevre/repo/action.js +42 -31
- package/lib/chevre/repo/additionalProperty.d.ts +35 -0
- package/lib/chevre/repo/additionalProperty.js +211 -0
- package/lib/chevre/repo/event.d.ts +9 -4
- package/lib/chevre/repo/event.js +59 -47
- package/lib/chevre/repo/mongoose/model/action.js +9 -1
- package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
- package/lib/chevre/repo/mongoose/model/event.js +53 -0
- package/lib/chevre/repo/mongoose/model/place.js +18 -0
- package/lib/chevre/repo/place.d.ts +1 -0
- package/lib/chevre/repo/place.js +5 -0
- package/lib/chevre/repo/transaction.js +20 -5
- package/lib/chevre/repository.d.ts +6 -0
- package/lib/chevre/repository.js +8 -1
- package/lib/chevre/service/account.d.ts +0 -4
- package/lib/chevre/service/account.js +24 -22
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/deposit.js +3 -3
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/transfer.js +3 -3
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +11 -20
- package/lib/chevre/service/delivery/factory.js +2 -1
- package/lib/chevre/service/event.js +10 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize.js +46 -10
- package/lib/chevre/service/offer/factory.js +7 -20
- package/lib/chevre/service/offer.js +6 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +5 -3
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -4
- package/lib/chevre/service/order/placeOrder.js +17 -7
- package/lib/chevre/service/order/returnOrder.js +2 -1
- package/lib/chevre/service/order/sendOrder.js +4 -2
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -8
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +6 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +4 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +4 -5
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +4 -6
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -1
- package/lib/chevre/service/transaction/returnOrder.js +10 -1
- package/lib/chevre/service/transaction.js +1 -14
- package/package.json +3 -3
- package/example/src/chevre/accountBlanceTest.ts +0 -24
- package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
- package/example/src/chevre/createSeats.ts +0 -59
- package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
- package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
- package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
- package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
- package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
- package/example/src/chevre/publishConfirmationNumber.ts +0 -30
- package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
- package/example/src/chevre/publishTransactionNumber.ts +0 -28
- package/example/src/chevre/renameTransaction.ts +0 -22
- package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.js +0 -187
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
const AVAILABLE_ROLE_NAMES = ['customer', 'pos'];
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
12
|
-
|
|
13
|
-
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
14
|
-
const memberRepo = new chevre.repository.Member(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = sellerRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
// _id: 1,
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
console.log('sellers found');
|
|
25
|
-
|
|
26
|
-
let i = 0;
|
|
27
|
-
let updateCount = 0;
|
|
28
|
-
await cursor.eachAsync(async (doc) => {
|
|
29
|
-
i += 1;
|
|
30
|
-
const seller: chevre.factory.seller.ISeller = doc.toObject();
|
|
31
|
-
|
|
32
|
-
const makesOffer = seller.makesOffer;
|
|
33
|
-
|
|
34
|
-
if (Array.isArray(makesOffer) && makesOffer.length > 0) {
|
|
35
|
-
console.log(
|
|
36
|
-
'already exist...', seller.project.id, seller.id, makesOffer.length, i);
|
|
37
|
-
} else {
|
|
38
|
-
let existingApplicationMembers = await memberRepo.search({
|
|
39
|
-
limit: 100,
|
|
40
|
-
page: 1,
|
|
41
|
-
project: { id: { $eq: seller.project.id } },
|
|
42
|
-
member: {
|
|
43
|
-
typeOf: { $eq: chevre.factory.creativeWorkType.WebApplication }
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
// ロールで絞る(customer or pos)
|
|
47
|
-
existingApplicationMembers = existingApplicationMembers
|
|
48
|
-
.filter((m) => {
|
|
49
|
-
return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
|
|
50
|
-
});
|
|
51
|
-
console.log(
|
|
52
|
-
existingApplicationMembers.length,
|
|
53
|
-
'existingApplicationMembers found.',
|
|
54
|
-
seller.project.id,
|
|
55
|
-
existingApplicationMembers.map((m) => m.member.name)
|
|
56
|
-
.join(',')
|
|
57
|
-
);
|
|
58
|
-
const newMakesOffer: chevre.factory.seller.IMakesOffer[] = existingApplicationMembers.map((a) => {
|
|
59
|
-
return {
|
|
60
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
61
|
-
availableAtOrFrom: [{ id: a.member.id }]
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
console.log(
|
|
65
|
-
'updating seller...', seller.project.id, seller.id, newMakesOffer.length, i);
|
|
66
|
-
await sellerRepo.save({
|
|
67
|
-
id: seller.id,
|
|
68
|
-
attributes: <any>{
|
|
69
|
-
makesOffer: newMakesOffer
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
updateCount += 1;
|
|
73
|
-
console.log(
|
|
74
|
-
'updated...', seller.project.id, seller.id, newMakesOffer.length, i);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
console.log(i, 'sellers checked');
|
|
79
|
-
console.log(updateCount, 'sellers updated');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
main()
|
|
83
|
-
.then()
|
|
84
|
-
.catch(console.error);
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
-
|
|
12
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const cursor = eventRepo.getCursor(
|
|
15
|
-
{
|
|
16
|
-
'project.id': { $eq: '' },
|
|
17
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
18
|
-
startDate: {
|
|
19
|
-
$gte: moment()
|
|
20
|
-
.add(-1, 'month')
|
|
21
|
-
.toDate()
|
|
22
|
-
}
|
|
23
|
-
// _id: { $eq: 'al6afd7np' }
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
// _id: 1,
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
console.log('events found');
|
|
30
|
-
|
|
31
|
-
let i = 0;
|
|
32
|
-
let updateCount = 0;
|
|
33
|
-
await cursor.eachAsync(async (doc) => {
|
|
34
|
-
i += 1;
|
|
35
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
36
|
-
|
|
37
|
-
const oldEventId = event.additionalProperty?.find((p) => p.name === 'oldEventId')?.value;
|
|
38
|
-
|
|
39
|
-
if (typeof oldEventId === 'string' && event.id === oldEventId) {
|
|
40
|
-
console.log(
|
|
41
|
-
'already exist...', event.project.id, event.id, event.startDate, oldEventId, i);
|
|
42
|
-
} else {
|
|
43
|
-
const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] = [
|
|
44
|
-
...(Array.isArray(event.additionalProperty)) ? event.additionalProperty : [],
|
|
45
|
-
{ name: 'oldEventId', value: String(event.id) }
|
|
46
|
-
];
|
|
47
|
-
console.log(
|
|
48
|
-
'updating event...', event.project.id, event.id, event.startDate, oldEventId, newAdditionalProperty, i);
|
|
49
|
-
await eventRepo.updatePartiallyById({
|
|
50
|
-
id: event.id,
|
|
51
|
-
attributes: <any>{
|
|
52
|
-
typeOf: event.typeOf,
|
|
53
|
-
additionalProperty: newAdditionalProperty
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
updateCount += 1;
|
|
57
|
-
console.log(
|
|
58
|
-
'updated', event.project.id, event.id, event.startDate, oldEventId, i);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
console.log(i, 'events checked');
|
|
63
|
-
console.log(updateCount, 'events updated');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
main()
|
|
67
|
-
.then()
|
|
68
|
-
.catch(console.error);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../lib/index';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const client = redis.createClient({
|
|
10
|
-
host: process.env.REDIS_HOST,
|
|
11
|
-
port: Number(process.env.REDIS_PORT),
|
|
12
|
-
password: process.env.REDIS_KEY
|
|
13
|
-
});
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
15
|
-
|
|
16
|
-
const confirmationNumberRepo = new chevre.repository.ConfirmationNumber(client);
|
|
17
|
-
|
|
18
|
-
const confirmationNumber = await confirmationNumberRepo.publish({
|
|
19
|
-
orderDate: moment()
|
|
20
|
-
// .add(-1, 'month')
|
|
21
|
-
.toDate()
|
|
22
|
-
});
|
|
23
|
-
console.log(confirmationNumber);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
main()
|
|
27
|
-
.then(() => {
|
|
28
|
-
console.log('success!');
|
|
29
|
-
})
|
|
30
|
-
.catch(console.error);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../lib/index';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const client = redis.createClient({
|
|
10
|
-
host: process.env.REDIS_HOST,
|
|
11
|
-
port: Number(process.env.REDIS_PORT),
|
|
12
|
-
password: process.env.REDIS_KEY
|
|
13
|
-
});
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
15
|
-
|
|
16
|
-
const serviceOutputIdentifierRepo = new chevre.repository.ServiceOutputIdentifier(client);
|
|
17
|
-
|
|
18
|
-
const identifier = await serviceOutputIdentifierRepo.publishByTimestamp({
|
|
19
|
-
startDate: new Date()
|
|
20
|
-
});
|
|
21
|
-
console.log(identifier);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
main()
|
|
25
|
-
.then(() => {
|
|
26
|
-
console.log('success!');
|
|
27
|
-
})
|
|
28
|
-
.catch(console.error);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../lib/index';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const client = redis.createClient({
|
|
10
|
-
host: process.env.REDIS_HOST,
|
|
11
|
-
port: Number(process.env.REDIS_PORT),
|
|
12
|
-
password: process.env.REDIS_KEY
|
|
13
|
-
});
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
15
|
-
|
|
16
|
-
const transactionNumberRepo = new chevre.repository.TransactionNumber(client);
|
|
17
|
-
|
|
18
|
-
const reservationNumber = await transactionNumberRepo.publishByTimestamp({
|
|
19
|
-
startDate: new Date()
|
|
20
|
-
});
|
|
21
|
-
console.log(reservationNumber);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
main()
|
|
25
|
-
.then(() => {
|
|
26
|
-
console.log('success!');
|
|
27
|
-
})
|
|
28
|
-
.catch(console.error);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as redis from 'redis';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
// import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
-
|
|
10
|
-
// Access the underlying database object provided by the MongoDB driver.
|
|
11
|
-
const db = mongoose.connection.db;
|
|
12
|
-
|
|
13
|
-
// Rename the `test` collection to `foobar`
|
|
14
|
-
const result = await db.collection('transactions')
|
|
15
|
-
.rename('assetTransactions', { dropTarget: true });
|
|
16
|
-
|
|
17
|
-
console.log(result);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
main()
|
|
21
|
-
.then(console.log)
|
|
22
|
-
.catch(console.error);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.call = void 0;
|
|
13
|
-
const account_1 = require("../../repo/account");
|
|
14
|
-
const accountAction_1 = require("../../repo/accountAction");
|
|
15
|
-
const accountTransaction_1 = require("../../repo/accountTransaction");
|
|
16
|
-
const AccountService = require("../account");
|
|
17
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
18
|
-
/* istanbul ignore next */
|
|
19
|
-
function call(data) {
|
|
20
|
-
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const accountRepo = new account_1.MongoRepository(settings.connection);
|
|
22
|
-
const accountActionRepo = new accountAction_1.MongoRepository(settings.connection);
|
|
23
|
-
const accountTransactionRepo = new accountTransaction_1.MongoRepository(settings.connection);
|
|
24
|
-
yield AccountService.transferMoney(data.actionAttributes)({
|
|
25
|
-
account: accountRepo,
|
|
26
|
-
accountAction: accountActionRepo,
|
|
27
|
-
accountTransaction: accountTransactionRepo
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.call = call;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.call = void 0;
|
|
13
|
-
const account_1 = require("../../repo/account");
|
|
14
|
-
const accountAction_1 = require("../../repo/accountAction");
|
|
15
|
-
const accountTransaction_1 = require("../../repo/accountTransaction");
|
|
16
|
-
const AccountService = require("../account");
|
|
17
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
18
|
-
/* istanbul ignore next */
|
|
19
|
-
function call(data) {
|
|
20
|
-
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const accountRepo = new account_1.MongoRepository(settings.connection);
|
|
22
|
-
const actionRepo = new accountAction_1.MongoRepository(settings.connection);
|
|
23
|
-
const transactionRepo = new accountTransaction_1.MongoRepository(settings.connection);
|
|
24
|
-
yield AccountService.cancelMoneyTransfer({
|
|
25
|
-
transaction: data.transaction
|
|
26
|
-
})({
|
|
27
|
-
account: accountRepo,
|
|
28
|
-
accountAction: actionRepo,
|
|
29
|
-
accountTransaction: transactionRepo
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.call = call;
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as factory from '../../../../factory';
|
|
2
|
-
export declare type IAuthorizeSeatReservationOffer = factory.action.authorize.offer.seatReservation.IAction<factory.service.webAPI.Identifier>;
|
|
3
|
-
/**
|
|
4
|
-
* 予約確定アクションを作成する
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 予約確定オブジェクトを作成する
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* 予約確定オブジェクトを作成する
|
|
11
|
-
*/
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber';
|
|
3
|
-
// import { format } from 'util';
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
/**
|
|
6
|
-
* 予約確定アクションを作成する
|
|
7
|
-
*/
|
|
8
|
-
// export async function createConfirmReservationActions(params: {
|
|
9
|
-
// order: factory.order.IOrder;
|
|
10
|
-
// transaction: factory.transaction.placeOrder.ITransaction;
|
|
11
|
-
// createConfirmReserveActions: boolean;
|
|
12
|
-
// }): Promise<factory.action.interact.confirm.reservation.IAttributes<factory.service.webAPI.Identifier>[]> {
|
|
13
|
-
// const confirmReservationActions: factory.action.interact.confirm.reservation.IAttributes<factory.service.webAPI.Identifier>[] = [];
|
|
14
|
-
// const seatReservationAuthorizeActions = <IAuthorizeSeatReservationOffer[]>
|
|
15
|
-
// params.transaction.object.authorizeActions
|
|
16
|
-
// .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
17
|
-
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
18
|
-
// const purpose: factory.order.ISimpleOrder = createPurpose({ order: params.order });
|
|
19
|
-
// seatReservationAuthorizeActions.forEach((a) => {
|
|
20
|
-
// const actionResult = a.result;
|
|
21
|
-
// if (a.instrument === undefined) {
|
|
22
|
-
// a.instrument = {
|
|
23
|
-
// typeOf: 'WebAPI',
|
|
24
|
-
// identifier: factory.service.webAPI.Identifier.Chevre
|
|
25
|
-
// };
|
|
26
|
-
// }
|
|
27
|
-
// if (actionResult !== undefined) {
|
|
28
|
-
// const responseBody = actionResult.responseBody;
|
|
29
|
-
// let confirmReservationObject: factory.action.interact.confirm.reservation.IObject<factory.service.webAPI.Identifier.Chevre>
|
|
30
|
-
// | factory.action.interact.confirm.reservation.IObject<factory.service.webAPI.Identifier.COA>;
|
|
31
|
-
// switch (a.instrument.identifier) {
|
|
32
|
-
// case factory.service.webAPI.Identifier.COA:
|
|
33
|
-
// confirmReservationObject = createConfirmReservationActionObject4COA({
|
|
34
|
-
// order: params.order,
|
|
35
|
-
// // tslint:disable-next-line:max-line-length
|
|
36
|
-
// tslint:disable-next-line:max-line-length
|
|
37
|
-
// reserveTransaction: <factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>>responseBody,
|
|
38
|
-
// requestBody: actionResult.requestBody,
|
|
39
|
-
// price: Number(actionResult.price),
|
|
40
|
-
// acceptedOffers: <factory.action.authorize.offer.seatReservation.IAcceptedOffer4COA[]>a.object.acceptedOffer
|
|
41
|
-
// });
|
|
42
|
-
// break;
|
|
43
|
-
// default:
|
|
44
|
-
// const reserveTransactionNumber = a.object.pendingTransaction?.transactionNumber;
|
|
45
|
-
// if (typeof reserveTransactionNumber !== 'string') {
|
|
46
|
-
// throw new factory.errors.NotFound('AuthorizaAction.object.pendingTransaction.transactionNumber');
|
|
47
|
-
// }
|
|
48
|
-
// confirmReservationObject = createConfirmReservationActionObject({
|
|
49
|
-
// order: params.order,
|
|
50
|
-
// // transaction: params.transaction,
|
|
51
|
-
// // tslint:disable-next-line:max-line-length
|
|
52
|
-
// tslint:disable-next-line:max-line-length
|
|
53
|
-
// // reserveTransaction: <factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.Chevre>>responseBody,
|
|
54
|
-
// reserveTransactionNumber
|
|
55
|
-
// });
|
|
56
|
-
// }
|
|
57
|
-
// if (params.createConfirmReserveActions) {
|
|
58
|
-
// confirmReservationActions.push({
|
|
59
|
-
// project: params.transaction.project,
|
|
60
|
-
// typeOf: <factory.actionType.ConfirmAction>factory.actionType.ConfirmAction,
|
|
61
|
-
// object: confirmReservationObject,
|
|
62
|
-
// // agent: Projectに統一(2022-05-16~)
|
|
63
|
-
// agent: params.transaction.project,
|
|
64
|
-
// // agent: params.transaction.agent,
|
|
65
|
-
// purpose: purpose,
|
|
66
|
-
// instrument: a.instrument
|
|
67
|
-
// });
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
70
|
-
// });
|
|
71
|
-
// return confirmReservationActions;
|
|
72
|
-
// }
|
|
73
|
-
// function createPurpose(params: {
|
|
74
|
-
// order: factory.order.IOrder;
|
|
75
|
-
// }): factory.order.ISimpleOrder {
|
|
76
|
-
// return {
|
|
77
|
-
// project: params.order.project,
|
|
78
|
-
// typeOf: params.order.typeOf,
|
|
79
|
-
// seller: params.order.seller,
|
|
80
|
-
// // mask
|
|
81
|
-
// customer: createMaskedCustomer(params.order),
|
|
82
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
83
|
-
// orderNumber: params.order.orderNumber,
|
|
84
|
-
// price: params.order.price,
|
|
85
|
-
// priceCurrency: params.order.priceCurrency,
|
|
86
|
-
// orderDate: params.order.orderDate
|
|
87
|
-
// };
|
|
88
|
-
// }
|
|
89
|
-
/**
|
|
90
|
-
* 予約確定オブジェクトを作成する
|
|
91
|
-
*/
|
|
92
|
-
// function createConfirmReservationActionObject4COA(params: {
|
|
93
|
-
// order: factory.order.IOrder;
|
|
94
|
-
// reserveTransaction: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
|
|
95
|
-
// requestBody: any;
|
|
96
|
-
// price: number;
|
|
97
|
-
// acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer4COA[];
|
|
98
|
-
// }): factory.action.interact.confirm.reservation.IObject<factory.service.webAPI.Identifier.COA> {
|
|
99
|
-
// const price = params.price;
|
|
100
|
-
// const customer = params.order.customer;
|
|
101
|
-
// const updTmpReserveSeatArgs = params.requestBody;
|
|
102
|
-
// const updTmpReserveSeatResult = params.reserveTransaction;
|
|
103
|
-
// // 電話番号のフォーマットを日本人にリーダブルに調整(COAではこのフォーマットで扱うので)
|
|
104
|
-
// const phoneUtil = PhoneNumberUtil.getInstance();
|
|
105
|
-
// const phoneNumber = phoneUtil.parse(customer.telephone, 'JP');
|
|
106
|
-
// let telNum = phoneUtil.format(phoneNumber, PhoneNumberFormat.NATIONAL);
|
|
107
|
-
// // COAでは数字のみ受け付けるので数字以外を除去
|
|
108
|
-
// telNum = telNum.replace(/[^\d]/g, '');
|
|
109
|
-
// const mailAddr = customer.email;
|
|
110
|
-
// if (mailAddr === undefined) {
|
|
111
|
-
// throw new factory.errors.Argument('order', 'order.customer.email undefined');
|
|
112
|
-
// }
|
|
113
|
-
// return {
|
|
114
|
-
// theaterCode: updTmpReserveSeatArgs.theaterCode,
|
|
115
|
-
// dateJouei: updTmpReserveSeatArgs.dateJouei,
|
|
116
|
-
// titleCode: updTmpReserveSeatArgs.titleCode,
|
|
117
|
-
// titleBranchNum: updTmpReserveSeatArgs.titleBranchNum,
|
|
118
|
-
// timeBegin: updTmpReserveSeatArgs.timeBegin,
|
|
119
|
-
// tmpReserveNum: updTmpReserveSeatResult.tmpReserveNum,
|
|
120
|
-
// tslint:disable-next-line:no-irregular-whitespace
|
|
121
|
-
// reserveName: format('%s %s', customer.familyName, customer.givenName),
|
|
122
|
-
// tslint:disable-next-line:no-irregular-whitespace
|
|
123
|
-
// reserveNameJkana: format('%s %s', customer.familyName, customer.givenName),
|
|
124
|
-
// telNum: telNum,
|
|
125
|
-
// mailAddr: mailAddr,
|
|
126
|
-
// reserveAmount: price, // デフォルトのpriceCurrencyがJPYなのでこれでよし
|
|
127
|
-
// listTicket: params.acceptedOffers.map((o) => o.ticketInfo),
|
|
128
|
-
// transactionNumber: String(updTmpReserveSeatResult.tmpReserveNum),
|
|
129
|
-
// typeOf: 'COAReserveTransaction'
|
|
130
|
-
// };
|
|
131
|
-
// }
|
|
132
|
-
/**
|
|
133
|
-
* 予約確定オブジェクトを作成する
|
|
134
|
-
*/
|
|
135
|
-
// function createConfirmReservationActionObject(params: {
|
|
136
|
-
// order: factory.order.IOrder;
|
|
137
|
-
// reserveTransactionNumber: string;
|
|
138
|
-
// }): factory.action.interact.confirm.reservation.IObject<factory.service.webAPI.Identifier.Chevre> {
|
|
139
|
-
// return {
|
|
140
|
-
// typeOf: factory.assetTransactionType.Reserve,
|
|
141
|
-
// transactionNumber: params.reserveTransactionNumber,
|
|
142
|
-
// potentialActions: {
|
|
143
|
-
// reserve: {
|
|
144
|
-
// purpose: {
|
|
145
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
146
|
-
// orderNumber: params.order.orderNumber,
|
|
147
|
-
// typeOf: params.order.typeOf
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
150
|
-
// }
|
|
151
|
-
// };
|
|
152
|
-
// }
|
|
153
|
-
// function createReservationUnderNameIdentifier(params: {
|
|
154
|
-
// order: factory.order.IOrder;
|
|
155
|
-
// transaction: factory.transaction.placeOrder.ITransaction;
|
|
156
|
-
// }): factory.propertyValue.IPropertyValue<string>[] {
|
|
157
|
-
// const order = params.order;
|
|
158
|
-
// const customer = order.customer;
|
|
159
|
-
// // 予約のunderName.identifierを決定する
|
|
160
|
-
// return [
|
|
161
|
-
// { name: 'orderNumber', value: order.orderNumber },
|
|
162
|
-
// // 不要なので廃止(2022-05-24~)
|
|
163
|
-
// // { name: 'transaction', value: params.transaction.id },
|
|
164
|
-
// // ↓legacy-reservationの印刷アウトプットで使用(2022-02-09廃止)
|
|
165
|
-
// // { name: 'paymentMethod', value: paymentMethodNames },
|
|
166
|
-
// ...(Array.isArray(customer.identifier)) ? customer.identifier : []
|
|
167
|
-
// ];
|
|
168
|
-
// }
|
|
169
|
-
// function createReservationUnderName(params: {
|
|
170
|
-
// order: factory.order.IOrder;
|
|
171
|
-
// identifier: factory.propertyValue.IPropertyValue<string>[];
|
|
172
|
-
// }): factory.reservation.IUnderName<factory.reservationType.EventReservation> {
|
|
173
|
-
// return {
|
|
174
|
-
// identifier: params.identifier,
|
|
175
|
-
// name: String(params.order.customer.name),
|
|
176
|
-
// typeOf: params.order.customer.typeOf,
|
|
177
|
-
// ...(typeof params.order.customer.address === 'string') ? { address: params.order.customer.address } : undefined,
|
|
178
|
-
// ...(typeof params.order.customer.age === 'string') ? { age: params.order.customer.age } : undefined,
|
|
179
|
-
// ...(typeof params.order.customer.email === 'string') ? { email: params.order.customer.email } : undefined,
|
|
180
|
-
// ...(typeof params.order.customer.familyName === 'string') ? { familyName: params.order.customer.familyName } : undefined,
|
|
181
|
-
// ...(typeof params.order.customer.gender === 'string') ? { gender: params.order.customer.gender } : undefined,
|
|
182
|
-
// ...(typeof params.order.customer.givenName === 'string') ? { givenName: params.order.customer.givenName } : undefined,
|
|
183
|
-
// ...(typeof params.order.customer.id === 'string') ? { id: params.order.customer.id } : undefined,
|
|
184
|
-
// ...(typeof params.order.customer.telephone === 'string') ? { telephone: params.order.customer.telephone } : undefined,
|
|
185
|
-
// ...(typeof params.order.customer.url === 'string') ? { url: params.order.customer.url } : undefined
|
|
186
|
-
// };
|
|
187
|
-
// }
|