@chevre/domain 20.4.0-alpha.15 → 20.4.0-alpha.16

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.
@@ -11,7 +11,7 @@ async function main() {
11
11
  const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
12
 
13
13
  const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
- project: { id: 'cinerino' }
14
+ // project: { id: 'cinerino' }
15
15
  });
16
16
  console.log('deleted', result);
17
17
  }
@@ -7,7 +7,8 @@ async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
8
 
9
9
  // const accountRepo = new chevre.repository.Account(mongoose.connection);
10
- const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
10
+ // const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
11
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
11
12
 
12
13
  let updateResult: any;
13
14
  // updateResult = await accountRepo.unsetUnnecessaryFields({
@@ -15,16 +16,21 @@ async function main() {
15
16
  // $unset: { status: 1 }
16
17
  // });
17
18
  // console.log('accounts unset.', updateResult);
18
- updateResult = await permitRepo.unsetUnnecessaryFields({
19
- filter: { 'paymentAccount.project': { $exists: true } },
20
- $unset: { 'paymentAccount.project': 1 }
21
- });
22
- console.log('permits unset', updateResult);
23
- updateResult = await permitRepo.unsetUnnecessaryFields({
24
- filter: { 'issuedThrough.project': { $exists: true } },
25
- $unset: { 'issuedThrough.project': 1 }
19
+ // updateResult = await permitRepo.unsetUnnecessaryFields({
20
+ // filter: { 'paymentAccount.project': { $exists: true } },
21
+ // $unset: { 'paymentAccount.project': 1 }
22
+ // });
23
+ // console.log('permits unset', updateResult);
24
+ // updateResult = await permitRepo.unsetUnnecessaryFields({
25
+ // filter: { 'issuedThrough.project': { $exists: true } },
26
+ // $unset: { 'issuedThrough.project': 1 }
27
+ // });
28
+ // console.log('permits unset', updateResult);
29
+ updateResult = await eventRepo.unsetUnnecessaryFields({
30
+ filter: { hasOfferCatalog: { $exists: true } },
31
+ $unset: { hasOfferCatalog: 1 }
26
32
  });
27
- console.log('permits unset', updateResult);
33
+ console.log('events unset', updateResult);
28
34
  }
29
35
 
30
36
  main()
@@ -141,9 +141,10 @@ export declare class MongoRepository {
141
141
  }, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
142
142
  bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
143
143
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
144
- deleteUnnecessaryProjectAttributesById(params: {
145
- id: string;
146
- }): Promise<void>;
144
+ unsetUnnecessaryFields(params: {
145
+ filter: any;
146
+ $unset: any;
147
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
147
148
  aggregateEvent(params: {
148
149
  project?: {
149
150
  id?: {
@@ -751,18 +751,9 @@ class MongoRepository {
751
751
  .sort({ startDate: factory.sortType.Descending })
752
752
  .cursor();
753
753
  }
754
- deleteUnnecessaryProjectAttributesById(params) {
754
+ unsetUnnecessaryFields(params) {
755
755
  return __awaiter(this, void 0, void 0, function* () {
756
- yield this.eventModel.updateOne({
757
- _id: { $eq: params.id }
758
- }, {
759
- $unset: {
760
- 'location.project': 1,
761
- 'workPerformed.project': 1,
762
- 'superEvent.location.project': 1,
763
- 'superEvent.workPerformed.project': 1
764
- }
765
- })
756
+ return this.eventModel.updateMany(params.filter, { $unset: params.$unset })
766
757
  .exec();
767
758
  });
768
759
  }
@@ -31,8 +31,8 @@ export declare class MongoRepository {
31
31
  };
32
32
  }): Promise<void>;
33
33
  deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params: {
34
- project: {
35
- id: string;
34
+ project?: {
35
+ id?: string;
36
36
  };
37
37
  }): Promise<{
38
38
  ok?: number | undefined;
@@ -278,12 +278,11 @@ class MongoRepository {
278
278
  });
279
279
  }
280
280
  deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params) {
281
+ var _a;
281
282
  return __awaiter(this, void 0, void 0, function* () {
282
- return this.priceSpecificationModel.deleteMany({
283
- 'project.id': { $eq: params.project.id },
284
- typeOf: { $eq: factory.priceSpecificationType.MovieTicketTypeChargeSpecification },
285
- price: { $eq: 0 }
286
- })
283
+ return this.priceSpecificationModel.deleteMany(Object.assign({ typeOf: { $eq: factory.priceSpecificationType.MovieTicketTypeChargeSpecification }, price: { $eq: 0 } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === 'string')
284
+ ? { 'project.id': { $eq: params.project.id } }
285
+ : undefined))
287
286
  .exec();
288
287
  });
289
288
  }
@@ -269,11 +269,10 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId) {
269
269
  }
270
270
  function processAuthorizeMovieTicket(params, transaction, paymentServiceId) {
271
271
  return (repos) => __awaiter(this, void 0, void 0, function* () {
272
- var _a, _b;
273
- const authorizeResult = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
272
+ const { accountId, checkResult, payAction } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
274
273
  return saveAuthorizeResult({
275
274
  id: transaction.id,
276
- update: Object.assign({ 'object.accountId': (_a = authorizeResult.checkResult) === null || _a === void 0 ? void 0 : _a.movieTickets[0].identifier, 'object.paymentMethod.accountId': (_b = authorizeResult.checkResult) === null || _b === void 0 ? void 0 : _b.movieTickets[0].identifier, 'object.checkResult': authorizeResult.checkResult }, (authorizeResult.payAction !== undefined) ? { 'object.payAction': authorizeResult.payAction } : undefined)
275
+ update: Object.assign({ 'object.accountId': accountId, 'object.paymentMethod.accountId': accountId, 'object.payAction': payAction }, (checkResult !== undefined) ? { 'object.checkResult': checkResult } : undefined)
277
276
  })(repos);
278
277
  });
279
278
  }
@@ -57,9 +57,14 @@ declare function checkByIdentifier(params: {
57
57
  project: ProjectRepo;
58
58
  }) => Promise<ICheckResult>;
59
59
  interface IAuthorizeResult {
60
- checkResult: ICheckResult;
61
- payAction?: factory.action.IAction<factory.action.IAttributes<factory.actionType.PayAction, any, any>>;
60
+ accountId: string;
61
+ checkResult?: ICheckResult;
62
+ payAction: factory.action.trade.pay.IAction;
62
63
  }
64
+ /**
65
+ * MovieTicket承認
66
+ * オーソリサービスが存在するわけではないので、実質着券する
67
+ */
63
68
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string): (repos: {
64
69
  action: ActionRepo;
65
70
  accountingReport: AccountingReportRepo;
@@ -17,6 +17,7 @@ const surfrock = require("@surfrock/sdk");
17
17
  const moment = require("moment-timezone");
18
18
  const credentials_1 = require("../../credentials");
19
19
  const factory = require("../../factory");
20
+ const settings_1 = require("../../settings");
20
21
  const factory_1 = require("./movieTicket/factory");
21
22
  const validation_1 = require("../assetTransaction/pay/movieTicket/validation");
22
23
  const errorHandler_1 = require("../../errorHandler");
@@ -258,14 +259,22 @@ function purchaseNumberAuthResult2movieTickets(params) {
258
259
  }
259
260
  return movieTickets;
260
261
  }
262
+ /**
263
+ * MovieTicket承認
264
+ * オーソリサービスが存在するわけではないので、実質着券する
265
+ */
261
266
  function authorize(params, transaction, paymentServiceId) {
262
267
  return (repos) => __awaiter(this, void 0, void 0, function* () {
263
268
  var _a, _b;
269
+ let accountId;
264
270
  let checkResult;
265
271
  let payAction;
266
272
  try {
267
- // MovieTicket決済の場合、認証
268
- checkResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId)(repos);
273
+ // オプション追加(2023-02-24~)
274
+ if (settings_1.settings.useCheckMovieTicketBeforePay) {
275
+ // MovieTicket決済の場合、認証
276
+ checkResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId)(repos);
277
+ }
269
278
  const paymentMethod = transaction.object.paymentMethod;
270
279
  const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
271
280
  const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
@@ -273,7 +282,10 @@ function authorize(params, transaction, paymentServiceId) {
273
282
  ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
274
283
  : transaction.id;
275
284
  const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
276
- const accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
285
+ accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
286
+ if (typeof accountId !== 'string' || accountId.length === 0) {
287
+ throw new factory.errors.ArgumentNull('object.paymentMethod.movieTickets.identifier');
288
+ }
277
289
  const payObject = {
278
290
  typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
279
291
  id: paymentServiceId,
@@ -284,10 +296,7 @@ function authorize(params, transaction, paymentServiceId) {
284
296
  }, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
285
297
  movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
286
298
  };
287
- const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject],
288
- // agent:Projectに変更(2022-05-19~)
289
- // agent: transaction.agent,
290
- agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
299
+ const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
291
300
  ? { purpose: params.purpose }
292
301
  : { purpose: { typeOf: transaction.typeOf, transactionNumber: transaction.transactionNumber, id: transaction.id } });
293
302
  // 着券させざるをえないが、informPaymentはしない(注文がまだ存在しないため)
@@ -296,7 +305,7 @@ function authorize(params, transaction, paymentServiceId) {
296
305
  catch (error) {
297
306
  throw (0, errorHandler_1.handleMvtkReserveError)(error);
298
307
  }
299
- return Object.assign({ checkResult }, (payAction !== undefined) ? { payAction } : undefined);
308
+ return { accountId, checkResult, payAction };
300
309
  });
301
310
  }
302
311
  exports.authorize = authorize;
@@ -26,6 +26,7 @@ export declare type ISettings = factory.project.ISettings & {
26
26
  useAggregateEntranceGateProjects: string[];
27
27
  useAggregateOfferProjects: string[];
28
28
  useOfferRateLimitProjects: string[];
29
+ useCheckMovieTicketBeforePay: boolean;
29
30
  };
30
31
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
31
32
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
@@ -100,4 +100,4 @@ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrder
100
100
  ? process.env.USE_AGGREGATE_OFFER_PROJECTS.split(',')
101
101
  : [], useOfferRateLimitProjects: (typeof process.env.USE_OFFER_RATE_LIMIT_PROJECTS === 'string')
102
102
  ? process.env.USE_OFFER_RATE_LIMIT_PROJECTS.split(',')
103
- : [] });
103
+ : [], useCheckMovieTicketBeforePay: process.env.USE_CHECK_MOVIE_TICKET_BEFORE_PAY === '1' });
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.289.0-alpha.11",
13
- "@cinerino/sdk": "3.140.0-alpha.11",
12
+ "@chevre/factory": "4.289.0-alpha.12",
13
+ "@cinerino/sdk": "3.140.0-alpha.14",
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.4.0-alpha.15"
123
+ "version": "20.4.0-alpha.16"
124
124
  }