@chevre/domain 21.9.0-alpha.0 → 21.9.0-alpha.10
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/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +19 -1
- package/example/src/chevre/searchEventTicketOffers.ts +1 -0
- package/example/src/chevre/{searchOfferCatalogs.ts → searchOfferCatalogItems.ts} +15 -5
- package/example/src/chevre/searchOffersByCatalog.ts +9 -2
- package/lib/chevre/repo/aggregateOffer.d.ts +10 -3
- package/lib/chevre/repo/aggregateOffer.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +92 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +55 -0
- package/lib/chevre/repo/offer.d.ts +8 -12
- package/lib/chevre/repo/offer.js +96 -56
- package/lib/chevre/repo/offerCatalog.d.ts +0 -4
- package/lib/chevre/repo/offerCatalog.js +0 -8
- package/lib/chevre/repo/offerCatalogItem.d.ts +47 -0
- package/lib/chevre/repo/offerCatalogItem.js +231 -0
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/findEventOffers.js +3 -1
- package/lib/chevre/service/assetTransaction/reserve.js +1 -0
- package/lib/chevre/service/offer/event/authorize.js +1 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +30 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +64 -3
- package/lib/chevre/service/offer/event.d.ts +2 -2
- package/lib/chevre/service/offer/event.js +2 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +5 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +23 -7
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +3 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +39 -24
- package/lib/chevre/service/task/onResourceUpdated.js +4 -1
- package/package.json +3 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & {
|
|
4
|
+
numberOfItems?: number;
|
|
5
|
+
itemListElementTypeOf: factory.offerType.Offer;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* オファーカタログアイテムリポジトリ
|
|
9
|
+
*/
|
|
10
|
+
export declare class MongoRepository {
|
|
11
|
+
private readonly offerCatalogItemModel;
|
|
12
|
+
constructor(connection: Connection);
|
|
13
|
+
static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
|
|
14
|
+
save(params: factory.offerCatalog.IOfferCatalog): Promise<factory.offerCatalog.IOfferCatalog>;
|
|
15
|
+
/**
|
|
16
|
+
* 同期日時を更新する
|
|
17
|
+
*/
|
|
18
|
+
updateDateSynced(params: {
|
|
19
|
+
id: string;
|
|
20
|
+
dateSynced: Date;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
23
|
+
search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
|
|
24
|
+
findItemListElementById(params: {
|
|
25
|
+
id: string;
|
|
26
|
+
project: {
|
|
27
|
+
id: string;
|
|
28
|
+
};
|
|
29
|
+
}): Promise<Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>;
|
|
30
|
+
deleteById(params: {
|
|
31
|
+
id: string;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
pullItemListElement(params: {
|
|
34
|
+
project: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
$pull: {
|
|
38
|
+
itemListElement: {
|
|
39
|
+
$elemMatch: {
|
|
40
|
+
id: {
|
|
41
|
+
$in: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}): Promise<import("mongodb").UpdateResult | undefined>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const mongoose_1 = require("mongoose");
|
|
25
|
+
const factory = require("../factory");
|
|
26
|
+
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
27
|
+
/**
|
|
28
|
+
* オファーカタログアイテムリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class MongoRepository {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, offerCatalogItem_1.schema);
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
+
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;
|
|
37
|
+
// MongoDB検索条件
|
|
38
|
+
const andConditions = [];
|
|
39
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
|
+
if (typeof projectIdEq === 'string') {
|
|
41
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
42
|
+
}
|
|
43
|
+
const idIn = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$in;
|
|
44
|
+
if (Array.isArray(idIn)) {
|
|
45
|
+
andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
|
|
46
|
+
}
|
|
47
|
+
// const idRegex = params.id?.$regex;
|
|
48
|
+
// if (typeof idRegex === 'string' && idRegex.length > 0) {
|
|
49
|
+
// andConditions.push({ _id: { $regex: new RegExp(idRegex) } });
|
|
50
|
+
// }
|
|
51
|
+
const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
52
|
+
if (typeof identifierEq === 'string') {
|
|
53
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
54
|
+
}
|
|
55
|
+
const identifierRegex = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
56
|
+
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
57
|
+
andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
|
|
58
|
+
}
|
|
59
|
+
if (params.name !== undefined) {
|
|
60
|
+
andConditions.push({
|
|
61
|
+
$or: [
|
|
62
|
+
{ 'name.ja': new RegExp(params.name) },
|
|
63
|
+
{ 'name.en': new RegExp(params.name) }
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const itemListElementTypeOfEq = (_g = (_f = params.itemListElement) === null || _f === void 0 ? void 0 : _f.typeOf) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
68
|
+
if (typeof itemListElementTypeOfEq === 'string') {
|
|
69
|
+
andConditions.push({ 'itemListElement.typeOf': { $exists: true, $eq: itemListElementTypeOfEq } });
|
|
70
|
+
}
|
|
71
|
+
const itemListElementIdIn = (_j = (_h = params.itemListElement) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
|
|
72
|
+
if (Array.isArray(itemListElementIdIn)) {
|
|
73
|
+
andConditions.push({ 'itemListElement.id': { $exists: true, $in: itemListElementIdIn } });
|
|
74
|
+
}
|
|
75
|
+
const itemListElementIdNin = (_l = (_k = params.itemListElement) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$nin;
|
|
76
|
+
if (Array.isArray(itemListElementIdNin)) {
|
|
77
|
+
andConditions.push({ 'itemListElement.id': { $nin: itemListElementIdNin } });
|
|
78
|
+
}
|
|
79
|
+
const itemListElementIdAll = (_o = (_m = params.itemListElement) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$all;
|
|
80
|
+
if (Array.isArray(itemListElementIdAll)) {
|
|
81
|
+
andConditions.push({ 'itemListElement.id': { $exists: true, $all: itemListElementIdAll } });
|
|
82
|
+
}
|
|
83
|
+
const itemOfferedTypeOfEq = (_q = (_p = params.itemOffered) === null || _p === void 0 ? void 0 : _p.typeOf) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
84
|
+
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
85
|
+
andConditions.push({ 'itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq } });
|
|
86
|
+
}
|
|
87
|
+
const itemOfferedServiceTypeCodeValueEq = (_t = (_s = (_r = params.itemOffered) === null || _r === void 0 ? void 0 : _r.serviceType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
88
|
+
if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
89
|
+
andConditions.push({ 'itemOffered.serviceType.codeValue': { $exists: true, $eq: itemOfferedServiceTypeCodeValueEq } });
|
|
90
|
+
}
|
|
91
|
+
const additionalPropertyElemMatch = (_u = params.additionalProperty) === null || _u === void 0 ? void 0 : _u.$elemMatch;
|
|
92
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
93
|
+
andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
|
|
94
|
+
}
|
|
95
|
+
const appliesToMovieTicketServiceOutputTypeOfIn = (_z = (_y = (_x = (_w = (_v = params.relatedOffer) === null || _v === void 0 ? void 0 : _v.priceSpecification) === null || _w === void 0 ? void 0 : _w.appliesToMovieTicket) === null || _x === void 0 ? void 0 : _x.serviceOutput) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
|
|
96
|
+
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfIn)) {
|
|
97
|
+
andConditions.push({
|
|
98
|
+
'relatedOffer.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
99
|
+
$exists: true,
|
|
100
|
+
$in: appliesToMovieTicketServiceOutputTypeOfIn
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return andConditions;
|
|
105
|
+
}
|
|
106
|
+
save(params) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
let doc;
|
|
109
|
+
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
110
|
+
const { id } = params, creatingDoc = __rest(params, ["id"]);
|
|
111
|
+
doc = yield this.offerCatalogItemModel.create(creatingDoc);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
|
|
115
|
+
doc = yield this.offerCatalogItemModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true })
|
|
116
|
+
.exec();
|
|
117
|
+
}
|
|
118
|
+
if (doc === null) {
|
|
119
|
+
throw new factory.errors.NotFound(this.offerCatalogItemModel.modelName);
|
|
120
|
+
}
|
|
121
|
+
return doc.toObject();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 同期日時を更新する
|
|
126
|
+
*/
|
|
127
|
+
updateDateSynced(params) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
yield this.offerCatalogItemModel.updateOne({ _id: { $eq: params.id } }, { $set: { dateSynced: params.dateSynced } })
|
|
130
|
+
.exec();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
count(params) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
136
|
+
const matchStages = conditions.map((condition) => {
|
|
137
|
+
return { $match: condition };
|
|
138
|
+
});
|
|
139
|
+
const result = yield this.offerCatalogItemModel.aggregate([
|
|
140
|
+
...matchStages,
|
|
141
|
+
{
|
|
142
|
+
$count: 'numItems'
|
|
143
|
+
}
|
|
144
|
+
])
|
|
145
|
+
.exec();
|
|
146
|
+
return (result.length > 0) ? result[0].numItems : 0;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
search(params) {
|
|
150
|
+
var _a;
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
153
|
+
const matchStages = conditions.map((condition) => {
|
|
154
|
+
return { $match: condition };
|
|
155
|
+
});
|
|
156
|
+
const aggregate = this.offerCatalogItemModel.aggregate([
|
|
157
|
+
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
|
|
158
|
+
...matchStages,
|
|
159
|
+
{
|
|
160
|
+
$project: {
|
|
161
|
+
_id: 0,
|
|
162
|
+
name: '$name',
|
|
163
|
+
description: '$description',
|
|
164
|
+
project: '$project',
|
|
165
|
+
typeOf: '$typeOf',
|
|
166
|
+
id: { $toString: '$_id' },
|
|
167
|
+
identifier: '$identifier',
|
|
168
|
+
itemOffered: '$itemOffered',
|
|
169
|
+
additionalProperty: '$additionalProperty',
|
|
170
|
+
relatedOffer: '$relatedOffer',
|
|
171
|
+
numberOfItems: {
|
|
172
|
+
$cond: {
|
|
173
|
+
if: { $isArray: '$itemListElement' },
|
|
174
|
+
then: { $size: '$itemListElement' },
|
|
175
|
+
else: 0
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
itemListElementTypeOf: { $first: '$itemListElement.typeOf' }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]);
|
|
182
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
183
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
184
|
+
aggregate.limit(params.limit * page)
|
|
185
|
+
.skip(params.limit * (page - 1));
|
|
186
|
+
}
|
|
187
|
+
return aggregate.exec();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
findItemListElementById(params) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const doc = yield this.offerCatalogItemModel.findOne({
|
|
193
|
+
'project.id': { $eq: params.project.id },
|
|
194
|
+
_id: { $eq: params.id }
|
|
195
|
+
}, { 'itemListElement.id': 1 })
|
|
196
|
+
.exec();
|
|
197
|
+
if (doc === null) {
|
|
198
|
+
throw new factory.errors.NotFound(this.offerCatalogItemModel.modelName);
|
|
199
|
+
}
|
|
200
|
+
return doc.toObject();
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
deleteById(params) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
yield this.offerCatalogItemModel.findOneAndRemove({ _id: params.id })
|
|
206
|
+
.exec();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
pullItemListElement(params) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
if (params.$pull.itemListElement.$elemMatch.id.$in.length === 0) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return this.offerCatalogItemModel.updateMany({
|
|
215
|
+
'project.id': { $eq: params.project.id },
|
|
216
|
+
'itemListElement.id': {
|
|
217
|
+
$exists: true,
|
|
218
|
+
$in: params.$pull.itemListElement.$elemMatch.id.$in
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
$pull: {
|
|
222
|
+
itemListElement: {
|
|
223
|
+
id: { $in: params.$pull.itemListElement.$elemMatch.id.$in }
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
.exec();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -21,6 +21,7 @@ import { MongoRepository as MemberRepo } from './repo/member';
|
|
|
21
21
|
import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
22
22
|
import { MongoRepository as OfferRepo } from './repo/offer';
|
|
23
23
|
import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
|
|
24
|
+
import { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalogItem';
|
|
24
25
|
import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
25
26
|
import { MongoRepository as OrderRepo } from './repo/order';
|
|
26
27
|
import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
@@ -131,6 +132,8 @@ export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
|
|
|
131
132
|
}
|
|
132
133
|
export declare class OfferCatalog extends OfferCatalogRepo {
|
|
133
134
|
}
|
|
135
|
+
export declare class OfferCatalogItem extends OfferCatalogItemRepo {
|
|
136
|
+
}
|
|
134
137
|
export declare class OfferItemCondition extends OfferItemConditionRepo {
|
|
135
138
|
}
|
|
136
139
|
export declare class Offer extends OfferRepo {
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
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.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = 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
|
* リポジトリ
|
|
@@ -25,6 +25,7 @@ const member_1 = require("./repo/member");
|
|
|
25
25
|
const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
|
|
26
26
|
const offer_1 = require("./repo/offer");
|
|
27
27
|
const offerCatalog_1 = require("./repo/offerCatalog");
|
|
28
|
+
const offerCatalogItem_1 = require("./repo/offerCatalogItem");
|
|
28
29
|
const offerItemCondition_1 = require("./repo/offerItemCondition");
|
|
29
30
|
const order_1 = require("./repo/order");
|
|
30
31
|
const ownershipInfo_1 = require("./repo/ownershipInfo");
|
|
@@ -157,6 +158,9 @@ exports.MerchantReturnPolicy = MerchantReturnPolicy;
|
|
|
157
158
|
class OfferCatalog extends offerCatalog_1.MongoRepository {
|
|
158
159
|
}
|
|
159
160
|
exports.OfferCatalog = OfferCatalog;
|
|
161
|
+
class OfferCatalogItem extends offerCatalogItem_1.MongoRepository {
|
|
162
|
+
}
|
|
163
|
+
exports.OfferCatalogItem = OfferCatalogItem;
|
|
160
164
|
class OfferItemCondition extends offerItemCondition_1.MongoRepository {
|
|
161
165
|
}
|
|
162
166
|
exports.OfferItemCondition = OfferItemCondition;
|
|
@@ -28,12 +28,14 @@ function findEventOffers(params) {
|
|
|
28
28
|
if (typeof offerCatalogId === 'string') {
|
|
29
29
|
// サブカタログIDを決定
|
|
30
30
|
let subOfferCatalogId = offerCatalogId;
|
|
31
|
+
let isOfferCatalogItem = false;
|
|
31
32
|
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: offerCatalogId });
|
|
32
33
|
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
33
34
|
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
35
|
+
isOfferCatalogItem = true;
|
|
34
36
|
}
|
|
35
37
|
const { offers } = yield repos.offer.searchAllByOfferCatalogId({
|
|
36
|
-
subOfferCatalog: { id: subOfferCatalogId }
|
|
38
|
+
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem }
|
|
37
39
|
});
|
|
38
40
|
availableOffers = offers;
|
|
39
41
|
}
|
|
@@ -118,6 +118,7 @@ function addReservations(params) {
|
|
|
118
118
|
event: { id: event.id },
|
|
119
119
|
// 対応アプリケーション条件追加(2023-01-27~)
|
|
120
120
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
121
|
+
priceSpecification: {},
|
|
121
122
|
onlyValid: true,
|
|
122
123
|
addSortIndex: false,
|
|
123
124
|
validateOfferRateLimit: true,
|
|
@@ -39,12 +39,7 @@ declare function searchEventTicketOffers(params: {
|
|
|
39
39
|
* 有効期間内のみかどうか
|
|
40
40
|
*/
|
|
41
41
|
onlyValid: boolean;
|
|
42
|
-
|
|
43
|
-
* どの決済方法に対して
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* COAムビチケ券種もほしい場合に指定
|
|
47
|
-
*/
|
|
42
|
+
priceSpecification: Pick<factory.unitPriceOffer.IPriceSpecificationSearchConditions, 'appliesToMovieTicket'>;
|
|
48
43
|
limit?: number;
|
|
49
44
|
page?: number;
|
|
50
45
|
addSortIndex: boolean;
|
|
@@ -54,4 +49,32 @@ declare function searchEventTicketOffers(params: {
|
|
|
54
49
|
ticketOffers: ITicketOfferWithSortIndex[];
|
|
55
50
|
unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
56
51
|
}>;
|
|
57
|
-
|
|
52
|
+
/**
|
|
53
|
+
* オファーで利用可能な適用決済カード条件を検索する
|
|
54
|
+
*/
|
|
55
|
+
declare function searchOfferAppliesToMovieTicket(params: {
|
|
56
|
+
event: {
|
|
57
|
+
/**
|
|
58
|
+
* イベントID
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* どのアプリケーションに対して
|
|
64
|
+
*/
|
|
65
|
+
store?: {
|
|
66
|
+
id?: string;
|
|
67
|
+
};
|
|
68
|
+
limit?: number;
|
|
69
|
+
page?: number;
|
|
70
|
+
/**
|
|
71
|
+
* 有効なオファーのみ対象とするか
|
|
72
|
+
*/
|
|
73
|
+
onlyValid?: boolean;
|
|
74
|
+
}): (repos: {
|
|
75
|
+
event: EventRepo;
|
|
76
|
+
offer: OfferRepo;
|
|
77
|
+
offerCatalog: OfferCatalogRepo;
|
|
78
|
+
product: ProductRepo;
|
|
79
|
+
}) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
|
|
80
|
+
export { searchEventTicketOffers, searchOfferAppliesToMovieTicket };
|
|
@@ -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.searchEventTicketOffers = void 0;
|
|
12
|
+
exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = void 0;
|
|
13
13
|
const moment = require("moment-timezone");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
15
|
const factory_1 = require("../factory");
|
|
@@ -28,9 +28,11 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
28
28
|
}
|
|
29
29
|
// サブカタログIDを決定
|
|
30
30
|
let subOfferCatalogId = catalogId;
|
|
31
|
+
let isOfferCatalogItem = false;
|
|
31
32
|
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
|
|
32
33
|
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
33
34
|
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
35
|
+
isOfferCatalogItem = true;
|
|
34
36
|
}
|
|
35
37
|
if (params.withSortIndex) {
|
|
36
38
|
// addSortIndexの場合はid指定廃止(2023-09-13~)
|
|
@@ -39,10 +41,11 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
39
41
|
}
|
|
40
42
|
const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
41
43
|
// ids: params.ids,
|
|
42
|
-
subOfferCatalog: { id: subOfferCatalogId },
|
|
44
|
+
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
43
45
|
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
44
46
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
45
47
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
48
|
+
priceSpecification: params.priceSpecification,
|
|
46
49
|
onlyValid: params.onlyValid === true,
|
|
47
50
|
useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
48
51
|
limit: params.limit,
|
|
@@ -57,7 +60,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
57
60
|
}
|
|
58
61
|
const { offers } = yield repos.offer.searchByIdsAndOfferCatalogId({
|
|
59
62
|
ids: params.ids,
|
|
60
|
-
subOfferCatalog: { id: subOfferCatalogId },
|
|
63
|
+
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
61
64
|
availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
|
|
62
65
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
63
66
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
@@ -113,6 +116,7 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
113
116
|
onlyValid: params.onlyValid,
|
|
114
117
|
unacceptedPaymentMethod,
|
|
115
118
|
excludeAppliesToMovieTicket,
|
|
119
|
+
priceSpecification: params.priceSpecification,
|
|
116
120
|
withSortIndex: params.addSortIndex,
|
|
117
121
|
useIncludeInDataCatalog: params.useIncludeInDataCatalog
|
|
118
122
|
})(repos);
|
|
@@ -274,6 +278,7 @@ function searchEventTicketOffers(params) {
|
|
|
274
278
|
ids: params.ids,
|
|
275
279
|
event,
|
|
276
280
|
store: params.store,
|
|
281
|
+
priceSpecification: params.priceSpecification,
|
|
277
282
|
limit: params.limit,
|
|
278
283
|
page: params.page,
|
|
279
284
|
addSortIndex: params.addSortIndex,
|
|
@@ -288,3 +293,59 @@ function searchEventTicketOffers(params) {
|
|
|
288
293
|
});
|
|
289
294
|
}
|
|
290
295
|
exports.searchEventTicketOffers = searchEventTicketOffers;
|
|
296
|
+
/**
|
|
297
|
+
* オファーで利用可能な適用決済カード条件を検索する
|
|
298
|
+
*/
|
|
299
|
+
function searchOfferAppliesToMovieTicket(params) {
|
|
300
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
var _a, _b, _c;
|
|
302
|
+
const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
|
|
303
|
+
// let soundFormatTypes: string[] = [];
|
|
304
|
+
let videoFormatTypes = [];
|
|
305
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
306
|
+
const superEvents = yield repos.event.search({
|
|
307
|
+
limit: 1,
|
|
308
|
+
page: 1,
|
|
309
|
+
id: { $eq: event.superEvent.id },
|
|
310
|
+
typeOf: factory.eventType.ScreeningEventSeries
|
|
311
|
+
}, { soundFormat: 1, videoFormat: 1 });
|
|
312
|
+
const superEvent = superEvents.shift();
|
|
313
|
+
if (superEvent === undefined) {
|
|
314
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
315
|
+
}
|
|
316
|
+
// soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
317
|
+
videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
318
|
+
}
|
|
319
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
|
|
320
|
+
// 上映方式がなければMovieTicket除外
|
|
321
|
+
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
322
|
+
// 興行設定があれば興行のカタログを参照する
|
|
323
|
+
const eventOffers = event.offers;
|
|
324
|
+
let catalogId;
|
|
325
|
+
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
326
|
+
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
|
|
327
|
+
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
328
|
+
catalogId = eventService.hasOfferCatalog.id;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (typeof catalogId !== 'string') {
|
|
332
|
+
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
333
|
+
}
|
|
334
|
+
// サブカタログIDを決定
|
|
335
|
+
let subOfferCatalogId = catalogId;
|
|
336
|
+
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
|
|
337
|
+
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
338
|
+
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
339
|
+
}
|
|
340
|
+
return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
|
|
341
|
+
subOfferCatalog: { id: subOfferCatalogId },
|
|
342
|
+
availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
|
|
343
|
+
unacceptedPaymentMethod: unacceptedPaymentMethod,
|
|
344
|
+
excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
|
|
345
|
+
onlyValid: params.onlyValid === true,
|
|
346
|
+
limit: params.limit,
|
|
347
|
+
page: params.page
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { authorize } from './event/authorize';
|
|
2
2
|
import { cancel } from './event/cancel';
|
|
3
3
|
import { importCategoryCodesFromCOA, importFromCOA } from './event/importFromCOA';
|
|
4
|
-
import { searchEventTicketOffers } from './event/searchEventTicketOffers';
|
|
4
|
+
import { searchEventTicketOffers, searchOfferAppliesToMovieTicket } from './event/searchEventTicketOffers';
|
|
5
5
|
import { voidTransaction } from './event/voidTransaction';
|
|
6
|
-
export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers };
|
|
6
|
+
export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
|
|
3
|
+
exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
|
|
4
4
|
const authorize_1 = require("./event/authorize");
|
|
5
5
|
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
|
|
6
6
|
const cancel_1 = require("./event/cancel");
|
|
@@ -10,5 +10,6 @@ Object.defineProperty(exports, "importCategoryCodesFromCOA", { enumerable: true,
|
|
|
10
10
|
Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importFromCOA; } });
|
|
11
11
|
const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
|
|
12
12
|
Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
|
|
13
|
+
Object.defineProperty(exports, "searchOfferAppliesToMovieTicket", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchOfferAppliesToMovieTicket; } });
|
|
13
14
|
const voidTransaction_1 = require("./event/voidTransaction");
|
|
14
15
|
Object.defineProperty(exports, "voidTransaction", { enumerable: true, get: function () { return voidTransaction_1.voidTransaction; } });
|
|
@@ -27,9 +27,11 @@ function searchProductOffers(params) {
|
|
|
27
27
|
}
|
|
28
28
|
// サブカタログIDを決定
|
|
29
29
|
let subOfferCatalogId = offerCatalogId;
|
|
30
|
+
let isOfferCatalogItem = false;
|
|
30
31
|
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: offerCatalogId });
|
|
31
32
|
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
32
33
|
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
34
|
+
isOfferCatalogItem = true;
|
|
33
35
|
}
|
|
34
36
|
let offers;
|
|
35
37
|
let sortedOfferIds;
|
|
@@ -40,8 +42,9 @@ function searchProductOffers(params) {
|
|
|
40
42
|
}
|
|
41
43
|
const searchByOfferCatalogIdResult = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
42
44
|
// ids: params.ids,
|
|
43
|
-
subOfferCatalog: { id: subOfferCatalogId },
|
|
45
|
+
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
44
46
|
excludeAppliesToMovieTicket: false,
|
|
47
|
+
priceSpecification: {},
|
|
45
48
|
limit: params.limit,
|
|
46
49
|
page: params.page,
|
|
47
50
|
onlyValid: params.onlyValid === true,
|
|
@@ -58,7 +61,7 @@ function searchProductOffers(params) {
|
|
|
58
61
|
}
|
|
59
62
|
const searchByOfferCatalogIdResult = yield repos.offer.searchByIdsAndOfferCatalogId({
|
|
60
63
|
ids: params.ids,
|
|
61
|
-
subOfferCatalog: { id: subOfferCatalogId },
|
|
64
|
+
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
62
65
|
excludeAppliesToMovieTicket: false,
|
|
63
66
|
limit: params.limit,
|
|
64
67
|
page: params.page,
|
|
@@ -8,6 +8,7 @@ import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
|
8
8
|
import { MongoRepository as MemberRepo } from '../../../repo/member';
|
|
9
9
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
10
10
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
11
|
+
import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
11
12
|
import { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
12
13
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
13
14
|
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
@@ -24,6 +25,7 @@ export declare function onResourceDeleted(params: factory.task.onResourceUpdated
|
|
|
24
25
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
25
26
|
offer: OfferRepo;
|
|
26
27
|
offerCatalog: OfferCatalogRepo;
|
|
28
|
+
offerCatalogItem: OfferCatalogItemRepo;
|
|
27
29
|
place: PlaceRepo;
|
|
28
30
|
product: ProductRepo;
|
|
29
31
|
productOffer: ProductOfferRepo;
|