@chevre/domain 21.8.0-alpha.4 → 21.8.0-alpha.41
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/countOffers.ts +32 -0
- package/example/src/chevre/importOffersFromCOA.ts +7 -1
- package/example/src/chevre/migrateAggregateOffers.ts +75 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
- package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
- package/example/src/chevre/searchOffersByCatalog.ts +9 -4
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +167 -0
- package/example/src/chevre/sync2aggregateOffer.ts +27 -0
- package/example/src/chevre/syncAggregateOffer.ts +25 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +71 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +176 -0
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
- package/lib/chevre/repo/offer.d.ts +71 -14
- package/lib/chevre/repo/offer.js +1061 -87
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +34 -1
- package/lib/chevre/repo/task.d.ts +7 -1
- package/lib/chevre/repo/task.js +100 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -2
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
- package/lib/chevre/service/assetTransaction/reserve.js +105 -31
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/authorize.js +18 -19
- package/lib/chevre/service/offer/event/factory.js +8 -8
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
- package/lib/chevre/service/order/onOrderStatusChanged.js +104 -81
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +11 -13
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +33 -8
- package/lib/chevre/service/payment/any.js +30 -21
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/task/returnPayTransaction.js +8 -3
- package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
- package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
- package/lib/chevre/service/transaction/returnOrder.js +5 -1
- package/lib/chevre/settings.d.ts +4 -2
- package/lib/chevre/settings.js +5 -5
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -386,21 +386,62 @@ function createReservations4transactionObject(params) {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
// 指定されたアドオンがオファーに存在すれば、アドオンの単価仕様作成
|
|
389
|
-
|
|
389
|
+
const acceptedAddOns = [];
|
|
390
390
|
let availableAddOns;
|
|
391
|
-
const
|
|
392
|
-
if (Array.isArray(
|
|
391
|
+
const acceptedAddOnsParams = acceptedOffer.addOn;
|
|
392
|
+
if (Array.isArray(acceptedAddOnsParams) && acceptedAddOnsParams.length > 0) {
|
|
393
393
|
// アドオンオファー検索(2023-03-02~)
|
|
394
394
|
availableAddOns = yield searchAvailableAddOns({
|
|
395
|
-
ids:
|
|
395
|
+
ids: acceptedAddOnsParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
|
|
396
396
|
project: { id: params.transaction.project.id },
|
|
397
397
|
ticketOffer,
|
|
398
398
|
availableAtOrFrom: params.availableAtOrFrom
|
|
399
399
|
})(repos);
|
|
400
400
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnsParams)) {
|
|
402
|
+
acceptedAddOnsParams.forEach((acceptedAddOnParams) => {
|
|
403
|
+
var _a, _b, _c;
|
|
404
|
+
const availableAddOn = availableAddOns === null || availableAddOns === void 0 ? void 0 : availableAddOns.find((addOn) => addOn.id === acceptedAddOnParams.id);
|
|
405
|
+
if (availableAddOn !== undefined) {
|
|
406
|
+
// acceptedAddOnsの重複を避ける(単価オファーIDに対して)
|
|
407
|
+
if (!acceptedAddOns.some((addOn) => addOn.id === availableAddOn.id)) {
|
|
408
|
+
const availableAddOnReferenceQuantityValue = availableAddOn.priceSpecification.referenceQuantity.value;
|
|
409
|
+
if (typeof availableAddOnReferenceQuantityValue !== 'number') {
|
|
410
|
+
throw new factory.errors.NotImplemented('addOn.priceSpecification.referenceQuantity.value must be number');
|
|
411
|
+
}
|
|
412
|
+
// 受入数量はデフォルトで単価オファーの基準数量
|
|
413
|
+
let referenceQuantityValueAccepted = availableAddOnReferenceQuantityValue;
|
|
414
|
+
// 数量指定を検証(2023-08-31~)
|
|
415
|
+
const specifiedReferencedQuantityValue = (_b = (_a = acceptedAddOnParams.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
416
|
+
if (typeof specifiedReferencedQuantityValue === 'number') {
|
|
417
|
+
if (specifiedReferencedQuantityValue < 1) {
|
|
418
|
+
throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value must be > 0');
|
|
419
|
+
}
|
|
420
|
+
// 数量が適用単位要件を満たしていなければエラー
|
|
421
|
+
if (specifiedReferencedQuantityValue % availableAddOnReferenceQuantityValue !== 0) {
|
|
422
|
+
throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value', `Offer ${availableAddOn.id} requires reference quantity value ${specifiedReferencedQuantityValue}`);
|
|
423
|
+
}
|
|
424
|
+
// 基準数量上書き
|
|
425
|
+
referenceQuantityValueAccepted = specifiedReferencedQuantityValue;
|
|
426
|
+
}
|
|
427
|
+
const priceAccepted = availableAddOn.priceSpecification.price *
|
|
428
|
+
(referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue);
|
|
429
|
+
const accountsReceivableAccepted = (typeof ((_c = availableAddOn.priceSpecification.accounting) === null || _c === void 0 ? void 0 : _c.accountsReceivable) === 'number')
|
|
430
|
+
? availableAddOn.priceSpecification.accounting.accountsReceivable *
|
|
431
|
+
(referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue)
|
|
432
|
+
: undefined;
|
|
433
|
+
const acceptedAddOn = Object.assign(Object.assign({}, availableAddOn), { priceSpecification: Object.assign(Object.assign(Object.assign({}, availableAddOn.priceSpecification), (typeof accountsReceivableAccepted === 'number')
|
|
434
|
+
? {
|
|
435
|
+
accounting: Object.assign(Object.assign({}, availableAddOn.priceSpecification.accounting), { accountsReceivable: accountsReceivableAccepted, typeOf: 'Accounting' })
|
|
436
|
+
}
|
|
437
|
+
: undefined), { price: priceAccepted, referenceQuantity: Object.assign(Object.assign({}, availableAddOn.priceSpecification.referenceQuantity), { value: referenceQuantityValueAccepted }) }) });
|
|
438
|
+
acceptedAddOns.push(acceptedAddOn);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
// acceptedAddOns = availableAddOns.filter(
|
|
443
|
+
// (availableAddOn) => acceptedAddOnsParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id)
|
|
444
|
+
// );
|
|
404
445
|
}
|
|
405
446
|
const subReservation = (_j = (_h = acceptedOffer.itemOffered) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.subReservation;
|
|
406
447
|
const reservationId = `${reservationNumber}-${reservationIndex}`;
|
|
@@ -530,31 +571,64 @@ function validateProgramMembershipUsed(params) {
|
|
|
530
571
|
if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
|
|
531
572
|
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
532
573
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
574
|
+
const permitIssuedThrough = yield repos.product.findById({ id: issuedThroughId }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], []);
|
|
575
|
+
switch (permitIssuedThrough.typeOf) {
|
|
576
|
+
// 発行サービスがCreditCardのケースに対応(2023-09-01~)
|
|
577
|
+
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
578
|
+
// 決済サービスのserviceOutputにPermitが存在すれば、設定されたメンバーシップ区分のPermitをprogramMembershipUsedとして適用する
|
|
579
|
+
let issuedThroughServiceType;
|
|
580
|
+
if (Array.isArray(permitIssuedThrough.serviceOutput)) {
|
|
581
|
+
const serviceOutputAsPermit = permitIssuedThrough.serviceOutput.find((output) => output.typeOf === factory.permit.PermitType.Permit);
|
|
582
|
+
if ((serviceOutputAsPermit === null || serviceOutputAsPermit === void 0 ? void 0 : serviceOutputAsPermit.typeOf) === factory.permit.PermitType.Permit) {
|
|
583
|
+
issuedThroughServiceType = serviceOutputAsPermit.issuedThrough.serviceType;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
if ((issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.typeOf) === 'CategoryCode') {
|
|
587
|
+
programMembershipUsed = {
|
|
588
|
+
project: permitIssuedThrough.project,
|
|
589
|
+
typeOf: factory.permit.PermitType.Permit,
|
|
590
|
+
identifier: programMembershipUsedIdentifier,
|
|
591
|
+
issuedThrough: {
|
|
592
|
+
id: permitIssuedThrough.id,
|
|
593
|
+
serviceType: issuedThroughServiceType,
|
|
594
|
+
typeOf: permitIssuedThrough.typeOf
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'issuedThrough has no serviceOutput as Permit');
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
602
|
+
case factory.product.ProductType.MembershipService:
|
|
603
|
+
// requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
|
|
604
|
+
const permitService = yield createPermitService({ issuedThrough: { id: issuedThroughId } })(repos);
|
|
605
|
+
// メンバーシップの存在確認
|
|
606
|
+
const serviceOutput = yield permitService.findByIdentifier({
|
|
607
|
+
project: { id: params.project.id },
|
|
608
|
+
identifier: programMembershipUsedIdentifier,
|
|
609
|
+
issuedThrough: { typeOf: factory.product.ProductType.MembershipService }
|
|
610
|
+
});
|
|
611
|
+
// 有効期間のチェック
|
|
612
|
+
if (serviceOutput.validFrom === undefined || serviceOutput.validFrom === null
|
|
613
|
+
|| serviceOutput.validUntil === undefined || serviceOutput.validUntil === null) {
|
|
614
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'not valid programMembership');
|
|
615
|
+
}
|
|
616
|
+
if (moment(serviceOutput.validFrom)
|
|
617
|
+
.isAfter(moment(now))
|
|
618
|
+
|| moment(serviceOutput.validUntil)
|
|
619
|
+
.isBefore(moment(now))) {
|
|
620
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
|
|
621
|
+
}
|
|
622
|
+
programMembershipUsed = {
|
|
623
|
+
project: serviceOutput.project,
|
|
624
|
+
typeOf: serviceOutput.typeOf,
|
|
625
|
+
identifier: serviceOutput.identifier,
|
|
626
|
+
issuedThrough: serviceOutput.issuedThrough
|
|
627
|
+
};
|
|
628
|
+
break;
|
|
629
|
+
default:
|
|
630
|
+
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `${permitIssuedThrough.typeOf} not implemented`);
|
|
551
631
|
}
|
|
552
|
-
programMembershipUsed = {
|
|
553
|
-
project: serviceOutput.project,
|
|
554
|
-
typeOf: serviceOutput.typeOf,
|
|
555
|
-
identifier: serviceOutput.identifier,
|
|
556
|
-
issuedThrough: serviceOutput.issuedThrough
|
|
557
|
-
};
|
|
558
632
|
}
|
|
559
633
|
return programMembershipUsed;
|
|
560
634
|
});
|
|
@@ -29,6 +29,23 @@ const accountTransactionIdentifier_1 = require("../factory/accountTransactionIde
|
|
|
29
29
|
*/
|
|
30
30
|
function givePointAward(params) {
|
|
31
31
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
// 入金識別子が存在する場合、冪等性の確保(2023-08-24~)
|
|
33
|
+
const pendingTransactionIdentifier = params.object.identifier;
|
|
34
|
+
if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
|
|
35
|
+
// すでにConfirmedのMoneyTransfer取引が存在すれば何もしない
|
|
36
|
+
const assetTransactions = yield repos.assetTransaction.search({
|
|
37
|
+
limit: 1,
|
|
38
|
+
project: { id: { $eq: params.project.id } },
|
|
39
|
+
typeOf: factory.assetTransactionType.MoneyTransfer,
|
|
40
|
+
statuses: [factory.transactionStatusType.Confirmed],
|
|
41
|
+
object: {
|
|
42
|
+
pendingTransaction: { identifier: { $eq: pendingTransactionIdentifier } }
|
|
43
|
+
}
|
|
44
|
+
}, ['_id']);
|
|
45
|
+
if (assetTransactions.length > 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
32
49
|
// アクション開始
|
|
33
50
|
const action = yield repos.action.start(params);
|
|
34
51
|
try {
|
|
@@ -188,6 +188,7 @@ function validateObjectWithoutDetail(params) {
|
|
|
188
188
|
var _a, _b, _c, _d;
|
|
189
189
|
const objectWithoutDetail = params.object;
|
|
190
190
|
if (Array.isArray(objectWithoutDetail.acceptedOffer)) {
|
|
191
|
+
const validatedAcceptedOffersWithoutDetail = [];
|
|
191
192
|
for (let acceptedOffer of objectWithoutDetail.acceptedOffer) {
|
|
192
193
|
let programMembershipUsed = (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
|
|
193
194
|
// トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
|
|
@@ -214,7 +215,9 @@ function validateObjectWithoutDetail(params) {
|
|
|
214
215
|
};
|
|
215
216
|
acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_d = acceptedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed }) }) });
|
|
216
217
|
}
|
|
218
|
+
validatedAcceptedOffersWithoutDetail.push(acceptedOffer);
|
|
217
219
|
}
|
|
220
|
+
objectWithoutDetail.acceptedOffer = validatedAcceptedOffersWithoutDetail;
|
|
218
221
|
}
|
|
219
222
|
return objectWithoutDetail;
|
|
220
223
|
});
|
|
@@ -298,44 +301,40 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
298
301
|
transaction: params.transaction
|
|
299
302
|
});
|
|
300
303
|
const acceptedAppliesToMovieTicket = (_a = offerWithoutDetail.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
301
|
-
// let movieTicketIdentifire: string | undefined;
|
|
302
|
-
// if (Array.isArray(acceptedAppliesToMovieTicket)) {
|
|
303
|
-
// // throw new factory.errors.NotImplemented('multiple appliesToMovieTicket not implemented');
|
|
304
|
-
// // no op
|
|
305
|
-
// } else if (typeof acceptedAppliesToMovieTicket?.identifier === 'string') {
|
|
306
|
-
// movieTicketIdentifire = acceptedAppliesToMovieTicket.identifier;
|
|
307
|
-
// }
|
|
308
304
|
// 承認アクションオブジェクトのacceptedOfferにappliesToMovieTicketを連携する(2022-08-02~)
|
|
309
305
|
const priceSpecification = Object.assign(Object.assign({}, offer.priceSpecification), (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
|
|
310
306
|
? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
|
|
311
307
|
: undefined);
|
|
308
|
+
const acceptedAddOns = (Array.isArray(offerWithoutDetail.addOn))
|
|
309
|
+
? offerWithoutDetail.addOn.map((acceptedAddOnOffer) => {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
if (typeof acceptedAddOnOffer.id !== 'string' || acceptedAddOnOffer.id.length === 0) {
|
|
312
|
+
throw new factory.errors.ArgumentNull('object.acceptedOffer.addOn.id');
|
|
313
|
+
}
|
|
314
|
+
const addOnOfferReferenceQuantityValue = (_b = (_a = acceptedAddOnOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
315
|
+
return Object.assign({
|
|
316
|
+
// typeOf: <factory.offerType.Offer>factory.offerType.Offer,
|
|
317
|
+
id: acceptedAddOnOffer.id }, (typeof addOnOfferReferenceQuantityValue === 'number')
|
|
318
|
+
? { priceSpecification: { referenceQuantity: { value: addOnOfferReferenceQuantityValue } } }
|
|
319
|
+
: undefined);
|
|
320
|
+
})
|
|
321
|
+
: [];
|
|
312
322
|
const acceptedOffer = {
|
|
313
323
|
// オファーの中身を最適化する(必要最低限の情報のみに)
|
|
314
324
|
id: String(offer.id),
|
|
315
325
|
identifier: offer.identifier,
|
|
316
326
|
priceSpecification,
|
|
317
|
-
// project: offer.project,
|
|
318
327
|
typeOf: offer.typeOf,
|
|
319
328
|
priceCurrency: offer.priceCurrency,
|
|
320
329
|
itemOffered: Object.assign({ typeOf: factory.product.ProductType.EventService, serviceOutput: (offerWithoutDetail.itemOffered !== undefined && offerWithoutDetail.itemOffered !== null)
|
|
321
330
|
? offerWithoutDetail.itemOffered.serviceOutput
|
|
322
331
|
: undefined }, (pointAward !== undefined) ? { pointAward } : undefined),
|
|
323
|
-
addOn:
|
|
324
|
-
? offerWithoutDetail.addOn.map((a) => {
|
|
325
|
-
return {
|
|
326
|
-
typeOf: factory.offerType.Offer,
|
|
327
|
-
id: String(a.id),
|
|
328
|
-
priceCurrency: offer.priceCurrency
|
|
329
|
-
};
|
|
330
|
-
})
|
|
331
|
-
: [],
|
|
332
|
+
addOn: acceptedAddOns,
|
|
332
333
|
// 追加属性をマージ
|
|
333
334
|
additionalProperty: [
|
|
334
335
|
...(Array.isArray(offerWithoutDetail.additionalProperty)) ? offerWithoutDetail.additionalProperty : [],
|
|
335
336
|
...(Array.isArray(offer.additionalProperty)) ? offer.additionalProperty : []
|
|
336
337
|
]
|
|
337
|
-
// movieTicketIdentifireの不要を確認後に廃止(2022-09-09以降)(2022-11-02+)
|
|
338
|
-
// ...(typeof movieTicketIdentifire === 'string') ? { movieTicketIdentifire } : undefined
|
|
339
338
|
};
|
|
340
339
|
let offeredThrough = (_b = params.event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
|
|
341
340
|
if (typeof (offeredThrough === null || offeredThrough === void 0 ? void 0 : offeredThrough.typeOf) !== 'string') {
|
|
@@ -299,6 +299,7 @@ function createReservation(params) {
|
|
|
299
299
|
}
|
|
300
300
|
return reservationItem;
|
|
301
301
|
}
|
|
302
|
+
// tslint:disable-next-line:max-func-body-length
|
|
302
303
|
function coaTicket2offer(params) {
|
|
303
304
|
var _a, _b;
|
|
304
305
|
// 適用通貨区分
|
|
@@ -322,7 +323,6 @@ function coaTicket2offer(params) {
|
|
|
322
323
|
}]
|
|
323
324
|
: undefined;
|
|
324
325
|
const unitPriceSpec = {
|
|
325
|
-
// project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
326
326
|
typeOf: factory.priceSpecificationType.UnitPriceSpecification,
|
|
327
327
|
price: 0,
|
|
328
328
|
priceCurrency: factory.priceCurrency.JPY,
|
|
@@ -332,15 +332,15 @@ function coaTicket2offer(params) {
|
|
|
332
332
|
unitCode: factory.unitCode.C62,
|
|
333
333
|
value: 1
|
|
334
334
|
}
|
|
335
|
-
// appliesToMovieTicket?: {};
|
|
336
335
|
};
|
|
337
336
|
const identifier = (0, util_1.format)('%s-%s-%s', factory.service.webAPI.Identifier.COA, params.theaterCode, params.ticketResult.ticketCode);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
337
|
+
const offerName = {
|
|
338
|
+
ja: params.ticketResult.ticketName,
|
|
339
|
+
en: (typeof params.ticketResult.ticketNameEng === 'string')
|
|
340
|
+
? params.ticketResult.ticketNameEng
|
|
341
|
+
: ''
|
|
342
|
+
};
|
|
343
|
+
return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
|
|
344
344
|
ja: '',
|
|
345
345
|
en: ''
|
|
346
346
|
}, alternateName: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
3
3
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
4
5
|
export declare function importFromCOA(params: {
|
|
5
6
|
project: {
|
|
6
7
|
id: string;
|
|
@@ -9,6 +10,7 @@ export declare function importFromCOA(params: {
|
|
|
9
10
|
}): (repos: {
|
|
10
11
|
categoryCode: CategoryCodeRepo;
|
|
11
12
|
offer: OfferRepo;
|
|
13
|
+
task: TaskRepo;
|
|
12
14
|
masterService: COA.service.Master;
|
|
13
15
|
}) => Promise<void>;
|
|
14
16
|
/**
|
|
@@ -35,8 +35,8 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
35
35
|
onlyValid: params.onlyValid === true,
|
|
36
36
|
// Mongoのpagingを利用するオプション(2023-02-21~)
|
|
37
37
|
limit: params.limit,
|
|
38
|
-
page: params.page
|
|
39
|
-
sort: false
|
|
38
|
+
page: params.page
|
|
39
|
+
// sort: false // 完全廃止(2023-09-04~)
|
|
40
40
|
});
|
|
41
41
|
return { availableOffers: offers, sortedOfferIds };
|
|
42
42
|
});
|
|
@@ -26,6 +26,7 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
|
26
26
|
*/
|
|
27
27
|
function voidTransaction(params) {
|
|
28
28
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b;
|
|
29
30
|
const transaction = yield repos.transaction.findById({
|
|
30
31
|
typeOf: params.purpose.typeOf,
|
|
31
32
|
id: params.purpose.id,
|
|
@@ -46,8 +47,12 @@ function voidTransaction(params) {
|
|
|
46
47
|
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
47
48
|
// 確定取引に対応(2023-05-07~)
|
|
48
49
|
case factory.transactionStatusType.Confirmed:
|
|
49
|
-
//
|
|
50
|
-
|
|
50
|
+
// OrderCancelledを考慮(2023-08-30~)
|
|
51
|
+
const orderCancelled = ((_b = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.orderStatus) === factory.orderStatus.OrderCancelled;
|
|
52
|
+
if (!orderCancelled) {
|
|
53
|
+
// 取り消すべきアクションに絞る
|
|
54
|
+
authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
|
|
55
|
+
}
|
|
51
56
|
break;
|
|
52
57
|
default:
|
|
53
58
|
// no op
|
|
@@ -29,7 +29,7 @@ function searchProductOffers(params) {
|
|
|
29
29
|
excludeAppliesToMovieTicket: false,
|
|
30
30
|
limit: params.limit,
|
|
31
31
|
page: params.page,
|
|
32
|
-
sort: false,
|
|
32
|
+
// sort: false, // 完全廃止(2023-09-04~)
|
|
33
33
|
onlyValid: params.onlyValid === true,
|
|
34
34
|
availableAtOrFrom: params.availableAt
|
|
35
35
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
|
-
import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
5
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
6
5
|
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
7
6
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
@@ -21,6 +20,5 @@ declare function confirmPayTransaction(data: factory.task.IData<factory.taskName
|
|
|
21
20
|
seller: SellerRepo;
|
|
22
21
|
task: TaskRepo;
|
|
23
22
|
transaction: TransactionRepo;
|
|
24
|
-
registerServiceInProgress: RegisterServiceInProgressRepo;
|
|
25
23
|
}) => Promise<void>;
|
|
26
24
|
export { confirmPayTransaction };
|
|
@@ -12,16 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.confirmPayTransaction = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
15
|
-
const payOrder_1 = require("../order/payOrder");
|
|
16
15
|
function confirmPayTransaction(data) {
|
|
17
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
18
18
|
// アクション開始
|
|
19
19
|
const action = yield repos.action.start(data);
|
|
20
20
|
try {
|
|
21
21
|
for (const confirmingTransaction of data.object) {
|
|
22
|
-
yield PayTransactionService.confirm({
|
|
23
|
-
transactionNumber: confirmingTransaction.transactionNumber,
|
|
24
|
-
potentialActions: {
|
|
22
|
+
yield PayTransactionService.confirm(Object.assign({ transactionNumber: confirmingTransaction.transactionNumber, potentialActions: {
|
|
25
23
|
pay: {
|
|
26
24
|
purpose: {
|
|
27
25
|
typeOf: data.purpose.typeOf,
|
|
@@ -29,8 +27,9 @@ function confirmPayTransaction(data) {
|
|
|
29
27
|
orderNumber: data.purpose.orderNumber
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
30
|
+
} }, (typeof ((_b = (_a = confirmingTransaction.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
31
|
+
? { object: { paymentMethod: { identifier: confirmingTransaction.object.paymentMethod.identifier } } }
|
|
32
|
+
: undefined))({
|
|
34
33
|
action: repos.action,
|
|
35
34
|
accountingReport: repos.accountingReport,
|
|
36
35
|
assetTransaction: repos.assetTransaction,
|
|
@@ -59,50 +58,40 @@ function confirmPayTransaction(data) {
|
|
|
59
58
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
60
59
|
// processOrder連携(2023-08-23~)
|
|
61
60
|
yield onConfirmed(data)({
|
|
62
|
-
|
|
63
|
-
order: repos.order,
|
|
64
|
-
registerActionInProgress: repos.registerServiceInProgress,
|
|
65
|
-
task: repos.task,
|
|
66
|
-
transaction: repos.transaction
|
|
61
|
+
task: repos.task
|
|
67
62
|
});
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
65
|
exports.confirmPayTransaction = confirmPayTransaction;
|
|
71
66
|
function onConfirmed(params) {
|
|
72
67
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
var _a, _b;
|
|
73
69
|
if (params.processOrder === true) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
let allPayTransactionConfirmed = false;
|
|
83
|
-
const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
|
|
84
|
-
.map((invoice) => invoice.paymentMethodId);
|
|
85
|
-
if (paymentMethodIds.length > 0) {
|
|
86
|
-
const referencedPayTransactions = yield repos.assetTransaction.search({
|
|
87
|
-
project: { id: { $eq: params.project.id } },
|
|
88
|
-
typeOf: factory.assetTransactionType.Pay,
|
|
89
|
-
transactionNumber: { $in: paymentMethodIds }
|
|
90
|
-
}, ['status']);
|
|
91
|
-
allPayTransactionConfirmed =
|
|
92
|
-
referencedPayTransactions.every((payTransation) => payTransation.status === factory.transactionStatusType.Confirmed);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
allPayTransactionConfirmed = true;
|
|
96
|
-
}
|
|
97
|
-
if (allPayTransactionConfirmed) {
|
|
98
|
-
yield (0, payOrder_1.payOrder)({
|
|
99
|
-
project: { id: params.project.id },
|
|
100
|
-
object: {
|
|
70
|
+
for (const confirmingTransaction of params.object) {
|
|
71
|
+
// タスク冪等作成
|
|
72
|
+
const onAssetTransactionStatusChangedTaskData = {
|
|
73
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
74
|
+
object: Object.assign({ typeOf: factory.assetTransactionType.Pay, transactionNumber: confirmingTransaction.transactionNumber, status: factory.transactionStatusType.Confirmed }, (typeof ((_b = (_a = confirmingTransaction.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
75
|
+
? { object: { paymentMethod: { identifier: confirmingTransaction.object.paymentMethod.identifier } } }
|
|
76
|
+
: undefined),
|
|
77
|
+
purpose: {
|
|
101
78
|
confirmationNumber: params.purpose.confirmationNumber,
|
|
102
|
-
orderNumber: params.purpose.orderNumber
|
|
79
|
+
orderNumber: params.purpose.orderNumber,
|
|
80
|
+
typeOf: 'Order'
|
|
103
81
|
},
|
|
104
82
|
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
105
|
-
}
|
|
83
|
+
};
|
|
84
|
+
const onAssetTransactionStatusChangedTask = {
|
|
85
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
86
|
+
name: factory.taskName.OnAssetTransactionStatusChanged,
|
|
87
|
+
status: factory.taskStatus.Ready,
|
|
88
|
+
runsAt: new Date(),
|
|
89
|
+
remainingNumberOfTries: 10,
|
|
90
|
+
numberOfTried: 0,
|
|
91
|
+
executionResults: [],
|
|
92
|
+
data: onAssetTransactionStatusChangedTaskData
|
|
93
|
+
};
|
|
94
|
+
yield repos.task.createOnAssetTransactionStatusChangedTaskIfNotExist(onAssetTransactionStatusChangedTask, { emitImmediately: true });
|
|
106
95
|
}
|
|
107
96
|
}
|
|
108
97
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
2
|
+
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
3
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
|
+
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
|
+
import * as factory from '../../factory';
|
|
7
|
+
declare function onAssetTransactionStatusChanged(params: factory.task.IData<factory.taskName.OnAssetTransactionStatusChanged>): (repos: {
|
|
8
|
+
assetTransaction: AssetTransactionRepo;
|
|
9
|
+
order: OrderRepo;
|
|
10
|
+
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
11
|
+
task: TaskRepo;
|
|
12
|
+
transaction: TransactionRepo;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
declare function paymentDue2Processing(params: {
|
|
15
|
+
project: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
confirmationNumber: string;
|
|
19
|
+
orderNumber: string;
|
|
20
|
+
useOnOrderStatusChanged: boolean;
|
|
21
|
+
}): (repos: {
|
|
22
|
+
order: OrderRepo;
|
|
23
|
+
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
24
|
+
task: TaskRepo;
|
|
25
|
+
transaction: TransactionRepo;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
export { onAssetTransactionStatusChanged, paymentDue2Processing };
|