@chevre/domain 22.7.0-alpha.21 → 22.7.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/service/order/deleteOrder.d.ts +4 -0
- package/lib/chevre/service/order/deleteOrder.js +47 -5
- package/lib/chevre/service/task/deletePerson.js +31 -30
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ import type { NoteRepo } from '../../repo/note';
|
|
|
5
5
|
import type { OrderRepo } from '../../repo/order';
|
|
6
6
|
import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
7
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
8
|
+
import type { SettingRepo } from '../../repo/setting';
|
|
9
|
+
import type { TaskRepo } from '../../repo/task';
|
|
8
10
|
import * as factory from '../../factory';
|
|
9
11
|
/**
|
|
10
12
|
* 注文に関わるリソースを削除する
|
|
@@ -20,5 +22,7 @@ declare function deleteOrder(params: {
|
|
|
20
22
|
order: OrderRepo;
|
|
21
23
|
ownershipInfo: OwnershipInfoRepo;
|
|
22
24
|
reservation: ReservationRepo;
|
|
25
|
+
setting: SettingRepo;
|
|
26
|
+
task: TaskRepo;
|
|
23
27
|
}) => Promise<void>;
|
|
24
28
|
export { deleteOrder };
|
|
@@ -22,7 +22,7 @@ function deleteOrder(params) {
|
|
|
22
22
|
limit: 1,
|
|
23
23
|
page: 1,
|
|
24
24
|
orderNumbers: [params.object.orderNumber]
|
|
25
|
-
}, { inclusion: ['orderDate', 'project', 'customer', 'orderNumber', 'seller'] });
|
|
25
|
+
}, { inclusion: ['orderDate', 'project', 'customer', 'orderNumber', 'seller', 'broker'] });
|
|
26
26
|
const order = orders.shift();
|
|
27
27
|
if (order === undefined) {
|
|
28
28
|
// すでに削除済
|
|
@@ -50,15 +50,57 @@ function deleteOrder(params) {
|
|
|
50
50
|
typeOf: factory.order.OrderType.Order
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
// await deleteEventsByOrder(order)(repos);
|
|
56
|
-
// }
|
|
53
|
+
// deletePerson(2024-12-25~)
|
|
54
|
+
yield deletePersonIfNecessary(order)(repos);
|
|
57
55
|
// 注文削除
|
|
58
56
|
yield repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
exports.deleteOrder = deleteOrder;
|
|
60
|
+
function deletePersonIfNecessary(order) {
|
|
61
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
// 代理注文を除く
|
|
64
|
+
if (order.customer.typeOf === factory.personType.Person
|
|
65
|
+
&& typeof ((_a = order.broker) === null || _a === void 0 ? void 0 : _a.typeOf) !== 'string') {
|
|
66
|
+
const ordersByPerson = yield repos.order.projectFields({
|
|
67
|
+
limit: 1,
|
|
68
|
+
page: 1,
|
|
69
|
+
customer: { ids: [order.customer.id] }
|
|
70
|
+
}, { inclusion: ['orderNumber'] });
|
|
71
|
+
if (ordersByPerson.length === 0) {
|
|
72
|
+
const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
73
|
+
if (typeof (setting === null || setting === void 0 ? void 0 : setting.userPoolIdNew) !== 'string') {
|
|
74
|
+
throw new factory.errors.NotFound('setting.userPoolIdNew');
|
|
75
|
+
}
|
|
76
|
+
const deletePersonTask = {
|
|
77
|
+
project: { typeOf: factory.organizationType.Project, id: order.project.id },
|
|
78
|
+
name: factory.taskName.DeletePerson,
|
|
79
|
+
status: factory.taskStatus.Ready,
|
|
80
|
+
runsAt: new Date(),
|
|
81
|
+
remainingNumberOfTries: 10,
|
|
82
|
+
numberOfTried: 0,
|
|
83
|
+
executionResults: [],
|
|
84
|
+
data: {
|
|
85
|
+
id: order.customer.id,
|
|
86
|
+
agent: {
|
|
87
|
+
id: order.project.id,
|
|
88
|
+
typeOf: factory.organizationType.Project,
|
|
89
|
+
name: factory.organizationType.Project
|
|
90
|
+
},
|
|
91
|
+
physically: true,
|
|
92
|
+
userPoolId: setting.userPoolIdNew,
|
|
93
|
+
project: { id: order.project.id },
|
|
94
|
+
migrate: false,
|
|
95
|
+
useUsernameAsGMOMemberId: false,
|
|
96
|
+
executeBackground: true
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
yield repos.task.saveMany([deletePersonTask], { emitImmediately: true });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
62
104
|
function deleteReservationsByOrder(order) {
|
|
63
105
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
64
106
|
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
@@ -56,23 +56,26 @@ function call(params) {
|
|
|
56
56
|
cognitoIdentityServiceProvider
|
|
57
57
|
});
|
|
58
58
|
const paymentServiceRepo = new paymentService_1.PaymentServiceRepo(connection);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
let creditCardRepo;
|
|
60
|
+
if (params.data.useUsernameAsGMOMemberId === true) {
|
|
61
|
+
const credentials = yield getCreditCardPaymentServiceChannel({
|
|
62
|
+
project: { id: params.project.id },
|
|
63
|
+
paymentMethodType: DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD
|
|
64
|
+
})({ paymentService: paymentServiceRepo });
|
|
65
|
+
creditCardRepo = new creditCard_1.CreditCardRepo({
|
|
66
|
+
siteId: credentials.siteId,
|
|
67
|
+
sitePass: credentials.sitePass,
|
|
68
|
+
cardService: new GMO.service.Card({
|
|
69
|
+
endpoint: credentials.endpoint,
|
|
70
|
+
useFetch: settings.gmo.useFetch
|
|
71
|
+
}, {
|
|
72
|
+
timeout: (params.data.executeBackground)
|
|
73
|
+
? settings.gmo.timeout
|
|
74
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
75
|
+
: 20000 // cronで実行の場合は長めに(2024-10-05~)
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
76
79
|
yield deleteById(params.data, setting)({
|
|
77
80
|
account: new account_1.AccountRepo(connection),
|
|
78
81
|
action: new action_1.ActionRepo(connection),
|
|
@@ -133,17 +136,17 @@ function deleteById(params, setting) {
|
|
|
133
136
|
existingPeople = yield repos.newPerson.search({ id: params.id });
|
|
134
137
|
debug('admin:people:deleteById: existingPeople:', JSON.stringify(existingPeople));
|
|
135
138
|
if (existingPeople.length > 0) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
if (repos.creditCard !== undefined) {
|
|
140
|
+
// クレジットカード削除
|
|
141
|
+
yield deleteCreditCardsById({
|
|
142
|
+
id: params.id,
|
|
143
|
+
useUsernameAsGMOMemberId: params.useUsernameAsGMOMemberId
|
|
144
|
+
}, setting)({
|
|
145
|
+
person: repos.newPerson,
|
|
146
|
+
creditCard: repos.creditCard,
|
|
147
|
+
cognitoIdentityServiceProvider: repos.cognitoIdentityServiceProvider
|
|
148
|
+
});
|
|
144
149
|
}
|
|
145
|
-
// settings
|
|
146
|
-
);
|
|
147
150
|
}
|
|
148
151
|
// 所有権削除
|
|
149
152
|
debug('admin:people:deleteById: deleteOwnershipInfosById processing... personId:', params.id);
|
|
@@ -375,9 +378,7 @@ function sleep(waitTime) {
|
|
|
375
378
|
const DELETE_CREDIT_CARD_MAX_RETRY_COUNT = 2;
|
|
376
379
|
const DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS = 1000;
|
|
377
380
|
function deleteCreditCardsById(params, setting) {
|
|
378
|
-
return (repos
|
|
379
|
-
// settings: Settings
|
|
380
|
-
) => __awaiter(this, void 0, void 0, function* () {
|
|
381
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
381
382
|
let retry = true;
|
|
382
383
|
let numberOfTry = 0;
|
|
383
384
|
while (numberOfTry >= 0) {
|
|
@@ -20,6 +20,7 @@ const note_1 = require("../../repo/note");
|
|
|
20
20
|
const order_1 = require("../../repo/order");
|
|
21
21
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
22
22
|
const reservation_1 = require("../../repo/reservation");
|
|
23
|
+
const setting_1 = require("../../repo/setting");
|
|
23
24
|
const task_1 = require("../../repo/task");
|
|
24
25
|
const transaction_1 = require("../../repo/transaction");
|
|
25
26
|
const TransactionService = require("../transaction");
|
|
@@ -39,6 +40,7 @@ function call(data) {
|
|
|
39
40
|
order: new order_1.OrderRepo(connection),
|
|
40
41
|
ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
|
|
41
42
|
reservation: new reservation_1.ReservationRepo(connection),
|
|
43
|
+
setting: new setting_1.SettingRepo(connection),
|
|
42
44
|
task: new task_1.TaskRepo(connection),
|
|
43
45
|
transaction: new transaction_1.TransactionRepo(connection)
|
|
44
46
|
});
|
|
@@ -9,6 +9,7 @@ import type { NoteRepo } from '../../repo/note';
|
|
|
9
9
|
import type { OrderRepo } from '../../repo/order';
|
|
10
10
|
import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
11
11
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
12
|
+
import type { SettingRepo } from '../../repo/setting';
|
|
12
13
|
import type { TaskRepo } from '../../repo/task';
|
|
13
14
|
import type { TransactionRepo } from '../../repo/transaction';
|
|
14
15
|
/**
|
|
@@ -26,6 +27,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
|
|
|
26
27
|
order: OrderRepo;
|
|
27
28
|
ownershipInfo: OwnershipInfoRepo;
|
|
28
29
|
reservation: ReservationRepo;
|
|
30
|
+
setting: SettingRepo;
|
|
29
31
|
task: TaskRepo;
|
|
30
32
|
transaction: TransactionRepo;
|
|
31
33
|
}) => Promise<void>;
|
package/package.json
CHANGED