@chevre/domain 21.2.0-alpha.0 → 21.2.0-alpha.2
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/lib/chevre/repo/confirmationNumber.d.ts +3 -1
- package/lib/chevre/repo/confirmationNumber.js +31 -30
- package/lib/chevre/repo/itemAvailability/screeningEvent.d.ts +3 -8
- package/lib/chevre/repo/itemAvailability/screeningEvent.js +32 -20
- package/lib/chevre/repo/orderNumber.d.ts +3 -1
- package/lib/chevre/repo/orderNumber.js +33 -27
- package/lib/chevre/service/assetTransaction/reserve.js +66 -3
- package/lib/chevre/service/offer.d.ts +11 -24
- package/lib/chevre/service/offer.js +16 -114
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +4 -1
- package/package.json +1 -1
|
@@ -3,10 +3,12 @@ import { RedisClientType } from 'redis';
|
|
|
3
3
|
* 確認番号リポジトリ
|
|
4
4
|
*/
|
|
5
5
|
export declare class RedisRepository {
|
|
6
|
+
private static readonly REDIS_KEY_PREFIX_NEW;
|
|
6
7
|
private static readonly REDIS_KEY_PREFIX;
|
|
7
8
|
private readonly redisClient;
|
|
8
9
|
constructor(redisClient: RedisClientType);
|
|
9
|
-
static
|
|
10
|
+
private static alignDigits;
|
|
11
|
+
private static createKey;
|
|
10
12
|
/**
|
|
11
13
|
* 発行する
|
|
12
14
|
*/
|
|
@@ -16,6 +16,7 @@ const util = require("util");
|
|
|
16
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
17
17
|
const fpe = require('node-fpe');
|
|
18
18
|
const factory = require("../factory");
|
|
19
|
+
const settings_1 = require("../settings");
|
|
19
20
|
const CONFIRMATION_NUMBER_MIN_LENGH = 4;
|
|
20
21
|
/**
|
|
21
22
|
* 確認番号リポジトリ
|
|
@@ -24,7 +25,7 @@ class RedisRepository {
|
|
|
24
25
|
constructor(redisClient) {
|
|
25
26
|
this.redisClient = redisClient;
|
|
26
27
|
}
|
|
27
|
-
static
|
|
28
|
+
static alignDigits(params) {
|
|
28
29
|
let aligndNumber = String(params);
|
|
29
30
|
if (aligndNumber.length < CONFIRMATION_NUMBER_MIN_LENGH) {
|
|
30
31
|
aligndNumber = `${'0'.repeat(CONFIRMATION_NUMBER_MIN_LENGH)}${aligndNumber}`
|
|
@@ -32,6 +33,21 @@ class RedisRepository {
|
|
|
32
33
|
}
|
|
33
34
|
return aligndNumber;
|
|
34
35
|
}
|
|
36
|
+
static createKey(params) {
|
|
37
|
+
const useNewKey = params.orderDate instanceof Date
|
|
38
|
+
&& moment(params.orderDate)
|
|
39
|
+
.isSameOrAfter(settings_1.USE_NEW_ORDER_NUMBER_KEY_FROM);
|
|
40
|
+
if (useNewKey) {
|
|
41
|
+
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
|
|
42
|
+
.tz('Asia/Tokyo')
|
|
43
|
+
.format('YYMM'));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, moment(params.orderDate)
|
|
47
|
+
.tz('Asia/Tokyo')
|
|
48
|
+
.format('YYMM'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
35
51
|
/**
|
|
36
52
|
* 発行する
|
|
37
53
|
*/
|
|
@@ -41,44 +57,29 @@ class RedisRepository {
|
|
|
41
57
|
const TTL = moment(params.orderDate)
|
|
42
58
|
.add(1, 'month')
|
|
43
59
|
.diff(moment(params.orderDate), 'seconds');
|
|
44
|
-
const key =
|
|
45
|
-
.tz('Asia/Tokyo')
|
|
46
|
-
.format('YYMM'));
|
|
60
|
+
const key = RedisRepository.createKey({ orderDate: params.orderDate });
|
|
47
61
|
const [incrReply] = yield this.redisClient.multi()
|
|
48
62
|
.incr(key)
|
|
49
63
|
.expire(key, TTL)
|
|
50
64
|
.exec();
|
|
51
|
-
// if (!Array.isArray(results)) {
|
|
52
|
-
// // なぜかresults: nullのことがあるのでハンドリング
|
|
53
|
-
// throw new factory.errors.ServiceUnavailable('incr confirmationNumber result not array');
|
|
54
|
-
// }
|
|
55
65
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
56
|
-
/* istanbul ignore
|
|
57
|
-
if (typeof incrReply
|
|
58
|
-
const no = incrReply;
|
|
59
|
-
// debug('no incremented.', no);
|
|
60
|
-
// 桁数調整
|
|
61
|
-
let confirmationNumber = RedisRepository.ALIGN_DIGITS(String(no));
|
|
62
|
-
// debug('encrypting confirmationNumber...', confirmationNumber);
|
|
63
|
-
// checkdigit
|
|
64
|
-
const cd = cdigit.luhn.compute(confirmationNumber);
|
|
65
|
-
// debug('check digit:', cd);
|
|
66
|
-
confirmationNumber = fpe({ password: cd })
|
|
67
|
-
.encrypt(confirmationNumber);
|
|
68
|
-
confirmationNumber = `${cd}${confirmationNumber}`;
|
|
69
|
-
// console.log(
|
|
70
|
-
// 'decrypted confirmationNumber:',
|
|
71
|
-
// fpe({ password: confirmationNumber.slice(0, 1) })
|
|
72
|
-
// .decrypt(confirmationNumber.slice(1))
|
|
73
|
-
// );
|
|
74
|
-
return confirmationNumber;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
66
|
+
/* istanbul ignore if */
|
|
67
|
+
if (typeof incrReply !== 'number') {
|
|
77
68
|
// 基本的にありえないフロー
|
|
78
|
-
throw new factory.errors.ServiceUnavailable('
|
|
69
|
+
throw new factory.errors.ServiceUnavailable('confirmation number not incremented unexpectedly');
|
|
79
70
|
}
|
|
71
|
+
// 桁数調整
|
|
72
|
+
let confirmationNumber = RedisRepository.alignDigits(incrReply);
|
|
73
|
+
// checkdigit
|
|
74
|
+
const cd = cdigit.luhn.compute(confirmationNumber);
|
|
75
|
+
// debug('check digit:', cd);
|
|
76
|
+
confirmationNumber = fpe({ password: cd })
|
|
77
|
+
.encrypt(confirmationNumber);
|
|
78
|
+
confirmationNumber = `${cd}${confirmationNumber}`;
|
|
79
|
+
return confirmationNumber;
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
RedisRepository.REDIS_KEY_PREFIX_NEW = 'confirmationNumber';
|
|
83
84
|
RedisRepository.REDIS_KEY_PREFIX = 'cinerino:confirmationNumber';
|
|
84
85
|
exports.RedisRepository = RedisRepository;
|
|
@@ -25,18 +25,15 @@ export interface IUnlockKey {
|
|
|
25
25
|
offer: IOffer;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* イベントストックホルダーリポジトリ
|
|
29
29
|
*/
|
|
30
30
|
export declare class RedisRepository {
|
|
31
31
|
static KEY_PREFIX_NEW: string;
|
|
32
32
|
static KEY_PREFIX: string;
|
|
33
33
|
private readonly redisClient;
|
|
34
34
|
constructor(redisClient: RedisClientType);
|
|
35
|
-
static
|
|
36
|
-
static
|
|
37
|
-
eventId: string;
|
|
38
|
-
startDate: Date;
|
|
39
|
-
}): string;
|
|
35
|
+
private static offer2field;
|
|
36
|
+
private static createKey;
|
|
40
37
|
/**
|
|
41
38
|
* 座席をロックする(maxキャパシティチェック有)
|
|
42
39
|
*/
|
|
@@ -78,8 +75,6 @@ export declare class RedisRepository {
|
|
|
78
75
|
startDate: Date;
|
|
79
76
|
offers: IOffer[];
|
|
80
77
|
}): Promise<{
|
|
81
|
-
seatSection: string;
|
|
82
|
-
seatNumber: string;
|
|
83
78
|
availability: factory.itemAvailability;
|
|
84
79
|
}[]>;
|
|
85
80
|
}
|
|
@@ -16,13 +16,13 @@ const factory = require("../../factory");
|
|
|
16
16
|
const settings_1 = require("../../settings");
|
|
17
17
|
const debug = createDebug('chevre-domain:repo');
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* イベントストックホルダーリポジトリ
|
|
20
20
|
*/
|
|
21
21
|
class RedisRepository {
|
|
22
22
|
constructor(redisClient) {
|
|
23
23
|
this.redisClient = redisClient;
|
|
24
24
|
}
|
|
25
|
-
static
|
|
25
|
+
static offer2field(params) {
|
|
26
26
|
var _a, _b;
|
|
27
27
|
// 予約IDをfieldにする場合
|
|
28
28
|
const serviceOutputId = (_b = (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id;
|
|
@@ -31,10 +31,10 @@ class RedisRepository {
|
|
|
31
31
|
}
|
|
32
32
|
return `${params.seatSection}:${params.seatNumber}`;
|
|
33
33
|
}
|
|
34
|
-
static
|
|
34
|
+
static createKey(params) {
|
|
35
35
|
const useNewKey = params.startDate instanceof Date
|
|
36
36
|
&& moment(params.startDate)
|
|
37
|
-
.
|
|
37
|
+
.isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
|
|
38
38
|
if (useNewKey) {
|
|
39
39
|
return `${RedisRepository.KEY_PREFIX_NEW}:${params.eventId}`;
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ class RedisRepository {
|
|
|
47
47
|
*/
|
|
48
48
|
lockIfNotLimitExceeded(lockKey, maximum) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const key = RedisRepository.
|
|
50
|
+
const key = RedisRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
51
51
|
yield this.redisClient.watch(key);
|
|
52
52
|
const hashCount = yield this.redisClient.hLen(key);
|
|
53
53
|
// Process result
|
|
@@ -64,10 +64,10 @@ class RedisRepository {
|
|
|
64
64
|
*/
|
|
65
65
|
lock(lockKey) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const key = RedisRepository.
|
|
67
|
+
const key = RedisRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
68
68
|
const value = lockKey.holder;
|
|
69
69
|
const multi = this.redisClient.multi();
|
|
70
|
-
const fields = lockKey.offers.map((offer) => RedisRepository.
|
|
70
|
+
const fields = lockKey.offers.map((offer) => RedisRepository.offer2field(offer));
|
|
71
71
|
fields.forEach((field) => {
|
|
72
72
|
multi.hSetNX(key, field, value);
|
|
73
73
|
});
|
|
@@ -103,8 +103,8 @@ class RedisRepository {
|
|
|
103
103
|
*/
|
|
104
104
|
unlock(params) {
|
|
105
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const key = RedisRepository.
|
|
107
|
-
const field = RedisRepository.
|
|
106
|
+
const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
107
|
+
const field = RedisRepository.offer2field(params.offer);
|
|
108
108
|
yield this.redisClient.multi()
|
|
109
109
|
.hDel(key, field)
|
|
110
110
|
.exec();
|
|
@@ -115,7 +115,7 @@ class RedisRepository {
|
|
|
115
115
|
*/
|
|
116
116
|
findUnavailableOffersByEventId(params) {
|
|
117
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const key = RedisRepository.
|
|
118
|
+
const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
119
119
|
const reply = yield this.redisClient.hGetAll(key);
|
|
120
120
|
let offers = [];
|
|
121
121
|
if (reply !== null) {
|
|
@@ -134,7 +134,7 @@ class RedisRepository {
|
|
|
134
134
|
*/
|
|
135
135
|
countUnavailableOffers(params) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const key = RedisRepository.
|
|
137
|
+
const key = RedisRepository.createKey({ eventId: params.event.id, startDate: params.event.startDate });
|
|
138
138
|
const reply = yield this.redisClient.hLen(key);
|
|
139
139
|
let fieldCount = 0;
|
|
140
140
|
if (typeof reply === 'number') {
|
|
@@ -148,8 +148,8 @@ class RedisRepository {
|
|
|
148
148
|
*/
|
|
149
149
|
getHolder(params) {
|
|
150
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
const key = RedisRepository.
|
|
152
|
-
const field = RedisRepository.
|
|
151
|
+
const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
152
|
+
const field = RedisRepository.offer2field(params.offer);
|
|
153
153
|
return this.redisClient.hGet(key, field);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
@@ -159,19 +159,31 @@ class RedisRepository {
|
|
|
159
159
|
*/
|
|
160
160
|
searchAvailability(params) {
|
|
161
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const key = RedisRepository.
|
|
162
|
+
const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
163
163
|
const fields = params.offers.map((o) => {
|
|
164
|
-
return RedisRepository.
|
|
164
|
+
return RedisRepository.offer2field(o);
|
|
165
165
|
});
|
|
166
|
+
// Array reply: list of values associated with the given fields, in the same order as they are requested.
|
|
166
167
|
const result = yield this.redisClient.hmGet(key, fields);
|
|
167
168
|
if (!Array.isArray(result)) {
|
|
168
169
|
throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
|
|
169
170
|
}
|
|
170
|
-
return params.offers.map((o, index) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
// return params.offers.map((o, index) => {
|
|
172
|
+
// const value4offer = result[index];
|
|
173
|
+
// return {
|
|
174
|
+
// ...o,
|
|
175
|
+
// availability: (typeof value4offer === 'string')
|
|
176
|
+
// ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
177
|
+
// : factory.itemAvailability.InStock
|
|
178
|
+
// };
|
|
179
|
+
// });
|
|
180
|
+
// availabilityのみ返却(2023-04-17~)
|
|
181
|
+
return result.map((holder) => {
|
|
182
|
+
return {
|
|
183
|
+
availability: (typeof holder === 'string')
|
|
184
|
+
? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
185
|
+
: factory.itemAvailability.InStock
|
|
186
|
+
};
|
|
175
187
|
});
|
|
176
188
|
});
|
|
177
189
|
}
|
|
@@ -3,9 +3,11 @@ import { RedisClientType } from 'redis';
|
|
|
3
3
|
* 注文番号リポジトリ
|
|
4
4
|
*/
|
|
5
5
|
export declare class RedisRepository {
|
|
6
|
-
static
|
|
6
|
+
private static readonly REDIS_KEY_PREFIX_NEW;
|
|
7
|
+
private static readonly REDIS_KEY_PREFIX;
|
|
7
8
|
private readonly redisClient;
|
|
8
9
|
constructor(redisClient: RedisClientType);
|
|
10
|
+
private static createKey;
|
|
9
11
|
/**
|
|
10
12
|
* タイムスタンプから発行する
|
|
11
13
|
*/
|
|
@@ -16,6 +16,8 @@ const util = require("util");
|
|
|
16
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
17
17
|
const fpe = require('node-fpe');
|
|
18
18
|
const factory = require("../factory");
|
|
19
|
+
const settings_1 = require("../settings");
|
|
20
|
+
const ORDER_NUMBER_SEPARATOR = '-';
|
|
19
21
|
/**
|
|
20
22
|
* 注文番号リポジトリ
|
|
21
23
|
*/
|
|
@@ -23,6 +25,17 @@ class RedisRepository {
|
|
|
23
25
|
constructor(redisClient) {
|
|
24
26
|
this.redisClient = redisClient;
|
|
25
27
|
}
|
|
28
|
+
static createKey(params) {
|
|
29
|
+
const useNewKey = params.orderDate instanceof Date
|
|
30
|
+
&& moment(params.orderDate)
|
|
31
|
+
.isSameOrAfter(settings_1.USE_NEW_ORDER_NUMBER_KEY_FROM);
|
|
32
|
+
if (useNewKey) {
|
|
33
|
+
return util.format('%s:%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, params.projectPrefix, params.timestamp);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return util.format('%s:%s:%s', RedisRepository.REDIS_KEY_PREFIX, params.projectPrefix, params.timestamp);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
26
39
|
/**
|
|
27
40
|
* タイムスタンプから発行する
|
|
28
41
|
*/
|
|
@@ -37,42 +50,35 @@ class RedisRepository {
|
|
|
37
50
|
const TTL = moment(params.orderDate)
|
|
38
51
|
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
39
52
|
.diff(now, 'seconds');
|
|
40
|
-
const key =
|
|
53
|
+
const key = RedisRepository.createKey({ orderDate: params.orderDate, projectPrefix, timestamp });
|
|
41
54
|
const [incrReply] = yield this.redisClient.multi()
|
|
42
55
|
.incr(key)
|
|
43
56
|
.expire(key, TTL)
|
|
44
57
|
.exec();
|
|
45
|
-
// if (!Array.isArray(results)) {
|
|
46
|
-
// // なぜかresults: nullのことがあるのでハンドリング
|
|
47
|
-
// throw new factory.errors.ServiceUnavailable('incr orderNumber result not array');
|
|
48
|
-
// }
|
|
49
58
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
50
|
-
/* istanbul ignore
|
|
51
|
-
if (typeof incrReply
|
|
52
|
-
let orderNumber = timestamp;
|
|
53
|
-
const no = incrReply;
|
|
54
|
-
orderNumber = `${orderNumber}${no}`;
|
|
55
|
-
// checkdigit
|
|
56
|
-
const cd = cdigit.luhn.compute(orderNumber);
|
|
57
|
-
const cipher = fpe({ password: cd });
|
|
58
|
-
orderNumber = cipher.encrypt(orderNumber);
|
|
59
|
-
orderNumber = `${projectPrefix}${cd}${orderNumber}`;
|
|
60
|
-
orderNumber = `${[
|
|
61
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
62
|
-
orderNumber.slice(0, 4),
|
|
63
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
64
|
-
orderNumber.slice(4, 11),
|
|
65
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
66
|
-
orderNumber.slice(11)
|
|
67
|
-
].join('-')}`;
|
|
68
|
-
return orderNumber;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
59
|
+
/* istanbul ignore if */
|
|
60
|
+
if (typeof incrReply !== 'number') {
|
|
71
61
|
// 基本的にありえないフロー
|
|
72
|
-
throw new factory.errors.ServiceUnavailable('
|
|
62
|
+
throw new factory.errors.ServiceUnavailable('order number not incremented unexpectedly');
|
|
73
63
|
}
|
|
64
|
+
let orderNumber = `${timestamp}${incrReply}`;
|
|
65
|
+
// checkdigit
|
|
66
|
+
const cd = cdigit.luhn.compute(orderNumber);
|
|
67
|
+
orderNumber = fpe({ password: cd })
|
|
68
|
+
.encrypt(orderNumber);
|
|
69
|
+
orderNumber = `${projectPrefix}${cd}${orderNumber}`;
|
|
70
|
+
orderNumber = `${[
|
|
71
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
72
|
+
orderNumber.slice(0, 4),
|
|
73
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
74
|
+
orderNumber.slice(4, 11),
|
|
75
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
76
|
+
orderNumber.slice(11)
|
|
77
|
+
].join(ORDER_NUMBER_SEPARATOR)}`;
|
|
78
|
+
return orderNumber;
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
}
|
|
82
|
+
RedisRepository.REDIS_KEY_PREFIX_NEW = 'orderNumber';
|
|
77
83
|
RedisRepository.REDIS_KEY_PREFIX = 'cinerino:orderNumber';
|
|
78
84
|
exports.RedisRepository = RedisRepository;
|
|
@@ -119,7 +119,7 @@ function addReservations(params) {
|
|
|
119
119
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
120
120
|
availableOffers = searchEventTicketOffersResult.unitPriceOffers;
|
|
121
121
|
}
|
|
122
|
-
const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event
|
|
122
|
+
const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event })(repos);
|
|
123
123
|
// 仮予約作成
|
|
124
124
|
const { acceptedOffers4transactionObject, objectSubReservations } = yield createAcceptedOffers4transactionObject({
|
|
125
125
|
acceptedOffers,
|
|
@@ -171,14 +171,77 @@ function addReservations(params) {
|
|
|
171
171
|
return transaction;
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* イベントに対する座席オファーを座席コードとセクションコード指定で検索する
|
|
176
|
+
*/
|
|
177
|
+
function searchEventSeatOffers(params) {
|
|
178
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
var _a, _b, _c, _d, _e, _f;
|
|
180
|
+
let offers = [];
|
|
181
|
+
// 座席指定利用可能かどうか
|
|
182
|
+
const eventOffers = params.event.offers;
|
|
183
|
+
const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
|
|
184
|
+
if (reservedSeatsAvailable) {
|
|
185
|
+
// 座席タイプ価格仕様を検索
|
|
186
|
+
const priceSpecs = yield repos.priceSpecification.search({
|
|
187
|
+
project: { id: { $eq: params.event.project.id } },
|
|
188
|
+
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
189
|
+
appliesToCategoryCode: {
|
|
190
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
const roomBranchCode = String((_d = (_c = eventOffers.itemOffered) === null || _c === void 0 ? void 0 : _c.availableChannel) === null || _d === void 0 ? void 0 : _d.serviceLocation.branchCode);
|
|
194
|
+
const movieTheaterBranchCode = String((_f = (_e = eventOffers.itemOffered) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.serviceLocation.containedInPlace.branchCode);
|
|
195
|
+
const seats = yield repos.place.searchSeats({
|
|
196
|
+
project: { id: { $eq: params.event.project.id } },
|
|
197
|
+
branchCode: { $in: params.branchCode.$in },
|
|
198
|
+
containedInPlace: {
|
|
199
|
+
branchCode: {
|
|
200
|
+
$in: params.containedInPlace.branchCode.$in
|
|
201
|
+
},
|
|
202
|
+
containedInPlace: {
|
|
203
|
+
branchCode: { $eq: roomBranchCode },
|
|
204
|
+
containedInPlace: {
|
|
205
|
+
branchCode: { $eq: movieTheaterBranchCode }
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
$projection: params.$projection
|
|
210
|
+
});
|
|
211
|
+
if (seats.length > 0) {
|
|
212
|
+
const availabilities = yield repos.eventAvailability.searchAvailability({
|
|
213
|
+
eventId: params.event.id,
|
|
214
|
+
startDate: moment(params.event.startDate)
|
|
215
|
+
.toDate(),
|
|
216
|
+
offers: seats.map((s) => {
|
|
217
|
+
var _a;
|
|
218
|
+
return {
|
|
219
|
+
seatNumber: s.branchCode,
|
|
220
|
+
seatSection: (_a = s.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode
|
|
221
|
+
};
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
offers = seats.map((seat, index) => {
|
|
225
|
+
return OfferService.addOffers2Seat({
|
|
226
|
+
seat,
|
|
227
|
+
// unavailableOffers: [],
|
|
228
|
+
availability: availabilities[index].availability,
|
|
229
|
+
priceSpecs
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return offers;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
174
237
|
function searchAvailableSeatOffers(params) {
|
|
175
238
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
176
239
|
// 座席オファー検索(必要な分だけ)
|
|
177
240
|
const { acceptedSeatNumbers, acceptedSeatSections } = getAcceptedSeatNumbersAndSeatSections({ acceptedOffers: params.acceptedOffers });
|
|
178
|
-
return
|
|
241
|
+
return searchEventSeatOffers({
|
|
179
242
|
branchCode: { $in: acceptedSeatNumbers },
|
|
180
243
|
containedInPlace: { branchCode: { $in: acceptedSeatSections } },
|
|
181
|
-
event:
|
|
244
|
+
event: params.event,
|
|
182
245
|
// 試しに冗長な情報を非取得にしてみる
|
|
183
246
|
$projection: {
|
|
184
247
|
'containedInPlace.containedInPlace': 0
|
|
@@ -11,35 +11,22 @@ import * as MoneyTransferOfferService from './offer/moneyTransfer';
|
|
|
11
11
|
import * as ProductOfferService from './offer/product';
|
|
12
12
|
export { EventOfferService as event, EventServiceByCOAOfferService as eventServiceByCOA, MoneyTransferOfferService as moneyTransfer, ProductOfferService as product };
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* 座席にオファー情報を付加する
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
event: {
|
|
26
|
-
id: string;
|
|
27
|
-
};
|
|
28
|
-
$projection?: {
|
|
29
|
-
[key: string]: number;
|
|
30
|
-
};
|
|
31
|
-
}): (repos: {
|
|
32
|
-
event: EventRepo;
|
|
33
|
-
priceSpecification: PriceSpecificationRepo;
|
|
34
|
-
eventAvailability: EventAvailabilityRepo;
|
|
35
|
-
place: PlaceRepo;
|
|
36
|
-
}) => Promise<factory.place.seat.IPlaceWithOffer[]>;
|
|
16
|
+
export declare function addOffers2Seat(params: {
|
|
17
|
+
seat: factory.place.seat.IPlace;
|
|
18
|
+
availability: factory.itemAvailability;
|
|
19
|
+
/**
|
|
20
|
+
* 座席区分加算料金
|
|
21
|
+
*/
|
|
22
|
+
priceSpecs: factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.CategoryCodeChargeSpecification>[];
|
|
23
|
+
}): factory.place.seat.IPlaceWithOffer;
|
|
37
24
|
/**
|
|
38
25
|
* イベントに対する座席オファーを検索する
|
|
39
26
|
*/
|
|
40
27
|
export declare function searchEventSeatOffersWithPaging(params: {
|
|
41
|
-
limit
|
|
42
|
-
page
|
|
28
|
+
limit: number;
|
|
29
|
+
page: number;
|
|
43
30
|
branchCode?: {
|
|
44
31
|
$eq?: string;
|
|
45
32
|
};
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createAggregateScreeningEventIfNotExist = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.
|
|
12
|
+
exports.createAggregateScreeningEventIfNotExist = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const EventOfferService = require("./offer/event");
|
|
@@ -24,121 +24,33 @@ exports.product = ProductOfferService;
|
|
|
24
24
|
* 座席にオファー情報を付加する
|
|
25
25
|
*/
|
|
26
26
|
function addOffers2Seat(params) {
|
|
27
|
-
const seatNumber = params.seat.branchCode;
|
|
28
|
-
const unavailableOffer = params.unavailableOffers.find((o) => o.seatSection === params.seatSection && o.seatNumber === seatNumber);
|
|
29
|
-
const priceComponent = [];
|
|
30
27
|
// 座席タイプが指定されていれば、適用される価格仕様を構成要素に追加
|
|
31
28
|
const seatingTypes = (Array.isArray(params.seat.seatingType))
|
|
32
29
|
? params.seat.seatingType
|
|
33
|
-
: (typeof params.seat.seatingType === 'string' && params.seat.seatingType.length > 0) ? [params.seat.seatingType]
|
|
34
|
-
|
|
35
|
-
priceComponent.push(...params.priceSpecs.filter((s) => {
|
|
30
|
+
: (typeof params.seat.seatingType === 'string' && params.seat.seatingType.length > 0) ? [params.seat.seatingType] : [];
|
|
31
|
+
const priceComponent = params.priceSpecs.filter((s) => {
|
|
36
32
|
// 適用カテゴリーコードに座席タイプが含まれる価格仕様を検索
|
|
37
33
|
return (Array.isArray(s.appliesToCategoryCode))
|
|
38
34
|
&& s.appliesToCategoryCode.some((categoryCode) => {
|
|
39
|
-
return seatingTypes.includes(categoryCode.codeValue)
|
|
40
|
-
|
|
41
|
-
&& categoryCode.inCodeSet.identifier === factory.categoryCode.CategorySetIdentifier.SeatingType;
|
|
35
|
+
return seatingTypes.includes(categoryCode.codeValue);
|
|
36
|
+
// && categoryCode.inCodeSet.identifier === factory.categoryCode.CategorySetIdentifier.SeatingType;
|
|
42
37
|
});
|
|
43
|
-
})
|
|
44
|
-
// 最適化(2022-11-15~)
|
|
38
|
+
});
|
|
45
39
|
const priceSpecification = {
|
|
46
40
|
typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
|
|
47
|
-
|
|
48
|
-
// valueAddedTaxIncluded: true,
|
|
49
|
-
priceComponent: priceComponent
|
|
41
|
+
priceComponent
|
|
50
42
|
};
|
|
51
|
-
let availability =
|
|
52
|
-
|
|
53
|
-
: factory.itemAvailability.InStock;
|
|
54
|
-
if (params.availability !== undefined) {
|
|
43
|
+
let availability = factory.itemAvailability.InStock;
|
|
44
|
+
if (typeof params.availability === 'string') {
|
|
55
45
|
availability = params.availability;
|
|
56
46
|
}
|
|
57
47
|
return Object.assign(Object.assign({}, params.seat), { offers: [{
|
|
58
|
-
// 最適化(2022-11-15~)
|
|
59
|
-
// project: params.project,
|
|
60
48
|
typeOf: factory.offerType.Offer,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
priceSpecification: priceSpecification
|
|
49
|
+
availability,
|
|
50
|
+
priceSpecification
|
|
64
51
|
}] });
|
|
65
52
|
}
|
|
66
|
-
|
|
67
|
-
* イベントに対する座席オファーを座席コードとセクションコード指定で検索する
|
|
68
|
-
*/
|
|
69
|
-
function searchEventSeatOffers(params) {
|
|
70
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
72
|
-
let offers = [];
|
|
73
|
-
// イベント取得属性最適化(2023-01-23~)
|
|
74
|
-
// const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({
|
|
75
|
-
// id: params.event.id
|
|
76
|
-
// });
|
|
77
|
-
const event = yield repos.event.findMinimizedIndividualEventById({
|
|
78
|
-
id: params.event.id
|
|
79
|
-
});
|
|
80
|
-
// 座席指定利用可能かどうか
|
|
81
|
-
const eventOffers = event.offers;
|
|
82
|
-
const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
|
|
83
|
-
if (reservedSeatsAvailable) {
|
|
84
|
-
// 座席タイプ価格仕様を検索
|
|
85
|
-
const priceSpecs = yield repos.priceSpecification.search({
|
|
86
|
-
project: { id: { $eq: event.project.id } },
|
|
87
|
-
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
88
|
-
appliesToCategoryCode: {
|
|
89
|
-
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
// const roomBranchCode = event.location.branchCode;
|
|
93
|
-
// const movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
94
|
-
const roomBranchCode = String((_d = (_c = eventOffers.itemOffered) === null || _c === void 0 ? void 0 : _c.availableChannel) === null || _d === void 0 ? void 0 : _d.serviceLocation.branchCode);
|
|
95
|
-
const movieTheaterBranchCode = String((_f = (_e = eventOffers.itemOffered) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.serviceLocation.containedInPlace.branchCode);
|
|
96
|
-
const seats = yield repos.place.searchSeats({
|
|
97
|
-
project: { id: { $eq: event.project.id } },
|
|
98
|
-
branchCode: { $in: (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in },
|
|
99
|
-
containedInPlace: {
|
|
100
|
-
branchCode: {
|
|
101
|
-
$in: (_j = (_h = params.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$in
|
|
102
|
-
},
|
|
103
|
-
containedInPlace: {
|
|
104
|
-
branchCode: { $eq: roomBranchCode },
|
|
105
|
-
containedInPlace: {
|
|
106
|
-
branchCode: { $eq: movieTheaterBranchCode }
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
$projection: params.$projection
|
|
111
|
-
});
|
|
112
|
-
if (seats.length > 0) {
|
|
113
|
-
const availabilities = yield repos.eventAvailability.searchAvailability({
|
|
114
|
-
eventId: params.event.id,
|
|
115
|
-
startDate: moment(event.startDate)
|
|
116
|
-
.toDate(),
|
|
117
|
-
offers: seats.map((s) => {
|
|
118
|
-
var _a;
|
|
119
|
-
return {
|
|
120
|
-
seatNumber: s.branchCode,
|
|
121
|
-
seatSection: (_a = s.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode
|
|
122
|
-
};
|
|
123
|
-
})
|
|
124
|
-
});
|
|
125
|
-
offers = seats.map((seat, index) => {
|
|
126
|
-
var _a;
|
|
127
|
-
return addOffers2Seat({
|
|
128
|
-
project: event.project,
|
|
129
|
-
seat: seat,
|
|
130
|
-
seatSection: (_a = seat.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode,
|
|
131
|
-
unavailableOffers: [],
|
|
132
|
-
availability: availabilities[index].availability,
|
|
133
|
-
priceSpecs: priceSpecs
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return offers;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
exports.searchEventSeatOffers = searchEventSeatOffers;
|
|
53
|
+
exports.addOffers2Seat = addOffers2Seat;
|
|
142
54
|
/**
|
|
143
55
|
* イベントに対する座席オファーを検索する
|
|
144
56
|
*/
|
|
@@ -147,12 +59,7 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
147
59
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
148
60
|
let offers = [];
|
|
149
61
|
// イベント取得属性最適化(2023-01-23~)
|
|
150
|
-
|
|
151
|
-
// id: params.event.id
|
|
152
|
-
// });
|
|
153
|
-
const event = yield repos.event.findMinimizedIndividualEventById({
|
|
154
|
-
id: params.event.id
|
|
155
|
-
});
|
|
62
|
+
const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
|
|
156
63
|
// 座席指定利用可能かどうか
|
|
157
64
|
const eventOffers = event.offers;
|
|
158
65
|
const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
|
|
@@ -165,8 +72,6 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
165
72
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
166
73
|
}
|
|
167
74
|
});
|
|
168
|
-
// const roomBranchCode = event.location.branchCode;
|
|
169
|
-
// const movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
170
75
|
const roomBranchCode = String((_d = (_c = eventOffers.itemOffered) === null || _c === void 0 ? void 0 : _c.availableChannel) === null || _d === void 0 ? void 0 : _d.serviceLocation.branchCode);
|
|
171
76
|
const movieTheaterBranchCode = String((_f = (_e = eventOffers.itemOffered) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.serviceLocation.containedInPlace.branchCode);
|
|
172
77
|
const seats = yield repos.place.searchSeats(Object.assign(Object.assign({}, params), { project: { id: { $eq: event.project.id } }, containedInPlace: {
|
|
@@ -196,14 +101,11 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
196
101
|
})
|
|
197
102
|
});
|
|
198
103
|
offers = seats.map((seat, index) => {
|
|
199
|
-
var _a;
|
|
200
104
|
return addOffers2Seat({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
seatSection: (_a = seat.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode,
|
|
204
|
-
unavailableOffers: [],
|
|
105
|
+
seat,
|
|
106
|
+
// unavailableOffers: [],
|
|
205
107
|
availability: availabilities[index].availability,
|
|
206
|
-
priceSpecs
|
|
108
|
+
priceSpecs
|
|
207
109
|
});
|
|
208
110
|
});
|
|
209
111
|
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
|
30
30
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
31
31
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
32
32
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
33
|
+
export declare const USE_NEW_ORDER_NUMBER_KEY_FROM: moment.Moment;
|
|
33
34
|
/**
|
|
34
35
|
* グローバル設定
|
|
35
36
|
*/
|
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.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
3
|
+
exports.settings = exports.USE_NEW_ORDER_NUMBER_KEY_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -49,6 +49,9 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
49
49
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
50
50
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
51
51
|
: moment('2023-07-23T15:00:00Z');
|
|
52
|
+
exports.USE_NEW_ORDER_NUMBER_KEY_FROM = (typeof process.env.USE_NEW_ORDER_NUMBER_KEY_FROM === 'string')
|
|
53
|
+
? moment(process.env.USE_NEW_ORDER_NUMBER_KEY_FROM)
|
|
54
|
+
: moment('2023-04-30T15:00:00Z');
|
|
52
55
|
/**
|
|
53
56
|
* グローバル設定
|
|
54
57
|
*/
|
package/package.json
CHANGED