@chevre/domain 21.20.0-alpha.8 → 21.20.0
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/findTransactionById.ts +21 -0
- package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
- package/example/src/chevre/importOffersFromCOA.ts +2 -1
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
- package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
- package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
- package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
- package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchActions.ts +13 -7
- package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -3
- package/example/src/verifyToken.ts +44 -0
- package/lib/chevre/credentials.d.ts +2 -0
- package/lib/chevre/credentials.js +4 -2
- package/lib/chevre/errorHandler.js +3 -0
- package/lib/chevre/factory/order.d.ts +1 -0
- package/lib/chevre/factory/order.js +2 -1
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
- package/lib/chevre/factory/transaction.d.ts +10 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
- package/lib/chevre/repo/acceptedOffer.js +100 -4
- package/lib/chevre/repo/accountingReport.d.ts +33 -7
- package/lib/chevre/repo/accountingReport.js +157 -5
- package/lib/chevre/repo/action.d.ts +32 -8
- package/lib/chevre/repo/action.js +114 -54
- package/lib/chevre/repo/event.d.ts +20 -0
- package/lib/chevre/repo/event.js +22 -0
- package/lib/chevre/repo/member.d.ts +8 -1
- package/lib/chevre/repo/member.js +7 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
- package/lib/chevre/repo/offer.d.ts +42 -0
- package/lib/chevre/repo/offer.js +35 -0
- package/lib/chevre/repo/order.js +43 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
- package/lib/chevre/repo/orderInTransaction.js +164 -0
- package/lib/chevre/repo/paymentServiceProvider.js +2 -1
- package/lib/chevre/repo/person.js +1 -4
- package/lib/chevre/repo/task.d.ts +26 -3
- package/lib/chevre/repo/task.js +61 -46
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transaction.js +13 -36
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
- package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
- package/lib/chevre/service/assetTransaction/pay.d.ts +21 -6
- package/lib/chevre/service/assetTransaction/pay.js +64 -23
- package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
- package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +16 -24
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +71 -66
- package/lib/chevre/service/offer/any.d.ts +35 -0
- package/lib/chevre/service/offer/any.js +67 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +27 -17
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +13 -1
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +11 -22
- package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product/factory.js +2 -5
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +11 -23
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +5 -5
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +3 -1
- package/lib/chevre/service/order/placeOrder.js +157 -50
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +67 -33
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -5
- package/lib/chevre/service/payment/any.js +3 -2
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +62 -68
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -5
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -7
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -3
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.d.ts +5 -0
- package/lib/chevre/service/payment.js +40 -5
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/checkInReservation.js +6 -5
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/factory.js +0 -8
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/searchByOrder.js +2 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/useReservation.js +10 -9
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
- package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
- package/lib/chevre/service/task/createAccountingReport.js +80 -0
- package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/pay.js +6 -0
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/useReservation.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
- package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
- package/lib/chevre/service/transaction/placeOrder.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
- package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
- package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
- package/lib/chevre/service/transaction/returnOrder.js +3 -10
- package/lib/chevre/service.js +0 -10
- package/lib/chevre/settings.d.ts +7 -3
- package/lib/chevre/settings.js +13 -4
- package/package.json +5 -9
- package/example/src/chevre/cleanAccountingReports.ts +0 -57
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
- package/lib/chevre/service/util.d.ts +0 -19
- package/lib/chevre/service/util.js +0 -126
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.publishConfirmationNumberIfNotExist = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
16
|
+
*/
|
|
17
|
+
function publishConfirmationNumberIfNotExist(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// 最適化(2023-02-03~)
|
|
20
|
+
let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
21
|
+
// すでに発行済であれば何もしない
|
|
22
|
+
if (typeof confirmationNumber === 'string') {
|
|
23
|
+
return confirmationNumber;
|
|
24
|
+
}
|
|
25
|
+
// 確認番号を発行
|
|
26
|
+
confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
|
|
27
|
+
// 取引に存在しなければ保管
|
|
28
|
+
yield repos.transaction.saveConfirmationNumberIfNotExist({
|
|
29
|
+
id: params.id,
|
|
30
|
+
confirmationNumber
|
|
31
|
+
});
|
|
32
|
+
// 確認番号を取引から再取得
|
|
33
|
+
// 最適化(2023-02-03~)
|
|
34
|
+
confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
35
|
+
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
36
|
+
if (typeof confirmationNumber !== 'string') {
|
|
37
|
+
throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
|
|
38
|
+
}
|
|
39
|
+
return confirmationNumber;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
2
|
+
import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
3
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
4
|
+
/**
|
|
5
|
+
* 未発行であれば、注文番号を発行して取引に保管する
|
|
6
|
+
*/
|
|
7
|
+
declare function publishOrderNumberIfNotExist(params: {
|
|
8
|
+
project: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 取引ID
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
object: {
|
|
16
|
+
orderDate: Date;
|
|
17
|
+
};
|
|
18
|
+
}): (repos: {
|
|
19
|
+
project: ProjectRepo;
|
|
20
|
+
transaction: TransactionRepo;
|
|
21
|
+
orderNumber: OrderNumberRepo;
|
|
22
|
+
}) => Promise<string>;
|
|
23
|
+
export { publishOrderNumberIfNotExist };
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.publishOrderNumberIfNotExist = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 未発行であれば、注文番号を発行して取引に保管する
|
|
16
|
+
*/
|
|
17
|
+
function publishOrderNumberIfNotExist(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// 最適化(2023-02-03~)
|
|
20
|
+
let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
21
|
+
// すでに発行済であれば何もしない
|
|
22
|
+
if (typeof orderNumber === 'string') {
|
|
23
|
+
return orderNumber;
|
|
24
|
+
}
|
|
25
|
+
// 注文番号を発行
|
|
26
|
+
const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
|
|
27
|
+
if (typeof alternateName !== 'string') {
|
|
28
|
+
throw new factory.errors.NotFound('project.alternateName');
|
|
29
|
+
}
|
|
30
|
+
orderNumber = yield repos.orderNumber.publishByTimestamp({
|
|
31
|
+
project: { alternateName },
|
|
32
|
+
orderDate: params.object.orderDate
|
|
33
|
+
});
|
|
34
|
+
// 取引に存在しなければ保管
|
|
35
|
+
yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
|
|
36
|
+
// 注文番号を取引から再取得
|
|
37
|
+
// 最適化(2023-02-03~)
|
|
38
|
+
orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
39
|
+
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
40
|
+
if (typeof orderNumber !== 'string') {
|
|
41
|
+
throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
|
|
42
|
+
}
|
|
43
|
+
return orderNumber;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
|
|
@@ -125,44 +125,41 @@ function createMoneyTransferAcceptedOffers(params) {
|
|
|
125
125
|
if (authorizeMoneyTansferAction.result === undefined) {
|
|
126
126
|
throw new factory.errors.Argument('Transaction', 'authorize money transfer offer result does not exist');
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
const currency = pendingTransaction.object.amount.currency;
|
|
132
|
-
const itemOffered = {
|
|
133
|
-
typeOf: factory.actionType.MoneyTransfer,
|
|
134
|
-
amount: {
|
|
135
|
-
typeOf: 'MonetaryAmount',
|
|
136
|
-
value: amountValue,
|
|
137
|
-
currency
|
|
138
|
-
},
|
|
139
|
-
toLocation: {
|
|
140
|
-
typeOf: authorizeMoneyTansferAction.object.itemOffered.toLocation.typeOf,
|
|
141
|
-
// いったんマスク
|
|
142
|
-
identifier: 'xxx',
|
|
143
|
-
issuedThrough: { id: (_a = authorizeMoneyTansferAction.object.itemOffered.toLocation.issuedThrough) === null || _a === void 0 ? void 0 : _a.id }
|
|
144
|
-
},
|
|
145
|
-
object: {
|
|
146
|
-
pendingTransaction: {
|
|
147
|
-
typeOf: pendingTransaction.typeOf,
|
|
148
|
-
// MonetaryAmountの識別子として、MoneyTransfer取引番号をセットする
|
|
149
|
-
transactionNumber: String(pendingTransaction.transactionNumber)
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
name: `${amountValue} ${currency}`
|
|
153
|
-
};
|
|
154
|
-
acceptedOffers.push({
|
|
155
|
-
typeOf: factory.offerType.Offer,
|
|
156
|
-
itemOffered
|
|
157
|
-
// 不要なので廃止(2023-07-01~)
|
|
158
|
-
// priceCurrency: authorizeMoneyTansferAction.result.priceCurrency,
|
|
159
|
-
// 不要なので廃止(2023-07-01~)
|
|
160
|
-
// seller: {
|
|
161
|
-
// typeOf: params.seller.typeOf,
|
|
162
|
-
// name: params.seller.name
|
|
163
|
-
// }
|
|
164
|
-
});
|
|
128
|
+
const resultAcceptedOffers = (_a = authorizeMoneyTansferAction.result) === null || _a === void 0 ? void 0 : _a.acceptedOffers;
|
|
129
|
+
if (Array.isArray(resultAcceptedOffers) && resultAcceptedOffers.length > 0) {
|
|
130
|
+
acceptedOffers.push(...resultAcceptedOffers);
|
|
165
131
|
}
|
|
132
|
+
// const pendingTransaction = authorizeMoneyTansferAction.result.responseBody;
|
|
133
|
+
// if (pendingTransaction !== undefined) {
|
|
134
|
+
// const amountValue = pendingTransaction.object.amount.value;
|
|
135
|
+
// const currency = pendingTransaction.object.amount.currency;
|
|
136
|
+
// const itemOffered: factory.order.IMoneyTransfer = {
|
|
137
|
+
// typeOf: factory.actionType.MoneyTransfer,
|
|
138
|
+
// amount: {
|
|
139
|
+
// typeOf: 'MonetaryAmount',
|
|
140
|
+
// value: amountValue,
|
|
141
|
+
// currency
|
|
142
|
+
// },
|
|
143
|
+
// toLocation: {
|
|
144
|
+
// typeOf: authorizeMoneyTansferAction.object.itemOffered.toLocation.typeOf,
|
|
145
|
+
// // いったんマスク
|
|
146
|
+
// identifier: 'xxx',
|
|
147
|
+
// issuedThrough: { id: authorizeMoneyTansferAction.object.itemOffered.toLocation.issuedThrough?.id }
|
|
148
|
+
// },
|
|
149
|
+
// object: {
|
|
150
|
+
// pendingTransaction: {
|
|
151
|
+
// typeOf: pendingTransaction.typeOf,
|
|
152
|
+
// // MonetaryAmountの識別子として、MoneyTransfer取引番号をセットする
|
|
153
|
+
// transactionNumber: String(pendingTransaction.transactionNumber)
|
|
154
|
+
// }
|
|
155
|
+
// },
|
|
156
|
+
// name: `${amountValue} ${currency}`
|
|
157
|
+
// };
|
|
158
|
+
// acceptedOffers.push({
|
|
159
|
+
// typeOf: factory.offerType.Offer,
|
|
160
|
+
// itemOffered
|
|
161
|
+
// });
|
|
162
|
+
// }
|
|
166
163
|
});
|
|
167
164
|
return { moneyTransferAcceptedOffers: acceptedOffers, moneyTransferOrderItems: orderedItems };
|
|
168
165
|
}
|
|
@@ -10,4 +10,6 @@ export declare function createOrder(params: {
|
|
|
10
10
|
orderStatus: factory.orderStatus;
|
|
11
11
|
isGift: boolean;
|
|
12
12
|
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
13
|
-
}): factory.transaction.placeOrder.IOrderAsResult
|
|
13
|
+
}): factory.transaction.placeOrder.IOrderAsResult & {
|
|
14
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
15
|
+
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOrder = void 0;
|
|
4
4
|
const factory = require("../../../factory");
|
|
5
|
-
const settings_1 = require("../../../settings");
|
|
6
5
|
const acceptedOffers_1 = require("./result/acceptedOffers");
|
|
7
6
|
/**
|
|
8
7
|
* 注文を生成する
|
|
@@ -87,9 +86,19 @@ function createPaymentMethods(params) {
|
|
|
87
86
|
const paymentMethodOfInvoice = Object.assign({ identifier: paymentMethodType }, (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
88
87
|
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } } // CreditCardIFのカード通貨区分を追加(2023-08-15~)
|
|
89
88
|
: undefined);
|
|
90
|
-
paymentMethods.push(
|
|
91
|
-
|
|
92
|
-
:
|
|
89
|
+
paymentMethods.push({
|
|
90
|
+
accountId: resultAsInvoice.accountId,
|
|
91
|
+
additionalProperty: (Array.isArray(resultAsInvoice.additionalProperty)) ? resultAsInvoice.additionalProperty : [],
|
|
92
|
+
issuedThrough: resultAsInvoice.issuedThrough,
|
|
93
|
+
name: resultAsInvoice.name,
|
|
94
|
+
paymentMethodId: resultAsInvoice.paymentMethodId,
|
|
95
|
+
paymentStatus: resultAsInvoice.paymentStatus,
|
|
96
|
+
totalPaymentDue: resultAsInvoice.totalPaymentDue,
|
|
97
|
+
paymentMethod: paymentMethodOfInvoice
|
|
98
|
+
// ...(USE_ORDER_PAYMENT_METHOD_TYPE_OF) // 完全廃止(2024-01-17~)
|
|
99
|
+
// ? { typeOf: paymentMethodType }
|
|
100
|
+
// : undefined
|
|
101
|
+
});
|
|
93
102
|
});
|
|
94
103
|
// 決済方法から注文金額の計算
|
|
95
104
|
price += authorizePaymentActions
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MongoRepository as MemberRepo } from '../../../repo/member';
|
|
2
|
+
import type { MongoRepository as SellerRepo } from '../../../repo/seller';
|
|
3
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
4
|
+
import * as factory from '../../../factory';
|
|
5
|
+
import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
6
|
+
interface IStartOperationRepos {
|
|
7
|
+
member: MemberRepo;
|
|
8
|
+
seller: SellerRepo;
|
|
9
|
+
transaction: TransactionRepo;
|
|
10
|
+
}
|
|
11
|
+
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
12
|
+
type IStartParams = PlaceOrderFactory.IStartParams & {
|
|
13
|
+
validateEligibleCustomerType: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 取引開始
|
|
17
|
+
*/
|
|
18
|
+
declare function start(params: IStartParams): IStartOperation<factory.transaction.placeOrder.ITransaction>;
|
|
19
|
+
export { start };
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.start = void 0;
|
|
13
|
+
const errorHandler_1 = require("../../../errorHandler");
|
|
14
|
+
const factory = require("../../../factory");
|
|
15
|
+
const validation_1 = require("../validation");
|
|
16
|
+
const factory_1 = require("./factory");
|
|
17
|
+
const validateStartRequest_1 = require("./validation/validateStartRequest");
|
|
18
|
+
/**
|
|
19
|
+
* 取引開始
|
|
20
|
+
*/
|
|
21
|
+
function start(params) {
|
|
22
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
24
|
+
const { passport, customerType } = yield (0, validation_1.validateWaiterPassport)(params);
|
|
25
|
+
const { memeberOfPayload, makesOfferFromClient, seller } = yield (0, validateStartRequest_1.validateStartRequest)(Object.assign({ project: { id: params.project.id }, seller: { id: params.seller.id }, clientUser: params.object.clientUser, memberOfToken: params.agent.memberOfToken }, (params.validateEligibleCustomerType === true
|
|
26
|
+
&& typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { customerType } : undefined))(repos);
|
|
27
|
+
const expiresInSeconds = (_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue;
|
|
28
|
+
if (typeof expiresInSeconds !== 'number') {
|
|
29
|
+
throw new factory.errors.NotFound('eligibleTransactionDuration.maxValue');
|
|
30
|
+
}
|
|
31
|
+
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
32
|
+
const startParams = (0, factory_1.createStartParams)(params, expiresInSeconds, passport, seller, params.broker, customerType, memeberOfPayload);
|
|
33
|
+
let transaction;
|
|
34
|
+
try {
|
|
35
|
+
transaction = yield repos.transaction.start(startParams);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
39
|
+
// no op
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
return transaction;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.start = start;
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { MongoRepository as MemberRepo } from '../../../../repo/member';
|
|
3
|
+
import type { MongoRepository as SellerRepo } from '../../../../repo/seller';
|
|
4
|
+
type ISeller = Pick<factory.seller.ISeller, 'id' | 'name' | 'project' | 'typeOf' | 'makesOffer' | 'additionalProperty'>;
|
|
5
|
+
declare function validateStartRequest(params: {
|
|
6
|
+
project: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
seller: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
clientUser?: factory.clientUser.IClientUser;
|
|
13
|
+
/**
|
|
14
|
+
* passportによって決定するカスタマータイプ
|
|
15
|
+
*/
|
|
16
|
+
customerType?: string;
|
|
17
|
+
memberOfToken?: string;
|
|
18
|
+
}): (repos: {
|
|
19
|
+
member: MemberRepo;
|
|
20
|
+
seller: SellerRepo;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
seller: ISeller;
|
|
23
|
+
makesOfferFromClient: factory.seller.IMakesOffer;
|
|
24
|
+
memeberOfPayload?: import("@chevre/factory/lib/transaction/placeOrder").IMemberOfPayload | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export { validateStartRequest };
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateStartRequest = void 0;
|
|
13
|
+
const jwt = require("jsonwebtoken");
|
|
14
|
+
const factory = require("../../../../factory");
|
|
15
|
+
function verifyMembershipToken(params) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
let result;
|
|
18
|
+
const { secret, token } = params;
|
|
19
|
+
if (typeof token === 'string' && token.length > 0) {
|
|
20
|
+
try {
|
|
21
|
+
result = yield new Promise((resolve, reject) => {
|
|
22
|
+
jwt.verify(token, secret, {
|
|
23
|
+
// issuer: credentials.jwt.issuer,
|
|
24
|
+
// ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
25
|
+
}, (err, decoded) => {
|
|
26
|
+
if (err instanceof Error) {
|
|
27
|
+
reject(err);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
resolve(decoded);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// JWTエラーをハンドリング
|
|
37
|
+
if (error instanceof jwt.TokenExpiredError) {
|
|
38
|
+
throw new factory.errors.Argument('memberOfToken', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
39
|
+
}
|
|
40
|
+
else if (error instanceof jwt.JsonWebTokenError) {
|
|
41
|
+
throw new factory.errors.Argument('memberOfToken', `invalid token. [${error.message}]`);
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new factory.errors.ArgumentNull('memberOfToken');
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function validateStartRequest(params) {
|
|
53
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
|
+
const sellers = yield repos.seller.search({
|
|
56
|
+
limit: 1,
|
|
57
|
+
page: 1,
|
|
58
|
+
project: { id: { $eq: params.project.id } },
|
|
59
|
+
id: { $eq: params.seller.id }
|
|
60
|
+
}, ['name', 'project', 'typeOf', 'makesOffer', 'additionalProperty'], []);
|
|
61
|
+
const seller = sellers.shift();
|
|
62
|
+
if (seller === undefined) {
|
|
63
|
+
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
64
|
+
}
|
|
65
|
+
const clientId = (_a = params.clientUser) === null || _a === void 0 ? void 0 : _a.client_id;
|
|
66
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
67
|
+
/* istanbul ignore if */
|
|
68
|
+
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
69
|
+
throw new factory.errors.ArgumentNull('client_id');
|
|
70
|
+
}
|
|
71
|
+
const makesOfferFromClient = (_b = seller.makesOffer) === null || _b === void 0 ? void 0 : _b.find((offer) => {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = offer.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.some((availableApplication) => availableApplication.id === clientId);
|
|
74
|
+
});
|
|
75
|
+
if (makesOfferFromClient === undefined) {
|
|
76
|
+
throw new factory.errors.Argument('seller', 'makes no offers');
|
|
77
|
+
}
|
|
78
|
+
// eligibleCustomerType検証(2023-11-20~)
|
|
79
|
+
if (typeof params.customerType === 'string') {
|
|
80
|
+
const isCustomerTypeEligible = Array.isArray(makesOfferFromClient.eligibleCustomerType)
|
|
81
|
+
&& makesOfferFromClient.eligibleCustomerType.some((categoryCode) => categoryCode.codeValue === params.customerType);
|
|
82
|
+
if (!isCustomerTypeEligible) {
|
|
83
|
+
throw new factory.errors.Argument('seller', 'cutomer type ineligible');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// IAM存在検証(2024-02-06~)
|
|
87
|
+
const iamMember = (yield repos.member.search({
|
|
88
|
+
project: { id: { $eq: seller.project.id } },
|
|
89
|
+
member: {
|
|
90
|
+
typeOf: { $eq: factory.creativeWorkType.WebApplication },
|
|
91
|
+
id: { $eq: clientId },
|
|
92
|
+
memberOf: { typeOf: { $eq: factory.organizationType.Project } } // プロジェクトメンバーのはず
|
|
93
|
+
}
|
|
94
|
+
})).shift();
|
|
95
|
+
if (iamMember === undefined) {
|
|
96
|
+
throw new factory.errors.NotFound(factory.iam.RoleType.OrganizationRole);
|
|
97
|
+
}
|
|
98
|
+
// メンバーシップトークン検証(2024-01-31~)
|
|
99
|
+
let memeberOfPayload;
|
|
100
|
+
if (Array.isArray(iamMember.member.member)) {
|
|
101
|
+
const verifySecret = (_d = (_c = iamMember.member.member[0]) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.secret; // ひとまず1種類のメンバーシップのみ対応
|
|
102
|
+
if (typeof verifySecret === 'string') {
|
|
103
|
+
memeberOfPayload = yield verifyMembershipToken({ token: params.memberOfToken, secret: verifySecret });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { makesOfferFromClient, memeberOfPayload, seller };
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.validateStartRequest = validateStartRequest;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
+
import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
2
3
|
export type IAuthorizeAnyPaymentResult = factory.action.authorize.paymentMethod.any.IResult;
|
|
3
4
|
export type IAuthorizeSeatReservationOffer = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
|
|
4
5
|
export type IAuthorizeSeatReservationOfferResult = factory.action.authorize.offer.eventService.IResult<factory.service.webAPI.Identifier>;
|
|
@@ -8,33 +9,19 @@ export type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecifica
|
|
|
8
9
|
* 取引が確定可能な状態かどうかをチェックする
|
|
9
10
|
*/
|
|
10
11
|
export declare function validateTransaction(transaction: factory.transaction.placeOrder.ITransaction, authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[]): void;
|
|
11
|
-
export type IConfirmationNumberGenerator = (order: factory.order.IOrder) => string;
|
|
12
12
|
export type IOrderURLGenerator = (order: factory.order.IOrder) => string;
|
|
13
|
-
export type IResultOrderParams = factory.transaction.placeOrder.IResultOrderParams & {
|
|
14
|
-
/**
|
|
15
|
-
* 注文日時
|
|
16
|
-
*/
|
|
17
|
-
orderDate: Date;
|
|
18
|
-
/**
|
|
19
|
-
* 確認番号のカスタム指定
|
|
20
|
-
*/
|
|
21
|
-
confirmationNumber?: string | IConfirmationNumberGenerator;
|
|
22
|
-
/**
|
|
23
|
-
* 注文確認URLのカスタム指定
|
|
24
|
-
*/
|
|
25
|
-
url?: string | IOrderURLGenerator;
|
|
26
|
-
/**
|
|
27
|
-
* 注文アイテム数
|
|
28
|
-
*/
|
|
29
|
-
numItems?: {
|
|
30
|
-
maxValue?: number;
|
|
31
|
-
minValue?: number;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
13
|
export declare function validateNumItems(params: {
|
|
14
|
+
order: factory.transaction.placeOrder.IOrderAsResult & {
|
|
15
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
16
|
+
};
|
|
17
|
+
result: {
|
|
18
|
+
order: PlaceOrderFactory.IResultOrderParams;
|
|
19
|
+
};
|
|
20
|
+
}): void;
|
|
21
|
+
export declare function validateOrderedItem(params: {
|
|
35
22
|
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
36
23
|
result: {
|
|
37
|
-
order: IResultOrderParams;
|
|
24
|
+
order: PlaceOrderFactory.IResultOrderParams;
|
|
38
25
|
};
|
|
39
26
|
}): void;
|
|
40
27
|
export declare function validatePaymentMethods(params: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateEventOffers = exports.validatePaymentMethods = exports.validateNumItems = exports.validateTransaction = void 0;
|
|
3
|
+
exports.validateEventOffers = exports.validatePaymentMethods = exports.validateOrderedItem = exports.validateNumItems = exports.validateTransaction = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文取引バリデーション
|
|
6
6
|
*/
|
|
@@ -235,8 +235,27 @@ function validateNumItems(params) {
|
|
|
235
235
|
throw new factory.errors.Argument('Transaction', (0, util_1.format)('Number of order items must be more than equal to %s', numItemsMinValue));
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
+
// itemOffered.typeOf数検証(2024-01-31~)
|
|
239
|
+
const itemOfferedTypeOfs = [...new Set(params.order.acceptedOffers.map((offer) => offer.itemOffered.typeOf))];
|
|
240
|
+
if (itemOfferedTypeOfs.length > 1) {
|
|
241
|
+
throw new factory.errors.Argument('Transaction', `different itemOffered.typeOfs contained. [${itemOfferedTypeOfs.join(',')}]`);
|
|
242
|
+
}
|
|
238
243
|
}
|
|
239
244
|
exports.validateNumItems = validateNumItems;
|
|
245
|
+
function validateOrderedItem(params) {
|
|
246
|
+
var _a, _b;
|
|
247
|
+
if (!Array.isArray(params.order.orderedItem)) {
|
|
248
|
+
throw new factory.errors.Argument('order.orderedItem', 'must be array');
|
|
249
|
+
}
|
|
250
|
+
// 注文アイテム数制限確認
|
|
251
|
+
const numOrderedItemMaxValue = (_b = (_a = params.result.order) === null || _a === void 0 ? void 0 : _a.orderedItem) === null || _b === void 0 ? void 0 : _b.maxValue;
|
|
252
|
+
if (typeof numOrderedItemMaxValue === 'number') {
|
|
253
|
+
if (params.order.orderedItem.length > numOrderedItemMaxValue) {
|
|
254
|
+
throw new factory.errors.Argument('Transaction', (0, util_1.format)('Number of orderedItem must be less than or equal to %s', numOrderedItemMaxValue));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.validateOrderedItem = validateOrderedItem;
|
|
240
259
|
function validatePaymentMethods(params) {
|
|
241
260
|
if (typeof settings_1.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number') {
|
|
242
261
|
// CreditCard IFの決済方法の最大値検証
|
|
@@ -1,80 +1,17 @@
|
|
|
1
|
-
import * as factory from '../../factory';
|
|
2
|
-
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
|
-
import type { RedisRepository as ConfirmationNumberRepo } from '../../repo/confirmationNumber';
|
|
4
|
-
import type { MongoRepository as EmailMessageRepo } from '../../repo/emailMessage';
|
|
5
|
-
import type { RedisRepository as OrderNumberRepo } from '../../repo/orderNumber';
|
|
6
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
7
|
-
import type { MongoRepository as SellerRepo } from '../../repo/seller';
|
|
8
|
-
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
9
|
-
import { IPassportValidator as IWaiterPassportValidator, placeOrder as PlaceOrderFactory } from '../../factory/transaction';
|
|
10
|
-
export declare const POINT_AWARD_IDENTIFIER_NAME = "pointAwardIdentifiers";
|
|
11
|
-
export interface IStartOperationRepos {
|
|
12
|
-
seller: SellerRepo;
|
|
13
|
-
transaction: TransactionRepo;
|
|
14
|
-
}
|
|
15
|
-
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
16
|
-
export interface IConfirmOperationRepos {
|
|
17
|
-
action: ActionRepo;
|
|
18
|
-
emailMessage?: EmailMessageRepo;
|
|
19
|
-
project: ProjectRepo;
|
|
20
|
-
transaction: TransactionRepo;
|
|
21
|
-
orderNumber: OrderNumberRepo;
|
|
22
|
-
confirmationNumber: ConfirmationNumberRepo;
|
|
23
|
-
}
|
|
24
|
-
export type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
|
|
25
|
-
export type IPassportValidator = IWaiterPassportValidator;
|
|
26
|
-
export type IStartParams = PlaceOrderFactory.IStartParams & {
|
|
27
|
-
validateEligibleCustomerType: boolean;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 取引開始
|
|
31
|
-
*/
|
|
32
|
-
export declare function start(params: IStartParams): IStartOperation<factory.transaction.placeOrder.ITransaction>;
|
|
33
|
-
export type IOrderURLGenerator = PlaceOrderFactory.IOrderURLGenerator;
|
|
34
|
-
export type IResultOrderParams = PlaceOrderFactory.IResultOrderParams;
|
|
35
|
-
export type IConfirmParams = PlaceOrderFactory.IConfirmParams;
|
|
36
|
-
/**
|
|
37
|
-
* 注文取引を確定する
|
|
38
|
-
*/
|
|
39
|
-
export declare function confirm(params: IConfirmParams): IConfirmOperation<factory.transaction.placeOrder.IResult>;
|
|
40
|
-
/**
|
|
41
|
-
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
42
|
-
*/
|
|
43
|
-
export declare function publishConfirmationNumberIfNotExist(params: {
|
|
44
|
-
/**
|
|
45
|
-
* 取引ID
|
|
46
|
-
*/
|
|
47
|
-
id: string;
|
|
48
|
-
object: {
|
|
49
|
-
orderDate: Date;
|
|
50
|
-
};
|
|
51
|
-
}): (repos: {
|
|
52
|
-
transaction: TransactionRepo;
|
|
53
|
-
confirmationNumber: ConfirmationNumberRepo;
|
|
54
|
-
}) => Promise<string>;
|
|
55
1
|
/**
|
|
56
|
-
*
|
|
2
|
+
* 進行中注文取引サービス
|
|
57
3
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
id: string;
|
|
66
|
-
object: {
|
|
67
|
-
orderDate: Date;
|
|
68
|
-
};
|
|
69
|
-
}): (repos: {
|
|
70
|
-
project: ProjectRepo;
|
|
71
|
-
transaction: TransactionRepo;
|
|
72
|
-
orderNumber: OrderNumberRepo;
|
|
73
|
-
}) => Promise<string>;
|
|
4
|
+
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
5
|
+
import * as factory from '../../factory';
|
|
6
|
+
import { POINT_AWARD_IDENTIFIER_NAME } from '../../factory/order';
|
|
7
|
+
import { confirm } from './placeOrderInProgress/confirm';
|
|
8
|
+
import { publishConfirmationNumberIfNotExist } from './placeOrderInProgress/publishConfirmationNumberIfNotExist';
|
|
9
|
+
import { publishOrderNumberIfNotExist } from './placeOrderInProgress/publishOrderNumberIfNotExist';
|
|
10
|
+
import { start } from './placeOrderInProgress/start';
|
|
74
11
|
/**
|
|
75
12
|
* インセンティブ承認
|
|
76
13
|
*/
|
|
77
|
-
|
|
14
|
+
declare function authorizeAward(params: {
|
|
78
15
|
transaction: {
|
|
79
16
|
id: string;
|
|
80
17
|
};
|
|
@@ -92,7 +29,7 @@ export declare function authorizeAward(params: {
|
|
|
92
29
|
/**
|
|
93
30
|
* インセンティブ承認を取り消す
|
|
94
31
|
*/
|
|
95
|
-
|
|
32
|
+
declare function voidAward(params: {
|
|
96
33
|
/**
|
|
97
34
|
* 取引進行者
|
|
98
35
|
*/
|
|
@@ -108,3 +45,4 @@ export declare function voidAward(params: {
|
|
|
108
45
|
}): (repos: {
|
|
109
46
|
transaction: TransactionRepo;
|
|
110
47
|
}) => Promise<void>;
|
|
48
|
+
export { authorizeAward, confirm, POINT_AWARD_IDENTIFIER_NAME, publishConfirmationNumberIfNotExist, publishOrderNumberIfNotExist, start, voidAward };
|