@chevre/domain 20.2.0-alpha.14 → 20.2.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.
@@ -0,0 +1,83 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: <string>process.env.PROJECT_ID };
8
+ interface IAggregation {
9
+ typeOf: 'AggregateOrder';
10
+ project: { id: string; typeOf: chevre.factory.organizationType.Project };
11
+ aggregateDate: Date;
12
+ aggregateDuration: string;
13
+ aggregateStart: Date;
14
+ orderCount: number;
15
+ acceptedOfferCount: number;
16
+ }
17
+
18
+ async function main() {
19
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
+
21
+ const now: Date = new Date();
22
+
23
+ const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
24
+ const orderRepo = new chevre.repository.Order(mongoose.connection);
25
+
26
+ let i = 0;
27
+ // tslint:disable-next-line:no-magic-numbers
28
+ while (i < 7) {
29
+ i += 1;
30
+
31
+ const orderDateFrom: Date = moment()
32
+ // .tz('Asia/Tokyo')
33
+ .add(-i, 'days')
34
+ .startOf('day')
35
+ .toDate();
36
+ const orderDateThrough: Date = moment()
37
+ // .tz('Asia/Tokyo')
38
+ .add(-i, 'days')
39
+ .endOf('day')
40
+ .toDate();
41
+ // console.log(bookingFrom, bookingThrough);
42
+
43
+ const aggregateResult = await orderRepo.aggregateOrder({
44
+ orderDate: {
45
+ $gte: orderDateFrom,
46
+ $lte: orderDateThrough
47
+ }
48
+ });
49
+
50
+ const aggregation: IAggregation = {
51
+ typeOf: 'AggregateOrder',
52
+ project: { id: '*', typeOf: chevre.factory.organizationType.Project },
53
+ aggregateDuration: moment.duration(1, 'days')
54
+ .toISOString(),
55
+ aggregateStart: orderDateFrom,
56
+ aggregateDate: now,
57
+ orderCount: (aggregateResult.length > 0) ? aggregateResult[0].orderCount : 0,
58
+ acceptedOfferCount: (aggregateResult.length > 0) ? aggregateResult[0].acceptedOfferCount : 0
59
+ };
60
+ const { acceptedOfferCount, orderCount, aggregateDate, ...setOnInsert } = aggregation;
61
+ const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
62
+ {
63
+ typeOf: { $eq: aggregation.typeOf },
64
+ 'project.id': { $eq: aggregation.project.id },
65
+ aggregateStart: { $eq: aggregation.aggregateStart },
66
+ aggregateDuration: { $eq: aggregation.aggregateDuration }
67
+ },
68
+ {
69
+ $setOnInsert: setOnInsert,
70
+ $set: { aggregateDate, orderCount, acceptedOfferCount }
71
+ },
72
+ { upsert: true }
73
+ )
74
+ .exec();
75
+ console.log(doc);
76
+ }
77
+ }
78
+
79
+ main()
80
+ .then(() => {
81
+ console.log('success!');
82
+ })
83
+ .catch(console.error);
@@ -0,0 +1,84 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: <string>process.env.PROJECT_ID };
8
+ interface IAggregation {
9
+ typeOf: 'AggregateReservation';
10
+ project: { id: string; typeOf: chevre.factory.organizationType.Project };
11
+ aggregateDate: Date;
12
+ aggregateDuration: string;
13
+ aggregateStart: Date;
14
+ // bookingTime: Date;
15
+ reservationCount: number;
16
+ }
17
+
18
+ async function main() {
19
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
+
21
+ const now: Date = new Date();
22
+
23
+ const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
24
+ const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
25
+
26
+ let i = 0;
27
+ // tslint:disable-next-line:no-magic-numbers
28
+ while (i < 7) {
29
+ i += 1;
30
+
31
+ const bookingFrom: Date = moment()
32
+ // .tz('Asia/Tokyo')
33
+ .add(-i, 'days')
34
+ .startOf('day')
35
+ .toDate();
36
+ const bookingThrough: Date = moment()
37
+ // .tz('Asia/Tokyo')
38
+ .add(-i, 'days')
39
+ .endOf('day')
40
+ .toDate();
41
+ // console.log(bookingFrom, bookingThrough);
42
+
43
+ // i日前の予約検索
44
+ const searchReservationCountResult = await reservationRepo.count({
45
+ typeOf: chevre.factory.reservationType.EventReservation,
46
+ reservationStatus: { $eq: chevre.factory.reservationStatusType.ReservationConfirmed },
47
+ bookingFrom,
48
+ bookingThrough
49
+ });
50
+
51
+ const aggregation: IAggregation = {
52
+ typeOf: 'AggregateReservation',
53
+ project: { id: '*', typeOf: chevre.factory.organizationType.Project },
54
+ aggregateDuration: moment.duration(1, 'days')
55
+ .toISOString(),
56
+ aggregateStart: bookingFrom,
57
+ aggregateDate: now,
58
+ reservationCount: searchReservationCountResult
59
+ };
60
+ console.log(aggregation);
61
+ const { reservationCount, aggregateDate, ...setOnInsert } = aggregation;
62
+ const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
63
+ {
64
+ typeOf: { $eq: aggregation.typeOf },
65
+ 'project.id': { $eq: aggregation.project.id },
66
+ aggregateStart: { $eq: aggregation.aggregateStart },
67
+ aggregateDuration: { $eq: aggregation.aggregateDuration }
68
+ },
69
+ {
70
+ $setOnInsert: setOnInsert,
71
+ $set: { aggregateDate, reservationCount }
72
+ },
73
+ { upsert: true }
74
+ )
75
+ .exec();
76
+ console.log(doc);
77
+ }
78
+ }
79
+
80
+ main()
81
+ .then(() => {
82
+ console.log('success!');
83
+ })
84
+ .catch(console.error);
@@ -0,0 +1,8 @@
1
+ import { Connection, Model } from 'mongoose';
2
+ /**
3
+ * 集計リポジトリ
4
+ */
5
+ export declare class MongoRepository {
6
+ readonly aggregationModel: typeof Model;
7
+ constructor(connection: Connection);
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MongoRepository = void 0;
4
+ const aggregation_1 = require("./mongoose/model/aggregation");
5
+ /**
6
+ * 集計リポジトリ
7
+ */
8
+ class MongoRepository {
9
+ constructor(connection) {
10
+ this.aggregationModel = connection.model(aggregation_1.modelName);
11
+ }
12
+ }
13
+ exports.MongoRepository = MongoRepository;
@@ -0,0 +1,7 @@
1
+ import * as mongoose from 'mongoose';
2
+ declare const modelName = "Aggregation";
3
+ /**
4
+ * 集計スキーマ
5
+ */
6
+ declare const schema: mongoose.Schema<mongoose.Document<any, any, any>, mongoose.Model<mongoose.Document<any, any, any>, any, any>, undefined, {}>;
7
+ export { modelName, schema };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = exports.modelName = void 0;
4
+ const mongoose = require("mongoose");
5
+ const modelName = 'Aggregation';
6
+ exports.modelName = modelName;
7
+ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
+ /**
9
+ * 集計スキーマ
10
+ */
11
+ const schema = new mongoose.Schema({}, {
12
+ collection: 'aggregations',
13
+ id: true,
14
+ read: 'primaryPreferred',
15
+ writeConcern: writeConcern,
16
+ strict: false,
17
+ useNestedStrict: true,
18
+ timestamps: {
19
+ createdAt: 'createdAt',
20
+ updatedAt: 'updatedAt'
21
+ },
22
+ toJSON: {
23
+ getters: false,
24
+ virtuals: false,
25
+ minimize: false,
26
+ versionKey: false
27
+ },
28
+ toObject: {
29
+ getters: false,
30
+ virtuals: true,
31
+ minimize: false,
32
+ versionKey: false
33
+ }
34
+ });
35
+ exports.schema = schema;
36
+ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
37
+ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
38
+ mongoose.model(modelName, schema)
39
+ .on('index',
40
+ // tslint:disable-next-line:no-single-line-block-comment
41
+ /* istanbul ignore next */
42
+ (error) => {
43
+ if (error !== undefined) {
44
+ // tslint:disable-next-line:no-console
45
+ console.error(error);
46
+ }
47
+ });
@@ -5,41 +5,17 @@ const mongoose = require("mongoose");
5
5
  const modelName = 'Telemetry';
6
6
  exports.modelName = modelName;
7
7
  const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
- const purposeSchema = new mongoose.Schema({
9
- typeOf: String
10
- }, {
11
- id: false,
12
- _id: false,
13
- strict: false
14
- });
15
- const objectSchema = new mongoose.Schema({
16
- measuredAt: Date
17
- }, {
18
- id: false,
19
- _id: false,
20
- strict: false
21
- });
22
- const resultSchema = new mongoose.Schema({}, {
23
- id: false,
24
- _id: false,
25
- strict: false
26
- });
27
- const errorSchema = new mongoose.Schema({}, {
28
- id: false,
29
- _id: false,
30
- strict: false
31
- });
32
8
  /**
33
9
  * 測定スキーマ
34
10
  */
35
11
  const schema = new mongoose.Schema({
36
12
  project: mongoose.SchemaTypes.Mixed,
37
- result: resultSchema,
38
- error: errorSchema,
39
- object: objectSchema,
13
+ result: mongoose.SchemaTypes.Mixed,
14
+ error: mongoose.SchemaTypes.Mixed,
15
+ object: mongoose.SchemaTypes.Mixed,
40
16
  startDate: Date,
41
17
  endDate: Date,
42
- purpose: purposeSchema
18
+ purpose: mongoose.SchemaTypes.Mixed
43
19
  }, {
44
20
  collection: 'telemetries',
45
21
  id: true,
@@ -76,4 +76,8 @@ export declare class MongoRepository {
76
76
  $in: string[];
77
77
  };
78
78
  }): Promise<(string)[]>;
79
+ aggregateOrder(params: factory.order.ISearchConditions): Promise<{
80
+ acceptedOfferCount: number;
81
+ orderCount: number;
82
+ }[]>;
79
83
  }
@@ -920,5 +920,34 @@ class MongoRepository {
920
920
  return [...new Set(reservationNumbers)];
921
921
  });
922
922
  }
923
+ aggregateOrder(params) {
924
+ var _a, _b;
925
+ return __awaiter(this, void 0, void 0, function* () {
926
+ return this.orderModel.aggregate([
927
+ {
928
+ $match: {
929
+ orderDate: {
930
+ $gte: (_a = params.orderDate) === null || _a === void 0 ? void 0 : _a.$gte,
931
+ $lte: (_b = params.orderDate) === null || _b === void 0 ? void 0 : _b.$lte
932
+ }
933
+ }
934
+ },
935
+ {
936
+ $group: {
937
+ _id: '$typeOf',
938
+ acceptedOfferCount: {
939
+ $sum: {
940
+ $cond: { if: { $isArray: '$acceptedOffers' }, then: { $size: '$acceptedOffers' }, else: 0 }
941
+ }
942
+ },
943
+ orderCount: {
944
+ $sum: 1
945
+ }
946
+ }
947
+ }
948
+ ])
949
+ .exec();
950
+ });
951
+ }
923
952
  }
924
953
  exports.MongoRepository = MongoRepository;
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
7
7
  import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
8
8
  import { MongoRepository as ActionRepo } from './repo/action';
9
9
  import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
10
+ import { MongoRepository as AggregationRepo } from './repo/aggregation';
10
11
  import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
11
12
  import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
12
13
  import { MongoRepository as CodeRepo } from './repo/code';
@@ -69,6 +70,8 @@ export declare class Action extends ActionRepo {
69
70
  */
70
71
  export declare class AdditionalProperty extends AdditionalPropertyRepo {
71
72
  }
73
+ export declare class Aggregation extends AggregationRepo {
74
+ }
72
75
  export declare namespace action {
73
76
  class RegisterServiceInProgress extends RegisterServiceActionInProgress {
74
77
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
3
+ exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
4
4
  // tslint:disable:max-classes-per-file completed-docs
5
5
  /**
6
6
  * リポジトリ
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
11
11
  const accountTransaction_1 = require("./repo/accountTransaction");
12
12
  const action_1 = require("./repo/action");
13
13
  const additionalProperty_1 = require("./repo/additionalProperty");
14
+ const aggregation_1 = require("./repo/aggregation");
14
15
  const assetTransaction_1 = require("./repo/assetTransaction");
15
16
  const categoryCode_1 = require("./repo/categoryCode");
16
17
  const code_1 = require("./repo/code");
@@ -80,6 +81,9 @@ exports.Action = Action;
80
81
  class AdditionalProperty extends additionalProperty_1.MongoRepository {
81
82
  }
82
83
  exports.AdditionalProperty = AdditionalProperty;
84
+ class Aggregation extends aggregation_1.MongoRepository {
85
+ }
86
+ exports.Aggregation = Aggregation;
83
87
  var action;
84
88
  (function (action) {
85
89
  class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
@@ -11,13 +11,10 @@ function createPayActions(params) {
11
11
  if (payObject !== undefined) {
12
12
  const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order);
13
13
  const simpleOrder = {
14
- // project: params.order.project,
15
14
  typeOf: params.order.typeOf,
16
15
  seller: params.order.seller,
17
16
  // mask
18
17
  customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
19
- // IOrderへ移行(2022-11-17~)
20
- // confirmationNumber: params.order.confirmationNumber,
21
18
  orderNumber: params.order.orderNumber,
22
19
  price: params.order.price,
23
20
  priceCurrency: params.order.priceCurrency,
@@ -25,13 +25,28 @@ export interface IStartOperationRepos {
25
25
  task: TaskRepo;
26
26
  }
27
27
  export declare type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
28
- export declare type ICancelOperation<T> = (repos: {
28
+ export interface ICancelRepos {
29
+ action: ActionRepo;
30
+ accountingReport: AccountingReportRepo;
29
31
  assetTransaction: AssetTransactionRepo;
30
- }) => Promise<T>;
31
- export declare type IConfirmOperation<T> = (repos: {
32
+ product: ProductRepo;
33
+ project: ProjectRepo;
34
+ seller: SellerRepo;
35
+ task: TaskRepo;
36
+ }
37
+ export declare type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
38
+ export interface IConfirmRepos {
39
+ action: ActionRepo;
40
+ accountingReport: AccountingReportRepo;
32
41
  assetTransaction: AssetTransactionRepo;
42
+ event: EventRepo;
33
43
  order: OrderRepo;
34
- }) => Promise<T>;
44
+ product: ProductRepo;
45
+ project: ProjectRepo;
46
+ seller: SellerRepo;
47
+ task: TaskRepo;
48
+ }
49
+ export declare type IConfirmOperation<T> = (repos: IConfirmRepos) => Promise<T>;
35
50
  export declare type IExportTasksOperation<T> = (repos: {
36
51
  task: TaskRepo;
37
52
  assetTransaction: AssetTransactionRepo;
@@ -13,6 +13,7 @@ exports.searchGMOTrade = exports.exportTasksById = exports.cancel = exports.conf
13
13
  const moment = require("moment");
14
14
  const factory = require("../../factory");
15
15
  const settings_1 = require("../../settings");
16
+ const payment_1 = require("../payment");
16
17
  const CreditCardPayment = require("../payment/creditCard");
17
18
  const MovieTicketPayment = require("../payment/movieTicket");
18
19
  const PaymentCardPayment = require("../payment/paymentCard");
@@ -307,8 +308,19 @@ function confirm(params) {
307
308
  typeOf: factory.assetTransactionType.Pay,
308
309
  id: transaction.id,
309
310
  result: {},
310
- potentialActions: potentialActions
311
+ // sync対応(2023-01-14~)
312
+ potentialActions: (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING)
313
+ ? { pay: [] }
314
+ : potentialActions
311
315
  });
316
+ // sync対応(2023-01-14~)
317
+ if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
318
+ if (Array.isArray(potentialActions.pay)) {
319
+ for (const payAction of potentialActions.pay) {
320
+ yield (0, payment_1.pay)(payAction)(repos);
321
+ }
322
+ }
323
+ }
312
324
  });
313
325
  }
314
326
  exports.confirm = confirm;
@@ -341,11 +353,23 @@ function fixOrderAsPurpose(params, transaction) {
341
353
  */
342
354
  function cancel(params) {
343
355
  return (repos) => __awaiter(this, void 0, void 0, function* () {
344
- yield repos.assetTransaction.cancel({
356
+ const transaction = yield repos.assetTransaction.cancel({
345
357
  typeOf: factory.assetTransactionType.Pay,
346
358
  id: params.id,
347
359
  transactionNumber: params.transactionNumber
348
360
  });
361
+ // sync対応(2023-01-14~)
362
+ if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
363
+ const payTransactionAsObject = {
364
+ project: transaction.project,
365
+ typeOf: transaction.typeOf,
366
+ id: transaction.id,
367
+ transactionNumber: transaction.transactionNumber,
368
+ object: transaction.object,
369
+ recipient: transaction.recipient
370
+ };
371
+ yield (0, payment_1.voidPayment)({ object: payTransactionAsObject })(repos);
372
+ }
349
373
  });
350
374
  }
351
375
  exports.cancel = cancel;
@@ -353,6 +377,7 @@ exports.cancel = cancel;
353
377
  * 取引のタスク出力
354
378
  */
355
379
  function exportTasksById(params) {
380
+ // tslint:disable-next-line:max-func-body-length
356
381
  return (repos) => __awaiter(this, void 0, void 0, function* () {
357
382
  const transaction = yield repos.assetTransaction.findById({
358
383
  typeOf: factory.assetTransactionType.Pay,
@@ -388,42 +413,50 @@ function exportTasksById(params) {
388
413
  .add(params.runsTasksAfterInSeconds, 'seconds')
389
414
  .toDate();
390
415
  }
416
+ const payTransactionAsObject = {
417
+ project: transaction.project,
418
+ typeOf: transaction.typeOf,
419
+ id: transaction.id,
420
+ transactionNumber: transaction.transactionNumber,
421
+ object: transaction.object,
422
+ recipient: transaction.recipient
423
+ };
424
+ const voidPaymentTasks = {
425
+ project: transaction.project,
426
+ name: factory.taskName.VoidPayment,
427
+ status: factory.taskStatus.Ready,
428
+ runsAt: taskRunsAt,
429
+ remainingNumberOfTries: 10,
430
+ numberOfTried: 0,
431
+ executionResults: [],
432
+ data: { object: payTransactionAsObject }
433
+ };
391
434
  switch (transaction.status) {
392
435
  case factory.transactionStatusType.Confirmed:
393
- // tslint:disable-next-line:no-single-line-block-comment
394
- /* istanbul ignore else */
395
- if (potentialActions !== undefined) {
396
- // tslint:disable-next-line:no-single-line-block-comment
397
- /* istanbul ignore else */
398
- if (potentialActions.pay !== undefined) {
399
- const payTasks = potentialActions.pay.map((a) => {
400
- return {
401
- project: transaction.project,
402
- name: factory.taskName.Pay,
403
- status: factory.taskStatus.Ready,
404
- runsAt: taskRunsAt,
405
- remainingNumberOfTries: 10,
406
- numberOfTried: 0,
407
- executionResults: [],
408
- data: a
409
- };
410
- });
411
- taskAttributes.push(...payTasks);
412
- }
436
+ const payActions = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.pay;
437
+ if (Array.isArray(payActions) && payActions.length > 0) {
438
+ const payTasks = payActions.map((a) => {
439
+ return {
440
+ project: transaction.project,
441
+ name: factory.taskName.Pay,
442
+ status: factory.taskStatus.Ready,
443
+ runsAt: taskRunsAt,
444
+ remainingNumberOfTries: 10,
445
+ numberOfTried: 0,
446
+ executionResults: [],
447
+ data: a
448
+ };
449
+ });
450
+ taskAttributes.push(...payTasks);
413
451
  }
414
452
  break;
415
453
  case factory.transactionStatusType.Canceled:
454
+ // sync対応(2023-01-14~)
455
+ if (!settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
456
+ taskAttributes.push(voidPaymentTasks);
457
+ }
458
+ break;
416
459
  case factory.transactionStatusType.Expired:
417
- const voidPaymentTasks = {
418
- project: transaction.project,
419
- name: factory.taskName.VoidPayment,
420
- status: factory.taskStatus.Ready,
421
- runsAt: taskRunsAt,
422
- remainingNumberOfTries: 10,
423
- numberOfTried: 0,
424
- executionResults: [],
425
- data: { object: transaction }
426
- };
427
460
  taskAttributes.push(voidPaymentTasks);
428
461
  break;
429
462
  default:
@@ -47,7 +47,12 @@ declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskNam
47
47
  */
48
48
  declare function processVoidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction>): (repos: {
49
49
  action: ActionRepo;
50
+ accountingReport: AccountingReportRepo;
50
51
  assetTransaction: AssetTransactionRepo;
52
+ product: ProductRepo;
53
+ project: ProjectRepo;
54
+ seller: SellerRepo;
55
+ task: TaskRepo;
51
56
  transaction: TransactionRepo;
52
57
  }) => Promise<void>;
53
58
  interface IAuthorizeRepos {
@@ -10,9 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
+ const accountingReport_1 = require("../../repo/accountingReport");
13
14
  const action_1 = require("../../repo/action");
14
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const event_1 = require("../../repo/event");
15
17
  const order_1 = require("../../repo/order");
18
+ const product_1 = require("../../repo/product");
19
+ const project_1 = require("../../repo/project");
20
+ const seller_1 = require("../../repo/seller");
21
+ const task_1 = require("../../repo/task");
16
22
  const PayTransactionService = require("../assetTransaction/pay");
17
23
  /**
18
24
  * タスク実行関数
@@ -22,6 +28,12 @@ function call(data) {
22
28
  const actionRepo = new action_1.MongoRepository(settings.connection);
23
29
  const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
24
30
  const orderRepo = new order_1.MongoRepository(settings.connection);
31
+ const accountingReportRepo = new accountingReport_1.MongoRepository(settings.connection);
32
+ const eventRepo = new event_1.MongoRepository(settings.connection);
33
+ const productRepo = new product_1.MongoRepository(settings.connection);
34
+ const projectRepo = new project_1.MongoRepository(settings.connection);
35
+ const sellerRepo = new seller_1.MongoRepository(settings.connection);
36
+ const taskRepo = new task_1.MongoRepository(settings.connection);
25
37
  // アクション開始
26
38
  const action = yield actionRepo.start(data);
27
39
  try {
@@ -38,8 +50,15 @@ function call(data) {
38
50
  }
39
51
  }
40
52
  })({
53
+ action: actionRepo,
54
+ accountingReport: accountingReportRepo,
41
55
  assetTransaction: assetTransactionRepo,
42
- order: orderRepo
56
+ event: eventRepo,
57
+ order: orderRepo,
58
+ product: productRepo,
59
+ project: projectRepo,
60
+ seller: sellerRepo,
61
+ task: taskRepo
43
62
  });
44
63
  }
45
64
  }
@@ -24,6 +24,7 @@ export declare type ISettings = factory.project.ISettings & {
24
24
  };
25
25
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
26
26
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
27
+ export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
27
28
  /**
28
29
  * グローバル設定
29
30
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
3
+ exports.settings = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
4
4
  const factory = require("./factory");
5
5
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
6
6
  ? process.env.INFORM_TRANSACTION_URL.split(',')
@@ -47,6 +47,7 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = 7;
47
47
  exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
48
48
  exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
49
49
  exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
50
+ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
50
51
  /**
51
52
  * グローバル設定
52
53
  */
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.281.0",
12
+ "@chevre/factory": "4.282.0-alpha.0",
13
13
  "@cinerino/sdk": "3.135.0",
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.2.0-alpha.14"
123
+ "version": "20.2.0-alpha.16"
124
124
  }
@@ -1,32 +0,0 @@
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
- const project = { id: <string>process.env.PROJECT_ID };
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
-
12
- // const now = new Date();
13
- await chevre.service.aggregation.project.aggregate({
14
- project: { id: project.id },
15
- reservationFor: {
16
- startFrom: moment('2022-01-01T00:00:00+09:00')
17
- .toDate(),
18
- startThrough: moment('2022-01-31T23:59:59+09:00')
19
- .toDate(),
20
- }
21
- })({
22
- project: new chevre.repository.Project(mongoose.connection),
23
- reservation: new chevre.repository.Reservation(mongoose.connection),
24
- task: new chevre.repository.Task(mongoose.connection)
25
- });
26
- }
27
-
28
- main()
29
- .then(() => {
30
- console.log('success!');
31
- })
32
- .catch(console.error);