@chevre/domain 21.18.0-alpha.12 → 21.18.0-alpha.14
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/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
- package/example/src/chevre/searchOrders.ts +11 -0
- package/example/src/chevre/searchTransactions.ts +41 -0
- package/lib/chevre/repo/acceptedOffer.d.ts +7 -0
- package/lib/chevre/repo/acceptedOffer.js +28 -0
- package/lib/chevre/repo/order.d.ts +2 -1
- package/lib/chevre/repo/order.js +10 -5
- package/lib/chevre/repo/place.js +14 -10
- package/lib/chevre/repo/transaction.d.ts +5 -4
- package/lib/chevre/repository.d.ts +0 -7
- package/lib/chevre/repository.js +1 -18
- package/lib/chevre/service/offer/product.d.ts +0 -14
- package/lib/chevre/service/offer/product.js +59 -42
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +2 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +15 -32
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder.js +59 -11
- package/lib/chevre/service/order/returnOrder.js +28 -10
- package/lib/chevre/service/order/sendOrder.d.ts +0 -2
- package/lib/chevre/service/order/sendOrder.js +9 -2
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/task/sendOrder.js +3 -7
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
- package/package.json +2 -2
- package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
- package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const ownershipInfos = await acceptedOfferRepo.aggreateOwnershipInfosByOrder(
|
|
14
|
+
{
|
|
15
|
+
orderNumber: { $eq: 'CIN4-3943271-4221863' }
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
// tslint:disable-next-line:no-null-keyword
|
|
19
|
+
console.dir(ownershipInfos, { depth: 1 });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then()
|
|
24
|
+
.catch(console.error);
|
|
@@ -10,6 +10,17 @@ async function main() {
|
|
|
10
10
|
|
|
11
11
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
|
+
const order = await orderRepo.findByOrderNumber({
|
|
14
|
+
orderNumber: 'CIN4-3943271-4221863',
|
|
15
|
+
project: { id: project.id },
|
|
16
|
+
inclusion: [
|
|
17
|
+
'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
|
|
18
|
+
'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
|
|
19
|
+
],
|
|
20
|
+
exclusion: []
|
|
21
|
+
});
|
|
22
|
+
console.log(order);
|
|
23
|
+
|
|
13
24
|
const orders = await orderRepo.search(
|
|
14
25
|
{
|
|
15
26
|
limit: 10,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const transactions = await transactionRepo.search<chevre.factory.transactionType.PlaceOrder>({
|
|
14
|
+
limit: 1,
|
|
15
|
+
page: 1,
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
18
|
+
statuses: [chevre.factory.transactionStatusType.Confirmed],
|
|
19
|
+
result: {
|
|
20
|
+
order: {
|
|
21
|
+
confirmationNumber: { $eq: '14438' },
|
|
22
|
+
orderNumbers: ['CIN3-0760465-8981560']
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
inclusion: ['id'],
|
|
26
|
+
exclusion: []
|
|
27
|
+
});
|
|
28
|
+
console.log('transactions found', transactions);
|
|
29
|
+
console.log(transactions.length, 'transactions found');
|
|
30
|
+
|
|
31
|
+
const transaction = await transactionRepo.findById({
|
|
32
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
33
|
+
id: '6570f9d7834f9638ceec86ad',
|
|
34
|
+
inclusion: ['_id', 'typeOf', 'status']
|
|
35
|
+
});
|
|
36
|
+
console.log('transaction found', transaction);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main()
|
|
40
|
+
.then()
|
|
41
|
+
.catch(console.error);
|
|
@@ -16,6 +16,13 @@ export declare class MongoRepository {
|
|
|
16
16
|
* オファー展開の注文検索
|
|
17
17
|
*/
|
|
18
18
|
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
|
|
19
|
+
aggreateOwnershipInfosByOrder(filter: {
|
|
20
|
+
orderNumber: {
|
|
21
|
+
$eq: string;
|
|
22
|
+
};
|
|
23
|
+
}): Promise<{
|
|
24
|
+
identifier: string;
|
|
25
|
+
}[]>;
|
|
19
26
|
/**
|
|
20
27
|
* 注文オファーを展開して検索する
|
|
21
28
|
*/
|
|
@@ -51,6 +51,34 @@ class MongoRepository {
|
|
|
51
51
|
.exec();
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
aggreateOwnershipInfosByOrder(filter) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const aggregate = this.orderModel.aggregate([
|
|
57
|
+
{
|
|
58
|
+
$unwind: {
|
|
59
|
+
path: '$acceptedOffers',
|
|
60
|
+
includeArrayIndex: 'acceptedOfferIndex'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{ $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
|
|
64
|
+
{
|
|
65
|
+
$project: {
|
|
66
|
+
_id: 0,
|
|
67
|
+
// acceptedOfferIndex: '$acceptedOfferIndex',
|
|
68
|
+
// itemOfferedTypeOf: '$acceptedOffers.itemOffered.typeOf',
|
|
69
|
+
// customerId: '$customer.id',
|
|
70
|
+
// orderNumber: '$orderNumber',
|
|
71
|
+
identifier: {
|
|
72
|
+
$concat: ['$customer.id', '-', '$acceptedOffers.itemOffered.typeOf', '-', '$orderNumber', '-', { $toString: '$acceptedOfferIndex' }]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
return aggregate
|
|
78
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
79
|
+
.exec();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
54
82
|
/**
|
|
55
83
|
* 注文オファーを展開して検索する
|
|
56
84
|
*/
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
type IKeyOfProjection = keyof Omit<factory.order.IOrder, 'acceptedOffers'> | '_id';
|
|
28
|
+
export type IReturnedOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'>;
|
|
28
29
|
/**
|
|
29
30
|
* 注文リポジトリ
|
|
30
31
|
*/
|
|
@@ -57,7 +58,7 @@ export declare class MongoRepository {
|
|
|
57
58
|
orderNumber: string;
|
|
58
59
|
dateReturned: Date;
|
|
59
60
|
returner: factory.order.IReturner;
|
|
60
|
-
}): Promise<
|
|
61
|
+
}): Promise<IReturnedOrder>;
|
|
61
62
|
/**
|
|
62
63
|
* 変更可能な属性を更新する
|
|
63
64
|
*/
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -741,9 +741,11 @@ class MongoRepository {
|
|
|
741
741
|
}, {
|
|
742
742
|
new: true,
|
|
743
743
|
projection: {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
744
|
+
_id: 1, project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
|
|
745
|
+
customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
|
|
746
|
+
// __v: 0,
|
|
747
|
+
// createdAt: 0,
|
|
748
|
+
// updatedAt: 0
|
|
747
749
|
}
|
|
748
750
|
})
|
|
749
751
|
.exec();
|
|
@@ -752,8 +754,11 @@ class MongoRepository {
|
|
|
752
754
|
const order = yield this.findByOrderNumber({
|
|
753
755
|
orderNumber: params.orderNumber,
|
|
754
756
|
project: { id: params.project.id },
|
|
755
|
-
inclusion: [
|
|
756
|
-
|
|
757
|
+
inclusion: [
|
|
758
|
+
'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
|
|
759
|
+
'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
|
|
760
|
+
],
|
|
761
|
+
exclusion: [] // 除外(2023-12-07~)
|
|
757
762
|
});
|
|
758
763
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
759
764
|
/* istanbul ignore next */
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -625,7 +625,7 @@ class MongoRepository {
|
|
|
625
625
|
}
|
|
626
626
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
627
627
|
searchScreeningRoomSections(searchConditions) {
|
|
628
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
628
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
629
629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
630
630
|
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
631
631
|
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -722,17 +722,21 @@ class MongoRepository {
|
|
|
722
722
|
{ $unwind: '$containsPlace' },
|
|
723
723
|
...matchStages,
|
|
724
724
|
{
|
|
725
|
-
$project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name',
|
|
726
|
-
|
|
727
|
-
branchCode: '$branchCode',
|
|
728
|
-
name: '$name',
|
|
725
|
+
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
|
|
726
|
+
? {
|
|
729
727
|
containedInPlace: {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
728
|
+
typeOf: '$typeOf',
|
|
729
|
+
branchCode: '$branchCode',
|
|
730
|
+
name: '$name',
|
|
731
|
+
containedInPlace: {
|
|
732
|
+
id: '$containedInPlace.id',
|
|
733
|
+
typeOf: '$containedInPlace.typeOf',
|
|
734
|
+
branchCode: '$containedInPlace.branchCode',
|
|
735
|
+
name: '$containedInPlace.name'
|
|
736
|
+
}
|
|
734
737
|
}
|
|
735
|
-
}
|
|
738
|
+
}
|
|
739
|
+
: undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
|
|
736
740
|
? {
|
|
737
741
|
seatCount: {
|
|
738
742
|
$cond: {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
+
type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
|
|
27
28
|
interface IAggregationByStatus {
|
|
28
29
|
transactionCount: number;
|
|
29
30
|
avgDuration: number;
|
|
@@ -64,8 +65,8 @@ export declare class MongoRepository {
|
|
|
64
65
|
findById<T extends factory.transactionType>(params: {
|
|
65
66
|
typeOf: T;
|
|
66
67
|
id: string;
|
|
67
|
-
inclusion?:
|
|
68
|
-
exclusion?:
|
|
68
|
+
inclusion?: IKeyOfProjection<T>[];
|
|
69
|
+
exclusion?: IKeyOfProjection<T>[];
|
|
69
70
|
}): Promise<factory.transaction.ITransaction<T>>;
|
|
70
71
|
/**
|
|
71
72
|
* 進行中の取引を取得する
|
|
@@ -187,8 +188,8 @@ export declare class MongoRepository {
|
|
|
187
188
|
* 取引を検索する
|
|
188
189
|
*/
|
|
189
190
|
search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T> & {
|
|
190
|
-
inclusion:
|
|
191
|
-
exclusion:
|
|
191
|
+
inclusion: IKeyOfProjection<T>[];
|
|
192
|
+
exclusion: IKeyOfProjection<T>[];
|
|
192
193
|
}): Promise<factory.transaction.ITransaction<T>[]>;
|
|
193
194
|
/**
|
|
194
195
|
* 特定の取引を更新する(汎用)
|
|
@@ -47,7 +47,6 @@ import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
|
|
|
47
47
|
import type { MongoRepository as TransactionRepo } from './repo/transaction';
|
|
48
48
|
import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
|
|
49
49
|
import type { MongoRepository as TripRepo } from './repo/trip';
|
|
50
|
-
import type { RedisRepository as RegisterServiceActionInProgress } from './repo/action/registerServiceInProgress';
|
|
51
50
|
import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
|
|
52
51
|
import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
|
|
53
52
|
import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
|
|
@@ -88,12 +87,6 @@ export type Aggregation = AggregationRepo;
|
|
|
88
87
|
export declare namespace Aggregation {
|
|
89
88
|
function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
|
|
90
89
|
}
|
|
91
|
-
export declare namespace action {
|
|
92
|
-
type RegisterServiceInProgress = RegisterServiceActionInProgress;
|
|
93
|
-
namespace RegisterServiceInProgress {
|
|
94
|
-
function createInstance(...params: ConstructorParameters<typeof RegisterServiceActionInProgress>): Promise<RegisterServiceActionInProgress>;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
90
|
export type AssetTransaction = AssetTransactionRepo;
|
|
98
91
|
export declare namespace AssetTransaction {
|
|
99
92
|
function createInstance(...params: ConstructorParameters<typeof AssetTransactionRepo>): Promise<AssetTransactionRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.
|
|
13
|
-
exports.rateLimit = void 0;
|
|
12
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
14
13
|
var AcceptedOffer;
|
|
15
14
|
(function (AcceptedOffer) {
|
|
16
15
|
let repo;
|
|
@@ -128,22 +127,6 @@ var Aggregation;
|
|
|
128
127
|
}
|
|
129
128
|
Aggregation.createInstance = createInstance;
|
|
130
129
|
})(Aggregation = exports.Aggregation || (exports.Aggregation = {}));
|
|
131
|
-
var action;
|
|
132
|
-
(function (action) {
|
|
133
|
-
let RegisterServiceInProgress;
|
|
134
|
-
(function (RegisterServiceInProgress) {
|
|
135
|
-
let repo;
|
|
136
|
-
function createInstance(...params) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
if (repo === undefined) {
|
|
139
|
-
repo = (yield Promise.resolve().then(() => require('./repo/action/registerServiceInProgress'))).RedisRepository;
|
|
140
|
-
}
|
|
141
|
-
return new repo(...params);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
RegisterServiceInProgress.createInstance = createInstance;
|
|
145
|
-
})(RegisterServiceInProgress = action.RegisterServiceInProgress || (action.RegisterServiceInProgress = {}));
|
|
146
|
-
})(action = exports.action || (exports.action = {}));
|
|
147
130
|
var AssetTransaction;
|
|
148
131
|
(function (AssetTransaction) {
|
|
149
132
|
let repo;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import type { MongoRepository as AccountRepo } from '../../repo/account';
|
|
3
3
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
|
-
import type { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
5
4
|
import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
6
5
|
import type { MongoRepository as OfferRepo } from '../../repo/offer';
|
|
7
6
|
import type { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
|
|
@@ -23,7 +22,6 @@ export interface IAuthorizeOperationRepos {
|
|
|
23
22
|
ownershipInfo: OwnershipInfoRepo;
|
|
24
23
|
product: ProductRepo;
|
|
25
24
|
project: ProjectRepo;
|
|
26
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
27
25
|
serviceOutput: ServiceOutputRepo;
|
|
28
26
|
serviceOutputIdentifier: ServiceOutputIdentifierRepo;
|
|
29
27
|
transaction: TransactionRepo;
|
|
@@ -94,17 +92,5 @@ export declare function authorize(params: {
|
|
|
94
92
|
export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): (repos: {
|
|
95
93
|
action: ActionRepo;
|
|
96
94
|
assetTransaction: AssetTransactionRepo;
|
|
97
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
98
95
|
transaction: TransactionRepo;
|
|
99
96
|
}) => Promise<void>;
|
|
100
|
-
export declare function processUnlockRegisterMembershipService(params: {
|
|
101
|
-
agent: {
|
|
102
|
-
id: string;
|
|
103
|
-
};
|
|
104
|
-
product: {
|
|
105
|
-
id: string;
|
|
106
|
-
};
|
|
107
|
-
purpose: factory.action.authorize.offer.product.IPurpose;
|
|
108
|
-
}): (repos: {
|
|
109
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
110
|
-
}) => Promise<void>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.voidTransaction = exports.authorize = exports.search = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
15
|
const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
|
|
@@ -129,11 +129,12 @@ function authorize(params) {
|
|
|
129
129
|
try {
|
|
130
130
|
// 会員の場合のみ排他ロック
|
|
131
131
|
if (params.agent.typeOf === factory.personType.Person) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
132
|
+
// 廃止(2023-12-07~)
|
|
133
|
+
// await processLockRegisterMembershipService({
|
|
134
|
+
// agent: params.agent,
|
|
135
|
+
// product: product,
|
|
136
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
137
|
+
// })(repos);
|
|
137
138
|
}
|
|
138
139
|
// サービス登録開始
|
|
139
140
|
const startParams = (0, factory_1.createRegisterServiceStartParams)({
|
|
@@ -155,11 +156,12 @@ function authorize(params) {
|
|
|
155
156
|
// no op
|
|
156
157
|
}
|
|
157
158
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
159
|
+
// 廃止(2023-12-07~)
|
|
160
|
+
// await processUnlockRegisterMembershipService({
|
|
161
|
+
// agent: params.agent,
|
|
162
|
+
// product: { id: String(product.id) },
|
|
163
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
164
|
+
// })(repos);
|
|
163
165
|
}
|
|
164
166
|
catch (error) {
|
|
165
167
|
// 失敗したら仕方ない
|
|
@@ -233,11 +235,12 @@ function voidTransaction(params) {
|
|
|
233
235
|
var _b, _c;
|
|
234
236
|
const productId = (_c = (_b = action.object[0]) === null || _b === void 0 ? void 0 : _b.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
|
|
235
237
|
if (typeof productId === 'string') {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
// 廃止(2023-12-07~)
|
|
239
|
+
// await processUnlockRegisterMembershipService({
|
|
240
|
+
// agent: { id: transaction.agent.id },
|
|
241
|
+
// product: { id: productId },
|
|
242
|
+
// purpose: params.purpose
|
|
243
|
+
// })(repos);
|
|
241
244
|
}
|
|
242
245
|
yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
|
|
243
246
|
yield processVoidRegisterServiceTransaction({
|
|
@@ -382,29 +385,43 @@ function createServiceOutputIdentifier(params) {
|
|
|
382
385
|
})));
|
|
383
386
|
});
|
|
384
387
|
}
|
|
385
|
-
function processLockRegisterMembershipService(params
|
|
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
|
-
|
|
388
|
+
// function processLockRegisterMembershipService(params: {
|
|
389
|
+
// agent: { id: string };
|
|
390
|
+
// product: factory.product.IProduct;
|
|
391
|
+
// purpose: factory.action.authorize.offer.product.IPurpose;
|
|
392
|
+
// }) {
|
|
393
|
+
// return async (repos: {
|
|
394
|
+
// registerActionInProgress: RegisterServiceInProgressRepo;
|
|
395
|
+
// }) => {
|
|
396
|
+
// if (params.product.typeOf === factory.product.ProductType.MembershipService) {
|
|
397
|
+
// await repos.registerActionInProgress.lock(
|
|
398
|
+
// {
|
|
399
|
+
// agent: { id: params.agent.id },
|
|
400
|
+
// product: { id: String(params.product.id) }
|
|
401
|
+
// },
|
|
402
|
+
// params.purpose.id
|
|
403
|
+
// );
|
|
404
|
+
// }
|
|
405
|
+
// };
|
|
406
|
+
// }
|
|
407
|
+
// export function processUnlockRegisterMembershipService(params: {
|
|
408
|
+
// agent: { id: string };
|
|
409
|
+
// product: { id: string };
|
|
410
|
+
// purpose: factory.action.authorize.offer.product.IPurpose;
|
|
411
|
+
// }) {
|
|
412
|
+
// return async (repos: {
|
|
413
|
+
// registerActionInProgress: RegisterServiceInProgressRepo;
|
|
414
|
+
// }) => {
|
|
415
|
+
// // 登録ロックIDが取引IDであればロック解除
|
|
416
|
+
// const holder = await repos.registerActionInProgress.getHolder({
|
|
417
|
+
// agent: { id: params.agent.id },
|
|
418
|
+
// product: { id: params.product.id }
|
|
419
|
+
// });
|
|
420
|
+
// if (holder === params.purpose.id) {
|
|
421
|
+
// await repos.registerActionInProgress.unlock({
|
|
422
|
+
// agent: { id: params.agent.id },
|
|
423
|
+
// product: { id: params.product.id }
|
|
424
|
+
// });
|
|
425
|
+
// }
|
|
426
|
+
// };
|
|
427
|
+
// }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
|
+
type ITransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'potentialActions' | 'project' | 'typeOf'>;
|
|
3
4
|
export declare function findPlaceOrderTransaction(params: {
|
|
4
5
|
project: {
|
|
5
6
|
id: string;
|
|
@@ -8,4 +9,5 @@ export declare function findPlaceOrderTransaction(params: {
|
|
|
8
9
|
orderNumber: string;
|
|
9
10
|
}): (repos: {
|
|
10
11
|
transaction: TransactionRepo;
|
|
11
|
-
}) => Promise<
|
|
12
|
+
}) => Promise<ITransaction>;
|
|
13
|
+
export {};
|
|
@@ -13,7 +13,6 @@ exports.findPlaceOrderTransaction = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
function findPlaceOrderTransaction(params) {
|
|
15
15
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
// 注文取引検索
|
|
17
16
|
const placeOrderTransactions = yield repos.transaction.search({
|
|
18
17
|
limit: 1,
|
|
19
18
|
page: 1,
|
|
@@ -26,7 +25,7 @@ function findPlaceOrderTransaction(params) {
|
|
|
26
25
|
orderNumbers: [params.orderNumber]
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
|
-
inclusion: [],
|
|
28
|
+
inclusion: ['id', 'potentialActions', 'project', 'typeOf'],
|
|
30
29
|
exclusion: []
|
|
31
30
|
});
|
|
32
31
|
const placeOrderTransaction = placeOrderTransactions.shift();
|
|
@@ -212,8 +212,11 @@ function cancelOrderIfExist(params) {
|
|
|
212
212
|
}
|
|
213
213
|
if (params.useOnOrderStatusChanged) {
|
|
214
214
|
yield (0, onOrderStatusChanged_1.onOrderCancelled)({
|
|
215
|
-
order:
|
|
216
|
-
|
|
215
|
+
order: {
|
|
216
|
+
orderDate: order.orderDate,
|
|
217
|
+
orderNumber: order.orderNumber,
|
|
218
|
+
orderStatus: factory.orderStatus.OrderCancelled // 強制的にOrderCancelledとして処理する
|
|
219
|
+
},
|
|
217
220
|
placeOrderTransaction
|
|
218
221
|
})({
|
|
219
222
|
task: repos.task
|
|
@@ -6,6 +6,6 @@ import * as factory from '../../../../factory';
|
|
|
6
6
|
* 注文中止時のアクション
|
|
7
7
|
*/
|
|
8
8
|
declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
9
|
-
transaction?: factory.transaction.placeOrder.ITransaction
|
|
9
|
+
transaction?: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
10
10
|
}): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
|
|
11
11
|
export { createOnOrderCancelledTasksByTransaction };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type IPlaceOrderTransaction = factory.transaction.ITransaction
|
|
3
|
+
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
4
4
|
declare function onOrderCancelled(params: {
|
|
5
|
-
order: factory.order.IOrder
|
|
5
|
+
order: Pick<factory.order.IOrder, 'orderNumber' | 'orderDate' | 'orderStatus'>;
|
|
6
6
|
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
7
7
|
}): (repos: {
|
|
8
8
|
task: TaskRepo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
|
-
type IDeliveredOrder = factory.order.IOrder & {
|
|
2
|
+
type IDeliveredOrder = Pick<factory.order.IOrder, 'id' | 'customer' | 'orderNumber' | 'project' | 'typeOf'> & {
|
|
3
3
|
orderStatus: factory.orderStatus.OrderDelivered;
|
|
4
4
|
};
|
|
5
5
|
declare function createInformTasks(order: IDeliveredOrder): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { RedisRepository as RegisterServiceInProgressRepo } from '../../../repo/action/registerServiceInProgress';
|
|
2
1
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
3
2
|
import * as factory from '../../../factory';
|
|
4
|
-
type IPlaceOrderTransaction = factory.transaction.ITransaction
|
|
3
|
+
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'potentialActions'>;
|
|
5
4
|
declare function onOrderDelivered(params: {
|
|
6
|
-
order:
|
|
5
|
+
order: Pick<factory.order.IOrder, 'id' | 'customer' | 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> & {
|
|
7
6
|
orderStatus: factory.orderStatus.OrderDelivered;
|
|
8
7
|
};
|
|
9
8
|
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
10
9
|
}): (repos: {
|
|
11
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
12
10
|
task: TaskRepo;
|
|
13
11
|
}) => Promise<void>;
|
|
14
12
|
export { onOrderDelivered };
|
|
@@ -15,7 +15,6 @@ exports.onOrderDelivered = void 0;
|
|
|
15
15
|
*/
|
|
16
16
|
const createDebug = require("debug");
|
|
17
17
|
const factory = require("../../../factory");
|
|
18
|
-
const product_1 = require("../../offer/product");
|
|
19
18
|
const factory_1 = require("./onOrderDelivered/factory");
|
|
20
19
|
const debug = createDebug('chevre-domain:service:order');
|
|
21
20
|
function onOrderDelivered(params) {
|
|
@@ -23,20 +22,6 @@ function onOrderDelivered(params) {
|
|
|
23
22
|
var _a, _b, _c, _d, _e;
|
|
24
23
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
25
24
|
let tasks = [];
|
|
26
|
-
// const maskedCustomer = createMaskedCustomer(params.order, { noProfile: true });
|
|
27
|
-
// const simpleOrder: factory.order.ISimpleOrder = {
|
|
28
|
-
// typeOf: params.order.typeOf,
|
|
29
|
-
// seller: {
|
|
30
|
-
// id: params.order.seller.id,
|
|
31
|
-
// typeOf: params.order.seller.typeOf,
|
|
32
|
-
// name: params.order.seller.name
|
|
33
|
-
// },
|
|
34
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
35
|
-
// orderNumber: params.order.orderNumber,
|
|
36
|
-
// price: params.order.price,
|
|
37
|
-
// priceCurrency: params.order.priceCurrency,
|
|
38
|
-
// orderDate: params.order.orderDate
|
|
39
|
-
// };
|
|
40
25
|
switch (params.order.orderStatus) {
|
|
41
26
|
case factory.orderStatus.OrderDelivered:
|
|
42
27
|
tasks = [
|
|
@@ -50,24 +35,22 @@ function onOrderDelivered(params) {
|
|
|
50
35
|
try {
|
|
51
36
|
const placeOrderTransaction = params.placeOrderTransaction;
|
|
52
37
|
if (typeof (placeOrderTransaction === null || placeOrderTransaction === void 0 ? void 0 : placeOrderTransaction.id) === 'string') {
|
|
38
|
+
// 廃止(2023-12-07~)
|
|
53
39
|
// プロダクト登録プロセスロック解除(orderからproductIdを抽出する)
|
|
54
|
-
if (Array.isArray(params.order.acceptedOffers)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})(repos);
|
|
69
|
-
})));
|
|
70
|
-
}
|
|
40
|
+
// if (Array.isArray(params.order.acceptedOffers)) {
|
|
41
|
+
// const productIds4unlock = params.order.acceptedOffers
|
|
42
|
+
// .filter((o) => o.itemOffered.typeOf === factory.permit.PermitType.Permit
|
|
43
|
+
// && typeof o.itemOffered.issuedThrough?.id === 'string'
|
|
44
|
+
// && o.itemOffered.issuedThrough.id.length > 0)
|
|
45
|
+
// .map((o) => String((<factory.order.IPermit>o.itemOffered).issuedThrough?.id));
|
|
46
|
+
// await Promise.all(productIds4unlock.map(async (productId) => {
|
|
47
|
+
// await processUnlockRegisterMembershipService({
|
|
48
|
+
// agent: { id: String(params.order.customer.id) },
|
|
49
|
+
// product: { id: productId },
|
|
50
|
+
// purpose: { typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id }
|
|
51
|
+
// })(repos);
|
|
52
|
+
// }));
|
|
53
|
+
// }
|
|
71
54
|
}
|
|
72
55
|
}
|
|
73
56
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
3
|
declare function onOrderPaymentDue(params: {
|
|
4
|
-
order:
|
|
4
|
+
order: Pick<factory.order.IOrder, 'paymentMethods' | 'project' | 'orderNumber' | 'confirmationNumber' | 'customer' | 'orderDate' | 'seller' | 'typeOf' | 'price' | 'priceCurrency'> & {
|
|
5
5
|
orderStatus: factory.orderStatus.OrderPaymentDue;
|
|
6
6
|
};
|
|
7
7
|
}): (repos: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
3
|
import { IExternalOrder } from './onOrderProcessing/factory';
|
|
4
|
-
type IPlaceOrderTransaction = factory.transaction.ITransaction
|
|
4
|
+
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
5
5
|
declare function onOrderProcessing(params: {
|
|
6
6
|
order: Omit<factory.order.IOrder, 'orderStatus'> & {
|
|
7
7
|
orderStatus: factory.orderStatus.OrderProcessing;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MongoRepository as AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
2
2
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
3
3
|
import * as factory from '../../../factory';
|
|
4
|
-
type IReturnOrderTransaction = factory.transaction.ITransaction
|
|
4
|
+
type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
5
5
|
declare function onOrderReturned(params: {
|
|
6
|
-
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'
|
|
6
|
+
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
|
|
7
7
|
orderStatus: factory.orderStatus.OrderReturned;
|
|
8
8
|
};
|
|
9
9
|
returnOrderTransaction?: IReturnOrderTransaction;
|
|
@@ -8,12 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.placeOrderWithoutTransaction = exports.placeOrder = void 0;
|
|
13
24
|
const moment = require("moment");
|
|
14
25
|
const order_1 = require("../../factory/order");
|
|
15
26
|
const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
|
|
16
|
-
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
17
27
|
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
18
28
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
19
29
|
const factory = require("../../factory");
|
|
@@ -78,17 +88,31 @@ function createOrderFromBody(params) {
|
|
|
78
88
|
const confirmationNumber = String(params.confirmationNumber);
|
|
79
89
|
const orderNumber = params.orderNumber;
|
|
80
90
|
let order;
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
const placeOrderTransactions = yield repos.transaction.search({
|
|
92
|
+
limit: 1,
|
|
93
|
+
page: 1,
|
|
94
|
+
project: { id: { $eq: params.project.id } },
|
|
95
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
96
|
+
statuses: [factory.transactionStatusType.Confirmed],
|
|
97
|
+
result: {
|
|
98
|
+
order: {
|
|
99
|
+
confirmationNumber: { $eq: confirmationNumber },
|
|
100
|
+
orderNumbers: [orderNumber]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
inclusion: ['id', 'potentialActions', 'project', 'typeOf', 'result'],
|
|
104
|
+
exclusion: []
|
|
105
|
+
});
|
|
106
|
+
const placeOrderTransactionWithResult = placeOrderTransactions.shift();
|
|
107
|
+
if (placeOrderTransactionWithResult === undefined) {
|
|
108
|
+
throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
|
|
109
|
+
}
|
|
110
|
+
const orderByTransaction = (_a = placeOrderTransactionWithResult.result) === null || _a === void 0 ? void 0 : _a.order;
|
|
87
111
|
if (orderByTransaction === undefined) {
|
|
88
112
|
throw new factory.errors.NotFound('transaction.result.order');
|
|
89
113
|
}
|
|
90
|
-
order = orderByTransaction;
|
|
91
|
-
|
|
114
|
+
order = createOrder(orderByTransaction);
|
|
115
|
+
const { result } = placeOrderTransactionWithResult, placeOrderTransaction = __rest(placeOrderTransactionWithResult, ["result"]);
|
|
92
116
|
return { order, placeOrderTransaction };
|
|
93
117
|
});
|
|
94
118
|
}
|
|
@@ -223,7 +247,19 @@ function placeOrder(params) {
|
|
|
223
247
|
// PaymentDueであればonOrderStatusChangedを実行(2023-08-23~)
|
|
224
248
|
if (order.orderStatus === factory.orderStatus.OrderPaymentDue) {
|
|
225
249
|
yield (0, onOrderStatusChanged_1.onOrderPaymentDue)({
|
|
226
|
-
order:
|
|
250
|
+
order: {
|
|
251
|
+
paymentMethods: order.paymentMethods,
|
|
252
|
+
project: order.project,
|
|
253
|
+
orderNumber: order.orderNumber,
|
|
254
|
+
confirmationNumber: order.confirmationNumber,
|
|
255
|
+
customer: order.customer,
|
|
256
|
+
orderDate: order.orderDate,
|
|
257
|
+
seller: order.seller,
|
|
258
|
+
typeOf: order.typeOf,
|
|
259
|
+
price: order.price,
|
|
260
|
+
priceCurrency: order.priceCurrency,
|
|
261
|
+
orderStatus: order.orderStatus
|
|
262
|
+
}
|
|
227
263
|
})({
|
|
228
264
|
task: repos.task
|
|
229
265
|
});
|
|
@@ -232,7 +268,19 @@ function placeOrder(params) {
|
|
|
232
268
|
// OrderPaymentDueをスキップしてOrderProcessingから開始する場合(2023-08-23~)
|
|
233
269
|
// OrderPaymentDueに対する処理をまず強制的に実行する(2023-08-24~)
|
|
234
270
|
yield (0, onOrderStatusChanged_1.onOrderPaymentDue)({
|
|
235
|
-
order:
|
|
271
|
+
order: {
|
|
272
|
+
paymentMethods: order.paymentMethods,
|
|
273
|
+
project: order.project,
|
|
274
|
+
orderNumber: order.orderNumber,
|
|
275
|
+
confirmationNumber: order.confirmationNumber,
|
|
276
|
+
customer: order.customer,
|
|
277
|
+
orderDate: order.orderDate,
|
|
278
|
+
seller: order.seller,
|
|
279
|
+
typeOf: order.typeOf,
|
|
280
|
+
price: order.price,
|
|
281
|
+
priceCurrency: order.priceCurrency,
|
|
282
|
+
orderStatus: factory.orderStatus.OrderPaymentDue
|
|
283
|
+
}
|
|
236
284
|
})({
|
|
237
285
|
task: repos.task
|
|
238
286
|
});
|
|
@@ -10,10 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.returnOrder = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
13
14
|
const order_1 = require("../../factory/order");
|
|
14
|
-
const factory_1 = require("../delivery/factory");
|
|
15
15
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
16
16
|
const factory = require("../../factory");
|
|
17
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
17
18
|
function returnOrder(params) {
|
|
18
19
|
// tslint:disable-next-line:max-func-body-length
|
|
19
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -29,8 +30,8 @@ function returnOrder(params) {
|
|
|
29
30
|
orderNumber,
|
|
30
31
|
project: { id: params.project.id },
|
|
31
32
|
inclusion: [
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
|
|
34
|
+
'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
|
|
34
35
|
],
|
|
35
36
|
exclusion: []
|
|
36
37
|
});
|
|
@@ -42,7 +43,7 @@ function returnOrder(params) {
|
|
|
42
43
|
typeOf: factory.transactionType.ReturnOrder,
|
|
43
44
|
statuses: [factory.transactionStatusType.Confirmed],
|
|
44
45
|
object: { order: { orderNumbers: [orderNumber] } },
|
|
45
|
-
inclusion: [],
|
|
46
|
+
inclusion: ['id', 'typeOf', 'potentialActions'],
|
|
46
47
|
exclusion: []
|
|
47
48
|
});
|
|
48
49
|
const returnOrderTransaction = returnOrderTransactions.shift();
|
|
@@ -69,13 +70,15 @@ function returnOrder(params) {
|
|
|
69
70
|
project: order.project,
|
|
70
71
|
recipient: order.seller,
|
|
71
72
|
typeOf: factory.actionType.ReturnAction
|
|
72
|
-
// ...(params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined
|
|
73
73
|
};
|
|
74
74
|
let returnedOwnershipInfos = [];
|
|
75
75
|
// アクション開始
|
|
76
76
|
const action = yield repos.action.start(returnOrderActionAttributes);
|
|
77
77
|
try {
|
|
78
|
-
returnedOwnershipInfos = yield processReturnOrder(order, dateReturned)({
|
|
78
|
+
returnedOwnershipInfos = yield processReturnOrder(order, dateReturned)({
|
|
79
|
+
acceptedOffer: repos.acceptedOffer,
|
|
80
|
+
ownershipInfo: repos.ownershipInfo
|
|
81
|
+
});
|
|
79
82
|
// 注文ステータス変更
|
|
80
83
|
order = yield repos.order.returnOrder({
|
|
81
84
|
project: { id: order.project.id },
|
|
@@ -83,6 +86,7 @@ function returnOrder(params) {
|
|
|
83
86
|
dateReturned,
|
|
84
87
|
returner
|
|
85
88
|
});
|
|
89
|
+
debug('repos.order.returnOrder processed. returnedOrder:', order);
|
|
86
90
|
}
|
|
87
91
|
catch (error) {
|
|
88
92
|
// actionにエラー結果を追加
|
|
@@ -99,7 +103,20 @@ function returnOrder(params) {
|
|
|
99
103
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
100
104
|
if (params.useOnOrderStatusChanged) {
|
|
101
105
|
yield (0, onOrderStatusChanged_1.onOrderReturned)({
|
|
102
|
-
order:
|
|
106
|
+
order: {
|
|
107
|
+
project: order.project,
|
|
108
|
+
typeOf: order.typeOf,
|
|
109
|
+
orderNumber: order.orderNumber,
|
|
110
|
+
dateReturned: order.dateReturned,
|
|
111
|
+
id: order.id,
|
|
112
|
+
customer: order.customer,
|
|
113
|
+
returner: order.returner,
|
|
114
|
+
seller: order.seller,
|
|
115
|
+
price: order.price,
|
|
116
|
+
priceCurrency: order.priceCurrency,
|
|
117
|
+
orderDate: order.orderDate,
|
|
118
|
+
orderStatus: factory.orderStatus.OrderReturned
|
|
119
|
+
},
|
|
103
120
|
returnOrderTransaction
|
|
104
121
|
})({
|
|
105
122
|
acceptedOffer: repos.acceptedOffer,
|
|
@@ -112,10 +129,11 @@ exports.returnOrder = returnOrder;
|
|
|
112
129
|
function processReturnOrder(order, dateReturned) {
|
|
113
130
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
114
131
|
const returnedOwnershipInfos = [];
|
|
115
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
116
|
-
// TODO 注文配送によって発生した所有権の特定を他の方法で行えないか?
|
|
117
132
|
// 所有権の所有期間変更
|
|
118
|
-
|
|
133
|
+
// 注文オファーリポジトリから所有権識別子を検索する(2023-12-07~)
|
|
134
|
+
const ownershipInfos = yield repos.acceptedOffer.aggreateOwnershipInfosByOrder({ orderNumber: { $eq: order.orderNumber } });
|
|
135
|
+
// const ownershipInfos = createOwnershipInfosFromOrder({ order });
|
|
136
|
+
debug('processing findByIdentifierAndUpdateOwnedThrough...', ownershipInfos);
|
|
119
137
|
if (Array.isArray(ownershipInfos)) {
|
|
120
138
|
yield Promise.all(ownershipInfos.map((ownershipInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
121
139
|
const ownershipInfoReturned = yield repos.ownershipInfo.findByIdentifierAndUpdateOwnedThrough({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
|
-
import type { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
3
2
|
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
3
|
import type { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
5
4
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
@@ -9,7 +8,6 @@ type ISendOperation<T> = (repos: {
|
|
|
9
8
|
action: ActionRepo;
|
|
10
9
|
order: OrderRepo;
|
|
11
10
|
ownershipInfo: OwnershipInfoRepo;
|
|
12
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
13
11
|
task: TaskRepo;
|
|
14
12
|
transaction: TransactionRepo;
|
|
15
13
|
}) => Promise<T>;
|
|
@@ -101,10 +101,17 @@ function sendOrder(params) {
|
|
|
101
101
|
yield repos.action.complete({ typeOf: sendOrderActionAttributes.typeOf, id: action.id, result: result });
|
|
102
102
|
if (params.useOnOrderStatusChanged) {
|
|
103
103
|
yield (0, onOrderStatusChanged_1.onOrderDelivered)({
|
|
104
|
-
order:
|
|
104
|
+
order: {
|
|
105
|
+
id: order.id,
|
|
106
|
+
customer: order.customer,
|
|
107
|
+
orderDate: order.orderDate,
|
|
108
|
+
orderNumber: order.orderNumber,
|
|
109
|
+
project: order.project,
|
|
110
|
+
typeOf: order.typeOf,
|
|
111
|
+
orderStatus: factory.orderStatus.OrderDelivered
|
|
112
|
+
},
|
|
105
113
|
placeOrderTransaction
|
|
106
114
|
})({
|
|
107
|
-
registerActionInProgress: repos.registerActionInProgress,
|
|
108
115
|
task: repos.task
|
|
109
116
|
});
|
|
110
117
|
}
|
|
@@ -114,7 +114,7 @@ function processVoidPayTransaction(params) {
|
|
|
114
114
|
transaction = (yield repos.transaction.findById({
|
|
115
115
|
typeOf: params.purpose.typeOf,
|
|
116
116
|
id: params.purpose.id,
|
|
117
|
-
inclusion: ['_id', 'typeOf', 'status', 'result
|
|
117
|
+
inclusion: ['_id', 'typeOf', 'status', 'result']
|
|
118
118
|
}));
|
|
119
119
|
}
|
|
120
120
|
// 承認アクションを取得
|
|
@@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
-
const factory = require("../../factory");
|
|
14
13
|
const action_1 = require("../../repo/action");
|
|
15
|
-
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
16
14
|
const order_1 = require("../../repo/order");
|
|
17
15
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
18
16
|
const task_1 = require("../../repo/task");
|
|
@@ -23,20 +21,18 @@ const OrderService = require("../order");
|
|
|
23
21
|
*/
|
|
24
22
|
function call(data) {
|
|
25
23
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (settings.redisClient === undefined) {
|
|
27
|
-
|
|
28
|
-
}
|
|
24
|
+
// if (settings.redisClient === undefined) {
|
|
25
|
+
// throw new factory.errors.Argument('settings', 'redisClient required');
|
|
26
|
+
// }
|
|
29
27
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
30
28
|
const orderRepo = new order_1.MongoRepository(settings.connection);
|
|
31
29
|
const ownershipInfoRepo = new ownershipInfo_1.MongoRepository(settings.connection);
|
|
32
30
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
33
31
|
const transactionRepo = new transaction_1.MongoRepository(settings.connection);
|
|
34
|
-
const registerServiceInProgressRepo = new registerServiceInProgress_1.RedisRepository(settings.redisClient);
|
|
35
32
|
yield OrderService.sendOrder(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
|
|
36
33
|
action: actionRepo,
|
|
37
34
|
order: orderRepo,
|
|
38
35
|
ownershipInfo: ownershipInfoRepo,
|
|
39
|
-
registerActionInProgress: registerServiceInProgressRepo,
|
|
40
36
|
task: taskRepo,
|
|
41
37
|
transaction: transactionRepo
|
|
42
38
|
});
|
|
@@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
-
const factory = require("../../factory");
|
|
14
13
|
const action_1 = require("../../repo/action");
|
|
15
|
-
const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
|
|
16
14
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
15
|
const transaction_1 = require("../../repo/transaction");
|
|
18
16
|
const ProductOfferService = require("../offer/product");
|
|
@@ -21,17 +19,15 @@ const ProductOfferService = require("../offer/product");
|
|
|
21
19
|
*/
|
|
22
20
|
function call(data) {
|
|
23
21
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (settings.redisClient === undefined) {
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
// if (settings.redisClient === undefined) {
|
|
23
|
+
// throw new factory.errors.Argument('settings', 'redisClient required');
|
|
24
|
+
// }
|
|
27
25
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
28
|
-
const registerActionInProgressRepo = new registerServiceInProgress_1.RedisRepository(settings.redisClient);
|
|
29
26
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
30
27
|
const transactionRepo = new transaction_1.MongoRepository(settings.connection);
|
|
31
28
|
yield ProductOfferService.voidTransaction(data)({
|
|
32
29
|
action: actionRepo,
|
|
33
30
|
assetTransaction: assetTransactionRepo,
|
|
34
|
-
registerActionInProgress: registerActionInProgressRepo,
|
|
35
31
|
transaction: transactionRepo
|
|
36
32
|
});
|
|
37
33
|
});
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.345.0",
|
|
14
14
|
"@cinerino/sdk": "5.3.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "21.18.0-alpha.
|
|
118
|
+
"version": "21.18.0-alpha.14"
|
|
119
119
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { RedisClientType } from 'redis';
|
|
2
|
-
/**
|
|
3
|
-
* 進行アクションキーインターフェース
|
|
4
|
-
*/
|
|
5
|
-
export interface IProgressKey {
|
|
6
|
-
agent: {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
product: {
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* 進行中サービス登録アクションリポジトリ
|
|
15
|
-
*/
|
|
16
|
-
export declare class RedisRepository {
|
|
17
|
-
private static readonly KEY_PREFIX;
|
|
18
|
-
private readonly redisClient;
|
|
19
|
-
constructor(redisClient: RedisClientType);
|
|
20
|
-
/**
|
|
21
|
-
* ロックする
|
|
22
|
-
*/
|
|
23
|
-
lock(progressKey: IProgressKey, holder: string): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* メンバーシップ登録進行ロックを解除する
|
|
26
|
-
*/
|
|
27
|
-
unlock(progressKey: IProgressKey): Promise<void>;
|
|
28
|
-
getHolder(progressKey: IProgressKey): Promise<string | null>;
|
|
29
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RedisRepository = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* 進行中サービス登録アクションリポジトリ
|
|
15
|
-
*/
|
|
16
|
-
class RedisRepository {
|
|
17
|
-
constructor(redisClient) {
|
|
18
|
-
this.redisClient = redisClient;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* ロックする
|
|
22
|
-
*/
|
|
23
|
-
lock(progressKey, holder) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const key = `${RedisRepository.KEY_PREFIX}:${progressKey.agent.id}:${progressKey.product.id}`;
|
|
26
|
-
const ttl = 7200;
|
|
27
|
-
const [setNXReply] = yield this.redisClient.multi()
|
|
28
|
-
.setNX(key, holder)
|
|
29
|
-
.expire(key, ttl)
|
|
30
|
-
.exec();
|
|
31
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
32
|
-
/* istanbul ignore else: please write tests */
|
|
33
|
-
if (setNXReply === 1 || setNXReply === true) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
throw new Error('Already in progress.');
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* メンバーシップ登録進行ロックを解除する
|
|
43
|
-
*/
|
|
44
|
-
unlock(progressKey) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const key = `${RedisRepository.KEY_PREFIX}:${progressKey.agent.id}:${progressKey.product.id}`;
|
|
47
|
-
yield this.redisClient.del([key]);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getHolder(progressKey) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const key = `${RedisRepository.KEY_PREFIX}:${progressKey.agent.id}:${progressKey.product.id}`;
|
|
53
|
-
return this.redisClient.get(key);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
RedisRepository.KEY_PREFIX = 'cinerino:registerProgramMembershipActionInProgress';
|
|
58
|
-
exports.RedisRepository = RedisRepository;
|