@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
|
@@ -34,13 +34,15 @@ function createPotentialActions(params) {
|
|
|
34
34
|
const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
|
|
35
35
|
// 注文配送メール送信設定
|
|
36
36
|
const sendEmailMessageActions = yield (0, sendEmailMessage_1.createSendEmailMessageActions)(params);
|
|
37
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order);
|
|
37
38
|
const simpleOrder = {
|
|
38
39
|
// project: params.order.project,
|
|
39
40
|
typeOf: params.order.typeOf,
|
|
40
41
|
seller: params.order.seller,
|
|
41
42
|
// mask
|
|
42
|
-
customer:
|
|
43
|
-
|
|
43
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
44
|
+
// IOrderへ移行(2022-11-17~)
|
|
45
|
+
// confirmationNumber: params.order.confirmationNumber,
|
|
44
46
|
orderNumber: params.order.orderNumber,
|
|
45
47
|
price: params.order.price,
|
|
46
48
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -34,13 +34,11 @@ function createSeller(params) {
|
|
|
34
34
|
var _a;
|
|
35
35
|
const seller = params.transaction.seller;
|
|
36
36
|
return {
|
|
37
|
-
|
|
37
|
+
// 最適化(2022-11-15~)
|
|
38
|
+
// project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
|
|
38
39
|
id: seller.id,
|
|
39
40
|
name: (typeof seller.name === 'string') ? seller.name : String((_a = seller.name) === null || _a === void 0 ? void 0 : _a.ja),
|
|
40
41
|
typeOf: seller.typeOf
|
|
41
|
-
// ↓最適化(2022-05-20~)
|
|
42
|
-
// ...(typeof seller.telephone === 'string') ? { telephone: seller.telephone } : undefined,
|
|
43
|
-
// ...(typeof seller.url === 'string') ? { url: seller.url } : undefined
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
44
|
function createCustomer(params) {
|
|
@@ -8,12 +8,13 @@ function validateSeller(params) {
|
|
|
8
8
|
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
9
9
|
throw new factory.errors.ArgumentNull('client_id');
|
|
10
10
|
}
|
|
11
|
-
const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.
|
|
11
|
+
const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.find((offer) => {
|
|
12
12
|
var _a;
|
|
13
13
|
return (_a = offer.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.some((availableApplication) => availableApplication.id === clientId);
|
|
14
14
|
});
|
|
15
|
-
if (makesOfferFromClient
|
|
15
|
+
if (makesOfferFromClient === undefined) {
|
|
16
16
|
throw new factory.errors.Argument('seller', 'makes no offers');
|
|
17
17
|
}
|
|
18
|
+
return { makesOfferFromClient };
|
|
18
19
|
}
|
|
19
20
|
exports.validateSeller = validateSeller;
|
|
@@ -27,14 +27,28 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
|
27
27
|
*/
|
|
28
28
|
function start(params) {
|
|
29
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a;
|
|
30
31
|
const seller = yield repos.seller.findById({ id: params.seller.id });
|
|
32
|
+
let makesOfferFromClient;
|
|
31
33
|
// 販売者オファー検証(2022-10-14~)
|
|
32
34
|
if (params.validateSeller === true) {
|
|
33
|
-
(0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
|
|
35
|
+
const validateSellerResult = (0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
|
|
36
|
+
makesOfferFromClient = validateSellerResult.makesOfferFromClient;
|
|
34
37
|
}
|
|
35
38
|
const passport = yield (0, validation_2.validateWaiterPassport)(params);
|
|
39
|
+
// fix expiresInSeconds(2022-11-29~)
|
|
40
|
+
let expiresInSeconds;
|
|
41
|
+
if (typeof ((_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue) === 'number') {
|
|
42
|
+
expiresInSeconds = makesOfferFromClient.eligibleTransactionDuration.maxValue;
|
|
43
|
+
}
|
|
44
|
+
else if (typeof params.expiresInSeconds === 'number') {
|
|
45
|
+
expiresInSeconds = params.expiresInSeconds;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new factory.errors.ArgumentNull('expiresInSeconds');
|
|
49
|
+
}
|
|
36
50
|
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
37
|
-
const startParams = (0, factory_1.createStartParams)(params, passport, seller, params.broker);
|
|
51
|
+
const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { expiresInSeconds }), passport, seller, params.broker);
|
|
38
52
|
let transaction;
|
|
39
53
|
try {
|
|
40
54
|
transaction = yield repos.transaction.start(startParams);
|
|
@@ -17,13 +17,14 @@ function createReturnMoneyTransferActions(params) {
|
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const order = params.order;
|
|
19
19
|
const returnMoneyTransferActions = [];
|
|
20
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
20
21
|
const purpose = {
|
|
21
|
-
// project: order.project,
|
|
22
22
|
typeOf: order.typeOf,
|
|
23
23
|
seller: order.seller,
|
|
24
24
|
// mask
|
|
25
|
-
customer:
|
|
26
|
-
|
|
25
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
26
|
+
// IOrderへ移行(2022-11-17~)
|
|
27
|
+
// confirmationNumber: order.confirmationNumber,
|
|
27
28
|
orderNumber: order.orderNumber,
|
|
28
29
|
price: order.price,
|
|
29
30
|
priceCurrency: order.priceCurrency,
|
|
@@ -62,11 +63,9 @@ function createReturnMoneyTransferActions(params) {
|
|
|
62
63
|
},
|
|
63
64
|
agent: order.project,
|
|
64
65
|
recipient: {
|
|
65
|
-
// project: { typeOf: transaction.project.typeOf, id: transaction.project.id },
|
|
66
66
|
typeOf: order.seller.typeOf,
|
|
67
67
|
id: order.seller.id,
|
|
68
68
|
name: order.seller.name
|
|
69
|
-
// url: order.seller.url
|
|
70
69
|
},
|
|
71
70
|
potentialActions: {},
|
|
72
71
|
purpose,
|
|
@@ -45,7 +45,8 @@ function createReturnPaymentMethodPotentialActions(params) {
|
|
|
45
45
|
seller: order.seller,
|
|
46
46
|
// mask
|
|
47
47
|
customer: (0, order_1.createMaskedCustomer)(order),
|
|
48
|
-
|
|
48
|
+
// IOrderへ移行(2022-11-17~)
|
|
49
|
+
// confirmationNumber: order.confirmationNumber,
|
|
49
50
|
orderNumber: order.orderNumber,
|
|
50
51
|
price: order.price,
|
|
51
52
|
priceCurrency: order.priceCurrency,
|
|
@@ -109,7 +110,8 @@ function createReturnPaymentMethodActions(params) {
|
|
|
109
110
|
seller: order.seller,
|
|
110
111
|
// mask
|
|
111
112
|
customer: (0, order_1.createMaskedCustomer)(order),
|
|
112
|
-
|
|
113
|
+
// IOrderへ移行(2022-11-17~)
|
|
114
|
+
// confirmationNumber: order.confirmationNumber,
|
|
113
115
|
orderNumber: order.orderNumber,
|
|
114
116
|
price: order.price,
|
|
115
117
|
priceCurrency: order.priceCurrency,
|
|
@@ -179,7 +181,8 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
|
179
181
|
seller: order.seller,
|
|
180
182
|
// mask
|
|
181
183
|
customer: (0, order_1.createMaskedCustomer)(order),
|
|
182
|
-
|
|
184
|
+
// IOrderへ移行(2022-11-17~)
|
|
185
|
+
// confirmationNumber: order.confirmationNumber,
|
|
183
186
|
orderNumber: order.orderNumber,
|
|
184
187
|
price: order.price,
|
|
185
188
|
priceCurrency: order.priceCurrency,
|
|
@@ -47,26 +47,24 @@ function createReturnPointAwardActions(params) {
|
|
|
47
47
|
console.error('JSON.parse(awardAccountsStr) throws', error);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
// const transaction = params.transaction;
|
|
51
50
|
const order = params.order;
|
|
51
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
52
52
|
const purpose = {
|
|
53
|
-
// project: order.project,
|
|
54
53
|
typeOf: order.typeOf,
|
|
55
54
|
seller: order.seller,
|
|
56
55
|
// mask
|
|
57
|
-
customer:
|
|
58
|
-
|
|
56
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
57
|
+
// IOrderへ移行(2022-11-17~)
|
|
58
|
+
// confirmationNumber: order.confirmationNumber,
|
|
59
59
|
orderNumber: order.orderNumber,
|
|
60
60
|
price: order.price,
|
|
61
61
|
priceCurrency: order.priceCurrency,
|
|
62
62
|
orderDate: order.orderDate
|
|
63
63
|
};
|
|
64
64
|
const recipient = {
|
|
65
|
-
// project: { typeOf: transaction.project.typeOf, id: transaction.project.id },
|
|
66
65
|
typeOf: order.seller.typeOf,
|
|
67
66
|
id: order.seller.id,
|
|
68
67
|
name: order.seller.name
|
|
69
|
-
// url: order.seller.url
|
|
70
68
|
};
|
|
71
69
|
// ポイントインセンティブの数だけ、返却アクションを作成
|
|
72
70
|
returnPointAwardActions.push(...pointAwardIdentifiers.map((pointAwardIdentifier) => {
|
|
@@ -23,7 +23,8 @@ function createSendEmailMessaegActionsOnReturn(params) {
|
|
|
23
23
|
seller: order.seller,
|
|
24
24
|
// mask
|
|
25
25
|
customer: (0, order_1.createMaskedCustomer)(order),
|
|
26
|
-
|
|
26
|
+
// IOrderへ移行(2022-11-17~)
|
|
27
|
+
// confirmationNumber: order.confirmationNumber,
|
|
27
28
|
orderNumber: order.orderNumber,
|
|
28
29
|
price: order.price,
|
|
29
30
|
priceCurrency: order.priceCurrency,
|
|
@@ -55,6 +55,14 @@ function start(params) {
|
|
|
55
55
|
returnPolicy: appliedReturnPolicy,
|
|
56
56
|
reason: params.object.reason
|
|
57
57
|
};
|
|
58
|
+
// fix expiresInSeconds(2022-11-30~)
|
|
59
|
+
let expiresInSeconds;
|
|
60
|
+
if (typeof params.expiresInSeconds === 'number') {
|
|
61
|
+
expiresInSeconds = params.expiresInSeconds;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new factory.errors.ArgumentNull('expiresInSeconds');
|
|
65
|
+
}
|
|
58
66
|
const returnOrderAttributes = {
|
|
59
67
|
project: params.project,
|
|
60
68
|
typeOf: factory.transactionType.ReturnOrder,
|
|
@@ -65,7 +73,8 @@ function start(params) {
|
|
|
65
73
|
name: seller.name
|
|
66
74
|
},
|
|
67
75
|
object: transactionObject,
|
|
68
|
-
expires: params.expires
|
|
76
|
+
// expires: params.expires,
|
|
77
|
+
expiresInSeconds
|
|
69
78
|
};
|
|
70
79
|
let returnOrderTransaction;
|
|
71
80
|
try {
|
|
@@ -53,26 +53,13 @@ function updateAgent(params) {
|
|
|
53
53
|
const newAgent = {
|
|
54
54
|
typeOf: transaction.agent.typeOf,
|
|
55
55
|
id: transaction.agent.id
|
|
56
|
-
// 不要なので廃止(2022-05-26~)
|
|
57
|
-
// ...(Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : {},
|
|
58
|
-
// ...(typeof params.agent.age === 'string') ? { age: params.agent.age } : {},
|
|
59
|
-
// ...(typeof params.agent.address === 'string') ? { address: params.agent.address } : {},
|
|
60
|
-
// ...(typeof params.agent.email === 'string') ? { email: params.agent.email } : {},
|
|
61
|
-
// ...(typeof params.agent.familyName === 'string') ? { familyName: params.agent.familyName } : {},
|
|
62
|
-
// ...(typeof params.agent.gender === 'string') ? { gender: params.agent.gender } : {},
|
|
63
|
-
// ...(typeof params.agent.givenName === 'string') ? { givenName: params.agent.givenName } : {},
|
|
64
|
-
// ...(typeof params.agent.name === 'string') ? { name: params.agent.name } : {},
|
|
65
|
-
// ...(typeof formattedTelephone === 'string') ? { telephone: formattedTelephone } : {},
|
|
66
|
-
// ...(typeof params.agent.url === 'string') ? { url: params.agent.url } : {}
|
|
67
56
|
};
|
|
68
57
|
// 注文取引の場合、object.customerにも適用
|
|
69
58
|
let customer;
|
|
70
59
|
if (transaction.typeOf === factory.transactionType.PlaceOrder) {
|
|
71
60
|
// いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
|
|
72
61
|
if (typeof ((_a = transaction.object.customer) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
73
|
-
customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
74
|
-
? { project: transaction.object.customer.project }
|
|
75
|
-
: undefined), (Array.isArray(transaction.object.customer.identifier))
|
|
62
|
+
customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: transaction.object.customer.typeOf, id: transaction.object.customer.id }, (Array.isArray(transaction.object.customer.identifier))
|
|
76
63
|
? { identifier: transaction.object.customer.identifier }
|
|
77
64
|
: undefined), (transaction.object.customer.typeOf === factory.personType.Person
|
|
78
65
|
&& typeof ((_b = transaction.object.customer.memberOf) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.279.0-alpha.1",
|
|
13
|
+
"@cinerino/sdk": "3.133.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.1.0-alpha.
|
|
123
|
+
"version": "20.1.0-alpha.21"
|
|
124
124
|
}
|
|
@@ -1,24 +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
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
-
|
|
10
|
-
const accountRepo = new chevre.repository.Account(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
// 不要な所有権を削除
|
|
13
|
-
const result = await accountRepo.authorizeAmount({
|
|
14
|
-
accountNumber: '139151625010963',
|
|
15
|
-
amount: 10,
|
|
16
|
-
transaction: <any>{ id: 'test' },
|
|
17
|
-
force: false
|
|
18
|
-
});
|
|
19
|
-
console.log('result:', result);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
main()
|
|
23
|
-
.then(console.log)
|
|
24
|
-
.catch(console.error);
|
|
@@ -1,56 +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 offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const cursor = offerRepo.getCursor(
|
|
15
|
-
{
|
|
16
|
-
// 'project.id': { $eq: project.id }
|
|
17
|
-
'priceSpecification.appliesToMovieTicket': {
|
|
18
|
-
$exists: true,
|
|
19
|
-
$type: 'array'
|
|
20
|
-
// $not: { $type: 'array' }
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// _id: 1,
|
|
25
|
-
// ownedFrom: 1,
|
|
26
|
-
// typeOfGood: 1
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
console.log('offers found');
|
|
30
|
-
|
|
31
|
-
let i = 0;
|
|
32
|
-
let isArrayCount = 0;
|
|
33
|
-
let updateCount = 0;
|
|
34
|
-
await cursor.eachAsync(async (doc) => {
|
|
35
|
-
i += 1;
|
|
36
|
-
const offer = <chevre.factory.unitPriceOffer.IUnitPriceOffer>doc.toObject();
|
|
37
|
-
const applieToMovieTicket = offer.priceSpecification?.appliesToMovieTicket;
|
|
38
|
-
if (Array.isArray(applieToMovieTicket)) {
|
|
39
|
-
console.log('is Array', offer.project.id, offer.id, i);
|
|
40
|
-
isArrayCount += 1;
|
|
41
|
-
} else if (typeof (<any>applieToMovieTicket)?.typeOf === 'string') {
|
|
42
|
-
console.log('is not array', offer.project.id, offer.id, i);
|
|
43
|
-
updateCount += 1;
|
|
44
|
-
} else {
|
|
45
|
-
console.log('no applieToMovieTicket', offer.project.id, offer.id, i);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
console.log(i, 'offers checked');
|
|
50
|
-
console.log(isArrayCount, 'isArrayCount');
|
|
51
|
-
console.log(updateCount, 'offers updated');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
main()
|
|
55
|
-
.then()
|
|
56
|
-
.catch(console.error);
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
|
|
4
|
-
const columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'];
|
|
5
|
-
const rows = [
|
|
6
|
-
{ column: 'A', min: 4, max: 22 },
|
|
7
|
-
{ column: 'B', min: 4, max: 22 },
|
|
8
|
-
{ column: 'C', min: 3, max: 23 },
|
|
9
|
-
{ column: 'D', min: 3, max: 23 },
|
|
10
|
-
{ column: 'E', min: 3, max: 23 },
|
|
11
|
-
{ column: 'F', min: 2, max: 24 },
|
|
12
|
-
{ column: 'G', min: 2, max: 24 },
|
|
13
|
-
{ column: 'H', min: 1, max: 24 },
|
|
14
|
-
{ column: 'I', min: 1, max: 24 },
|
|
15
|
-
{ column: 'J', min: 1, max: 24 },
|
|
16
|
-
{ column: 'K', min: 1, max: 24 },
|
|
17
|
-
{ column: 'L', min: 1, max: 24 },
|
|
18
|
-
{ column: 'M', min: 1, max: 24 },
|
|
19
|
-
{ column: 'N', min: 1, max: 24 },
|
|
20
|
-
{ column: 'O', min: 1, max: 24 },
|
|
21
|
-
{ column: 'P', min: 1, max: 24 },
|
|
22
|
-
{ column: 'Q', min: 1, max: 24 },
|
|
23
|
-
{ column: 'R', min: 1, max: 24 },
|
|
24
|
-
{ column: 'S', min: 4, max: 21 },
|
|
25
|
-
{ column: 'T', min: 4, max: 21 },
|
|
26
|
-
{ column: 'U', min: 4, max: 21 },
|
|
27
|
-
{ column: 'V', min: 1, max: 24 },
|
|
28
|
-
{ column: 'W', min: 1, max: 24 }
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
const seats: {
|
|
32
|
-
branchCode: string;
|
|
33
|
-
typeOf: 'Seat';
|
|
34
|
-
}[] = [];
|
|
35
|
-
columns.forEach((column) => {
|
|
36
|
-
const row = rows.find((r) => r.column === column);
|
|
37
|
-
|
|
38
|
-
if (row !== undefined) {
|
|
39
|
-
const seatsByRow: {
|
|
40
|
-
branchCode: string;
|
|
41
|
-
typeOf: 'Seat';
|
|
42
|
-
}[] = [];
|
|
43
|
-
// tslint:disable-next-line:no-increment-decrement
|
|
44
|
-
for (let i = row.min; i <= row.max; i++) {
|
|
45
|
-
seatsByRow.push(
|
|
46
|
-
{
|
|
47
|
-
branchCode: `${column}-${i}`,
|
|
48
|
-
typeOf: 'Seat'
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
seats.push(...seatsByRow);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
console.log(seats);
|
|
58
|
-
// tslint:disable-next-line:non-literal-fs-path
|
|
59
|
-
fs.writeFileSync(`${__dirname}/createSeatsResult.json`, JSON.stringify(seats, null, ' '));
|
|
@@ -1,35 +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 ownershipInfoId = '40576fe8-5e6a-4caa-9622-0944d6d9cf7b';
|
|
9
|
-
const newOwnerId = '600ad33b-8ed1-4a8c-ad50-694bec02ff12';
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
|
|
15
|
-
await ownershipInfoRepo.addOwnerIfNotExist({
|
|
16
|
-
id: ownershipInfoId,
|
|
17
|
-
ownedBy: {
|
|
18
|
-
id: newOwnerId,
|
|
19
|
-
typeOf: chevre.factory.personType.Person
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
console.log('added');
|
|
23
|
-
|
|
24
|
-
await ownershipInfoRepo.removeOwnerIfExist({
|
|
25
|
-
id: ownershipInfoId,
|
|
26
|
-
ownedBy: {
|
|
27
|
-
id: newOwnerId
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
console.log('removed');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
main()
|
|
34
|
-
.then()
|
|
35
|
-
.catch(console.error);
|
|
@@ -1,82 +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
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = eventRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
// 'project.id': { $eq: project.id },
|
|
18
|
-
'project.id': { $ne: '' },
|
|
19
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
20
|
-
startDate: {
|
|
21
|
-
$gte: moment()
|
|
22
|
-
.add(-1, 'month')
|
|
23
|
-
.toDate()
|
|
24
|
-
}
|
|
25
|
-
// _id: { $eq: 'al6afd7np' }
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
// _id: 1,
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
console.log('events found');
|
|
32
|
-
|
|
33
|
-
let i = 0;
|
|
34
|
-
let updateCount = 0;
|
|
35
|
-
await cursor.eachAsync(async (doc) => {
|
|
36
|
-
i += 1;
|
|
37
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
38
|
-
|
|
39
|
-
const itemOfferedId = (<chevre.factory.event.screeningEvent.IOffer | undefined>event.offers)?.itemOffered?.id;
|
|
40
|
-
const itemOfferedName = (<any>event.offers)?.itemOffered?.name?.ja;
|
|
41
|
-
|
|
42
|
-
if (typeof itemOfferedName === 'string' && itemOfferedName.length > 0) {
|
|
43
|
-
console.log(
|
|
44
|
-
'already exist...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
45
|
-
} else {
|
|
46
|
-
const existingProducts = await productRepo.search({
|
|
47
|
-
limit: 1,
|
|
48
|
-
page: 1,
|
|
49
|
-
project: { id: { $eq: event.project.id } },
|
|
50
|
-
id: { $eq: itemOfferedId }
|
|
51
|
-
});
|
|
52
|
-
const existingProduct = existingProducts.shift();
|
|
53
|
-
if (existingProduct === undefined) {
|
|
54
|
-
// throw new Error(`product not found ${event.id}`);
|
|
55
|
-
// no op
|
|
56
|
-
} else {
|
|
57
|
-
const newItemOfferedName: string = (typeof existingProduct.name === 'string')
|
|
58
|
-
? existingProduct.name
|
|
59
|
-
: String(existingProduct.name?.ja);
|
|
60
|
-
console.log(
|
|
61
|
-
'updating event...', event.project.id, event.id, event.startDate, itemOfferedId, newItemOfferedName, i);
|
|
62
|
-
await eventRepo.updatePartiallyById({
|
|
63
|
-
id: event.id,
|
|
64
|
-
attributes: <any>{
|
|
65
|
-
typeOf: event.typeOf,
|
|
66
|
-
'offers.itemOffered.name': { ja: newItemOfferedName }
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
updateCount += 1;
|
|
71
|
-
console.log(
|
|
72
|
-
'updated', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
console.log(i, 'events checked');
|
|
77
|
-
console.log(updateCount, 'events updated');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
main()
|
|
81
|
-
.then()
|
|
82
|
-
.catch(console.error);
|
|
@@ -1,92 +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
|
-
type IMovieTicketPriceSpec =
|
|
8
|
-
chevre.factory.priceSpecification.IPriceSpecification<chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification>;
|
|
9
|
-
const CREATING_VIDEO_FORMAT = 'all';
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const priceSpecRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = priceSpecRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'project.id': { $eq: project.id },
|
|
19
|
-
typeOf: { $eq: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification }
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
// _id: 1,
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
console.log('priceSpecs found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
await cursor.eachAsync(async (doc) => {
|
|
30
|
-
i += 1;
|
|
31
|
-
const priceSpec: IMovieTicketPriceSpec = doc.toObject();
|
|
32
|
-
const appliesToVideoFormat = priceSpec.appliesToVideoFormat;
|
|
33
|
-
|
|
34
|
-
if (appliesToVideoFormat === CREATING_VIDEO_FORMAT) {
|
|
35
|
-
console.log(
|
|
36
|
-
'appliesToVideoFormat is...',
|
|
37
|
-
CREATING_VIDEO_FORMAT,
|
|
38
|
-
priceSpec.project?.id, priceSpec.appliesToMovieTicket.serviceType, priceSpec.appliesToVideoFormat, priceSpec.price, i);
|
|
39
|
-
} else {
|
|
40
|
-
// 券種区分について、もうひとつの上映方式に対応する価格仕様が存在しなければ、作成する
|
|
41
|
-
const priceSpecs = await priceSpecRepo.search({
|
|
42
|
-
limit: 1,
|
|
43
|
-
page: 1,
|
|
44
|
-
project: { id: { $eq: project.id } },
|
|
45
|
-
typeOf: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
46
|
-
appliesToVideoFormats: [CREATING_VIDEO_FORMAT],
|
|
47
|
-
appliesToMovieTicket: {
|
|
48
|
-
serviceTypes: [priceSpec.appliesToMovieTicket.serviceType]
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const priceSpec4all = priceSpecs.shift();
|
|
52
|
-
if (priceSpec4all !== undefined) {
|
|
53
|
-
console.log(
|
|
54
|
-
'already exist.',
|
|
55
|
-
priceSpec.project?.id, priceSpec.appliesToMovieTicket.serviceType, priceSpec.appliesToVideoFormat, priceSpec.price, i);
|
|
56
|
-
} else {
|
|
57
|
-
const newPriceSpec: IMovieTicketPriceSpec = {
|
|
58
|
-
typeOf: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
59
|
-
project: priceSpec.project,
|
|
60
|
-
price: priceSpec.price,
|
|
61
|
-
priceCurrency: priceSpec.priceCurrency,
|
|
62
|
-
name: priceSpec.name,
|
|
63
|
-
appliesToMovieTicket: priceSpec.appliesToMovieTicket,
|
|
64
|
-
appliesToVideoFormat: CREATING_VIDEO_FORMAT,
|
|
65
|
-
valueAddedTaxIncluded: true
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
console.log(
|
|
69
|
-
'creating priceSpec...',
|
|
70
|
-
priceSpec.project?.id,
|
|
71
|
-
newPriceSpec.appliesToMovieTicket.serviceType, newPriceSpec.appliesToVideoFormat, newPriceSpec.price, i);
|
|
72
|
-
await priceSpecRepo.save({
|
|
73
|
-
attributes: newPriceSpec
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
updateCount += 1;
|
|
77
|
-
console.log(
|
|
78
|
-
'created',
|
|
79
|
-
priceSpec.project?.id,
|
|
80
|
-
newPriceSpec.appliesToMovieTicket.serviceType, newPriceSpec.appliesToVideoFormat, newPriceSpec.price, i);
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log(i, 'priceSpecs checked');
|
|
87
|
-
console.log(updateCount, 'priceSpecs updated');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
main()
|
|
91
|
-
.then()
|
|
92
|
-
.catch(console.error);
|