@chevre/domain 21.2.0-alpha.57 → 21.2.0-alpha.59
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/deleteTasksByName.ts +2 -1
- package/lib/chevre/repo/action.d.ts +15 -0
- package/lib/chevre/repo/action.js +23 -0
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.js +34 -13
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/offerItemCondition.d.ts +39 -0
- package/lib/chevre/repo/offerItemCondition.js +112 -0
- package/lib/chevre/repo/task.d.ts +3 -0
- package/lib/chevre/repo/task.js +2 -3
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/assetTransaction/cancelReservation.js +22 -20
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +22 -20
- package/lib/chevre/service/assetTransaction/pay.js +22 -20
- package/lib/chevre/service/assetTransaction/refund.js +22 -20
- package/lib/chevre/service/assetTransaction/registerService.js +22 -20
- package/lib/chevre/service/assetTransaction/reserve.js +22 -20
- package/lib/chevre/service/task/returnPayTransaction.js +1 -7
- package/lib/chevre/service/transaction/deleteTransaction.js +55 -31
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -11,7 +11,8 @@ async function main() {
|
|
|
11
11
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const result = await taskRepo.deleteByName({
|
|
14
|
-
name:
|
|
14
|
+
name: chevre.factory.taskName.DeleteOrder,
|
|
15
|
+
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
console.log('deleted', result);
|
|
@@ -133,6 +133,21 @@ export declare class MongoRepository {
|
|
|
133
133
|
deleteEndDatePassedCertainPeriod(params: {
|
|
134
134
|
$lt: Date;
|
|
135
135
|
}): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* 取引からアクションを削除する
|
|
138
|
+
*/
|
|
139
|
+
deleteByPurpose(params: {
|
|
140
|
+
project: {
|
|
141
|
+
id: string;
|
|
142
|
+
};
|
|
143
|
+
purpose: {
|
|
144
|
+
typeOf: factory.transactionType;
|
|
145
|
+
id: string;
|
|
146
|
+
};
|
|
147
|
+
typeOf: factory.actionType;
|
|
148
|
+
}): Promise<{
|
|
149
|
+
deletedCount?: number;
|
|
150
|
+
} | null>;
|
|
136
151
|
aggregateAuthorizeEventServiceOfferAction(params: {
|
|
137
152
|
project?: {
|
|
138
153
|
id?: {
|
|
@@ -675,6 +675,29 @@ class MongoRepository {
|
|
|
675
675
|
.exec();
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* 取引からアクションを削除する
|
|
680
|
+
*/
|
|
681
|
+
deleteByPurpose(params) {
|
|
682
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
683
|
+
return this.actionModel.deleteMany({
|
|
684
|
+
'project.id': { $eq: params.project.id },
|
|
685
|
+
typeOf: { $eq: params.typeOf },
|
|
686
|
+
'purpose.id': { $exists: true, $eq: params.purpose.id },
|
|
687
|
+
'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf }
|
|
688
|
+
})
|
|
689
|
+
.exec()
|
|
690
|
+
.then((result) => {
|
|
691
|
+
return {
|
|
692
|
+
// n: result?.n,
|
|
693
|
+
// opTime: result.opTime,
|
|
694
|
+
// ok: result?.ok,
|
|
695
|
+
// operationTime,
|
|
696
|
+
deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
|
|
697
|
+
};
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
}
|
|
678
701
|
aggregateAuthorizeEventServiceOfferAction(params) {
|
|
679
702
|
return __awaiter(this, void 0, void 0, function* () {
|
|
680
703
|
const statuses = yield Promise.all([
|
|
@@ -148,7 +148,7 @@ export declare class MongoRepository {
|
|
|
148
148
|
/**
|
|
149
149
|
* 取引を検索する
|
|
150
150
|
*/
|
|
151
|
-
search<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>,
|
|
151
|
+
search<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>, inclusion?: string[], exclusion?: string[]): Promise<factory.assetTransaction.ITransaction<T>[]>;
|
|
152
152
|
/**
|
|
153
153
|
* 取引番号指定で削除する
|
|
154
154
|
*/
|
|
@@ -23,7 +23,7 @@ class MongoRepository {
|
|
|
23
23
|
}
|
|
24
24
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
25
25
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
27
27
|
const andConditions = [
|
|
28
28
|
{
|
|
29
29
|
typeOf: params.typeOf
|
|
@@ -133,15 +133,18 @@ class MongoRepository {
|
|
|
133
133
|
const objectPaymentMethodIdEq4refund = (_j = (_h = params.object) === null || _h === void 0 ? void 0 : _h.paymentMethodId) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
134
134
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
135
135
|
andConditions.push({
|
|
136
|
-
'object.paymentMethodId': {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const objectPaymentMethodIdIn4refund = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$in;
|
|
140
|
+
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
141
|
+
andConditions.push({
|
|
142
|
+
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
break;
|
|
143
146
|
case factory.assetTransactionType.MoneyTransfer:
|
|
144
|
-
const fromLocationIdentifierEq = (
|
|
147
|
+
const fromLocationIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.fromLocation) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
145
148
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
146
149
|
andConditions.push({
|
|
147
150
|
'object.fromLocation.identifier': {
|
|
@@ -150,7 +153,7 @@ class MongoRepository {
|
|
|
150
153
|
}
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
|
-
const toLocationIdentifierEq = (
|
|
156
|
+
const toLocationIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.toLocation) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
154
157
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
155
158
|
andConditions.push({
|
|
156
159
|
'object.toLocation.identifier': {
|
|
@@ -159,7 +162,7 @@ class MongoRepository {
|
|
|
159
162
|
}
|
|
160
163
|
});
|
|
161
164
|
}
|
|
162
|
-
const pendingTransactionIdentifierEq = (
|
|
165
|
+
const pendingTransactionIdentifierEq = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.pendingTransaction) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
163
166
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
164
167
|
andConditions.push({
|
|
165
168
|
'object.pendingTransaction.identifier': {
|
|
@@ -172,7 +175,7 @@ class MongoRepository {
|
|
|
172
175
|
case factory.assetTransactionType.CancelReservation:
|
|
173
176
|
break;
|
|
174
177
|
case factory.assetTransactionType.Reserve:
|
|
175
|
-
const objectReservationNumberEq = (
|
|
178
|
+
const objectReservationNumberEq = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationNumber) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
176
179
|
if (typeof objectReservationNumberEq === 'string') {
|
|
177
180
|
andConditions.push({
|
|
178
181
|
'object.reservationNumber': {
|
|
@@ -220,7 +223,7 @@ class MongoRepository {
|
|
|
220
223
|
}
|
|
221
224
|
break;
|
|
222
225
|
case factory.assetTransactionType.RegisterService:
|
|
223
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
226
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_1 = (_0 = (_z = (_y = params.object) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.serviceOutput) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$eq;
|
|
224
227
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
225
228
|
andConditions.push({
|
|
226
229
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -229,7 +232,7 @@ class MongoRepository {
|
|
|
229
232
|
}
|
|
230
233
|
});
|
|
231
234
|
}
|
|
232
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
235
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_5 = (_4 = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.itemOffered) === null || _3 === void 0 ? void 0 : _3.serviceOutput) === null || _4 === void 0 ? void 0 : _4.identifier) === null || _5 === void 0 ? void 0 : _5.$in;
|
|
233
236
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
234
237
|
andConditions.push({
|
|
235
238
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -589,12 +592,30 @@ class MongoRepository {
|
|
|
589
592
|
/**
|
|
590
593
|
* 取引を検索する
|
|
591
594
|
*/
|
|
592
|
-
search(params,
|
|
595
|
+
search(params, inclusion, exclusion) {
|
|
593
596
|
var _a;
|
|
594
597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
595
598
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
599
|
+
let projection = {};
|
|
600
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
601
|
+
inclusion.forEach((field) => {
|
|
602
|
+
projection[field] = 1;
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
projection = {
|
|
607
|
+
__v: 0,
|
|
608
|
+
createdAt: 0,
|
|
609
|
+
updatedAt: 0
|
|
610
|
+
};
|
|
611
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
612
|
+
exclusion.forEach((field) => {
|
|
613
|
+
projection[field] = 0;
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
596
617
|
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
597
|
-
.select(
|
|
618
|
+
.select(projection);
|
|
598
619
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
599
620
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
600
621
|
query.limit(params.limit)
|
|
@@ -0,0 +1,74 @@
|
|
|
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" />
|
|
25
|
+
import { Schema } from 'mongoose';
|
|
26
|
+
declare const modelName = "Offer";
|
|
27
|
+
/**
|
|
28
|
+
* アイテムコンディションスキーマ
|
|
29
|
+
*/
|
|
30
|
+
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
|
+
collection: string;
|
|
32
|
+
id: true;
|
|
33
|
+
read: string;
|
|
34
|
+
writeConcern: import("mongodb").WriteConcern;
|
|
35
|
+
strict: true;
|
|
36
|
+
strictQuery: false;
|
|
37
|
+
timestamps: {
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
};
|
|
41
|
+
toJSON: {
|
|
42
|
+
getters: false;
|
|
43
|
+
virtuals: false;
|
|
44
|
+
minimize: false;
|
|
45
|
+
versionKey: false;
|
|
46
|
+
};
|
|
47
|
+
toObject: {
|
|
48
|
+
getters: false;
|
|
49
|
+
virtuals: true;
|
|
50
|
+
minimize: false;
|
|
51
|
+
versionKey: false;
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
name?: any;
|
|
55
|
+
typeOf?: string | undefined;
|
|
56
|
+
project?: any;
|
|
57
|
+
identifier?: string | undefined;
|
|
58
|
+
itemOfferded?: any;
|
|
59
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
60
|
+
name?: any;
|
|
61
|
+
typeOf?: string | undefined;
|
|
62
|
+
project?: any;
|
|
63
|
+
identifier?: string | undefined;
|
|
64
|
+
itemOfferded?: any;
|
|
65
|
+
}>> & Omit<import("mongoose").FlatRecord<{
|
|
66
|
+
name?: any;
|
|
67
|
+
typeOf?: string | undefined;
|
|
68
|
+
project?: any;
|
|
69
|
+
identifier?: string | undefined;
|
|
70
|
+
itemOfferded?: any;
|
|
71
|
+
}> & {
|
|
72
|
+
_id: import("mongoose").Types.ObjectId;
|
|
73
|
+
}, never>>;
|
|
74
|
+
export { modelName, schema };
|
|
@@ -0,0 +1,45 @@
|
|
|
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 = 'Offer';
|
|
7
|
+
exports.modelName = modelName;
|
|
8
|
+
/**
|
|
9
|
+
* アイテムコンディションスキーマ
|
|
10
|
+
*/
|
|
11
|
+
const schema = new mongoose_1.Schema({
|
|
12
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
identifier: String,
|
|
14
|
+
typeOf: String,
|
|
15
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
16
|
+
itemOfferded: mongoose_1.SchemaTypes.Mixed
|
|
17
|
+
}, {
|
|
18
|
+
collection: 'offerItemConditions',
|
|
19
|
+
id: true,
|
|
20
|
+
read: 'primaryPreferred',
|
|
21
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
22
|
+
strict: true,
|
|
23
|
+
strictQuery: false,
|
|
24
|
+
timestamps: {
|
|
25
|
+
createdAt: 'createdAt',
|
|
26
|
+
updatedAt: 'updatedAt'
|
|
27
|
+
},
|
|
28
|
+
toJSON: {
|
|
29
|
+
getters: false,
|
|
30
|
+
virtuals: false,
|
|
31
|
+
minimize: false,
|
|
32
|
+
versionKey: false
|
|
33
|
+
},
|
|
34
|
+
toObject: {
|
|
35
|
+
getters: false,
|
|
36
|
+
virtuals: true,
|
|
37
|
+
minimize: false,
|
|
38
|
+
versionKey: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
exports.schema = schema;
|
|
42
|
+
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
43
|
+
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
44
|
+
schema.index({ identifier: 1 }, { name: 'searchByIdentifier' });
|
|
45
|
+
schema.index({ 'project.id': 1, identifier: 1 }, { name: 'searchByProjectId' });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IProjection {
|
|
4
|
+
[key: string]: 0 | 1;
|
|
5
|
+
}
|
|
6
|
+
interface IOfferItemCondition {
|
|
7
|
+
id?: string;
|
|
8
|
+
identifier: string;
|
|
9
|
+
itemOfferded: {
|
|
10
|
+
typeOf: factory.product.ProductType.EventService;
|
|
11
|
+
serviceOutput?: {
|
|
12
|
+
typeOf: factory.reservationType.EventReservation;
|
|
13
|
+
reservationFor: any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
name: factory.multilingualString;
|
|
17
|
+
project: {
|
|
18
|
+
id: string;
|
|
19
|
+
typeOf: factory.organizationType.Project;
|
|
20
|
+
};
|
|
21
|
+
typeOf: 'OfferItemCondition';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* アイテムコンディションリポジトリ
|
|
25
|
+
*/
|
|
26
|
+
export declare class MongoRepository {
|
|
27
|
+
private readonly offerItemConditionModel;
|
|
28
|
+
constructor(connection: Connection);
|
|
29
|
+
static CREATE_MONGO_CONDITIONS(params: any): any[];
|
|
30
|
+
findById(params: {
|
|
31
|
+
id: string;
|
|
32
|
+
}): Promise<IOfferItemCondition>;
|
|
33
|
+
search(params: any, projection?: IProjection): Promise<IOfferItemCondition[]>;
|
|
34
|
+
save(params: IOfferItemCondition): Promise<IOfferItemCondition>;
|
|
35
|
+
deleteById(params: {
|
|
36
|
+
id: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const factory = require("../factory");
|
|
25
|
+
const offerItemCondition_1 = require("./mongoose/schemas/offerItemCondition");
|
|
26
|
+
/**
|
|
27
|
+
* アイテムコンディションリポジトリ
|
|
28
|
+
*/
|
|
29
|
+
class MongoRepository {
|
|
30
|
+
constructor(connection) {
|
|
31
|
+
this.offerItemConditionModel = connection.model(offerItemCondition_1.modelName, offerItemCondition_1.schema);
|
|
32
|
+
}
|
|
33
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
const andConditions = [];
|
|
36
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
37
|
+
if (typeof projectIdEq === 'string') {
|
|
38
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
39
|
+
}
|
|
40
|
+
const identifierEq = (_c = params.identifier) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
41
|
+
if (typeof identifierEq === 'string') {
|
|
42
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
43
|
+
}
|
|
44
|
+
const identifierIn = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$in;
|
|
45
|
+
if (Array.isArray(identifierIn)) {
|
|
46
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
47
|
+
}
|
|
48
|
+
return andConditions;
|
|
49
|
+
}
|
|
50
|
+
findById(params) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const doc = yield this.offerItemConditionModel.findOne({ _id: params.id }, {
|
|
53
|
+
__v: 0,
|
|
54
|
+
createdAt: 0,
|
|
55
|
+
updatedAt: 0
|
|
56
|
+
})
|
|
57
|
+
.exec();
|
|
58
|
+
if (doc === null) {
|
|
59
|
+
throw new factory.errors.NotFound(this.offerItemConditionModel.modelName);
|
|
60
|
+
}
|
|
61
|
+
return doc.toObject();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
search(params, projection) {
|
|
65
|
+
var _a;
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
68
|
+
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
69
|
+
? Object.values(projection)
|
|
70
|
+
.some((value) => value !== 0)
|
|
71
|
+
: false;
|
|
72
|
+
const query = this.offerItemConditionModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
|
|
73
|
+
? projection
|
|
74
|
+
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
|
|
75
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
76
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
77
|
+
query.limit(params.limit)
|
|
78
|
+
.skip(params.limit * (page - 1));
|
|
79
|
+
}
|
|
80
|
+
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) {
|
|
81
|
+
query.sort({ identifier: params.sort.identifier });
|
|
82
|
+
}
|
|
83
|
+
return query.setOptions({ maxTimeMS: 10000 })
|
|
84
|
+
.exec()
|
|
85
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
save(params) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
let doc;
|
|
91
|
+
if (params.id === '') {
|
|
92
|
+
doc = yield this.offerItemConditionModel.create(params);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
|
|
96
|
+
doc = yield this.offerItemConditionModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
97
|
+
.exec();
|
|
98
|
+
}
|
|
99
|
+
if (doc === null) {
|
|
100
|
+
throw new factory.errors.NotFound(this.offerItemConditionModel.modelName);
|
|
101
|
+
}
|
|
102
|
+
return doc.toObject();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
deleteById(params) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
yield this.offerItemConditionModel.findOneAndRemove({ _id: params.id })
|
|
108
|
+
.exec();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -93,6 +93,9 @@ export declare class MongoRepository {
|
|
|
93
93
|
}): Promise<void>;
|
|
94
94
|
deleteByName(params: {
|
|
95
95
|
name: factory.taskName;
|
|
96
|
+
status?: {
|
|
97
|
+
$eq?: factory.taskStatus;
|
|
98
|
+
};
|
|
96
99
|
}): Promise<import("mongodb").DeleteResult>;
|
|
97
100
|
countDelayedTasks(params: {
|
|
98
101
|
delayInSeconds: number;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -411,10 +411,9 @@ class MongoRepository {
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
deleteByName(params) {
|
|
414
|
+
var _a;
|
|
414
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
415
|
-
return this.taskModel.deleteMany({
|
|
416
|
-
name: { $eq: params.name }
|
|
417
|
-
})
|
|
416
|
+
return this.taskModel.deleteMany(Object.assign({ name: { $eq: params.name } }, (typeof ((_a = params.status) === null || _a === void 0 ? void 0 : _a.$eq) === 'string') ? { status: { $eq: params.status.$eq } } : undefined))
|
|
418
417
|
.exec();
|
|
419
418
|
});
|
|
420
419
|
}
|
|
@@ -20,6 +20,7 @@ import { MongoRepository as MemberRepo } from './repo/member';
|
|
|
20
20
|
import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
21
21
|
import { MongoRepository as OfferRepo } from './repo/offer';
|
|
22
22
|
import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
|
|
23
|
+
import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
23
24
|
import { MongoRepository as OrderRepo } from './repo/order';
|
|
24
25
|
import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
25
26
|
import { MongoRepository as PermitRepo } from './repo/permit';
|
|
@@ -123,10 +124,12 @@ export declare class Member extends MemberRepo {
|
|
|
123
124
|
*/
|
|
124
125
|
export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
|
|
125
126
|
}
|
|
126
|
-
export declare class Offer extends OfferRepo {
|
|
127
|
-
}
|
|
128
127
|
export declare class OfferCatalog extends OfferCatalogRepo {
|
|
129
128
|
}
|
|
129
|
+
export declare class OfferItemCondition extends OfferItemConditionRepo {
|
|
130
|
+
}
|
|
131
|
+
export declare class Offer extends OfferRepo {
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* 注文リポジトリ
|
|
132
135
|
*/
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = 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.
|
|
3
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = 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.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.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
|
* リポジトリ
|
|
@@ -24,6 +24,7 @@ const member_1 = require("./repo/member");
|
|
|
24
24
|
const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
|
|
25
25
|
const offer_1 = require("./repo/offer");
|
|
26
26
|
const offerCatalog_1 = require("./repo/offerCatalog");
|
|
27
|
+
const offerItemCondition_1 = require("./repo/offerItemCondition");
|
|
27
28
|
const order_1 = require("./repo/order");
|
|
28
29
|
const ownershipInfo_1 = require("./repo/ownershipInfo");
|
|
29
30
|
const permit_1 = require("./repo/permit");
|
|
@@ -147,12 +148,15 @@ exports.Member = Member;
|
|
|
147
148
|
class MerchantReturnPolicy extends merchantReturnPolicy_1.MongoRepository {
|
|
148
149
|
}
|
|
149
150
|
exports.MerchantReturnPolicy = MerchantReturnPolicy;
|
|
150
|
-
class Offer extends offer_1.MongoRepository {
|
|
151
|
-
}
|
|
152
|
-
exports.Offer = Offer;
|
|
153
151
|
class OfferCatalog extends offerCatalog_1.MongoRepository {
|
|
154
152
|
}
|
|
155
153
|
exports.OfferCatalog = OfferCatalog;
|
|
154
|
+
class OfferItemCondition extends offerItemCondition_1.MongoRepository {
|
|
155
|
+
}
|
|
156
|
+
exports.OfferItemCondition = OfferItemCondition;
|
|
157
|
+
class Offer extends offer_1.MongoRepository {
|
|
158
|
+
}
|
|
159
|
+
exports.Offer = Offer;
|
|
156
160
|
/**
|
|
157
161
|
* 注文リポジトリ
|
|
158
162
|
*/
|
|
@@ -167,27 +167,29 @@ function exportTasksById(params) {
|
|
|
167
167
|
});
|
|
168
168
|
const potentialActions = transaction.potentialActions;
|
|
169
169
|
const taskAttributes = [];
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
170
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
171
|
+
// 資産取引削除タスクを作成
|
|
172
|
+
const deleteTransactionTask = {
|
|
173
|
+
project: transaction.project,
|
|
174
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
175
|
+
status: factory.taskStatus.Ready,
|
|
176
|
+
runsAt: moment(transaction.endDate)
|
|
177
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
178
|
+
.toDate(),
|
|
179
|
+
remainingNumberOfTries: 3,
|
|
180
|
+
numberOfTried: 0,
|
|
181
|
+
executionResults: [],
|
|
182
|
+
data: {
|
|
183
|
+
object: {
|
|
184
|
+
project: transaction.project,
|
|
185
|
+
id: transaction.id,
|
|
186
|
+
transactionNumber: transaction.transactionNumber,
|
|
187
|
+
typeOf: transaction.typeOf
|
|
188
|
+
}
|
|
187
189
|
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
};
|
|
191
|
+
taskAttributes.push(deleteTransactionTask);
|
|
192
|
+
}
|
|
191
193
|
switch (transaction.status) {
|
|
192
194
|
case factory.transactionStatusType.Confirmed:
|
|
193
195
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -360,27 +360,29 @@ function exportTasksById(params) {
|
|
|
360
360
|
});
|
|
361
361
|
const potentialActions = transaction.potentialActions;
|
|
362
362
|
const taskAttributes = [];
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
363
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
364
|
+
// 資産取引削除タスクを作成
|
|
365
|
+
const deleteTransactionTask = {
|
|
366
|
+
project: transaction.project,
|
|
367
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
368
|
+
status: factory.taskStatus.Ready,
|
|
369
|
+
runsAt: moment(transaction.endDate)
|
|
370
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
371
|
+
.toDate(),
|
|
372
|
+
remainingNumberOfTries: 3,
|
|
373
|
+
numberOfTried: 0,
|
|
374
|
+
executionResults: [],
|
|
375
|
+
data: {
|
|
376
|
+
object: {
|
|
377
|
+
project: transaction.project,
|
|
378
|
+
id: transaction.id,
|
|
379
|
+
transactionNumber: transaction.transactionNumber,
|
|
380
|
+
typeOf: transaction.typeOf
|
|
381
|
+
}
|
|
380
382
|
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
};
|
|
384
|
+
taskAttributes.push(deleteTransactionTask);
|
|
385
|
+
}
|
|
384
386
|
// タスク実行日時バッファの指定があれば調整
|
|
385
387
|
let taskRunsAt = new Date();
|
|
386
388
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
|
@@ -399,27 +399,29 @@ function exportTasksById(params) {
|
|
|
399
399
|
});
|
|
400
400
|
const potentialActions = transaction.potentialActions;
|
|
401
401
|
const taskAttributes = [];
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
402
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
403
|
+
// 資産取引削除タスクを作成
|
|
404
|
+
const deleteTransactionTask = {
|
|
405
|
+
project: transaction.project,
|
|
406
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
407
|
+
status: factory.taskStatus.Ready,
|
|
408
|
+
runsAt: moment(transaction.endDate)
|
|
409
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
410
|
+
.toDate(),
|
|
411
|
+
remainingNumberOfTries: 3,
|
|
412
|
+
numberOfTried: 0,
|
|
413
|
+
executionResults: [],
|
|
414
|
+
data: {
|
|
415
|
+
object: {
|
|
416
|
+
project: transaction.project,
|
|
417
|
+
id: transaction.id,
|
|
418
|
+
transactionNumber: transaction.transactionNumber,
|
|
419
|
+
typeOf: transaction.typeOf
|
|
420
|
+
}
|
|
419
421
|
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
422
|
+
};
|
|
423
|
+
taskAttributes.push(deleteTransactionTask);
|
|
424
|
+
}
|
|
423
425
|
// タスク実行日時バッファの指定があれば調整
|
|
424
426
|
let taskRunsAt = new Date();
|
|
425
427
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
|
@@ -160,27 +160,29 @@ function exportTasksById(params) {
|
|
|
160
160
|
});
|
|
161
161
|
const potentialActions = transaction.potentialActions;
|
|
162
162
|
const taskAttributes = [];
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
164
|
+
// 資産取引削除タスクを作成
|
|
165
|
+
const deleteTransactionTask = {
|
|
166
|
+
project: transaction.project,
|
|
167
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
168
|
+
status: factory.taskStatus.Ready,
|
|
169
|
+
runsAt: moment(transaction.endDate)
|
|
170
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
171
|
+
.toDate(),
|
|
172
|
+
remainingNumberOfTries: 3,
|
|
173
|
+
numberOfTried: 0,
|
|
174
|
+
executionResults: [],
|
|
175
|
+
data: {
|
|
176
|
+
object: {
|
|
177
|
+
project: transaction.project,
|
|
178
|
+
id: transaction.id,
|
|
179
|
+
transactionNumber: transaction.transactionNumber,
|
|
180
|
+
typeOf: transaction.typeOf
|
|
181
|
+
}
|
|
180
182
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
};
|
|
184
|
+
taskAttributes.push(deleteTransactionTask);
|
|
185
|
+
}
|
|
184
186
|
// タスク実行日時バッファの指定があれば調整
|
|
185
187
|
let taskRunsAt = new Date();
|
|
186
188
|
if (typeof params.runsTasksAfterInSeconds === 'number') {
|
|
@@ -230,27 +230,29 @@ function exportTasksById(params) {
|
|
|
230
230
|
});
|
|
231
231
|
const potentialActions = transaction.potentialActions;
|
|
232
232
|
const taskAttributes = [];
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
233
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
234
|
+
// 資産取引削除タスクを作成
|
|
235
|
+
const deleteTransactionTask = {
|
|
236
|
+
project: transaction.project,
|
|
237
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
238
|
+
status: factory.taskStatus.Ready,
|
|
239
|
+
runsAt: moment(transaction.endDate)
|
|
240
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
241
|
+
.toDate(),
|
|
242
|
+
remainingNumberOfTries: 3,
|
|
243
|
+
numberOfTried: 0,
|
|
244
|
+
executionResults: [],
|
|
245
|
+
data: {
|
|
246
|
+
object: {
|
|
247
|
+
project: transaction.project,
|
|
248
|
+
id: transaction.id,
|
|
249
|
+
transactionNumber: transaction.transactionNumber,
|
|
250
|
+
typeOf: transaction.typeOf
|
|
251
|
+
}
|
|
250
252
|
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
};
|
|
254
|
+
taskAttributes.push(deleteTransactionTask);
|
|
255
|
+
}
|
|
254
256
|
const taskRunsAt = new Date();
|
|
255
257
|
switch (transaction.status) {
|
|
256
258
|
case factory.transactionStatusType.Confirmed:
|
|
@@ -773,27 +773,29 @@ function exportTasksById(params) {
|
|
|
773
773
|
});
|
|
774
774
|
const potentialActions = transaction.potentialActions;
|
|
775
775
|
const taskAttributes = [];
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
776
|
+
if (settings_1.USE_DELETE_ASSET_TRANSACTION_TASK) {
|
|
777
|
+
// 資産取引削除タスクを作成
|
|
778
|
+
const deleteTransactionTask = {
|
|
779
|
+
project: transaction.project,
|
|
780
|
+
name: factory.taskName.DeleteAssetTransaction,
|
|
781
|
+
status: factory.taskStatus.Ready,
|
|
782
|
+
runsAt: moment(transaction.endDate)
|
|
783
|
+
.add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
784
|
+
.toDate(),
|
|
785
|
+
remainingNumberOfTries: 3,
|
|
786
|
+
numberOfTried: 0,
|
|
787
|
+
executionResults: [],
|
|
788
|
+
data: {
|
|
789
|
+
object: {
|
|
790
|
+
project: transaction.project,
|
|
791
|
+
id: transaction.id,
|
|
792
|
+
transactionNumber: transaction.transactionNumber,
|
|
793
|
+
typeOf: transaction.typeOf
|
|
794
|
+
}
|
|
793
795
|
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
796
|
+
};
|
|
797
|
+
taskAttributes.push(deleteTransactionTask);
|
|
798
|
+
}
|
|
797
799
|
switch (transaction.status) {
|
|
798
800
|
case factory.transactionStatusType.Confirmed:
|
|
799
801
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -134,13 +134,7 @@ function refundTransactionAlreadyExists(params) {
|
|
|
134
134
|
typeOf: factory.assetTransactionType.Refund,
|
|
135
135
|
statuses: [factory.transactionStatusType.Confirmed],
|
|
136
136
|
object: { paymentMethodId: { $eq: params.object.paymentMethodId } }
|
|
137
|
-
},
|
|
138
|
-
agent: 0,
|
|
139
|
-
object: 0,
|
|
140
|
-
potentialActions: 0,
|
|
141
|
-
recipient: 0,
|
|
142
|
-
result: 0
|
|
143
|
-
});
|
|
137
|
+
}, ['_id'], []);
|
|
144
138
|
return refundTransactions.length > 0;
|
|
145
139
|
});
|
|
146
140
|
}
|
|
@@ -31,7 +31,7 @@ function deleteTransaction(params) {
|
|
|
31
31
|
// すでに削除済
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
//
|
|
34
|
+
// アクション開始
|
|
35
35
|
const actionAttributes = {
|
|
36
36
|
typeOf: factory.actionType.DeleteAction,
|
|
37
37
|
project: transaction.project,
|
|
@@ -39,30 +39,28 @@ function deleteTransaction(params) {
|
|
|
39
39
|
agent: transaction.project
|
|
40
40
|
};
|
|
41
41
|
let deletePayTransactionResult;
|
|
42
|
+
let deleteRefundResult;
|
|
42
43
|
let payTransactionNumbers = [];
|
|
43
44
|
let deleteReservationsResult;
|
|
44
45
|
let deleteReserveTransactionResult;
|
|
45
46
|
let deletedReservationNumbers = [];
|
|
47
|
+
let deleteActionResult;
|
|
46
48
|
const action = yield repos.action.start(actionAttributes);
|
|
47
49
|
try {
|
|
48
50
|
const transactionTypeOf = transaction.typeOf;
|
|
49
51
|
switch (transactionTypeOf) {
|
|
50
52
|
case factory.transactionType.PlaceOrder:
|
|
53
|
+
// 取引に対する全ての承認アクションを検索
|
|
54
|
+
const authorizeActions = yield repos.action.searchByPurpose({
|
|
55
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
56
|
+
purpose: {
|
|
57
|
+
typeOf: transaction.typeOf,
|
|
58
|
+
id: transaction.id
|
|
59
|
+
}
|
|
60
|
+
});
|
|
51
61
|
switch (transaction.status) {
|
|
52
|
-
// 中止あるいは期限切れ取引の場合
|
|
53
62
|
case factory.transactionStatusType.Canceled:
|
|
54
63
|
case factory.transactionStatusType.Expired:
|
|
55
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
56
|
-
// TODO サービス登録取引を削除
|
|
57
|
-
// 決済取引を削除
|
|
58
|
-
const deletePayTransactionsByPlaceOrderResult = yield deletePayTransactionsByPlaceOrder({ transaction })(repos);
|
|
59
|
-
deletePayTransactionResult = deletePayTransactionsByPlaceOrderResult.deletePayTransactionResult;
|
|
60
|
-
payTransactionNumbers = deletePayTransactionsByPlaceOrderResult.payTransactionNumbers;
|
|
61
|
-
// 取引上での予約を削除
|
|
62
|
-
const deleteReservationsByPlaceOrderResult = yield deleteReservationsByPlaceOrder({ transaction })(repos);
|
|
63
|
-
deleteReservationsResult = deleteReservationsByPlaceOrderResult.deleteResult;
|
|
64
|
-
deleteReserveTransactionResult = deleteReservationsByPlaceOrderResult.deleteReserveTransactionResult;
|
|
65
|
-
deletedReservationNumbers = deleteReservationsByPlaceOrderResult.reserveTransactionNumbers;
|
|
66
64
|
break;
|
|
67
65
|
case factory.transactionStatusType.Confirmed:
|
|
68
66
|
const deletingOrder = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
|
|
@@ -74,6 +72,24 @@ function deleteTransaction(params) {
|
|
|
74
72
|
break;
|
|
75
73
|
default:
|
|
76
74
|
}
|
|
75
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
76
|
+
// TODO サービス登録取引を削除
|
|
77
|
+
// 決済取引を削除
|
|
78
|
+
const deletePayTransactionsByPlaceOrderResult = yield deletePayTransactionsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
79
|
+
deletePayTransactionResult = deletePayTransactionsByPlaceOrderResult.deletePayTransactionResult;
|
|
80
|
+
deleteRefundResult = deletePayTransactionsByPlaceOrderResult.deleteRefundResult;
|
|
81
|
+
payTransactionNumbers = deletePayTransactionsByPlaceOrderResult.payTransactionNumbers;
|
|
82
|
+
// 取引上での予約を削除
|
|
83
|
+
const deleteReservationsByPlaceOrderResult = yield deleteReservationsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
84
|
+
deleteReservationsResult = deleteReservationsByPlaceOrderResult.deleteResult;
|
|
85
|
+
deleteReserveTransactionResult = deleteReservationsByPlaceOrderResult.deleteReserveTransactionResult;
|
|
86
|
+
deletedReservationNumbers = deleteReservationsByPlaceOrderResult.reserveTransactionNumbers;
|
|
87
|
+
// アクション削除(2023-05-19~)
|
|
88
|
+
deleteActionResult = yield repos.action.deleteByPurpose({
|
|
89
|
+
project: { id: transaction.project.id },
|
|
90
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
91
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
92
|
+
});
|
|
77
93
|
// 取引削除
|
|
78
94
|
yield repos.transaction.findByIdAndDelete({ id: transaction.id });
|
|
79
95
|
break;
|
|
@@ -105,10 +121,12 @@ function deleteTransaction(params) {
|
|
|
105
121
|
// アクション完了
|
|
106
122
|
const actionResult = {
|
|
107
123
|
deletePayTransactionResult,
|
|
124
|
+
deleteRefundResult,
|
|
108
125
|
payTransactionNumbers,
|
|
109
126
|
deleteReservationsResult,
|
|
110
127
|
deleteReserveTransactionResult,
|
|
111
|
-
deletedReservationNumbers
|
|
128
|
+
deletedReservationNumbers,
|
|
129
|
+
deleteActionResult
|
|
112
130
|
};
|
|
113
131
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
114
132
|
});
|
|
@@ -118,14 +136,7 @@ function deleteReservationsByPlaceOrder(params) {
|
|
|
118
136
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
119
137
|
let deleteResult;
|
|
120
138
|
let deleteReserveTransactionResult;
|
|
121
|
-
|
|
122
|
-
const authorizeActions = yield repos.action.searchByPurpose({
|
|
123
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
124
|
-
purpose: {
|
|
125
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
126
|
-
id: params.transaction.id
|
|
127
|
-
}
|
|
128
|
-
});
|
|
139
|
+
const authorizeActions = params.authorizeActions;
|
|
129
140
|
// 予約取引番号を抽出
|
|
130
141
|
const authorizeReservationOfferActions = authorizeActions
|
|
131
142
|
.filter((a) => {
|
|
@@ -159,6 +170,8 @@ function deleteReservationsByPlaceOrder(params) {
|
|
|
159
170
|
ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
|
|
160
171
|
deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
|
|
161
172
|
};
|
|
173
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
174
|
+
// TODO 予約取消取引も削除可能か?
|
|
162
175
|
}
|
|
163
176
|
return { deleteResult, deleteReserveTransactionResult, reserveTransactionNumbers };
|
|
164
177
|
});
|
|
@@ -166,14 +179,8 @@ function deleteReservationsByPlaceOrder(params) {
|
|
|
166
179
|
function deletePayTransactionsByPlaceOrder(params) {
|
|
167
180
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
168
181
|
let deletePayTransactionResult;
|
|
169
|
-
|
|
170
|
-
const authorizeActions =
|
|
171
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
172
|
-
purpose: {
|
|
173
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
174
|
-
id: params.transaction.id
|
|
175
|
-
}
|
|
176
|
-
});
|
|
182
|
+
let deleteRefundResult;
|
|
183
|
+
const authorizeActions = params.authorizeActions;
|
|
177
184
|
// 決済取引番号を抽出
|
|
178
185
|
const authorizePaymentActions = authorizeActions
|
|
179
186
|
.filter((a) => {
|
|
@@ -196,7 +203,24 @@ function deletePayTransactionsByPlaceOrder(params) {
|
|
|
196
203
|
ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
|
|
197
204
|
deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
|
|
198
205
|
};
|
|
206
|
+
// 返金取引も削除(2023-05-19~)
|
|
207
|
+
const refundTransactions = yield repos.assetTransaction.search({
|
|
208
|
+
typeOf: factory.assetTransactionType.Refund,
|
|
209
|
+
object: { paymentMethodId: { $in: payTransactionNumbers } }
|
|
210
|
+
}, ['transactionNumber'], []);
|
|
211
|
+
if (refundTransactions.length > 0) {
|
|
212
|
+
const deleteRefundAssetTransactionsResult = yield repos.assetTransaction.deleteByTransactionNumber({
|
|
213
|
+
project: { id: params.transaction.project.id },
|
|
214
|
+
transactionNumbers: refundTransactions.map((refundTransaction) => refundTransaction.transactionNumber),
|
|
215
|
+
typeOf: factory.assetTransactionType.Refund
|
|
216
|
+
});
|
|
217
|
+
deleteRefundResult = {
|
|
218
|
+
n: deleteRefundAssetTransactionsResult === null || deleteRefundAssetTransactionsResult === void 0 ? void 0 : deleteRefundAssetTransactionsResult.n,
|
|
219
|
+
ok: deleteRefundAssetTransactionsResult === null || deleteRefundAssetTransactionsResult === void 0 ? void 0 : deleteRefundAssetTransactionsResult.ok,
|
|
220
|
+
deletedCount: deleteRefundAssetTransactionsResult === null || deleteRefundAssetTransactionsResult === void 0 ? void 0 : deleteRefundAssetTransactionsResult.deletedCount
|
|
221
|
+
};
|
|
222
|
+
}
|
|
199
223
|
}
|
|
200
|
-
return { deletePayTransactionResult, payTransactionNumbers };
|
|
224
|
+
return { deletePayTransactionResult, deleteRefundResult, payTransactionNumbers };
|
|
201
225
|
});
|
|
202
226
|
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
|
33
33
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
34
34
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
35
35
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
36
|
+
export declare const USE_DELETE_ASSET_TRANSACTION_TASK: boolean;
|
|
36
37
|
export declare const USE_DELETE_ORDER_TASK: boolean;
|
|
37
38
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
38
39
|
/**
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_ORDER_TASK = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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 = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_ORDER_TASK = exports.USE_DELETE_ASSET_TRANSACTION_TASK = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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 = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -59,6 +59,7 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
59
59
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
60
60
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
61
61
|
: moment('2023-08-31T15:00:00Z');
|
|
62
|
+
exports.USE_DELETE_ASSET_TRANSACTION_TASK = process.env.USE_DELETE_ASSET_TRANSACTION_TASK === '1';
|
|
62
63
|
exports.USE_DELETE_ORDER_TASK = process.env.USE_DELETE_ORDER_TASK === '1';
|
|
63
64
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
64
65
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.4",
|
|
13
13
|
"@cinerino/sdk": "3.156.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -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.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.59"
|
|
121
121
|
}
|