@chevre/domain 21.18.0-alpha.11 → 21.18.0-alpha.13

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.
Files changed (38) hide show
  1. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
  2. package/example/src/chevre/searchOrders.ts +11 -0
  3. package/example/src/chevre/searchReservationsByOrder.ts +30 -0
  4. package/example/src/chevre/searchTransactions.ts +41 -0
  5. package/lib/chevre/repo/acceptedOffer.d.ts +7 -0
  6. package/lib/chevre/repo/acceptedOffer.js +28 -0
  7. package/lib/chevre/repo/order.d.ts +2 -1
  8. package/lib/chevre/repo/order.js +10 -5
  9. package/lib/chevre/repo/transaction.d.ts +5 -4
  10. package/lib/chevre/repository.d.ts +0 -7
  11. package/lib/chevre/repository.js +1 -18
  12. package/lib/chevre/service/offer/product.d.ts +0 -14
  13. package/lib/chevre/service/offer/product.js +59 -42
  14. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
  15. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
  16. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +5 -2
  17. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  18. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +2 -2
  19. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  20. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +2 -4
  21. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +15 -32
  22. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +1 -1
  23. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
  24. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +2 -2
  25. package/lib/chevre/service/order/placeOrder.js +59 -11
  26. package/lib/chevre/service/order/returnOrder.js +28 -10
  27. package/lib/chevre/service/order/sendOrder.d.ts +0 -2
  28. package/lib/chevre/service/order/sendOrder.js +9 -2
  29. package/lib/chevre/service/payment/any.js +1 -1
  30. package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
  31. package/lib/chevre/service/reserve/searchByOrder.js +113 -0
  32. package/lib/chevre/service/reserve.d.ts +2 -1
  33. package/lib/chevre/service/reserve.js +3 -1
  34. package/lib/chevre/service/task/sendOrder.js +3 -7
  35. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
  36. package/package.json +1 -1
  37. package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
  38. package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
@@ -0,0 +1,24 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
12
+
13
+ const ownershipInfos = await acceptedOfferRepo.aggreateOwnershipInfosByOrder(
14
+ {
15
+ orderNumber: { $eq: 'CIN4-3943271-4221863' }
16
+ }
17
+ );
18
+ // tslint:disable-next-line:no-null-keyword
19
+ console.dir(ownershipInfos, { depth: 1 });
20
+ }
21
+
22
+ main()
23
+ .then()
24
+ .catch(console.error);
@@ -10,6 +10,17 @@ async function main() {
10
10
 
11
11
  const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
12
12
 
13
+ const order = await orderRepo.findByOrderNumber({
14
+ orderNumber: 'CIN4-3943271-4221863',
15
+ project: { id: project.id },
16
+ inclusion: [
17
+ 'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
18
+ 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
19
+ ],
20
+ exclusion: []
21
+ });
22
+ console.log(order);
23
+
13
24
  const orders = await orderRepo.search(
14
25
  {
15
26
  limit: 10,
@@ -0,0 +1,30 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const { reservations } = await (await chevre.service.reserve.createService()).searchByOrder({
12
+ limit: 10,
13
+ page: 1,
14
+ project: { id: project.id },
15
+ orderNumber: 'CIN3-0760465-8981560',
16
+ // orderNumber: 'SSK1-3743647-5975553',
17
+ // orderNumber: 'SSK9-4864565-8689164',
18
+ typeOf: chevre.factory.reservationType.EventReservation
19
+ })({
20
+ acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
21
+ order: await chevre.repository.Order.createInstance(mongoose.connection),
22
+ reservation: await chevre.repository.Reservation.createInstance(mongoose.connection)
23
+ });
24
+ console.log(reservations);
25
+ console.log(reservations.length, 'reservations found');
26
+ }
27
+
28
+ main()
29
+ .then(console.log)
30
+ .catch(console.error);
@@ -0,0 +1,41 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
12
+
13
+ const transactions = await transactionRepo.search<chevre.factory.transactionType.PlaceOrder>({
14
+ limit: 1,
15
+ page: 1,
16
+ project: { id: { $eq: project.id } },
17
+ typeOf: chevre.factory.transactionType.PlaceOrder,
18
+ statuses: [chevre.factory.transactionStatusType.Confirmed],
19
+ result: {
20
+ order: {
21
+ confirmationNumber: { $eq: '14438' },
22
+ orderNumbers: ['CIN3-0760465-8981560']
23
+ }
24
+ },
25
+ inclusion: ['id'],
26
+ exclusion: []
27
+ });
28
+ console.log('transactions found', transactions);
29
+ console.log(transactions.length, 'transactions found');
30
+
31
+ const transaction = await transactionRepo.findById({
32
+ typeOf: chevre.factory.transactionType.PlaceOrder,
33
+ id: '6570f9d7834f9638ceec86ad',
34
+ inclusion: ['_id', 'typeOf', 'status']
35
+ });
36
+ console.log('transaction found', transaction);
37
+ }
38
+
39
+ main()
40
+ .then()
41
+ .catch(console.error);
@@ -16,6 +16,13 @@ export declare class MongoRepository {
16
16
  * オファー展開の注文検索
17
17
  */
18
18
  searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
19
+ aggreateOwnershipInfosByOrder(filter: {
20
+ orderNumber: {
21
+ $eq: string;
22
+ };
23
+ }): Promise<{
24
+ identifier: string;
25
+ }[]>;
19
26
  /**
20
27
  * 注文オファーを展開して検索する
21
28
  */
@@ -51,6 +51,34 @@ class MongoRepository {
51
51
  .exec();
52
52
  });
53
53
  }
54
+ aggreateOwnershipInfosByOrder(filter) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const aggregate = this.orderModel.aggregate([
57
+ {
58
+ $unwind: {
59
+ path: '$acceptedOffers',
60
+ includeArrayIndex: 'acceptedOfferIndex'
61
+ }
62
+ },
63
+ { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
64
+ {
65
+ $project: {
66
+ _id: 0,
67
+ // acceptedOfferIndex: '$acceptedOfferIndex',
68
+ // itemOfferedTypeOf: '$acceptedOffers.itemOffered.typeOf',
69
+ // customerId: '$customer.id',
70
+ // orderNumber: '$orderNumber',
71
+ identifier: {
72
+ $concat: ['$customer.id', '-', '$acceptedOffers.itemOffered.typeOf', '-', '$orderNumber', '-', { $toString: '$acceptedOfferIndex' }]
73
+ }
74
+ }
75
+ }
76
+ ]);
77
+ return aggregate
78
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
79
+ .exec();
80
+ });
81
+ }
54
82
  /**
55
83
  * 注文オファーを展開して検索する
56
84
  */
@@ -25,6 +25,7 @@
25
25
  import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  type IKeyOfProjection = keyof Omit<factory.order.IOrder, 'acceptedOffers'> | '_id';
28
+ export type IReturnedOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'>;
28
29
  /**
29
30
  * 注文リポジトリ
30
31
  */
@@ -57,7 +58,7 @@ export declare class MongoRepository {
57
58
  orderNumber: string;
58
59
  dateReturned: Date;
59
60
  returner: factory.order.IReturner;
60
- }): Promise<factory.order.IOrder>;
61
+ }): Promise<IReturnedOrder>;
61
62
  /**
62
63
  * 変更可能な属性を更新する
63
64
  */
@@ -741,9 +741,11 @@ class MongoRepository {
741
741
  }, {
742
742
  new: true,
743
743
  projection: {
744
- __v: 0,
745
- createdAt: 0,
746
- updatedAt: 0
744
+ _id: 1, project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
745
+ customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
746
+ // __v: 0,
747
+ // createdAt: 0,
748
+ // updatedAt: 0
747
749
  }
748
750
  })
749
751
  .exec();
@@ -752,8 +754,11 @@ class MongoRepository {
752
754
  const order = yield this.findByOrderNumber({
753
755
  orderNumber: params.orderNumber,
754
756
  project: { id: params.project.id },
755
- inclusion: [],
756
- exclusion: []
757
+ inclusion: [
758
+ 'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
759
+ 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
760
+ ],
761
+ exclusion: [] // 除外(2023-12-07~)
757
762
  });
758
763
  // tslint:disable-next-line:no-single-line-block-comment
759
764
  /* istanbul ignore next */
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
+ type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
27
28
  interface IAggregationByStatus {
28
29
  transactionCount: number;
29
30
  avgDuration: number;
@@ -64,8 +65,8 @@ export declare class MongoRepository {
64
65
  findById<T extends factory.transactionType>(params: {
65
66
  typeOf: T;
66
67
  id: string;
67
- inclusion?: string[];
68
- exclusion?: string[];
68
+ inclusion?: IKeyOfProjection<T>[];
69
+ exclusion?: IKeyOfProjection<T>[];
69
70
  }): Promise<factory.transaction.ITransaction<T>>;
70
71
  /**
71
72
  * 進行中の取引を取得する
@@ -187,8 +188,8 @@ export declare class MongoRepository {
187
188
  * 取引を検索する
188
189
  */
189
190
  search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T> & {
190
- inclusion: string[];
191
- exclusion: string[];
191
+ inclusion: IKeyOfProjection<T>[];
192
+ exclusion: IKeyOfProjection<T>[];
192
193
  }): Promise<factory.transaction.ITransaction<T>[]>;
193
194
  /**
194
195
  * 特定の取引を更新する(汎用)
@@ -47,7 +47,6 @@ import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
47
47
  import type { MongoRepository as TransactionRepo } from './repo/transaction';
48
48
  import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
49
49
  import type { MongoRepository as TripRepo } from './repo/trip';
50
- import type { RedisRepository as RegisterServiceActionInProgress } from './repo/action/registerServiceInProgress';
51
50
  import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
52
51
  import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
53
52
  import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
@@ -88,12 +87,6 @@ export type Aggregation = AggregationRepo;
88
87
  export declare namespace Aggregation {
89
88
  function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
90
89
  }
91
- export declare namespace action {
92
- type RegisterServiceInProgress = RegisterServiceActionInProgress;
93
- namespace RegisterServiceInProgress {
94
- function createInstance(...params: ConstructorParameters<typeof RegisterServiceActionInProgress>): Promise<RegisterServiceActionInProgress>;
95
- }
96
- }
97
90
  export type AssetTransaction = AssetTransactionRepo;
98
91
  export declare namespace AssetTransaction {
99
92
  function createInstance(...params: ConstructorParameters<typeof AssetTransactionRepo>): Promise<AssetTransactionRepo>;
@@ -9,8 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.rateLimit = void 0;
12
+ exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
14
13
  var AcceptedOffer;
15
14
  (function (AcceptedOffer) {
16
15
  let repo;
@@ -128,22 +127,6 @@ var Aggregation;
128
127
  }
129
128
  Aggregation.createInstance = createInstance;
130
129
  })(Aggregation = exports.Aggregation || (exports.Aggregation = {}));
131
- var action;
132
- (function (action) {
133
- let RegisterServiceInProgress;
134
- (function (RegisterServiceInProgress) {
135
- let repo;
136
- function createInstance(...params) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- if (repo === undefined) {
139
- repo = (yield Promise.resolve().then(() => require('./repo/action/registerServiceInProgress'))).RedisRepository;
140
- }
141
- return new repo(...params);
142
- });
143
- }
144
- RegisterServiceInProgress.createInstance = createInstance;
145
- })(RegisterServiceInProgress = action.RegisterServiceInProgress || (action.RegisterServiceInProgress = {}));
146
- })(action = exports.action || (exports.action = {}));
147
130
  var AssetTransaction;
148
131
  (function (AssetTransaction) {
149
132
  let repo;
@@ -1,7 +1,6 @@
1
1
  import * as factory from '../../factory';
2
2
  import type { MongoRepository as AccountRepo } from '../../repo/account';
3
3
  import type { MongoRepository as ActionRepo } from '../../repo/action';
4
- import type { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
5
4
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
6
5
  import type { MongoRepository as OfferRepo } from '../../repo/offer';
7
6
  import type { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
@@ -23,7 +22,6 @@ export interface IAuthorizeOperationRepos {
23
22
  ownershipInfo: OwnershipInfoRepo;
24
23
  product: ProductRepo;
25
24
  project: ProjectRepo;
26
- registerActionInProgress: RegisterServiceInProgressRepo;
27
25
  serviceOutput: ServiceOutputRepo;
28
26
  serviceOutputIdentifier: ServiceOutputIdentifierRepo;
29
27
  transaction: TransactionRepo;
@@ -94,17 +92,5 @@ export declare function authorize(params: {
94
92
  export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): (repos: {
95
93
  action: ActionRepo;
96
94
  assetTransaction: AssetTransactionRepo;
97
- registerActionInProgress: RegisterServiceInProgressRepo;
98
95
  transaction: TransactionRepo;
99
96
  }) => Promise<void>;
100
- export declare function processUnlockRegisterMembershipService(params: {
101
- agent: {
102
- id: string;
103
- };
104
- product: {
105
- id: string;
106
- };
107
- purpose: factory.action.authorize.offer.product.IPurpose;
108
- }): (repos: {
109
- registerActionInProgress: RegisterServiceInProgressRepo;
110
- }) => Promise<void>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.processUnlockRegisterMembershipService = exports.voidTransaction = exports.authorize = exports.search = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
12
+ exports.voidTransaction = exports.authorize = exports.search = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../../factory");
15
15
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
@@ -129,11 +129,12 @@ function authorize(params) {
129
129
  try {
130
130
  // 会員の場合のみ排他ロック
131
131
  if (params.agent.typeOf === factory.personType.Person) {
132
- yield processLockRegisterMembershipService({
133
- agent: params.agent,
134
- product: product,
135
- purpose: { typeOf: transaction.typeOf, id: transaction.id }
136
- })(repos);
132
+ // 廃止(2023-12-07~)
133
+ // await processLockRegisterMembershipService({
134
+ // agent: params.agent,
135
+ // product: product,
136
+ // purpose: { typeOf: transaction.typeOf, id: transaction.id }
137
+ // })(repos);
137
138
  }
138
139
  // サービス登録開始
139
140
  const startParams = (0, factory_1.createRegisterServiceStartParams)({
@@ -155,11 +156,12 @@ function authorize(params) {
155
156
  // no op
156
157
  }
157
158
  try {
158
- yield processUnlockRegisterMembershipService({
159
- agent: params.agent,
160
- product: { id: String(product.id) },
161
- purpose: { typeOf: transaction.typeOf, id: transaction.id }
162
- })(repos);
159
+ // 廃止(2023-12-07~)
160
+ // await processUnlockRegisterMembershipService({
161
+ // agent: params.agent,
162
+ // product: { id: String(product.id) },
163
+ // purpose: { typeOf: transaction.typeOf, id: transaction.id }
164
+ // })(repos);
163
165
  }
164
166
  catch (error) {
165
167
  // 失敗したら仕方ない
@@ -233,11 +235,12 @@ function voidTransaction(params) {
233
235
  var _b, _c;
234
236
  const productId = (_c = (_b = action.object[0]) === null || _b === void 0 ? void 0 : _b.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
235
237
  if (typeof productId === 'string') {
236
- yield processUnlockRegisterMembershipService({
237
- agent: { id: transaction.agent.id },
238
- product: { id: productId },
239
- purpose: params.purpose
240
- })(repos);
238
+ // 廃止(2023-12-07~)
239
+ // await processUnlockRegisterMembershipService({
240
+ // agent: { id: transaction.agent.id },
241
+ // product: { id: productId },
242
+ // purpose: params.purpose
243
+ // })(repos);
241
244
  }
242
245
  yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
243
246
  yield processVoidRegisterServiceTransaction({
@@ -382,29 +385,43 @@ function createServiceOutputIdentifier(params) {
382
385
  })));
383
386
  });
384
387
  }
385
- function processLockRegisterMembershipService(params) {
386
- return (repos) => __awaiter(this, void 0, void 0, function* () {
387
- if (params.product.typeOf === factory.product.ProductType.MembershipService) {
388
- yield repos.registerActionInProgress.lock({
389
- agent: { id: params.agent.id },
390
- product: { id: String(params.product.id) }
391
- }, params.purpose.id);
392
- }
393
- });
394
- }
395
- function processUnlockRegisterMembershipService(params) {
396
- return (repos) => __awaiter(this, void 0, void 0, function* () {
397
- // 登録ロックIDが取引IDであればロック解除
398
- const holder = yield repos.registerActionInProgress.getHolder({
399
- agent: { id: params.agent.id },
400
- product: { id: params.product.id }
401
- });
402
- if (holder === params.purpose.id) {
403
- yield repos.registerActionInProgress.unlock({
404
- agent: { id: params.agent.id },
405
- product: { id: params.product.id }
406
- });
407
- }
408
- });
409
- }
410
- exports.processUnlockRegisterMembershipService = processUnlockRegisterMembershipService;
388
+ // function processLockRegisterMembershipService(params: {
389
+ // agent: { id: string };
390
+ // product: factory.product.IProduct;
391
+ // purpose: factory.action.authorize.offer.product.IPurpose;
392
+ // }) {
393
+ // return async (repos: {
394
+ // registerActionInProgress: RegisterServiceInProgressRepo;
395
+ // }) => {
396
+ // if (params.product.typeOf === factory.product.ProductType.MembershipService) {
397
+ // await repos.registerActionInProgress.lock(
398
+ // {
399
+ // agent: { id: params.agent.id },
400
+ // product: { id: String(params.product.id) }
401
+ // },
402
+ // params.purpose.id
403
+ // );
404
+ // }
405
+ // };
406
+ // }
407
+ // export function processUnlockRegisterMembershipService(params: {
408
+ // agent: { id: string };
409
+ // product: { id: string };
410
+ // purpose: factory.action.authorize.offer.product.IPurpose;
411
+ // }) {
412
+ // return async (repos: {
413
+ // registerActionInProgress: RegisterServiceInProgressRepo;
414
+ // }) => {
415
+ // // 登録ロックIDが取引IDであればロック解除
416
+ // const holder = await repos.registerActionInProgress.getHolder({
417
+ // agent: { id: params.agent.id },
418
+ // product: { id: params.product.id }
419
+ // });
420
+ // if (holder === params.purpose.id) {
421
+ // await repos.registerActionInProgress.unlock({
422
+ // agent: { id: params.agent.id },
423
+ // product: { id: params.product.id }
424
+ // });
425
+ // }
426
+ // };
427
+ // }
@@ -1,5 +1,6 @@
1
1
  import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
2
2
  import * as factory from '../../factory';
3
+ type ITransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'potentialActions' | 'project' | 'typeOf'>;
3
4
  export declare function findPlaceOrderTransaction(params: {
4
5
  project: {
5
6
  id: string;
@@ -8,4 +9,5 @@ export declare function findPlaceOrderTransaction(params: {
8
9
  orderNumber: string;
9
10
  }): (repos: {
10
11
  transaction: TransactionRepo;
11
- }) => Promise<factory.transaction.placeOrder.ITransaction>;
12
+ }) => Promise<ITransaction>;
13
+ export {};
@@ -13,7 +13,6 @@ exports.findPlaceOrderTransaction = void 0;
13
13
  const factory = require("../../factory");
14
14
  function findPlaceOrderTransaction(params) {
15
15
  return (repos) => __awaiter(this, void 0, void 0, function* () {
16
- // 注文取引検索
17
16
  const placeOrderTransactions = yield repos.transaction.search({
18
17
  limit: 1,
19
18
  page: 1,
@@ -26,7 +25,7 @@ function findPlaceOrderTransaction(params) {
26
25
  orderNumbers: [params.orderNumber]
27
26
  }
28
27
  },
29
- inclusion: [],
28
+ inclusion: ['id', 'potentialActions', 'project', 'typeOf'],
30
29
  exclusion: []
31
30
  });
32
31
  const placeOrderTransaction = placeOrderTransactions.shift();
@@ -212,8 +212,11 @@ function cancelOrderIfExist(params) {
212
212
  }
213
213
  if (params.useOnOrderStatusChanged) {
214
214
  yield (0, onOrderStatusChanged_1.onOrderCancelled)({
215
- order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderCancelled // 強制的にOrderCancelledとして処理する
216
- }),
215
+ order: {
216
+ orderDate: order.orderDate,
217
+ orderNumber: order.orderNumber,
218
+ orderStatus: factory.orderStatus.OrderCancelled // 強制的にOrderCancelledとして処理する
219
+ },
217
220
  placeOrderTransaction
218
221
  })({
219
222
  task: repos.task
@@ -6,6 +6,6 @@ import * as factory from '../../../../factory';
6
6
  * 注文中止時のアクション
7
7
  */
8
8
  declare function createOnOrderCancelledTasksByTransaction(params: {
9
- transaction?: factory.transaction.placeOrder.ITransaction;
9
+ transaction?: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
10
10
  }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
11
11
  export { createOnOrderCancelledTasksByTransaction };
@@ -1,8 +1,8 @@
1
1
  import type { MongoRepository as TaskRepo } from '../../../repo/task';
2
2
  import * as factory from '../../../factory';
3
- type IPlaceOrderTransaction = factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
3
+ type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
4
4
  declare function onOrderCancelled(params: {
5
- order: factory.order.IOrder;
5
+ order: Pick<factory.order.IOrder, 'orderNumber' | 'orderDate' | 'orderStatus'>;
6
6
  placeOrderTransaction?: IPlaceOrderTransaction;
7
7
  }): (repos: {
8
8
  task: TaskRepo;
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../../../factory';
2
- type IDeliveredOrder = factory.order.IOrder & {
2
+ type IDeliveredOrder = Pick<factory.order.IOrder, 'id' | 'customer' | 'orderNumber' | 'project' | 'typeOf'> & {
3
3
  orderStatus: factory.orderStatus.OrderDelivered;
4
4
  };
5
5
  declare function createInformTasks(order: IDeliveredOrder): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
@@ -1,14 +1,12 @@
1
- import type { RedisRepository as RegisterServiceInProgressRepo } from '../../../repo/action/registerServiceInProgress';
2
1
  import type { MongoRepository as TaskRepo } from '../../../repo/task';
3
2
  import * as factory from '../../../factory';
4
- type IPlaceOrderTransaction = factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
3
+ type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'potentialActions'>;
5
4
  declare function onOrderDelivered(params: {
6
- order: Omit<factory.order.IOrder, 'orderStatus'> & {
5
+ order: Pick<factory.order.IOrder, 'id' | 'customer' | 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> & {
7
6
  orderStatus: factory.orderStatus.OrderDelivered;
8
7
  };
9
8
  placeOrderTransaction?: IPlaceOrderTransaction;
10
9
  }): (repos: {
11
- registerActionInProgress: RegisterServiceInProgressRepo;
12
10
  task: TaskRepo;
13
11
  }) => Promise<void>;
14
12
  export { onOrderDelivered };