@chevre/domain 25.2.0-alpha.11 → 25.2.0-alpha.13
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/action.d.ts +15 -9
- package/lib/chevre/repo/action.js +71 -172
- package/lib/chevre/repo/orderInTransaction.d.ts +8 -1
- package/lib/chevre/repo/orderInTransaction.js +17 -1
- package/lib/chevre/repo/transaction/placeOrder.d.ts +0 -27
- package/lib/chevre/repo/transaction/placeOrder.js +76 -47
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +65 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +30 -17
- package/package.json +1 -1
|
@@ -9,6 +9,9 @@ export { ICancelActionAction };
|
|
|
9
9
|
*/
|
|
10
10
|
type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction | factory.actionType.AuthorizeAction | factory.actionType.PayAction | factory.actionType.RefundAction>;
|
|
11
11
|
type IAvailableActionRecipe = IActionRecipe<Exclude<factory.recipe.RecipeCategory, factory.recipe.RecipeCategory.publishPaymentUrl | factory.recipe.RecipeCategory.checkMovieTicket | factory.recipe.RecipeCategory.acceptCOAOffer | factory.recipe.RecipeCategory.authorizeInvoice | factory.recipe.RecipeCategory.authorizeInvoice3ds | factory.recipe.RecipeCategory.payCreditCard | factory.recipe.RecipeCategory.payMovieTicket | factory.recipe.RecipeCategory.refundCreditCard | factory.recipe.RecipeCategory.refundMovieTicket>>;
|
|
12
|
+
export interface IDeleteActionResult {
|
|
13
|
+
deletedCount?: number;
|
|
14
|
+
}
|
|
12
15
|
/**
|
|
13
16
|
* アクションリポジトリ
|
|
14
17
|
*/
|
|
@@ -50,15 +53,20 @@ export declare class ActionRepo extends ActionProcessRepo<IAction<StartableActio
|
|
|
50
53
|
orderNumber: string;
|
|
51
54
|
sort?: factory.action.ISortOrder;
|
|
52
55
|
}): Promise<IAction<factory.actionType>[]>;
|
|
56
|
+
/**
|
|
57
|
+
* 注文番号から、注文に対するアクションを削除する
|
|
58
|
+
*/
|
|
59
|
+
deleteActionsByOrderNumber(params: {
|
|
60
|
+
project: {
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
orderNumber: string;
|
|
64
|
+
}): Promise<IDeleteActionResult[]>;
|
|
53
65
|
deleteByProject(params: {
|
|
54
66
|
project: {
|
|
55
67
|
id: string;
|
|
56
68
|
};
|
|
57
69
|
}): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* イベントと入場ゲート指定で予約使用アクションを集計する
|
|
60
|
-
* discontinue(2024-12-26~)
|
|
61
|
-
*/
|
|
62
70
|
/**
|
|
63
71
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
64
72
|
*/
|
|
@@ -78,20 +86,18 @@ export declare class ActionRepo extends ActionProcessRepo<IAction<StartableActio
|
|
|
78
86
|
/**
|
|
79
87
|
* 取引からアクションを削除する
|
|
80
88
|
*/
|
|
81
|
-
|
|
89
|
+
deleteActionsByTransactionId(params: {
|
|
82
90
|
project: {
|
|
83
91
|
id: string;
|
|
84
92
|
};
|
|
85
|
-
|
|
93
|
+
transaction: {
|
|
86
94
|
typeOf: factory.transactionType;
|
|
87
95
|
id: string;
|
|
88
96
|
};
|
|
89
97
|
typeOf: {
|
|
90
98
|
$in: factory.actionType[];
|
|
91
99
|
};
|
|
92
|
-
}): Promise<
|
|
93
|
-
deletedCount?: number;
|
|
94
|
-
} | null>;
|
|
100
|
+
}): Promise<IDeleteActionResult[]>;
|
|
95
101
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/action").IAction<import("@chevre/factory/lib/chevre/action").IAttributes<factory.actionType, any, any>>, "id"> & {
|
|
96
102
|
identifier?: string;
|
|
97
103
|
} & {
|
|
@@ -312,130 +312,55 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
312
312
|
.lean() // 2024-08-26~
|
|
313
313
|
.exec();
|
|
314
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* 注文番号から、注文に対するアクションを削除する
|
|
317
|
+
*/
|
|
318
|
+
async deleteActionsByOrderNumber(params) {
|
|
319
|
+
const { project, orderNumber } = params;
|
|
320
|
+
if (typeof project.id !== 'string' || project.id === '') {
|
|
321
|
+
throw new factory_1.factory.errors.ArgumentNull('project.id');
|
|
322
|
+
}
|
|
323
|
+
if (typeof orderNumber !== 'string' || orderNumber === '') {
|
|
324
|
+
throw new factory_1.factory.errors.ArgumentNull('orderNumber');
|
|
325
|
+
}
|
|
326
|
+
const filters = [
|
|
327
|
+
{
|
|
328
|
+
'project.id': { $eq: project.id },
|
|
329
|
+
'object.orderNumber': { $exists: true, $eq: orderNumber }
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
'project.id': { $eq: project.id },
|
|
333
|
+
'purpose.orderNumber': { $exists: true, $eq: orderNumber }
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
'project.id': { $eq: project.id },
|
|
337
|
+
'about.orderNumber': { $exists: true, $eq: orderNumber }
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
'project.id': { $eq: project.id },
|
|
341
|
+
'instrument.orderNumber': { $exists: true, $eq: orderNumber }
|
|
342
|
+
},
|
|
343
|
+
];
|
|
344
|
+
const results = await Promise.all(filters.map(async (filter) => {
|
|
345
|
+
return this.actionModel.deleteMany(filter)
|
|
346
|
+
.exec();
|
|
347
|
+
}));
|
|
348
|
+
return results.map((result) => {
|
|
349
|
+
return {
|
|
350
|
+
// n: result?.n,
|
|
351
|
+
// opTime: result.opTime,
|
|
352
|
+
// ok: result?.ok,
|
|
353
|
+
// operationTime,
|
|
354
|
+
deletedCount: result?.deletedCount
|
|
355
|
+
};
|
|
356
|
+
});
|
|
357
|
+
}
|
|
315
358
|
async deleteByProject(params) {
|
|
316
359
|
await this.actionModel.deleteMany({
|
|
317
360
|
'project.id': { $eq: params.project.id }
|
|
318
361
|
})
|
|
319
362
|
.exec();
|
|
320
363
|
}
|
|
321
|
-
// public async reCompleteAuthorizeEventOfferAction(params: {
|
|
322
|
-
// id: string;
|
|
323
|
-
// object: factory.action.authorize.offer.eventService.IObject;
|
|
324
|
-
// result: factory.action.authorize.offer.eventService.IResult;
|
|
325
|
-
// }): Promise<void> {
|
|
326
|
-
// return this.actionModel.findOneAndUpdate(
|
|
327
|
-
// {
|
|
328
|
-
// // typeOf: factory.actionType.AuthorizeAction,
|
|
329
|
-
// _id: { $eq: params.id },
|
|
330
|
-
// // ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
331
|
-
// // actionStatus: factory.actionStatusType.CompletedActionStatus
|
|
332
|
-
// actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus }
|
|
333
|
-
// },
|
|
334
|
-
// {
|
|
335
|
-
// $set: {
|
|
336
|
-
// actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
337
|
-
// object: params.object,
|
|
338
|
-
// result: params.result,
|
|
339
|
-
// endDate: new Date()
|
|
340
|
-
// }
|
|
341
|
-
// },
|
|
342
|
-
// { new: true, projection: { _id: 1 } }
|
|
343
|
-
// )
|
|
344
|
-
// .lean<{ _id: ObjectId }>()
|
|
345
|
-
// .exec()
|
|
346
|
-
// .then((doc) => {
|
|
347
|
-
// if (doc === null) {
|
|
348
|
-
// throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
349
|
-
// }
|
|
350
|
-
// });
|
|
351
|
-
// }
|
|
352
|
-
// public async updateById(params: {
|
|
353
|
-
// id: string;
|
|
354
|
-
// update: any;
|
|
355
|
-
// }): Promise<void> {
|
|
356
|
-
// await this.actionModel.updateOne(
|
|
357
|
-
// { _id: { $eq: params.id } },
|
|
358
|
-
// params.update
|
|
359
|
-
// )
|
|
360
|
-
// .exec();
|
|
361
|
-
// }
|
|
362
|
-
// public async findByIdAndUpdate(params: {
|
|
363
|
-
// id: string;
|
|
364
|
-
// update: UpdateQuery<IAction<factory.actionType>>;
|
|
365
|
-
// }): Promise<void> {
|
|
366
|
-
// await this.actionModel.findOneAndUpdate(
|
|
367
|
-
// { _id: { $eq: params.id } },
|
|
368
|
-
// params.update,
|
|
369
|
-
// { projection: { _id: 1 } }
|
|
370
|
-
// )
|
|
371
|
-
// .lean<{ _id: ObjectId }>()
|
|
372
|
-
// .exec()
|
|
373
|
-
// .then((doc) => {
|
|
374
|
-
// if (doc === null) {
|
|
375
|
-
// throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
376
|
-
// }
|
|
377
|
-
// });
|
|
378
|
-
// }
|
|
379
|
-
/**
|
|
380
|
-
* イベントと入場ゲート指定で予約使用アクションを集計する
|
|
381
|
-
* discontinue(2024-12-26~)
|
|
382
|
-
*/
|
|
383
|
-
// public async countUseActionsByEntranceGate(params: {
|
|
384
|
-
// event: { id: string };
|
|
385
|
-
// entranceGateIdentifier: string;
|
|
386
|
-
// }): Promise<IUseActionCountByOffer[]> {
|
|
387
|
-
// return this.actionModel.aggregate([
|
|
388
|
-
// {
|
|
389
|
-
// $match: {
|
|
390
|
-
// actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
391
|
-
// }
|
|
392
|
-
// },
|
|
393
|
-
// {
|
|
394
|
-
// $match: {
|
|
395
|
-
// typeOf: { $eq: factory.actionType.UseAction }
|
|
396
|
-
// }
|
|
397
|
-
// },
|
|
398
|
-
// {
|
|
399
|
-
// $match: {
|
|
400
|
-
// 'object.typeOf': {
|
|
401
|
-
// $exists: true,
|
|
402
|
-
// $eq: factory.reservationType.EventReservation
|
|
403
|
-
// }
|
|
404
|
-
// }
|
|
405
|
-
// },
|
|
406
|
-
// {
|
|
407
|
-
// $match: {
|
|
408
|
-
// 'object.reservationFor.id': {
|
|
409
|
-
// $exists: true,
|
|
410
|
-
// $eq: params.event.id
|
|
411
|
-
// }
|
|
412
|
-
// }
|
|
413
|
-
// },
|
|
414
|
-
// {
|
|
415
|
-
// $match: {
|
|
416
|
-
// 'location.identifier': {
|
|
417
|
-
// $exists: true,
|
|
418
|
-
// $eq: params.entranceGateIdentifier
|
|
419
|
-
// }
|
|
420
|
-
// }
|
|
421
|
-
// },
|
|
422
|
-
// {
|
|
423
|
-
// $group: {
|
|
424
|
-
// _id: '$object.id',
|
|
425
|
-
// object: { $first: '$object' }
|
|
426
|
-
// }
|
|
427
|
-
// },
|
|
428
|
-
// {
|
|
429
|
-
// $group: {
|
|
430
|
-
// _id: '$object.reservedTicket.ticketType.id',
|
|
431
|
-
// useActionCount: {
|
|
432
|
-
// $sum: 1
|
|
433
|
-
// }
|
|
434
|
-
// }
|
|
435
|
-
// }
|
|
436
|
-
// ])
|
|
437
|
-
// .exec();
|
|
438
|
-
// }
|
|
439
364
|
/**
|
|
440
365
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
441
366
|
*/
|
|
@@ -473,15 +398,34 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
473
398
|
/**
|
|
474
399
|
* 取引からアクションを削除する
|
|
475
400
|
*/
|
|
476
|
-
async
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
401
|
+
async deleteActionsByTransactionId(params) {
|
|
402
|
+
const { project, transaction } = params;
|
|
403
|
+
if (typeof project.id !== 'string' || project.id === '') {
|
|
404
|
+
throw new factory_1.factory.errors.ArgumentNull('project.id');
|
|
405
|
+
}
|
|
406
|
+
if (typeof transaction.id !== 'string' || transaction.id === '') {
|
|
407
|
+
throw new factory_1.factory.errors.ArgumentNull('transaction.id ');
|
|
408
|
+
}
|
|
409
|
+
const filters = [
|
|
410
|
+
{
|
|
411
|
+
'project.id': { $eq: project.id },
|
|
412
|
+
typeOf: { $in: params.typeOf.$in },
|
|
413
|
+
'purpose.id': { $exists: true, $eq: transaction.id },
|
|
414
|
+
'purpose.typeOf': { $exists: true, $eq: transaction.typeOf }
|
|
415
|
+
},
|
|
416
|
+
// instrumentによるアクション削除にも対応(2026-07-10~)
|
|
417
|
+
{
|
|
418
|
+
'project.id': { $eq: project.id },
|
|
419
|
+
// typeOf: { $in: params.typeOf.$in }, // typOfでフィルターしない
|
|
420
|
+
'instrument.id': { $exists: true, $eq: transaction.id },
|
|
421
|
+
'instrument.typeOf': { $exists: true, $eq: transaction.typeOf }
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
const results = await Promise.all(filters.map(async (filter) => {
|
|
425
|
+
return this.actionModel.deleteMany(filter)
|
|
426
|
+
.exec();
|
|
427
|
+
}));
|
|
428
|
+
return results.map((result) => {
|
|
485
429
|
return {
|
|
486
430
|
// n: result?.n,
|
|
487
431
|
// opTime: result.opTime,
|
|
@@ -491,51 +435,6 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
491
435
|
};
|
|
492
436
|
});
|
|
493
437
|
}
|
|
494
|
-
// public async saveActionWithEndDate(savingAction: Omit<factory.action.authorize.invoice.IAction, 'id'>) {
|
|
495
|
-
// const { sameAs, typeOf, project, agent, object, ...updateFields } = savingAction;
|
|
496
|
-
// const filter: FilterQuery<factory.recipe.IRecipe> = {
|
|
497
|
-
// 'project.id': { $eq: project.id },
|
|
498
|
-
// // 'agent.id': { $exists: true, $eq: agent.id },
|
|
499
|
-
// // 'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
500
|
-
// 'object.paymentMethodId': { $exists: true, $eq: object.paymentMethodId },
|
|
501
|
-
// typeOf: { $eq: typeOf },
|
|
502
|
-
// 'sameAs.id': { $exists: true, $eq: sameAs.id }
|
|
503
|
-
// };
|
|
504
|
-
// const setOnInsert: AnyKeys<IAction<factory.actionType>> = { typeOf, project, agent, object, sameAs };
|
|
505
|
-
// const setKeys: AnyKeys<IAction<factory.actionType>> = updateFields;
|
|
506
|
-
// const update: UpdateQuery<IAction<factory.actionType>> = {
|
|
507
|
-
// $setOnInsert: setOnInsert,
|
|
508
|
-
// $set: setKeys
|
|
509
|
-
// };
|
|
510
|
-
// return this.actionModel.updateOne<HydratedDocument<IRecipeAsDocument>>(
|
|
511
|
-
// filter,
|
|
512
|
-
// update,
|
|
513
|
-
// {
|
|
514
|
-
// upsert: true,
|
|
515
|
-
// includeResultMetadata: true
|
|
516
|
-
// }
|
|
517
|
-
// )
|
|
518
|
-
// .exec();
|
|
519
|
-
// }
|
|
520
|
-
// public async findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
|
|
521
|
-
// project: { id: string };
|
|
522
|
-
// recipeFor: { id: string };
|
|
523
|
-
// }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null> {
|
|
524
|
-
// return this.actionRecipeModel.findOne(
|
|
525
|
-
// {
|
|
526
|
-
// 'project.id': { $eq: params.project.id },
|
|
527
|
-
// 'recipeFor.id': { $eq: params.recipeFor.id }
|
|
528
|
-
// },
|
|
529
|
-
// { step: 1, recipeCategory: 1 }
|
|
530
|
-
// // { lean: true }
|
|
531
|
-
// )
|
|
532
|
-
// .lean<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'>>()
|
|
533
|
-
// .exec();
|
|
534
|
-
// // if (result === null) {
|
|
535
|
-
// // throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
|
|
536
|
-
// // }
|
|
537
|
-
// // return result;
|
|
538
|
-
// }
|
|
539
438
|
getCursor(conditions, projection) {
|
|
540
439
|
return this.actionModel.find(conditions, projection)
|
|
541
440
|
.sort({ startDate: factory_1.factory.sortType.Descending })
|
|
@@ -11,6 +11,7 @@ export type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'pr
|
|
|
11
11
|
acceptedOffers: factory.order.IAcceptedOffer[];
|
|
12
12
|
customer?: factory.order.ICustomer;
|
|
13
13
|
seller?: factory.order.ISeller;
|
|
14
|
+
confirmationNumber?: string;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* typeOf: Orderへドキュメント変換時の編集フィールド
|
|
@@ -127,6 +128,12 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
127
128
|
setCustomerByIdentifier(params: Pick<IOrderInTransaction, 'project' | 'identifier'> & {
|
|
128
129
|
customer: factory.order.ICustomer;
|
|
129
130
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
131
|
+
/**
|
|
132
|
+
* 確認番号を参照する
|
|
133
|
+
*/
|
|
134
|
+
findConfirmationNumberByIdentifier(params: {
|
|
135
|
+
identifier: string;
|
|
136
|
+
}): Promise<string | undefined>;
|
|
130
137
|
/**
|
|
131
138
|
* 注文ドキュメントに確認番号を保管する
|
|
132
139
|
* 確認番号未発行の場合のみ保管される
|
|
@@ -139,7 +146,7 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
139
146
|
* 注文取引タイプのドキュメントのみを参照対象にするかどうか
|
|
140
147
|
*/
|
|
141
148
|
onlyPlaceOrder: boolean;
|
|
142
|
-
}): Promise<
|
|
149
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
143
150
|
deleteByIdentifier(params: {
|
|
144
151
|
identifier: string;
|
|
145
152
|
}): Promise<import("mongodb").DeleteResult>;
|
|
@@ -241,6 +241,22 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
241
241
|
}
|
|
242
242
|
return result;
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* 確認番号を参照する
|
|
246
|
+
*/
|
|
247
|
+
async findConfirmationNumberByIdentifier(params) {
|
|
248
|
+
const { identifier } = params;
|
|
249
|
+
const doc = await this.orderModel.findOne({
|
|
250
|
+
identifier: { $eq: identifier },
|
|
251
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
252
|
+
}, { confirmationNumber: 1 })
|
|
253
|
+
.lean()
|
|
254
|
+
.exec();
|
|
255
|
+
if (doc === null) {
|
|
256
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
257
|
+
}
|
|
258
|
+
return doc.confirmationNumber;
|
|
259
|
+
}
|
|
244
260
|
/**
|
|
245
261
|
* 注文ドキュメントに確認番号を保管する
|
|
246
262
|
* 確認番号未発行の場合のみ保管される
|
|
@@ -251,7 +267,7 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
251
267
|
if (typeof confirmationNumber !== 'string' || confirmationNumber === '') {
|
|
252
268
|
throw new factory_1.factory.errors.ArgumentNull('confirmationNumber');
|
|
253
269
|
}
|
|
254
|
-
|
|
270
|
+
return this.orderModel.updateOne({
|
|
255
271
|
identifier: { $eq: identifier },
|
|
256
272
|
confirmationNumber: { $exists: false },
|
|
257
273
|
...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
|
|
@@ -43,15 +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
|
-
findInProgressConfirmationNumberById(params: {
|
|
50
|
-
id: string;
|
|
51
|
-
status: {
|
|
52
|
-
$in: factory.transactionStatusType[];
|
|
53
|
-
};
|
|
54
|
-
}): Promise<string | undefined>;
|
|
55
46
|
/**
|
|
56
47
|
* 取引期限変更
|
|
57
48
|
*/
|
|
@@ -60,17 +51,6 @@ export declare class PlaceOrderRepo {
|
|
|
60
51
|
id: string;
|
|
61
52
|
expires: Date;
|
|
62
53
|
}): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* 取引オブジェクトを更新
|
|
65
|
-
* 注文名称など
|
|
66
|
-
*/
|
|
67
|
-
updateObject(params: {
|
|
68
|
-
typeOf: factory.transactionType.PlaceOrder;
|
|
69
|
-
id: string;
|
|
70
|
-
object?: {
|
|
71
|
-
name?: string;
|
|
72
|
-
};
|
|
73
|
-
}): Promise<void>;
|
|
74
54
|
/**
|
|
75
55
|
* 特定の進行中取引を更新する(汎用)
|
|
76
56
|
*/
|
|
@@ -91,13 +71,6 @@ export declare class PlaceOrderRepo {
|
|
|
91
71
|
}): Promise<{
|
|
92
72
|
modifiedCount: number;
|
|
93
73
|
}>;
|
|
94
|
-
saveConfirmationNumberIfNotExist(params: {
|
|
95
|
-
id: string;
|
|
96
|
-
status: {
|
|
97
|
-
$in: factory.transactionStatusType[];
|
|
98
|
-
};
|
|
99
|
-
confirmationNumber: string;
|
|
100
|
-
}): Promise<void>;
|
|
101
74
|
/**
|
|
102
75
|
* 進行中の注文取引を取得する
|
|
103
76
|
*/
|
|
@@ -226,22 +226,31 @@ class PlaceOrderRepo {
|
|
|
226
226
|
// }
|
|
227
227
|
// return doc.object.orderNumber;
|
|
228
228
|
// }
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
async findInProgressConfirmationNumberById(params
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
229
|
+
// /**
|
|
230
|
+
// * 取引の確認番号を検索する
|
|
231
|
+
// */
|
|
232
|
+
// public async findInProgressConfirmationNumberById(params: {
|
|
233
|
+
// id: string;
|
|
234
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
235
|
+
// }): Promise<string | undefined> {
|
|
236
|
+
// const doc = await this.transactionModel.findOne(
|
|
237
|
+
// {
|
|
238
|
+
// _id: { $eq: params.id },
|
|
239
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
240
|
+
// status: { $in: params.status.$in }
|
|
241
|
+
// },
|
|
242
|
+
// { 'object.confirmationNumber': 1 }
|
|
243
|
+
// )
|
|
244
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
|
|
245
|
+
// .exec();
|
|
246
|
+
// if (doc === null) {
|
|
247
|
+
// throw new factory.errors.NotFound(
|
|
248
|
+
// this.transactionModel.modelName,
|
|
249
|
+
// `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
|
|
250
|
+
// );
|
|
251
|
+
// }
|
|
252
|
+
// return doc.object.confirmationNumber;
|
|
253
|
+
// }
|
|
245
254
|
/**
|
|
246
255
|
* 取引期限変更
|
|
247
256
|
*/
|
|
@@ -263,28 +272,41 @@ class PlaceOrderRepo {
|
|
|
263
272
|
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
|
-
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
async updateObject(params
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
275
|
+
// /**
|
|
276
|
+
// * 取引オブジェクトを更新
|
|
277
|
+
// * 注文名称など
|
|
278
|
+
// */
|
|
279
|
+
// public async updateObject(params: {
|
|
280
|
+
// typeOf: factory.transactionType.PlaceOrder;
|
|
281
|
+
// id: string;
|
|
282
|
+
// object?: {
|
|
283
|
+
// name?: string;
|
|
284
|
+
// };
|
|
285
|
+
// }): Promise<void> {
|
|
286
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
287
|
+
// {
|
|
288
|
+
// _id: { $eq: params.id },
|
|
289
|
+
// typeOf: { $eq: params.typeOf },
|
|
290
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
291
|
+
// },
|
|
292
|
+
// {
|
|
293
|
+
// $set: {
|
|
294
|
+
// ...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
|
|
295
|
+
// }
|
|
296
|
+
// },
|
|
297
|
+
// {
|
|
298
|
+
// projection: { _id: 1 }
|
|
299
|
+
// }
|
|
300
|
+
// )
|
|
301
|
+
// .lean<{ _id: ObjectId }>()
|
|
302
|
+
// .exec();
|
|
303
|
+
// if (doc === null) {
|
|
304
|
+
// throw new factory.errors.NotFound(
|
|
305
|
+
// this.transactionModel.modelName,
|
|
306
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
307
|
+
// );
|
|
308
|
+
// }
|
|
309
|
+
// }
|
|
288
310
|
/**
|
|
289
311
|
* 特定の進行中取引を更新する(汎用)
|
|
290
312
|
*/
|
|
@@ -316,15 +338,22 @@ class PlaceOrderRepo {
|
|
|
316
338
|
.exec();
|
|
317
339
|
return { modifiedCount: result.modifiedCount };
|
|
318
340
|
}
|
|
319
|
-
async saveConfirmationNumberIfNotExist(params
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
341
|
+
// public async saveConfirmationNumberIfNotExist(params: {
|
|
342
|
+
// id: string;
|
|
343
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
344
|
+
// confirmationNumber: string;
|
|
345
|
+
// }): Promise<void> {
|
|
346
|
+
// await this.transactionModel.updateOne(
|
|
347
|
+
// {
|
|
348
|
+
// _id: { $eq: params.id },
|
|
349
|
+
// // status: { $eq: factory.transactionStatusType.InProgress },
|
|
350
|
+
// status: { $in: params.status.$in },
|
|
351
|
+
// 'object.confirmationNumber': { $exists: false }
|
|
352
|
+
// },
|
|
353
|
+
// { $set: { 'object.confirmationNumber': params.confirmationNumber } }
|
|
354
|
+
// )
|
|
355
|
+
// .exec();
|
|
356
|
+
// }
|
|
328
357
|
/**
|
|
329
358
|
* 進行中の注文取引を取得する
|
|
330
359
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
2
|
import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
|
+
import type { IDeleteActionResult, ActionRepo } from '../../repo/action';
|
|
3
4
|
import type { NoteRepo } from '../../repo/note';
|
|
4
5
|
import type { OrderRepo } from '../../repo/order';
|
|
5
6
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
@@ -17,8 +18,11 @@ declare function deleteOrder(params: {
|
|
|
17
18
|
}): (repos: {
|
|
18
19
|
acceptedOffer: AcceptedOfferRepo;
|
|
19
20
|
accountingReport: AccountingReportRepo;
|
|
21
|
+
action: ActionRepo;
|
|
20
22
|
note: NoteRepo;
|
|
21
23
|
order: OrderRepo;
|
|
22
24
|
reservation: ReservationRepo;
|
|
23
|
-
}) => Promise<
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
deleteActionsResult: IDeleteActionResult[];
|
|
27
|
+
}>;
|
|
24
28
|
export { deleteOrder };
|
|
@@ -12,6 +12,7 @@ function deleteOrder(params) {
|
|
|
12
12
|
if (typeof params.object.identifier !== 'string' || params.object.identifier === '') {
|
|
13
13
|
throw new factory_1.factory.errors.ArgumentNull('object.identifier');
|
|
14
14
|
}
|
|
15
|
+
let deleteActionsResult = [];
|
|
15
16
|
const orders = await repos.order.projectFields({
|
|
16
17
|
limit: 1,
|
|
17
18
|
page: 1,
|
|
@@ -21,7 +22,7 @@ function deleteOrder(params) {
|
|
|
21
22
|
const order = orders.shift();
|
|
22
23
|
if (order === undefined) {
|
|
23
24
|
// すでに削除済
|
|
24
|
-
return;
|
|
25
|
+
return { deleteActionsResult: [] };
|
|
25
26
|
}
|
|
26
27
|
if (typeof order.id !== 'string') {
|
|
27
28
|
throw new factory_1.factory.errors.Internal(`order.id undefined. orderNumber: ${order.orderNumber}`);
|
|
@@ -43,8 +44,14 @@ function deleteOrder(params) {
|
|
|
43
44
|
typeOf: factory_1.factory.order.OrderType.Order
|
|
44
45
|
}
|
|
45
46
|
});
|
|
47
|
+
// アクション削除(2026-07-10~)
|
|
48
|
+
deleteActionsResult = await repos.action.deleteActionsByOrderNumber({
|
|
49
|
+
orderNumber: order.orderNumber,
|
|
50
|
+
project: { id: order.project.id },
|
|
51
|
+
});
|
|
46
52
|
// 注文削除
|
|
47
53
|
await repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
54
|
+
return { deleteActionsResult };
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
57
|
function deleteReservationsByOrder(order) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixOrderAsNeeded = fixOrderAsNeeded;
|
|
4
|
-
const factory_1 = require("../../../../factory");
|
|
5
4
|
const publishConfirmationNumberIfNotExist_1 = require("../../../transaction/placeOrder/publishConfirmationNumberIfNotExist");
|
|
6
5
|
function fixOrderAsNeeded(params) {
|
|
7
6
|
return async (repos) => {
|
|
@@ -12,7 +11,7 @@ function fixOrderAsNeeded(params) {
|
|
|
12
11
|
// if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
13
12
|
const confirmationNumber = await (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
14
13
|
id: params.purpose.id,
|
|
15
|
-
status: { $in: [
|
|
14
|
+
// status: { $in: [factory.transactionStatusType.InProgress] },
|
|
16
15
|
object: { orderDate }
|
|
17
16
|
})(repos);
|
|
18
17
|
// }
|
package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { factory } from '../../../factory';
|
|
2
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
3
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
4
|
+
type IAuthorizePaymentAction = factory.action.authorize.paymentMethod.any.IAction;
|
|
5
|
+
export declare function deletePayTransactionsByPlaceOrder(params: {
|
|
6
|
+
authorizeActions: (IAuthorizeOfferAction | IAuthorizePaymentAction)[];
|
|
7
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'project'>;
|
|
8
|
+
}): (repos: {
|
|
9
|
+
assetTransaction: AssetTransactionRepo;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
deletePayTransactionResult: any;
|
|
12
|
+
deleteRefundResult: any;
|
|
13
|
+
payTransactionNumbers: string[];
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deletePayTransactionsByPlaceOrder = deletePayTransactionsByPlaceOrder;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const factory_1 = require("../../../factory");
|
|
6
|
+
function deletePayTransactionsByPlaceOrder(params) {
|
|
7
|
+
return async (repos) => {
|
|
8
|
+
let deletePayTransactionResult;
|
|
9
|
+
let deleteRefundResult;
|
|
10
|
+
const authorizeActions = params.authorizeActions;
|
|
11
|
+
// 決済取引番号を抽出
|
|
12
|
+
const authorizePaymentActions = authorizeActions
|
|
13
|
+
.filter((a) => {
|
|
14
|
+
return a.object.typeOf === factory_1.factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
15
|
+
&& typeof a.object?.paymentMethodId === 'string'
|
|
16
|
+
&& a.object.paymentMethodId.length > 0;
|
|
17
|
+
});
|
|
18
|
+
const payTransactionNumbers = authorizePaymentActions.map((a) => String(a.object.paymentMethodId));
|
|
19
|
+
if (payTransactionNumbers.length > 0) {
|
|
20
|
+
// 決済取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
21
|
+
const deleteAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
22
|
+
project: { id: params.transaction.project.id },
|
|
23
|
+
transactionNumbers: payTransactionNumbers,
|
|
24
|
+
typeOf: factory_1.factory.assetTransactionType.Pay
|
|
25
|
+
});
|
|
26
|
+
deletePayTransactionResult = {
|
|
27
|
+
n: deleteAssetTransactionsResult?.n,
|
|
28
|
+
ok: deleteAssetTransactionsResult?.ok,
|
|
29
|
+
deletedCount: deleteAssetTransactionsResult?.deletedCount
|
|
30
|
+
};
|
|
31
|
+
// 返金取引も削除(2023-05-19~)
|
|
32
|
+
const refundTransactions = await repos.assetTransaction.search({
|
|
33
|
+
typeOf: factory_1.factory.assetTransactionType.Refund,
|
|
34
|
+
object: { paymentMethodId: { $in: payTransactionNumbers } }
|
|
35
|
+
}, ['transactionNumber'], []);
|
|
36
|
+
if (refundTransactions.length > 0) {
|
|
37
|
+
const deleteRefundAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
38
|
+
project: { id: params.transaction.project.id },
|
|
39
|
+
transactionNumbers: refundTransactions.map(({ transactionNumber }) => transactionNumber),
|
|
40
|
+
typeOf: factory_1.factory.assetTransactionType.Refund
|
|
41
|
+
});
|
|
42
|
+
deleteRefundResult = {
|
|
43
|
+
n: deleteRefundAssetTransactionsResult?.n,
|
|
44
|
+
ok: deleteRefundAssetTransactionsResult?.ok,
|
|
45
|
+
deletedCount: deleteRefundAssetTransactionsResult?.deletedCount
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { deletePayTransactionResult, deleteRefundResult, payTransactionNumbers };
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { factory } from '../../../factory';
|
|
2
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
3
|
+
import type { ReservationRepo } from '../../../repo/reservation';
|
|
4
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
5
|
+
type IAuthorizePaymentAction = factory.action.authorize.paymentMethod.any.IAction;
|
|
6
|
+
interface IDeleteResult {
|
|
7
|
+
n?: number;
|
|
8
|
+
ok?: number;
|
|
9
|
+
deletedCount?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function deleteReservationsByPlaceOrder(params: {
|
|
12
|
+
authorizeActions: (IAuthorizeOfferAction | IAuthorizePaymentAction)[];
|
|
13
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'project'>;
|
|
14
|
+
}): (repos: {
|
|
15
|
+
assetTransaction: AssetTransactionRepo;
|
|
16
|
+
reservation: ReservationRepo;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
deleteResult?: IDeleteResult;
|
|
19
|
+
deleteReserveTransactionResult?: IDeleteResult;
|
|
20
|
+
deleteCancelReservationTransactionResult?: IDeleteResult;
|
|
21
|
+
reserveTransactionNumbers: string[];
|
|
22
|
+
}>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteReservationsByPlaceOrder = deleteReservationsByPlaceOrder;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const factory_1 = require("../../../factory");
|
|
6
|
+
function deleteReservationsByPlaceOrder(params) {
|
|
7
|
+
return async (repos) => {
|
|
8
|
+
let deleteResult;
|
|
9
|
+
let deleteReserveTransactionResult;
|
|
10
|
+
let deleteCancelReservationTransactionResult;
|
|
11
|
+
const authorizeActions = params.authorizeActions;
|
|
12
|
+
// 予約取引番号を抽出
|
|
13
|
+
const authorizeReservationOfferActions = authorizeActions
|
|
14
|
+
.filter((a) => {
|
|
15
|
+
return a.object.typeOf === factory_1.factory.action.authorize.offer.eventService.ObjectType.SeatReservation
|
|
16
|
+
&& a.instrument?.transactionNumber === 'string'
|
|
17
|
+
&& a.instrument.transactionNumber.length > 0;
|
|
18
|
+
});
|
|
19
|
+
const reserveTransactionNumbers = authorizeReservationOfferActions
|
|
20
|
+
.map((a) => String(a.instrument?.transactionNumber));
|
|
21
|
+
if (reserveTransactionNumbers.length > 0) {
|
|
22
|
+
// 該当予約番号の予約を削除する(プロジェクトでも絞ること)
|
|
23
|
+
const deleteReservationsResult = await repos.reservation.deleteByReservationNumbers({
|
|
24
|
+
project: { id: params.transaction.project.id },
|
|
25
|
+
reservationNumbers: reserveTransactionNumbers
|
|
26
|
+
});
|
|
27
|
+
deleteResult = {
|
|
28
|
+
n: deleteReservationsResult?.n,
|
|
29
|
+
ok: deleteReservationsResult?.ok,
|
|
30
|
+
deletedCount: deleteReservationsResult?.deletedCount
|
|
31
|
+
};
|
|
32
|
+
// 予約取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
33
|
+
const deleteAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
34
|
+
project: { id: params.transaction.project.id },
|
|
35
|
+
transactionNumbers: reserveTransactionNumbers,
|
|
36
|
+
typeOf: factory_1.factory.assetTransactionType.Reserve
|
|
37
|
+
});
|
|
38
|
+
deleteReserveTransactionResult = {
|
|
39
|
+
n: deleteAssetTransactionsResult?.n,
|
|
40
|
+
ok: deleteAssetTransactionsResult?.ok,
|
|
41
|
+
deletedCount: deleteAssetTransactionsResult?.deletedCount
|
|
42
|
+
};
|
|
43
|
+
// 予約番号で予約取消取引を検索
|
|
44
|
+
const deletingCancelReservationTransactions = await repos.assetTransaction.search({
|
|
45
|
+
project: { id: { $eq: params.transaction.project.id } },
|
|
46
|
+
object: { reservationNumber: { $in: reserveTransactionNumbers } },
|
|
47
|
+
typeOf: factory_1.factory.assetTransactionType.CancelReservation
|
|
48
|
+
}, ['transactionNumber'], []);
|
|
49
|
+
if (deletingCancelReservationTransactions.length > 0) {
|
|
50
|
+
// 予約取消取引も削除(2024-04-18~)
|
|
51
|
+
const deleteCancelReservationResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
52
|
+
project: { id: params.transaction.project.id },
|
|
53
|
+
transactionNumbers: deletingCancelReservationTransactions.map(({ transactionNumber }) => String(transactionNumber)),
|
|
54
|
+
typeOf: factory_1.factory.assetTransactionType.CancelReservation
|
|
55
|
+
});
|
|
56
|
+
deleteCancelReservationTransactionResult = {
|
|
57
|
+
n: deleteCancelReservationResult?.n,
|
|
58
|
+
ok: deleteCancelReservationResult?.ok,
|
|
59
|
+
deletedCount: deleteCancelReservationResult?.deletedCount
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { deleteResult, deleteReserveTransactionResult, deleteCancelReservationTransactionResult, reserveTransactionNumbers };
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -4,6 +4,8 @@ exports.deleteTransaction = deleteTransaction;
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
const factory_1 = require("../../factory");
|
|
6
6
|
const deleteOrder_1 = require("../order/deleteOrder");
|
|
7
|
+
const deletePayTransactionsByPlaceOrder_1 = require("./deleteTransaction/deletePayTransactionsByPlaceOrder");
|
|
8
|
+
const deleteReservationsByPlaceOrder_1 = require("./deleteTransaction/deleteReservationsByPlaceOrder");
|
|
7
9
|
/**
|
|
8
10
|
* 取引に関わるリソースを削除する
|
|
9
11
|
* 冪等性を確保すること
|
|
@@ -30,7 +32,6 @@ function deleteTransactionById(params) {
|
|
|
30
32
|
if (typeof deletingTransactionId !== 'string' || deletingTransactionId.length === 0) {
|
|
31
33
|
throw new factory_1.factory.errors.ArgumentNull('object.id');
|
|
32
34
|
}
|
|
33
|
-
// let deletingOrderNumberByTask: string | undefined;
|
|
34
35
|
let transaction;
|
|
35
36
|
if (params.object.typeOf === factory_1.factory.transactionType.PlaceOrder) {
|
|
36
37
|
transaction = (await repos.placeOrder.findPlaceOrderTransactions({
|
|
@@ -38,7 +39,6 @@ function deleteTransactionById(params) {
|
|
|
38
39
|
typeOf: params.object.typeOf,
|
|
39
40
|
inclusion: ['typeOf', 'project', 'status']
|
|
40
41
|
})).shift();
|
|
41
|
-
// deletingOrderNumberByTask = params.object.object.orderNumber;
|
|
42
42
|
}
|
|
43
43
|
else if (params.object.typeOf === factory_1.factory.transactionType.ReturnOrder) {
|
|
44
44
|
transaction = (await repos.returnOrder.findReturnOrderTransactions({
|
|
@@ -70,7 +70,7 @@ function deleteTransactionById(params) {
|
|
|
70
70
|
let deleteCancelReservationTransactionResult;
|
|
71
71
|
let deletedReservationNumbers = [];
|
|
72
72
|
let deleteActionResult;
|
|
73
|
-
|
|
73
|
+
let deleteOrderResult;
|
|
74
74
|
const action = await repos.action.start(actionAttributes);
|
|
75
75
|
try {
|
|
76
76
|
const transactionTypeOf = transaction.typeOf;
|
|
@@ -90,12 +90,7 @@ function deleteTransactionById(params) {
|
|
|
90
90
|
break;
|
|
91
91
|
case factory_1.factory.transactionStatusType.Confirmed: {
|
|
92
92
|
// identifierによる削除に変更(2026-06-28~)
|
|
93
|
-
|
|
94
|
-
// await deleteOrder({
|
|
95
|
-
// object: { orderNumber: deletingOrderNumberByTask }
|
|
96
|
-
// })(repos);
|
|
97
|
-
// }
|
|
98
|
-
await (0, deleteOrder_1.deleteOrder)({
|
|
93
|
+
deleteOrderResult = await (0, deleteOrder_1.deleteOrder)({
|
|
99
94
|
object: { identifier: transaction.id }
|
|
100
95
|
})(repos);
|
|
101
96
|
break;
|
|
@@ -104,27 +99,29 @@ function deleteTransactionById(params) {
|
|
|
104
99
|
throw new factory_1.factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
105
100
|
}
|
|
106
101
|
// 決済取引を削除
|
|
107
|
-
const deletePayTransactionsByPlaceOrderResult = await deletePayTransactionsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
102
|
+
const deletePayTransactionsByPlaceOrderResult = await (0, deletePayTransactionsByPlaceOrder_1.deletePayTransactionsByPlaceOrder)({ authorizeActions, transaction })(repos);
|
|
108
103
|
deletePayTransactionResult = deletePayTransactionsByPlaceOrderResult.deletePayTransactionResult;
|
|
109
104
|
deleteRefundResult = deletePayTransactionsByPlaceOrderResult.deleteRefundResult;
|
|
110
105
|
payTransactionNumbers = deletePayTransactionsByPlaceOrderResult.payTransactionNumbers;
|
|
111
106
|
// 取引上での予約を削除
|
|
112
|
-
const deleteReservationsByPlaceOrderResult = await deleteReservationsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
107
|
+
const deleteReservationsByPlaceOrderResult = await (0, deleteReservationsByPlaceOrder_1.deleteReservationsByPlaceOrder)({ authorizeActions, transaction })(repos);
|
|
113
108
|
deleteReservationsResult = deleteReservationsByPlaceOrderResult.deleteResult;
|
|
114
109
|
deleteReserveTransactionResult = deleteReservationsByPlaceOrderResult.deleteReserveTransactionResult;
|
|
115
110
|
deleteCancelReservationTransactionResult =
|
|
116
111
|
deleteReservationsByPlaceOrderResult.deleteCancelReservationTransactionResult;
|
|
117
112
|
deletedReservationNumbers = deleteReservationsByPlaceOrderResult.reserveTransactionNumbers;
|
|
118
113
|
// アクション削除(2023-05-19~)
|
|
119
|
-
deleteActionResult = await repos.action.
|
|
114
|
+
deleteActionResult = await repos.action.deleteActionsByTransactionId({
|
|
120
115
|
project: { id: transaction.project.id },
|
|
121
|
-
|
|
116
|
+
transaction: { id: transaction.id, typeOf: transactionTypeOf },
|
|
122
117
|
typeOf: {
|
|
123
118
|
$in: [
|
|
124
|
-
factory_1.factory.actionType.
|
|
125
|
-
factory_1.factory.actionType.
|
|
126
|
-
factory_1.factory.actionType.
|
|
127
|
-
|
|
119
|
+
factory_1.factory.actionType.AcceptAction, // オファー採用、決済採用
|
|
120
|
+
factory_1.factory.actionType.AuthorizeAction, // オファー承認、決済承認
|
|
121
|
+
factory_1.factory.actionType.CheckAction, // 決済カード認証
|
|
122
|
+
// factory.actionType.InformAction, // 通知は特になし
|
|
123
|
+
factory_1.factory.actionType.OrderAction, // 注文
|
|
124
|
+
factory_1.factory.actionType.RefundAction // 決済採用返金
|
|
128
125
|
]
|
|
129
126
|
}
|
|
130
127
|
});
|
|
@@ -166,143 +163,9 @@ function deleteTransactionById(params) {
|
|
|
166
163
|
deleteCancelReservationTransactionResult,
|
|
167
164
|
deletedReservationNumbers,
|
|
168
165
|
deleteActionResult,
|
|
166
|
+
deleteOrderResult // 2026-07-10~
|
|
169
167
|
// ...(deleteMessagessResult !== undefined) ? { deleteMessagessResult } : undefined
|
|
170
168
|
};
|
|
171
169
|
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
172
170
|
};
|
|
173
171
|
}
|
|
174
|
-
function deleteReservationsByPlaceOrder(params) {
|
|
175
|
-
return async (repos) => {
|
|
176
|
-
let deleteResult;
|
|
177
|
-
let deleteReserveTransactionResult;
|
|
178
|
-
let deleteCancelReservationTransactionResult;
|
|
179
|
-
const authorizeActions = params.authorizeActions;
|
|
180
|
-
// 予約取引番号を抽出
|
|
181
|
-
const authorizeReservationOfferActions = authorizeActions
|
|
182
|
-
.filter((a) => {
|
|
183
|
-
const pendingTransactionNumber = a.instrument?.transactionNumber;
|
|
184
|
-
return a.object.typeOf === factory_1.factory.action.authorize.offer.eventService.ObjectType.SeatReservation
|
|
185
|
-
&& typeof pendingTransactionNumber === 'string'
|
|
186
|
-
&& pendingTransactionNumber.length > 0;
|
|
187
|
-
});
|
|
188
|
-
const reserveTransactionNumbers = authorizeReservationOfferActions
|
|
189
|
-
.map((a) => String(a.instrument?.transactionNumber));
|
|
190
|
-
if (reserveTransactionNumbers.length > 0) {
|
|
191
|
-
// 該当予約番号の予約を削除する(プロジェクトでも絞ること)
|
|
192
|
-
const deleteReservationsResult = await repos.reservation.deleteByReservationNumbers({
|
|
193
|
-
project: { id: params.transaction.project.id },
|
|
194
|
-
reservationNumbers: reserveTransactionNumbers
|
|
195
|
-
});
|
|
196
|
-
deleteResult = {
|
|
197
|
-
n: deleteReservationsResult?.n,
|
|
198
|
-
ok: deleteReservationsResult?.ok,
|
|
199
|
-
deletedCount: deleteReservationsResult?.deletedCount
|
|
200
|
-
};
|
|
201
|
-
// 予約取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
202
|
-
const deleteAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
203
|
-
project: { id: params.transaction.project.id },
|
|
204
|
-
transactionNumbers: reserveTransactionNumbers,
|
|
205
|
-
typeOf: factory_1.factory.assetTransactionType.Reserve
|
|
206
|
-
});
|
|
207
|
-
deleteReserveTransactionResult = {
|
|
208
|
-
n: deleteAssetTransactionsResult?.n,
|
|
209
|
-
ok: deleteAssetTransactionsResult?.ok,
|
|
210
|
-
deletedCount: deleteAssetTransactionsResult?.deletedCount
|
|
211
|
-
};
|
|
212
|
-
// 予約番号で予約取消取引を検索
|
|
213
|
-
const deletingCancelReservationTransactions = await repos.assetTransaction.search({
|
|
214
|
-
project: { id: { $eq: params.transaction.project.id } },
|
|
215
|
-
object: { reservationNumber: { $in: reserveTransactionNumbers } },
|
|
216
|
-
typeOf: factory_1.factory.assetTransactionType.CancelReservation
|
|
217
|
-
}, ['transactionNumber'], []);
|
|
218
|
-
if (deletingCancelReservationTransactions.length > 0) {
|
|
219
|
-
// 予約取消取引も削除(2024-04-18~)
|
|
220
|
-
const deleteCancelReservationResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
221
|
-
project: { id: params.transaction.project.id },
|
|
222
|
-
transactionNumbers: deletingCancelReservationTransactions.map(({ transactionNumber }) => String(transactionNumber)),
|
|
223
|
-
typeOf: factory_1.factory.assetTransactionType.CancelReservation
|
|
224
|
-
});
|
|
225
|
-
deleteCancelReservationTransactionResult = {
|
|
226
|
-
n: deleteCancelReservationResult?.n,
|
|
227
|
-
ok: deleteCancelReservationResult?.ok,
|
|
228
|
-
deletedCount: deleteCancelReservationResult?.deletedCount
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return { deleteResult, deleteReserveTransactionResult, deleteCancelReservationTransactionResult, reserveTransactionNumbers };
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function deletePayTransactionsByPlaceOrder(params) {
|
|
236
|
-
return async (repos) => {
|
|
237
|
-
let deletePayTransactionResult;
|
|
238
|
-
let deleteRefundResult;
|
|
239
|
-
const authorizeActions = params.authorizeActions;
|
|
240
|
-
// 決済取引番号を抽出
|
|
241
|
-
const authorizePaymentActions = authorizeActions
|
|
242
|
-
.filter((a) => {
|
|
243
|
-
const pendingTransactionNumber = a.object?.paymentMethodId;
|
|
244
|
-
return a.object.typeOf === factory_1.factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
245
|
-
&& typeof pendingTransactionNumber === 'string'
|
|
246
|
-
&& pendingTransactionNumber.length > 0;
|
|
247
|
-
});
|
|
248
|
-
const payTransactionNumbers = authorizePaymentActions.map((a) => String(a.object.paymentMethodId));
|
|
249
|
-
if (payTransactionNumbers.length > 0) {
|
|
250
|
-
// 決済取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
251
|
-
const deleteAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
252
|
-
project: { id: params.transaction.project.id },
|
|
253
|
-
transactionNumbers: payTransactionNumbers,
|
|
254
|
-
typeOf: factory_1.factory.assetTransactionType.Pay
|
|
255
|
-
});
|
|
256
|
-
deletePayTransactionResult = {
|
|
257
|
-
n: deleteAssetTransactionsResult?.n,
|
|
258
|
-
ok: deleteAssetTransactionsResult?.ok,
|
|
259
|
-
deletedCount: deleteAssetTransactionsResult?.deletedCount
|
|
260
|
-
};
|
|
261
|
-
// 返金取引も削除(2023-05-19~)
|
|
262
|
-
const refundTransactions = await repos.assetTransaction.search({
|
|
263
|
-
typeOf: factory_1.factory.assetTransactionType.Refund,
|
|
264
|
-
object: { paymentMethodId: { $in: payTransactionNumbers } }
|
|
265
|
-
}, ['transactionNumber'], []);
|
|
266
|
-
if (refundTransactions.length > 0) {
|
|
267
|
-
const deleteRefundAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
268
|
-
project: { id: params.transaction.project.id },
|
|
269
|
-
transactionNumbers: refundTransactions.map(({ transactionNumber }) => transactionNumber),
|
|
270
|
-
typeOf: factory_1.factory.assetTransactionType.Refund
|
|
271
|
-
});
|
|
272
|
-
deleteRefundResult = {
|
|
273
|
-
n: deleteRefundAssetTransactionsResult?.n,
|
|
274
|
-
ok: deleteRefundAssetTransactionsResult?.ok,
|
|
275
|
-
deletedCount: deleteRefundAssetTransactionsResult?.deletedCount
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return { deletePayTransactionResult, deleteRefundResult, payTransactionNumbers };
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
// function deleteMessagesByPlaceOrder(params: {
|
|
283
|
-
// transaction: factory.task.deleteTransaction.IObject;
|
|
284
|
-
// }) {
|
|
285
|
-
// return async (repos: {
|
|
286
|
-
// message: MessageRepo;
|
|
287
|
-
// }): Promise<{
|
|
288
|
-
// deleteResult?: IDeleteResult;
|
|
289
|
-
// }> => {
|
|
290
|
-
// let deleteResult: IDeleteResult | undefined;
|
|
291
|
-
// if (params.transaction.typeOf === factory.transactionType.PlaceOrder
|
|
292
|
-
// && params.transaction.specifyingMethod === factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
293
|
-
// const orderNumber = params.transaction.object.orderNumber;
|
|
294
|
-
// if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
295
|
-
// const deleteReservationsResult = await repos.message.deleteByMainEntityOrderNumber({
|
|
296
|
-
// project: { id: params.transaction.project.id },
|
|
297
|
-
// mainEntity: { orderNumber }
|
|
298
|
-
// });
|
|
299
|
-
// deleteResult = {
|
|
300
|
-
// n: deleteReservationsResult?.n,
|
|
301
|
-
// ok: deleteReservationsResult?.ok,
|
|
302
|
-
// deletedCount: deleteReservationsResult?.deletedCount
|
|
303
|
-
// };
|
|
304
|
-
// }
|
|
305
|
-
// }
|
|
306
|
-
// return { deleteResult };
|
|
307
|
-
// };
|
|
308
|
-
// }
|
|
@@ -60,7 +60,7 @@ function confirm(params, options) {
|
|
|
60
60
|
// 確認番号を事前発行
|
|
61
61
|
const confirmationNumber = await (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
62
62
|
id: params.id,
|
|
63
|
-
status: { $in: [
|
|
63
|
+
// status: { $in: [factory.transactionStatusType.Confirmed, factory.transactionStatusType.InProgress] },
|
|
64
64
|
object: { orderDate: params.result.order.orderDate }
|
|
65
65
|
})(repos);
|
|
66
66
|
const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
2
2
|
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
3
|
-
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
4
|
-
import { factory } from '../../../factory';
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* 未発行であれば、確認番号を発行して注文ドキュメントに保管する
|
|
5
|
+
* reimplement using OrderInTransactionRepo(2026-07-09~)
|
|
7
6
|
*/
|
|
8
7
|
declare function publishConfirmationNumberIfNotExist(params: {
|
|
9
8
|
/**
|
|
10
9
|
* 取引ID
|
|
11
10
|
*/
|
|
12
11
|
id: string;
|
|
13
|
-
status: {
|
|
14
|
-
$in: factory.transactionStatusType[];
|
|
15
|
-
};
|
|
16
12
|
object: {
|
|
17
13
|
orderDate: Date;
|
|
18
14
|
};
|
|
19
15
|
}): (repos: {
|
|
20
|
-
placeOrder: PlaceOrderRepo;
|
|
21
16
|
confirmationNumber: ConfirmationNumberRepo;
|
|
22
17
|
orderInTransaction: OrderInTransactionRepo;
|
|
23
18
|
}) => Promise<string>;
|
|
@@ -1,41 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
// import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
4
9
|
const factory_1 = require("../../../factory");
|
|
10
|
+
const debug = (0, debug_1.default)('chevre-domain:service:transaction:placeOrder:publishConfirmationNumberIfNotExist');
|
|
5
11
|
/**
|
|
6
|
-
*
|
|
12
|
+
* 未発行であれば、確認番号を発行して注文ドキュメントに保管する
|
|
13
|
+
* reimplement using OrderInTransactionRepo(2026-07-09~)
|
|
7
14
|
*/
|
|
8
15
|
function publishConfirmationNumberIfNotExist(params) {
|
|
9
16
|
return async (repos) => {
|
|
10
|
-
let confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
17
|
+
// let confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
|
|
18
|
+
// id: params.id,
|
|
19
|
+
// status: { $in: params.status.$in }
|
|
20
|
+
// });
|
|
21
|
+
let confirmationNumber = await repos.orderInTransaction.findConfirmationNumberByIdentifier({ identifier: params.id });
|
|
22
|
+
debug('already exists?', confirmationNumber);
|
|
14
23
|
// すでに発行済であれば何もしない
|
|
15
24
|
if (typeof confirmationNumber === 'string') {
|
|
16
25
|
return confirmationNumber;
|
|
17
26
|
}
|
|
18
27
|
// 確認番号を発行
|
|
19
28
|
confirmationNumber = await repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
debug('saving new confirmationNumber...', confirmationNumber);
|
|
30
|
+
// // 取引に存在しなければ保管
|
|
31
|
+
// await repos.placeOrder.saveConfirmationNumberIfNotExist({
|
|
32
|
+
// id: params.id,
|
|
33
|
+
// status: { $in: params.status.$in },
|
|
34
|
+
// confirmationNumber
|
|
35
|
+
// });
|
|
26
36
|
// 注文ドキュメントにも保管(2026-07-08~)
|
|
27
|
-
await repos.orderInTransaction.saveConfirmationNumberIfNotExist({
|
|
37
|
+
const saveResult = await repos.orderInTransaction.saveConfirmationNumberIfNotExist({
|
|
28
38
|
identifier: params.id,
|
|
29
39
|
confirmationNumber
|
|
30
40
|
}, { onlyPlaceOrder: true });
|
|
41
|
+
debug('saveConfirmationNumberIfNotExist result:', JSON.stringify(saveResult));
|
|
31
42
|
// 確認番号を取引から再取得
|
|
32
|
-
confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
43
|
+
// confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
|
|
44
|
+
// id: params.id,
|
|
45
|
+
// status: { $in: params.status.$in }
|
|
46
|
+
// });
|
|
47
|
+
confirmationNumber = await repos.orderInTransaction.findConfirmationNumberByIdentifier({ identifier: params.id });
|
|
48
|
+
debug('confirmationNumber should exist:', confirmationNumber);
|
|
36
49
|
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
37
50
|
if (typeof confirmationNumber !== 'string') {
|
|
38
|
-
throw new factory_1.factory.errors.Internal('
|
|
51
|
+
throw new factory_1.factory.errors.Internal('orderInTransaction.confirmationNumber not found');
|
|
39
52
|
}
|
|
40
53
|
return confirmationNumber;
|
|
41
54
|
};
|
package/package.json
CHANGED