@chevre/domain 21.7.0-alpha.11 → 21.7.0-alpha.12

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,103 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const now = new Date();
12
+ const endDateLt: Date = moment(now)
13
+ // tslint:disable-next-line:no-magic-numbers
14
+ .add(-365, 'days')
15
+ .toDate();
16
+ const startDateLt: Date = moment('2021-02-01T00:00:00Z')
17
+ .toDate();
18
+
19
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
20
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
21
+
22
+ const cursor = transactionRepo.getCursor(
23
+ {
24
+ typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
25
+ startDate: {
26
+ // $exists: true,
27
+ $lt: startDateLt
28
+ }
29
+ // endDate: {
30
+ // $exists: true,
31
+ // $lt: moment(now)
32
+ // // tslint:disable-next-line:no-magic-numbers
33
+ // .add(-365, 'days')
34
+ // .toDate()
35
+ // }
36
+ },
37
+ {
38
+ _id: 1,
39
+ typeOf: 1,
40
+ project: 1,
41
+ startDate: 1,
42
+ endDate: 1,
43
+ object: 1
44
+ }
45
+ );
46
+ console.log('transactions found');
47
+
48
+ let i = 0;
49
+ let updateCount = 0;
50
+ await cursor.eachAsync(async (doc) => {
51
+ i += 1;
52
+ const transaction: Pick<
53
+ chevre.factory.transaction.placeOrder.ITransaction,
54
+ 'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
55
+ > = doc.toObject();
56
+ console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
57
+
58
+ const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
59
+ .isBefore(endDateLt);
60
+ if (isEndDateBefore) {
61
+ updateCount += 1;
62
+ const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
63
+ project: transaction.project,
64
+ name: chevre.factory.taskName.DeleteTransaction,
65
+ status: chevre.factory.taskStatus.Ready,
66
+ runsAt: now,
67
+ remainingNumberOfTries: 3,
68
+ numberOfTried: 0,
69
+ executionResults: [],
70
+ data: {
71
+ object: {
72
+ specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
73
+ endDate: transaction.endDate,
74
+ id: transaction.id,
75
+ object: {
76
+ ...(typeof transaction.object.confirmationNumber === 'string')
77
+ ? { confirmationNumber: transaction.object.confirmationNumber }
78
+ : undefined,
79
+ ...(typeof transaction.object.orderNumber === 'string')
80
+ ? { orderNumber: transaction.object.orderNumber }
81
+ : undefined
82
+ },
83
+ project: transaction.project,
84
+ startDate: transaction.startDate,
85
+ typeOf: transaction.typeOf
86
+ }
87
+ }
88
+ };
89
+ console.log(
90
+ 'saving task...',
91
+ deleteTransactionTask, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
92
+ await taskRepo.saveMany([deleteTransactionTask], { emitImmediately: false });
93
+ console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
94
+ }
95
+ });
96
+
97
+ console.log(i, 'transactions checked');
98
+ console.log(updateCount, 'transactions updated');
99
+ }
100
+
101
+ main()
102
+ .then()
103
+ .catch(console.error);
@@ -18,10 +18,8 @@ async function main() {
18
18
  typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
19
19
  status: { $eq: chevre.factory.transactionStatusType.Confirmed },
20
20
  startDate: {
21
- $lte: moment('2023-04-01T00:00:00Z')
21
+ $lte: moment('2023-08-16T07:26:00Z')
22
22
  .toDate()
23
- // $lte: moment('2023-08-16T07:26:00Z')
24
- // .toDate()
25
23
  },
26
24
  'object.authorizeActions': { $exists: true }
27
25
  },
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import { Connection } from 'mongoose';
2
26
  import * as factory from '../factory';
3
27
  interface IAggregationByStatus {
@@ -193,6 +217,7 @@ export declare class MongoRepository {
193
217
  filter: any;
194
218
  $unset: any;
195
219
  }): Promise<import("mongodb").UpdateResult>;
220
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
196
221
  aggregatePlaceOrder(params: {
197
222
  project?: {
198
223
  id?: {
@@ -776,6 +776,11 @@ class MongoRepository {
776
776
  .exec();
777
777
  });
778
778
  }
779
+ getCursor(conditions, projection) {
780
+ return this.transactionModel.find(conditions, projection)
781
+ .sort({ startDate: factory.sortType.Descending })
782
+ .cursor();
783
+ }
779
784
  aggregatePlaceOrder(params) {
780
785
  return __awaiter(this, void 0, void 0, function* () {
781
786
  const statuses = yield Promise.all([
@@ -20,4 +20,18 @@ export declare function createConfirmReservationActionObject4COAByOrder(params:
20
20
  export declare function createConfirmRegisterServiceActionObjectByOrder(params: {
21
21
  order: factory.order.IOrder;
22
22
  }): factory.action.interact.confirm.registerService.IObject[];
23
+ export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
24
+ /**
25
+ * 注文作成後のアクション
26
+ */
27
+ export declare function createOnPlaceOrderTasksByTransaction(params: {
28
+ object: factory.order.IOrder | IExternalOrder;
29
+ potentialActions?: factory.action.trade.order.IPotentialActions;
30
+ }): factory.task.IAttributes<factory.taskName>[];
31
+ /**
32
+ * 注文配送後のアクション
33
+ */
34
+ export declare function createOnOrderSentTasksByTransaction(params: {
35
+ potentialActions?: factory.action.transfer.send.order.IPotentialActions;
36
+ }): (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/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/orderProgramMembership").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)[];
23
37
  export {};
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  var _a;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
13
+ exports.createOnOrderSentTasksByTransaction = exports.createOnPlaceOrderTasksByTransaction = exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
14
14
  const google_libphonenumber_1 = require("google-libphonenumber");
15
15
  const jwt = require("jsonwebtoken");
16
16
  const util_1 = require("util");
@@ -262,3 +262,178 @@ function createConfirmRegisterServiceActionObjectByOrder(params) {
262
262
  });
263
263
  }
264
264
  exports.createConfirmRegisterServiceActionObjectByOrder = createConfirmRegisterServiceActionObjectByOrder;
265
+ /**
266
+ * 注文作成後のアクション
267
+ */
268
+ // export function onPlaceOrder(params: {
269
+ // object: factory.order.IOrder | IExternalOrder;
270
+ // potentialActions?: factory.action.trade.order.IPotentialActions;
271
+ // }) {
272
+ // return async (repos: {
273
+ // task: TaskRepo;
274
+ // }) => {
275
+ // const potentialActions = params.potentialActions;
276
+ // const now = new Date();
277
+ // // potentialActionsのためのタスクを生成
278
+ // const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
279
+ // // tslint:disable-next-line:no-single-line-block-comment
280
+ // /* istanbul ignore else */
281
+ // if (potentialActions !== undefined) {
282
+ // // tslint:disable-next-line:no-single-line-block-comment
283
+ // /* istanbul ignore else */
284
+ // if (potentialActions.sendOrder !== undefined) {
285
+ // const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
286
+ // project: potentialActions.sendOrder.project,
287
+ // name: factory.taskName.SendOrder,
288
+ // status: factory.taskStatus.Ready,
289
+ // runsAt: now, // なるはやで実行
290
+ // remainingNumberOfTries: 10,
291
+ // numberOfTried: 0,
292
+ // executionResults: [],
293
+ // // data: potentialActions.sendOrder
294
+ // data: {
295
+ // project: potentialActions.sendOrder.project,
296
+ // object: {
297
+ // ...potentialActions.sendOrder.object,
298
+ // confirmationNumber: params.object.confirmationNumber
299
+ // },
300
+ // ...(potentialActions.sendOrder.potentialActions !== undefined)
301
+ // ? { potentialActions: potentialActions.sendOrder.potentialActions }
302
+ // : undefined
303
+ // }
304
+ // };
305
+ // taskAttributes.push(sendOrderTask);
306
+ // }
307
+ // // ポイント付与
308
+ // // tslint:disable-next-line:no-single-line-block-comment
309
+ // /* istanbul ignore else */
310
+ // if (Array.isArray(potentialActions.givePointAward)) {
311
+ // taskAttributes.push(...potentialActions.givePointAward.map(
312
+ // (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
313
+ // return {
314
+ // project: a.project,
315
+ // name: factory.taskName.GivePointAward,
316
+ // status: factory.taskStatus.Ready,
317
+ // runsAt: now, // なるはやで実行
318
+ // remainingNumberOfTries: 10,
319
+ // numberOfTried: 0,
320
+ // executionResults: [],
321
+ // data: a
322
+ // };
323
+ // }));
324
+ // }
325
+ // }
326
+ // // タスク保管
327
+ // await repos.task.saveMany(taskAttributes, { emitImmediately: true });
328
+ // };
329
+ // }
330
+ function createOnPlaceOrderTasksByTransaction(params) {
331
+ const potentialActions = params.potentialActions;
332
+ const now = new Date();
333
+ // potentialActionsのためのタスクを生成
334
+ const taskAttributes = [];
335
+ // tslint:disable-next-line:no-single-line-block-comment
336
+ /* istanbul ignore else */
337
+ if (potentialActions !== undefined) {
338
+ // tslint:disable-next-line:no-single-line-block-comment
339
+ /* istanbul ignore else */
340
+ if (potentialActions.sendOrder !== undefined) {
341
+ const sendOrderTask = {
342
+ project: potentialActions.sendOrder.project,
343
+ name: factory.taskName.SendOrder,
344
+ status: factory.taskStatus.Ready,
345
+ runsAt: now,
346
+ remainingNumberOfTries: 10,
347
+ numberOfTried: 0,
348
+ executionResults: [],
349
+ data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
350
+ ? { potentialActions: potentialActions.sendOrder.potentialActions }
351
+ : undefined)
352
+ };
353
+ taskAttributes.push(sendOrderTask);
354
+ }
355
+ // ポイント付与
356
+ // tslint:disable-next-line:no-single-line-block-comment
357
+ /* istanbul ignore else */
358
+ if (Array.isArray(potentialActions.givePointAward)) {
359
+ taskAttributes.push(...potentialActions.givePointAward.map((a) => {
360
+ return {
361
+ project: a.project,
362
+ name: factory.taskName.GivePointAward,
363
+ status: factory.taskStatus.Ready,
364
+ runsAt: now,
365
+ remainingNumberOfTries: 10,
366
+ numberOfTried: 0,
367
+ executionResults: [],
368
+ data: a
369
+ };
370
+ }));
371
+ }
372
+ }
373
+ return taskAttributes;
374
+ }
375
+ exports.createOnPlaceOrderTasksByTransaction = createOnPlaceOrderTasksByTransaction;
376
+ /**
377
+ * 注文配送後のアクション
378
+ */
379
+ function createOnOrderSentTasksByTransaction(params) {
380
+ const potentialActions = params.potentialActions;
381
+ const now = new Date();
382
+ const taskAttributes = [];
383
+ // tslint:disable-next-line:no-single-line-block-comment
384
+ /* istanbul ignore else */
385
+ if (potentialActions !== undefined) {
386
+ if (Array.isArray(potentialActions.registerService)) {
387
+ taskAttributes.push(...potentialActions.registerService.map((a) => {
388
+ return {
389
+ project: a.project,
390
+ name: factory.taskName.ConfirmRegisterService,
391
+ status: factory.taskStatus.Ready,
392
+ runsAt: now,
393
+ remainingNumberOfTries: 10,
394
+ numberOfTried: 0,
395
+ executionResults: [],
396
+ data: a
397
+ };
398
+ }));
399
+ }
400
+ // 通貨転送
401
+ // tslint:disable-next-line:no-single-line-block-comment
402
+ /* istanbul ignore else */
403
+ if (Array.isArray(potentialActions.moneyTransfer)) {
404
+ taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
405
+ return {
406
+ project: a.project,
407
+ name: factory.taskName.ConfirmMoneyTransfer,
408
+ status: factory.taskStatus.Ready,
409
+ runsAt: now,
410
+ remainingNumberOfTries: 10,
411
+ numberOfTried: 0,
412
+ executionResults: [],
413
+ data: a
414
+ };
415
+ }));
416
+ }
417
+ // tslint:disable-next-line:no-single-line-block-comment
418
+ /* istanbul ignore else */
419
+ if (Array.isArray(potentialActions.sendEmailMessage)) {
420
+ potentialActions.sendEmailMessage.forEach((s) => {
421
+ const sendEmailMessageTask = {
422
+ project: s.project,
423
+ name: factory.taskName.SendEmailMessage,
424
+ status: factory.taskStatus.Ready,
425
+ runsAt: now,
426
+ remainingNumberOfTries: 3,
427
+ numberOfTried: 0,
428
+ executionResults: [],
429
+ data: {
430
+ actionAttributes: s
431
+ }
432
+ };
433
+ taskAttributes.push(sendEmailMessageTask);
434
+ });
435
+ }
436
+ }
437
+ return taskAttributes;
438
+ }
439
+ exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
@@ -1,6 +1,7 @@
1
1
  import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
2
2
  import { MongoRepository as TaskRepo } from '../../repo/task';
3
3
  import * as factory from '../../factory';
4
+ import { IExternalOrder } from './onOrderStatusChanged/factory';
4
5
  type IPlaceOrderTransaction = factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
5
6
  type IReturnOrderTransaction = factory.transaction.ITransaction<factory.transactionType.ReturnOrder>;
6
7
  export declare function onOrderStatusChanged(params: {
@@ -11,5 +12,4 @@ export declare function onOrderStatusChanged(params: {
11
12
  registerActionInProgress: RegisterServiceInProgressRepo;
12
13
  task: TaskRepo;
13
14
  }) => Promise<void>;
14
- export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
15
- export {};
15
+ export { IExternalOrder };
@@ -23,7 +23,7 @@ const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTE
23
23
  const TOKEN_EXPIRES_IN = 604800;
24
24
  function onOrderStatusChanged(params) {
25
25
  return (repos) => __awaiter(this, void 0, void 0, function* () {
26
- var _a, _b, _c;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h;
27
27
  let tasks = [];
28
28
  const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
29
29
  const simpleOrder = {
@@ -41,7 +41,13 @@ function onOrderStatusChanged(params) {
41
41
  };
42
42
  switch (params.order.orderStatus) {
43
43
  case factory.orderStatus.OrderDelivered:
44
- tasks = (0, factory_1.createInformTasks)(params.order);
44
+ tasks = [
45
+ ...(0, factory_1.createInformTasks)(params.order),
46
+ // 取引のpotentialActionsを適用(2023-08-17~)
47
+ ...(0, factory_1.createOnOrderSentTasksByTransaction)({
48
+ potentialActions: (_e = (_d = (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.potentialActions) === null || _d === void 0 ? void 0 : _d.sendOrder) === null || _e === void 0 ? void 0 : _e.potentialActions
49
+ })
50
+ ];
45
51
  // プロダクト登録プロセスロック解除
46
52
  try {
47
53
  const placeOrderTransaction = params.placeOrderTransaction;
@@ -79,10 +85,10 @@ function onOrderStatusChanged(params) {
79
85
  ...yield createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
80
86
  ...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
81
87
  // 取引のpotentialActionsを適用(2023-08-17~)
82
- ...createOnPlaceOrderTasksByTransaction({
88
+ ...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
83
89
  object: params.order,
84
90
  // potentialActions: params.potentialActions
85
- potentialActions: (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.potentialActions
91
+ potentialActions: (_h = (_g = (_f = params.placeOrderTransaction) === null || _f === void 0 ? void 0 : _f.potentialActions) === null || _g === void 0 ? void 0 : _g.order) === null || _h === void 0 ? void 0 : _h.potentialActions
86
92
  })
87
93
  ];
88
94
  break;
@@ -370,113 +376,3 @@ function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
370
376
  return tasks;
371
377
  });
372
378
  }
373
- /**
374
- * 注文作成後のアクション
375
- */
376
- // export function onPlaceOrder(params: {
377
- // object: factory.order.IOrder | IExternalOrder;
378
- // potentialActions?: factory.action.trade.order.IPotentialActions;
379
- // }) {
380
- // return async (repos: {
381
- // task: TaskRepo;
382
- // }) => {
383
- // const potentialActions = params.potentialActions;
384
- // const now = new Date();
385
- // // potentialActionsのためのタスクを生成
386
- // const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
387
- // // tslint:disable-next-line:no-single-line-block-comment
388
- // /* istanbul ignore else */
389
- // if (potentialActions !== undefined) {
390
- // // tslint:disable-next-line:no-single-line-block-comment
391
- // /* istanbul ignore else */
392
- // if (potentialActions.sendOrder !== undefined) {
393
- // const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
394
- // project: potentialActions.sendOrder.project,
395
- // name: factory.taskName.SendOrder,
396
- // status: factory.taskStatus.Ready,
397
- // runsAt: now, // なるはやで実行
398
- // remainingNumberOfTries: 10,
399
- // numberOfTried: 0,
400
- // executionResults: [],
401
- // // data: potentialActions.sendOrder
402
- // data: {
403
- // project: potentialActions.sendOrder.project,
404
- // object: {
405
- // ...potentialActions.sendOrder.object,
406
- // confirmationNumber: params.object.confirmationNumber
407
- // },
408
- // ...(potentialActions.sendOrder.potentialActions !== undefined)
409
- // ? { potentialActions: potentialActions.sendOrder.potentialActions }
410
- // : undefined
411
- // }
412
- // };
413
- // taskAttributes.push(sendOrderTask);
414
- // }
415
- // // ポイント付与
416
- // // tslint:disable-next-line:no-single-line-block-comment
417
- // /* istanbul ignore else */
418
- // if (Array.isArray(potentialActions.givePointAward)) {
419
- // taskAttributes.push(...potentialActions.givePointAward.map(
420
- // (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
421
- // return {
422
- // project: a.project,
423
- // name: factory.taskName.GivePointAward,
424
- // status: factory.taskStatus.Ready,
425
- // runsAt: now, // なるはやで実行
426
- // remainingNumberOfTries: 10,
427
- // numberOfTried: 0,
428
- // executionResults: [],
429
- // data: a
430
- // };
431
- // }));
432
- // }
433
- // }
434
- // // タスク保管
435
- // await repos.task.saveMany(taskAttributes, { emitImmediately: true });
436
- // };
437
- // }
438
- function createOnPlaceOrderTasksByTransaction(params) {
439
- const potentialActions = params.potentialActions;
440
- const now = new Date();
441
- // potentialActionsのためのタスクを生成
442
- const taskAttributes = [];
443
- // tslint:disable-next-line:no-single-line-block-comment
444
- /* istanbul ignore else */
445
- if (potentialActions !== undefined) {
446
- // tslint:disable-next-line:no-single-line-block-comment
447
- /* istanbul ignore else */
448
- if (potentialActions.sendOrder !== undefined) {
449
- const sendOrderTask = {
450
- project: potentialActions.sendOrder.project,
451
- name: factory.taskName.SendOrder,
452
- status: factory.taskStatus.Ready,
453
- runsAt: now,
454
- remainingNumberOfTries: 10,
455
- numberOfTried: 0,
456
- executionResults: [],
457
- data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
458
- ? { potentialActions: potentialActions.sendOrder.potentialActions }
459
- : undefined)
460
- };
461
- taskAttributes.push(sendOrderTask);
462
- }
463
- // ポイント付与
464
- // tslint:disable-next-line:no-single-line-block-comment
465
- /* istanbul ignore else */
466
- if (Array.isArray(potentialActions.givePointAward)) {
467
- taskAttributes.push(...potentialActions.givePointAward.map((a) => {
468
- return {
469
- project: a.project,
470
- name: factory.taskName.GivePointAward,
471
- status: factory.taskStatus.Ready,
472
- runsAt: now,
473
- remainingNumberOfTries: 10,
474
- numberOfTried: 0,
475
- executionResults: [],
476
- data: a
477
- };
478
- }));
479
- }
480
- }
481
- return taskAttributes;
482
- }
@@ -34,7 +34,6 @@ declare function placeOrder(params: {
34
34
  confirmationNumber: string;
35
35
  orderNumber: string;
36
36
  };
37
- potentialActions?: factory.action.trade.order.IPotentialActions;
38
37
  useOnOrderStatusChanged: boolean;
39
38
  }): (repos: {
40
39
  accountingReport: AccountingReportRepo;
@@ -153,6 +153,9 @@ exports.placeOrderWithoutTransaction = placeOrderWithoutTransaction;
153
153
  function placeOrder(params) {
154
154
  return (repos) => __awaiter(this, void 0, void 0, function* () {
155
155
  var _a;
156
+ if (typeof params.useOnOrderStatusChanged !== 'boolean') {
157
+ throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
158
+ }
156
159
  // 注文番号から取引と注文をfixする
157
160
  const { order, placeOrderTransaction } = yield createOrderFromBody({
158
161
  project: { id: params.project.id },
@@ -216,9 +219,6 @@ function placeOrder(params) {
216
219
  }
217
220
  yield repos.action.complete({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
218
221
  }
219
- if (typeof params.useOnOrderStatusChanged !== 'boolean') {
220
- throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
221
- }
222
222
  if (params.useOnOrderStatusChanged) {
223
223
  // 経理レポートを保管
224
224
  yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(order)({ accountingReport: repos.accountingReport });
@@ -25,7 +25,6 @@ declare function sendOrder(params: {
25
25
  confirmationNumber: string;
26
26
  orderNumber: string;
27
27
  };
28
- potentialActions?: factory.action.transfer.send.order.IPotentialActions;
29
28
  useOnOrderStatusChanged: boolean;
30
29
  }): ISendOperation<void>;
31
30
  export { sendOrder };
@@ -22,6 +22,9 @@ function sendOrder(params) {
22
22
  // tslint:disable-next-line:max-func-body-length
23
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
24
  var _a;
25
+ if (typeof params.useOnOrderStatusChanged !== 'boolean') {
26
+ throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
27
+ }
25
28
  try {
26
29
  const orderNumber = params.object.orderNumber;
27
30
  const confirmationNumber = params.object.confirmationNumber;
@@ -96,7 +99,7 @@ function sendOrder(params) {
96
99
  }
97
100
  const result = ownershipInfos;
98
101
  yield repos.action.complete({ typeOf: sendOrderActionAttributes.typeOf, id: action.id, result: result });
99
- if (params.useOnOrderStatusChanged || params.useOnOrderStatusChanged === undefined) {
102
+ if (params.useOnOrderStatusChanged) {
100
103
  yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({ order, placeOrderTransaction })({
101
104
  registerActionInProgress: repos.registerActionInProgress,
102
105
  task: repos.task
@@ -119,73 +122,8 @@ function sendOrder(params) {
119
122
  throw error;
120
123
  }
121
124
  }
122
- yield onSend(params)({ task: repos.task });
125
+ // onOrderStatusChangedへ移行(2023-08-17~)
126
+ // await onSend(params)({ task: repos.task });
123
127
  });
124
128
  }
125
129
  exports.sendOrder = sendOrder;
126
- /**
127
- * 注文配送後のアクション
128
- */
129
- function onSend(params) {
130
- return (repos) => __awaiter(this, void 0, void 0, function* () {
131
- const potentialActions = params.potentialActions;
132
- const now = new Date();
133
- const taskAttributes = [];
134
- // tslint:disable-next-line:no-single-line-block-comment
135
- /* istanbul ignore else */
136
- if (potentialActions !== undefined) {
137
- if (Array.isArray(potentialActions.registerService)) {
138
- taskAttributes.push(...potentialActions.registerService.map((a) => {
139
- return {
140
- project: a.project,
141
- name: factory.taskName.ConfirmRegisterService,
142
- status: factory.taskStatus.Ready,
143
- runsAt: now,
144
- remainingNumberOfTries: 10,
145
- numberOfTried: 0,
146
- executionResults: [],
147
- data: a
148
- };
149
- }));
150
- }
151
- // 通貨転送
152
- // tslint:disable-next-line:no-single-line-block-comment
153
- /* istanbul ignore else */
154
- if (Array.isArray(potentialActions.moneyTransfer)) {
155
- taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
156
- return {
157
- project: a.project,
158
- name: factory.taskName.ConfirmMoneyTransfer,
159
- status: factory.taskStatus.Ready,
160
- runsAt: now,
161
- remainingNumberOfTries: 10,
162
- numberOfTried: 0,
163
- executionResults: [],
164
- data: a
165
- };
166
- }));
167
- }
168
- // tslint:disable-next-line:no-single-line-block-comment
169
- /* istanbul ignore else */
170
- if (Array.isArray(potentialActions.sendEmailMessage)) {
171
- potentialActions.sendEmailMessage.forEach((s) => {
172
- const sendEmailMessageTask = {
173
- project: s.project,
174
- name: factory.taskName.SendEmailMessage,
175
- status: factory.taskStatus.Ready,
176
- runsAt: now,
177
- remainingNumberOfTries: 3,
178
- numberOfTried: 0,
179
- executionResults: [],
180
- data: {
181
- actionAttributes: s
182
- }
183
- };
184
- taskAttributes.push(sendEmailMessageTask);
185
- });
186
- }
187
- }
188
- // タスク保管
189
- yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
190
- });
191
- }
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.7.0-alpha.11"
120
+ "version": "21.7.0-alpha.12"
121
121
  }