@chevre/domain 20.1.0-alpha.1 → 20.1.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/deleteEvents.ts +9 -1
- package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +127 -0
- package/lib/chevre/repo/action.js +42 -31
- package/lib/chevre/repo/mongoose/model/action.js +9 -1
- package/lib/chevre/repo/mongoose/model/place.js +18 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +11 -17
- package/lib/chevre/service/delivery/factory.js +2 -1
- 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.js +6 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +6 -4
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -4
- package/lib/chevre/service/order/placeOrder.js +21 -11
- package/lib/chevre/service/order/returnOrder.js +3 -2
- package/lib/chevre/service/order/sendOrder.js +6 -4
- package/lib/chevre/service/transaction/orderProgramMembership.js +0 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +6 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +5 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +4 -5
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +9 -6
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +4 -6
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +3 -2
- package/lib/chevre/service/transaction.js +1 -14
- package/package.json +3 -3
- package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmReservation.js +0 -187
|
@@ -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);
|
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
|
-
// }
|