@chevre/domain 21.20.0-alpha.2 → 21.20.0-alpha.20
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/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- 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/processAcceptOffer.ts +48 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
- package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
- package/lib/chevre/repo/acceptedOffer.js +32 -2
- package/lib/chevre/repo/action.d.ts +3 -3
- package/lib/chevre/repo/action.js +4 -6
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
- package/lib/chevre/repo/order.js +28 -9
- package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
- package/lib/chevre/repo/orderInTransaction.js +77 -0
- package/lib/chevre/repo/task.d.ts +0 -2
- package/lib/chevre/repo/task.js +56 -46
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- 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 +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/any.d.ts +29 -0
- package/lib/chevre/service/offer/any.js +55 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +11 -0
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +12 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
- package/lib/chevre/service/offer/eventServiceByCOA.js +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +18 -12
- 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 +2 -0
- package/lib/chevre/service/order/placeOrder.js +28 -29
- 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 +68 -30
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard.js +102 -133
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- 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 +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- 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/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- 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 +1 -1
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
package/lib/chevre/repo/order.js
CHANGED
|
@@ -24,7 +24,9 @@ class MongoRepository {
|
|
|
24
24
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
25
25
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
26
26
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
27
|
-
const andConditions = [
|
|
27
|
+
const andConditions = [
|
|
28
|
+
{ typeOf: { $eq: factory.order.OrderType.Order } }
|
|
29
|
+
];
|
|
28
30
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
29
31
|
if (typeof projectIdEq === 'string') {
|
|
30
32
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
@@ -663,7 +665,13 @@ class MongoRepository {
|
|
|
663
665
|
createIfNotExist(order) {
|
|
664
666
|
return __awaiter(this, void 0, void 0, function* () {
|
|
665
667
|
try {
|
|
666
|
-
|
|
668
|
+
// 存在しなければ上書き
|
|
669
|
+
// updateOneに変更(2024-01-14~)
|
|
670
|
+
// await this.orderModel.findOneAndUpdate(
|
|
671
|
+
yield this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
|
|
672
|
+
// new: true,
|
|
673
|
+
upsert: true
|
|
674
|
+
})
|
|
667
675
|
.exec();
|
|
668
676
|
}
|
|
669
677
|
catch (error) {
|
|
@@ -688,7 +696,8 @@ class MongoRepository {
|
|
|
688
696
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
689
697
|
orderNumber: { $eq: params.orderNumber },
|
|
690
698
|
orderStatus: { $eq: params.previousOrderStatus },
|
|
691
|
-
'project.id': { $eq: params.project.id }
|
|
699
|
+
'project.id': { $eq: params.project.id },
|
|
700
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
692
701
|
}, {
|
|
693
702
|
previousOrderStatus: params.previousOrderStatus,
|
|
694
703
|
orderStatus: params.orderStatus
|
|
@@ -735,7 +744,8 @@ class MongoRepository {
|
|
|
735
744
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
736
745
|
orderNumber: { $eq: params.orderNumber },
|
|
737
746
|
orderStatus: { $eq: factory.orderStatus.OrderDelivered },
|
|
738
|
-
'project.id': { $eq: params.project.id }
|
|
747
|
+
'project.id': { $eq: params.project.id },
|
|
748
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
739
749
|
}, {
|
|
740
750
|
previousOrderStatus: factory.orderStatus.OrderDelivered,
|
|
741
751
|
orderStatus: factory.orderStatus.OrderReturned,
|
|
@@ -785,7 +795,8 @@ class MongoRepository {
|
|
|
785
795
|
return __awaiter(this, void 0, void 0, function* () {
|
|
786
796
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
787
797
|
orderNumber: { $eq: params.orderNumber },
|
|
788
|
-
'project.id': { $eq: params.project.id }
|
|
798
|
+
'project.id': { $eq: params.project.id },
|
|
799
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
789
800
|
}, {
|
|
790
801
|
$set: Object.assign(Object.assign({}, (Array.isArray(params.additionalProperty)) ? { additionalProperty: params.additionalProperty } : undefined), (typeof params.name === 'string') ? { name: params.name } : undefined)
|
|
791
802
|
}, {
|
|
@@ -810,6 +821,7 @@ class MongoRepository {
|
|
|
810
821
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
811
822
|
orderNumber: { $eq: params.orderNumber },
|
|
812
823
|
'project.id': { $eq: params.project.id },
|
|
824
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
813
825
|
'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
|
|
814
826
|
}, {
|
|
815
827
|
$set: {
|
|
@@ -854,7 +866,10 @@ class MongoRepository {
|
|
|
854
866
|
});
|
|
855
867
|
}
|
|
856
868
|
}
|
|
857
|
-
const doc = yield this.orderModel.
|
|
869
|
+
const doc = yield this.orderModel.findOne({
|
|
870
|
+
_id: params.id,
|
|
871
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
872
|
+
}, projection)
|
|
858
873
|
.exec();
|
|
859
874
|
if (doc === null) {
|
|
860
875
|
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
@@ -890,7 +905,8 @@ class MongoRepository {
|
|
|
890
905
|
}
|
|
891
906
|
const doc = yield this.orderModel.findOne({
|
|
892
907
|
orderNumber: { $eq: params.orderNumber },
|
|
893
|
-
'project.id': { $eq: params.project.id }
|
|
908
|
+
'project.id': { $eq: params.project.id },
|
|
909
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
894
910
|
}, projection)
|
|
895
911
|
.exec();
|
|
896
912
|
if (doc === null) {
|
|
@@ -908,7 +924,7 @@ class MongoRepository {
|
|
|
908
924
|
orderNumber: 1,
|
|
909
925
|
_id: 0
|
|
910
926
|
};
|
|
911
|
-
const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, acceptedOffers: {
|
|
927
|
+
const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, typeOf: { $eq: factory.order.OrderType.Order }, acceptedOffers: {
|
|
912
928
|
$elemMatch: {
|
|
913
929
|
'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
|
|
914
930
|
'itemOffered.id': { $eq: params.reservationId }
|
|
@@ -928,7 +944,10 @@ class MongoRepository {
|
|
|
928
944
|
*/
|
|
929
945
|
deleteByOrderNumber(params) {
|
|
930
946
|
return __awaiter(this, void 0, void 0, function* () {
|
|
931
|
-
yield this.orderModel.deleteOne({
|
|
947
|
+
yield this.orderModel.deleteOne({
|
|
948
|
+
orderNumber: params.orderNumber,
|
|
949
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
950
|
+
})
|
|
932
951
|
.exec();
|
|
933
952
|
});
|
|
934
953
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'> & {
|
|
4
|
+
typeOf: factory.transactionType.PlaceOrder;
|
|
5
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 取引中注文リポジトリ
|
|
9
|
+
*/
|
|
10
|
+
export declare class MongoRepository {
|
|
11
|
+
private readonly orderModel;
|
|
12
|
+
constructor(connection: Connection);
|
|
13
|
+
/**
|
|
14
|
+
* 注文を受注する
|
|
15
|
+
*/
|
|
16
|
+
placeOrder(order: factory.order.IOrder): Promise<void>;
|
|
17
|
+
acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongodb").UpdateResult | undefined>;
|
|
18
|
+
voidAcceptedOfferByReservationNumber(params: {
|
|
19
|
+
orderNumber: string;
|
|
20
|
+
acceptedOffers: {
|
|
21
|
+
reservationNumber: {
|
|
22
|
+
$in: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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.MongoRepository = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
14
|
+
const order_1 = require("./mongoose/schemas/order");
|
|
15
|
+
/**
|
|
16
|
+
* 取引中注文リポジトリ
|
|
17
|
+
*/
|
|
18
|
+
class MongoRepository {
|
|
19
|
+
constructor(connection) {
|
|
20
|
+
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 注文を受注する
|
|
24
|
+
*/
|
|
25
|
+
placeOrder(order) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
// typeOf:PlaceOrderのドキュメントが存在すれば、typeOf:Orderに変更する
|
|
28
|
+
yield this.orderModel.updateOne({
|
|
29
|
+
orderNumber: { $eq: order.orderNumber },
|
|
30
|
+
typeOf: { $eq: factory.transactionType.PlaceOrder }
|
|
31
|
+
}, { $set: order }, {})
|
|
32
|
+
.exec();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
acceptOffer(params) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (!Array.isArray(params.acceptedOffers) || params.acceptedOffers.length === 0) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return this.orderModel.updateOne({
|
|
41
|
+
typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
42
|
+
orderNumber: { $eq: params.orderNumber }
|
|
43
|
+
}, {
|
|
44
|
+
$setOnInsert: {
|
|
45
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
46
|
+
orderNumber: params.orderNumber,
|
|
47
|
+
project: params.project
|
|
48
|
+
},
|
|
49
|
+
$push: {
|
|
50
|
+
acceptedOffers: {
|
|
51
|
+
$each: params.acceptedOffers
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, { upsert: true })
|
|
55
|
+
.exec();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
voidAcceptedOfferByReservationNumber(params) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return this.orderModel.updateOne({
|
|
61
|
+
typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
62
|
+
orderNumber: { $eq: params.orderNumber }
|
|
63
|
+
}, {
|
|
64
|
+
$pull: {
|
|
65
|
+
acceptedOffers: {
|
|
66
|
+
'itemOffered.reservationNumber': {
|
|
67
|
+
$exists: true,
|
|
68
|
+
$in: params.acceptedOffers.reservationNumber.$in
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
.exec();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -39,9 +39,7 @@ export declare class MongoRepository {
|
|
|
39
39
|
* 取引削除タスク冪等作成
|
|
40
40
|
*/
|
|
41
41
|
createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
42
|
-
createConfirmReserveTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
43
42
|
createOnAssetTransactionStatusChangedTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.OnAssetTransactionStatusChanged>, options: IOptionOnCreate): Promise<void>;
|
|
44
|
-
createSendOrderTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.SendOrder>, options: IOptionOnCreate): Promise<void>;
|
|
45
43
|
executeById(params: {
|
|
46
44
|
id: string;
|
|
47
45
|
executor: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -243,31 +243,36 @@ class MongoRepository {
|
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
createConfirmReserveTransactionTaskIfNotExist(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
246
|
+
// public async createConfirmReserveTransactionTaskIfNotExist(
|
|
247
|
+
// params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>,
|
|
248
|
+
// options: IOptionOnCreate
|
|
249
|
+
// ): Promise<void> {
|
|
250
|
+
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
251
|
+
// {
|
|
252
|
+
// 'project.id': { $eq: params.project.id },
|
|
253
|
+
// name: { $eq: params.name },
|
|
254
|
+
// 'data.object.transactionNumber': {
|
|
255
|
+
// $exists: true,
|
|
256
|
+
// $eq: String(params.data.object.transactionNumber)
|
|
257
|
+
// },
|
|
258
|
+
// 'data.purpose.orderNumber': {
|
|
259
|
+
// $exists: true,
|
|
260
|
+
// $eq: String(params.data.purpose.orderNumber)
|
|
261
|
+
// }
|
|
262
|
+
// },
|
|
263
|
+
// { $setOnInsert: params },
|
|
264
|
+
// { new: true, upsert: true }
|
|
265
|
+
// )
|
|
266
|
+
// .select({ _id: 1 })
|
|
267
|
+
// .exec();
|
|
268
|
+
// if (options.emitImmediately) {
|
|
269
|
+
// taskEventEmitter.emitTaskStatusChanged({
|
|
270
|
+
// id: createdTask.id,
|
|
271
|
+
// name: params.name,
|
|
272
|
+
// status: factory.taskStatus.Ready
|
|
273
|
+
// });
|
|
274
|
+
// }
|
|
275
|
+
// }
|
|
271
276
|
createOnAssetTransactionStatusChangedTaskIfNotExist(params, options) {
|
|
272
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
278
|
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
@@ -293,27 +298,32 @@ class MongoRepository {
|
|
|
293
298
|
}
|
|
294
299
|
});
|
|
295
300
|
}
|
|
296
|
-
createSendOrderTaskIfNotExist(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
301
|
+
// public async createSendOrderTaskIfNotExist(
|
|
302
|
+
// params: factory.task.IAttributes<factory.taskName.SendOrder>,
|
|
303
|
+
// options: IOptionOnCreate
|
|
304
|
+
// ): Promise<void> {
|
|
305
|
+
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
306
|
+
// {
|
|
307
|
+
// 'project.id': { $eq: params.project.id },
|
|
308
|
+
// name: { $eq: params.name },
|
|
309
|
+
// 'data.object.orderNumber': {
|
|
310
|
+
// $exists: true,
|
|
311
|
+
// $eq: String(params.data.object.orderNumber)
|
|
312
|
+
// }
|
|
313
|
+
// },
|
|
314
|
+
// { $setOnInsert: params },
|
|
315
|
+
// { new: true, upsert: true }
|
|
316
|
+
// )
|
|
317
|
+
// .select({ _id: 1 })
|
|
318
|
+
// .exec();
|
|
319
|
+
// if (options.emitImmediately) {
|
|
320
|
+
// taskEventEmitter.emitTaskStatusChanged({
|
|
321
|
+
// id: createdTask.id,
|
|
322
|
+
// name: params.name,
|
|
323
|
+
// status: factory.taskStatus.Ready
|
|
324
|
+
// });
|
|
325
|
+
// }
|
|
326
|
+
// }
|
|
317
327
|
// public async createOnOrderPaymentCompletedTaskIfNotExist(
|
|
318
328
|
// params: factory.task.IAttributes<factory.taskName.OnOrderPaymentCompleted>,
|
|
319
329
|
// options: IOptionOnCreate
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
-
type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
|
|
27
|
+
type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
|
|
28
28
|
interface IAggregationByStatus {
|
|
29
29
|
transactionCount: number;
|
|
30
30
|
avgDuration: number;
|
|
@@ -25,6 +25,7 @@ import type { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
|
|
|
25
25
|
import type { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalogItem';
|
|
26
26
|
import type { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
27
27
|
import type { MongoRepository as OrderRepo } from './repo/order';
|
|
28
|
+
import type { MongoRepository as OrderInTransactionRepo } from './repo/orderInTransaction';
|
|
28
29
|
import type { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
29
30
|
import type { MongoRepository as PaymentServiceRepo } from './repo/paymentService';
|
|
30
31
|
import type { MongoRepository as PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
|
|
@@ -152,6 +153,10 @@ export type Order = OrderRepo;
|
|
|
152
153
|
export declare namespace Order {
|
|
153
154
|
function createInstance(...params: ConstructorParameters<typeof OrderRepo>): Promise<OrderRepo>;
|
|
154
155
|
}
|
|
156
|
+
export type OrderInTransaction = OrderInTransactionRepo;
|
|
157
|
+
export declare namespace OrderInTransaction {
|
|
158
|
+
function createInstance(...params: ConstructorParameters<typeof OrderInTransactionRepo>): Promise<OrderInTransactionRepo>;
|
|
159
|
+
}
|
|
155
160
|
export type OrderNumber = OrderNumberRepo;
|
|
156
161
|
export declare namespace OrderNumber {
|
|
157
162
|
function createInstance(...params: ConstructorParameters<typeof OrderNumberRepo>): Promise<OrderNumberRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.rateLimit = void 0;
|
|
12
|
+
exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -336,6 +336,19 @@ var Order;
|
|
|
336
336
|
}
|
|
337
337
|
Order.createInstance = createInstance;
|
|
338
338
|
})(Order = exports.Order || (exports.Order = {}));
|
|
339
|
+
var OrderInTransaction;
|
|
340
|
+
(function (OrderInTransaction) {
|
|
341
|
+
let repo;
|
|
342
|
+
function createInstance(...params) {
|
|
343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
+
if (repo === undefined) {
|
|
345
|
+
repo = (yield Promise.resolve().then(() => require('./repo/orderInTransaction'))).MongoRepository;
|
|
346
|
+
}
|
|
347
|
+
return new repo(...params);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
OrderInTransaction.createInstance = createInstance;
|
|
351
|
+
})(OrderInTransaction = exports.OrderInTransaction || (exports.OrderInTransaction = {}));
|
|
339
352
|
var OrderNumber;
|
|
340
353
|
(function (OrderNumber) {
|
|
341
354
|
let repo;
|
|
@@ -13,7 +13,6 @@ import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentSe
|
|
|
13
13
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
14
14
|
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
15
15
|
import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
16
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
17
16
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
18
17
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
19
18
|
import * as CreditCardPayment from '../payment/creditCard';
|
|
@@ -27,17 +26,12 @@ export interface IStartOperationRepos {
|
|
|
27
26
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
28
27
|
person: PersonRepo;
|
|
29
28
|
product: ProductRepo;
|
|
30
|
-
project: ProjectRepo;
|
|
31
29
|
assetTransaction: AssetTransactionRepo;
|
|
32
30
|
task: TaskRepo;
|
|
33
31
|
}
|
|
34
32
|
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
35
33
|
export interface ICancelRepos {
|
|
36
|
-
action: ActionRepo;
|
|
37
|
-
accountingReport: AccountingReportRepo;
|
|
38
34
|
assetTransaction: AssetTransactionRepo;
|
|
39
|
-
project: ProjectRepo;
|
|
40
|
-
task: TaskRepo;
|
|
41
35
|
}
|
|
42
36
|
export type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
|
|
43
37
|
export interface IConfirmRepos {
|
|
@@ -47,7 +41,6 @@ export interface IConfirmRepos {
|
|
|
47
41
|
assetTransaction: AssetTransactionRepo;
|
|
48
42
|
event: EventRepo;
|
|
49
43
|
order: OrderRepo;
|
|
50
|
-
project: ProjectRepo;
|
|
51
44
|
task: TaskRepo;
|
|
52
45
|
}
|
|
53
46
|
export type IConfirmOperation<T> = (repos: IConfirmRepos) => Promise<T>;
|
|
@@ -61,14 +54,12 @@ export type ICheckOperation<T> = (repos: {
|
|
|
61
54
|
paymentAccepted: PaymentAcceptedRepo;
|
|
62
55
|
paymentService: PaymentServiceRepo;
|
|
63
56
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
64
|
-
project: ProjectRepo;
|
|
65
57
|
}) => Promise<T>;
|
|
66
58
|
export type IPublishPaymentUrlOperation<T> = (repos: {
|
|
67
59
|
paymentAccepted: PaymentAcceptedRepo;
|
|
68
60
|
paymentService: PaymentServiceRepo;
|
|
69
61
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
70
62
|
person: PersonRepo;
|
|
71
|
-
project: ProjectRepo;
|
|
72
63
|
}) => Promise<T>;
|
|
73
64
|
export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
74
65
|
accountingReport: AccountingReportRepo;
|
|
@@ -76,7 +67,6 @@ export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
|
76
67
|
paymentAccepted: PaymentAcceptedRepo;
|
|
77
68
|
paymentService: PaymentServiceRepo;
|
|
78
69
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
79
|
-
project: ProjectRepo;
|
|
80
70
|
task: TaskRepo;
|
|
81
71
|
assetTransaction: AssetTransactionRepo;
|
|
82
72
|
}) => Promise<T>;
|
|
@@ -40,7 +40,7 @@ function publishPaymentUrl(params) {
|
|
|
40
40
|
let result;
|
|
41
41
|
switch (paymentServiceType) {
|
|
42
42
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
43
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
|
|
43
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false, processPublishPaymentUrl: true })(repos);
|
|
44
44
|
let paymentUrl;
|
|
45
45
|
// 3DS拡張(2024-01-02~)
|
|
46
46
|
const retUrl = (_c = params.object.paymentMethod.creditCard) === null || _c === void 0 ? void 0 : _c.retUrl;
|
|
@@ -79,7 +79,7 @@ function invalidatePaymentUrl(params) {
|
|
|
79
79
|
const paymentServiceType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
80
80
|
switch (paymentServiceType) {
|
|
81
81
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
82
|
-
yield CreditCardPayment.refundCreditCard(params, false)(repos);
|
|
82
|
+
yield CreditCardPayment.refundCreditCard(params, { requirePayAction: false })(repos);
|
|
83
83
|
break;
|
|
84
84
|
default:
|
|
85
85
|
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
@@ -304,7 +304,7 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
304
304
|
}
|
|
305
305
|
function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
|
|
306
306
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
307
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false, searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
308
308
|
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
309
309
|
: undefined))(repos);
|
|
310
310
|
return saveAuthorizeResult({
|
|
@@ -471,7 +471,7 @@ function exportTasksById(params) {
|
|
|
471
471
|
purpose: {
|
|
472
472
|
confirmationNumber: '',
|
|
473
473
|
orderNumber: '',
|
|
474
|
-
typeOf:
|
|
474
|
+
typeOf: factory.order.OrderType.Order
|
|
475
475
|
},
|
|
476
476
|
useOnOrderStatusChanged: true
|
|
477
477
|
};
|
|
@@ -103,7 +103,7 @@ function verifyToken(params) {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
if (repos.action !== undefined && action !== undefined) {
|
|
106
|
-
yield repos.action.
|
|
106
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
107
107
|
}
|
|
108
108
|
return result;
|
|
109
109
|
});
|
|
@@ -63,7 +63,7 @@ function givePointAward(params) {
|
|
|
63
63
|
}
|
|
64
64
|
// アクション完了
|
|
65
65
|
const actionResult = {};
|
|
66
|
-
yield repos.action.
|
|
66
|
+
yield repos.action.completeWithVoid({ typeOf: params.typeOf, id: action.id, result: actionResult });
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
exports.givePointAward = givePointAward;
|
|
@@ -140,7 +140,7 @@ function returnPointAward(params) {
|
|
|
140
140
|
const actionResult = {
|
|
141
141
|
moneyTransferTransaction: moneyTransferTransactions
|
|
142
142
|
};
|
|
143
|
-
yield repos.action.
|
|
143
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
exports.returnPointAward = returnPointAward;
|
|
@@ -193,7 +193,7 @@ function importFromCOA(params) {
|
|
|
193
193
|
}
|
|
194
194
|
// アクション完了
|
|
195
195
|
const actionResult = { savedScreeningEventsCount, savedScreeningEventSeriesCount };
|
|
196
|
-
yield repos.action.
|
|
196
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
exports.importFromCOA = importFromCOA;
|
|
@@ -807,7 +807,7 @@ function updateEvent4ttts(params) {
|
|
|
807
807
|
throw error;
|
|
808
808
|
}
|
|
809
809
|
// アクション完了
|
|
810
|
-
yield repos.action.
|
|
810
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: event.id } });
|
|
811
811
|
yield (0, offer_1.onEventChanged)({
|
|
812
812
|
id: [event.id],
|
|
813
813
|
project: { id: event.project.id },
|
|
@@ -439,7 +439,7 @@ function moneyTransfer(params) {
|
|
|
439
439
|
throw error;
|
|
440
440
|
}
|
|
441
441
|
const actionResult = {};
|
|
442
|
-
yield repos.action.
|
|
442
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
exports.moneyTransfer = moneyTransfer;
|
|
@@ -11,14 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.triggerWebhook = exports.report2developers = exports.sendEmailMessage = void 0;
|
|
13
13
|
const sgMail = require("@sendgrid/mail");
|
|
14
|
-
const createDebug = require("debug");
|
|
15
14
|
const http_status_1 = require("http-status");
|
|
16
15
|
const request = require("request");
|
|
17
16
|
const util = require("util");
|
|
18
17
|
const credentials_1 = require("../credentials");
|
|
19
18
|
const settings_1 = require("../settings");
|
|
20
19
|
const factory = require("../factory");
|
|
21
|
-
const debug = createDebug('chevre-domain:service');
|
|
22
20
|
/**
|
|
23
21
|
* Eメールメッセージを送信する
|
|
24
22
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
@@ -110,8 +108,7 @@ function sendEmailMessage(params) {
|
|
|
110
108
|
throw error;
|
|
111
109
|
}
|
|
112
110
|
// アクション完了
|
|
113
|
-
|
|
114
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
111
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
115
112
|
});
|
|
116
113
|
}
|
|
117
114
|
exports.sendEmailMessage = sendEmailMessage;
|
|
@@ -365,6 +362,6 @@ function processInformAction(params) {
|
|
|
365
362
|
throw error;
|
|
366
363
|
}
|
|
367
364
|
}
|
|
368
|
-
yield repos.action.
|
|
365
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
369
366
|
});
|
|
370
367
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
3
|
+
import type { RedisRepository as OrderNumberRepo } from '../../repo/orderNumber';
|
|
4
|
+
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
5
|
+
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
|
+
interface IAcceptOfferOperationRepos {
|
|
7
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
8
|
+
orderNumber: OrderNumberRepo;
|
|
9
|
+
project: ProjectRepo;
|
|
10
|
+
transaction: TransactionRepo;
|
|
11
|
+
}
|
|
12
|
+
type IAcceptOfferOperation<T> = (repos: IAcceptOfferOperationRepos) => Promise<T>;
|
|
13
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
|
|
14
|
+
export declare function acceptOffer(params: {
|
|
15
|
+
project: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
purpose: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
22
|
+
}): IAcceptOfferOperation<void>;
|
|
23
|
+
export declare function voidAcceptedOffer(params: {
|
|
24
|
+
authorizeActions: IAuthorizeOfferAction[];
|
|
25
|
+
orderNumber: string;
|
|
26
|
+
}): (repos: {
|
|
27
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
export {};
|