@chevre/domain 21.8.0-alpha.3 → 21.8.0-alpha.30
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.
- package/example/src/chevre/db/stats.ts +22 -0
- package/example/src/chevre/importOffersFromCOA.ts +7 -1
- package/example/src/chevre/migrateAggregateOffers.ts +58 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
- package/example/src/chevre/searchTasks.ts +9 -9
- package/example/src/chevre/syncAggregateOffer.ts +25 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +71 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +42 -0
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
- package/lib/chevre/repo/offer.d.ts +38 -8
- package/lib/chevre/repo/offer.js +208 -25
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +34 -1
- package/lib/chevre/repo/task.d.ts +7 -1
- package/lib/chevre/repo/task.js +111 -22
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
- package/lib/chevre/service/assetTransaction/reserve.js +105 -31
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/authorize.js +3 -0
- package/lib/chevre/service/offer/event/factory.js +8 -8
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
- package/lib/chevre/service/order/onOrderStatusChanged.js +104 -81
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +11 -13
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +33 -8
- package/lib/chevre/service/payment/any.js +30 -21
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
- package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +2 -2
- package/lib/chevre/settings.js +3 -5
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const modelName = 'AggregateOffer';
|
|
7
|
+
exports.modelName = modelName;
|
|
8
|
+
/**
|
|
9
|
+
* 集計オファースキーマ
|
|
10
|
+
*/
|
|
11
|
+
const schema = new mongoose_1.Schema({
|
|
12
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
_id: String,
|
|
14
|
+
typeOf: String,
|
|
15
|
+
offers: [mongoose_1.SchemaTypes.Mixed]
|
|
16
|
+
}, {
|
|
17
|
+
collection: 'aggregateOffers',
|
|
18
|
+
id: true,
|
|
19
|
+
read: 'primaryPreferred',
|
|
20
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
21
|
+
strict: true,
|
|
22
|
+
strictQuery: false,
|
|
23
|
+
timestamps: {
|
|
24
|
+
createdAt: 'createdAt',
|
|
25
|
+
updatedAt: 'updatedAt'
|
|
26
|
+
},
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
exports.schema = schema;
|
|
41
|
+
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
42
|
+
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
@@ -29,6 +29,7 @@ const schema = new mongoose_1.Schema({
|
|
|
29
29
|
availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
|
|
30
30
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
31
31
|
itemOffered: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
+
// offers: [SchemaTypes.Mixed],
|
|
32
33
|
priceCurrency: String,
|
|
33
34
|
priceSpecification: mongoose_1.SchemaTypes.Mixed,
|
|
34
35
|
eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -72,6 +72,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
72
72
|
customer?: any;
|
|
73
73
|
returner?: any;
|
|
74
74
|
orderStatus?: string | undefined;
|
|
75
|
+
previousOrderStatus?: string | undefined;
|
|
75
76
|
isGift?: boolean | undefined;
|
|
76
77
|
dateReturned?: Date | undefined;
|
|
77
78
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
@@ -95,6 +96,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
95
96
|
customer?: any;
|
|
96
97
|
returner?: any;
|
|
97
98
|
orderStatus?: string | undefined;
|
|
99
|
+
previousOrderStatus?: string | undefined;
|
|
98
100
|
isGift?: boolean | undefined;
|
|
99
101
|
dateReturned?: Date | undefined;
|
|
100
102
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
@@ -118,6 +120,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
118
120
|
customer?: any;
|
|
119
121
|
returner?: any;
|
|
120
122
|
orderStatus?: string | undefined;
|
|
123
|
+
previousOrderStatus?: string | undefined;
|
|
121
124
|
isGift?: boolean | undefined;
|
|
122
125
|
dateReturned?: Date | undefined;
|
|
123
126
|
}> & {
|
|
@@ -57,6 +57,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
57
57
|
status?: string | undefined;
|
|
58
58
|
data?: any;
|
|
59
59
|
project?: any;
|
|
60
|
+
identifier?: string | undefined;
|
|
60
61
|
runsAt?: Date | undefined;
|
|
61
62
|
remainingNumberOfTries?: number | undefined;
|
|
62
63
|
lastTriedAt?: Date | undefined;
|
|
@@ -69,6 +70,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
69
70
|
status?: string | undefined;
|
|
70
71
|
data?: any;
|
|
71
72
|
project?: any;
|
|
73
|
+
identifier?: string | undefined;
|
|
72
74
|
runsAt?: Date | undefined;
|
|
73
75
|
remainingNumberOfTries?: number | undefined;
|
|
74
76
|
lastTriedAt?: Date | undefined;
|
|
@@ -81,6 +83,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
81
83
|
status?: string | undefined;
|
|
82
84
|
data?: any;
|
|
83
85
|
project?: any;
|
|
86
|
+
identifier?: string | undefined;
|
|
84
87
|
runsAt?: Date | undefined;
|
|
85
88
|
remainingNumberOfTries?: number | undefined;
|
|
86
89
|
lastTriedAt?: Date | undefined;
|
|
@@ -9,6 +9,7 @@ exports.modelName = modelName;
|
|
|
9
9
|
* タスクスキーマ
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose_1.Schema({
|
|
12
|
+
identifier: String,
|
|
12
13
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
14
|
name: String,
|
|
14
15
|
status: String,
|
|
@@ -52,6 +53,13 @@ schema.index({ 'project.id': 1, runsAt: -1 }, { name: 'searchByProjectId-v202207
|
|
|
52
53
|
schema.index({ name: 1, runsAt: -1 }, { name: 'searchByName-v2' });
|
|
53
54
|
schema.index({ status: 1, runsAt: -1 }, { name: 'searchByStatus-v2' });
|
|
54
55
|
schema.index({ runsAt: -1 }, { name: 'searchByRunsAt-v2' });
|
|
56
|
+
// identifier追加(2023-09-01~)
|
|
57
|
+
schema.index({ identifier: 1, runsAt: -1 }, {
|
|
58
|
+
name: 'searchByIdentifier',
|
|
59
|
+
partialFilterExpression: {
|
|
60
|
+
identifier: { $exists: true }
|
|
61
|
+
}
|
|
62
|
+
});
|
|
55
63
|
schema.index({ dateAborted: 1, runsAt: -1 }, {
|
|
56
64
|
name: 'searchByDateAborted',
|
|
57
65
|
partialFilterExpression: {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
25
26
|
import { Connection } from 'mongoose';
|
|
26
27
|
import * as factory from '../factory';
|
|
27
28
|
interface IProjection {
|
|
@@ -31,8 +32,10 @@ interface IProjection {
|
|
|
31
32
|
* オファーリポジトリ
|
|
32
33
|
*/
|
|
33
34
|
export declare class MongoRepository {
|
|
35
|
+
private readonly aggregateOfferModel;
|
|
34
36
|
private readonly offerModel;
|
|
35
37
|
private readonly offerCatalogModel;
|
|
38
|
+
private readonly taskModel;
|
|
36
39
|
constructor(connection: Connection);
|
|
37
40
|
static CREATE_OFFER_MONGO_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): any[];
|
|
38
41
|
/**
|
|
@@ -64,9 +67,11 @@ export declare class MongoRepository {
|
|
|
64
67
|
findById(params: {
|
|
65
68
|
id: string;
|
|
66
69
|
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
67
|
-
count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
|
|
68
70
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
69
71
|
save(params: factory.unitPriceOffer.IUnitPriceOffer): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
72
|
+
/**
|
|
73
|
+
* sskts専用オファー保管
|
|
74
|
+
*/
|
|
70
75
|
saveManyByIdentifier(params: {
|
|
71
76
|
attributes: factory.unitPriceOffer.IUnitPriceOffer;
|
|
72
77
|
upsert?: boolean;
|
|
@@ -87,17 +92,42 @@ export declare class MongoRepository {
|
|
|
87
92
|
};
|
|
88
93
|
}): Promise<import("mongodb").UpdateResult | undefined>;
|
|
89
94
|
deleteById(params: {
|
|
90
|
-
id: string;
|
|
91
|
-
}): Promise<void>;
|
|
92
|
-
deleteByProject(params: {
|
|
93
95
|
project: {
|
|
94
96
|
id: string;
|
|
95
97
|
};
|
|
98
|
+
id: string;
|
|
96
99
|
}): Promise<void>;
|
|
97
100
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
sync2aggregateOffer(params: {
|
|
102
|
+
id?: {
|
|
103
|
+
$in: string[];
|
|
104
|
+
};
|
|
105
|
+
identifier?: {
|
|
106
|
+
$in: string[];
|
|
107
|
+
};
|
|
108
|
+
project: {
|
|
109
|
+
id: string;
|
|
110
|
+
};
|
|
111
|
+
isDeleted: boolean;
|
|
112
|
+
typeOf: factory.offerType.AggregateOffer | factory.offerType.Offer;
|
|
113
|
+
}): Promise<BulkWriteOpResultObject | void>;
|
|
114
|
+
/**
|
|
115
|
+
* オファー同期専用のタスク保管
|
|
116
|
+
*/
|
|
117
|
+
saveSyncTask(params: {
|
|
118
|
+
id: {
|
|
119
|
+
$in: string[];
|
|
120
|
+
};
|
|
121
|
+
identifier: {
|
|
122
|
+
$in: string[];
|
|
123
|
+
};
|
|
124
|
+
isDeleted: boolean;
|
|
125
|
+
project: {
|
|
126
|
+
id: string;
|
|
127
|
+
};
|
|
128
|
+
typeOf: factory.offerType.AggregateOffer | factory.offerType.Offer;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
id: string;
|
|
131
|
+
}[]>;
|
|
102
132
|
}
|
|
103
133
|
export {};
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -23,16 +23,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
24
|
const uniqid = require("uniqid");
|
|
25
25
|
const factory = require("../factory");
|
|
26
|
+
const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
|
|
26
27
|
const offer_1 = require("./mongoose/schemas/offer");
|
|
27
28
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
29
|
+
const task_1 = require("./mongoose/schemas/task");
|
|
30
|
+
const task_2 = require("../eventEmitter/task");
|
|
28
31
|
const settings_1 = require("../settings");
|
|
29
32
|
/**
|
|
30
33
|
* オファーリポジトリ
|
|
31
34
|
*/
|
|
32
35
|
class MongoRepository {
|
|
33
36
|
constructor(connection) {
|
|
37
|
+
this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
|
|
34
38
|
this.offerModel = connection.model(offer_1.modelName, offer_1.schema);
|
|
35
39
|
this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
|
|
40
|
+
this.taskModel = connection.model(task_1.modelName, task_1.schema);
|
|
36
41
|
}
|
|
37
42
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
38
43
|
static CREATE_OFFER_MONGO_CONDITIONS(params) {
|
|
@@ -401,7 +406,8 @@ class MongoRepository {
|
|
|
401
406
|
const doc = yield this.offerModel.findOne({ _id: params.id }, {
|
|
402
407
|
__v: 0,
|
|
403
408
|
createdAt: 0,
|
|
404
|
-
updatedAt: 0
|
|
409
|
+
updatedAt: 0,
|
|
410
|
+
availableAddOn: 0 // 廃止属性の残存が確認されたので(2023-09-04~)
|
|
405
411
|
})
|
|
406
412
|
.exec();
|
|
407
413
|
if (doc === null) {
|
|
@@ -410,14 +416,14 @@ class MongoRepository {
|
|
|
410
416
|
return doc.toObject();
|
|
411
417
|
});
|
|
412
418
|
}
|
|
413
|
-
count(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
419
|
+
// public async count(
|
|
420
|
+
// params: factory.unitPriceOffer.ISearchConditions
|
|
421
|
+
// ): Promise<number> {
|
|
422
|
+
// const conditions = MongoRepository.CREATE_OFFER_MONGO_CONDITIONS(params);
|
|
423
|
+
// return this.offerModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
424
|
+
// .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
425
|
+
// .exec();
|
|
426
|
+
// }
|
|
421
427
|
search(params, projection) {
|
|
422
428
|
var _a;
|
|
423
429
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -428,7 +434,8 @@ class MongoRepository {
|
|
|
428
434
|
: false;
|
|
429
435
|
const query = this.offerModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
|
|
430
436
|
? projection
|
|
431
|
-
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0
|
|
437
|
+
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0, availableAddOn: 0 // 廃止属性の残存が確認されたので(2023-09-04~)
|
|
438
|
+
}));
|
|
432
439
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
433
440
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
434
441
|
query.limit(params.limit)
|
|
@@ -460,9 +467,22 @@ class MongoRepository {
|
|
|
460
467
|
if (doc === null) {
|
|
461
468
|
throw new factory.errors.NotFound(this.offerModel.modelName);
|
|
462
469
|
}
|
|
470
|
+
// 同期タスク作成(2023-09-03~)
|
|
471
|
+
if (typeof doc._id === 'string') {
|
|
472
|
+
yield this.saveSyncTask({
|
|
473
|
+
project: { id: params.project.id },
|
|
474
|
+
id: { $in: [doc._id] },
|
|
475
|
+
identifier: { $in: [] },
|
|
476
|
+
isDeleted: false,
|
|
477
|
+
typeOf: factory.offerType.Offer
|
|
478
|
+
});
|
|
479
|
+
}
|
|
463
480
|
return doc.toObject();
|
|
464
481
|
});
|
|
465
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* sskts専用オファー保管
|
|
485
|
+
*/
|
|
466
486
|
saveManyByIdentifier(params) {
|
|
467
487
|
return __awaiter(this, void 0, void 0, function* () {
|
|
468
488
|
const bulkWriteOps = [];
|
|
@@ -486,7 +506,9 @@ class MongoRepository {
|
|
|
486
506
|
},
|
|
487
507
|
update: {
|
|
488
508
|
$set: $set,
|
|
489
|
-
$setOnInsert: {
|
|
509
|
+
$setOnInsert: {
|
|
510
|
+
_id: id
|
|
511
|
+
}
|
|
490
512
|
},
|
|
491
513
|
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
492
514
|
}
|
|
@@ -495,6 +517,14 @@ class MongoRepository {
|
|
|
495
517
|
}
|
|
496
518
|
if (bulkWriteOps.length > 0) {
|
|
497
519
|
yield this.offerModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
520
|
+
// 同期タスク作成(2023-09-03~)
|
|
521
|
+
yield this.saveSyncTask({
|
|
522
|
+
project: { id: params[0].attributes.project.id },
|
|
523
|
+
id: { $in: [] },
|
|
524
|
+
identifier: { $in: params.map((savingOffer) => savingOffer.attributes.identifier) },
|
|
525
|
+
isDeleted: false,
|
|
526
|
+
typeOf: factory.offerType.Offer
|
|
527
|
+
});
|
|
498
528
|
}
|
|
499
529
|
});
|
|
500
530
|
}
|
|
@@ -506,10 +536,14 @@ class MongoRepository {
|
|
|
506
536
|
if (params.addOn.itemOffered.id.$in.length === 0) {
|
|
507
537
|
return;
|
|
508
538
|
}
|
|
509
|
-
|
|
539
|
+
const conditions = {
|
|
510
540
|
'project.id': { $eq: params.project.id },
|
|
511
541
|
'addOn.itemOffered.id': { $exists: true, $in: params.addOn.itemOffered.id.$in }
|
|
512
|
-
}
|
|
542
|
+
};
|
|
543
|
+
const updatingOffers = yield this.offerModel.find(conditions, { _id: 1 })
|
|
544
|
+
.exec()
|
|
545
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
546
|
+
const result = yield this.offerModel.updateMany(conditions, {
|
|
513
547
|
$pull: {
|
|
514
548
|
addOn: {
|
|
515
549
|
'itemOffered.id': { $in: params.addOn.itemOffered.id.$in }
|
|
@@ -517,31 +551,180 @@ class MongoRepository {
|
|
|
517
551
|
}
|
|
518
552
|
})
|
|
519
553
|
.exec();
|
|
554
|
+
// 同期タスク作成(2023-09-03~)
|
|
555
|
+
if (updatingOffers.length > 0) {
|
|
556
|
+
yield this.saveSyncTask({
|
|
557
|
+
project: { id: params.project.id },
|
|
558
|
+
id: { $in: updatingOffers.map((offer) => offer.id) },
|
|
559
|
+
identifier: { $in: [] },
|
|
560
|
+
isDeleted: false,
|
|
561
|
+
typeOf: factory.offerType.Offer
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
return result;
|
|
520
565
|
});
|
|
521
566
|
}
|
|
522
567
|
deleteById(params) {
|
|
523
568
|
return __awaiter(this, void 0, void 0, function* () {
|
|
524
|
-
yield this.offerModel.findOneAndRemove({ _id: params.id })
|
|
525
|
-
.exec();
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
deleteByProject(params) {
|
|
529
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
530
|
-
yield this.offerModel.deleteMany({
|
|
531
|
-
'project.id': { $eq: params.project.id }
|
|
532
|
-
})
|
|
569
|
+
yield this.offerModel.findOneAndRemove({ _id: params.id }, { projection: { _id: 1 } })
|
|
533
570
|
.exec();
|
|
571
|
+
// 同期タスク作成(2023-09-03~)
|
|
572
|
+
yield this.saveSyncTask({
|
|
573
|
+
project: { id: params.project.id },
|
|
574
|
+
id: { $in: [params.id] },
|
|
575
|
+
identifier: { $in: [] },
|
|
576
|
+
isDeleted: true,
|
|
577
|
+
typeOf: factory.offerType.Offer
|
|
578
|
+
});
|
|
534
579
|
});
|
|
535
580
|
}
|
|
581
|
+
// public async deleteByProject(params: {
|
|
582
|
+
// project: { id: string };
|
|
583
|
+
// }): Promise<void> {
|
|
584
|
+
// await this.offerModel.deleteMany({
|
|
585
|
+
// 'project.id': { $eq: params.project.id }
|
|
586
|
+
// })
|
|
587
|
+
// .exec();
|
|
588
|
+
// }
|
|
536
589
|
getCursor(conditions, projection) {
|
|
537
590
|
return this.offerModel.find(conditions, projection)
|
|
538
591
|
.sort({ 'priceSpecification.price': factory.sortType.Descending })
|
|
539
592
|
.cursor();
|
|
540
593
|
}
|
|
541
|
-
unsetUnnecessaryFields(params
|
|
594
|
+
// public async unsetUnnecessaryFields(params: {
|
|
595
|
+
// filter: any;
|
|
596
|
+
// $unset: any;
|
|
597
|
+
// }) {
|
|
598
|
+
// return this.offerModel.updateMany(
|
|
599
|
+
// params.filter,
|
|
600
|
+
// { $unset: params.$unset }
|
|
601
|
+
// )
|
|
602
|
+
// .exec();
|
|
603
|
+
// }
|
|
604
|
+
sync2aggregateOffer(params) {
|
|
605
|
+
var _a, _b;
|
|
542
606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
543
|
-
|
|
544
|
-
.
|
|
607
|
+
if (params.typeOf === factory.offerType.Offer) {
|
|
608
|
+
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
609
|
+
const identifierIn = (_b = params.identifier) === null || _b === void 0 ? void 0 : _b.$in;
|
|
610
|
+
if (params.isDeleted === true) {
|
|
611
|
+
if (Array.isArray(idIn) && idIn.length > 0) {
|
|
612
|
+
yield this.aggregateOfferModel.deleteMany({
|
|
613
|
+
'project.id': { $eq: params.project.id },
|
|
614
|
+
_id: { $in: idIn }
|
|
615
|
+
})
|
|
616
|
+
.exec();
|
|
617
|
+
}
|
|
618
|
+
// コードで削除することは現状ない
|
|
619
|
+
// if (Array.isArray(identifierIn) && identifierIn.length > 0) {
|
|
620
|
+
// await this.aggregateOfferModel.deleteMany({
|
|
621
|
+
// 'project.id': { $eq: params.project.id },
|
|
622
|
+
// 'offers.identifier': { $exists: true, $in: identifierIn }
|
|
623
|
+
// })
|
|
624
|
+
// .exec();
|
|
625
|
+
// }
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
let unitPriceOffers = [];
|
|
629
|
+
if (Array.isArray(idIn) && idIn.length > 0) {
|
|
630
|
+
unitPriceOffers = yield this.offerModel.find({
|
|
631
|
+
'project.id': { $eq: params.project.id },
|
|
632
|
+
_id: { $in: idIn }
|
|
633
|
+
}, {
|
|
634
|
+
__v: 0,
|
|
635
|
+
createdAt: 0,
|
|
636
|
+
updatedAt: 0,
|
|
637
|
+
offers: 0,
|
|
638
|
+
availableAddOn: 0 // 廃止属性の残存が確認されたので(2023-09-04~)
|
|
639
|
+
})
|
|
640
|
+
.exec()
|
|
641
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
642
|
+
}
|
|
643
|
+
if (Array.isArray(identifierIn) && identifierIn.length > 0) {
|
|
644
|
+
unitPriceOffers = yield this.offerModel.find({
|
|
645
|
+
'project.id': { $eq: params.project.id },
|
|
646
|
+
identifier: { $exists: true, $in: identifierIn }
|
|
647
|
+
}, {
|
|
648
|
+
__v: 0,
|
|
649
|
+
createdAt: 0,
|
|
650
|
+
updatedAt: 0,
|
|
651
|
+
offers: 0,
|
|
652
|
+
availableAddOn: 0 // 廃止属性の残存が確認されたので(2023-09-04~)
|
|
653
|
+
})
|
|
654
|
+
.exec()
|
|
655
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
656
|
+
}
|
|
657
|
+
const bulkWriteOps = [];
|
|
658
|
+
if (unitPriceOffers.length > 0) {
|
|
659
|
+
unitPriceOffers.forEach((unitPriceOffer) => {
|
|
660
|
+
delete unitPriceOffer._id;
|
|
661
|
+
const $set = {
|
|
662
|
+
project: unitPriceOffer.project,
|
|
663
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
664
|
+
offers: [unitPriceOffer]
|
|
665
|
+
};
|
|
666
|
+
bulkWriteOps.push({
|
|
667
|
+
updateOne: {
|
|
668
|
+
filter: {
|
|
669
|
+
'project.id': { $eq: unitPriceOffer.project.id },
|
|
670
|
+
_id: { $eq: unitPriceOffer.id }
|
|
671
|
+
},
|
|
672
|
+
update: {
|
|
673
|
+
$set,
|
|
674
|
+
$setOnInsert: { _id: unitPriceOffer.id }
|
|
675
|
+
},
|
|
676
|
+
upsert: true
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
if (bulkWriteOps.length > 0) {
|
|
682
|
+
return this.aggregateOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else if (params.typeOf === factory.offerType.AggregateOffer) {
|
|
687
|
+
// no op
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* オファー同期専用のタスク保管
|
|
693
|
+
*/
|
|
694
|
+
saveSyncTask(params) {
|
|
695
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
696
|
+
const syncAggregateOfferTask = {
|
|
697
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
698
|
+
name: factory.taskName.SyncAggregateOffer,
|
|
699
|
+
status: factory.taskStatus.Ready,
|
|
700
|
+
runsAt: new Date(),
|
|
701
|
+
remainingNumberOfTries: 3,
|
|
702
|
+
numberOfTried: 0,
|
|
703
|
+
executionResults: [],
|
|
704
|
+
data: {
|
|
705
|
+
project: { id: params.project.id },
|
|
706
|
+
id: params.id,
|
|
707
|
+
identifier: params.identifier,
|
|
708
|
+
isDeleted: params.isDeleted,
|
|
709
|
+
typeOf: params.typeOf
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
const taskAttributes = [syncAggregateOfferTask];
|
|
713
|
+
const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
|
|
714
|
+
if (result.insertedCount !== taskAttributes.length) {
|
|
715
|
+
throw new factory.errors.ServiceUnavailable('all tasks not saved');
|
|
716
|
+
}
|
|
717
|
+
const savedTasks = Object.values(result.insertedIds)
|
|
718
|
+
.map((objectId) => {
|
|
719
|
+
return { id: objectId.toHexString() };
|
|
720
|
+
});
|
|
721
|
+
savedTasks.forEach((savedTask) => {
|
|
722
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
723
|
+
id: savedTask.id,
|
|
724
|
+
status: factory.taskStatus.Ready
|
|
725
|
+
});
|
|
726
|
+
});
|
|
727
|
+
return savedTasks;
|
|
545
728
|
});
|
|
546
729
|
}
|
|
547
730
|
}
|
|
@@ -70,6 +70,21 @@ export declare class MongoRepository {
|
|
|
70
70
|
}): Promise<{
|
|
71
71
|
updatedAt: Date;
|
|
72
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* 注文後に決済方法区分を確定する
|
|
75
|
+
*/
|
|
76
|
+
fixPaymentMethodIdentifier(params: {
|
|
77
|
+
project: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
orderNumber: string;
|
|
81
|
+
invoice: {
|
|
82
|
+
paymentMethodId: string;
|
|
83
|
+
paymentMethod: {
|
|
84
|
+
identifier: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}): Promise<void>;
|
|
73
88
|
findById(params: {
|
|
74
89
|
id: string;
|
|
75
90
|
inclusion: string[];
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -681,7 +681,10 @@ class MongoRepository {
|
|
|
681
681
|
orderNumber: { $eq: params.orderNumber },
|
|
682
682
|
orderStatus: { $eq: params.previousOrderStatus },
|
|
683
683
|
'project.id': { $eq: params.project.id }
|
|
684
|
-
}, {
|
|
684
|
+
}, {
|
|
685
|
+
previousOrderStatus: params.previousOrderStatus,
|
|
686
|
+
orderStatus: params.orderStatus
|
|
687
|
+
}, {
|
|
685
688
|
new: true,
|
|
686
689
|
projection: {
|
|
687
690
|
__v: 0,
|
|
@@ -723,6 +726,7 @@ class MongoRepository {
|
|
|
723
726
|
orderStatus: { $eq: factory.orderStatus.OrderDelivered },
|
|
724
727
|
'project.id': { $eq: params.project.id }
|
|
725
728
|
}, {
|
|
729
|
+
previousOrderStatus: factory.orderStatus.OrderDelivered,
|
|
726
730
|
orderStatus: factory.orderStatus.OrderReturned,
|
|
727
731
|
dateReturned: params.dateReturned,
|
|
728
732
|
returner: params.returner
|
|
@@ -782,6 +786,35 @@ class MongoRepository {
|
|
|
782
786
|
return { updatedAt: doc.updatedAt };
|
|
783
787
|
});
|
|
784
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* 注文後に決済方法区分を確定する
|
|
791
|
+
*/
|
|
792
|
+
fixPaymentMethodIdentifier(params) {
|
|
793
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
794
|
+
const doc = yield this.orderModel.findOneAndUpdate({
|
|
795
|
+
orderNumber: { $eq: params.orderNumber },
|
|
796
|
+
'project.id': { $eq: params.project.id },
|
|
797
|
+
'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
|
|
798
|
+
}, {
|
|
799
|
+
$set: {
|
|
800
|
+
'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
|
|
801
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
802
|
+
// TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
|
|
803
|
+
'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
|
|
804
|
+
}
|
|
805
|
+
}, {
|
|
806
|
+
arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
|
|
807
|
+
new: true,
|
|
808
|
+
projection: {
|
|
809
|
+
_id: 1
|
|
810
|
+
}
|
|
811
|
+
})
|
|
812
|
+
.exec();
|
|
813
|
+
if (doc === null) {
|
|
814
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
785
818
|
findById(params) {
|
|
786
819
|
return __awaiter(this, void 0, void 0, function* () {
|
|
787
820
|
let projection = {};
|
|
@@ -30,11 +30,17 @@ export declare class MongoRepository {
|
|
|
30
30
|
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options: IOptionOnCreate): Promise<{
|
|
31
31
|
id: string;
|
|
32
32
|
}[]>;
|
|
33
|
+
/**
|
|
34
|
+
* タスク識別子から冪等作成する
|
|
35
|
+
*/
|
|
36
|
+
createIfNotExistByIdentifier(params: factory.task.IAttributes<factory.taskName>, options: IOptionOnCreate): Promise<void>;
|
|
33
37
|
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
|
|
34
38
|
/**
|
|
35
39
|
* 取引削除タスク冪等作成
|
|
36
40
|
*/
|
|
37
41
|
createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
42
|
+
createConfirmReserveTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
43
|
+
createOnAssetTransactionStatusChangedTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.OnAssetTransactionStatusChanged>, options: IOptionOnCreate): Promise<void>;
|
|
38
44
|
createSendOrderTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.SendOrder>, options: IOptionOnCreate): Promise<void>;
|
|
39
45
|
executeById(params: {
|
|
40
46
|
id: string;
|
|
@@ -68,7 +74,7 @@ export declare class MongoRepository {
|
|
|
68
74
|
*/
|
|
69
75
|
$nin?: factory.taskName[];
|
|
70
76
|
};
|
|
71
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
77
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncAggregateOffer").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
72
78
|
retry(params: {
|
|
73
79
|
intervalInMinutes: number;
|
|
74
80
|
}): Promise<void>;
|