@chevre/domain 20.1.0-alpha.38 → 20.1.0-alpha.39

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.
@@ -35,6 +35,11 @@ export declare class MongoRepository {
35
35
  underName?: factory.reservation.IUnderName<T>;
36
36
  reservedTicket?: factory.reservation.ITicket;
37
37
  }): Promise<factory.reservation.IReservation<T>>;
38
+ confirmByReservationNumber(params: {
39
+ reservationNumber: string;
40
+ previousReservationStatus: factory.reservationStatusType;
41
+ underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
42
+ }): Promise<void>;
38
43
  /**
39
44
  * 予約取消
40
45
  */
@@ -911,6 +911,19 @@ class MongoRepository {
911
911
  return doc.toObject();
912
912
  });
913
913
  }
914
+ confirmByReservationNumber(params) {
915
+ return __awaiter(this, void 0, void 0, function* () {
916
+ const conditions = {
917
+ reservationNumber: { $eq: String(params.reservationNumber) },
918
+ reservationStatus: { $eq: params.previousReservationStatus }
919
+ };
920
+ const update = Object.assign({ reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime: new Date() }, (params.underName !== undefined) ? { underName: params.underName } : undefined
921
+ // ...(params.reservedTicket !== undefined) ? { reservedTicket: params.reservedTicket } : undefined
922
+ );
923
+ yield this.reservationModel.updateMany(conditions, update)
924
+ .exec();
925
+ });
926
+ }
914
927
  /**
915
928
  * 予約取消
916
929
  */
@@ -8,6 +8,7 @@ const moment = require("moment");
8
8
  const factory = require("../../../factory");
9
9
  const accountTransactionIdentifier_1 = require("../../../factory/accountTransactionIdentifier");
10
10
  const price_1 = require("./factory/price");
11
+ const USE_RESERVATION_PACKAGE_AS_OBJECT = process.env.USE_RESERVATION_PACKAGE_AS_OBJECT === '1';
11
12
  function createStartParams(params) {
12
13
  var _a;
13
14
  const reservationNumber = params.reservationNumber;
@@ -425,7 +426,9 @@ function createReservation(params) {
425
426
  : undefined);
426
427
  }
427
428
  exports.createReservation = createReservation;
429
+ // tslint:disable-next-line:max-func-body-length
428
430
  function createPotentialActions(params) {
431
+ var _a;
429
432
  const transaction = params.transaction;
430
433
  const reservationFor = transaction.object.reservationFor;
431
434
  if (reservationFor === undefined) {
@@ -433,55 +436,70 @@ function createPotentialActions(params) {
433
436
  }
434
437
  // 予約アクション属性作成
435
438
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
436
- const reserveActionAttributes = pendingReservations.map((reservation) => {
437
- var _a, _b;
438
- const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
439
- // 不要なので廃止(2022-12-14~)
440
- // if (params.object !== undefined) {
441
- // // 予約属性の指定があれば上書き
442
- // const confirmingReservation = params.object.reservations.find((r) => r.id === eventReservation.id);
443
- // if (confirmingReservation !== undefined) {
444
- // if (confirmingReservation.underName !== undefined) {
445
- // eventReservation.underName = confirmingReservation.underName;
446
- // eventReservation.reservedTicket.underName = confirmingReservation.underName;
447
- // }
448
- // if (confirmingReservation.reservedTicket !== undefined) {
449
- // if (confirmingReservation.reservedTicket.issuedBy !== undefined) {
450
- // eventReservation.reservedTicket.issuedBy = confirmingReservation.reservedTicket.issuedBy;
451
- // }
452
- // }
453
- // }
454
- // }
455
- // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
456
- if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
457
- const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
458
- eventReservation.underName = ordre2reservationUnderNameResult.underName;
459
- // 不要なので廃止(2022-12-19~)
460
- // eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
461
- eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
462
- }
463
- const acceptedOffer4reservation = (_b = transaction.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.find((o) => { var _a, _b; return ((_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id) === reservation.id; });
464
- const moneyTransfer = createMoneyTransferActions({
465
- acceptedOffer: acceptedOffer4reservation,
466
- reservation: eventReservation,
467
- transaction: params.transaction
468
- });
469
- return {
470
- project: transaction.project,
471
- typeOf: factory.actionType.ReserveAction,
472
- result: {},
473
- object: eventReservation,
474
- // プロジェクトに変更(2022-05-26~)
475
- agent: transaction.project,
476
- potentialActions: {
477
- moneyTransfer: moneyTransfer
478
- },
479
- purpose: {
480
- typeOf: transaction.typeOf,
481
- id: transaction.id
439
+ let reserveActionAttributes = [];
440
+ if (pendingReservations.length > 0) {
441
+ // ReservationPackageに対応(2022-12-22~)
442
+ if (USE_RESERVATION_PACKAGE_AS_OBJECT) {
443
+ let underName;
444
+ // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
445
+ if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
446
+ const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
447
+ underName = ordre2reservationUnderNameResult.underName;
482
448
  }
483
- };
484
- });
449
+ const reservationPackage = {
450
+ reservationFor,
451
+ reservationNumber: pendingReservations[0].reservationNumber,
452
+ reservationStatus: pendingReservations[0].reservationStatus,
453
+ subReservation: pendingReservations,
454
+ underName,
455
+ typeOf: factory.reservationType.ReservationPackage
456
+ };
457
+ reserveActionAttributes = [{
458
+ project: transaction.project,
459
+ typeOf: factory.actionType.ReserveAction,
460
+ // result: {},
461
+ object: reservationPackage,
462
+ agent: transaction.project,
463
+ potentialActions: {
464
+ // tslint:disable-next-line:no-suspicious-comment
465
+ // TODO implement
466
+ moneyTransfer: []
467
+ },
468
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
469
+ }];
470
+ }
471
+ else {
472
+ reserveActionAttributes = pendingReservations.map((reservation) => {
473
+ var _a, _b;
474
+ const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
475
+ // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
476
+ if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
477
+ const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
478
+ eventReservation.underName = ordre2reservationUnderNameResult.underName;
479
+ // 不要なので廃止(2022-12-19~)
480
+ // eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
481
+ eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
482
+ }
483
+ const acceptedOffer4reservation = (_b = transaction.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.find((o) => { var _a, _b; return ((_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id) === reservation.id; });
484
+ const moneyTransfer = createMoneyTransferActions({
485
+ acceptedOffer: acceptedOffer4reservation,
486
+ reservation: eventReservation,
487
+ transaction: params.transaction
488
+ });
489
+ return {
490
+ project: transaction.project,
491
+ typeOf: factory.actionType.ReserveAction,
492
+ // result: {},
493
+ object: eventReservation,
494
+ agent: transaction.project,
495
+ potentialActions: {
496
+ moneyTransfer: moneyTransfer
497
+ },
498
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
499
+ };
500
+ });
501
+ }
502
+ }
485
503
  return {
486
504
  reserve: reserveActionAttributes
487
505
  };
@@ -19,6 +19,7 @@ const onReservationConfirmed_1 = require("./potentialActions/onReservationConfir
19
19
  * 予約を確定する
20
20
  */
21
21
  function confirmReservation(actionAttributesList) {
22
+ // tslint:disable-next-line:max-func-body-length
22
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
23
24
  let confirmedReservations = [];
24
25
  if (actionAttributesList.length > 0) {
@@ -26,20 +27,31 @@ function confirmReservation(actionAttributesList) {
26
27
  const reservation = actionAttributes.object;
27
28
  const action = yield repos.action.start(actionAttributes);
28
29
  try {
29
- // 予約を確定状態に変更する
30
- // reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
31
- yield repos.reservation.confirm({
32
- // 更新属性をwhitelist化(2022-06-13~)
33
- // ...actionAttributes.object,
34
- id: reservation.id,
35
- previousReservationStatus: reservation.reservationStatus,
36
- underName: reservation.underName
37
- // issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
38
- // reservedTicket: reservation.reservedTicket
39
- });
40
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
41
- // delete (<any>reservation)._id;
42
- // confirmedReservations.push(reservation);
30
+ // ReservationPackageに対応(2022-12-22~)
31
+ if (reservation.typeOf === factory.reservationType.ReservationPackage) {
32
+ // 予約を確定状態に変更する
33
+ yield repos.reservation.confirmByReservationNumber({
34
+ reservationNumber: reservation.reservationNumber,
35
+ previousReservationStatus: reservation.reservationStatus,
36
+ underName: reservation.underName
37
+ });
38
+ }
39
+ else {
40
+ // 予約を確定状態に変更する
41
+ // reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
42
+ yield repos.reservation.confirm({
43
+ // 更新属性をwhitelist化(2022-06-13~)
44
+ // ...actionAttributes.object,
45
+ id: reservation.id,
46
+ previousReservationStatus: reservation.reservationStatus,
47
+ underName: reservation.underName
48
+ // issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
49
+ // reservedTicket: reservation.reservedTicket
50
+ });
51
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
52
+ // delete (<any>reservation)._id;
53
+ // confirmedReservations.push(reservation);
54
+ }
43
55
  }
44
56
  catch (error) {
45
57
  // actionにエラー結果を追加
@@ -53,9 +65,7 @@ function confirmReservation(actionAttributesList) {
53
65
  throw error;
54
66
  }
55
67
  // アクション完了
56
- const actionResult = {
57
- confirmedReservationId: reservation.id
58
- };
68
+ const actionResult = {};
59
69
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
60
70
  yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
61
71
  })));
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.280.0-alpha.8",
12
+ "@chevre/factory": "4.280.0-alpha.9",
13
13
  "@cinerino/sdk": "3.135.0-alpha.4",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.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.38"
123
+ "version": "20.1.0-alpha.39"
124
124
  }