@chevre/domain 28.0.0-alpha.14 → 28.0.0-alpha.16
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/place/pos.js +11 -12
- package/lib/chevre/repo/sellerPaymentAccepted.d.ts +14 -21
- package/lib/chevre/repo/sellerPaymentAccepted.js +65 -38
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +2 -2
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +1 -1
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket/payActionParams2seatInfoSyncIn.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
- package/package.json +1 -1
|
@@ -95,10 +95,6 @@ class POSRepo {
|
|
|
95
95
|
}
|
|
96
96
|
// 最大数検証(2026-09-20~)
|
|
97
97
|
const { maxNumPOS } = options;
|
|
98
|
-
const { posCount } = await this.countPOS();
|
|
99
|
-
if (posCount >= maxNumPOS) {
|
|
100
|
-
throw new factory_1.factory.errors.Argument('operator.id', 'maxNumPOS exceeded');
|
|
101
|
-
}
|
|
102
98
|
const creatingPOS = {
|
|
103
99
|
// // 互換性維持対応としてidを保管
|
|
104
100
|
// id: params.branchCode as any, // discontinue(2026-09-22~)
|
|
@@ -108,22 +104,25 @@ class POSRepo {
|
|
|
108
104
|
const doc = await this.civicStructureModel.findOneAndUpdate({
|
|
109
105
|
'project.id': { $eq: params.project.id },
|
|
110
106
|
_id: { $eq: this.operator.id },
|
|
111
|
-
'hasPOS.branchCode': { $ne: params.branchCode }
|
|
112
|
-
|
|
113
|
-
$
|
|
114
|
-
|
|
115
|
-
$each: [creatingPOS],
|
|
116
|
-
$slice: maxNumPOS // 最大数担保(2026-09-20~)
|
|
117
|
-
},
|
|
107
|
+
'hasPOS.branchCode': { $ne: params.branchCode },
|
|
108
|
+
// 配列の長さが上限未満であることをアトミックに確認
|
|
109
|
+
$expr: {
|
|
110
|
+
$lt: [{ $size: { $ifNull: ['$hasPOS', []] } }, maxNumPOS] // 最大数担保(2026-09-20~)
|
|
118
111
|
}
|
|
119
112
|
}, {
|
|
120
|
-
|
|
113
|
+
$push: { hasPOS: creatingPOS }
|
|
114
|
+
}, {
|
|
121
115
|
projection: { _id: 1 }
|
|
122
116
|
})
|
|
123
117
|
.lean()
|
|
124
118
|
.exec();
|
|
125
119
|
// 存在しなければID重複
|
|
126
120
|
if (doc === null) {
|
|
121
|
+
const { posCount } = await this.countPOS();
|
|
122
|
+
if (posCount >= maxNumPOS) {
|
|
123
|
+
throw new factory_1.factory.errors.Argument('operator.id', 'maxNumPOS exceeded');
|
|
124
|
+
}
|
|
125
|
+
// 上限以下で追加できない場合は「すでに登録済み」
|
|
127
126
|
throw new factory_1.factory.errors.AlreadyInUse('hasPOS', ['id']);
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -5,29 +5,19 @@ import { Connection } from 'mongoose';
|
|
|
5
5
|
export declare class SellerPaymentAcceptedRepo {
|
|
6
6
|
private readonly sellerModel;
|
|
7
7
|
constructor(connection: Connection);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
$eq?: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
project?: {
|
|
17
|
-
id?: {
|
|
18
|
-
$eq?: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
8
|
+
findSellerPaymentAccepted(params: {
|
|
9
|
+
sellerId: string;
|
|
10
|
+
projectId: string;
|
|
11
|
+
limit: number;
|
|
12
|
+
page: number;
|
|
21
13
|
codeValue?: {
|
|
22
14
|
$eq?: string;
|
|
23
15
|
};
|
|
24
16
|
}): Promise<{
|
|
25
17
|
codeValue: string;
|
|
26
|
-
seller: {
|
|
27
|
-
id: string;
|
|
28
|
-
};
|
|
29
18
|
}[]>;
|
|
30
|
-
|
|
19
|
+
private countSellerPaymentAccepted;
|
|
20
|
+
addSellerPaymentAccepted(params: {
|
|
31
21
|
codeValue: string;
|
|
32
22
|
project: {
|
|
33
23
|
id: string;
|
|
@@ -35,8 +25,10 @@ export declare class SellerPaymentAcceptedRepo {
|
|
|
35
25
|
seller: {
|
|
36
26
|
id: string;
|
|
37
27
|
};
|
|
28
|
+
}, options: {
|
|
29
|
+
maxNumSellerPaymentAccepted: number;
|
|
38
30
|
}): Promise<void>;
|
|
39
|
-
|
|
31
|
+
deleteSellerPaymentAccepted(params: {
|
|
40
32
|
codeValue: string;
|
|
41
33
|
project: {
|
|
42
34
|
id: string;
|
|
@@ -46,9 +38,10 @@ export declare class SellerPaymentAcceptedRepo {
|
|
|
46
38
|
};
|
|
47
39
|
}): Promise<void>;
|
|
48
40
|
isAcceptedBySeller(params: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
sellerId: string;
|
|
42
|
+
/**
|
|
43
|
+
* 決済方法区分
|
|
44
|
+
*/
|
|
52
45
|
codeValue: string;
|
|
53
46
|
}): Promise<boolean>;
|
|
54
47
|
}
|
|
@@ -13,21 +13,21 @@ class SellerPaymentAcceptedRepo {
|
|
|
13
13
|
constructor(connection) {
|
|
14
14
|
this.sellerModel = connection.model(seller_1.modelName, (0, seller_1.createSchema)());
|
|
15
15
|
}
|
|
16
|
-
async
|
|
16
|
+
async findSellerPaymentAccepted(params) {
|
|
17
|
+
const { sellerId, projectId } = params;
|
|
17
18
|
const matchStages = [];
|
|
18
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
19
|
-
if (typeof projectIdEq === 'string') {
|
|
20
|
-
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
21
|
-
}
|
|
22
|
-
const sellerIdEq = params.seller?.id?.$eq;
|
|
23
|
-
if (typeof sellerIdEq === 'string') {
|
|
24
|
-
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(sellerIdEq) } } });
|
|
25
|
-
}
|
|
26
19
|
const codeValueEq = params.codeValue?.$eq;
|
|
27
20
|
if (typeof codeValueEq === 'string') {
|
|
28
21
|
matchStages.push({ $match: { 'paymentAccepted.paymentMethodType': { $exists: true, $eq: codeValueEq } } });
|
|
29
22
|
}
|
|
30
23
|
const aggregate = this.sellerModel.aggregate([
|
|
24
|
+
// まず販売者ドキュメントで絞る
|
|
25
|
+
{
|
|
26
|
+
$match: {
|
|
27
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(sellerId) },
|
|
28
|
+
'project.id': { $eq: projectId }
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
31
|
{
|
|
32
32
|
$unwind: {
|
|
33
33
|
path: '$paymentAccepted'
|
|
@@ -39,45 +39,81 @@ class SellerPaymentAcceptedRepo {
|
|
|
39
39
|
$project: {
|
|
40
40
|
_id: 0,
|
|
41
41
|
codeValue: '$paymentAccepted.paymentMethodType',
|
|
42
|
-
seller: { id: { $toString: '$_id' } }
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
45
|
+
const { limit, page } = params;
|
|
46
|
+
const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
|
|
47
|
+
aggregate.skip(limit * (pageMustBePositive - 1))
|
|
48
|
+
.limit(limit);
|
|
51
49
|
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
52
50
|
.exec();
|
|
53
51
|
}
|
|
54
|
-
async
|
|
55
|
-
|
|
52
|
+
async countSellerPaymentAccepted(params) {
|
|
53
|
+
const paymentAcceptedCount = (await this.sellerModel.aggregate([
|
|
54
|
+
{
|
|
55
|
+
$match: {
|
|
56
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(params.seller.id) },
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
$project: {
|
|
61
|
+
paymentAcceptedCount: {
|
|
62
|
+
$cond: {
|
|
63
|
+
if: { $isArray: '$paymentAccepted' },
|
|
64
|
+
then: { $size: '$paymentAccepted' },
|
|
65
|
+
else: 0
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
]).option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
71
|
+
.exec()).at(0)?.paymentAcceptedCount;
|
|
72
|
+
if (typeof paymentAcceptedCount !== 'number') {
|
|
73
|
+
throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
|
|
74
|
+
}
|
|
75
|
+
return { paymentAcceptedCount };
|
|
76
|
+
}
|
|
77
|
+
async addSellerPaymentAccepted(params, options) {
|
|
78
|
+
const sellerDoc = await this.sellerModel.findOne({
|
|
56
79
|
'project.id': { $eq: params.project.id },
|
|
57
80
|
_id: { $eq: params.seller.id }
|
|
58
81
|
}, { _id: 1 })
|
|
82
|
+
.lean()
|
|
59
83
|
.exec();
|
|
60
|
-
if (
|
|
84
|
+
if (sellerDoc === null) {
|
|
61
85
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
|
|
62
86
|
}
|
|
87
|
+
// 最大数検証(2026-09-20~)
|
|
88
|
+
const { maxNumSellerPaymentAccepted } = options;
|
|
63
89
|
const creatingPaymentAccepted = {
|
|
64
90
|
paymentMethodType: params.codeValue
|
|
65
91
|
};
|
|
66
|
-
doc = await this.sellerModel.findOneAndUpdate({
|
|
92
|
+
const doc = await this.sellerModel.findOneAndUpdate({
|
|
67
93
|
'project.id': { $eq: params.project.id },
|
|
68
94
|
_id: { $eq: params.seller.id },
|
|
69
|
-
'paymentAccepted.paymentMethodType': { $ne: params.codeValue }
|
|
95
|
+
'paymentAccepted.paymentMethodType': { $ne: params.codeValue },
|
|
96
|
+
// 配列の長さが上限未満であることをアトミックに確認
|
|
97
|
+
$expr: {
|
|
98
|
+
$lt: [{ $size: { $ifNull: ['$paymentAccepted', []] } }, maxNumSellerPaymentAccepted] // 最大数担保(2026-09-22~)
|
|
99
|
+
}
|
|
70
100
|
}, {
|
|
71
101
|
$push: { paymentAccepted: creatingPaymentAccepted }
|
|
72
102
|
}, {
|
|
73
103
|
projection: { _id: 1 }
|
|
74
104
|
})
|
|
105
|
+
.lean()
|
|
75
106
|
.exec();
|
|
76
107
|
if (doc === null) {
|
|
108
|
+
const { paymentAcceptedCount } = await this.countSellerPaymentAccepted({ seller: params.seller });
|
|
109
|
+
if (paymentAcceptedCount >= maxNumSellerPaymentAccepted) {
|
|
110
|
+
throw new factory_1.factory.errors.Argument('seller.id', 'maxNumSellerPaymentAccepted exceeded');
|
|
111
|
+
}
|
|
112
|
+
// 上限以下で追加できない場合は「すでに登録済み」
|
|
77
113
|
throw new factory_1.factory.errors.AlreadyInUse('paymentAccepted', ['paymentMethodType']);
|
|
78
114
|
}
|
|
79
115
|
}
|
|
80
|
-
async
|
|
116
|
+
async deleteSellerPaymentAccepted(params) {
|
|
81
117
|
const doc = await this.sellerModel.findOneAndUpdate({
|
|
82
118
|
'project.id': { $eq: params.project.id },
|
|
83
119
|
_id: { $eq: params.seller.id },
|
|
@@ -87,29 +123,20 @@ class SellerPaymentAcceptedRepo {
|
|
|
87
123
|
}, {
|
|
88
124
|
projection: { _id: 1 }
|
|
89
125
|
})
|
|
126
|
+
.lean()
|
|
90
127
|
.exec();
|
|
91
128
|
if (doc === null) {
|
|
92
129
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
|
|
93
130
|
}
|
|
94
131
|
}
|
|
95
132
|
async isAcceptedBySeller(params) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
$project: {
|
|
104
|
-
_id: 0,
|
|
105
|
-
codeValue: '$paymentAccepted.paymentMethodType'
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
])
|
|
109
|
-
.limit(1)
|
|
110
|
-
.skip(0);
|
|
111
|
-
return (await aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
112
|
-
.exec()).length > 0;
|
|
133
|
+
const { sellerId, codeValue } = params;
|
|
134
|
+
const doc = await this.sellerModel.exists({
|
|
135
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(sellerId) },
|
|
136
|
+
'paymentAccepted.paymentMethodType': { $exists: true, $eq: codeValue }
|
|
137
|
+
})
|
|
138
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS });
|
|
139
|
+
return doc !== null;
|
|
113
140
|
}
|
|
114
141
|
}
|
|
115
142
|
exports.SellerPaymentAcceptedRepo = SellerPaymentAcceptedRepo;
|
|
@@ -21,7 +21,7 @@ function validateSeller(params) {
|
|
|
21
21
|
// 販売者の対応決済方法かどうか確認
|
|
22
22
|
// const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === paymentMethodType);
|
|
23
23
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
24
|
-
|
|
24
|
+
sellerId,
|
|
25
25
|
codeValue: paymentMethodType
|
|
26
26
|
});
|
|
27
27
|
if (paymentAccepted !== true) {
|
|
@@ -33,7 +33,7 @@ function validateSeller(params) {
|
|
|
33
33
|
// 販売者の対応決済方法かどうか確認
|
|
34
34
|
// const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === paymentMethodType);
|
|
35
35
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
36
|
-
|
|
36
|
+
sellerId,
|
|
37
37
|
codeValue: paymentMethodType
|
|
38
38
|
});
|
|
39
39
|
if (paymentAccepted !== true) {
|
|
@@ -6,7 +6,7 @@ function getGMOInfoFromSeller(params) {
|
|
|
6
6
|
return async (repos) => {
|
|
7
7
|
if (params.requirePaymentAccepted) {
|
|
8
8
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
9
|
-
|
|
9
|
+
sellerId: params.seller.id,
|
|
10
10
|
codeValue: params.paymentMethodType
|
|
11
11
|
});
|
|
12
12
|
if (paymentAccepted !== true) {
|
|
@@ -56,7 +56,7 @@ function checkMovieTicket(params) {
|
|
|
56
56
|
const screeningEvent = await repos.event.projectEventFieldsById({ id: eventIds[0] }, ['typeOf', 'project', 'coaInfo', 'startDate', 'offers.offeredThrough', 'superEvent.workPerformed.identifier']);
|
|
57
57
|
const sellerId = optimizedCheckObject[0]?.seller.id;
|
|
58
58
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
59
|
-
|
|
59
|
+
sellerId,
|
|
60
60
|
codeValue: paymentMethodType
|
|
61
61
|
});
|
|
62
62
|
if (paymentAccepted !== true) {
|
package/lib/chevre/service/payment/movieTicket/payMovieTicket/payActionParams2seatInfoSyncIn.js
CHANGED
|
@@ -31,7 +31,7 @@ function payActionParams2seatInfoSyncIn(params) {
|
|
|
31
31
|
paymentServiceId
|
|
32
32
|
})(repos);
|
|
33
33
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
34
|
-
|
|
34
|
+
sellerId,
|
|
35
35
|
codeValue: paymentMethodType
|
|
36
36
|
});
|
|
37
37
|
if (paymentAccepted !== true) {
|
|
@@ -61,7 +61,7 @@ checkedAction, purpose) {
|
|
|
61
61
|
// }
|
|
62
62
|
// const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === paymentMethodType);
|
|
63
63
|
const paymentAccepted = await repos.paymentAccepted.isAcceptedBySeller({
|
|
64
|
-
|
|
64
|
+
sellerId,
|
|
65
65
|
codeValue: paymentMethodType
|
|
66
66
|
});
|
|
67
67
|
if (paymentAccepted !== true) {
|
package/package.json
CHANGED