@chevre/domain 21.22.0 → 21.23.0-alpha.1
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/findReservationByCode.ts +34 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +2 -2
- package/lib/chevre/repo/acceptedOffer.d.ts +4 -1
- package/lib/chevre/repo/acceptedOffer.js +8 -4
- package/lib/chevre/repo/code.d.ts +2 -2
- package/lib/chevre/repo/code.js +27 -54
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/authorization.js +31 -29
- package/lib/chevre/repo/order.js +1 -1
- package/lib/chevre/repo/reservation.d.ts +5 -3
- package/lib/chevre/repo/reservation.js +6 -26
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/order/deleteOrder.js +5 -7
- package/lib/chevre/service/payment/creditCard.js +3 -2
- package/lib/chevre/service/reserve/findByCode.d.ts +30 -0
- package/lib/chevre/service/reserve/findByCode.js +91 -0
- package/lib/chevre/service/reserve/searchByOrder.d.ts +1 -1
- package/lib/chevre/service/reserve.d.ts +2 -1
- package/lib/chevre/service/reserve.js +3 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +13 -8
- package/package.json +3 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
16
|
+
const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
|
|
17
|
+
const reservationRepo = await chevre.repository.Reservation.createInstance(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const result = await (await chevre.service.reserve.createService()).findByCode({
|
|
20
|
+
project: { id: project.id },
|
|
21
|
+
code: '068cb0ba-8529-4a2b-8cf5-890d5af9c536',
|
|
22
|
+
id: '589701779538948-0'
|
|
23
|
+
})({
|
|
24
|
+
acceptedOffer: acceptedOfferRepo,
|
|
25
|
+
authorization: authorizationRepo,
|
|
26
|
+
reservation: reservationRepo
|
|
27
|
+
});
|
|
28
|
+
// tslint:disable-next-line:no-null-keyword
|
|
29
|
+
console.dir(result, { depth: null });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main()
|
|
33
|
+
.then(console.log)
|
|
34
|
+
.catch(console.error);
|
|
@@ -20,11 +20,11 @@ async function main() {
|
|
|
20
20
|
runsAt: {
|
|
21
21
|
$gte: moment()
|
|
22
22
|
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
-
.add(
|
|
23
|
+
.add(223, 'days')
|
|
24
24
|
.toDate(),
|
|
25
25
|
$lte: moment()
|
|
26
26
|
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
-
.add(
|
|
27
|
+
.add(300, 'days')
|
|
28
28
|
.toDate()
|
|
29
29
|
}
|
|
30
30
|
// _id: { $eq: '64aba5f37b8b8ef9eca60be5' }
|
|
@@ -85,20 +85,24 @@ class MongoRepository {
|
|
|
85
85
|
* 注文オファーを展開して検索する
|
|
86
86
|
*/
|
|
87
87
|
searchAcceptedOffersByOrderNumber(filter, inclusion) {
|
|
88
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
const matchStages = [
|
|
91
91
|
{ $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
|
|
92
92
|
{ $match: { 'project.id': { $eq: filter.project.id.$eq } } },
|
|
93
93
|
{ $match: { typeOf: { $eq: factory.order.OrderType.Order } } }
|
|
94
94
|
];
|
|
95
|
-
const
|
|
95
|
+
const itemOfferedIdEq = (_c = (_b = (_a = filter.acceptedOffers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
96
|
+
if (typeof itemOfferedIdEq === 'string') {
|
|
97
|
+
matchStages.push({ $match: { 'acceptedOffers.itemOffered.id': { $exists: true, $eq: itemOfferedIdEq } } });
|
|
98
|
+
}
|
|
99
|
+
const itemOfferedTypeOfIn = (_f = (_e = (_d = filter.acceptedOffers) === null || _d === void 0 ? void 0 : _d.itemOffered) === null || _e === void 0 ? void 0 : _e.typeOf) === null || _f === void 0 ? void 0 : _f.$in;
|
|
96
100
|
if (Array.isArray(itemOfferedTypeOfIn)) {
|
|
97
101
|
matchStages.push({
|
|
98
102
|
$match: { 'acceptedOffers.itemOffered.typeOf': { $exists: true, $in: itemOfferedTypeOfIn } }
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
|
-
const resevationForIdIn = (
|
|
105
|
+
const resevationForIdIn = (_k = (_j = (_h = (_g = filter.acceptedOffers) === null || _g === void 0 ? void 0 : _g.itemOffered) === null || _h === void 0 ? void 0 : _h.reservationFor) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
|
|
102
106
|
if (Array.isArray(resevationForIdIn)) {
|
|
103
107
|
matchStages.push({
|
|
104
108
|
$match: {
|
|
@@ -106,7 +110,7 @@ class MongoRepository {
|
|
|
106
110
|
}
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
|
-
const ticketedSeatNumberIn = (
|
|
113
|
+
const ticketedSeatNumberIn = (_q = (_p = (_o = (_m = (_l = filter.acceptedOffers) === null || _l === void 0 ? void 0 : _l.itemOffered) === null || _m === void 0 ? void 0 : _m.reservedTicket) === null || _o === void 0 ? void 0 : _o.ticketedSeat) === null || _p === void 0 ? void 0 : _p.seatNumber) === null || _q === void 0 ? void 0 : _q.$in;
|
|
110
114
|
if (Array.isArray(ticketedSeatNumberIn)) {
|
|
111
115
|
matchStages.push({
|
|
112
116
|
$match: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { modelName } from './mongoose/schemas/authorization';
|
|
4
4
|
export type IObject = factory.authorization.IObject;
|
|
@@ -10,7 +10,7 @@ export { modelName };
|
|
|
10
10
|
export declare class MongoRepository {
|
|
11
11
|
private readonly authorizationModel;
|
|
12
12
|
constructor(connection: Connection);
|
|
13
|
-
static CREATE_MONGO_CONDITIONS(params: factory.authorization.ISearchConditions):
|
|
13
|
+
static CREATE_MONGO_CONDITIONS(params: factory.authorization.ISearchConditions): FilterQuery<factory.authorization.IAuthorization>[];
|
|
14
14
|
/**
|
|
15
15
|
* コードを発行する
|
|
16
16
|
*/
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -25,33 +25,27 @@ class MongoRepository {
|
|
|
25
25
|
}
|
|
26
26
|
// tslint:disable-next-line:max-func-body-length
|
|
27
27
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
28
|
-
var _a, _b;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f;
|
|
29
29
|
const andConditions = [];
|
|
30
30
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
31
31
|
if (typeof projectIdEq === 'string') {
|
|
32
|
-
andConditions.push({
|
|
33
|
-
'project.id': {
|
|
34
|
-
$eq: projectIdEq
|
|
35
|
-
}
|
|
36
|
-
});
|
|
32
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (Array.isArray(params.id.$in)) {
|
|
42
|
-
andConditions.push({
|
|
43
|
-
_id: { $in: params.id.$in }
|
|
44
|
-
});
|
|
45
|
-
}
|
|
34
|
+
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
35
|
+
if (typeof idEq === 'string') {
|
|
36
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
46
37
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
39
|
+
if (Array.isArray(idIn)) {
|
|
40
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
41
|
+
}
|
|
42
|
+
const codeEq = (_e = params.code) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
43
|
+
if (typeof codeEq === 'string') {
|
|
44
|
+
andConditions.push({ code: { $eq: codeEq } });
|
|
45
|
+
}
|
|
46
|
+
const codeIn = (_f = params.code) === null || _f === void 0 ? void 0 : _f.$in;
|
|
47
|
+
if (Array.isArray(codeIn)) {
|
|
48
|
+
andConditions.push({ code: { $in: codeIn } });
|
|
55
49
|
}
|
|
56
50
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
57
51
|
/* istanbul ignore else */
|
|
@@ -102,26 +96,16 @@ class MongoRepository {
|
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
113
|
-
/* istanbul ignore else */
|
|
99
|
+
// if (Array.isArray(params.codes)) {
|
|
100
|
+
// andConditions.push({
|
|
101
|
+
// code: { $exists: true, $in: params.codes }
|
|
102
|
+
// });
|
|
103
|
+
// }
|
|
114
104
|
if (params.validFrom instanceof Date) {
|
|
115
|
-
andConditions.push({
|
|
116
|
-
validUntil: { $exists: true, $gte: params.validFrom }
|
|
117
|
-
});
|
|
105
|
+
andConditions.push({ validUntil: { $exists: true, $gte: params.validFrom } });
|
|
118
106
|
}
|
|
119
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
120
|
-
/* istanbul ignore else */
|
|
121
107
|
if (params.validThrough instanceof Date) {
|
|
122
|
-
andConditions.push({
|
|
123
|
-
validFrom: { $lte: params.validThrough }
|
|
124
|
-
});
|
|
108
|
+
andConditions.push({ validFrom: { $lte: params.validThrough } });
|
|
125
109
|
}
|
|
126
110
|
return andConditions;
|
|
127
111
|
}
|
|
@@ -150,21 +134,10 @@ class MongoRepository {
|
|
|
150
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
135
|
const now = new Date();
|
|
152
136
|
const doc = yield this.authorizationModel.findOne({
|
|
153
|
-
'project.id': {
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
$exists: true,
|
|
158
|
-
$eq: params.code
|
|
159
|
-
},
|
|
160
|
-
validFrom: {
|
|
161
|
-
$exists: true,
|
|
162
|
-
$lte: now
|
|
163
|
-
},
|
|
164
|
-
validUntil: {
|
|
165
|
-
$exists: true,
|
|
166
|
-
$gte: now
|
|
167
|
-
}
|
|
137
|
+
'project.id': { $eq: params.project.id },
|
|
138
|
+
code: { $eq: String(params.code) },
|
|
139
|
+
validFrom: { $lte: now },
|
|
140
|
+
validUntil: { $exists: true, $gte: now }
|
|
168
141
|
})
|
|
169
142
|
.exec();
|
|
170
143
|
if (doc === null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Authorization";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|
|
@@ -8,10 +8,19 @@ const modelName = 'Authorization';
|
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
10
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
-
typeOf:
|
|
12
|
-
|
|
11
|
+
typeOf: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
code: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
13
19
|
object: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
-
validFrom:
|
|
20
|
+
validFrom: {
|
|
21
|
+
type: Date,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
15
24
|
validUntil: Date
|
|
16
25
|
};
|
|
17
26
|
const schemaOptions = {
|
|
@@ -40,17 +49,6 @@ const schemaOptions = {
|
|
|
40
49
|
versionKey: false
|
|
41
50
|
}
|
|
42
51
|
};
|
|
43
|
-
/**
|
|
44
|
-
* 認可スキーマ
|
|
45
|
-
*/
|
|
46
|
-
let schema;
|
|
47
|
-
function createSchema() {
|
|
48
|
-
if (schema === undefined) {
|
|
49
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
50
|
-
}
|
|
51
|
-
return schema;
|
|
52
|
-
}
|
|
53
|
-
exports.createSchema = createSchema;
|
|
54
52
|
const indexes = [
|
|
55
53
|
[
|
|
56
54
|
{ createdAt: 1 },
|
|
@@ -74,27 +72,15 @@ const indexes = [
|
|
|
74
72
|
],
|
|
75
73
|
[
|
|
76
74
|
{ 'project.id': 1, validFrom: 1 },
|
|
77
|
-
{
|
|
78
|
-
name: 'searchByProjectId-v20220721'
|
|
79
|
-
}
|
|
75
|
+
{ name: 'searchByProjectId-v20220721' }
|
|
80
76
|
],
|
|
81
77
|
[
|
|
82
78
|
{ typeOf: 1, validFrom: 1 },
|
|
83
|
-
{
|
|
84
|
-
name: 'searchByTypeOf',
|
|
85
|
-
partialFilterExpression: {
|
|
86
|
-
typeOf: { $exists: true }
|
|
87
|
-
}
|
|
88
|
-
}
|
|
79
|
+
{ name: 'searchByTypeOf-v2' }
|
|
89
80
|
],
|
|
90
81
|
[
|
|
91
82
|
{ code: 1, validFrom: 1 },
|
|
92
|
-
{
|
|
93
|
-
name: 'searchByCode',
|
|
94
|
-
partialFilterExpression: {
|
|
95
|
-
code: { $exists: true }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
83
|
+
{ name: 'searchByCode-v2' }
|
|
98
84
|
],
|
|
99
85
|
[
|
|
100
86
|
{ validUntil: 1, validFrom: 1 },
|
|
@@ -143,3 +129,19 @@ const indexes = [
|
|
|
143
129
|
]
|
|
144
130
|
];
|
|
145
131
|
exports.indexes = indexes;
|
|
132
|
+
/**
|
|
133
|
+
* 承認スキーマ
|
|
134
|
+
*/
|
|
135
|
+
let schema;
|
|
136
|
+
function createSchema() {
|
|
137
|
+
if (schema === undefined) {
|
|
138
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
139
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
140
|
+
indexes.forEach((indexParams) => {
|
|
141
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return schema;
|
|
146
|
+
}
|
|
147
|
+
exports.createSchema = createSchema;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -949,7 +949,7 @@ class MongoRepository {
|
|
|
949
949
|
deleteByOrderNumber(params) {
|
|
950
950
|
return __awaiter(this, void 0, void 0, function* () {
|
|
951
951
|
yield this.orderModel.deleteOne({
|
|
952
|
-
orderNumber: params.orderNumber,
|
|
952
|
+
orderNumber: { $eq: params.orderNumber },
|
|
953
953
|
typeOf: { $eq: factory.order.OrderType.Order }
|
|
954
954
|
})
|
|
955
955
|
.exec();
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { BulkWriteResult } from 'mongodb';
|
|
26
|
-
import type { Connection, UpdateWriteOpResult } from 'mongoose';
|
|
26
|
+
import type { Connection, FilterQuery, UpdateWriteOpResult } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
28
|
export interface IUpdatePartiallyParams {
|
|
29
29
|
additionalTicketText?: string;
|
|
@@ -34,13 +34,14 @@ export type ICreatingReservation<T extends factory.reservationType> = T extends
|
|
|
34
34
|
} : T extends factory.reservationType.EventReservation ? (factory.reservation.eventReservation.IReservation) & {
|
|
35
35
|
_id: string;
|
|
36
36
|
} : never;
|
|
37
|
+
type IKeyOfProjection = keyof factory.reservation.IReservation<factory.reservationType.BusReservation | factory.reservationType.EventReservation> | '_id';
|
|
37
38
|
/**
|
|
38
39
|
* 予約リポジトリ
|
|
39
40
|
*/
|
|
40
41
|
export declare class MongoRepository {
|
|
41
42
|
private readonly reservationModel;
|
|
42
43
|
constructor(connection: Connection);
|
|
43
|
-
static CREATE_MONGO_CONDITIONS(params: factory.reservation.ISearchConditions<factory.reservationType>):
|
|
44
|
+
static CREATE_MONGO_CONDITIONS(params: factory.reservation.ISearchConditions<factory.reservationType>): FilterQuery<import("@chevre/factory/lib/reservation/busReservation").IReservation | import("@chevre/factory/lib/reservation/event").IReservation | import("@chevre/factory/lib/reservation/reservationPackage").IReservation>[];
|
|
44
45
|
/**
|
|
45
46
|
* 汎用予約カウント
|
|
46
47
|
*/
|
|
@@ -49,7 +50,7 @@ export declare class MongoRepository {
|
|
|
49
50
|
* 予約検索
|
|
50
51
|
*/
|
|
51
52
|
search<T extends factory.reservationType>(params: factory.reservation.ISearchConditions<T>, projection?: {
|
|
52
|
-
[key
|
|
53
|
+
[key in IKeyOfProjection]?: 0 | 1;
|
|
53
54
|
}): Promise<factory.reservation.IReservation<factory.reservationType.EventReservation>[]>;
|
|
54
55
|
findById<T extends factory.reservationType>(params: {
|
|
55
56
|
id: string;
|
|
@@ -144,3 +145,4 @@ export declare class MongoRepository {
|
|
|
144
145
|
deleteReservedTicketUnderName(): Promise<import("mongodb").UpdateResult>;
|
|
145
146
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
146
147
|
}
|
|
148
|
+
export {};
|
|
@@ -25,7 +25,7 @@ class MongoRepository {
|
|
|
25
25
|
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, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
26
26
|
// MongoDB検索条件
|
|
27
27
|
const andConditions = [
|
|
28
|
-
{ typeOf: params.typeOf }
|
|
28
|
+
{ typeOf: { $eq: params.typeOf } }
|
|
29
29
|
];
|
|
30
30
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
31
31
|
if (typeof projectIdEq === 'string') {
|
|
@@ -38,42 +38,22 @@ class MongoRepository {
|
|
|
38
38
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
39
39
|
/* istanbul ignore else */
|
|
40
40
|
if (Array.isArray(params.ids)) {
|
|
41
|
-
andConditions.push({
|
|
42
|
-
_id: {
|
|
43
|
-
$in: params.ids
|
|
44
|
-
}
|
|
45
|
-
});
|
|
41
|
+
andConditions.push({ _id: { $in: params.ids } });
|
|
46
42
|
}
|
|
47
43
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
48
44
|
/* istanbul ignore else */
|
|
49
45
|
if (params.id !== undefined && params.id !== null) {
|
|
50
46
|
if (typeof params.id.$eq === 'string') {
|
|
51
|
-
andConditions.push({
|
|
52
|
-
_id: {
|
|
53
|
-
$eq: params.id.$eq
|
|
54
|
-
}
|
|
55
|
-
});
|
|
47
|
+
andConditions.push({ _id: { $eq: params.id.$eq } });
|
|
56
48
|
}
|
|
57
49
|
if (typeof params.id.$ne === 'string') {
|
|
58
|
-
andConditions.push({
|
|
59
|
-
_id: {
|
|
60
|
-
$ne: params.id.$ne
|
|
61
|
-
}
|
|
62
|
-
});
|
|
50
|
+
andConditions.push({ _id: { $ne: params.id.$ne } });
|
|
63
51
|
}
|
|
64
52
|
if (Array.isArray(params.id.$in)) {
|
|
65
|
-
andConditions.push({
|
|
66
|
-
_id: {
|
|
67
|
-
$in: params.id.$in
|
|
68
|
-
}
|
|
69
|
-
});
|
|
53
|
+
andConditions.push({ _id: { $in: params.id.$in } });
|
|
70
54
|
}
|
|
71
55
|
if (Array.isArray(params.id.$nin)) {
|
|
72
|
-
andConditions.push({
|
|
73
|
-
_id: {
|
|
74
|
-
$nin: params.id.$nin
|
|
75
|
-
}
|
|
76
|
-
});
|
|
56
|
+
andConditions.push({ _id: { $nin: params.id.$nin } });
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
59
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -25,7 +25,7 @@ function getToken(params) {
|
|
|
25
25
|
const authorizations = yield repos.authorization.search({
|
|
26
26
|
limit: 1,
|
|
27
27
|
project: { id: { $eq: params.project.id } },
|
|
28
|
-
code: { $
|
|
28
|
+
code: { $eq: String(params.code) },
|
|
29
29
|
validFrom: now,
|
|
30
30
|
validThrough: now
|
|
31
31
|
});
|
|
@@ -62,14 +62,12 @@ function deleteReservationsByOrder(order) {
|
|
|
62
62
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
64
64
|
orderNumber: { $eq: order.orderNumber },
|
|
65
|
-
project: { id: { $eq: order.project.id } }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
.map((o) => {
|
|
71
|
-
return o.itemOffered.id;
|
|
65
|
+
project: { id: { $eq: order.project.id } },
|
|
66
|
+
acceptedOffers: {
|
|
67
|
+
itemOffered: { typeOf: { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] } }
|
|
68
|
+
}
|
|
72
69
|
});
|
|
70
|
+
const reservationIds = acceptedOffers.map((o) => String(o.itemOffered.id));
|
|
73
71
|
if (reservationIds.length > 0) {
|
|
74
72
|
yield repos.reservation.deleteByIds({ project: { id: order.project.id }, ids: reservationIds });
|
|
75
73
|
}
|
|
@@ -538,8 +538,9 @@ function processChangeTransaction(params) {
|
|
|
538
538
|
if (error.name === 'GMOServiceBadRequestError') {
|
|
539
539
|
// 会員が存在しない場合このエラーになる
|
|
540
540
|
if (Array.isArray(error.errors) && error.errors.length === 1 && error.errors[0].info === 'E01050004') {
|
|
541
|
-
|
|
542
|
-
|
|
541
|
+
debug('creditCardService.alterTran:E01050004:', 'orderId:', searchTradeResult.orderId, 'status:', searchTradeResult.status);
|
|
542
|
+
if (searchTradeResult.status === GMO.utils.util.Status.Authenticated
|
|
543
|
+
|| searchTradeResult.status === GMO.utils.util.Status.Void) {
|
|
543
544
|
throwsError = false;
|
|
544
545
|
}
|
|
545
546
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
3
|
+
import type { MongoRepository as AuthorizationRepo } from '../../repo/code';
|
|
4
|
+
import type { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
5
|
+
type AvailableReservationType = factory.reservationType.BusReservation | factory.reservationType.EventReservation;
|
|
6
|
+
type IReservationResult = Pick<factory.reservation.IReservation<AvailableReservationType>, 'id' | 'additionalTicketText' | 'reservationStatus'> & {
|
|
7
|
+
reservedTicket: {
|
|
8
|
+
ticketType: Pick<factory.reservation.ITicketType<AvailableReservationType>, 'identifier' | 'name'>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare function findByCode(params: {
|
|
12
|
+
/**
|
|
13
|
+
* 予約ID
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
project: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 注文コード
|
|
21
|
+
*/
|
|
22
|
+
code: string;
|
|
23
|
+
}): (repos: {
|
|
24
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
25
|
+
authorization: AuthorizationRepo;
|
|
26
|
+
reservation: ReservationRepo;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
reservation: IReservationResult;
|
|
29
|
+
}>;
|
|
30
|
+
export { findByCode };
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.findByCode = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
function findByCode(params) {
|
|
15
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
18
|
+
throw new factory.errors.ArgumentNull('id');
|
|
19
|
+
}
|
|
20
|
+
if (typeof params.code !== 'string' || params.code.length === 0) {
|
|
21
|
+
throw new factory.errors.ArgumentNull('code');
|
|
22
|
+
}
|
|
23
|
+
const now = new Date();
|
|
24
|
+
const authorization = (yield repos.authorization.search({
|
|
25
|
+
limit: 1,
|
|
26
|
+
project: { id: { $eq: params.project.id } },
|
|
27
|
+
code: { $eq: params.code },
|
|
28
|
+
validFrom: now,
|
|
29
|
+
validThrough: now
|
|
30
|
+
})).shift();
|
|
31
|
+
if (authorization === undefined) {
|
|
32
|
+
throw new factory.errors.NotFound('Authorization');
|
|
33
|
+
}
|
|
34
|
+
let reservationIdInOrder;
|
|
35
|
+
let reservationTypeInOrder;
|
|
36
|
+
let offeredThroughIdentifier = factory.service.webAPI.Identifier.Chevre;
|
|
37
|
+
const data = authorization.object;
|
|
38
|
+
switch (data.typeOf) {
|
|
39
|
+
case factory.order.OrderType.Order:
|
|
40
|
+
const { orderNumber } = data;
|
|
41
|
+
const acceptedOffer = (yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
42
|
+
limit: 1,
|
|
43
|
+
page: 1,
|
|
44
|
+
project: { id: { $eq: params.project.id } },
|
|
45
|
+
orderNumber: { $eq: String(orderNumber) },
|
|
46
|
+
acceptedOffers: { itemOffered: { id: { $eq: String(params.id) } } }
|
|
47
|
+
}, ['itemOffered', 'offeredThrough'])).shift();
|
|
48
|
+
const itemOfferedTypeOf = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.typeOf;
|
|
49
|
+
if (itemOfferedTypeOf === factory.reservationType.BusReservation
|
|
50
|
+
|| itemOfferedTypeOf === factory.reservationType.EventReservation) {
|
|
51
|
+
reservationIdInOrder = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.id;
|
|
52
|
+
reservationTypeInOrder = itemOfferedTypeOf;
|
|
53
|
+
offeredThroughIdentifier = (_a = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
throw new factory.errors.NotImplemented(`authorization object typeOf: ${data.typeOf} not implemented`);
|
|
58
|
+
}
|
|
59
|
+
let reservation;
|
|
60
|
+
if (typeof reservationIdInOrder === 'string' && typeof reservationTypeInOrder === 'string') {
|
|
61
|
+
switch (offeredThroughIdentifier) {
|
|
62
|
+
// COA対応
|
|
63
|
+
case factory.service.webAPI.Identifier.COA:
|
|
64
|
+
throw new factory.errors.NotImplemented(`offeredThroughIdentifier: ${offeredThroughIdentifier} not implemented`);
|
|
65
|
+
default:
|
|
66
|
+
const reservationFromRepo = (yield repos.reservation.search({
|
|
67
|
+
project: { id: { $eq: params.project.id } },
|
|
68
|
+
typeOf: reservationTypeInOrder,
|
|
69
|
+
id: { $eq: reservationIdInOrder }
|
|
70
|
+
}, { id: 1, additionalTicketText: 1, reservationStatus: 1, reservedTicket: 1 })).shift();
|
|
71
|
+
if (reservationFromRepo !== undefined) {
|
|
72
|
+
const { id, additionalTicketText, reservationStatus, reservedTicket } = reservationFromRepo;
|
|
73
|
+
reservation = {
|
|
74
|
+
id, additionalTicketText, reservationStatus,
|
|
75
|
+
reservedTicket: {
|
|
76
|
+
ticketType: {
|
|
77
|
+
identifier: reservedTicket === null || reservedTicket === void 0 ? void 0 : reservedTicket.ticketType.identifier,
|
|
78
|
+
name: { ja: (_b = reservedTicket === null || reservedTicket === void 0 ? void 0 : reservedTicket.ticketType.name) === null || _b === void 0 ? void 0 : _b.ja }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (reservation === undefined) {
|
|
86
|
+
throw new factory.errors.NotFound('Reservation');
|
|
87
|
+
}
|
|
88
|
+
return { reservation };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.findByCode = findByCode;
|
|
@@ -6,7 +6,7 @@ type IReservationResult = Pick<factory.reservation.IReservation<factory.reservat
|
|
|
6
6
|
declare function searchByOrder(params: {
|
|
7
7
|
limit: number;
|
|
8
8
|
page: number;
|
|
9
|
-
typeOf: factory.reservationType;
|
|
9
|
+
typeOf: factory.reservationType.BusReservation | factory.reservationType.EventReservation;
|
|
10
10
|
project: {
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
@@ -5,7 +5,8 @@ import { maskUnderName } from './reserve/factory';
|
|
|
5
5
|
import { cancelPendingReservation, cancelReservation } from './reserve/cancelReservation';
|
|
6
6
|
import { checkInReservation } from './reserve/checkInReservation';
|
|
7
7
|
import { confirmReservation } from './reserve/confirmReservation';
|
|
8
|
+
import { findByCode } from './reserve/findByCode';
|
|
8
9
|
import { searchByOrder } from './reserve/searchByOrder';
|
|
9
10
|
import { useReservation } from './reserve/useReservation';
|
|
10
11
|
import { verifyToken4reservation } from './reserve/verifyToken4reservation';
|
|
11
|
-
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInReservation, confirmReservation, searchByOrder, useReservation, verifyToken4reservation };
|
|
12
|
+
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInReservation, confirmReservation, findByCode, searchByOrder, useReservation, verifyToken4reservation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyToken4reservation = exports.useReservation = exports.searchByOrder = exports.confirmReservation = exports.checkInReservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
3
|
+
exports.verifyToken4reservation = exports.useReservation = exports.searchByOrder = exports.findByCode = exports.confirmReservation = exports.checkInReservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約サービス
|
|
6
6
|
*/
|
|
@@ -13,6 +13,8 @@ const checkInReservation_1 = require("./reserve/checkInReservation");
|
|
|
13
13
|
Object.defineProperty(exports, "checkInReservation", { enumerable: true, get: function () { return checkInReservation_1.checkInReservation; } });
|
|
14
14
|
const confirmReservation_1 = require("./reserve/confirmReservation");
|
|
15
15
|
Object.defineProperty(exports, "confirmReservation", { enumerable: true, get: function () { return confirmReservation_1.confirmReservation; } });
|
|
16
|
+
const findByCode_1 = require("./reserve/findByCode");
|
|
17
|
+
Object.defineProperty(exports, "findByCode", { enumerable: true, get: function () { return findByCode_1.findByCode; } });
|
|
16
18
|
const searchByOrder_1 = require("./reserve/searchByOrder");
|
|
17
19
|
Object.defineProperty(exports, "searchByOrder", { enumerable: true, get: function () { return searchByOrder_1.searchByOrder; } });
|
|
18
20
|
const useReservation_1 = require("./reserve/useReservation");
|
|
@@ -149,13 +149,16 @@ function deleteTransactionById(params) {
|
|
|
149
149
|
&& params.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.Id) {
|
|
150
150
|
throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.task.deleteTransaction.SpecifyingMethod.Id}`);
|
|
151
151
|
}
|
|
152
|
-
const
|
|
153
|
-
|
|
152
|
+
const deletingTransactionId = params.object.id;
|
|
153
|
+
if (typeof deletingTransactionId !== 'string' || deletingTransactionId.length === 0) {
|
|
154
|
+
throw new factory.errors.ArgumentNull('object.id');
|
|
155
|
+
}
|
|
156
|
+
const transaction = (yield repos.transaction.search({
|
|
157
|
+
ids: [deletingTransactionId],
|
|
154
158
|
typeOf: params.object.typeOf,
|
|
155
|
-
inclusion: [],
|
|
159
|
+
inclusion: ['typeOf', 'project', 'status', 'result'],
|
|
156
160
|
exclusion: []
|
|
157
|
-
});
|
|
158
|
-
const transaction = transactions.shift();
|
|
161
|
+
})).shift();
|
|
159
162
|
if (transaction === undefined) {
|
|
160
163
|
// すでに削除済
|
|
161
164
|
return;
|
|
@@ -183,7 +186,7 @@ function deleteTransactionById(params) {
|
|
|
183
186
|
const authorizeActions = yield repos.action.searchByPurpose({
|
|
184
187
|
typeOf: factory.actionType.AuthorizeAction,
|
|
185
188
|
purpose: {
|
|
186
|
-
typeOf:
|
|
189
|
+
typeOf: transactionTypeOf,
|
|
187
190
|
id: transaction.id
|
|
188
191
|
}
|
|
189
192
|
});
|
|
@@ -200,6 +203,7 @@ function deleteTransactionById(params) {
|
|
|
200
203
|
}
|
|
201
204
|
break;
|
|
202
205
|
default:
|
|
206
|
+
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
203
207
|
}
|
|
204
208
|
// tslint:disable-next-line:no-suspicious-comment
|
|
205
209
|
// TODO サービス登録取引を削除
|
|
@@ -216,10 +220,11 @@ function deleteTransactionById(params) {
|
|
|
216
220
|
// アクション削除(2023-05-19~)
|
|
217
221
|
deleteActionResult = yield repos.action.deleteByPurpose({
|
|
218
222
|
project: { id: transaction.project.id },
|
|
219
|
-
purpose: { id: transaction.id, typeOf:
|
|
223
|
+
purpose: { id: transaction.id, typeOf: transactionTypeOf },
|
|
220
224
|
typeOf: {
|
|
221
225
|
$in: [
|
|
222
226
|
factory.actionType.AuthorizeAction,
|
|
227
|
+
factory.actionType.CheckAction,
|
|
223
228
|
factory.actionType.InformAction,
|
|
224
229
|
factory.actionType.OrderAction
|
|
225
230
|
]
|
|
@@ -343,7 +348,7 @@ function deletePayTransactionsByPlaceOrder(params) {
|
|
|
343
348
|
if (refundTransactions.length > 0) {
|
|
344
349
|
const deleteRefundAssetTransactionsResult = yield repos.assetTransaction.deleteByTransactionNumber({
|
|
345
350
|
project: { id: params.transaction.project.id },
|
|
346
|
-
transactionNumbers: refundTransactions.map((
|
|
351
|
+
transactionNumbers: refundTransactions.map(({ transactionNumber }) => transactionNumber),
|
|
347
352
|
typeOf: factory.assetTransactionType.Refund
|
|
348
353
|
});
|
|
349
354
|
deleteRefundResult = {
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
14
|
-
"@cinerino/sdk": "5.12.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.356.0",
|
|
14
|
+
"@cinerino/sdk": "5.12.0-alpha.2",
|
|
15
15
|
"@motionpicture/coa-service": "9.3.0-alpha.5",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.4",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.
|
|
113
|
+
"version": "21.23.0-alpha.1"
|
|
114
114
|
}
|