@chevre/domain 22.2.0 → 22.3.0-alpha.1
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/migrateCustomerAdditionalProperties.ts +114 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +2 -2
- package/lib/chevre/repo/customer.d.ts +4 -0
- package/lib/chevre/repo/customer.js +16 -22
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/customer.js +21 -23
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +4 -1
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.js +38 -17
- package/package.json +3 -3
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
|
|
15
|
+
const customerRepo = await chevre.repository.Customer.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = customerRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
// typeOf: { $eq: chevre.factory.placeType.ScreeningRoom }
|
|
20
|
+
// 'project.id': { $eq: project.id },
|
|
21
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// paymentMethods: 1,
|
|
25
|
+
// project: 1,
|
|
26
|
+
// orderDate: 1
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
console.log('docs found');
|
|
30
|
+
|
|
31
|
+
const additionalPropertyNames: string[] = [];
|
|
32
|
+
const projectIds: string[] = [];
|
|
33
|
+
const unexpextedprojectIds: string[] = [];
|
|
34
|
+
let checked: number = 0;
|
|
35
|
+
let created: number = 0;
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const customer: chevre.factory.customer.ICustomer = doc.toObject();
|
|
41
|
+
|
|
42
|
+
const additionalPropertyNamesOnResource = (Array.isArray(customer.additionalProperty))
|
|
43
|
+
? customer.additionalProperty?.map((p) => p.name)
|
|
44
|
+
: [];
|
|
45
|
+
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
46
|
+
console.log(
|
|
47
|
+
additionalPropertyNamesOnResource.join(','),
|
|
48
|
+
additionalPropertyNamesOnResource.length,
|
|
49
|
+
'additionalPropertyNamesOnResource found',
|
|
50
|
+
customer.project.id,
|
|
51
|
+
customer.branchCode
|
|
52
|
+
);
|
|
53
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
54
|
+
projectIds.push(customer.project.id);
|
|
55
|
+
additionalPropertyNamesOnResource.forEach((name) => {
|
|
56
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
57
|
+
unexpextedprojectIds.push(customer.project.id);
|
|
58
|
+
}
|
|
59
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
60
|
+
if (name.length < 5) {
|
|
61
|
+
unexpextedprojectIds.push(customer.project.id);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
|
|
66
|
+
checked += 1;
|
|
67
|
+
const existingAdditionalProperties = await additionalPropertyRepo.search({
|
|
68
|
+
limit: 1,
|
|
69
|
+
project: { id: { $eq: customer.project.id } },
|
|
70
|
+
codeValue: { $eq: additionalPropertyNameOnResource },
|
|
71
|
+
inCodeSet: { identifier: { $eq: customer.typeOf } }
|
|
72
|
+
});
|
|
73
|
+
if (existingAdditionalProperties.length === 0) {
|
|
74
|
+
const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
|
|
75
|
+
project: customer.project,
|
|
76
|
+
// id?: string;
|
|
77
|
+
typeOf: 'CategoryCode',
|
|
78
|
+
codeValue: additionalPropertyNameOnResource,
|
|
79
|
+
inCodeSet: {
|
|
80
|
+
typeOf: 'CategoryCodeSet',
|
|
81
|
+
identifier: customer.typeOf
|
|
82
|
+
},
|
|
83
|
+
name: { ja: additionalPropertyNameOnResource }
|
|
84
|
+
};
|
|
85
|
+
await additionalPropertyRepo.save({ attributes: additionalProperty });
|
|
86
|
+
created += 1;
|
|
87
|
+
console.log(
|
|
88
|
+
'additionalProerty created',
|
|
89
|
+
additionalPropertyNameOnResource,
|
|
90
|
+
customer.project.id,
|
|
91
|
+
customer.branchCode
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
console.log(
|
|
95
|
+
'additionalProerty existed',
|
|
96
|
+
additionalPropertyNameOnResource,
|
|
97
|
+
customer.project.id,
|
|
98
|
+
customer.branchCode
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
console.log(i, 'places checked');
|
|
105
|
+
console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
|
|
106
|
+
console.log('projectIds:', [...new Set(projectIds)]);
|
|
107
|
+
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
108
|
+
console.log('checked:', checked);
|
|
109
|
+
console.log('created:', created);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
main()
|
|
113
|
+
.then()
|
|
114
|
+
.catch(console.error);
|
|
@@ -6,10 +6,10 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const customerRepo = await chevre.repository.Customer.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
12
|
+
updateResult = await customerRepo.unsetUnnecessaryFields({
|
|
13
13
|
filter: {
|
|
14
14
|
_id: { $exists: true }
|
|
15
15
|
},
|
|
@@ -50,5 +50,9 @@ export declare class CustomerRepo {
|
|
|
50
50
|
}, never>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.customer.ICustomer> & Omit<factory.customer.ICustomer & {
|
|
51
51
|
_id: import("mongoose").Types.ObjectId;
|
|
52
52
|
}, never>>>;
|
|
53
|
+
unsetUnnecessaryFields(params: {
|
|
54
|
+
filter: any;
|
|
55
|
+
$unset: any;
|
|
56
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
53
57
|
}
|
|
54
58
|
export {};
|
|
@@ -32,7 +32,7 @@ class CustomerRepo {
|
|
|
32
32
|
this.customerModel = connection.model(customer_1.modelName, (0, customer_1.createSchema)());
|
|
33
33
|
}
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f;
|
|
36
36
|
const andConditions = [];
|
|
37
37
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
38
|
if (typeof projectIdEq === 'string') {
|
|
@@ -55,29 +55,17 @@ class CustomerRepo {
|
|
|
55
55
|
]
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
+
const additionalPropertyElemMatch = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
|
|
59
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
60
|
+
andConditions.push({
|
|
61
|
+
additionalProperty: {
|
|
62
|
+
$exists: true,
|
|
63
|
+
$elemMatch: additionalPropertyElemMatch
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
58
67
|
return andConditions;
|
|
59
68
|
}
|
|
60
|
-
// public async findById(
|
|
61
|
-
// conditions: {
|
|
62
|
-
// id: string;
|
|
63
|
-
// },
|
|
64
|
-
// projection?: any
|
|
65
|
-
// ): Promise<factory.customer.ICustomer> {
|
|
66
|
-
// const doc = await this.customerModel.findOne(
|
|
67
|
-
// { _id: conditions.id },
|
|
68
|
-
// {
|
|
69
|
-
// __v: 0,
|
|
70
|
-
// createdAt: 0,
|
|
71
|
-
// updatedAt: 0,
|
|
72
|
-
// ...projection
|
|
73
|
-
// }
|
|
74
|
-
// )
|
|
75
|
-
// .exec();
|
|
76
|
-
// if (doc === null) {
|
|
77
|
-
// throw new factory.errors.NotFound(this.customerModel.modelName);
|
|
78
|
-
// }
|
|
79
|
-
// return doc.toObject();
|
|
80
|
-
// }
|
|
81
69
|
save(params) {
|
|
82
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
71
|
let customer;
|
|
@@ -132,5 +120,11 @@ class CustomerRepo {
|
|
|
132
120
|
.sort({ branchCode: factory.sortType.Ascending })
|
|
133
121
|
.cursor();
|
|
134
122
|
}
|
|
123
|
+
unsetUnnecessaryFields(params) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
return this.customerModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
126
|
+
.exec();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
135
129
|
}
|
|
136
130
|
exports.CustomerRepo = CustomerRepo;
|
|
@@ -5,6 +5,6 @@ type IModel = Model<IDocType>;
|
|
|
5
5
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
6
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
7
|
declare const modelName = "Customer";
|
|
8
|
-
declare function createSchema(): ISchema;
|
|
9
8
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
10
|
export { createSchema, IModel, indexes, modelName };
|
|
@@ -19,6 +19,9 @@ const schemaDefinition = {
|
|
|
19
19
|
},
|
|
20
20
|
url: String,
|
|
21
21
|
telephone: String
|
|
22
|
+
// createdAt: SchemaTypes.Mixed,
|
|
23
|
+
// updatedAt: SchemaTypes.Mixed,
|
|
24
|
+
// __v: SchemaTypes.Mixed
|
|
22
25
|
};
|
|
23
26
|
const schemaOptions = {
|
|
24
27
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -29,10 +32,8 @@ const schemaOptions = {
|
|
|
29
32
|
writeConcern: writeConcern_1.writeConcern,
|
|
30
33
|
strict: true,
|
|
31
34
|
strictQuery: false,
|
|
32
|
-
timestamps:
|
|
33
|
-
|
|
34
|
-
updatedAt: 'updatedAt'
|
|
35
|
-
},
|
|
35
|
+
timestamps: false,
|
|
36
|
+
versionKey: false,
|
|
36
37
|
toJSON: {
|
|
37
38
|
getters: false,
|
|
38
39
|
virtuals: false,
|
|
@@ -46,26 +47,7 @@ const schemaOptions = {
|
|
|
46
47
|
versionKey: false
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
|
-
/**
|
|
50
|
-
* 顧客スキーマ
|
|
51
|
-
*/
|
|
52
|
-
let schema;
|
|
53
|
-
function createSchema() {
|
|
54
|
-
if (schema === undefined) {
|
|
55
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
56
|
-
}
|
|
57
|
-
return schema;
|
|
58
|
-
}
|
|
59
|
-
exports.createSchema = createSchema;
|
|
60
50
|
const indexes = [
|
|
61
|
-
[
|
|
62
|
-
{ createdAt: 1 },
|
|
63
|
-
{ name: 'searchByCreatedAt' }
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
{ updatedAt: 1 },
|
|
67
|
-
{ name: 'searchByUpdatedAt' }
|
|
68
|
-
],
|
|
69
51
|
[
|
|
70
52
|
{ branchCode: 1 },
|
|
71
53
|
{ name: 'searchByBranchCode' }
|
|
@@ -96,3 +78,19 @@ const indexes = [
|
|
|
96
78
|
]
|
|
97
79
|
];
|
|
98
80
|
exports.indexes = indexes;
|
|
81
|
+
/**
|
|
82
|
+
* 顧客スキーマ
|
|
83
|
+
*/
|
|
84
|
+
let schema;
|
|
85
|
+
function createSchema() {
|
|
86
|
+
if (schema === undefined) {
|
|
87
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
88
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
89
|
+
indexes.forEach((indexParams) => {
|
|
90
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return schema;
|
|
95
|
+
}
|
|
96
|
+
exports.createSchema = createSchema;
|
|
@@ -186,6 +186,9 @@ function availableSalesTicket2offerWithDetails(params) {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
const priceSpecification = Object.assign({}, (typeof (appliesToSurfrock === null || appliesToSurfrock === void 0 ? void 0 : appliesToSurfrock.identifier) === 'string') ? { appliesToSurfrock } : undefined);
|
|
189
|
+
const disPrice = (typeof availableSalesTicket.disPrice === 'number' && availableSalesTicket.disPrice > 0)
|
|
190
|
+
? availableSalesTicket.disPrice
|
|
191
|
+
: 0; // support case of coupon(2024-08-31~)
|
|
189
192
|
const ticketInfo = {
|
|
190
193
|
ticketCode: availableSalesTicket.ticketCode,
|
|
191
194
|
ticketName: availableSalesTicket.ticketName,
|
|
@@ -193,7 +196,7 @@ function availableSalesTicket2offerWithDetails(params) {
|
|
|
193
196
|
ticketNameKana: availableSalesTicket.ticketNameKana,
|
|
194
197
|
stdPrice: availableSalesTicket.stdPrice,
|
|
195
198
|
addPrice: availableSalesTicket.addPrice,
|
|
196
|
-
disPrice
|
|
199
|
+
disPrice,
|
|
197
200
|
// salePrice: salePrice,
|
|
198
201
|
salesTicketSalePrice: Number(availableSalesTicket.salePrice),
|
|
199
202
|
spseatAdd1: offer.ticketInfo.spseatAdd1,
|
|
@@ -98,12 +98,44 @@ function createPriceComponent(params) {
|
|
|
98
98
|
eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
const { disPrice, limitCount, stdPrice } = ticketInfo;
|
|
102
|
+
if (typeof stdPrice !== 'number') {
|
|
103
|
+
throw new factory.errors.Argument('ticketInfo.stdPrice', 'must be number');
|
|
104
|
+
}
|
|
105
|
+
const accountsReceivable = (ticketInfo.mvtkAppPrice > 0) ? ticketInfo.mvtkAppPrice : stdPrice;
|
|
106
|
+
// const maxPrice: number = stdPrice;
|
|
107
|
+
let price = stdPrice;
|
|
108
|
+
// support disPrice(2024-09-02~)
|
|
109
|
+
if (typeof disPrice === 'number' && disPrice > 0) {
|
|
110
|
+
price -= disPrice;
|
|
111
|
+
}
|
|
112
|
+
let referenceQuantity = {
|
|
113
|
+
typeOf: 'QuantitativeValue',
|
|
114
|
+
unitCode: factory.unitCode.C62,
|
|
115
|
+
value: 1
|
|
116
|
+
};
|
|
117
|
+
switch (ticketInfo.limitUnit) {
|
|
118
|
+
case '001':
|
|
119
|
+
referenceQuantity = {
|
|
120
|
+
typeOf: 'QuantitativeValue',
|
|
121
|
+
unitCode: factory.unitCode.C62,
|
|
122
|
+
value: Number(limitCount)
|
|
123
|
+
};
|
|
124
|
+
price = Number(limitCount) * price;
|
|
125
|
+
break;
|
|
126
|
+
case '002':
|
|
127
|
+
referenceQuantity = {
|
|
128
|
+
typeOf: 'QuantitativeValue',
|
|
129
|
+
unitCode: factory.unitCode.C62,
|
|
130
|
+
value: 1,
|
|
131
|
+
minValue: Number(limitCount)
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
// no op
|
|
136
|
+
// referenceQuantity.value = 1;
|
|
137
|
+
}
|
|
138
|
+
const unitPriceSpec = Object.assign({ typeOf: factory.priceSpecificationType.UnitPriceSpecification, name: { ja: ticketInfo.ticketName, en: ticketInfo.ticketNameEng }, price, priceCurrency: factory.priceCurrency.JPY, referenceQuantity, valueAddedTaxIncluded: true, accounting: {
|
|
107
139
|
typeOf: 'Accounting',
|
|
108
140
|
accountsReceivable
|
|
109
141
|
} }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
|
|
@@ -114,17 +146,6 @@ function createPriceComponent(params) {
|
|
|
114
146
|
]
|
|
115
147
|
}
|
|
116
148
|
: undefined);
|
|
117
|
-
switch (ticketInfo.limitUnit) {
|
|
118
|
-
case '001':
|
|
119
|
-
unitPriceSpec.referenceQuantity.value = Number(ticketInfo.limitCount);
|
|
120
|
-
unitPriceSpec.price = Number(ticketInfo.limitCount) * Number(ticketInfo.stdPrice);
|
|
121
|
-
break;
|
|
122
|
-
case '002':
|
|
123
|
-
unitPriceSpec.referenceQuantity.minValue = Number(ticketInfo.limitCount);
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
unitPriceSpec.referenceQuantity.value = 1;
|
|
127
|
-
}
|
|
128
149
|
// 区分加算料金
|
|
129
150
|
const categoryCodeChargeSpecs = [];
|
|
130
151
|
// movieTicketTypeChargePriceSpecにaddPriceが含まれる場合は除く
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "10.
|
|
12
|
+
"@chevre/factory": "4.383.0-alpha.1",
|
|
13
|
+
"@cinerino/sdk": "10.9.0-alpha.1",
|
|
14
14
|
"@motionpicture/coa-service": "9.5.0-alpha.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "22.
|
|
113
|
+
"version": "22.3.0-alpha.1"
|
|
114
114
|
}
|