@chevre/domain
Version:
Chevre Domain Library for Node.js
69 lines (68 loc) • 3.61 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.searchPriceSpecs4event = searchPriceSpecs4event;
const factory = require("../../../factory");
function searchPriceSpecs4event(params) {
return (repos) => __awaiter(this, void 0, void 0, function* () {
let soundFormatChargeSpecs = [];
let videoFormatChargeSpecs = [];
let movieTicketTypeChargeSpecs = [];
const movieTicketServiceTypes = [...new Set(params.availableOffers.reduce((a, b) => {
if (!Array.isArray(b.priceSpecification.appliesToMovieTicket)) {
return a;
}
return [
...a,
...b.priceSpecification.appliesToMovieTicket.map((movieTicket) => movieTicket.serviceType)
];
}, []))];
if (params.soundFormatTypes.length > 0) {
soundFormatChargeSpecs =
yield repos.priceSpecification.search({
project: { id: { $eq: params.project.id } },
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
appliesToCategoryCode: {
$elemMatch: {
codeValue: { $in: params.soundFormatTypes },
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.SoundFormatType }
}
}
});
}
if ((params.videoFormatTypes.length > 0)) {
videoFormatChargeSpecs =
yield repos.priceSpecification.search({
project: { id: { $eq: params.project.id } },
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
appliesToCategoryCode: {
$elemMatch: {
codeValue: { $in: params.videoFormatTypes },
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType }
}
}
});
// 存在する適用決済カード区分の分だけ検索する(2023-03-03~)
if (movieTicketServiceTypes.length > 0) {
movieTicketTypeChargeSpecs =
yield repos.priceSpecification.search({
project: { id: { $eq: params.project.id } },
typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
appliesToVideoFormats: params.videoFormatTypes,
appliesToMovieTicket: {
serviceTypes: movieTicketServiceTypes
}
});
}
}
return { soundFormatChargeSpecs, videoFormatChargeSpecs, movieTicketTypeChargeSpecs };
});
}
;