@chevre/domain 20.7.0-alpha.7 → 20.7.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +2 -0
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.js +81 -25
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +5 -2
- package/lib/chevre/service/offer/eventServiceByCOA.js +12 -4
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
1
2
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
2
3
|
import { IAcceptedOffer4COA } from './factory';
|
|
3
4
|
/**
|
|
@@ -13,6 +14,7 @@ declare function validateAcceptedOffers(params: {
|
|
|
13
14
|
project: {
|
|
14
15
|
id: string;
|
|
15
16
|
};
|
|
17
|
+
availablePaymentMethodTypes: factory.categoryCode.ICategoryCode[];
|
|
16
18
|
}): (repos: {
|
|
17
19
|
offer: OfferRepo;
|
|
18
20
|
}) => Promise<{
|
|
@@ -11,7 +11,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.validateAcceptedOffers = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
|
-
|
|
14
|
+
function createAppliesToMovieTicket(params) {
|
|
15
|
+
const isMvtkOrMG = typeof params.ticketInfo.mvtkNum === 'string' && params.ticketInfo.mvtkNum.length > 0;
|
|
16
|
+
let movieTicketTypeChargePriceSpec;
|
|
17
|
+
let appliesToMovieTicket;
|
|
18
|
+
if (isMvtkOrMG) {
|
|
19
|
+
// kbnMgtkから動的にavailablePaymentMethodを設定
|
|
20
|
+
let kbnMgtk = params.ticketInfo.kbnMgtk;
|
|
21
|
+
if (typeof kbnMgtk !== 'string') {
|
|
22
|
+
kbnMgtk = '';
|
|
23
|
+
}
|
|
24
|
+
const availablePaymentMethodType = params.availablePaymentMethodTypes.find((categoryCode) => { var _a, _b; return ((_b = (_a = categoryCode.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === 'kbnMgtk')) === null || _b === void 0 ? void 0 : _b.value) === kbnMgtk; });
|
|
25
|
+
if (availablePaymentMethodType === undefined) {
|
|
26
|
+
throw new factory.errors.Argument('offer', `available payment method type not found for kbnMgtk: ${kbnMgtk}`);
|
|
27
|
+
}
|
|
28
|
+
const availablePaymentMethod = availablePaymentMethodType.codeValue;
|
|
29
|
+
movieTicketTypeChargePriceSpec = {
|
|
30
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
31
|
+
typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
32
|
+
name: { ja: params.ticketInfo.ticketName, en: params.ticketInfo.ticketNameEng },
|
|
33
|
+
price: Number(params.ticketInfo.addPrice),
|
|
34
|
+
priceCurrency: factory.priceCurrency.JPY,
|
|
35
|
+
valueAddedTaxIncluded: true,
|
|
36
|
+
appliesToMovieTicket: {
|
|
37
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
38
|
+
serviceType: params.ticketInfo.mvtkKbnKensyu,
|
|
39
|
+
serviceOutput: { typeOf: availablePaymentMethod }
|
|
40
|
+
},
|
|
41
|
+
appliesToVideoFormat: params.ticketInfo.kbnEisyahousiki
|
|
42
|
+
};
|
|
43
|
+
appliesToMovieTicket = {
|
|
44
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
45
|
+
identifier: params.ticketInfo.mvtkNum,
|
|
46
|
+
serviceType: params.ticketInfo.mvtkKbnKensyu,
|
|
47
|
+
serviceOutput: { typeOf: availablePaymentMethod }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { movieTicketTypeChargePriceSpec, appliesToMovieTicket };
|
|
51
|
+
}
|
|
15
52
|
/**
|
|
16
53
|
* 受け入れらたオファーの内容を検証
|
|
17
54
|
*/
|
|
@@ -29,9 +66,9 @@ function validateAcceptedOffers(params) {
|
|
|
29
66
|
project: { id: { $eq: params.project.id } }
|
|
30
67
|
});
|
|
31
68
|
}
|
|
32
|
-
//
|
|
69
|
+
// tslint:disable-next-line:max-func-body-length
|
|
33
70
|
const acceptedOffers = params.object.acceptedOffer.map((acceptedOffer) => {
|
|
34
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
71
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
35
72
|
const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
|
|
36
73
|
if (availableUnitPriceOffer === undefined) {
|
|
37
74
|
throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.identifier} not found`);
|
|
@@ -40,19 +77,33 @@ function validateAcceptedOffers(params) {
|
|
|
40
77
|
if (priceSpecification === undefined) {
|
|
41
78
|
throw new factory.errors.NotFound('priceSpecification');
|
|
42
79
|
}
|
|
80
|
+
const unitPriceSpecByRequest = priceSpecification.priceComponent.find((component) => component.typeOf === factory.priceSpecificationType.UnitPriceSpecification);
|
|
81
|
+
if (unitPriceSpecByRequest === undefined) {
|
|
82
|
+
throw new factory.errors.ArgumentNull('offer.priceSpecification.priceComponent');
|
|
83
|
+
}
|
|
84
|
+
// appliesToMovieTicket.serviceOutput.typeOfを自動補完(2023-03-13~)
|
|
85
|
+
const { appliesToMovieTicket, movieTicketTypeChargePriceSpec } = createAppliesToMovieTicket({
|
|
86
|
+
project: { id: params.project.id },
|
|
87
|
+
ticketInfo,
|
|
88
|
+
availablePaymentMethodTypes: params.availablePaymentMethodTypes
|
|
89
|
+
});
|
|
90
|
+
let surfrockChargePriceSpec;
|
|
91
|
+
let appliesToMovieTicket4surfrock;
|
|
43
92
|
// appliesToSurfrockの指定があれば強制的にMovieTicket決済
|
|
44
93
|
let eligibleMonetaryAmount;
|
|
45
94
|
const surfrockIdentifier = (_b = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToSurfrock) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
46
|
-
|
|
95
|
+
const surfrockPaymentMethodType = (_e = (_d = (_c = acceptedOffer.priceSpecification) === null || _c === void 0 ? void 0 : _c.appliesToSurfrock) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.typeOf;
|
|
96
|
+
if (typeof surfrockIdentifier === 'string' && surfrockIdentifier.length > 0
|
|
97
|
+
&& typeof surfrockPaymentMethodType === 'string' && surfrockPaymentMethodType.length > 0) {
|
|
47
98
|
// serviceTypeはticketCode
|
|
48
|
-
const serviceType = (
|
|
99
|
+
const serviceType = (_g = (_f = availableUnitPriceOffer.additionalProperty) === null || _f === void 0 ? void 0 : _f.find((p) => p.name === 'ticketCode')) === null || _g === void 0 ? void 0 : _g.value;
|
|
49
100
|
if (typeof serviceType !== 'string') {
|
|
50
101
|
throw new factory.errors.NotFound('ticketCode of unitPriceOffer');
|
|
51
102
|
}
|
|
52
|
-
|
|
103
|
+
surfrockChargePriceSpec = {
|
|
53
104
|
appliesToMovieTicket: {
|
|
54
105
|
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
55
|
-
serviceOutput: { typeOf:
|
|
106
|
+
serviceOutput: { typeOf: surfrockPaymentMethodType },
|
|
56
107
|
serviceType
|
|
57
108
|
},
|
|
58
109
|
appliesToVideoFormat: 'Default',
|
|
@@ -62,22 +113,12 @@ function validateAcceptedOffers(params) {
|
|
|
62
113
|
typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
63
114
|
valueAddedTaxIncluded: true
|
|
64
115
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
component.appliesToMovieTicket.push({
|
|
72
|
-
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
73
|
-
identifier: surfrockIdentifier,
|
|
74
|
-
serviceOutput: { typeOf: MENBERSHIP_COUPON_PAYMENT_METHOD_TYPE },
|
|
75
|
-
serviceType
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return component;
|
|
79
|
-
});
|
|
80
|
-
priceSpecification.priceComponent.push(surfrockChargePriceSpec);
|
|
116
|
+
appliesToMovieTicket4surfrock = {
|
|
117
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
118
|
+
identifier: surfrockIdentifier,
|
|
119
|
+
serviceOutput: { typeOf: surfrockPaymentMethodType },
|
|
120
|
+
serviceType
|
|
121
|
+
};
|
|
81
122
|
}
|
|
82
123
|
else {
|
|
83
124
|
// appliesToSurfrockの指定がなければ単価オファーの適用通貨条件を強制適用
|
|
@@ -85,6 +126,21 @@ function validateAcceptedOffers(params) {
|
|
|
85
126
|
eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
|
|
86
127
|
}
|
|
87
128
|
}
|
|
129
|
+
const unitPriceSpec = Object.assign({ typeOf: factory.priceSpecificationType.UnitPriceSpecification, name: unitPriceSpecByRequest.name, price: unitPriceSpecByRequest.price, priceCurrency: factory.priceCurrency.JPY, referenceQuantity: unitPriceSpecByRequest.referenceQuantity, valueAddedTaxIncluded: true }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
|
|
130
|
+
? {
|
|
131
|
+
appliesToMovieTicket: [
|
|
132
|
+
...(appliesToMovieTicket !== undefined) ? [appliesToMovieTicket] : [],
|
|
133
|
+
...(appliesToMovieTicket4surfrock !== undefined) ? [appliesToMovieTicket4surfrock] : []
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
: undefined);
|
|
137
|
+
// priceComponentを再生成
|
|
138
|
+
const priceComponent = [
|
|
139
|
+
unitPriceSpec,
|
|
140
|
+
...(movieTicketTypeChargePriceSpec !== undefined) ? [movieTicketTypeChargePriceSpec] : [],
|
|
141
|
+
...(surfrockChargePriceSpec !== undefined) ? [surfrockChargePriceSpec] : []
|
|
142
|
+
];
|
|
143
|
+
priceSpecification.priceComponent = priceComponent;
|
|
88
144
|
return Object.assign(Object.assign({ additionalProperty,
|
|
89
145
|
itemOffered,
|
|
90
146
|
name,
|
|
@@ -95,10 +151,10 @@ function validateAcceptedOffers(params) {
|
|
|
95
151
|
priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
|
|
96
152
|
// tslint:disable-next-line:no-suspicious-comment
|
|
97
153
|
// TODO itemOfferedに完全置き換え
|
|
98
|
-
seatNumber: (
|
|
154
|
+
seatNumber: (_k = (_j = (_h = itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservedTicket) === null || _j === void 0 ? void 0 : _j.ticketedSeat) === null || _k === void 0 ? void 0 : _k.seatNumber,
|
|
99
155
|
// tslint:disable-next-line:no-suspicious-comment
|
|
100
156
|
// TODO itemOfferedに完全置き換え
|
|
101
|
-
seatSection: (
|
|
157
|
+
seatSection: (_o = (_m = (_l = itemOffered.serviceOutput) === null || _l === void 0 ? void 0 : _l.reservedTicket) === null || _m === void 0 ? void 0 : _m.ticketedSeat) === null || _o === void 0 ? void 0 : _o.seatSection
|
|
102
158
|
});
|
|
103
159
|
});
|
|
104
160
|
return { acceptedOffers };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
|
+
import { MongoRepository as CategoryCodeRepo } from '../../repo/categoryCode';
|
|
2
3
|
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
3
4
|
import { MongoRepository as OfferRepo } from '../../repo/offer';
|
|
4
5
|
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
5
6
|
import { IAcceptedOffer4COA } from './eventServiceByCOA/factory';
|
|
6
7
|
import * as factory from '../../factory';
|
|
7
8
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
8
|
-
|
|
9
|
+
interface IAuthorizeRepos {
|
|
9
10
|
action: ActionRepo;
|
|
11
|
+
categoryCode: CategoryCodeRepo;
|
|
10
12
|
event: EventRepo;
|
|
11
13
|
offer: OfferRepo;
|
|
12
14
|
transaction: TransactionRepo;
|
|
13
|
-
}
|
|
15
|
+
}
|
|
16
|
+
export declare type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
|
|
14
17
|
export declare type IAuthorizeOfferAction = factory.action.authorize.offer.seatReservation.IAction<WebAPIIdentifier.COA>;
|
|
15
18
|
/**
|
|
16
19
|
* COA興行オファー承認
|
|
@@ -29,16 +29,20 @@ function authorize(params) {
|
|
|
29
29
|
throw new factory.errors.Forbidden('Transaction not yours');
|
|
30
30
|
}
|
|
31
31
|
// イベント取得属性最適化(2023-01-23~)
|
|
32
|
-
// const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
|
|
33
32
|
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
34
33
|
id: params.object.event.id
|
|
35
34
|
});
|
|
35
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
36
|
+
project: { id: { $eq: transaction.project.id } },
|
|
37
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
38
|
+
});
|
|
36
39
|
// COA仮予約後にリクエストが来る前提
|
|
37
40
|
// validate acceptedOffer(2023-03-09~)
|
|
38
41
|
// const acceptedOffer = params.object.acceptedOffer;
|
|
39
42
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
40
43
|
object: params.object,
|
|
41
|
-
project: { id: transaction.project.id }
|
|
44
|
+
project: { id: transaction.project.id },
|
|
45
|
+
availablePaymentMethodTypes
|
|
42
46
|
})(repos);
|
|
43
47
|
const updTmpReserveSeatArgs = params.result.requestBody;
|
|
44
48
|
const updTmpReserveSeatResult = params.result.responseBody;
|
|
@@ -145,16 +149,20 @@ function changeOffers(params) {
|
|
|
145
149
|
}
|
|
146
150
|
validate4changeOffer({ action: authorizeAction, object: params.object });
|
|
147
151
|
// イベント取得属性最適化(2023-01-23~)
|
|
148
|
-
// const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
|
|
149
152
|
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
150
153
|
id: params.object.event.id
|
|
151
154
|
});
|
|
155
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
156
|
+
project: { id: { $eq: transaction.project.id } },
|
|
157
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
158
|
+
});
|
|
152
159
|
// COA仮予約後にリクエストが来る前提
|
|
153
160
|
// validate acceptedOffer(2023-03-09~)
|
|
154
161
|
// const acceptedOffer = params.object.acceptedOffer;
|
|
155
162
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
156
163
|
object: params.object,
|
|
157
|
-
project: { id: transaction.project.id }
|
|
164
|
+
project: { id: transaction.project.id },
|
|
165
|
+
availablePaymentMethodTypes
|
|
158
166
|
})(repos);
|
|
159
167
|
// 供給情報と価格を変更してからDB更新
|
|
160
168
|
authorizeAction.object.acceptedOffer = acceptedOffers;
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.301.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.149.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.301.0-alpha.2",
|
|
13
|
+
"@cinerino/sdk": "3.149.0-alpha.4",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.7.0-alpha.
|
|
123
|
+
"version": "20.7.0-alpha.9"
|
|
124
124
|
}
|