@chevre/domain 26.1.0-alpha.0 → 26.1.0-alpha.2
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/accountingReport.d.ts +1 -32
- package/lib/chevre/repo/accountingReport.js +4 -85
- package/lib/chevre/repo/action/checkMovieTicket.d.ts +44 -54
- package/lib/chevre/repo/action/checkMovieTicket.js +71 -66
- package/lib/chevre/repo/action/dedicatedAction/dedicatedActionProcess.d.ts +5 -5
- package/lib/chevre/repo/adminAccountingReport.d.ts +40 -0
- package/lib/chevre/repo/adminAccountingReport.js +89 -0
- package/lib/chevre/repo/adminCheckMovieTicketAction.d.ts +29 -0
- package/lib/chevre/repo/adminCheckMovieTicketAction.js +87 -0
- package/lib/chevre/repo/aggregateAction.d.ts +1 -10
- package/lib/chevre/repo/aggregateAction.js +0 -25
- package/lib/chevre/repo/aggregateCheckMovieTicketAction.d.ts +31 -0
- package/lib/chevre/repo/aggregateCheckMovieTicketAction.js +138 -0
- package/lib/chevre/repo/aggregateUseAction.d.ts +0 -9
- package/lib/chevre/repo/aggregateUseAction.js +0 -25
- package/lib/chevre/repo/mongoose/schemas/action/checkMovieTicket.d.ts +11 -0
- package/lib/chevre/repo/mongoose/schemas/action/checkMovieTicket.js +108 -0
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +35 -2
- package/lib/chevre/service/aggregation/system.d.ts +2 -1
- package/lib/chevre/service/aggregation/system.js +1 -2
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -2
- package/lib/chevre/service/order/deleteOrder.js +1 -1
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +4 -4
- package/lib/chevre/service/payment/movieTicket/validation.js +13 -43
- package/lib/chevre/service/task/deleteTransaction.js +2 -2
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import type { Connection
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
import { IDocType } from './mongoose/schemas/accountingReport';
|
|
4
|
-
type IMatchStage = PipelineStage.Match;
|
|
5
|
-
type IReportAsFindResult = Pick<factory.report.accountingReport.IReport, 'mainEntity'> & {
|
|
6
|
-
isPartOf: {
|
|
7
|
-
mainEntity: factory.report.accountingReport.IOrderAsMainEntity;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
4
|
/**
|
|
11
5
|
* 経理レポートリポジトリ
|
|
12
6
|
*/
|
|
13
7
|
export declare class AccountingReportRepo {
|
|
14
8
|
private readonly accountingReportModel;
|
|
15
9
|
constructor(connection: Connection);
|
|
16
|
-
static CREATE_MONGO_CONDITIONS(params: factory.report.accountingReport.ISearchConditions & {
|
|
17
|
-
seller?: {
|
|
18
|
-
id?: string;
|
|
19
|
-
};
|
|
20
|
-
}): IMatchStage[];
|
|
21
10
|
syncMainEntity(params: IDocType): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* 注文番号で削除する
|
|
24
|
-
*/
|
|
25
|
-
deleteByOrderNumber(params: {
|
|
26
|
-
mainEntity: {
|
|
27
|
-
orderNumber: string;
|
|
28
|
-
};
|
|
29
|
-
}): Promise<void>;
|
|
30
11
|
/**
|
|
31
12
|
* 注文にアクションレポートを追加する
|
|
32
13
|
* 注文に対する経理レポート自体が未作成であれば自動的に作成する
|
|
@@ -40,16 +21,4 @@ export declare class AccountingReportRepo {
|
|
|
40
21
|
};
|
|
41
22
|
hasPart: factory.report.accountingReport.IChildReport;
|
|
42
23
|
}): Promise<void>;
|
|
43
|
-
findAccountingReports(params: factory.report.accountingReport.ISearchConditions & {
|
|
44
|
-
seller?: {
|
|
45
|
-
id?: string;
|
|
46
|
-
};
|
|
47
|
-
limit: number;
|
|
48
|
-
page: number;
|
|
49
|
-
}): Promise<IReportAsFindResult[]>;
|
|
50
|
-
unsetUnnecessaryFields(params: {
|
|
51
|
-
filter: any;
|
|
52
|
-
$unset: any;
|
|
53
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
54
24
|
}
|
|
55
|
-
export {};
|
|
@@ -12,44 +12,6 @@ class AccountingReportRepo {
|
|
|
12
12
|
constructor(connection) {
|
|
13
13
|
this.accountingReportModel = connection.model(accountingReport_1.modelName, (0, accountingReport_1.createSchema)());
|
|
14
14
|
}
|
|
15
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
16
|
-
const matchStages = [];
|
|
17
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
18
|
-
if (typeof projectIdEq === 'string') {
|
|
19
|
-
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
20
|
-
}
|
|
21
|
-
// req.seller.idを考慮(2023-07-21~)
|
|
22
|
-
if (typeof params.seller?.id === 'string') {
|
|
23
|
-
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: params.seller.id } } });
|
|
24
|
-
}
|
|
25
|
-
const orderNumberEq = params.order?.orderNumber?.$eq;
|
|
26
|
-
if (typeof orderNumberEq === 'string') {
|
|
27
|
-
matchStages.push({ $match: { 'mainEntity.orderNumber': { $eq: orderNumberEq } } });
|
|
28
|
-
}
|
|
29
|
-
const sellerIdEq = params.order?.seller?.id?.$eq;
|
|
30
|
-
if (typeof sellerIdEq === 'string') {
|
|
31
|
-
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: sellerIdEq } } });
|
|
32
|
-
}
|
|
33
|
-
const paymentMethodIdEq = params.order?.paymentMethods?.paymentMethodId?.$eq;
|
|
34
|
-
if (typeof paymentMethodIdEq === 'string') {
|
|
35
|
-
matchStages.push({
|
|
36
|
-
$match: { 'mainEntity.paymentMethods.paymentMethodId': { $exists: true, $eq: paymentMethodIdEq } }
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const orderDateGte = params.order?.orderDate?.$gte;
|
|
40
|
-
if (orderDateGte instanceof Date) {
|
|
41
|
-
matchStages.push({
|
|
42
|
-
$match: { 'mainEntity.orderDate': { $gte: orderDateGte } }
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const orderDateLte = params.order?.orderDate?.$lte;
|
|
46
|
-
if (orderDateLte instanceof Date) {
|
|
47
|
-
matchStages.push({
|
|
48
|
-
$match: { 'mainEntity.orderDate': { $lte: orderDateLte } }
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return matchStages;
|
|
52
|
-
}
|
|
53
15
|
async syncMainEntity(params) {
|
|
54
16
|
const setOnInsert = {
|
|
55
17
|
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
@@ -57,7 +19,7 @@ class AccountingReportRepo {
|
|
|
57
19
|
hasPart: [],
|
|
58
20
|
mainEntity: {
|
|
59
21
|
orderNumber: params.mainEntity.orderNumber // orderNumberのみが最低限必要なのでなければ作成
|
|
60
|
-
}
|
|
22
|
+
}
|
|
61
23
|
};
|
|
62
24
|
try {
|
|
63
25
|
// なければ作成
|
|
@@ -80,13 +42,6 @@ class AccountingReportRepo {
|
|
|
80
42
|
await this.accountingReportModel.updateOne({ 'mainEntity.orderNumber': { $eq: params.mainEntity.orderNumber } }, { $set: { mainEntity: params.mainEntity } })
|
|
81
43
|
.exec();
|
|
82
44
|
}
|
|
83
|
-
/**
|
|
84
|
-
* 注文番号で削除する
|
|
85
|
-
*/
|
|
86
|
-
async deleteByOrderNumber(params) {
|
|
87
|
-
await this.accountingReportModel.deleteOne({ 'mainEntity.orderNumber': params.mainEntity.orderNumber })
|
|
88
|
-
.exec();
|
|
89
|
-
}
|
|
90
45
|
/**
|
|
91
46
|
* 注文にアクションレポートを追加する
|
|
92
47
|
* 注文に対する経理レポート自体が未作成であれば自動的に作成する
|
|
@@ -95,50 +50,14 @@ class AccountingReportRepo {
|
|
|
95
50
|
const setOnInsert = {
|
|
96
51
|
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
97
52
|
typeOf: 'Report',
|
|
98
|
-
// hasPart: [],
|
|
99
53
|
mainEntity: {
|
|
100
54
|
orderNumber: params.mainEntity.orderNumber // orderNumberのみが最低限必要なのでなければ作成
|
|
101
|
-
}
|
|
55
|
+
}
|
|
102
56
|
};
|
|
103
|
-
|
|
57
|
+
await this.accountingReportModel.updateOne({ 'mainEntity.orderNumber': { $eq: params.mainEntity.orderNumber } }, {
|
|
104
58
|
$addToSet: { hasPart: params.hasPart },
|
|
105
59
|
$setOnInsert: setOnInsert
|
|
106
|
-
}, {
|
|
107
|
-
projection: { _id: 1 },
|
|
108
|
-
upsert: true
|
|
109
|
-
})
|
|
110
|
-
.exec();
|
|
111
|
-
if (doc === null) {
|
|
112
|
-
throw new factory_1.factory.errors.NotFound(this.accountingReportModel.modelName);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async findAccountingReports(params) {
|
|
116
|
-
const { limit, page } = params;
|
|
117
|
-
const matchStages = AccountingReportRepo.CREATE_MONGO_CONDITIONS(params);
|
|
118
|
-
const aggregate = this.accountingReportModel.aggregate([
|
|
119
|
-
...matchStages,
|
|
120
|
-
// pipelineの順序に注意
|
|
121
|
-
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
122
|
-
{ $sort: { 'mainEntity.orderDate': factory_1.factory.sortType.Descending } },
|
|
123
|
-
{ $unwind: '$hasPart' },
|
|
124
|
-
// hasPart内に対する検索条件は存在しないため、unwind後のmatchは不要
|
|
125
|
-
{
|
|
126
|
-
$project: {
|
|
127
|
-
_id: 0,
|
|
128
|
-
mainEntity: '$hasPart.mainEntity',
|
|
129
|
-
isPartOf: {
|
|
130
|
-
mainEntity: '$mainEntity'
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
]);
|
|
135
|
-
return aggregate
|
|
136
|
-
.skip(limit * (page - 1))
|
|
137
|
-
.limit(limit)
|
|
138
|
-
.exec();
|
|
139
|
-
}
|
|
140
|
-
async unsetUnnecessaryFields(params) {
|
|
141
|
-
return this.accountingReportModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
60
|
+
}, { upsert: true })
|
|
142
61
|
.exec();
|
|
143
62
|
}
|
|
144
63
|
}
|
|
@@ -1,67 +1,45 @@
|
|
|
1
|
-
import { Surfrock } from '@surfrock/sdk';
|
|
1
|
+
import type { Surfrock } from '@surfrock/sdk';
|
|
2
2
|
import type { Connection } from 'mongoose';
|
|
3
3
|
import { factory } from '../../factory';
|
|
4
|
-
import {
|
|
4
|
+
import { DedicatedActionProcessRepo, IActionRecipe, IRecipeAsActionAttributes } from './dedicatedAction/dedicatedActionProcess';
|
|
5
5
|
export type IMinimizedPurchaseNumberAuthResult = Pick<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult, 'mkknmiNumSum' | 'resultInfo' | 'ykknmiNumSum'> & {
|
|
6
6
|
knyknrNoInfoOut: Omit<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberInfo, 'ykknInfo' | 'mkknInfo'>[] | null;
|
|
7
7
|
};
|
|
8
|
+
type StartableActionType = factory.actionType.CheckAction;
|
|
9
|
+
type ICheckMovieTicketAction = Pick<factory.action.check.paymentMethod.movieTicket.IAction, 'actionStatus' | 'agent' | 'endDate' | 'error' | 'expires' | 'id' | 'instrument' | 'object' | 'project' | 'purpose' | 'sameAs' | 'startDate' | 'typeOf'> & {
|
|
10
|
+
potentialActions?: never;
|
|
11
|
+
result?: never;
|
|
12
|
+
};
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* 決済カード認証アクションリポジトリ
|
|
10
15
|
*/
|
|
11
|
-
|
|
16
|
+
export declare class CheckMovieTicketActionRepo extends DedicatedActionProcessRepo<StartableActionType, IActionRecipe<factory.recipe.RecipeCategory.checkMovieTicket>> {
|
|
12
17
|
/**
|
|
13
|
-
*
|
|
18
|
+
* 専用アクションモデル
|
|
14
19
|
*/
|
|
15
|
-
|
|
16
|
-
purpose?: {
|
|
17
|
-
/**
|
|
18
|
-
* 注文取引ID
|
|
19
|
-
*/
|
|
20
|
-
id?: string;
|
|
21
|
-
};
|
|
22
|
-
object?: never;
|
|
23
|
-
sort?: never;
|
|
24
|
-
}) | (Pick<factory.action.ISearchConditions, 'sort'> & {
|
|
25
|
-
purpose?: {
|
|
26
|
-
/**
|
|
27
|
-
* 注文取引ID
|
|
28
|
-
*/
|
|
29
|
-
id?: string;
|
|
30
|
-
};
|
|
31
|
-
object?: {
|
|
32
|
-
/**
|
|
33
|
-
* 決済サービス
|
|
34
|
-
*/
|
|
35
|
-
id?: {
|
|
36
|
-
$eq?: string;
|
|
37
|
-
};
|
|
38
|
-
movieTickets?: {
|
|
39
|
-
identifier?: {
|
|
40
|
-
$eq?: string;
|
|
41
|
-
};
|
|
42
|
-
serviceOutput?: {
|
|
43
|
-
reservationFor?: {
|
|
44
|
-
id?: {
|
|
45
|
-
$eq?: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
typeOf?: {
|
|
51
|
-
$eq?: factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
20
|
+
private readonly checkMovieTicketActionModel;
|
|
54
21
|
/**
|
|
55
|
-
*
|
|
22
|
+
* 旧汎用アクションモデル
|
|
56
23
|
*/
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
export type ICheckMovieTicketAction = factory.action.check.paymentMethod.movieTicket.IAction;
|
|
60
|
-
/**
|
|
61
|
-
* 決済カード認証アクションリポジトリ
|
|
62
|
-
*/
|
|
63
|
-
export declare class CheckMovieTicketActionRepo extends ActionProcessRepo<ICheckMovieTicketAction, IActionRecipe<factory.recipe.RecipeCategory.checkMovieTicket>> {
|
|
24
|
+
private readonly legacyActionModel;
|
|
64
25
|
constructor(connection: Connection);
|
|
26
|
+
startCheckMovieTicketAction(attributes: Pick<factory.action.check.paymentMethod.movieTicket.IAttributes, 'agent' | 'instrument' | 'object' | 'project' | 'purpose' | 'sameAs' | 'typeOf'> & {
|
|
27
|
+
potentialActions?: never;
|
|
28
|
+
}, options?: {
|
|
29
|
+
recipe?: IRecipeAsActionAttributes<factory.recipe.RecipeCategory.checkMovieTicket>;
|
|
30
|
+
}): Promise<Pick<ICheckMovieTicketAction, 'id' | 'typeOf' | 'startDate'>>;
|
|
31
|
+
completeCheckMovieTicketAction(params: {
|
|
32
|
+
typeOf: StartableActionType;
|
|
33
|
+
id: string;
|
|
34
|
+
result?: never;
|
|
35
|
+
recipe?: IRecipeAsActionAttributes<factory.recipe.RecipeCategory.checkMovieTicket>;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
giveUpCheckMovieTicketAction(params: {
|
|
38
|
+
typeOf: StartableActionType;
|
|
39
|
+
id: string;
|
|
40
|
+
error: Error | Error[] | unknown;
|
|
41
|
+
recipe?: IRecipeAsActionAttributes<factory.recipe.RecipeCategory.checkMovieTicket>;
|
|
42
|
+
}): Promise<void>;
|
|
65
43
|
findActionBySameAs(params: {
|
|
66
44
|
sameAs: {
|
|
67
45
|
id: string;
|
|
@@ -69,7 +47,7 @@ export declare class CheckMovieTicketActionRepo extends ActionProcessRepo<ICheck
|
|
|
69
47
|
purpose?: {
|
|
70
48
|
id: string;
|
|
71
49
|
};
|
|
72
|
-
}): Promise<Pick<
|
|
50
|
+
}): Promise<Pick<ICheckMovieTicketAction, "error" | "id" | "purpose" | "actionStatus"> | null>;
|
|
73
51
|
/**
|
|
74
52
|
* アクションIDからレシピのafterMediaを参照する
|
|
75
53
|
*/
|
|
@@ -81,6 +59,7 @@ export declare class CheckMovieTicketActionRepo extends ActionProcessRepo<ICheck
|
|
|
81
59
|
id: string;
|
|
82
60
|
};
|
|
83
61
|
}): Promise<IMinimizedPurchaseNumberAuthResult | undefined>;
|
|
62
|
+
private completedCheckMovieTicketActionExistsById;
|
|
84
63
|
searchYkknInfoByCheckRecipe(filter: {
|
|
85
64
|
limit: number;
|
|
86
65
|
page: number;
|
|
@@ -116,6 +95,17 @@ export declare class CheckMovieTicketActionRepo extends ActionProcessRepo<ICheck
|
|
|
116
95
|
/**
|
|
117
96
|
* 認証済アクション参照
|
|
118
97
|
*/
|
|
119
|
-
|
|
98
|
+
findCompletedCheckMovieTicketAction(params: {
|
|
99
|
+
/**
|
|
100
|
+
* 認証アクションID
|
|
101
|
+
*/
|
|
102
|
+
id: string;
|
|
103
|
+
purpose: {
|
|
104
|
+
/**
|
|
105
|
+
* 注文取引ID
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
};
|
|
109
|
+
}): Promise<Pick<ICheckMovieTicketAction, "id"> | null>;
|
|
120
110
|
}
|
|
121
111
|
export {};
|
|
@@ -3,39 +3,75 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CheckMovieTicketActionRepo = void 0;
|
|
4
4
|
const factory_1 = require("../../factory");
|
|
5
5
|
const settings_1 = require("../../settings");
|
|
6
|
-
const
|
|
6
|
+
const checkMovieTicket_1 = require("../mongoose/schemas/action/checkMovieTicket");
|
|
7
|
+
const action_1 = require("../mongoose/schemas/action");
|
|
8
|
+
const dedicatedActionProcess_1 = require("./dedicatedAction/dedicatedActionProcess");
|
|
7
9
|
const EXPIRE_AFTER_SECONDS = 2592000; // 30 days
|
|
8
10
|
/**
|
|
9
11
|
* 決済カード認証アクションリポジトリ
|
|
10
12
|
*/
|
|
11
|
-
class CheckMovieTicketActionRepo extends
|
|
13
|
+
class CheckMovieTicketActionRepo extends dedicatedActionProcess_1.DedicatedActionProcessRepo {
|
|
14
|
+
/**
|
|
15
|
+
* 専用アクションモデル
|
|
16
|
+
*/
|
|
17
|
+
checkMovieTicketActionModel;
|
|
18
|
+
/**
|
|
19
|
+
* 旧汎用アクションモデル
|
|
20
|
+
*/
|
|
21
|
+
legacyActionModel;
|
|
12
22
|
constructor(connection) {
|
|
13
|
-
|
|
23
|
+
const checkMovieTicketActionModel = connection.model(checkMovieTicket_1.modelName, (0, checkMovieTicket_1.createSchema)());
|
|
24
|
+
const legacyActionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
|
|
25
|
+
super({
|
|
26
|
+
connection,
|
|
27
|
+
actionModel: checkMovieTicketActionModel
|
|
28
|
+
}, {
|
|
14
29
|
expireAfterSeconds: EXPIRE_AFTER_SECONDS,
|
|
15
30
|
recipeExpireAfterSeconds: EXPIRE_AFTER_SECONDS
|
|
16
31
|
});
|
|
32
|
+
this.checkMovieTicketActionModel = checkMovieTicketActionModel;
|
|
33
|
+
this.legacyActionModel = legacyActionModel;
|
|
34
|
+
}
|
|
35
|
+
async startCheckMovieTicketAction(attributes, options) {
|
|
36
|
+
return this.startAction(attributes, options);
|
|
37
|
+
}
|
|
38
|
+
async completeCheckMovieTicketAction(params) {
|
|
39
|
+
await this.completeAction(params);
|
|
40
|
+
}
|
|
41
|
+
async giveUpCheckMovieTicketAction(params) {
|
|
42
|
+
await this.giveUpAction(params);
|
|
17
43
|
}
|
|
18
44
|
async findActionBySameAs(params) {
|
|
19
|
-
|
|
45
|
+
const filter = {
|
|
20
46
|
typeOf: { $eq: factory_1.factory.actionType.CheckAction }, // 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
|
|
21
47
|
'sameAs.id': { $exists: true, $eq: params.sameAs.id },
|
|
22
48
|
...(typeof params.purpose?.id === 'string')
|
|
23
49
|
? { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
|
|
24
50
|
: undefined
|
|
25
|
-
}
|
|
51
|
+
};
|
|
52
|
+
const projection = {
|
|
26
53
|
_id: 0,
|
|
27
54
|
id: { $toString: '$_id' },
|
|
28
55
|
actionStatus: 1,
|
|
29
56
|
error: 1,
|
|
30
57
|
purpose: 1
|
|
31
|
-
}
|
|
58
|
+
};
|
|
59
|
+
const doc = await this.checkMovieTicketActionModel.findOne(filter, projection)
|
|
32
60
|
.lean()
|
|
33
61
|
.exec();
|
|
62
|
+
if (doc === null) {
|
|
63
|
+
// コレクション移行の互換性維持対応(2026-08-20~)
|
|
64
|
+
return this.legacyActionModel.findOne(filter, projection)
|
|
65
|
+
.lean()
|
|
66
|
+
.exec();
|
|
67
|
+
}
|
|
68
|
+
return doc;
|
|
34
69
|
}
|
|
35
70
|
/**
|
|
36
71
|
* アクションIDからレシピのafterMediaを参照する
|
|
37
72
|
*/
|
|
38
73
|
async findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params) {
|
|
74
|
+
// レシピのみ参照のため互換性維持対応は不要
|
|
39
75
|
const recipe = await this.actionRecipeModel.findOne({
|
|
40
76
|
'project.id': { $eq: params.project.id },
|
|
41
77
|
'recipeFor.id': { $eq: params.recipeFor.id }
|
|
@@ -52,7 +88,7 @@ class CheckMovieTicketActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
52
88
|
.exec();
|
|
53
89
|
return recipe?.step[0]?.itemListElement[0]?.itemListElement[0]?.afterMedia;
|
|
54
90
|
}
|
|
55
|
-
async
|
|
91
|
+
async completedCheckMovieTicketActionExistsById(filter) {
|
|
56
92
|
const filterQuery = {
|
|
57
93
|
_id: { $eq: filter.id },
|
|
58
94
|
'project.id': { $eq: filter.project.id },
|
|
@@ -60,11 +96,19 @@ class CheckMovieTicketActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
60
96
|
typeOf: { $eq: factory_1.factory.actionType.CheckAction },
|
|
61
97
|
actionStatus: { $eq: factory_1.factory.actionStatusType.CompletedActionStatus }
|
|
62
98
|
};
|
|
63
|
-
const actionDoc = await this.
|
|
99
|
+
const actionDoc = await this.checkMovieTicketActionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
|
|
64
100
|
.exec();
|
|
65
101
|
if (actionDoc === null) {
|
|
66
|
-
|
|
102
|
+
// コレクション移行の互換性維持対応(2026-08-20~)
|
|
103
|
+
const legacyActionDoc = await this.legacyActionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
|
|
104
|
+
.exec();
|
|
105
|
+
if (legacyActionDoc === null) {
|
|
106
|
+
throw new factory_1.factory.errors.NotFound(this.checkMovieTicketActionModel.modelName);
|
|
107
|
+
}
|
|
67
108
|
}
|
|
109
|
+
}
|
|
110
|
+
async searchYkknInfoByCheckRecipe(filter) {
|
|
111
|
+
await this.completedCheckMovieTicketActionExistsById(filter);
|
|
68
112
|
const filterQuery4recipe = {
|
|
69
113
|
'recipeFor.id': { $eq: filter.id }
|
|
70
114
|
};
|
|
@@ -96,18 +140,7 @@ class CheckMovieTicketActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
96
140
|
.exec();
|
|
97
141
|
}
|
|
98
142
|
async searchMkknInfoByCheckRecipe(filter) {
|
|
99
|
-
|
|
100
|
-
_id: { $eq: filter.id },
|
|
101
|
-
'project.id': { $eq: filter.project.id },
|
|
102
|
-
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
103
|
-
typeOf: { $eq: factory_1.factory.actionType.CheckAction },
|
|
104
|
-
actionStatus: { $eq: factory_1.factory.actionStatusType.CompletedActionStatus }
|
|
105
|
-
};
|
|
106
|
-
const actionDoc = this.actionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
|
|
107
|
-
.exec();
|
|
108
|
-
if (actionDoc === null) {
|
|
109
|
-
throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
|
|
110
|
-
}
|
|
143
|
+
await this.completedCheckMovieTicketActionExistsById(filter);
|
|
111
144
|
const filterQuery4recipe = {
|
|
112
145
|
'recipeFor.id': { $eq: filter.id }
|
|
113
146
|
};
|
|
@@ -145,57 +178,29 @@ class CheckMovieTicketActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
145
178
|
/**
|
|
146
179
|
* 認証済アクション参照
|
|
147
180
|
*/
|
|
148
|
-
async
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (typeof objectMovieTicketsIdentifierEq === 'string') {
|
|
156
|
-
andConditions.push({
|
|
157
|
-
'object.movieTickets.identifier': { $exists: true, $eq: objectMovieTicketsIdentifierEq }
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
|
|
161
|
-
if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
|
|
162
|
-
andConditions.push({
|
|
163
|
-
'object.movieTickets.serviceOutput.reservationFor.id': { $exists: true, $eq: objectMovieTicketsServiceOutputReservationForIdEq }
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
167
|
-
if (typeof objectTypeOfEq === 'string') {
|
|
168
|
-
andConditions.push({
|
|
169
|
-
'object.typeOf': { $exists: true, $eq: objectTypeOfEq }
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
const objectIdEq = params.object?.id?.$eq;
|
|
173
|
-
if (typeof objectIdEq === 'string') {
|
|
174
|
-
andConditions.push({
|
|
175
|
-
'object.id': { $exists: true, $eq: objectIdEq }
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const purposeIdEq = params.purpose?.id;
|
|
179
|
-
if (typeof purposeIdEq === 'string') {
|
|
180
|
-
andConditions.push({
|
|
181
|
-
'purpose.id': { $exists: true, $eq: purposeIdEq }
|
|
182
|
-
});
|
|
183
|
-
}
|
|
181
|
+
async findCompletedCheckMovieTicketAction(params) {
|
|
182
|
+
const filter = {
|
|
183
|
+
_id: { $eq: params.id },
|
|
184
|
+
typeOf: { $eq: factory_1.factory.actionType.CheckAction },
|
|
185
|
+
actionStatus: { $eq: factory_1.factory.actionStatusType.CompletedActionStatus },
|
|
186
|
+
'purpose.id': { $exists: true, $eq: params.purpose.id }
|
|
187
|
+
};
|
|
184
188
|
const projection = {
|
|
185
189
|
_id: 0,
|
|
186
190
|
id: { $toString: '$_id' },
|
|
187
191
|
};
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
/* istanbul ignore else */
|
|
191
|
-
if (params.sort?.startDate !== undefined) {
|
|
192
|
-
query.sort({ startDate: params.sort.startDate });
|
|
193
|
-
}
|
|
194
|
-
// const explainResult = await (<any>query).explain();
|
|
195
|
-
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
196
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
192
|
+
const doc = await this.checkMovieTicketActionModel.findOne(filter, projection)
|
|
193
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
197
194
|
.lean()
|
|
198
195
|
.exec();
|
|
196
|
+
if (doc === null) {
|
|
197
|
+
// コレクション移行の互換性維持対応(2026-08-20~)
|
|
198
|
+
return this.legacyActionModel.findOne(filter, projection)
|
|
199
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
200
|
+
.lean()
|
|
201
|
+
.exec();
|
|
202
|
+
}
|
|
203
|
+
return doc;
|
|
199
204
|
}
|
|
200
205
|
}
|
|
201
206
|
exports.CheckMovieTicketActionRepo = CheckMovieTicketActionRepo;
|
|
@@ -2,10 +2,11 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import { factory } from '../../../factory';
|
|
3
3
|
import type { IAbstractActionModel } from '../../mongoose/schemas/action/abstractAction';
|
|
4
4
|
import { ActionRecipeRepo, IActionRecipe, IRecipeAsActionAttributes } from '../anyAction/actionRecipe';
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
5
|
+
export { IActionRecipe, IRecipeAsActionAttributes };
|
|
6
|
+
type AvailableActionType = factory.actionType.InformAction | factory.actionType.AddAction | factory.actionType.UpdateAction | factory.actionType.ReplaceAction | factory.actionType.DeleteAction | factory.actionType.UseAction | factory.actionType.CheckAction;
|
|
7
|
+
type IAction<T extends AvailableActionType> = T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction : T extends factory.actionType.AddAction ? factory.action.update.add.IAction : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction : T extends factory.actionType.DeleteAction ? factory.action.update.deleteAction.IAction : T extends factory.actionType.UseAction ? factory.action.consume.use.reservation.IAction : T extends factory.actionType.CheckAction ? factory.action.check.paymentMethod.movieTicket.IAction : never;
|
|
8
|
+
type IActionAttributes<T extends AvailableActionType> = T extends factory.actionType.InformAction ? factory.action.interact.inform.IAttributes : T extends factory.actionType.AddAction ? factory.action.update.add.IAttributes : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAttributes : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAttributes : T extends factory.actionType.DeleteAction ? factory.action.update.deleteAction.IAttributes : T extends factory.actionType.UseAction ? factory.action.consume.use.reservation.IAttributes : T extends factory.actionType.CheckAction ? factory.action.check.paymentMethod.movieTicket.IAttributes : never;
|
|
9
|
+
type IResult<T extends AvailableActionType> = T extends factory.actionType.InformAction ? factory.action.interact.inform.IResult : T extends factory.actionType.AddAction ? factory.action.update.add.IResult : T extends factory.actionType.UpdateAction ? factory.action.update.update.IResult : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IResult : T extends factory.actionType.DeleteAction ? factory.action.update.deleteAction.IResult : T extends factory.actionType.UseAction ? factory.action.consume.use.reservation.IResult : T extends factory.actionType.CheckAction ? factory.action.check.paymentMethod.movieTicket.IResult : never;
|
|
9
10
|
interface IOptions {
|
|
10
11
|
expireAfterSeconds: number;
|
|
11
12
|
recipeExpireAfterSeconds: number;
|
|
@@ -43,4 +44,3 @@ export declare class DedicatedActionProcessRepo<TActionType extends AvailableAct
|
|
|
43
44
|
recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
|
|
44
45
|
}): Promise<void>;
|
|
45
46
|
}
|
|
46
|
-
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Connection, PipelineStage } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
type IMatchStage = PipelineStage.Match;
|
|
4
|
+
type IReportAsFindResult = Pick<factory.report.accountingReport.IReport, 'mainEntity'> & {
|
|
5
|
+
isPartOf: {
|
|
6
|
+
mainEntity: factory.report.accountingReport.IOrderAsMainEntity;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 経理レポート管理リポジトリ
|
|
11
|
+
*/
|
|
12
|
+
export declare class AdminAccountingReportRepo {
|
|
13
|
+
private readonly accountingReportModel;
|
|
14
|
+
constructor(connection: Connection);
|
|
15
|
+
static CREATE_MONGO_CONDITIONS(params: factory.report.accountingReport.ISearchConditions & {
|
|
16
|
+
seller?: {
|
|
17
|
+
id?: string;
|
|
18
|
+
};
|
|
19
|
+
}): IMatchStage[];
|
|
20
|
+
findAccountingReports(params: factory.report.accountingReport.ISearchConditions & {
|
|
21
|
+
seller?: {
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
24
|
+
limit: number;
|
|
25
|
+
page: number;
|
|
26
|
+
}): Promise<IReportAsFindResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* 注文番号で削除する
|
|
29
|
+
*/
|
|
30
|
+
deleteByOrderNumber(params: {
|
|
31
|
+
mainEntity: {
|
|
32
|
+
orderNumber: string;
|
|
33
|
+
};
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
unsetUnnecessaryFields(params: {
|
|
36
|
+
filter: any;
|
|
37
|
+
$unset: any;
|
|
38
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminAccountingReportRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
6
|
+
/**
|
|
7
|
+
* 経理レポート管理リポジトリ
|
|
8
|
+
*/
|
|
9
|
+
class AdminAccountingReportRepo {
|
|
10
|
+
accountingReportModel;
|
|
11
|
+
constructor(connection) {
|
|
12
|
+
this.accountingReportModel = connection.model(accountingReport_1.modelName, (0, accountingReport_1.createSchema)());
|
|
13
|
+
}
|
|
14
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
15
|
+
const matchStages = [];
|
|
16
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
17
|
+
if (typeof projectIdEq === 'string') {
|
|
18
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
19
|
+
}
|
|
20
|
+
// req.seller.idを考慮(2023-07-21~)
|
|
21
|
+
if (typeof params.seller?.id === 'string') {
|
|
22
|
+
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: params.seller.id } } });
|
|
23
|
+
}
|
|
24
|
+
const orderNumberEq = params.order?.orderNumber?.$eq;
|
|
25
|
+
if (typeof orderNumberEq === 'string') {
|
|
26
|
+
matchStages.push({ $match: { 'mainEntity.orderNumber': { $eq: orderNumberEq } } });
|
|
27
|
+
}
|
|
28
|
+
const sellerIdEq = params.order?.seller?.id?.$eq;
|
|
29
|
+
if (typeof sellerIdEq === 'string') {
|
|
30
|
+
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: sellerIdEq } } });
|
|
31
|
+
}
|
|
32
|
+
const paymentMethodIdEq = params.order?.paymentMethods?.paymentMethodId?.$eq;
|
|
33
|
+
if (typeof paymentMethodIdEq === 'string') {
|
|
34
|
+
matchStages.push({
|
|
35
|
+
$match: { 'mainEntity.paymentMethods.paymentMethodId': { $exists: true, $eq: paymentMethodIdEq } }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const orderDateGte = params.order?.orderDate?.$gte;
|
|
39
|
+
if (orderDateGte instanceof Date) {
|
|
40
|
+
matchStages.push({
|
|
41
|
+
$match: { 'mainEntity.orderDate': { $gte: orderDateGte } }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const orderDateLte = params.order?.orderDate?.$lte;
|
|
45
|
+
if (orderDateLte instanceof Date) {
|
|
46
|
+
matchStages.push({
|
|
47
|
+
$match: { 'mainEntity.orderDate': { $lte: orderDateLte } }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return matchStages;
|
|
51
|
+
}
|
|
52
|
+
async findAccountingReports(params) {
|
|
53
|
+
const { limit, page } = params;
|
|
54
|
+
const matchStages = AdminAccountingReportRepo.CREATE_MONGO_CONDITIONS(params);
|
|
55
|
+
const aggregate = this.accountingReportModel.aggregate([
|
|
56
|
+
...matchStages,
|
|
57
|
+
// pipelineの順序に注意
|
|
58
|
+
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
59
|
+
{ $sort: { 'mainEntity.orderDate': factory_1.factory.sortType.Descending } },
|
|
60
|
+
{ $unwind: '$hasPart' },
|
|
61
|
+
// hasPart内に対する検索条件は存在しないため、unwind後のmatchは不要
|
|
62
|
+
{
|
|
63
|
+
$project: {
|
|
64
|
+
_id: 0,
|
|
65
|
+
mainEntity: '$hasPart.mainEntity',
|
|
66
|
+
isPartOf: {
|
|
67
|
+
mainEntity: '$mainEntity'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
return aggregate
|
|
73
|
+
.skip(limit * (page - 1))
|
|
74
|
+
.limit(limit)
|
|
75
|
+
.exec();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 注文番号で削除する
|
|
79
|
+
*/
|
|
80
|
+
async deleteByOrderNumber(params) {
|
|
81
|
+
await this.accountingReportModel.deleteOne({ 'mainEntity.orderNumber': params.mainEntity.orderNumber })
|
|
82
|
+
.exec();
|
|
83
|
+
}
|
|
84
|
+
async unsetUnnecessaryFields(params) {
|
|
85
|
+
return this.accountingReportModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
86
|
+
.exec();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.AdminAccountingReportRepo = AdminAccountingReportRepo;
|