@chevre/domain 21.2.0-alpha.50 → 21.2.0-alpha.52
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.
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const actions = <chevre.factory.action.transfer.send.message.email.IAction[]>await actionRepo.search(
|
|
13
|
+
{
|
|
14
|
+
limit: 1000,
|
|
15
|
+
page: 1,
|
|
16
|
+
typeOf: { $eq: chevre.factory.actionType.SendAction },
|
|
17
|
+
object: {
|
|
18
|
+
typeOf: { $eq: chevre.factory.creativeWorkType.EmailMessage }
|
|
19
|
+
}
|
|
20
|
+
// startFrom: moment()
|
|
21
|
+
// .add(-20, 'days')
|
|
22
|
+
// .toDate(),
|
|
23
|
+
// startThrough: moment()
|
|
24
|
+
// .add(-19, 'days')
|
|
25
|
+
// .toDate(),
|
|
26
|
+
},
|
|
27
|
+
['project', '_id', 'object', 'purpose'],
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
const maxLenght = Math.max(...actions.map((action) => {
|
|
31
|
+
return (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
|
|
32
|
+
}));
|
|
33
|
+
actions.forEach((action) => {
|
|
34
|
+
const length = (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
|
|
35
|
+
if (typeof length !== 'number') {
|
|
36
|
+
throw new Error(`${action.project.id},${action.id},${action.purpose?.typeOf},${action.purpose?.orderNumber},${action.object.text?.length}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
console.log('maxLenght:', maxLenght);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main()
|
|
43
|
+
.then(console.log)
|
|
44
|
+
.catch(console.error);
|
|
@@ -18,7 +18,14 @@ const factory = require("../../factory");
|
|
|
18
18
|
*/
|
|
19
19
|
function deleteOrder(params) {
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const
|
|
21
|
+
const orders = yield repos.order.search({
|
|
22
|
+
orderNumbers: [params.object.orderNumber]
|
|
23
|
+
});
|
|
24
|
+
const order = orders.shift();
|
|
25
|
+
if (order === undefined) {
|
|
26
|
+
// すでに削除済
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
22
29
|
// 注文アイテムの予約を削除
|
|
23
30
|
yield deleteReservationsByOrder(order)(repos);
|
|
24
31
|
// 所有権削除
|
|
@@ -119,23 +119,30 @@ exports.exportTasks = exportTasks;
|
|
|
119
119
|
* 取引に関わるリソースを削除する
|
|
120
120
|
* 冪等性を確保すること
|
|
121
121
|
*/
|
|
122
|
+
// tslint:disable-next-line:max-func-body-length
|
|
122
123
|
function deleteTransaction(params) {
|
|
124
|
+
// tslint:disable-next-line:max-func-body-length
|
|
123
125
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
const transactions = yield repos.transaction.search({
|
|
127
|
+
ids: [params.object.id],
|
|
128
|
+
typeOf: params.object.typeOf,
|
|
129
|
+
inclusion: [],
|
|
130
|
+
exclusion: []
|
|
131
|
+
});
|
|
132
|
+
const transaction = transactions.shift();
|
|
133
|
+
if (transaction === undefined) {
|
|
134
|
+
// すでに削除済
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
126
137
|
// DeleteTransactionアクションを作成(logとしての意味合いも含めて)
|
|
127
138
|
const actionAttributes = {
|
|
128
139
|
typeOf: factory.actionType.DeleteAction,
|
|
129
140
|
project: transaction.project,
|
|
130
|
-
object:
|
|
131
|
-
agent:
|
|
132
|
-
typeOf: transaction.seller.typeOf,
|
|
133
|
-
id: transaction.seller.id,
|
|
134
|
-
name: (typeof transaction.seller.name === 'string')
|
|
135
|
-
? transaction.seller.name
|
|
136
|
-
: String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
|
|
137
|
-
}
|
|
141
|
+
object: params.object,
|
|
142
|
+
agent: transaction.project
|
|
138
143
|
};
|
|
144
|
+
let deletePayTransactionResult;
|
|
145
|
+
let payTransactionNumbers = [];
|
|
139
146
|
let deleteReservationsResult;
|
|
140
147
|
let deleteReserveTransactionResult;
|
|
141
148
|
let deletedReservationNumbers = [];
|
|
@@ -150,13 +157,15 @@ function deleteTransaction(params) {
|
|
|
150
157
|
case factory.transactionStatusType.Expired:
|
|
151
158
|
// tslint:disable-next-line:no-suspicious-comment
|
|
152
159
|
// TODO サービス登録取引を削除
|
|
153
|
-
//
|
|
154
|
-
|
|
160
|
+
// 決済取引を削除
|
|
161
|
+
const deletePayTransactionsByPlaceOrderResult = yield deletePayTransactionsByPlaceOrder({ transaction })(repos);
|
|
162
|
+
deletePayTransactionResult = deletePayTransactionsByPlaceOrderResult.deletePayTransactionResult;
|
|
163
|
+
payTransactionNumbers = deletePayTransactionsByPlaceOrderResult.payTransactionNumbers;
|
|
155
164
|
// 取引上での予約を削除
|
|
156
|
-
const
|
|
157
|
-
deleteReservationsResult =
|
|
158
|
-
deleteReserveTransactionResult =
|
|
159
|
-
deletedReservationNumbers =
|
|
165
|
+
const deleteReservationsByPlaceOrderResult = yield deleteReservationsByPlaceOrder({ transaction })(repos);
|
|
166
|
+
deleteReservationsResult = deleteReservationsByPlaceOrderResult.deleteResult;
|
|
167
|
+
deleteReserveTransactionResult = deleteReservationsByPlaceOrderResult.deleteReserveTransactionResult;
|
|
168
|
+
deletedReservationNumbers = deleteReservationsByPlaceOrderResult.reserveTransactionNumbers;
|
|
160
169
|
break;
|
|
161
170
|
case factory.transactionStatusType.Confirmed:
|
|
162
171
|
// no op
|
|
@@ -165,8 +174,6 @@ function deleteTransaction(params) {
|
|
|
165
174
|
}
|
|
166
175
|
// 取引削除
|
|
167
176
|
yield repos.transaction.findByIdAndDelete({ id: transaction.id });
|
|
168
|
-
// await repos.transaction.transactionModel.findByIdAndDelete(transaction.id)
|
|
169
|
-
// .exec();
|
|
170
177
|
break;
|
|
171
178
|
// implemented(2022-06-09~)
|
|
172
179
|
case factory.transactionType.ReturnOrder:
|
|
@@ -195,6 +202,8 @@ function deleteTransaction(params) {
|
|
|
195
202
|
}
|
|
196
203
|
// アクション完了
|
|
197
204
|
const actionResult = {
|
|
205
|
+
deletePayTransactionResult,
|
|
206
|
+
payTransactionNumbers,
|
|
198
207
|
deleteReservationsResult,
|
|
199
208
|
deleteReserveTransactionResult,
|
|
200
209
|
deletedReservationNumbers
|
|
@@ -203,7 +212,7 @@ function deleteTransaction(params) {
|
|
|
203
212
|
});
|
|
204
213
|
}
|
|
205
214
|
exports.deleteTransaction = deleteTransaction;
|
|
206
|
-
function
|
|
215
|
+
function deleteReservationsByPlaceOrder(params) {
|
|
207
216
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
208
217
|
let deleteResult;
|
|
209
218
|
let deleteReserveTransactionResult;
|
|
@@ -252,3 +261,40 @@ function deleteReservationsByTransaction(params) {
|
|
|
252
261
|
return { deleteResult, deleteReserveTransactionResult, reserveTransactionNumbers };
|
|
253
262
|
});
|
|
254
263
|
}
|
|
264
|
+
function deletePayTransactionsByPlaceOrder(params) {
|
|
265
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
let deletePayTransactionResult;
|
|
267
|
+
// 取引に対する全ての承認アクションを検索
|
|
268
|
+
const authorizeActions = yield repos.action.searchByPurpose({
|
|
269
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
270
|
+
purpose: {
|
|
271
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
272
|
+
id: params.transaction.id
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
// 決済取引番号を抽出
|
|
276
|
+
const authorizePaymentActions = authorizeActions
|
|
277
|
+
.filter((a) => {
|
|
278
|
+
var _a;
|
|
279
|
+
const pendingTransactionNumber = (_a = a.object) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
|
|
280
|
+
return a.object.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
281
|
+
&& typeof pendingTransactionNumber === 'string'
|
|
282
|
+
&& pendingTransactionNumber.length > 0;
|
|
283
|
+
});
|
|
284
|
+
const payTransactionNumbers = authorizePaymentActions.map((a) => String(a.object.paymentMethodId));
|
|
285
|
+
if (payTransactionNumbers.length > 0) {
|
|
286
|
+
// 決済取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
287
|
+
const deleteAssetTransactionsResult = yield repos.assetTransaction.deleteByTransactionNumber({
|
|
288
|
+
project: { id: params.transaction.project.id },
|
|
289
|
+
transactionNumbers: payTransactionNumbers,
|
|
290
|
+
typeOf: factory.assetTransactionType.Pay
|
|
291
|
+
});
|
|
292
|
+
deletePayTransactionResult = {
|
|
293
|
+
n: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.n,
|
|
294
|
+
ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
|
|
295
|
+
deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return { deletePayTransactionResult, payTransactionNumbers };
|
|
299
|
+
});
|
|
300
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.1",
|
|
13
13
|
"@cinerino/sdk": "3.156.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.52"
|
|
121
121
|
}
|