@chevre/domain 20.11.0-alpha.3 → 20.11.1
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/person/createInformTask.ts +77 -0
- package/lib/chevre/service/assetTransaction/registerService.js +3 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -15
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.js +3 -12
- package/lib/chevre/service/offer/product.js +3 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +5 -3
- package/package.json +3 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
type IPermitOwnershipInfo = chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IPermitAsGood>;
|
|
7
|
+
|
|
8
|
+
const project = { id: <string>process.env.PROJECT_ID };
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
12
|
+
|
|
13
|
+
const now = new Date();
|
|
14
|
+
|
|
15
|
+
const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
|
|
16
|
+
const newPersonRepo = new chevre.repository.Person({
|
|
17
|
+
userPoolId: <string>process.env.USERPOOL_ID_NEW
|
|
18
|
+
});
|
|
19
|
+
const oldPersonRepo = new chevre.repository.Person({
|
|
20
|
+
userPoolId: <string>process.env.USERPOOL_ID_OLD
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const id = 'a7909268-a584-425e-8212-d7d10f344093';
|
|
24
|
+
|
|
25
|
+
const profile = await newPersonRepo.findById({
|
|
26
|
+
userId: id
|
|
27
|
+
});
|
|
28
|
+
console.log('profile found');
|
|
29
|
+
|
|
30
|
+
let oldUser;
|
|
31
|
+
const userIdentitiesStr = profile.additionalProperty?.find((p) => p.name === 'identities')?.value;
|
|
32
|
+
if (typeof userIdentitiesStr === 'string' && userIdentitiesStr.length > 0) {
|
|
33
|
+
try {
|
|
34
|
+
const identities = JSON.parse(userIdentitiesStr);
|
|
35
|
+
if (Array.isArray(identities) && identities.length > 0) {
|
|
36
|
+
const userIdByIdentities = identities[0].userId;
|
|
37
|
+
if (typeof userIdByIdentities === 'string' && userIdByIdentities.length > 0) {
|
|
38
|
+
// oldUserは必ず存在するはず
|
|
39
|
+
oldUser = await oldPersonRepo.findById({ userId: userIdByIdentities });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// tslint:disable-next-line:no-console
|
|
44
|
+
console.error('person2username throwed', error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const paymentCardOwnershipInfos = <IPermitOwnershipInfo[]>
|
|
50
|
+
await ownershipInfoRepo.search({
|
|
51
|
+
sort: { ownedFrom: chevre.factory.sortType.Ascending },
|
|
52
|
+
limit: 1,
|
|
53
|
+
page: 1,
|
|
54
|
+
project: { id: { $eq: project.id } },
|
|
55
|
+
ownedFrom: now,
|
|
56
|
+
ownedThrough: now,
|
|
57
|
+
ownedBy: { id },
|
|
58
|
+
typeOfGood: {
|
|
59
|
+
issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.PaymentCard } }
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const paymentCardOwnershipInfo = paymentCardOwnershipInfos.shift();
|
|
63
|
+
console.log('paymentCard found');
|
|
64
|
+
|
|
65
|
+
console.log({
|
|
66
|
+
id,
|
|
67
|
+
// ...profile,
|
|
68
|
+
accountNumber: paymentCardOwnershipInfo?.typeOfGood.identifier,
|
|
69
|
+
...oldUser
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then(() => {
|
|
75
|
+
console.log('success!');
|
|
76
|
+
})
|
|
77
|
+
.catch(console.error);
|
|
@@ -120,7 +120,9 @@ function createTransactionObject(params) {
|
|
|
120
120
|
transactionObject.push({
|
|
121
121
|
typeOf: factory.offerType.Offer,
|
|
122
122
|
id: String(offer.id),
|
|
123
|
-
itemOffered: Object.assign({
|
|
123
|
+
itemOffered: Object.assign({
|
|
124
|
+
// project: params.product.project,
|
|
125
|
+
typeOf: params.product.typeOf, id: String(params.product.id), serviceOutput: serviceOutput }, (pointAward !== undefined) ? { pointAward } : undefined)
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
return transactionObject;
|
|
@@ -22,7 +22,7 @@ export declare function responseBody2acceptedOffers4result(params: {
|
|
|
22
22
|
responseBody: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
|
|
23
23
|
object: factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.COA>;
|
|
24
24
|
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
25
|
-
seller: factory.transaction.placeOrder.ISeller
|
|
25
|
+
seller: Pick<factory.transaction.placeOrder.ISeller, 'typeOf' | 'name'>;
|
|
26
26
|
bookingTime: Date;
|
|
27
27
|
totalPrice: number;
|
|
28
28
|
}): IResultAcceptedOffer[];
|
|
@@ -71,11 +71,11 @@ exports.offers2resultPrice = offers2resultPrice;
|
|
|
71
71
|
function responseBody2acceptedOffers4result(params) {
|
|
72
72
|
const acceptedOffers4result = [];
|
|
73
73
|
const event = params.event;
|
|
74
|
-
const
|
|
74
|
+
const reservationNumber = String(params.responseBody.tmpReserveNum);
|
|
75
75
|
// 座席仮予約からオファー情報を生成する
|
|
76
76
|
// tslint:disable-next-line:max-func-body-length
|
|
77
|
-
acceptedOffers4result.push(...
|
|
78
|
-
var _a, _b, _c, _d
|
|
77
|
+
acceptedOffers4result.push(...params.responseBody.listTmpReserve.map((tmpReserve, index) => {
|
|
78
|
+
var _a, _b, _c, _d;
|
|
79
79
|
const requestedOffer = params.object.acceptedOffer.find((o) => {
|
|
80
80
|
var _a, _b, _c, _d;
|
|
81
81
|
return ((_d = (_c = (_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatNumber) === tmpReserve.seatNum
|
|
@@ -84,14 +84,7 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
84
84
|
if (requestedOffer === undefined) {
|
|
85
85
|
throw new factory.errors.Argument('offers', '要求された供給情報と仮予約結果が一致しません');
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
if (event.coaInfo !== undefined) {
|
|
89
|
-
coaInfo = event.coaInfo;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const coaInfoProperty = (_a = event.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'coaInfo');
|
|
93
|
-
coaInfo = (coaInfoProperty !== undefined) ? JSON.parse(coaInfoProperty.value) : undefined;
|
|
94
|
-
}
|
|
87
|
+
const coaInfo = event.coaInfo;
|
|
95
88
|
if (coaInfo === undefined) {
|
|
96
89
|
throw new factory.errors.NotFound('Event COA Info');
|
|
97
90
|
}
|
|
@@ -100,11 +93,10 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
100
93
|
coaInfo.theaterCode,
|
|
101
94
|
coaInfo.dateJouei,
|
|
102
95
|
// tslint:disable-next-line:no-magic-numbers
|
|
103
|
-
(`00000000${
|
|
96
|
+
(`00000000${reservationNumber}`).slice(-8),
|
|
104
97
|
// tslint:disable-next-line:no-magic-numbers
|
|
105
98
|
(`000${index + 1}`).slice(-3)
|
|
106
99
|
].join('');
|
|
107
|
-
const reservationNumber = String(updTmpReserveSeatResult.tmpReserveNum);
|
|
108
100
|
const reservationId = `${reservationNumber}-${index.toString()}`;
|
|
109
101
|
const workPerformed = {
|
|
110
102
|
id: event.superEvent.workPerformed.id,
|
|
@@ -159,8 +151,8 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
159
151
|
name: requestedOffer.name
|
|
160
152
|
}
|
|
161
153
|
};
|
|
162
|
-
const additionalProperty = (
|
|
163
|
-
const additionalTicketText = (
|
|
154
|
+
const additionalProperty = (_b = (_a = requestedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.additionalProperty;
|
|
155
|
+
const additionalTicketText = (_d = (_c = requestedOffer.itemOffered) === null || _c === void 0 ? void 0 : _c.serviceOutput) === null || _d === void 0 ? void 0 : _d.additionalTicketText;
|
|
164
156
|
const issuedThrough = {
|
|
165
157
|
typeOf: factory.product.ProductType.EventService,
|
|
166
158
|
id: '',
|
|
@@ -143,7 +143,7 @@ function createPriceComponent(params) {
|
|
|
143
143
|
priceCurrency: factory.priceCurrency.JPY,
|
|
144
144
|
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
145
145
|
appliesToCategoryCode: [{
|
|
146
|
-
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
146
|
+
// project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
147
147
|
typeOf: 'CategoryCode',
|
|
148
148
|
codeValue: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
|
|
149
149
|
inCodeSet: {
|
|
@@ -170,7 +170,7 @@ function createPriceComponent(params) {
|
|
|
170
170
|
priceCurrency: factory.priceCurrency.JPY,
|
|
171
171
|
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
172
172
|
appliesToCategoryCode: [{
|
|
173
|
-
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
173
|
+
// project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
174
174
|
typeOf: 'CategoryCode',
|
|
175
175
|
codeValue: ticketInfo.spseatKbn,
|
|
176
176
|
inCodeSet: {
|
|
@@ -250,9 +250,6 @@ function validateAcceptedOffers(params) {
|
|
|
250
250
|
// tslint:disable-next-line:max-func-body-length
|
|
251
251
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
252
252
|
var _a;
|
|
253
|
-
// const offerIds: string[] = (Array.isArray(params.object.acceptedOffer))
|
|
254
|
-
// ? [...new Set(params.object.acceptedOffer.map((o) => o.id))]
|
|
255
|
-
// : [];
|
|
256
253
|
const theaterCode = String((_a = params.screeningEvent.coaInfo) === null || _a === void 0 ? void 0 : _a.theaterCode);
|
|
257
254
|
const offerIdentifiers = (Array.isArray(params.object.acceptedOffer))
|
|
258
255
|
? [...new Set((params.object.acceptedOffer).map((o) => {
|
|
@@ -262,12 +259,6 @@ function validateAcceptedOffers(params) {
|
|
|
262
259
|
let availableUnitPriceOffers = [];
|
|
263
260
|
// 指定された単価オファーを検索
|
|
264
261
|
// ticketCodeで検索(2023-03-22~)
|
|
265
|
-
// if (offerIds.length > 0) {
|
|
266
|
-
// availableUnitPriceOffers = await repos.offer.search({
|
|
267
|
-
// id: { $in: offerIds },
|
|
268
|
-
// project: { id: { $eq: params.project.id } }
|
|
269
|
-
// });
|
|
270
|
-
// }
|
|
271
262
|
if (offerIdentifiers.length > 0) {
|
|
272
263
|
availableUnitPriceOffers = yield repos.offer.search({
|
|
273
264
|
identifier: { $in: offerIdentifiers },
|
|
@@ -320,7 +311,7 @@ function validateAcceptedOffers(params) {
|
|
|
320
311
|
name,
|
|
321
312
|
price,
|
|
322
313
|
priceSpecification, ticketInfo: Object.assign(Object.assign({}, ticketInfo), {
|
|
323
|
-
// usePoint
|
|
314
|
+
// usePointを自動設定(2023-03-22~)
|
|
324
315
|
usePoint: (typeof usePointValue === 'string') ? Number(usePointValue) : 0, salePrice // COAに渡す販売金額を上書き(2023-03-20~)
|
|
325
316
|
}),
|
|
326
317
|
// 以下属性については単価オファーから読む(2023-03-09~)
|
|
@@ -353,7 +353,9 @@ function validateAcceptedOffers(params) {
|
|
|
353
353
|
? { description: offerWithoutDetail.itemOffered.pointAward.description }
|
|
354
354
|
: undefined);
|
|
355
355
|
}
|
|
356
|
-
const itemOffered = Object.assign({
|
|
356
|
+
const itemOffered = Object.assign({
|
|
357
|
+
// project: project,
|
|
358
|
+
typeOf: params.product.typeOf, id: params.product.id, name: params.product.name, serviceOutput: Object.assign(Object.assign(Object.assign({}, (_j = params.product) === null || _j === void 0 ? void 0 : _j.serviceOutput), (_k = offerWithoutDetail.itemOffered) === null || _k === void 0 ? void 0 : _k.serviceOutput), { project: project,
|
|
357
359
|
// 発行者は販売者でいったん固定
|
|
358
360
|
issuedBy: issuedBy, typeOf: factory.permit.PermitType.Permit }) }, (pointAward !== undefined) ? { pointAward } : undefined);
|
|
359
361
|
return Object.assign(Object.assign(Object.assign({}, offerWithoutDetail), offer), { itemOffered, seller: { project: project, typeOf: params.seller.typeOf, id: params.seller.id, name: params.seller.name } });
|
|
@@ -206,7 +206,7 @@ function processAuthorizeProductOffer(params) {
|
|
|
206
206
|
const transaction = params.transaction;
|
|
207
207
|
const project = { typeOf: factory.organizationType.Project, id: params.project.id };
|
|
208
208
|
const seller = {
|
|
209
|
-
project: project,
|
|
209
|
+
// project: project,
|
|
210
210
|
typeOf: transaction.seller.typeOf,
|
|
211
211
|
id: transaction.seller.id,
|
|
212
212
|
name: transaction.seller.name
|
|
@@ -263,11 +263,13 @@ function processAuthorizeProductOffer(params) {
|
|
|
263
263
|
? acceptedOffer.itemOffered.name
|
|
264
264
|
: undefined;
|
|
265
265
|
const object = [{
|
|
266
|
-
project: project,
|
|
266
|
+
// project: project,
|
|
267
267
|
typeOf: acceptedProductOffer.typeOf,
|
|
268
268
|
id: acceptedProductOffer.id,
|
|
269
269
|
priceCurrency: acceptedProductOffer.priceCurrency,
|
|
270
|
-
itemOffered: Object.assign({
|
|
270
|
+
itemOffered: Object.assign({
|
|
271
|
+
// project: project,
|
|
272
|
+
typeOf: factory.product.ProductType.MembershipService, id: params.product.id, serviceOutput: Object.assign({ project: project, typeOf: acceptedOffer.itemOffered.typeOf }, (typeof serviceOutputName === 'string') ? { name: serviceOutputName } : undefined) }, (pointAward !== undefined) ? { pointAward } : undefined),
|
|
271
273
|
seller: seller
|
|
272
274
|
}];
|
|
273
275
|
// メンバーシップオファー承認
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.151.0
|
|
12
|
+
"@chevre/factory": "4.307.0",
|
|
13
|
+
"@cinerino/sdk": "3.151.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.11.
|
|
123
|
+
"version": "20.11.1"
|
|
124
124
|
}
|