@chevre/domain 21.2.0-alpha.1 → 21.2.0-alpha.3
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/processReserve.ts +2 -2
- package/example/src/chevre/searchEventSeats.ts +42 -0
- package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +4 -8
- package/lib/chevre/repo/{itemAvailability/screeningEvent.js → stockHolder.js} +52 -27
- package/lib/chevre/repository.d.ts +3 -5
- package/lib/chevre/repository.js +5 -8
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
- package/lib/chevre/service/assetTransaction/reserve.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/reserve.js +71 -5
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer.d.ts +13 -26
- package/lib/chevre/service/offer.js +21 -116
- package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
- package/lib/chevre/service/reserve/cancelReservation.js +6 -6
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +3 -3
- package/lib/chevre/service/task/cancelReservation.js +3 -3
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ async function main() {
|
|
|
22
22
|
id: String(process.env.EVENT_ID)
|
|
23
23
|
})({
|
|
24
24
|
event: new chevre.repository.Event(mongoose.connection),
|
|
25
|
-
|
|
25
|
+
stockHolder: new chevre.repository.StockHolder(client),
|
|
26
26
|
offer: new chevre.repository.Offer(mongoose.connection),
|
|
27
27
|
offerCatalog: new chevre.repository.OfferCatalog(mongoose.connection),
|
|
28
28
|
offerRateLimit: new chevre.repository.rateLimit.Offer(client),
|
|
@@ -30,7 +30,7 @@ async function main() {
|
|
|
30
30
|
const priceSpecRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
31
31
|
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
32
32
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
33
|
-
const itemAvailabilityRepo = new chevre.repository.
|
|
33
|
+
const itemAvailabilityRepo = new chevre.repository.StockHolder(client);
|
|
34
34
|
const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
|
|
35
35
|
|
|
36
36
|
const identifier = `CIN${(new Date()).valueOf()}`;
|
|
@@ -70,7 +70,7 @@ async function main() {
|
|
|
70
70
|
validateEventOfferPeriod: false,
|
|
71
71
|
validateAppliesToMovieTicket: true
|
|
72
72
|
})({
|
|
73
|
-
|
|
73
|
+
stockHolder: itemAvailabilityRepo,
|
|
74
74
|
event: eventRepo,
|
|
75
75
|
offer: offerRepo,
|
|
76
76
|
offerCatalog: offerCatalogRepo,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as redis from 'redis';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
11
|
+
socket: {
|
|
12
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
13
|
+
host: <string>process.env.REDIS_HOST
|
|
14
|
+
},
|
|
15
|
+
password: <string>process.env.REDIS_KEY
|
|
16
|
+
});
|
|
17
|
+
await client.connect();
|
|
18
|
+
|
|
19
|
+
const itemAvailabilityRepo = new chevre.repository.StockHolder(client);
|
|
20
|
+
|
|
21
|
+
const result = await itemAvailabilityRepo.searchHolders({
|
|
22
|
+
eventId: 'alckc9mlx',
|
|
23
|
+
startDate: new Date(),
|
|
24
|
+
offers: [
|
|
25
|
+
{
|
|
26
|
+
seatSection: 'Default',
|
|
27
|
+
seatNumber: 'B-10'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
seatSection: 'xxx',
|
|
31
|
+
seatNumber: 'xxx'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
console.log(result);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main()
|
|
39
|
+
.then(() => {
|
|
40
|
+
console.log('success!');
|
|
41
|
+
})
|
|
42
|
+
.catch(console.error);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RedisClientType } from 'redis';
|
|
2
|
-
import * as factory from '../../factory';
|
|
3
2
|
export interface IOffer {
|
|
4
3
|
itemOffered?: {
|
|
5
4
|
serviceOutput?: {
|
|
@@ -24,10 +23,11 @@ export interface IUnlockKey {
|
|
|
24
23
|
startDate: Date;
|
|
25
24
|
offer: IOffer;
|
|
26
25
|
}
|
|
26
|
+
export type IGetHolderResult = string | null;
|
|
27
27
|
/**
|
|
28
28
|
* イベントストックホルダーリポジトリ
|
|
29
29
|
*/
|
|
30
|
-
export declare class
|
|
30
|
+
export declare class StockHolderRepository {
|
|
31
31
|
static KEY_PREFIX_NEW: string;
|
|
32
32
|
static KEY_PREFIX: string;
|
|
33
33
|
private readonly redisClient;
|
|
@@ -70,13 +70,9 @@ export declare class RedisRepository {
|
|
|
70
70
|
* 在庫状況を検索する
|
|
71
71
|
* offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
searchHolders(params: {
|
|
74
74
|
eventId: string;
|
|
75
75
|
startDate: Date;
|
|
76
76
|
offers: IOffer[];
|
|
77
|
-
}): Promise<
|
|
78
|
-
seatSection: string;
|
|
79
|
-
seatNumber: string;
|
|
80
|
-
availability: factory.itemAvailability;
|
|
81
|
-
}[]>;
|
|
77
|
+
}): Promise<IGetHolderResult[]>;
|
|
82
78
|
}
|
|
@@ -9,16 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.StockHolderRepository = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment");
|
|
15
|
-
const factory = require("
|
|
16
|
-
const settings_1 = require("
|
|
15
|
+
const factory = require("../factory");
|
|
16
|
+
const settings_1 = require("../settings");
|
|
17
17
|
const debug = createDebug('chevre-domain:repo');
|
|
18
18
|
/**
|
|
19
19
|
* イベントストックホルダーリポジトリ
|
|
20
20
|
*/
|
|
21
|
-
class
|
|
21
|
+
class StockHolderRepository {
|
|
22
22
|
constructor(redisClient) {
|
|
23
23
|
this.redisClient = redisClient;
|
|
24
24
|
}
|
|
@@ -36,10 +36,10 @@ class RedisRepository {
|
|
|
36
36
|
&& moment(params.startDate)
|
|
37
37
|
.isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
|
|
38
38
|
if (useNewKey) {
|
|
39
|
-
return `${
|
|
39
|
+
return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
return `${
|
|
42
|
+
return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -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 =
|
|
50
|
+
const key = StockHolderRepository.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 =
|
|
67
|
+
const key = StockHolderRepository.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) =>
|
|
70
|
+
const fields = lockKey.offers.map((offer) => StockHolderRepository.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 =
|
|
107
|
-
const field =
|
|
106
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
107
|
+
const field = StockHolderRepository.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 =
|
|
118
|
+
const key = StockHolderRepository.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 =
|
|
137
|
+
const key = StockHolderRepository.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 =
|
|
152
|
-
const field =
|
|
151
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
152
|
+
const field = StockHolderRepository.offer2field(params.offer);
|
|
153
153
|
return this.redisClient.hGet(key, field);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
@@ -157,25 +157,50 @@ class RedisRepository {
|
|
|
157
157
|
* 在庫状況を検索する
|
|
158
158
|
* offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
|
|
159
159
|
*/
|
|
160
|
-
searchAvailability(params
|
|
160
|
+
// public async searchAvailability(params: {
|
|
161
|
+
// eventId: string;
|
|
162
|
+
// startDate: Date;
|
|
163
|
+
// offers: IOffer[];
|
|
164
|
+
// }): Promise<{
|
|
165
|
+
// seatSection: string;
|
|
166
|
+
// seatNumber: string;
|
|
167
|
+
// availability: factory.itemAvailability;
|
|
168
|
+
// }[]> {
|
|
169
|
+
// const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
170
|
+
// const fields = params.offers.map((o) => {
|
|
171
|
+
// return RedisRepository.offer2field(o);
|
|
172
|
+
// });
|
|
173
|
+
// // Array reply: list of values associated with the given fields, in the same order as they are requested.
|
|
174
|
+
// const result = await this.redisClient.hmGet(key, fields);
|
|
175
|
+
// if (!Array.isArray(result)) {
|
|
176
|
+
// throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
|
|
177
|
+
// }
|
|
178
|
+
// return params.offers.map((o, index) => {
|
|
179
|
+
// const value4offer = result[index];
|
|
180
|
+
// return {
|
|
181
|
+
// ...o,
|
|
182
|
+
// availability: (typeof value4offer === 'string')
|
|
183
|
+
// ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
184
|
+
// : factory.itemAvailability.InStock
|
|
185
|
+
// };
|
|
186
|
+
// });
|
|
187
|
+
// }
|
|
188
|
+
searchHolders(params) {
|
|
161
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const key =
|
|
190
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
163
191
|
const fields = params.offers.map((o) => {
|
|
164
|
-
return
|
|
192
|
+
return StockHolderRepository.offer2field(o);
|
|
165
193
|
});
|
|
194
|
+
// Array reply: list of values associated with the given fields, in the same order as they are requested.
|
|
166
195
|
const result = yield this.redisClient.hmGet(key, fields);
|
|
167
196
|
if (!Array.isArray(result)) {
|
|
168
197
|
throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
|
|
169
198
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return Object.assign(Object.assign({}, o), { availability: (typeof value4offer === 'string')
|
|
173
|
-
? factory.itemAvailability.OutOfStock
|
|
174
|
-
: factory.itemAvailability.InStock });
|
|
175
|
-
});
|
|
199
|
+
// そのまま返却(2023-04-17~)
|
|
200
|
+
return result;
|
|
176
201
|
});
|
|
177
202
|
}
|
|
178
203
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
exports.
|
|
204
|
+
StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
|
|
205
|
+
StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
|
|
206
|
+
exports.StockHolderRepository = StockHolderRepository;
|
|
@@ -16,7 +16,6 @@ import { MongoRepository as CreativeWorkRepo } from './repo/creativeWork';
|
|
|
16
16
|
import { MongoRepository as CustomerRepo } from './repo/customer';
|
|
17
17
|
import { MongoRepository as EmailMessageRepo } from './repo/emailMessage';
|
|
18
18
|
import { MongoRepository as EventRepo } from './repo/event';
|
|
19
|
-
import { RedisRepository as ScreeningEventItemAvailabilityRepo } from './repo/itemAvailability/screeningEvent';
|
|
20
19
|
import { MongoRepository as MemberRepo } from './repo/member';
|
|
21
20
|
import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
22
21
|
import { MongoRepository as OfferRepo } from './repo/offer';
|
|
@@ -34,6 +33,7 @@ import { MongoRepository as RoleRepo } from './repo/role';
|
|
|
34
33
|
import { MongoRepository as SellerRepo } from './repo/seller';
|
|
35
34
|
import { MongoRepository as ServiceOutputRepo } from './repo/serviceOutput';
|
|
36
35
|
import { RedisRepository as ServiceOutputIdentifierRepo } from './repo/serviceOutputIdentifier';
|
|
36
|
+
import { StockHolderRepository as StockHolderRepo } from './repo/stockHolder';
|
|
37
37
|
import { MongoRepository as TaskRepo } from './repo/task';
|
|
38
38
|
import { MongoRepository as TelemetryRepo } from './repo/telemetry';
|
|
39
39
|
import { MongoRepository as TransactionRepo } from './repo/transaction';
|
|
@@ -183,6 +183,8 @@ export declare class ServiceOutput extends ServiceOutputRepo {
|
|
|
183
183
|
}
|
|
184
184
|
export declare class ServiceOutputIdentifier extends ServiceOutputIdentifierRepo {
|
|
185
185
|
}
|
|
186
|
+
export declare class StockHolder extends StockHolderRepo {
|
|
187
|
+
}
|
|
186
188
|
export declare class Task extends TaskRepo {
|
|
187
189
|
}
|
|
188
190
|
export declare class Telemetry extends TelemetryRepo {
|
|
@@ -193,10 +195,6 @@ export declare class TransactionNumber extends TransactionNumberRepo {
|
|
|
193
195
|
}
|
|
194
196
|
export declare class Trip extends TripRepo {
|
|
195
197
|
}
|
|
196
|
-
export declare namespace itemAvailability {
|
|
197
|
-
class ScreeningEvent extends ScreeningEventItemAvailabilityRepo {
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
198
|
export declare namespace rateLimit {
|
|
201
199
|
class Offer extends OfferRateLimitRepo {
|
|
202
200
|
}
|
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.
|
|
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.OfferCatalog = exports.Offer = 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
|
* リポジトリ
|
|
@@ -20,7 +20,6 @@ const creativeWork_1 = require("./repo/creativeWork");
|
|
|
20
20
|
const customer_1 = require("./repo/customer");
|
|
21
21
|
const emailMessage_1 = require("./repo/emailMessage");
|
|
22
22
|
const event_1 = require("./repo/event");
|
|
23
|
-
const screeningEvent_1 = require("./repo/itemAvailability/screeningEvent");
|
|
24
23
|
const member_1 = require("./repo/member");
|
|
25
24
|
const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
|
|
26
25
|
const offer_1 = require("./repo/offer");
|
|
@@ -38,6 +37,7 @@ const role_1 = require("./repo/role");
|
|
|
38
37
|
const seller_1 = require("./repo/seller");
|
|
39
38
|
const serviceOutput_1 = require("./repo/serviceOutput");
|
|
40
39
|
const serviceOutputIdentifier_1 = require("./repo/serviceOutputIdentifier");
|
|
40
|
+
const stockHolder_1 = require("./repo/stockHolder");
|
|
41
41
|
const task_1 = require("./repo/task");
|
|
42
42
|
const telemetry_1 = require("./repo/telemetry");
|
|
43
43
|
const transaction_1 = require("./repo/transaction");
|
|
@@ -225,6 +225,9 @@ exports.ServiceOutput = ServiceOutput;
|
|
|
225
225
|
class ServiceOutputIdentifier extends serviceOutputIdentifier_1.RedisRepository {
|
|
226
226
|
}
|
|
227
227
|
exports.ServiceOutputIdentifier = ServiceOutputIdentifier;
|
|
228
|
+
class StockHolder extends stockHolder_1.StockHolderRepository {
|
|
229
|
+
}
|
|
230
|
+
exports.StockHolder = StockHolder;
|
|
228
231
|
class Task extends task_1.MongoRepository {
|
|
229
232
|
}
|
|
230
233
|
exports.Task = Task;
|
|
@@ -240,12 +243,6 @@ exports.TransactionNumber = TransactionNumber;
|
|
|
240
243
|
class Trip extends trip_1.MongoRepository {
|
|
241
244
|
}
|
|
242
245
|
exports.Trip = Trip;
|
|
243
|
-
var itemAvailability;
|
|
244
|
-
(function (itemAvailability) {
|
|
245
|
-
class ScreeningEvent extends screeningEvent_1.RedisRepository {
|
|
246
|
-
}
|
|
247
|
-
itemAvailability.ScreeningEvent = ScreeningEvent;
|
|
248
|
-
})(itemAvailability = exports.itemAvailability || (exports.itemAvailability = {}));
|
|
249
246
|
var rateLimit;
|
|
250
247
|
(function (rateLimit) {
|
|
251
248
|
// tslint:disable-next-line:no-shadowed-variable
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
|
-
import { RedisRepository as EventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
3
2
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
3
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
5
4
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
@@ -7,11 +6,12 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
|
7
6
|
import { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
8
7
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
9
8
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
9
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
10
10
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
11
11
|
import * as factory from '../../../factory';
|
|
12
12
|
export type IAggregateScreeningEventOperation<T> = (repos: {
|
|
13
13
|
event: EventRepo;
|
|
14
|
-
|
|
14
|
+
stockHolder: StockHolderRepo;
|
|
15
15
|
offer: OfferRepo;
|
|
16
16
|
offerCatalog: OfferCatalogRepo;
|
|
17
17
|
offerRateLimit: OfferRateLimitRepo;
|
|
@@ -387,13 +387,14 @@ function filterByEligibleSeatingType(params) {
|
|
|
387
387
|
const maximumAttendeeCapacity = eligibleSeatOffers.length;
|
|
388
388
|
let remainingAttendeeCapacity;
|
|
389
389
|
if (maximumAttendeeCapacity > 0) {
|
|
390
|
-
const availabilities = yield repos.
|
|
390
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
391
391
|
eventId: params.event.id,
|
|
392
392
|
startDate: moment(params.event.startDate)
|
|
393
393
|
.toDate(),
|
|
394
394
|
offers: eligibleSeatOffers
|
|
395
395
|
});
|
|
396
|
-
remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
396
|
+
// remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
397
|
+
remainingAttendeeCapacity = availabilities.filter((holder) => typeof holder !== 'string').length;
|
|
397
398
|
}
|
|
398
399
|
else {
|
|
399
400
|
remainingAttendeeCapacity = 0;
|
|
@@ -438,7 +439,7 @@ function aggregateReservationByEvent(params) {
|
|
|
438
439
|
// remainingAttendeeCapacityを決定
|
|
439
440
|
if (typeof maximumAttendeeCapacity === 'number') {
|
|
440
441
|
// 残席数を座席ロック数から計算
|
|
441
|
-
const unavailableOfferCount = yield repos.
|
|
442
|
+
const unavailableOfferCount = yield repos.stockHolder.countUnavailableOffers({
|
|
442
443
|
event: {
|
|
443
444
|
id: params.event.id,
|
|
444
445
|
startDate: moment(params.event.startDate)
|
|
@@ -2,7 +2,6 @@ import * as factory from '../../factory';
|
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
4
|
import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../repo/event';
|
|
5
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
|
|
6
5
|
import { MongoRepository as OfferRepo } from '../../repo/offer';
|
|
7
6
|
import { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
|
|
8
7
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
@@ -12,9 +11,10 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
12
11
|
import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
13
12
|
import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
|
|
14
13
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
14
|
+
import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
|
|
15
15
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
16
16
|
export interface IStartOperationRepos {
|
|
17
|
-
|
|
17
|
+
stockHolder: StockHolderRepo;
|
|
18
18
|
event: EventRepo;
|
|
19
19
|
offer: OfferRepo;
|
|
20
20
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -29,7 +29,7 @@ export interface IStartOperationRepos {
|
|
|
29
29
|
}
|
|
30
30
|
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
31
31
|
export interface IAddReservationsOperationRepos {
|
|
32
|
-
|
|
32
|
+
stockHolder: StockHolderRepo;
|
|
33
33
|
event: EventRepo;
|
|
34
34
|
offer: OfferRepo;
|
|
35
35
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -44,7 +44,7 @@ export interface IAddReservationsOperationRepos {
|
|
|
44
44
|
export type IAddReservationsOperation<T> = (repos: IAddReservationsOperationRepos) => Promise<T>;
|
|
45
45
|
export type ICancelOperation<T> = (repos: {
|
|
46
46
|
action: ActionRepo;
|
|
47
|
-
|
|
47
|
+
stockHolder: StockHolderRepo;
|
|
48
48
|
offerRateLimit: OfferRateLimitRepo;
|
|
49
49
|
reservation: ReservationRepo;
|
|
50
50
|
task: TaskRepo;
|
|
@@ -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,80 @@ 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.stockHolder.searchHolders({
|
|
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
|
+
availability: (typeof availabilities[index] === 'string')
|
|
230
|
+
? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
231
|
+
: factory.itemAvailability.InStock,
|
|
232
|
+
priceSpecs
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return offers;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
174
240
|
function searchAvailableSeatOffers(params) {
|
|
175
241
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
176
242
|
// 座席オファー検索(必要な分だけ)
|
|
177
243
|
const { acceptedSeatNumbers, acceptedSeatSections } = getAcceptedSeatNumbersAndSeatSections({ acceptedOffers: params.acceptedOffers });
|
|
178
|
-
return
|
|
244
|
+
return searchEventSeatOffers({
|
|
179
245
|
branchCode: { $in: acceptedSeatNumbers },
|
|
180
246
|
containedInPlace: { branchCode: { $in: acceptedSeatSections } },
|
|
181
|
-
event:
|
|
247
|
+
event: params.event,
|
|
182
248
|
// 試しに冗長な情報を非取得にしてみる
|
|
183
249
|
$projection: {
|
|
184
250
|
'containedInPlace.containedInPlace': 0
|
|
@@ -575,7 +641,7 @@ function processLockSeats(params) {
|
|
|
575
641
|
const holder = params.transaction.id;
|
|
576
642
|
const maximumAttendeeCapacity4event = (_a = params.event.location) === null || _a === void 0 ? void 0 : _a.maximumAttendeeCapacity;
|
|
577
643
|
if (typeof maximumAttendeeCapacity4event === 'number') {
|
|
578
|
-
yield repos.
|
|
644
|
+
yield repos.stockHolder.lockIfNotLimitExceeded({
|
|
579
645
|
eventId: params.event.id,
|
|
580
646
|
startDate: moment(params.event.startDate)
|
|
581
647
|
.toDate(),
|
|
@@ -585,7 +651,7 @@ function processLockSeats(params) {
|
|
|
585
651
|
}, maximumAttendeeCapacity4event);
|
|
586
652
|
}
|
|
587
653
|
else {
|
|
588
|
-
yield repos.
|
|
654
|
+
yield repos.stockHolder.lock({
|
|
589
655
|
eventId: params.event.id,
|
|
590
656
|
startDate: moment(params.event.startDate)
|
|
591
657
|
.toDate(),
|
|
@@ -2,7 +2,6 @@ import * as factory from '../../../factory';
|
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
4
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
5
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
6
5
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
7
6
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
8
7
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
@@ -11,6 +10,7 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
|
11
10
|
import { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
12
11
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
13
12
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
13
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
14
14
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
15
15
|
import { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
16
16
|
import { RedisRepository as TransactionNumberRepo } from '../../../repo/transactionNumber';
|
|
@@ -19,7 +19,7 @@ interface IAuthorizeRepos {
|
|
|
19
19
|
action: ActionRepo;
|
|
20
20
|
assetTransaction: AssetTransactionRepo;
|
|
21
21
|
event: EventRepo;
|
|
22
|
-
|
|
22
|
+
stockHolder: StockHolderRepo;
|
|
23
23
|
offer: OfferRepo;
|
|
24
24
|
offerCatalog: OfferCatalogRepo;
|
|
25
25
|
offerRateLimit: OfferRateLimitRepo;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
8
8
|
import { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
9
9
|
interface ICancelRepos {
|
|
10
10
|
action: ActionRepo;
|
|
11
11
|
assetTransaction: AssetTransactionRepo;
|
|
12
|
-
|
|
12
|
+
stockHolder: StockHolderRepo;
|
|
13
13
|
offerRateLimit: OfferRateLimitRepo;
|
|
14
14
|
reservation: ReservationRepo;
|
|
15
15
|
task: TaskRepo;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
8
8
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
9
9
|
interface IVoidTransactionRepos {
|
|
10
10
|
action: ActionRepo;
|
|
11
11
|
assetTransaction: AssetTransactionRepo;
|
|
12
|
-
|
|
12
|
+
stockHolder: StockHolderRepo;
|
|
13
13
|
offerRateLimit: OfferRateLimitRepo;
|
|
14
14
|
reservation: ReservationRepo;
|
|
15
15
|
task: TaskRepo;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../repo/event';
|
|
2
|
-
import { RedisRepository as EventAvailabilityRepo } from '../repo/itemAvailability/screeningEvent';
|
|
3
2
|
import { MongoRepository as PlaceRepo } from '../repo/place';
|
|
4
3
|
import { MongoRepository as PriceSpecificationRepo } from '../repo/priceSpecification';
|
|
5
4
|
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
5
|
+
import { StockHolderRepository as StockHolderRepo } from '../repo/stockHolder';
|
|
6
6
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
7
7
|
import * as factory from '../factory';
|
|
8
8
|
import * as EventOfferService from './offer/event';
|
|
@@ -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
|
};
|
|
@@ -57,7 +44,7 @@ export declare function searchEventSeatOffersWithPaging(params: {
|
|
|
57
44
|
}): (repos: {
|
|
58
45
|
event: EventRepo;
|
|
59
46
|
priceSpecification: PriceSpecificationRepo;
|
|
60
|
-
|
|
47
|
+
stockHolder: StockHolderRepo;
|
|
61
48
|
place: PlaceRepo;
|
|
62
49
|
}) => Promise<factory.place.seat.IPlaceWithOffer[]>;
|
|
63
50
|
interface IChangedEvent {
|
|
@@ -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: {
|
|
@@ -183,7 +88,7 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
183
88
|
}
|
|
184
89
|
} }));
|
|
185
90
|
if (seats.length > 0) {
|
|
186
|
-
const availabilities = yield repos.
|
|
91
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
187
92
|
eventId: params.event.id,
|
|
188
93
|
startDate: moment(event.startDate)
|
|
189
94
|
.toDate(),
|
|
@@ -196,14 +101,14 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
196
101
|
})
|
|
197
102
|
});
|
|
198
103
|
offers = seats.map((seat, index) => {
|
|
199
|
-
var _a;
|
|
200
104
|
return addOffers2Seat({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
105
|
+
seat,
|
|
106
|
+
// unavailableOffers: [],
|
|
107
|
+
// availability: availabilities[index].availability,
|
|
108
|
+
availability: (typeof availabilities[index] === 'string')
|
|
109
|
+
? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
110
|
+
: factory.itemAvailability.InStock,
|
|
111
|
+
priceSpecs
|
|
207
112
|
});
|
|
208
113
|
});
|
|
209
114
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
8
|
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservat
|
|
|
12
12
|
declare function cancelPendingReservation(actionAttributesList: factory.action.cancel.reservation.IAttributes[]): (repos: {
|
|
13
13
|
action: ActionRepo;
|
|
14
14
|
assetTransaction: AssetTransactionRepo;
|
|
15
|
-
|
|
15
|
+
stockHolder: StockHolderRepo;
|
|
16
16
|
offerRateLimit: OfferRateLimitRepo;
|
|
17
17
|
reservation: ReservationRepo;
|
|
18
18
|
task: TaskRepo;
|
|
@@ -22,7 +22,7 @@ declare function cancelPendingReservation(actionAttributesList: factory.action.c
|
|
|
22
22
|
*/
|
|
23
23
|
declare function cancelReservation(actionAttributesList: factory.action.cancel.reservation.IAttributes[]): (repos: {
|
|
24
24
|
action: ActionRepo;
|
|
25
|
-
|
|
25
|
+
stockHolder: StockHolderRepo;
|
|
26
26
|
offerRateLimit: OfferRateLimitRepo;
|
|
27
27
|
reservation: ReservationRepo;
|
|
28
28
|
task: TaskRepo;
|
|
@@ -344,9 +344,9 @@ function processUnlockSeat(params) {
|
|
|
344
344
|
seatSection: ''
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
|
-
let holder = yield repos.
|
|
347
|
+
let holder = yield repos.stockHolder.getHolder(lockKey);
|
|
348
348
|
if (holder === params.expectedHolder) {
|
|
349
|
-
yield repos.
|
|
349
|
+
yield repos.stockHolder.unlock(lockKey);
|
|
350
350
|
}
|
|
351
351
|
// 予約取引がまだ座席を保持していれば座席ロック解除
|
|
352
352
|
const ticketedSeat = reservation.reservedTicket.ticketedSeat;
|
|
@@ -359,9 +359,9 @@ function processUnlockSeat(params) {
|
|
|
359
359
|
seatSection: ticketedSeat.seatSection
|
|
360
360
|
}
|
|
361
361
|
};
|
|
362
|
-
holder = yield repos.
|
|
362
|
+
holder = yield repos.stockHolder.getHolder(lockKey);
|
|
363
363
|
if (holder === params.expectedHolder) {
|
|
364
|
-
yield repos.
|
|
364
|
+
yield repos.stockHolder.unlock(lockKey);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
// subReservationがあれば、そちらも解除(順不同)
|
|
@@ -380,9 +380,9 @@ function processUnlockSeat(params) {
|
|
|
380
380
|
seatSection: seatSection4sub
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
|
-
const holder4sub = yield repos.
|
|
383
|
+
const holder4sub = yield repos.stockHolder.getHolder(lockKey4sub);
|
|
384
384
|
if (holder4sub === params.expectedHolder) {
|
|
385
|
-
yield repos.
|
|
385
|
+
yield repos.stockHolder.unlock(lockKey4sub);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
})));
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const event_1 = require("../../repo/event");
|
|
15
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
16
15
|
const offer_1 = require("../../repo/offer");
|
|
17
16
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
18
17
|
const place_1 = require("../../repo/place");
|
|
@@ -20,6 +19,7 @@ const product_1 = require("../../repo/product");
|
|
|
20
19
|
const project_1 = require("../../repo/project");
|
|
21
20
|
const offer_2 = require("../../repo/rateLimit/offer");
|
|
22
21
|
const reservation_1 = require("../../repo/reservation");
|
|
22
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
23
23
|
const task_1 = require("../../repo/task");
|
|
24
24
|
const AggregationService = require("../aggregation");
|
|
25
25
|
/**
|
|
@@ -32,7 +32,7 @@ function call(data) {
|
|
|
32
32
|
}
|
|
33
33
|
yield AggregationService.event.aggregateScreeningEvent(data)({
|
|
34
34
|
event: new event_1.MongoRepository(settings.connection),
|
|
35
|
-
|
|
35
|
+
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient),
|
|
36
36
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
37
37
|
offerCatalog: new offerCatalog_1.MongoRepository(settings.connection),
|
|
38
38
|
offerRateLimit: new offer_2.RedisRepository(settings.redisClient),
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const ReserveService = require("../reserve");
|
|
21
21
|
/**
|
|
@@ -30,12 +30,12 @@ function call(data) {
|
|
|
30
30
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
33
|
-
const
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
yield ReserveService.cancelPendingReservation(data.actionAttributes)({
|
|
36
36
|
action: actionRepo,
|
|
37
37
|
assetTransaction: assetTransactionRepo,
|
|
38
|
-
|
|
38
|
+
stockHolder: stockHolderRepo,
|
|
39
39
|
offerRateLimit: offerRateLimitRepo,
|
|
40
40
|
reservation: reservationRepo,
|
|
41
41
|
task: taskRepo
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const ReserveService = require("../reserve");
|
|
21
21
|
/**
|
|
@@ -30,7 +30,7 @@ function call(data) {
|
|
|
30
30
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const transactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
33
|
-
const
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
yield ReserveService.cancelReservation(data.actionAttributes)({
|
|
36
36
|
action: actionRepo,
|
|
@@ -38,7 +38,7 @@ function call(data) {
|
|
|
38
38
|
task: taskRepo,
|
|
39
39
|
assetTransaction: transactionRepo,
|
|
40
40
|
offerRateLimit: offerRateLimitRepo,
|
|
41
|
-
|
|
41
|
+
stockHolder: stockHolderRepo
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
}
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const EventOfferService = require("../offer/event");
|
|
21
21
|
/**
|
|
@@ -28,14 +28,14 @@ function call(data) {
|
|
|
28
28
|
}
|
|
29
29
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
30
30
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
31
|
-
const
|
|
31
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
32
32
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
33
33
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
34
34
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
35
35
|
yield EventOfferService.voidTransaction(data)({
|
|
36
36
|
action: actionRepo,
|
|
37
37
|
assetTransaction: assetTransactionRepo,
|
|
38
|
-
|
|
38
|
+
stockHolder: stockHolderRepo,
|
|
39
39
|
offerRateLimit: offerRateLimitRepo,
|
|
40
40
|
reservation: reservationRepo,
|
|
41
41
|
task: taskRepo
|
package/package.json
CHANGED