@chevre/domain 20.4.0-alpha.9 → 20.5.0
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/aggregateEventReservation.ts +2 -1
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -4
- package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
- package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
- package/example/src/chevre/reIndex.ts +25 -0
- package/example/src/chevre/searchEventTicketOffers.ts +7 -4
- package/example/src/chevre/searchOfferCatalogs.ts +14 -16
- package/example/src/chevre/searchOffersByCatalog.ts +2 -1
- package/example/src/chevre/searchProductOffers.ts +38 -0
- package/example/src/chevre/searchTasks.ts +22 -0
- package/example/src/chevre/sendEmailMessage.ts +81 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +6 -11
- package/lib/chevre/emailMessageBuilder.js +72 -30
- package/lib/chevre/errorHandler.js +1 -0
- package/lib/chevre/repo/accountTransaction.d.ts +0 -5
- package/lib/chevre/repo/accountTransaction.js +44 -38
- package/lib/chevre/repo/code.d.ts +0 -7
- package/lib/chevre/repo/code.js +0 -17
- package/lib/chevre/repo/event.d.ts +5 -4
- package/lib/chevre/repo/event.js +8 -17
- package/lib/chevre/repo/mongoose/model/accountTransaction.js +0 -5
- package/lib/chevre/repo/mongoose/model/member.js +5 -2
- package/lib/chevre/repo/mongoose/model/offer.js +19 -9
- package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
- package/lib/chevre/repo/mongoose/model/product.js +15 -2
- package/lib/chevre/repo/offer.d.ts +17 -2
- package/lib/chevre/repo/offer.js +77 -44
- package/lib/chevre/repo/offerCatalog.d.ts +3 -5
- package/lib/chevre/repo/offerCatalog.js +78 -37
- package/lib/chevre/repo/priceSpecification.d.ts +11 -0
- package/lib/chevre/repo/priceSpecification.js +44 -66
- package/lib/chevre/repo/task.d.ts +8 -0
- package/lib/chevre/repo/task.js +21 -9
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +93 -96
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -3
- package/lib/chevre/service/assetTransaction/pay.js +2 -3
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService/factory.js +6 -3
- package/lib/chevre/service/assetTransaction/registerService.js +3 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +0 -7
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.js +0 -1
- package/lib/chevre/service/assetTransaction/reserve.js +47 -17
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +1 -38
- package/lib/chevre/service/event.js +20 -3
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +7 -8
- package/lib/chevre/service/notification.js +18 -7
- package/lib/chevre/service/offer/event/authorize.js +5 -5
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +222 -346
- package/lib/chevre/service/offer/factory.d.ts +8 -3
- package/lib/chevre/service/offer/factory.js +44 -26
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +15 -7
- package/lib/chevre/service/offer/product.d.ts +11 -4
- package/lib/chevre/service/offer/product.js +59 -50
- package/lib/chevre/service/payment/any/factory.js +30 -21
- package/lib/chevre/service/payment/any.js +11 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +22 -0
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +183 -0
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +13 -0
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +45 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +15 -0
- package/lib/chevre/service/{assetTransaction/pay → payment}/movieTicket/validation.js +8 -7
- package/lib/chevre/service/payment/movieTicket.d.ts +10 -22
- package/lib/chevre/service/payment/movieTicket.js +19 -219
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
- package/lib/chevre/service/transaction/orderProgramMembership.js +5 -6
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +7 -1
- package/package.json +3 -3
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.d.ts +0 -14
- package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
- package/lib/chevre/service/task/deleteAuthorization.js +0 -29
|
@@ -16,11 +16,12 @@ async function main() {
|
|
|
16
16
|
|
|
17
17
|
// const now = new Date();
|
|
18
18
|
await chevre.service.aggregation.event.aggregateScreeningEvent({
|
|
19
|
-
id:
|
|
19
|
+
id: String(process.env.EVENT_ID)
|
|
20
20
|
})({
|
|
21
21
|
event: new chevre.repository.Event(mongoose.connection),
|
|
22
22
|
eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
|
|
23
23
|
offer: new chevre.repository.Offer(mongoose.connection),
|
|
24
|
+
offerCatalog: new chevre.repository.OfferCatalog(mongoose.connection),
|
|
24
25
|
offerRateLimit: new chevre.repository.rateLimit.Offer(client),
|
|
25
26
|
place: new chevre.repository.Place(mongoose.connection),
|
|
26
27
|
product: new chevre.repository.Product(mongoose.connection),
|
|
@@ -175,10 +175,6 @@ async function main() {
|
|
|
175
175
|
typeOf: 'CategoryCodeSet',
|
|
176
176
|
identifier: chevre.factory.categoryCode.CategorySetIdentifier.ServiceType
|
|
177
177
|
},
|
|
178
|
-
project: {
|
|
179
|
-
typeOf: chevre.factory.organizationType.Project,
|
|
180
|
-
id: 'cinerino'
|
|
181
|
-
},
|
|
182
178
|
typeOf: 'CategoryCode'
|
|
183
179
|
}
|
|
184
180
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: process.env.PROJECT_ID };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
|
|
14
|
+
project: { id: project.id }
|
|
15
|
+
});
|
|
16
|
+
console.log('deleted', result);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
main()
|
|
20
|
+
.then()
|
|
21
|
+
.catch(console.error);
|
|
@@ -8,9 +8,11 @@ import { chevre } from '../../../lib/index';
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
12
12
|
|
|
13
|
-
const result = await
|
|
13
|
+
const result = await taskRepo.deleteByName({
|
|
14
|
+
name: <any>'deleteAuthorization'
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
console.log('deleted', result);
|
|
16
18
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
10
|
+
const result = await priceSpecificationRepo.reIndex();
|
|
11
|
+
console.log(result);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
main()
|
|
15
|
+
.then()
|
|
16
|
+
.catch(console.error);
|
|
17
|
+
// setInterval(
|
|
18
|
+
// () => {
|
|
19
|
+
// main()
|
|
20
|
+
// .then()
|
|
21
|
+
// .catch(console.error);
|
|
22
|
+
// },
|
|
23
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
// 60000
|
|
25
|
+
// );
|
|
@@ -22,11 +22,13 @@ async function main() {
|
|
|
22
22
|
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
23
23
|
|
|
24
24
|
const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
|
|
25
|
-
event: { id: '
|
|
25
|
+
event: { id: 'ale6qiedq' },
|
|
26
26
|
onlyValid: true,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
validateOfferRateLimit: true,
|
|
28
|
+
addSortIndex: true,
|
|
29
|
+
limit: 100,
|
|
30
|
+
page: 1,
|
|
31
|
+
searchAddOns: true
|
|
30
32
|
// ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
|
|
31
33
|
})({
|
|
32
34
|
event: eventRepo,
|
|
@@ -35,6 +37,7 @@ async function main() {
|
|
|
35
37
|
priceSpecification: priceSpecificationRepo,
|
|
36
38
|
product: productRepo
|
|
37
39
|
});
|
|
40
|
+
console.log(ticketOffers.map((o) => o.sortIndex));
|
|
38
41
|
console.log(ticketOffers.length);
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
// import * as redis from 'redis';
|
|
3
2
|
import * as mongoose from 'mongoose';
|
|
4
3
|
|
|
5
4
|
import { chevre } from '../../../lib/index';
|
|
6
5
|
|
|
6
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
|
|
7
8
|
async function main() {
|
|
8
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const catalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
|
|
24
|
-
});
|
|
25
|
-
console.log(catalogs);
|
|
13
|
+
console.log('searching...');
|
|
14
|
+
const catalogs = await catalogRepo.search(
|
|
15
|
+
{
|
|
16
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
17
|
+
identifier: { $eq: '0001' },
|
|
18
|
+
sort: { identifier: chevre.factory.sortType.Descending },
|
|
19
|
+
limit: 2,
|
|
20
|
+
page: 1
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
console.log('catalogs found', catalogs.map((catalog) => `${catalog.identifier} ${catalog.numberOfItems}`));
|
|
26
24
|
console.log(catalogs.length);
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -9,13 +9,14 @@ async function main() {
|
|
|
9
9
|
|
|
10
10
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
11
|
|
|
12
|
-
const offers = await offerRepo.findOffersByOfferCatalogId({
|
|
12
|
+
const { offers } = await offerRepo.findOffersByOfferCatalogId({
|
|
13
13
|
ids: ['al96nqj7z', 'xxx', '1001'],
|
|
14
14
|
// ids: ['xx', 'xxx'],
|
|
15
15
|
offerCatalog: {
|
|
16
16
|
id: '0001'
|
|
17
17
|
// id: 'xxx'
|
|
18
18
|
},
|
|
19
|
+
excludeAppliesToMovieTicket: false,
|
|
19
20
|
sort: true
|
|
20
21
|
});
|
|
21
22
|
console.log(offers.map((o) => o.id));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
12
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const { offers } = await chevre.service.offer.product.search({
|
|
15
|
+
ids: ['7k7bbepxp', 'yyyyyy'],
|
|
16
|
+
project: { id: String(PROJECT_ID) },
|
|
17
|
+
itemOffered: { id: '62b90fef5b3eb4000b75150f' },
|
|
18
|
+
// seller?: {
|
|
19
|
+
// id: string;
|
|
20
|
+
// },
|
|
21
|
+
// availableAt?: {
|
|
22
|
+
// id: string;
|
|
23
|
+
// },
|
|
24
|
+
onlyValid: true,
|
|
25
|
+
// limit?: number,
|
|
26
|
+
// page?: number,
|
|
27
|
+
addSortIndex: false
|
|
28
|
+
})({
|
|
29
|
+
offer: offerRepo,
|
|
30
|
+
product: productRepo
|
|
31
|
+
});
|
|
32
|
+
console.log(offers.map((o) => `${o.sortIndex} ${o.id}`));
|
|
33
|
+
console.log(offers.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then(console.log)
|
|
38
|
+
.catch(console.error);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const tasks = await taskRepo.search({
|
|
12
|
+
limit: 100,
|
|
13
|
+
page: 1,
|
|
14
|
+
id: { $eq: '63b7a54d8ba861284895937f' }
|
|
15
|
+
});
|
|
16
|
+
console.log(tasks);
|
|
17
|
+
console.log(tasks.length);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main()
|
|
21
|
+
.then(console.log)
|
|
22
|
+
.catch(console.error);
|
|
@@ -0,0 +1,81 @@
|
|
|
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 SENDER_EMAIL = String(process.env.SENDER_EMAIL);
|
|
9
|
+
const RECIPIENT_EMAIL = String(process.env.RECIPIENT_EMAIL);
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
15
|
+
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
await chevre.service.notification.sendEmailMessage({
|
|
18
|
+
project: {
|
|
19
|
+
typeOf: chevre.factory.organizationType.Project,
|
|
20
|
+
id: project.id
|
|
21
|
+
},
|
|
22
|
+
typeOf: chevre.factory.actionType.SendAction,
|
|
23
|
+
object: {
|
|
24
|
+
typeOf: chevre.factory.creativeWorkType.EmailMessage,
|
|
25
|
+
identifier: 'SendOrder-CIN1-3970498-5700993',
|
|
26
|
+
name: 'SendOrder-CIN1-3970498-5700993',
|
|
27
|
+
sender: {
|
|
28
|
+
typeOf: 'Corporation',
|
|
29
|
+
name: 'sample sender ',
|
|
30
|
+
email: SENDER_EMAIL
|
|
31
|
+
},
|
|
32
|
+
toRecipient: [
|
|
33
|
+
{
|
|
34
|
+
typeOf: 'WebApplication',
|
|
35
|
+
name: 'sample recipient 2',
|
|
36
|
+
email: RECIPIENT_EMAIL
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
about: {
|
|
40
|
+
typeOf: 'Thing',
|
|
41
|
+
identifier: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent,
|
|
42
|
+
name: 'sample about'
|
|
43
|
+
},
|
|
44
|
+
text: 'sample text'
|
|
45
|
+
},
|
|
46
|
+
agent: {
|
|
47
|
+
typeOf: chevre.factory.organizationType.Project,
|
|
48
|
+
id: project.id
|
|
49
|
+
},
|
|
50
|
+
recipient: {
|
|
51
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
52
|
+
id: 'xxxx',
|
|
53
|
+
name: 'sample recipient'
|
|
54
|
+
},
|
|
55
|
+
purpose: {
|
|
56
|
+
typeOf: chevre.factory.order.OrderType.Order,
|
|
57
|
+
seller: {
|
|
58
|
+
id: '59d20831e53ebc2b4e774466',
|
|
59
|
+
name: 'seller name',
|
|
60
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
61
|
+
},
|
|
62
|
+
customer: {
|
|
63
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
64
|
+
id: 'xxxx',
|
|
65
|
+
name: '****'
|
|
66
|
+
},
|
|
67
|
+
orderNumber: 'CIN1-3970498-5700993',
|
|
68
|
+
price: 0,
|
|
69
|
+
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
70
|
+
orderDate: moment('2023-03-06T01:02:58.866Z')
|
|
71
|
+
.toDate()
|
|
72
|
+
}
|
|
73
|
+
})({
|
|
74
|
+
action: actionRepo,
|
|
75
|
+
project: projectRepo
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
main()
|
|
80
|
+
.then(console.log)
|
|
81
|
+
.catch(console.error);
|
|
@@ -6,19 +6,14 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
|
|
9
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
10
|
|
|
12
|
-
let updateResult
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
let updateResult: any;
|
|
12
|
+
updateResult = await offerRepo.unsetUnnecessaryFields({
|
|
13
|
+
filter: { 'category.project': { $exists: true } },
|
|
14
|
+
$unset: { 'category.project': 1 }
|
|
15
15
|
});
|
|
16
|
-
console.log('
|
|
17
|
-
updateResult = await permitRepo.unsetUnnecessaryFields({
|
|
18
|
-
filter: { 'paymentAccount.accountType': { $exists: true } },
|
|
19
|
-
$unset: { 'paymentAccount.accountType': 1 }
|
|
20
|
-
});
|
|
21
|
-
console.log('permits unset', updateResult);
|
|
16
|
+
console.log('offers unset', updateResult);
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
main()
|
|
@@ -124,7 +124,7 @@ function createEmailMessageSender(params) {
|
|
|
124
124
|
* 注文配送メッセージを作成する
|
|
125
125
|
*/
|
|
126
126
|
function createSendOrderMessage(params) {
|
|
127
|
-
var _a
|
|
127
|
+
var _a;
|
|
128
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
129
|
const emailMessageText = yield createEmailMessageText({
|
|
130
130
|
order: params.order,
|
|
@@ -142,16 +142,30 @@ function createSendOrderMessage(params) {
|
|
|
142
142
|
if (defaultToRecipientEmail === undefined) {
|
|
143
143
|
throw new factory.errors.Argument('order', 'order.customer.email undefined');
|
|
144
144
|
}
|
|
145
|
+
const defaultRecipientName = `${params.order.customer.familyName} ${params.order.customer.givenName}`;
|
|
145
146
|
const sender = createEmailMessageSender(params);
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
const toRecipientCustomization = (_a = params.email) === null || _a === void 0 ? void 0 : _a.toRecipient;
|
|
148
|
+
const toRecipient = (Array.isArray(toRecipientCustomization))
|
|
149
|
+
? toRecipientCustomization.map((customizedRecipient) => {
|
|
150
|
+
return {
|
|
151
|
+
typeOf: params.order.customer.typeOf,
|
|
152
|
+
name: (typeof customizedRecipient.name === 'string')
|
|
153
|
+
? customizedRecipient.name
|
|
154
|
+
: defaultRecipientName,
|
|
155
|
+
email: (typeof customizedRecipient.email === 'string')
|
|
156
|
+
? customizedRecipient.email
|
|
157
|
+
: defaultToRecipientEmail
|
|
158
|
+
};
|
|
159
|
+
})
|
|
160
|
+
: [{
|
|
161
|
+
typeOf: params.order.customer.typeOf,
|
|
162
|
+
name: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.name) === 'string')
|
|
163
|
+
? toRecipientCustomization.name
|
|
164
|
+
: defaultRecipientName,
|
|
165
|
+
email: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.email) === 'string')
|
|
166
|
+
? toRecipientCustomization.email
|
|
167
|
+
: defaultToRecipientEmail
|
|
168
|
+
}];
|
|
155
169
|
return {
|
|
156
170
|
typeOf: factory.creativeWorkType.EmailMessage,
|
|
157
171
|
identifier: `SendOrder-${params.order.orderNumber}`,
|
|
@@ -168,7 +182,7 @@ exports.createSendOrderMessage = createSendOrderMessage;
|
|
|
168
182
|
* 注文返品メッセージを作成する
|
|
169
183
|
*/
|
|
170
184
|
function createReturnOrderMessage(params) {
|
|
171
|
-
var _a
|
|
185
|
+
var _a;
|
|
172
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
187
|
const emailMessageText = yield createEmailMessageText({
|
|
174
188
|
order: params.order,
|
|
@@ -186,16 +200,30 @@ function createReturnOrderMessage(params) {
|
|
|
186
200
|
if (defaultToRecipientEmail === undefined) {
|
|
187
201
|
throw new factory.errors.Argument('order', 'order.customer.email undefined');
|
|
188
202
|
}
|
|
203
|
+
const defaultRecipientName = `${params.order.customer.familyName} ${params.order.customer.givenName}`;
|
|
189
204
|
const sender = createEmailMessageSender(params);
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
const toRecipientCustomization = (_a = params.email) === null || _a === void 0 ? void 0 : _a.toRecipient;
|
|
206
|
+
const toRecipient = (Array.isArray(toRecipientCustomization))
|
|
207
|
+
? toRecipientCustomization.map((customizedRecipient) => {
|
|
208
|
+
return {
|
|
209
|
+
typeOf: params.order.customer.typeOf,
|
|
210
|
+
name: (typeof customizedRecipient.name === 'string')
|
|
211
|
+
? customizedRecipient.name
|
|
212
|
+
: defaultRecipientName,
|
|
213
|
+
email: (typeof customizedRecipient.email === 'string')
|
|
214
|
+
? customizedRecipient.email
|
|
215
|
+
: defaultToRecipientEmail
|
|
216
|
+
};
|
|
217
|
+
})
|
|
218
|
+
: [{
|
|
219
|
+
typeOf: params.order.customer.typeOf,
|
|
220
|
+
name: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.name) === 'string')
|
|
221
|
+
? toRecipientCustomization.name
|
|
222
|
+
: defaultRecipientName,
|
|
223
|
+
email: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.email) === 'string')
|
|
224
|
+
? toRecipientCustomization.email
|
|
225
|
+
: defaultToRecipientEmail
|
|
226
|
+
}];
|
|
199
227
|
return {
|
|
200
228
|
typeOf: factory.creativeWorkType.EmailMessage,
|
|
201
229
|
identifier: `ReturnOrder-${params.order.orderNumber}`,
|
|
@@ -212,7 +240,7 @@ exports.createReturnOrderMessage = createReturnOrderMessage;
|
|
|
212
240
|
* 返金メッセージを作成する
|
|
213
241
|
*/
|
|
214
242
|
function createRefundMessage(params) {
|
|
215
|
-
var _a
|
|
243
|
+
var _a;
|
|
216
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
217
245
|
const emailMessageText = yield createEmailMessageText({
|
|
218
246
|
order: params.order,
|
|
@@ -228,16 +256,30 @@ function createRefundMessage(params) {
|
|
|
228
256
|
if (defaultToRecipientEmail === undefined) {
|
|
229
257
|
throw new factory.errors.Argument('order', 'order.customer.email undefined');
|
|
230
258
|
}
|
|
259
|
+
const defaultRecipientName = `${params.order.customer.familyName} ${params.order.customer.givenName}`;
|
|
231
260
|
const sender = createEmailMessageSender(params);
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
261
|
+
const toRecipientCustomization = (_a = params.email) === null || _a === void 0 ? void 0 : _a.toRecipient;
|
|
262
|
+
const toRecipient = (Array.isArray(toRecipientCustomization))
|
|
263
|
+
? toRecipientCustomization.map((customizedRecipient) => {
|
|
264
|
+
return {
|
|
265
|
+
typeOf: params.order.customer.typeOf,
|
|
266
|
+
name: (typeof customizedRecipient.name === 'string')
|
|
267
|
+
? customizedRecipient.name
|
|
268
|
+
: defaultRecipientName,
|
|
269
|
+
email: (typeof customizedRecipient.email === 'string')
|
|
270
|
+
? customizedRecipient.email
|
|
271
|
+
: defaultToRecipientEmail
|
|
272
|
+
};
|
|
273
|
+
})
|
|
274
|
+
: [{
|
|
275
|
+
typeOf: params.order.customer.typeOf,
|
|
276
|
+
name: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.name) === 'string')
|
|
277
|
+
? toRecipientCustomization.name
|
|
278
|
+
: defaultRecipientName,
|
|
279
|
+
email: (typeof (toRecipientCustomization === null || toRecipientCustomization === void 0 ? void 0 : toRecipientCustomization.email) === 'string')
|
|
280
|
+
? toRecipientCustomization.email
|
|
281
|
+
: defaultToRecipientEmail
|
|
282
|
+
}];
|
|
241
283
|
return {
|
|
242
284
|
typeOf: factory.creativeWorkType.EmailMessage,
|
|
243
285
|
identifier: `RefundOrder-${params.order.orderNumber}`,
|
|
@@ -19,6 +19,7 @@ function handleMongoError(error) {
|
|
|
19
19
|
if (handledError instanceof mongoose_1.mongo.MongoError) {
|
|
20
20
|
switch (handledError.code) {
|
|
21
21
|
case MongoErrorCode.DuplicateKey:
|
|
22
|
+
handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
|
|
22
23
|
// no op
|
|
23
24
|
break;
|
|
24
25
|
case MongoErrorCode.MaxTimeMSExpired:
|
|
@@ -47,18 +47,13 @@ export declare class MongoRepository {
|
|
|
47
47
|
/**
|
|
48
48
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
49
49
|
*/
|
|
50
|
-
startExportTasks<T extends factory.account.transactionType>(status: factory.transactionStatusType): Promise<factory.account.transaction.ITransaction<T> | null>;
|
|
51
50
|
/**
|
|
52
51
|
* タスクエクスポートリトライ
|
|
53
52
|
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
54
53
|
*/
|
|
55
|
-
reexportTasks(params: {
|
|
56
|
-
intervalInMinutes: number;
|
|
57
|
-
}): Promise<void>;
|
|
58
54
|
/**
|
|
59
55
|
* タスクをエクスポート済に変更する
|
|
60
56
|
*/
|
|
61
|
-
setTasksExportedById(transactionId: string): Promise<void>;
|
|
62
57
|
/**
|
|
63
58
|
* 取引を期限切れにする
|
|
64
59
|
*/
|
|
@@ -76,7 +76,7 @@ class MongoRepository {
|
|
|
76
76
|
*/
|
|
77
77
|
start(params) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined
|
|
79
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined }))
|
|
80
80
|
.then((doc) => doc.toObject());
|
|
81
81
|
});
|
|
82
82
|
}
|
|
@@ -94,7 +94,7 @@ class MongoRepository {
|
|
|
94
94
|
$in: [factory.transactionStatusType.InProgress, factory.transactionStatusType.Confirmed]
|
|
95
95
|
}
|
|
96
96
|
}, {
|
|
97
|
-
$setOnInsert: Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: startDate, endDate: undefined
|
|
97
|
+
$setOnInsert: Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: startDate, endDate: undefined })
|
|
98
98
|
}, {
|
|
99
99
|
new: true,
|
|
100
100
|
upsert: true
|
|
@@ -225,50 +225,56 @@ class MongoRepository {
|
|
|
225
225
|
/**
|
|
226
226
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
227
227
|
*/
|
|
228
|
-
startExportTasks(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
// public async startExportTasks<T extends factory.account.transactionType>(
|
|
229
|
+
// status: factory.transactionStatusType
|
|
230
|
+
// ): Promise<factory.account.transaction.ITransaction<T> | null> {
|
|
231
|
+
// return this.transactionModel.findOneAndUpdate(
|
|
232
|
+
// {
|
|
233
|
+
// status: status,
|
|
234
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
235
|
+
// },
|
|
236
|
+
// { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting },
|
|
237
|
+
// { new: true }
|
|
238
|
+
// )
|
|
239
|
+
// .exec()
|
|
240
|
+
// // tslint:disable-next-line:no-null-keyword
|
|
241
|
+
// .then((doc) => (doc === null) ? null : doc.toObject());
|
|
242
|
+
// }
|
|
239
243
|
// tslint:disable-next-line:no-suspicious-comment
|
|
240
244
|
/**
|
|
241
245
|
* タスクエクスポートリトライ
|
|
242
246
|
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
243
247
|
*/
|
|
244
|
-
reexportTasks(params) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
248
|
+
// public async reexportTasks(params: { intervalInMinutes: number }): Promise<void> {
|
|
249
|
+
// await this.transactionModel.updateMany(
|
|
250
|
+
// {
|
|
251
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
252
|
+
// updatedAt: {
|
|
253
|
+
// $lt: moment()
|
|
254
|
+
// .add(-params.intervalInMinutes, 'minutes')
|
|
255
|
+
// .toDate()
|
|
256
|
+
// }
|
|
257
|
+
// },
|
|
258
|
+
// {
|
|
259
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
260
|
+
// }
|
|
261
|
+
// )
|
|
262
|
+
// .exec();
|
|
263
|
+
// }
|
|
259
264
|
/**
|
|
260
265
|
* タスクをエクスポート済に変更する
|
|
261
266
|
*/
|
|
262
|
-
setTasksExportedById(transactionId) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
267
|
+
// public async setTasksExportedById(transactionId: string): Promise<void> {
|
|
268
|
+
// await this.transactionModel.findByIdAndUpdate(
|
|
269
|
+
// transactionId,
|
|
270
|
+
// {
|
|
271
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
272
|
+
// tasksExportedAt: moment()
|
|
273
|
+
// .toDate()
|
|
274
|
+
// }
|
|
275
|
+
// )
|
|
276
|
+
// .exec();
|
|
277
|
+
// }
|
|
272
278
|
/**
|
|
273
279
|
* 取引を期限切れにする
|
|
274
280
|
*/
|
|
@@ -35,13 +35,6 @@ export declare class MongoRepository {
|
|
|
35
35
|
}): Promise<IObject>;
|
|
36
36
|
count(params: factory.authorization.ISearchConditions): Promise<number>;
|
|
37
37
|
search(params: factory.authorization.ISearchConditions): Promise<factory.authorization.IAuthorization[]>;
|
|
38
|
-
deleteByCode(params: {
|
|
39
|
-
code: string;
|
|
40
|
-
}): Promise<{
|
|
41
|
-
n?: number;
|
|
42
|
-
ok?: number;
|
|
43
|
-
deletedCount?: number;
|
|
44
|
-
} | null>;
|
|
45
38
|
/**
|
|
46
39
|
* 有効期限を一定期間過ぎた承認を削除する
|
|
47
40
|
*/
|