@chevre/domain 24.0.0-alpha.6 → 24.0.0-alpha.7
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/mongoose/schemas/transaction.js +16 -0
- package/lib/chevre/repo/orderNumber.d.ts +3 -2
- package/lib/chevre/repo/orderNumber.js +17 -15
- package/lib/chevre/repo/transaction/placeOrder.d.ts +76 -0
- package/lib/chevre/repo/transaction/placeOrder.js +170 -0
- package/lib/chevre/repo/transaction.d.ts +0 -62
- package/lib/chevre/repo/transaction.js +205 -146
- package/lib/chevre/repository.d.ts +7 -0
- package/lib/chevre/repository.js +15 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +4 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +2 -9
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -0
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -2
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -0
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +3 -6
- package/lib/chevre/service/payment/any.d.ts +3 -0
- package/lib/chevre/service/payment/any.js +4 -4
- package/lib/chevre/service/task/acceptCOAOffer.js +3 -1
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +2 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -0
- package/lib/chevre/service/transaction/placeOrder/confirm.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
- package/lib/chevre/service/transaction.d.ts +2 -0
- package/lib/chevre/service/transaction.js +2 -2
- package/package.json +1 -1
|
@@ -60,27 +60,22 @@ class TransactionRepo {
|
|
|
60
60
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
61
61
|
const andConditions = [];
|
|
62
62
|
const projectIdEq = params.project?.id?.$eq;
|
|
63
|
-
/* istanbul ignore else */
|
|
64
63
|
if (typeof projectIdEq === 'string') {
|
|
65
64
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
66
65
|
}
|
|
67
|
-
/* istanbul ignore else */
|
|
68
66
|
if (typeof params.typeOf === 'string') {
|
|
69
67
|
andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
70
68
|
}
|
|
71
|
-
/* istanbul ignore else */
|
|
72
69
|
if (params.startFrom !== undefined) {
|
|
73
70
|
andConditions.push({
|
|
74
71
|
startDate: { $gte: params.startFrom }
|
|
75
72
|
});
|
|
76
73
|
}
|
|
77
|
-
/* istanbul ignore else */
|
|
78
74
|
if (params.startThrough !== undefined) {
|
|
79
75
|
andConditions.push({
|
|
80
76
|
startDate: { $lte: params.startThrough }
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
|
-
/* istanbul ignore else */
|
|
84
79
|
if (params.endFrom !== undefined) {
|
|
85
80
|
andConditions.push({
|
|
86
81
|
endDate: {
|
|
@@ -89,7 +84,6 @@ class TransactionRepo {
|
|
|
89
84
|
}
|
|
90
85
|
});
|
|
91
86
|
}
|
|
92
|
-
/* istanbul ignore else */
|
|
93
87
|
if (params.endThrough !== undefined) {
|
|
94
88
|
andConditions.push({
|
|
95
89
|
endDate: {
|
|
@@ -98,24 +92,19 @@ class TransactionRepo {
|
|
|
98
92
|
}
|
|
99
93
|
});
|
|
100
94
|
}
|
|
101
|
-
/* istanbul ignore else */
|
|
102
95
|
if (Array.isArray(params.ids)) {
|
|
103
96
|
andConditions.push({
|
|
104
97
|
_id: { $in: params.ids }
|
|
105
98
|
});
|
|
106
99
|
}
|
|
107
|
-
/* istanbul ignore else */
|
|
108
100
|
if (Array.isArray(params.statuses)) {
|
|
109
101
|
andConditions.push({ status: { $in: params.statuses } });
|
|
110
102
|
}
|
|
111
|
-
/* istanbul ignore else */
|
|
112
103
|
const statusIn = params.status?.$in;
|
|
113
104
|
if (Array.isArray(statusIn)) {
|
|
114
105
|
andConditions.push({ status: { $in: statusIn } });
|
|
115
106
|
}
|
|
116
|
-
/* istanbul ignore else */
|
|
117
107
|
if (params.agent !== undefined) {
|
|
118
|
-
/* istanbul ignore else */
|
|
119
108
|
if (params.agent.typeOf !== undefined) {
|
|
120
109
|
andConditions.push({
|
|
121
110
|
'agent.typeOf': {
|
|
@@ -124,7 +113,6 @@ class TransactionRepo {
|
|
|
124
113
|
}
|
|
125
114
|
});
|
|
126
115
|
}
|
|
127
|
-
/* istanbul ignore else */
|
|
128
116
|
if (Array.isArray(params.agent.ids)) {
|
|
129
117
|
andConditions.push({
|
|
130
118
|
'agent.id': {
|
|
@@ -133,7 +121,6 @@ class TransactionRepo {
|
|
|
133
121
|
}
|
|
134
122
|
});
|
|
135
123
|
}
|
|
136
|
-
/* istanbul ignore else */
|
|
137
124
|
if (Array.isArray(params.agent.identifiers)) {
|
|
138
125
|
andConditions.push({
|
|
139
126
|
'agent.identifier': {
|
|
@@ -176,12 +163,10 @@ class TransactionRepo {
|
|
|
176
163
|
// }
|
|
177
164
|
}
|
|
178
165
|
const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
179
|
-
/* istanbul ignore else */
|
|
180
166
|
if (Array.isArray(tasksExportActionStatusIn)) {
|
|
181
167
|
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
182
168
|
}
|
|
183
169
|
const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
184
|
-
/* istanbul ignore else */
|
|
185
170
|
if (typeof tasksExportActionStatusEq === 'string') {
|
|
186
171
|
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
|
|
187
172
|
}
|
|
@@ -207,11 +192,8 @@ class TransactionRepo {
|
|
|
207
192
|
}
|
|
208
193
|
break;
|
|
209
194
|
case factory.transactionType.ReturnOrder:
|
|
210
|
-
/* istanbul ignore else */
|
|
211
195
|
if (params.object !== undefined) {
|
|
212
|
-
/* istanbul ignore else */
|
|
213
196
|
if (params.object.order !== undefined) {
|
|
214
|
-
/* istanbul ignore else */
|
|
215
197
|
if (Array.isArray(params.object.order.orderNumbers)) {
|
|
216
198
|
andConditions.push({
|
|
217
199
|
'object.order.orderNumber': {
|
|
@@ -378,54 +360,79 @@ class TransactionRepo {
|
|
|
378
360
|
}
|
|
379
361
|
return doc;
|
|
380
362
|
}
|
|
381
|
-
/**
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
async findInProgressPaymentMethodId(params
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
363
|
+
// /**
|
|
364
|
+
// * 進行中取引に保管された採用済決済方法を検索する
|
|
365
|
+
// */
|
|
366
|
+
// public async findInProgressPaymentMethodId(params: {
|
|
367
|
+
// id: string;
|
|
368
|
+
// }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined> {
|
|
369
|
+
// const doc = await this.transactionModel.findOne(
|
|
370
|
+
// {
|
|
371
|
+
// _id: { $eq: params.id },
|
|
372
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
373
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
374
|
+
// },
|
|
375
|
+
// { 'object.paymentMethods': 1 }
|
|
376
|
+
// )
|
|
377
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>() // 2024-08-26~
|
|
378
|
+
// .exec();
|
|
379
|
+
// if (doc === null) {
|
|
380
|
+
// throw new factory.errors.NotFound(
|
|
381
|
+
// this.transactionModel.modelName,
|
|
382
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
383
|
+
// );
|
|
384
|
+
// }
|
|
385
|
+
// return doc.object.paymentMethods;
|
|
386
|
+
// }
|
|
387
|
+
// /**
|
|
388
|
+
// * 取引の注文番号を検索する
|
|
389
|
+
// */
|
|
390
|
+
// public async findInProgressOrderNumberById(params: {
|
|
391
|
+
// id: string;
|
|
392
|
+
// }): Promise<string | undefined> {
|
|
393
|
+
// const doc = await this.transactionModel.findOne(
|
|
394
|
+
// {
|
|
395
|
+
// _id: { $eq: params.id },
|
|
396
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
397
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
398
|
+
// },
|
|
399
|
+
// { 'object.orderNumber': 1 }
|
|
400
|
+
// )
|
|
401
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
|
|
402
|
+
// .exec();
|
|
403
|
+
// if (doc === null) {
|
|
404
|
+
// throw new factory.errors.NotFound(
|
|
405
|
+
// this.transactionModel.modelName,
|
|
406
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
407
|
+
// );
|
|
408
|
+
// }
|
|
409
|
+
// return doc.object.orderNumber;
|
|
410
|
+
// }
|
|
411
|
+
// /**
|
|
412
|
+
// * 取引の確認番号を検索する
|
|
413
|
+
// */
|
|
414
|
+
// public async findInProgressConfirmationNumberById(params: {
|
|
415
|
+
// id: string;
|
|
416
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
417
|
+
// }): Promise<string | undefined> {
|
|
418
|
+
// const doc = await this.transactionModel.findOne(
|
|
419
|
+
// {
|
|
420
|
+
// _id: { $eq: params.id },
|
|
421
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
422
|
+
// status: { $in: params.status.$in }
|
|
423
|
+
// },
|
|
424
|
+
// { 'object.confirmationNumber': 1 }
|
|
425
|
+
// )
|
|
426
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
|
|
427
|
+
// .exec();
|
|
428
|
+
// if (doc === null) {
|
|
429
|
+
// throw new factory.errors.NotFound(
|
|
430
|
+
// this.transactionModel.modelName,
|
|
431
|
+
// `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
|
|
432
|
+
// );
|
|
433
|
+
// }
|
|
434
|
+
// return doc.object.confirmationNumber;
|
|
435
|
+
// }
|
|
429
436
|
/**
|
|
430
437
|
* 取引進行者プロフィールを更新
|
|
431
438
|
*/
|
|
@@ -449,49 +456,73 @@ class TransactionRepo {
|
|
|
449
456
|
throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
|
|
450
457
|
}
|
|
451
458
|
}
|
|
452
|
-
/**
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
async updateExpires(params
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
459
|
+
// /**
|
|
460
|
+
// * 取引期限変更
|
|
461
|
+
// */
|
|
462
|
+
// public async updateExpires<T extends factory.transactionType>(params: {
|
|
463
|
+
// typeOf: T;
|
|
464
|
+
// id: string;
|
|
465
|
+
// expires: Date;
|
|
466
|
+
// }): Promise<void> {
|
|
467
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
468
|
+
// {
|
|
469
|
+
// _id: { $eq: params.id },
|
|
470
|
+
// typeOf: { $eq: params.typeOf },
|
|
471
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
472
|
+
// },
|
|
473
|
+
// {
|
|
474
|
+
// $set: {
|
|
475
|
+
// expires: params.expires
|
|
476
|
+
// }
|
|
477
|
+
// },
|
|
478
|
+
// {
|
|
479
|
+
// projection: { _id: 1 }
|
|
480
|
+
// }
|
|
481
|
+
// )
|
|
482
|
+
// .lean<{ _id: ObjectId }>()
|
|
483
|
+
// .exec();
|
|
484
|
+
// if (doc === null) {
|
|
485
|
+
// throw new factory.errors.NotFound(
|
|
486
|
+
// this.transactionModel.modelName,
|
|
487
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
488
|
+
// );
|
|
489
|
+
// }
|
|
490
|
+
// }
|
|
491
|
+
// /**
|
|
492
|
+
// * 取引オブジェクトを更新
|
|
493
|
+
// * 注文名称など
|
|
494
|
+
// */
|
|
495
|
+
// public async updateObject<T extends factory.transactionType>(params: {
|
|
496
|
+
// typeOf: T;
|
|
497
|
+
// id: string;
|
|
498
|
+
// object?: {
|
|
499
|
+
// name?: string;
|
|
500
|
+
// };
|
|
501
|
+
// }): Promise<void> {
|
|
502
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
503
|
+
// {
|
|
504
|
+
// _id: { $eq: params.id },
|
|
505
|
+
// typeOf: { $eq: params.typeOf },
|
|
506
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
507
|
+
// },
|
|
508
|
+
// {
|
|
509
|
+
// $set: {
|
|
510
|
+
// ...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
|
|
511
|
+
// }
|
|
512
|
+
// },
|
|
513
|
+
// {
|
|
514
|
+
// projection: { _id: 1 }
|
|
515
|
+
// }
|
|
516
|
+
// )
|
|
517
|
+
// .lean<{ _id: ObjectId }>()
|
|
518
|
+
// .exec();
|
|
519
|
+
// if (doc === null) {
|
|
520
|
+
// throw new factory.errors.NotFound(
|
|
521
|
+
// this.transactionModel.modelName,
|
|
522
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
523
|
+
// );
|
|
524
|
+
// }
|
|
525
|
+
// }
|
|
495
526
|
/**
|
|
496
527
|
* 取引を確定する
|
|
497
528
|
*/
|
|
@@ -947,52 +978,80 @@ class TransactionRepo {
|
|
|
947
978
|
query.limit(params.limit)
|
|
948
979
|
.skip(params.limit * (page - 1));
|
|
949
980
|
}
|
|
950
|
-
/* istanbul ignore else */
|
|
951
981
|
if (params.sort?.startDate !== undefined) {
|
|
952
982
|
query.sort({ startDate: params.sort.startDate });
|
|
953
983
|
}
|
|
954
984
|
// const explainResult = await (<any>query).explain();
|
|
955
985
|
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
956
986
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
957
|
-
.lean() // 2024-08-26~
|
|
958
|
-
.exec();
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* 特定の進行中取引を更新する(汎用)
|
|
962
|
-
*/
|
|
963
|
-
async findByIdAndUpdateInProgress(params) {
|
|
964
|
-
await this.transactionModel.findOneAndUpdate({
|
|
965
|
-
_id: { $eq: params.id },
|
|
966
|
-
status: { $eq: factory.transactionStatusType.InProgress }
|
|
967
|
-
}, params.update, {
|
|
968
|
-
// new: true,
|
|
969
|
-
projection: { _id: 1 }
|
|
970
|
-
})
|
|
971
987
|
.lean()
|
|
972
|
-
.exec()
|
|
973
|
-
.then((doc) => {
|
|
974
|
-
if (doc === null) {
|
|
975
|
-
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
async saveOrderNumberIfNotExist(params) {
|
|
980
|
-
await this.transactionModel.updateOne({
|
|
981
|
-
_id: { $eq: params.id },
|
|
982
|
-
status: { $eq: factory.transactionStatusType.InProgress },
|
|
983
|
-
'object.orderNumber': { $exists: false }
|
|
984
|
-
}, { 'object.orderNumber': params.orderNumber })
|
|
985
|
-
.exec();
|
|
986
|
-
}
|
|
987
|
-
async saveConfirmationNumberIfNotExist(params) {
|
|
988
|
-
await this.transactionModel.updateOne({
|
|
989
|
-
_id: { $eq: params.id },
|
|
990
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
991
|
-
status: { $in: params.status.$in },
|
|
992
|
-
'object.confirmationNumber': { $exists: false }
|
|
993
|
-
}, { $set: { 'object.confirmationNumber': params.confirmationNumber } })
|
|
994
988
|
.exec();
|
|
995
989
|
}
|
|
990
|
+
// /**
|
|
991
|
+
// * 特定の進行中取引を更新する(汎用)
|
|
992
|
+
// */
|
|
993
|
+
// public async findByIdAndUpdateInProgress(params: {
|
|
994
|
+
// id: string;
|
|
995
|
+
// update: {
|
|
996
|
+
// $set?: { 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl };
|
|
997
|
+
// // $unset?: any;
|
|
998
|
+
// // $pull?: any;
|
|
999
|
+
// // $push?: any;
|
|
1000
|
+
// };
|
|
1001
|
+
// }): Promise<void> {
|
|
1002
|
+
// await this.transactionModel.findOneAndUpdate(
|
|
1003
|
+
// {
|
|
1004
|
+
// _id: { $eq: params.id },
|
|
1005
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
1006
|
+
// },
|
|
1007
|
+
// params.update,
|
|
1008
|
+
// {
|
|
1009
|
+
// // new: true,
|
|
1010
|
+
// projection: { _id: 1 }
|
|
1011
|
+
// }
|
|
1012
|
+
// )
|
|
1013
|
+
// .lean<{ _id: ObjectId }>()
|
|
1014
|
+
// .exec()
|
|
1015
|
+
// .then((doc) => {
|
|
1016
|
+
// if (doc === null) {
|
|
1017
|
+
// throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
1018
|
+
// }
|
|
1019
|
+
// });
|
|
1020
|
+
// }
|
|
1021
|
+
// /**
|
|
1022
|
+
// * 進行中取引のobjectに注文番号を保管する
|
|
1023
|
+
// */
|
|
1024
|
+
// public async saveOrderNumberIfNotExist(params: {
|
|
1025
|
+
// id: string;
|
|
1026
|
+
// orderNumber: string;
|
|
1027
|
+
// }): Promise<{ modifiedCount: number }> {
|
|
1028
|
+
// const result = await this.transactionModel.updateOne(
|
|
1029
|
+
// {
|
|
1030
|
+
// _id: { $eq: params.id },
|
|
1031
|
+
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
1032
|
+
// 'object.orderNumber': { $exists: false }
|
|
1033
|
+
// },
|
|
1034
|
+
// { $set: { 'object.orderNumber': params.orderNumber } }
|
|
1035
|
+
// )
|
|
1036
|
+
// .exec();
|
|
1037
|
+
// return { modifiedCount: result.modifiedCount };
|
|
1038
|
+
// }
|
|
1039
|
+
// public async saveConfirmationNumberIfNotExist(params: {
|
|
1040
|
+
// id: string;
|
|
1041
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
1042
|
+
// confirmationNumber: string;
|
|
1043
|
+
// }): Promise<void> {
|
|
1044
|
+
// await this.transactionModel.updateOne(
|
|
1045
|
+
// {
|
|
1046
|
+
// _id: { $eq: params.id },
|
|
1047
|
+
// // status: { $eq: factory.transactionStatusType.InProgress },
|
|
1048
|
+
// status: { $in: params.status.$in },
|
|
1049
|
+
// 'object.confirmationNumber': { $exists: false }
|
|
1050
|
+
// },
|
|
1051
|
+
// { $set: { 'object.confirmationNumber': params.confirmationNumber } }
|
|
1052
|
+
// )
|
|
1053
|
+
// .exec();
|
|
1054
|
+
// }
|
|
996
1055
|
async findByIdAndDelete(params) {
|
|
997
1056
|
await this.transactionModel.findByIdAndDelete(params.id)
|
|
998
1057
|
.exec();
|
|
@@ -84,6 +84,7 @@ import type { TaskRepo } from './repo/task';
|
|
|
84
84
|
import type { TelemetryRepo } from './repo/telemetry';
|
|
85
85
|
import type { TicketRepo } from './repo/ticket';
|
|
86
86
|
import type { TransactionRepo } from './repo/transaction';
|
|
87
|
+
import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
|
|
87
88
|
import type { TransactionNumberRepo } from './repo/transactionNumber';
|
|
88
89
|
import type { TransactionProcessRepo } from './repo/transactionProcess';
|
|
89
90
|
import type { TripRepo } from './repo/trip';
|
|
@@ -466,6 +467,12 @@ export type Transaction = TransactionRepo;
|
|
|
466
467
|
export declare namespace Transaction {
|
|
467
468
|
function createInstance(...params: ConstructorParameters<typeof TransactionRepo>): Promise<TransactionRepo>;
|
|
468
469
|
}
|
|
470
|
+
export declare namespace transaction {
|
|
471
|
+
type PlaceOrder = PlaceOrderRepo;
|
|
472
|
+
namespace PlaceOrder {
|
|
473
|
+
function createInstance(...params: ConstructorParameters<typeof PlaceOrderRepo>): Promise<PlaceOrderRepo>;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
469
476
|
export type TransactionNumber = TransactionNumberRepo;
|
|
470
477
|
export declare namespace TransactionNumber {
|
|
471
478
|
function createInstance(...params: ConstructorParameters<typeof TransactionNumberRepo>): Promise<TransactionNumberRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedPaymentMethod = exports.AcceptedOffer = void 0;
|
|
27
|
-
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
|
|
27
|
+
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
|
|
28
28
|
var AcceptedOffer;
|
|
29
29
|
(function (AcceptedOffer) {
|
|
30
30
|
let repo;
|
|
@@ -1001,6 +1001,20 @@ var Transaction;
|
|
|
1001
1001
|
}
|
|
1002
1002
|
Transaction.createInstance = createInstance;
|
|
1003
1003
|
})(Transaction || (exports.Transaction = Transaction = {}));
|
|
1004
|
+
var transaction;
|
|
1005
|
+
(function (transaction) {
|
|
1006
|
+
let PlaceOrder;
|
|
1007
|
+
(function (PlaceOrder) {
|
|
1008
|
+
let repo;
|
|
1009
|
+
async function createInstance(...params) {
|
|
1010
|
+
if (repo === undefined) {
|
|
1011
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/transaction/placeOrder')))).PlaceOrderRepo;
|
|
1012
|
+
}
|
|
1013
|
+
return new repo(...params);
|
|
1014
|
+
}
|
|
1015
|
+
PlaceOrder.createInstance = createInstance;
|
|
1016
|
+
})(PlaceOrder = transaction.PlaceOrder || (transaction.PlaceOrder = {}));
|
|
1017
|
+
})(transaction || (exports.transaction = transaction = {}));
|
|
1004
1018
|
var TransactionNumber;
|
|
1005
1019
|
(function (TransactionNumber) {
|
|
1006
1020
|
let repo;
|
|
@@ -27,6 +27,7 @@ import type { StockHolderRepo } from '../../../repo/stockHolder';
|
|
|
27
27
|
import type { TaskRepo } from '../../../repo/task';
|
|
28
28
|
import type { TicketRepo } from '../../../repo/ticket';
|
|
29
29
|
import type { TransactionRepo } from '../../../repo/transaction';
|
|
30
|
+
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
30
31
|
import type { TransactionNumberRepo } from '../../../repo/transactionNumber';
|
|
31
32
|
interface IAuthorizeRepos {
|
|
32
33
|
action: ActionRepo;
|
|
@@ -55,6 +56,7 @@ interface IAuthorizeRepos {
|
|
|
55
56
|
setting: SettingRepo;
|
|
56
57
|
task: TaskRepo;
|
|
57
58
|
ticket: TicketRepo;
|
|
59
|
+
placeOrder: PlaceOrderRepo;
|
|
58
60
|
transaction: TransactionRepo;
|
|
59
61
|
transactionNumber: TransactionNumberRepo;
|
|
60
62
|
}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.authorize = authorize;
|
|
27
27
|
const factory = __importStar(require("../../../factory"));
|
|
28
|
-
const
|
|
28
|
+
const issueOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/issueOrderNumberIfNotExist");
|
|
29
29
|
const any_1 = require("../any");
|
|
30
30
|
const defaultOffer_1 = require("./authorize/defaultOffer");
|
|
31
31
|
const factory_1 = require("./authorize/factory");
|
|
@@ -52,7 +52,7 @@ function authorize(params, options) {
|
|
|
52
52
|
})(repos);
|
|
53
53
|
let acceptedOffers4result;
|
|
54
54
|
const now = new Date();
|
|
55
|
-
const orderNumber = await (0,
|
|
55
|
+
const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
|
|
56
56
|
project: { id: params.project.id },
|
|
57
57
|
id: transaction.id,
|
|
58
58
|
object: { orderDate: now }
|
|
@@ -10,6 +10,7 @@ import type { SettingRepo } from '../../../repo/setting';
|
|
|
10
10
|
import type { StockHolderRepo } from '../../../repo/stockHolder';
|
|
11
11
|
import type { TaskRepo } from '../../../repo/task';
|
|
12
12
|
import type { TransactionRepo } from '../../../repo/transaction';
|
|
13
|
+
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
13
14
|
interface IVoidTransactionRepos {
|
|
14
15
|
action: ActionRepo;
|
|
15
16
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -19,6 +20,7 @@ interface IVoidTransactionRepos {
|
|
|
19
20
|
reservation: ReservationRepo;
|
|
20
21
|
setting: SettingRepo;
|
|
21
22
|
task: TaskRepo;
|
|
23
|
+
placeOrder: PlaceOrderRepo;
|
|
22
24
|
transaction: TransactionRepo;
|
|
23
25
|
/**
|
|
24
26
|
* COAオファー承認取消の場合必須
|
|
@@ -10,6 +10,7 @@ import type { SettingRepo } from '../../../repo/setting';
|
|
|
10
10
|
import type { StockHolderRepo } from '../../../repo/stockHolder';
|
|
11
11
|
import type { TaskRepo } from '../../../repo/task';
|
|
12
12
|
import type { TransactionRepo } from '../../../repo/transaction';
|
|
13
|
+
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
13
14
|
interface IVoidTransactionByActionIdRepos {
|
|
14
15
|
action: ActionRepo;
|
|
15
16
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -19,6 +20,7 @@ interface IVoidTransactionByActionIdRepos {
|
|
|
19
20
|
reservation: ReservationRepo;
|
|
20
21
|
setting: SettingRepo;
|
|
21
22
|
task: TaskRepo;
|
|
23
|
+
placeOrder: PlaceOrderRepo;
|
|
22
24
|
transaction: TransactionRepo;
|
|
23
25
|
/**
|
|
24
26
|
* COAオファー承認取消の場合必須
|
|
@@ -49,7 +49,7 @@ function voidTransactionByActionId(params) {
|
|
|
49
49
|
// if (transaction.agent.id !== params.agent.id) {
|
|
50
50
|
// throw new factory.errors.Forbidden('Transaction not yours');
|
|
51
51
|
// }
|
|
52
|
-
const orderNumber = await repos.
|
|
52
|
+
const orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.purpose.id });
|
|
53
53
|
const action = await repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
54
54
|
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
55
55
|
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
@@ -4,12 +4,14 @@ import type { EventRepo } from '../../../repo/event';
|
|
|
4
4
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
5
5
|
import type { ProjectRepo } from '../../../repo/project';
|
|
6
6
|
import type { TransactionRepo } from '../../../repo/transaction';
|
|
7
|
+
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
7
8
|
import * as factory from '../../../factory';
|
|
8
9
|
interface IAcceptRepos {
|
|
9
10
|
action: ActionRepo;
|
|
10
11
|
event: EventRepo;
|
|
11
12
|
orderNumber: OrderNumberRepo;
|
|
12
13
|
project: ProjectRepo;
|
|
14
|
+
placeOrder: PlaceOrderRepo;
|
|
13
15
|
transaction: TransactionRepo;
|
|
14
16
|
reserveService: COA.service.Reserve;
|
|
15
17
|
masterService: COA.service.Master;
|
|
@@ -27,7 +27,7 @@ exports.acceptOffer = acceptOffer;
|
|
|
27
27
|
exports.reAcceptOffer = reAcceptOffer;
|
|
28
28
|
const errorHandler_1 = require("../../../errorHandler");
|
|
29
29
|
const factory = __importStar(require("../../../factory"));
|
|
30
|
-
const
|
|
30
|
+
const issueOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/issueOrderNumberIfNotExist");
|
|
31
31
|
const authorize_1 = require("./acceptOffer/authorize");
|
|
32
32
|
const factory_1 = require("./acceptOffer/factory");
|
|
33
33
|
function findCOAInfo(params) {
|
|
@@ -62,8 +62,8 @@ function acceptOffer(params) {
|
|
|
62
62
|
typeOf: factory.transactionType.PlaceOrder,
|
|
63
63
|
id: params.purpose.id
|
|
64
64
|
}, ['project', 'agent', 'typeOf']);
|
|
65
|
-
//
|
|
66
|
-
await (0,
|
|
65
|
+
// issueOrderNumber(2025-03-11~)
|
|
66
|
+
await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
|
|
67
67
|
project: { id: transaction.project.id },
|
|
68
68
|
id: transaction.id,
|
|
69
69
|
object: { orderDate: new Date() }
|
|
@@ -148,7 +148,7 @@ function reAcceptOffer(params) {
|
|
|
148
148
|
typeOf: factory.transactionType.PlaceOrder,
|
|
149
149
|
id: params.purpose.id
|
|
150
150
|
}, ['project', 'agent', 'typeOf']);
|
|
151
|
-
const orderNumber = await repos.
|
|
151
|
+
const orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: transaction.id });
|
|
152
152
|
if (typeof orderNumber !== 'string') {
|
|
153
153
|
// 事前に発行されているはず
|
|
154
154
|
throw new factory.errors.NotFound('transaction.object.orderNumber');
|