@chevre/domain 20.11.0 → 20.12.0-alpha.0

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.
@@ -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({ project: params.product.project, typeOf: params.product.typeOf, id: String(params.product.id), serviceOutput: serviceOutput }, (pointAward !== undefined) ? { pointAward } : undefined)
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;
@@ -72,6 +72,10 @@ function importCategoryCodesFromCOA(params) {
72
72
  theaterCode: params.theaterCode,
73
73
  kubunClass: '045'
74
74
  });
75
+ // const acousticKubuns = await repos.masterService.kubunName({
76
+ // theaterCode: params.theaterCode,
77
+ // kubunClass: '046'
78
+ // });
75
79
  const seatKubuns = yield repos.masterService.kubunName({
76
80
  theaterCode: params.theaterCode,
77
81
  kubunClass: '050'
@@ -87,6 +91,16 @@ function importCategoryCodesFromCOA(params) {
87
91
  upsert: true
88
92
  });
89
93
  });
94
+ // acousticKubuns.forEach((kubun) => {
95
+ // saveParams.push({
96
+ // attributes: kubun2categoryCode({
97
+ // kubun,
98
+ // project: params.project,
99
+ // inCodeSet: { identifier: factory.categoryCode.CategorySetIdentifier.SoundFormatType }
100
+ // }),
101
+ // upsert: true
102
+ // });
103
+ // });
90
104
  seatKubuns.forEach((kubun) => {
91
105
  saveParams.push({
92
106
  attributes: kubun2categoryCode({
@@ -50,7 +50,7 @@ function createAppliesToMovieTicket(params) {
50
50
  }
51
51
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
52
52
  function createPriceComponent(params) {
53
- var _a, _b, _c, _d, _e, _f;
53
+ var _a, _b, _c, _d, _e, _f, _g;
54
54
  const acceptedOffer = params.acceptedOffer;
55
55
  const availableUnitPriceOffer = params.availableUnitPriceOffer;
56
56
  const kbnJoueihousiki = (_a = params.screeningEvent.superEvent.coaInfo) === null || _a === void 0 ? void 0 : _a.kbnJoueihousiki;
@@ -130,29 +130,58 @@ function createPriceComponent(params) {
130
130
  // movieTicketTypeChargePriceSpecにaddPriceが含まれる場合は除く
131
131
  if (movieTicketTypeChargePriceSpec === undefined) {
132
132
  if (ticketInfo.addPrice > 0) {
133
- categoryCodeChargeSpecs.push({
134
- name: {
135
- en: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunNameEng) === 'string')
136
- ? kbnJoueihousiki.kubunNameEng
137
- : String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
138
- ja: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunName) === 'string')
139
- ? `${kbnJoueihousiki.kubunName}加算料金`
140
- : '加算単価'
141
- },
142
- price: ticketInfo.addPrice,
143
- priceCurrency: factory.priceCurrency.JPY,
144
- typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
145
- appliesToCategoryCode: [{
146
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
147
- typeOf: 'CategoryCode',
148
- codeValue: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
149
- inCodeSet: {
150
- typeOf: 'CategoryCodeSet',
151
- identifier: factory.categoryCode.CategorySetIdentifier.VideoFormatType
152
- }
153
- }],
154
- valueAddedTaxIncluded: true
155
- });
133
+ const videoFormatTypeCharge = (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunAddPrice) === 'number') ? kbnJoueihousiki.kubunAddPrice : 0;
134
+ const kbnAcoustic = (_g = params.screeningEvent.coaInfo) === null || _g === void 0 ? void 0 : _g.kbnAcoustic;
135
+ const soundFormatTypeCharge = (typeof (kbnAcoustic === null || kbnAcoustic === void 0 ? void 0 : kbnAcoustic.kubunAddPrice) === 'number') ? kbnAcoustic.kubunAddPrice : 0;
136
+ // 上映方式区分加算料金と音響区分加算料金を考慮する
137
+ if (videoFormatTypeCharge > 0) {
138
+ categoryCodeChargeSpecs.push({
139
+ name: {
140
+ en: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunNameEng) === 'string')
141
+ ? kbnJoueihousiki.kubunNameEng
142
+ : String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
143
+ ja: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunName) === 'string')
144
+ ? `${kbnJoueihousiki.kubunName}加算料金`
145
+ : '加算単価'
146
+ },
147
+ price: videoFormatTypeCharge,
148
+ priceCurrency: factory.priceCurrency.JPY,
149
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
150
+ appliesToCategoryCode: [{
151
+ typeOf: 'CategoryCode',
152
+ codeValue: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
153
+ inCodeSet: {
154
+ typeOf: 'CategoryCodeSet',
155
+ identifier: factory.categoryCode.CategorySetIdentifier.VideoFormatType
156
+ }
157
+ }],
158
+ valueAddedTaxIncluded: true
159
+ });
160
+ }
161
+ if (soundFormatTypeCharge > 0) {
162
+ categoryCodeChargeSpecs.push({
163
+ name: {
164
+ en: (typeof (kbnAcoustic === null || kbnAcoustic === void 0 ? void 0 : kbnAcoustic.kubunNameEng) === 'string')
165
+ ? kbnAcoustic.kubunNameEng
166
+ : String(kbnAcoustic === null || kbnAcoustic === void 0 ? void 0 : kbnAcoustic.kubunCode),
167
+ ja: (typeof (kbnAcoustic === null || kbnAcoustic === void 0 ? void 0 : kbnAcoustic.kubunName) === 'string')
168
+ ? `${kbnAcoustic.kubunName}加算料金`
169
+ : '加算単価'
170
+ },
171
+ price: soundFormatTypeCharge,
172
+ priceCurrency: factory.priceCurrency.JPY,
173
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
174
+ appliesToCategoryCode: [{
175
+ typeOf: 'CategoryCode',
176
+ codeValue: String(kbnAcoustic === null || kbnAcoustic === void 0 ? void 0 : kbnAcoustic.kubunCode),
177
+ inCodeSet: {
178
+ typeOf: 'CategoryCodeSet',
179
+ identifier: factory.categoryCode.CategorySetIdentifier.SoundFormatType
180
+ }
181
+ }],
182
+ valueAddedTaxIncluded: true
183
+ });
184
+ }
156
185
  }
157
186
  }
158
187
  if (ticketInfo.spseatAdd1 > 0) {
@@ -170,7 +199,7 @@ function createPriceComponent(params) {
170
199
  priceCurrency: factory.priceCurrency.JPY,
171
200
  typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
172
201
  appliesToCategoryCode: [{
173
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
202
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
174
203
  typeOf: 'CategoryCode',
175
204
  codeValue: ticketInfo.spseatKbn,
176
205
  inCodeSet: {
@@ -353,7 +353,9 @@ function validateAcceptedOffers(params) {
353
353
  ? { description: offerWithoutDetail.itemOffered.pointAward.description }
354
354
  : undefined);
355
355
  }
356
- const itemOffered = Object.assign({ project: project, 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,
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({ project: project, 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),
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.306.0",
13
- "@cinerino/sdk": "3.151.0-alpha.2",
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.0"
123
+ "version": "20.12.0-alpha.0"
124
124
  }