@chevre/domain 25.0.0-alpha.20 → 25.0.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/repo/message.d.ts +7 -3
- package/lib/chevre/repo/message.js +13 -59
- package/lib/chevre/repo/mongoose/schemas/message.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.js +51 -50
- package/lib/chevre/repo/order.d.ts +1 -8
- package/lib/chevre/repo/order.js +24 -13
- package/lib/chevre/repo/orderInTransaction.d.ts +1 -2
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/transaction/placeOrder.d.ts +1 -6
- package/lib/chevre/repo/transaction/placeOrder.js +25 -16
- package/lib/chevre/service/order/deleteOrder.d.ts +6 -10
- package/lib/chevre/service/order/deleteOrder.js +7 -48
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +0 -8
- package/lib/chevre/service/taskHandler.js +0 -1
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +8 -14
- package/lib/chevre/service/transaction/deleteTransaction.js +11 -117
- package/lib/chevre/service/transaction/placeOrder/confirm.js +4 -1
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.d.ts +4 -1
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.js +37 -24
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrder/start.js +15 -19
- package/package.json +2 -2
- package/lib/chevre/service/task/deletePerson.d.ts +0 -6
- package/lib/chevre/service/task/deletePerson.js +0 -465
|
@@ -46,9 +46,6 @@ export declare class MessageRepo {
|
|
|
46
46
|
projectFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(IEmailMessage & {
|
|
47
47
|
id: string;
|
|
48
48
|
})[]>;
|
|
49
|
-
/**
|
|
50
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
51
|
-
*/
|
|
52
49
|
/**
|
|
53
50
|
* コードをキーにしてひとつ更新(なければ作成する)
|
|
54
51
|
*/
|
|
@@ -62,6 +59,13 @@ export declare class MessageRepo {
|
|
|
62
59
|
id: string;
|
|
63
60
|
};
|
|
64
61
|
}): Promise<IFindByIdentifierResult>;
|
|
62
|
+
/**
|
|
63
|
+
* 発行日時を基準に複数削除
|
|
64
|
+
* 2026-06-28~
|
|
65
|
+
*/
|
|
66
|
+
deleteDatePublishedPassedCertainPeriod(params: {
|
|
67
|
+
$lt: Date;
|
|
68
|
+
}): Promise<void>;
|
|
65
69
|
deleteByMainEntityOrderNumber(params: {
|
|
66
70
|
project: {
|
|
67
71
|
id: string;
|
|
@@ -80,65 +80,6 @@ class MessageRepo {
|
|
|
80
80
|
.lean() // 2024-09-19~
|
|
81
81
|
.exec();
|
|
82
82
|
}
|
|
83
|
-
// 重複エラーをハンドルするためにupsertOneByIdentifierへ移行(2025-05-11~)
|
|
84
|
-
/**
|
|
85
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
86
|
-
*/
|
|
87
|
-
// public async upsertByIdentifier(
|
|
88
|
-
// params: Pick<
|
|
89
|
-
// IEmailMessage,
|
|
90
|
-
// 'about' | 'identifier' | 'mainEntity' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'provider'
|
|
91
|
-
// >[]
|
|
92
|
-
// ): Promise<BulkWriteResult | void> {
|
|
93
|
-
// const now = new Date();
|
|
94
|
-
// const bulkWriteOps: AnyBulkWriteOperation<IEmailMessage>[] = [];
|
|
95
|
-
// if (Array.isArray(params)) {
|
|
96
|
-
// params.forEach((creatingNoteParams) => {
|
|
97
|
-
// const { about, identifier, project, text, mainEntity, name, sender, toRecipient, provider } = creatingNoteParams;
|
|
98
|
-
// if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
99
|
-
// throw new factory.errors.ArgumentNull('identifier');
|
|
100
|
-
// }
|
|
101
|
-
// if (typeof text !== 'string') {
|
|
102
|
-
// throw new factory.errors.ArgumentNull('text');
|
|
103
|
-
// }
|
|
104
|
-
// // リソースのユニークネスを保証するfilter
|
|
105
|
-
// const filter: RootFilterQuery<IEmailMessage> = {
|
|
106
|
-
// // typeOf: { $eq: factory.creativeWorkType.EmailMessage },
|
|
107
|
-
// 'project.id': { $eq: project.id },
|
|
108
|
-
// identifier: { $eq: identifier }
|
|
109
|
-
// };
|
|
110
|
-
// const setOnInsert: MatchKeysAndValues<IEmailMessage> = {
|
|
111
|
-
// identifier,
|
|
112
|
-
// project,
|
|
113
|
-
// datePublished: now,
|
|
114
|
-
// typeOf: factory.creativeWorkType.EmailMessage
|
|
115
|
-
// };
|
|
116
|
-
// // 変更可能な属性のみ上書き
|
|
117
|
-
// const setFields: MatchKeysAndValues<IEmailMessage> = {
|
|
118
|
-
// provider,
|
|
119
|
-
// mainEntity,
|
|
120
|
-
// about,
|
|
121
|
-
// sender,
|
|
122
|
-
// text,
|
|
123
|
-
// toRecipient,
|
|
124
|
-
// ...(typeof name === 'string') ? { name } : undefined
|
|
125
|
-
// };
|
|
126
|
-
// const updateFilter: UpdateFilter<IEmailMessage> = {
|
|
127
|
-
// $setOnInsert: setOnInsert,
|
|
128
|
-
// $set: setFields
|
|
129
|
-
// };
|
|
130
|
-
// const updateOne: UpdateOneModel<IEmailMessage> = {
|
|
131
|
-
// filter,
|
|
132
|
-
// update: updateFilter,
|
|
133
|
-
// upsert: true
|
|
134
|
-
// };
|
|
135
|
-
// bulkWriteOps.push({ updateOne });
|
|
136
|
-
// });
|
|
137
|
-
// }
|
|
138
|
-
// if (bulkWriteOps.length > 0) {
|
|
139
|
-
// return this.messageModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
83
|
/**
|
|
143
84
|
* コードをキーにしてひとつ更新(なければ作成する)
|
|
144
85
|
*/
|
|
@@ -219,6 +160,19 @@ class MessageRepo {
|
|
|
219
160
|
}
|
|
220
161
|
return doc;
|
|
221
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* 発行日時を基準に複数削除
|
|
165
|
+
* 2026-06-28~
|
|
166
|
+
*/
|
|
167
|
+
async deleteDatePublishedPassedCertainPeriod(params) {
|
|
168
|
+
const { $lt } = params;
|
|
169
|
+
if ($lt instanceof Date) {
|
|
170
|
+
await this.messageModel.deleteMany({
|
|
171
|
+
datePublished: { $lt }
|
|
172
|
+
})
|
|
173
|
+
.exec();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
222
176
|
async deleteByMainEntityOrderNumber(params) {
|
|
223
177
|
return this.messageModel.deleteMany({
|
|
224
178
|
'project.id': { $eq: params.project.id },
|
|
@@ -16,7 +16,7 @@ export type IEmailMessage = factory.creativeWork.message.email.ICreativeWork & {
|
|
|
16
16
|
typeOf: factory.organizationType.Corporation;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
type IDocType =
|
|
19
|
+
type IDocType = Pick<IEmailMessage, 'about' | 'identifier' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'typeOf' | 'datePublished' | 'mainEntity' | 'provider'>;
|
|
20
20
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
21
21
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
22
22
|
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|
|
@@ -22,8 +22,6 @@ const schemaDefinition = {
|
|
|
22
22
|
startDate: Date,
|
|
23
23
|
endDate: Date,
|
|
24
24
|
tasksExportAction: mongoose_1.SchemaTypes.Mixed,
|
|
25
|
-
// tasksExportedAt: Date, // discontinue(2024-06-19~)
|
|
26
|
-
// tasksExportationStatus: String, // discontinue(2024-06-19~)
|
|
27
25
|
potentialActions: mongoose_1.SchemaTypes.Mixed,
|
|
28
26
|
instrument: mongoose_1.SchemaTypes.Mixed
|
|
29
27
|
};
|
|
@@ -81,24 +79,6 @@ const indexes = [
|
|
|
81
79
|
{ expires: 1, startDate: -1 },
|
|
82
80
|
{ name: 'searchByExpiresAndStartDate' }
|
|
83
81
|
],
|
|
84
|
-
[
|
|
85
|
-
{ 'result.order.confirmationNumber': 1, startDate: -1 },
|
|
86
|
-
{
|
|
87
|
-
name: 'searchByResultOrderConfirmationNumber',
|
|
88
|
-
partialFilterExpression: {
|
|
89
|
-
'result.order.confirmationNumber': { $exists: true }
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
[
|
|
94
|
-
{ 'result.order.orderNumber': 1, startDate: -1 },
|
|
95
|
-
{
|
|
96
|
-
name: 'searchByResultOrderNumberAndStartDate',
|
|
97
|
-
partialFilterExpression: {
|
|
98
|
-
'result.order.orderNumber': { $exists: true }
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
82
|
[
|
|
103
83
|
{ 'object.confirmationNumber': 1, startDate: -1 },
|
|
104
84
|
{
|
|
@@ -126,36 +106,6 @@ const indexes = [
|
|
|
126
106
|
}
|
|
127
107
|
}
|
|
128
108
|
],
|
|
129
|
-
[
|
|
130
|
-
// 結果の注文番号はユニークなはず
|
|
131
|
-
{
|
|
132
|
-
typeOf: 1,
|
|
133
|
-
'result.order.orderNumber': 1
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'searchPlaceOrderByOrderNumber',
|
|
137
|
-
unique: true,
|
|
138
|
-
partialFilterExpression: {
|
|
139
|
-
'result.order.orderNumber': { $exists: true }
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
[
|
|
144
|
-
// 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
145
|
-
{
|
|
146
|
-
typeOf: 1,
|
|
147
|
-
'object.orderNumber': 1
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'uniquePlacingOrderNumber20260221',
|
|
151
|
-
unique: true,
|
|
152
|
-
partialFilterExpression: {
|
|
153
|
-
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
154
|
-
'object.orderNumber': { $exists: true },
|
|
155
|
-
startDate: { $gte: new Date('2026-02-21T11:00:00Z') }
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
109
|
[
|
|
160
110
|
// 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
161
111
|
{
|
|
@@ -261,6 +211,57 @@ const indexes = [
|
|
|
261
211
|
}
|
|
262
212
|
}
|
|
263
213
|
]
|
|
214
|
+
// result.order廃止につきインデックス廃止(2026-06-28~)
|
|
215
|
+
// [
|
|
216
|
+
// { 'result.order.confirmationNumber': 1, startDate: -1 },
|
|
217
|
+
// {
|
|
218
|
+
// name: 'searchByResultOrderConfirmationNumber',
|
|
219
|
+
// partialFilterExpression: {
|
|
220
|
+
// 'result.order.confirmationNumber': { $exists: true }
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
// ],
|
|
224
|
+
// [
|
|
225
|
+
// { 'result.order.orderNumber': 1, startDate: -1 },
|
|
226
|
+
// {
|
|
227
|
+
// name: 'searchByResultOrderNumberAndStartDate',
|
|
228
|
+
// partialFilterExpression: {
|
|
229
|
+
// 'result.order.orderNumber': { $exists: true }
|
|
230
|
+
// }
|
|
231
|
+
// }
|
|
232
|
+
// ],
|
|
233
|
+
// result.order廃止につきインデックス廃止(2026-06-28~)
|
|
234
|
+
// [
|
|
235
|
+
// // 結果の注文番号はユニークなはず
|
|
236
|
+
// {
|
|
237
|
+
// typeOf: 1,
|
|
238
|
+
// 'result.order.orderNumber': 1
|
|
239
|
+
// },
|
|
240
|
+
// {
|
|
241
|
+
// name: 'searchPlaceOrderByOrderNumber',
|
|
242
|
+
// unique: true,
|
|
243
|
+
// partialFilterExpression: {
|
|
244
|
+
// 'result.order.orderNumber': { $exists: true }
|
|
245
|
+
// }
|
|
246
|
+
// }
|
|
247
|
+
// ],
|
|
248
|
+
// uniquePlacingOrderNumberと重複しているので廃止(2026-06-28~)
|
|
249
|
+
// [
|
|
250
|
+
// // 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
251
|
+
// {
|
|
252
|
+
// typeOf: 1,
|
|
253
|
+
// 'object.orderNumber': 1
|
|
254
|
+
// },
|
|
255
|
+
// {
|
|
256
|
+
// name: 'uniquePlacingOrderNumber20260221',
|
|
257
|
+
// unique: true,
|
|
258
|
+
// partialFilterExpression: {
|
|
259
|
+
// typeOf: factory.transactionType.PlaceOrder,
|
|
260
|
+
// 'object.orderNumber': { $exists: true },
|
|
261
|
+
// startDate: { $gte: new Date('2026-02-21T11:00:00Z') }
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
// ],
|
|
264
265
|
];
|
|
265
266
|
exports.indexes = indexes;
|
|
266
267
|
/**
|
|
@@ -26,7 +26,7 @@ interface IAggregateOrder {
|
|
|
26
26
|
export type IOrderOnStatusChanged = Pick<IOrderWithoutAcceptedOffers & {
|
|
27
27
|
id: string;
|
|
28
28
|
}, 'id' | 'orderNumber' | 'broker' | 'confirmationNumber' | 'customer' | 'dateReturned' | 'name' | 'orderDate' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'previousOrderStatus' | 'price' | 'priceCurrency' | 'project' | 'returner' | 'seller' | 'typeOf'>;
|
|
29
|
-
type ISearchConditions = Pick<factory.order.ISearchConditions, 'acceptedOffers' | 'broker' | 'confirmationNumbers' | 'customer' | 'name' | 'orderDate' | 'orderNumbers' | 'orderStatuses' | 'paymentMethods' | 'project' | 'provider' | 'seller'>;
|
|
29
|
+
type ISearchConditions = Pick<factory.order.ISearchConditions, 'acceptedOffers' | 'broker' | 'confirmationNumbers' | 'customer' | 'name' | 'orderDate' | 'orderNumbers' | 'orderStatuses' | 'paymentMethods' | 'project' | 'provider' | 'seller' | 'identifier'>;
|
|
30
30
|
/**
|
|
31
31
|
* 注文リポジトリ
|
|
32
32
|
*/
|
|
@@ -152,13 +152,6 @@ export declare class OrderRepo {
|
|
|
152
152
|
$unset: any;
|
|
153
153
|
arrayFilters?: any[];
|
|
154
154
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
155
|
-
updateIdentifier4migration(params: {
|
|
156
|
-
project: {
|
|
157
|
-
id: string;
|
|
158
|
-
};
|
|
159
|
-
orderNumber: string;
|
|
160
|
-
identifier: string;
|
|
161
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
162
155
|
aggregateOrder(params: {
|
|
163
156
|
project?: {
|
|
164
157
|
id?: {
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -239,6 +239,10 @@ class OrderRepo {
|
|
|
239
239
|
}
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
+
const identifierEq = params.identifier?.$eq;
|
|
243
|
+
if (typeof identifierEq === 'string') {
|
|
244
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
245
|
+
}
|
|
242
246
|
if (Array.isArray(params.orderNumbers)) {
|
|
243
247
|
if (params.orderNumbers.length === 1) {
|
|
244
248
|
// use $eq(2025-04-01~)
|
|
@@ -844,19 +848,26 @@ class OrderRepo {
|
|
|
844
848
|
})
|
|
845
849
|
.exec();
|
|
846
850
|
}
|
|
847
|
-
async updateIdentifier4migration(params
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
851
|
+
// public async updateIdentifier4migration(params: {
|
|
852
|
+
// project: { id: string };
|
|
853
|
+
// orderNumber: string;
|
|
854
|
+
// identifier: string;
|
|
855
|
+
// }) {
|
|
856
|
+
// const { orderNumber, project, identifier } = params;
|
|
857
|
+
// return this.orderModel.updateOne(
|
|
858
|
+
// {
|
|
859
|
+
// orderNumber: { $eq: orderNumber },
|
|
860
|
+
// 'project.id': { $eq: project.id },
|
|
861
|
+
// typeOf: { $eq: factory.order.OrderType.Order }
|
|
862
|
+
// },
|
|
863
|
+
// {
|
|
864
|
+
// $set: {
|
|
865
|
+
// ...(typeof identifier === 'string') ? { identifier } : undefined
|
|
866
|
+
// }
|
|
867
|
+
// }
|
|
868
|
+
// )
|
|
869
|
+
// .exec();
|
|
870
|
+
// }
|
|
860
871
|
async aggregateOrder(params) {
|
|
861
872
|
const matchConditions = {
|
|
862
873
|
orderDate: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
import { AcceptedOfferInReserveRepo } from './acceptedOfferInReserve';
|
|
4
|
-
type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project' | 'broker'> & {
|
|
4
|
+
export type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project' | 'broker'> & {
|
|
5
5
|
typeOf: factory.transactionType.PlaceOrder;
|
|
6
6
|
orderDate: Date;
|
|
7
7
|
/**
|
|
@@ -131,4 +131,3 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
131
131
|
identifier: string;
|
|
132
132
|
}): Promise<import("mongodb").DeleteResult>;
|
|
133
133
|
}
|
|
134
|
-
export {};
|
|
@@ -31,7 +31,7 @@ type ICreatingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | '
|
|
|
31
31
|
export declare class TaskRepo {
|
|
32
32
|
readonly taskModel: IModel;
|
|
33
33
|
constructor(connection: Connection);
|
|
34
|
-
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/
|
|
34
|
+
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/deleteTransaction").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").ITask>[];
|
|
35
35
|
runImmediately(params: Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'expires' | 'name' | 'project' | 'remainingNumberOfTries' | 'runsAt'> & {
|
|
36
36
|
alternateName?: never;
|
|
37
37
|
identifier?: never;
|
|
@@ -43,12 +43,6 @@ export declare class PlaceOrderRepo {
|
|
|
43
43
|
findInProgressPaymentMethodId(params: {
|
|
44
44
|
id: string;
|
|
45
45
|
}): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
|
|
46
|
-
/**
|
|
47
|
-
* 取引の注文番号を検索する
|
|
48
|
-
*/
|
|
49
|
-
findInProgressOrderNumberById(params: {
|
|
50
|
-
id: string;
|
|
51
|
-
}): Promise<string | undefined>;
|
|
52
46
|
/**
|
|
53
47
|
* 取引の確認番号を検索する
|
|
54
48
|
*/
|
|
@@ -130,6 +124,7 @@ export declare class PlaceOrderRepo {
|
|
|
130
124
|
id: string;
|
|
131
125
|
object: {
|
|
132
126
|
orderDate: Date;
|
|
127
|
+
orderNumber: string;
|
|
133
128
|
};
|
|
134
129
|
result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
|
|
135
130
|
potentialActions: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
|
|
@@ -202,22 +202,30 @@ class PlaceOrderRepo {
|
|
|
202
202
|
}
|
|
203
203
|
return doc.object.paymentMethods;
|
|
204
204
|
}
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
async findInProgressOrderNumberById(params
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
205
|
+
// /**
|
|
206
|
+
// * 取引の注文番号を検索する
|
|
207
|
+
// */
|
|
208
|
+
// public async findInProgressOrderNumberById(params: {
|
|
209
|
+
// id: string;
|
|
210
|
+
// }): Promise<string | undefined> {
|
|
211
|
+
// const doc = await this.transactionModel.findOne(
|
|
212
|
+
// {
|
|
213
|
+
// _id: { $eq: params.id },
|
|
214
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
215
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
216
|
+
// },
|
|
217
|
+
// { 'object.orderNumber': 1 }
|
|
218
|
+
// )
|
|
219
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
|
|
220
|
+
// .exec();
|
|
221
|
+
// if (doc === null) {
|
|
222
|
+
// throw new factory.errors.NotFound(
|
|
223
|
+
// this.transactionModel.modelName,
|
|
224
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
225
|
+
// );
|
|
226
|
+
// }
|
|
227
|
+
// return doc.object.orderNumber;
|
|
228
|
+
// }
|
|
221
229
|
/**
|
|
222
230
|
* 取引の確認番号を検索する
|
|
223
231
|
*/
|
|
@@ -432,6 +440,7 @@ class PlaceOrderRepo {
|
|
|
432
440
|
status: factory_1.factory.transactionStatusType.Confirmed, // ステータス変更
|
|
433
441
|
endDate,
|
|
434
442
|
'object.orderDate': params.object.orderDate, // add(2026-06-15~)
|
|
443
|
+
'object.orderNumber': params.object.orderNumber, // add(2026-06-27~)
|
|
435
444
|
result: params.result, // resultを更新
|
|
436
445
|
potentialActions: params.potentialActions // resultを更新
|
|
437
446
|
}, {
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
2
|
import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
|
-
import type { EventRepo } from '../../repo/event';
|
|
4
3
|
import type { NoteRepo } from '../../repo/note';
|
|
5
4
|
import type { OrderRepo } from '../../repo/order';
|
|
6
|
-
import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
5
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
8
|
-
import type { SettingRepo } from '../../repo/setting';
|
|
9
|
-
import type { TaskRepo } from '../../repo/task';
|
|
10
|
-
import { factory } from '../../factory';
|
|
11
6
|
/**
|
|
12
7
|
* 注文に関わるリソースを削除する
|
|
13
8
|
* 冪等性を確保すること
|
|
14
9
|
*/
|
|
15
10
|
declare function deleteOrder(params: {
|
|
16
|
-
object:
|
|
11
|
+
object: {
|
|
12
|
+
/**
|
|
13
|
+
* 注文取引ID
|
|
14
|
+
*/
|
|
15
|
+
identifier: string;
|
|
16
|
+
};
|
|
17
17
|
}): (repos: {
|
|
18
18
|
acceptedOffer: AcceptedOfferRepo;
|
|
19
19
|
accountingReport: AccountingReportRepo;
|
|
20
|
-
event: EventRepo;
|
|
21
20
|
note: NoteRepo;
|
|
22
21
|
order: OrderRepo;
|
|
23
|
-
ownershipInfo: OwnershipInfoRepo;
|
|
24
22
|
reservation: ReservationRepo;
|
|
25
|
-
setting: SettingRepo;
|
|
26
|
-
task: TaskRepo;
|
|
27
23
|
}) => Promise<void>;
|
|
28
24
|
export { deleteOrder };
|
|
@@ -9,23 +9,26 @@ const factory_1 = require("../../factory");
|
|
|
9
9
|
*/
|
|
10
10
|
function deleteOrder(params) {
|
|
11
11
|
return async (repos) => {
|
|
12
|
+
if (typeof params.object.identifier !== 'string' || params.object.identifier === '') {
|
|
13
|
+
throw new factory_1.factory.errors.ArgumentNull('object.identifier');
|
|
14
|
+
}
|
|
12
15
|
const orders = await repos.order.projectFields({
|
|
13
16
|
limit: 1,
|
|
14
17
|
page: 1,
|
|
15
|
-
orderNumbers: [params.object.orderNumber]
|
|
16
|
-
|
|
18
|
+
// orderNumbers: [params.object.orderNumber],
|
|
19
|
+
identifier: { $eq: params.object.identifier }
|
|
20
|
+
}, { inclusion: ['project', 'orderNumber'] });
|
|
17
21
|
const order = orders.shift();
|
|
18
22
|
if (order === undefined) {
|
|
19
23
|
// すでに削除済
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
26
|
if (typeof order.id !== 'string') {
|
|
23
|
-
throw new factory_1.factory.errors.Internal(`order.id undefined. orderNumber: ${
|
|
27
|
+
throw new factory_1.factory.errors.Internal(`order.id undefined. orderNumber: ${order.orderNumber}`);
|
|
24
28
|
}
|
|
25
29
|
// 注文アイテムの予約を削除
|
|
26
30
|
await deleteReservationsByOrder(order)(repos);
|
|
27
31
|
// 所有権は所有期限でcleanされるので、注文削除時連動はひとまず廃止(2026-05-17~)
|
|
28
|
-
// // 所有権削除
|
|
29
32
|
// try {
|
|
30
33
|
// await deleteOwnershipInfosByOrder(order)(repos);
|
|
31
34
|
// } catch (error) {
|
|
@@ -42,50 +45,6 @@ function deleteOrder(params) {
|
|
|
42
45
|
});
|
|
43
46
|
// 注文削除
|
|
44
47
|
await repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
45
|
-
// deletePerson(2024-12-25~)
|
|
46
|
-
await deletePersonIfNecessary(order)(repos);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function deletePersonIfNecessary(order) {
|
|
50
|
-
return async (repos) => {
|
|
51
|
-
// 代理注文を除く
|
|
52
|
-
const isCustomerPerson = order.customer.typeOf === factory_1.factory.personType.Person
|
|
53
|
-
&& typeof order.broker?.typeOf !== 'string';
|
|
54
|
-
if (isCustomerPerson) {
|
|
55
|
-
const ordersByPerson = await repos.order.projectFields({
|
|
56
|
-
limit: 1,
|
|
57
|
-
page: 1,
|
|
58
|
-
customer: { ids: [order.customer.id] }
|
|
59
|
-
}, { inclusion: ['orderNumber'] });
|
|
60
|
-
if (ordersByPerson.length === 0) {
|
|
61
|
-
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
62
|
-
if (typeof setting?.userPoolIdNew !== 'string') {
|
|
63
|
-
throw new factory_1.factory.errors.NotFound('setting.userPoolIdNew');
|
|
64
|
-
}
|
|
65
|
-
const deletePersonTask = {
|
|
66
|
-
project: { typeOf: factory_1.factory.organizationType.Project, id: order.project.id },
|
|
67
|
-
name: factory_1.factory.taskName.DeletePerson,
|
|
68
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
69
|
-
runsAt: new Date(),
|
|
70
|
-
remainingNumberOfTries: 10,
|
|
71
|
-
numberOfTried: 0,
|
|
72
|
-
executionResults: [],
|
|
73
|
-
data: {
|
|
74
|
-
id: order.customer.id,
|
|
75
|
-
agent: {
|
|
76
|
-
id: order.project.id,
|
|
77
|
-
typeOf: factory_1.factory.organizationType.Project,
|
|
78
|
-
name: factory_1.factory.organizationType.Project
|
|
79
|
-
},
|
|
80
|
-
physically: true,
|
|
81
|
-
userPoolId: setting.userPoolIdNew,
|
|
82
|
-
// migrate: false,
|
|
83
|
-
executeBackground: true
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
await repos.task.saveMany([deletePersonTask], { emitImmediately: true });
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
48
|
};
|
|
90
49
|
}
|
|
91
50
|
function deleteReservationsByOrder(order) {
|
|
@@ -7,5 +7,5 @@ import { factory } from '../../../../factory';
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
9
9
|
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
10
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/
|
|
10
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
|
|
11
11
|
export { createOnOrderCancelledTasksByTransaction };
|
package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ declare function createInformTasks(params: {
|
|
|
18
18
|
}, setting: Pick<ISetting, 'onOrderStatusChanged'> | null): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
19
19
|
declare function createNextSendOrderTasks(params: {
|
|
20
20
|
order: IInTransitOrder;
|
|
21
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/
|
|
21
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
|
|
22
22
|
export { createInformTasks, createNextSendOrderTasks, IInTransitOrder };
|
|
@@ -11,5 +11,5 @@ declare function createInformTasks(order: IReturnedOrder, returnOrderAction: IRe
|
|
|
11
11
|
declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
12
12
|
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'customer' | 'price' | 'priceCurrency' | 'orderDate'>;
|
|
13
13
|
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
14
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/
|
|
14
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
|
|
15
15
|
export { createInformTasks, createOnOrderReturnedTasksByTransaction, IReturnAction };
|
|
@@ -38,14 +38,10 @@ const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
|
38
38
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
39
39
|
const action_1 = require("../../repo/action");
|
|
40
40
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
41
|
-
const event_1 = require("../../repo/event");
|
|
42
41
|
const message_1 = require("../../repo/message");
|
|
43
42
|
const note_1 = require("../../repo/note");
|
|
44
43
|
const order_1 = require("../../repo/order");
|
|
45
|
-
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
46
44
|
const reservation_1 = require("../../repo/reservation");
|
|
47
|
-
const setting_1 = require("../../repo/setting");
|
|
48
|
-
const task_1 = require("../../repo/task");
|
|
49
45
|
const transaction_1 = require("../../repo/transaction");
|
|
50
46
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
51
47
|
const returnOrder_1 = require("../../repo/transaction/returnOrder");
|
|
@@ -60,14 +56,10 @@ function call(data) {
|
|
|
60
56
|
accountingReport: new accountingReport_1.AccountingReportRepo(connection),
|
|
61
57
|
action: new action_1.ActionRepo(connection),
|
|
62
58
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
63
|
-
event: new event_1.EventRepo(connection),
|
|
64
59
|
message: new message_1.MessageRepo(connection),
|
|
65
60
|
note: new note_1.NoteRepo(connection),
|
|
66
61
|
order: new order_1.OrderRepo(connection),
|
|
67
|
-
ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
|
|
68
62
|
reservation: new reservation_1.ReservationRepo(connection),
|
|
69
|
-
setting: new setting_1.SettingRepo(connection),
|
|
70
|
-
task: new task_1.TaskRepo(connection),
|
|
71
63
|
transaction: new transaction_1.TransactionRepo(connection),
|
|
72
64
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
73
65
|
returnOrder: new returnOrder_1.ReturnOrderRepo(connection),
|