@chevre/domain 22.5.0-alpha.12 → 22.5.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/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -30
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +21 -113
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
- package/lib/chevre/service/offer/event/searchOffersByIds.js +26 -20
- package/lib/chevre/service/offer/event.d.ts +2 -1
- package/lib/chevre/service/offer/event.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/task/deletePerson.d.ts +6 -0
- package/lib/chevre/service/task/deletePerson.js +421 -0
- package/lib/chevre/service/task.js +1 -0
- package/package.json +5 -7
|
@@ -55,33 +55,4 @@ declare function searchEventTicketOffers(params: {
|
|
|
55
55
|
ticketOffers: ITicketOfferWithSortIndex[];
|
|
56
56
|
unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
57
57
|
}>;
|
|
58
|
-
|
|
59
|
-
* オファーで利用可能な適用決済カード条件を検索する
|
|
60
|
-
*/
|
|
61
|
-
declare function searchOfferAppliesToMovieTicket(params: {
|
|
62
|
-
event: {
|
|
63
|
-
/**
|
|
64
|
-
* イベントID
|
|
65
|
-
*/
|
|
66
|
-
id: string;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* どのアプリケーションに対して
|
|
70
|
-
*/
|
|
71
|
-
store?: {
|
|
72
|
-
id?: string;
|
|
73
|
-
};
|
|
74
|
-
limit?: number;
|
|
75
|
-
page?: number;
|
|
76
|
-
/**
|
|
77
|
-
* 有効なオファーのみ対象とするか
|
|
78
|
-
*/
|
|
79
|
-
onlyValid?: boolean;
|
|
80
|
-
}): (repos: {
|
|
81
|
-
event: EventRepo;
|
|
82
|
-
eventSeries: EventSeriesRepo;
|
|
83
|
-
offer: OfferRepo;
|
|
84
|
-
offerCatalog: OfferCatalogRepo;
|
|
85
|
-
product: ProductRepo;
|
|
86
|
-
}) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
|
|
87
|
-
export { searchEventTicketOffers, searchOfferAppliesToMovieTicket };
|
|
58
|
+
export { searchEventTicketOffers };
|
|
@@ -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.searchEventTicketOffers = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
14
|
const factory_1 = require("../factory");
|
|
15
15
|
const checkAvailability_1 = require("./checkAvailability");
|
|
@@ -18,8 +18,7 @@ const searchPriceSpecs4event_1 = require("./searchPriceSpecs4event");
|
|
|
18
18
|
function searchTicketOffersByItemOffered(params) {
|
|
19
19
|
// tslint:disable-next-line:max-func-body-length
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f
|
|
22
|
-
let catalogId;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
22
|
const eventService = (yield repos.product.projectFields({
|
|
24
23
|
limit: 1,
|
|
25
24
|
page: 1,
|
|
@@ -30,35 +29,37 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
30
29
|
if (eventService === undefined) {
|
|
31
30
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
32
|
+
const offerCatalogItemsOfProduct = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement;
|
|
33
|
+
/**
|
|
34
|
+
* プロダクトのカタログIDリスト
|
|
35
|
+
*/
|
|
36
|
+
const catalogIdsOfProduct = (Array.isArray(offerCatalogItemsOfProduct)) ? offerCatalogItemsOfProduct.map(({ id }) => id) : [];
|
|
37
|
+
/**
|
|
38
|
+
* プロダクトのひとつめのカタログID
|
|
39
|
+
*/
|
|
40
|
+
const firstCatalogIdOfProduct = catalogIdsOfProduct.at(0);
|
|
41
|
+
if (typeof firstCatalogIdOfProduct !== 'string') {
|
|
39
42
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* カタログID or サブカタログID
|
|
46
|
+
*/
|
|
47
|
+
let subOfferCatalogId = firstCatalogIdOfProduct;
|
|
43
48
|
let isOfferCatalogItem = false;
|
|
44
|
-
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id:
|
|
49
|
+
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: firstCatalogIdOfProduct });
|
|
45
50
|
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
46
51
|
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
47
52
|
isOfferCatalogItem = true;
|
|
48
53
|
}
|
|
49
54
|
if (params.withSortIndex) {
|
|
50
|
-
// addSortIndexの場合はid指定廃止(2023-09-13~)
|
|
51
|
-
// if (Array.isArray(params.ids)) {
|
|
52
|
-
// throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
53
|
-
// }
|
|
54
55
|
// 明示的にカタログ指定可能にする
|
|
55
|
-
if (typeof ((
|
|
56
|
+
if (typeof ((_c = params.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
|
|
56
57
|
if (isOfferCatalogItem) {
|
|
57
58
|
// カタログに含まれるサブカタログか検証(2024-09-30~)
|
|
58
59
|
const offerCatalogIncludingSpecifiedElement = yield repos.offerCatalog.projectFields({
|
|
59
60
|
limit: 1,
|
|
60
61
|
page: 1,
|
|
61
|
-
id: { $in:
|
|
62
|
+
id: { $in: catalogIdsOfProduct },
|
|
62
63
|
itemListElement: { id: { $in: [params.includedInDataCatalog.id] } }
|
|
63
64
|
}, ['id']);
|
|
64
65
|
if (offerCatalogIncludingSpecifiedElement.length === 0) {
|
|
@@ -83,7 +84,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
83
84
|
throw new factory.errors.NotFound('OfferCatalogItem');
|
|
84
85
|
}
|
|
85
86
|
// 強制的にサブカタログの適用決済カード条件に変更
|
|
86
|
-
const appliesToMovieTicketBySubCatalog = (
|
|
87
|
+
const appliesToMovieTicketBySubCatalog = (_e = (_d = offerCatalogItem.relatedOffer) === null || _d === void 0 ? void 0 : _d.priceSpecification) === null || _e === void 0 ? void 0 : _e.appliesToMovieTicket;
|
|
87
88
|
if (Array.isArray(appliesToMovieTicketBySubCatalog)) {
|
|
88
89
|
priceSpecificationCondition = {
|
|
89
90
|
appliesToMovieTicket: {
|
|
@@ -104,7 +105,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
104
105
|
}
|
|
105
106
|
const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
106
107
|
offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
107
|
-
availableAtOrFrom: { id: (
|
|
108
|
+
availableAtOrFrom: { id: (_f = params.store) === null || _f === void 0 ? void 0 : _f.id },
|
|
108
109
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
109
110
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
110
111
|
priceSpecification: priceSpecificationCondition,
|
|
@@ -117,27 +118,6 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
117
118
|
}
|
|
118
119
|
else {
|
|
119
120
|
throw new factory.errors.NotImplemented('only withSortIndex: true implemented'); // ID指定での検索はモジュール分離(2024-09-30~)
|
|
120
|
-
// if (!Array.isArray(params.ids)) {
|
|
121
|
-
// throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
122
|
-
// }
|
|
123
|
-
// let includedInDataCatalogIds: string[] = [subOfferCatalogId];
|
|
124
|
-
// if (isOfferCatalogItem) {
|
|
125
|
-
// // 複数カタログ対応(2023-09-27~)
|
|
126
|
-
// const offerCatalogItems = await repos.offerCatalog.findItemListElementById({
|
|
127
|
-
// id: catalogId,
|
|
128
|
-
// project: { id: eventService.project.id }
|
|
129
|
-
// });
|
|
130
|
-
// includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
|
|
131
|
-
// }
|
|
132
|
-
// const availableOffers = await repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
133
|
-
// ids: params.ids,
|
|
134
|
-
// includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
|
|
135
|
-
// availableAtOrFrom: { id: params.store?.id },
|
|
136
|
-
// unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
137
|
-
// excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
138
|
-
// onlyValid: params.onlyValid === true
|
|
139
|
-
// });
|
|
140
|
-
// return { availableOffers };
|
|
141
121
|
}
|
|
142
122
|
});
|
|
143
123
|
}
|
|
@@ -272,75 +252,3 @@ function searchEventTicketOffers(params) {
|
|
|
272
252
|
});
|
|
273
253
|
}
|
|
274
254
|
exports.searchEventTicketOffers = searchEventTicketOffers;
|
|
275
|
-
/**
|
|
276
|
-
* オファーで利用可能な適用決済カード条件を検索する
|
|
277
|
-
*/
|
|
278
|
-
function searchOfferAppliesToMovieTicket(params) {
|
|
279
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
280
|
-
var _a, _b, _c, _d;
|
|
281
|
-
// optimize(2024-07-18~)
|
|
282
|
-
const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
|
|
283
|
-
// let soundFormatTypes: string[] = [];
|
|
284
|
-
let videoFormatTypes = [];
|
|
285
|
-
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
286
|
-
const superEvents = yield repos.eventSeries.projectEventSeriesFields({
|
|
287
|
-
limit: 1,
|
|
288
|
-
page: 1,
|
|
289
|
-
id: { $eq: event.superEvent.id }
|
|
290
|
-
// typeOf: factory.eventType.ScreeningEventSeries
|
|
291
|
-
}, ['soundFormat', 'videoFormat']);
|
|
292
|
-
const superEvent = superEvents.shift();
|
|
293
|
-
if (superEvent === undefined) {
|
|
294
|
-
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
295
|
-
}
|
|
296
|
-
// soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
297
|
-
videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
298
|
-
}
|
|
299
|
-
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
|
|
300
|
-
// 上映方式がなければMovieTicket除外
|
|
301
|
-
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
302
|
-
// 興行設定があれば興行のカタログを参照する
|
|
303
|
-
const eventOffers = event.offers;
|
|
304
|
-
let catalogId;
|
|
305
|
-
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
306
|
-
const eventService = (yield repos.product.projectFields({
|
|
307
|
-
limit: 1,
|
|
308
|
-
page: 1,
|
|
309
|
-
id: { $eq: eventOffers.itemOffered.id }
|
|
310
|
-
}, ['hasOfferCatalog']
|
|
311
|
-
// []
|
|
312
|
-
)).shift();
|
|
313
|
-
if (eventService === undefined) {
|
|
314
|
-
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
315
|
-
}
|
|
316
|
-
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
317
|
-
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
318
|
-
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
319
|
-
catalogId = firstCatalogIdOfProduct;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
if (typeof catalogId !== 'string') {
|
|
323
|
-
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
324
|
-
}
|
|
325
|
-
// サブカタログIDを決定
|
|
326
|
-
let subOfferCatalogId = catalogId;
|
|
327
|
-
// let isOfferCatalogItem: boolean = false;
|
|
328
|
-
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
|
|
329
|
-
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
330
|
-
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
331
|
-
// isOfferCatalogItem = true;
|
|
332
|
-
}
|
|
333
|
-
return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
|
|
334
|
-
// subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
335
|
-
subOfferCatalog: { id: subOfferCatalogId },
|
|
336
|
-
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
337
|
-
unacceptedPaymentMethod: unacceptedPaymentMethod,
|
|
338
|
-
excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
|
|
339
|
-
onlyValid: params.onlyValid === true,
|
|
340
|
-
// useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
341
|
-
limit: params.limit,
|
|
342
|
-
page: params.page
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EventRepo } from '../../../repo/event';
|
|
2
|
+
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
3
|
+
import type { OfferRepo } from '../../../repo/offer';
|
|
4
|
+
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
5
|
+
import type { ProductRepo } from '../../../repo/product';
|
|
6
|
+
import * as factory from '../../../factory';
|
|
7
|
+
/**
|
|
8
|
+
* オファーで利用可能な適用決済カード条件を検索する
|
|
9
|
+
* プロダクトのひとつめのカタログのみ検索対象なので注意
|
|
10
|
+
* また、サブカタログによるカタログが設定されている場合、カタログのひとつめのサブカタログのみが検索対象
|
|
11
|
+
*/
|
|
12
|
+
declare function searchOfferAppliesToMovieTicket(params: {
|
|
13
|
+
event: {
|
|
14
|
+
/**
|
|
15
|
+
* イベントID
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* どのアプリケーションに対して
|
|
21
|
+
*/
|
|
22
|
+
store?: {
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
limit?: number;
|
|
26
|
+
page?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 有効なオファーのみ対象とするか
|
|
29
|
+
*/
|
|
30
|
+
onlyValid?: boolean;
|
|
31
|
+
}): (repos: {
|
|
32
|
+
event: EventRepo;
|
|
33
|
+
eventSeries: EventSeriesRepo;
|
|
34
|
+
offer: OfferRepo;
|
|
35
|
+
offerCatalog: OfferCatalogRepo;
|
|
36
|
+
product: ProductRepo;
|
|
37
|
+
}) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
|
|
38
|
+
export { searchOfferAppliesToMovieTicket };
|
|
@@ -0,0 +1,97 @@
|
|
|
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.searchOfferAppliesToMovieTicket = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
function getUnacceptedPaymentMethodByEvent(params) {
|
|
15
|
+
var _a;
|
|
16
|
+
let unacceptedPaymentMethod = [];
|
|
17
|
+
const unacceptedPaymentMethodByEvent = (_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.unacceptedPaymentMethod;
|
|
18
|
+
// 施設コンテンツを参照する必要はない(2022-10-31~)
|
|
19
|
+
if (Array.isArray(unacceptedPaymentMethodByEvent)) {
|
|
20
|
+
unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
|
|
21
|
+
}
|
|
22
|
+
return unacceptedPaymentMethod;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* オファーで利用可能な適用決済カード条件を検索する
|
|
26
|
+
* プロダクトのひとつめのカタログのみ検索対象なので注意
|
|
27
|
+
* また、サブカタログによるカタログが設定されている場合、カタログのひとつめのサブカタログのみが検索対象
|
|
28
|
+
*/
|
|
29
|
+
function searchOfferAppliesToMovieTicket(params) {
|
|
30
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
// optimize(2024-07-18~)
|
|
33
|
+
const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
|
|
34
|
+
// let soundFormatTypes: string[] = [];
|
|
35
|
+
let videoFormatTypes = [];
|
|
36
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
37
|
+
const superEvents = yield repos.eventSeries.projectEventSeriesFields({
|
|
38
|
+
limit: 1,
|
|
39
|
+
page: 1,
|
|
40
|
+
id: { $eq: event.superEvent.id }
|
|
41
|
+
// typeOf: factory.eventType.ScreeningEventSeries
|
|
42
|
+
}, ['soundFormat', 'videoFormat']);
|
|
43
|
+
const superEvent = superEvents.shift();
|
|
44
|
+
if (superEvent === undefined) {
|
|
45
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
46
|
+
}
|
|
47
|
+
// soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
48
|
+
videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
49
|
+
}
|
|
50
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
|
|
51
|
+
// 上映方式がなければMovieTicket除外
|
|
52
|
+
const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
|
|
53
|
+
// 興行設定があれば興行のカタログを参照する
|
|
54
|
+
const eventOffers = event.offers;
|
|
55
|
+
let catalogId;
|
|
56
|
+
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
57
|
+
const eventService = (yield repos.product.projectFields({
|
|
58
|
+
limit: 1,
|
|
59
|
+
page: 1,
|
|
60
|
+
id: { $eq: eventOffers.itemOffered.id }
|
|
61
|
+
}, ['hasOfferCatalog']
|
|
62
|
+
// []
|
|
63
|
+
)).shift();
|
|
64
|
+
if (eventService === undefined) {
|
|
65
|
+
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
66
|
+
}
|
|
67
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
68
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
69
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
70
|
+
catalogId = firstCatalogIdOfProduct;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (typeof catalogId !== 'string') {
|
|
74
|
+
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
75
|
+
}
|
|
76
|
+
// サブカタログIDを決定
|
|
77
|
+
let subOfferCatalogId = catalogId;
|
|
78
|
+
// let isOfferCatalogItem: boolean = false;
|
|
79
|
+
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
|
|
80
|
+
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
81
|
+
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
82
|
+
// isOfferCatalogItem = true;
|
|
83
|
+
}
|
|
84
|
+
return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
|
|
85
|
+
// subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
86
|
+
subOfferCatalog: { id: subOfferCatalogId },
|
|
87
|
+
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
88
|
+
unacceptedPaymentMethod: unacceptedPaymentMethod,
|
|
89
|
+
excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
|
|
90
|
+
onlyValid: params.onlyValid === true,
|
|
91
|
+
// useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
92
|
+
limit: params.limit,
|
|
93
|
+
page: params.page
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
|
|
@@ -20,11 +20,7 @@ const debug = createDebug('chevre-domain:service:offer');
|
|
|
20
20
|
function searchTicketOffersByItemOffered(params) {
|
|
21
21
|
// tslint:disable-next-line:max-func-body-length
|
|
22
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
var _a, _b, _c, _d
|
|
24
|
-
/**
|
|
25
|
-
* プロダクトのカタログID
|
|
26
|
-
*/
|
|
27
|
-
let catalogId;
|
|
23
|
+
var _a, _b, _c, _d;
|
|
28
24
|
const eventService = (yield repos.product.projectFields({
|
|
29
25
|
limit: 1,
|
|
30
26
|
page: 1,
|
|
@@ -35,18 +31,24 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
35
31
|
if (eventService === undefined) {
|
|
36
32
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
34
|
+
const offerCatalogItemsOfProduct = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement;
|
|
35
|
+
/**
|
|
36
|
+
* プロダクトのカタログIDリスト
|
|
37
|
+
*/
|
|
38
|
+
const catalogIdsOfProduct = (Array.isArray(offerCatalogItemsOfProduct)) ? offerCatalogItemsOfProduct.map(({ id }) => id) : [];
|
|
39
|
+
/**
|
|
40
|
+
* プロダクトのひとつめのカタログID
|
|
41
|
+
*/
|
|
42
|
+
const firstCatalogIdOfProduct = catalogIdsOfProduct.at(0);
|
|
43
|
+
if (typeof firstCatalogIdOfProduct !== 'string') {
|
|
44
44
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* カタログID or サブカタログID
|
|
48
|
+
*/
|
|
49
|
+
let subOfferCatalogId = firstCatalogIdOfProduct;
|
|
48
50
|
let isOfferCatalogItem = false;
|
|
49
|
-
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id:
|
|
51
|
+
const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: firstCatalogIdOfProduct });
|
|
50
52
|
if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
|
|
51
53
|
subOfferCatalogId = offerCatalogFirstElement.id;
|
|
52
54
|
isOfferCatalogItem = true;
|
|
@@ -62,19 +64,19 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
62
64
|
if (isOfferCatalogItem) {
|
|
63
65
|
// 複数カタログ対応(2023-09-27~)
|
|
64
66
|
const offerCatalogItems = yield repos.offerCatalog.findItemListElementById({
|
|
65
|
-
id:
|
|
67
|
+
id: firstCatalogIdOfProduct,
|
|
66
68
|
project: { id: eventService.project.id }
|
|
67
69
|
});
|
|
68
70
|
includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
|
|
69
71
|
}
|
|
70
72
|
// includedInDataCatalogIdsを明示的に指定可能にする(2024-10-01~)
|
|
71
|
-
let includedInDataCatalogIdsSpecified = (
|
|
73
|
+
let includedInDataCatalogIdsSpecified = (_c = params.options.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id;
|
|
72
74
|
if (Array.isArray(includedInDataCatalogIdsSpecified)) {
|
|
75
|
+
includedInDataCatalogIdsSpecified = [...new Set(includedInDataCatalogIdsSpecified)]; // unique
|
|
73
76
|
if (isOfferCatalogItem) {
|
|
74
|
-
includedInDataCatalogIdsSpecified = [...new Set(includedInDataCatalogIdsSpecified)]; // unique
|
|
75
77
|
// プロダクトのカタログに含まれるサブカタログにフィルター
|
|
76
78
|
const includedInDataCatalogIdsSpecifiedInOfferCatalog = yield repos.offerCatalog.searchItemListElement({
|
|
77
|
-
id: { $in:
|
|
79
|
+
id: { $in: catalogIdsOfProduct },
|
|
78
80
|
itemListElement: { id: { $in: includedInDataCatalogIdsSpecified } }
|
|
79
81
|
});
|
|
80
82
|
if (includedInDataCatalogIdsSpecifiedInOfferCatalog.length !== includedInDataCatalogIdsSpecified.length) {
|
|
@@ -83,14 +85,18 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
83
85
|
includedInDataCatalogIds = includedInDataCatalogIdsSpecified;
|
|
84
86
|
}
|
|
85
87
|
else {
|
|
86
|
-
//
|
|
88
|
+
// サブカタログでない場合は全てプロダクトのひとつめのカタログIDに一致するはず(現状プロダクトのカタログ数が1の前提なので)
|
|
89
|
+
const everySpecifiedCatalogIdsValid = includedInDataCatalogIdsSpecified.every((id) => id === subOfferCatalogId);
|
|
90
|
+
if (!everySpecifiedCatalogIdsValid) {
|
|
91
|
+
throw new factory.errors.Argument('includedInDataCatalog.id', 'invalid offerCatalog');
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
debug('searchOffersByIds:', 'searchAllByIdsAndOfferCatalogId processing...', eventService.project.id, params.ids.join(','), includedInDataCatalogIds.join(','));
|
|
90
96
|
const availableOffers = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
91
97
|
ids: params.ids,
|
|
92
98
|
includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
|
|
93
|
-
availableAtOrFrom: { id: (
|
|
99
|
+
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
94
100
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
95
101
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
96
102
|
onlyValid: true
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { authorize } from './event/authorize';
|
|
2
2
|
import { importCategoryCodesFromCOA, importFromCOA } from './event/importFromCOA';
|
|
3
|
-
import { searchEventTicketOffers
|
|
3
|
+
import { searchEventTicketOffers } from './event/searchEventTicketOffers';
|
|
4
|
+
import { searchOfferAppliesToMovieTicket } from './event/searchOfferAppliesToMovieTicket';
|
|
4
5
|
import { searchOfferCatalogItemAvailability } from './event/searchOfferCatalogItemAvailability';
|
|
5
6
|
import { searchOfferCatalogItems } from './event/searchOfferCatalogItems';
|
|
6
7
|
import { voidTransaction } from './event/voidTransaction';
|
|
@@ -8,7 +8,8 @@ Object.defineProperty(exports, "importCategoryCodesFromCOA", { enumerable: true,
|
|
|
8
8
|
Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importFromCOA; } });
|
|
9
9
|
const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
|
|
10
10
|
Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
|
|
11
|
-
|
|
11
|
+
const searchOfferAppliesToMovieTicket_1 = require("./event/searchOfferAppliesToMovieTicket");
|
|
12
|
+
Object.defineProperty(exports, "searchOfferAppliesToMovieTicket", { enumerable: true, get: function () { return searchOfferAppliesToMovieTicket_1.searchOfferAppliesToMovieTicket; } });
|
|
12
13
|
const searchOfferCatalogItemAvailability_1 = require("./event/searchOfferCatalogItemAvailability");
|
|
13
14
|
Object.defineProperty(exports, "searchOfferCatalogItemAvailability", { enumerable: true, get: function () { return searchOfferCatalogItemAvailability_1.searchOfferCatalogItemAvailability; } });
|
|
14
15
|
const searchOfferCatalogItems_1 = require("./event/searchOfferCatalogItems");
|
|
@@ -7,5 +7,5 @@ import * as factory from '../../../../factory';
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
9
9
|
transaction?: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
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/createAccountingReport").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/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)[];
|
|
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/createAccountingReport").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deletePerson").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/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 };
|
package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ declare function createInformTasks(params: {
|
|
|
13
13
|
}, settings: Settings): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
14
14
|
declare function createNextSendOrderTasks(params: {
|
|
15
15
|
order: IInTransitOrder;
|
|
16
|
-
}): (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/createAccountingReport").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/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)[];
|
|
16
|
+
}): (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/createAccountingReport").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deletePerson").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/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)[];
|
|
17
17
|
export { createInformTasks, createNextSendOrderTasks, IInTransitOrder };
|
|
@@ -8,5 +8,5 @@ declare function createInformTasks(order: IReturnedOrder, settings: Settings): f
|
|
|
8
8
|
declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
9
9
|
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'customer' | 'price' | 'priceCurrency' | 'orderDate'>;
|
|
10
10
|
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
11
|
-
}): (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/createAccountingReport").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/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
|
+
}): (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/createAccountingReport").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deletePerson").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/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)[];
|
|
12
12
|
export { createInformTasks, createOnOrderReturnedTasksByTransaction };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
3
|
+
/**
|
|
4
|
+
* タスク実行関数
|
|
5
|
+
*/
|
|
6
|
+
export declare function call(params: Pick<factory.task.deletePerson.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -0,0 +1,421 @@
|
|
|
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.call = void 0;
|
|
13
|
+
const GMO = require("@motionpicture/gmo-service");
|
|
14
|
+
const factory = require("../../factory");
|
|
15
|
+
const person2username_1 = require("../payment/any/person2username");
|
|
16
|
+
const account_1 = require("../../repo/account");
|
|
17
|
+
const action_1 = require("../../repo/action");
|
|
18
|
+
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
19
|
+
const creditCard_1 = require("../../repo/paymentMethod/creditCard");
|
|
20
|
+
const paymentService_1 = require("../../repo/paymentService");
|
|
21
|
+
const person_1 = require("../../repo/person");
|
|
22
|
+
const project_1 = require("../../repo/project");
|
|
23
|
+
const task_1 = require("../../repo/task");
|
|
24
|
+
const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = 'CreditCard';
|
|
25
|
+
let cognitoIdentityServiceProvider;
|
|
26
|
+
/**
|
|
27
|
+
* タスク実行関数
|
|
28
|
+
*/
|
|
29
|
+
function call(params) {
|
|
30
|
+
return ({ connection, settings }) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (cognitoIdentityServiceProvider === undefined) {
|
|
32
|
+
const { CognitoIdentityProvider } = yield Promise.resolve().then(() => require('@aws-sdk/client-cognito-identity-provider'));
|
|
33
|
+
const { fromEnv } = yield Promise.resolve().then(() => require('@aws-sdk/credential-providers'));
|
|
34
|
+
cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
35
|
+
apiVersion: 'latest',
|
|
36
|
+
region: 'ap-northeast-1',
|
|
37
|
+
credentials: fromEnv()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const newPersonRepo = new person_1.PersonRepo({
|
|
41
|
+
userPoolId: params.data.userPoolId,
|
|
42
|
+
cognitoIdentityServiceProvider
|
|
43
|
+
});
|
|
44
|
+
const oldPersonRepo = new person_1.PersonRepo({
|
|
45
|
+
userPoolId: settings.userPoolIdOld,
|
|
46
|
+
cognitoIdentityServiceProvider
|
|
47
|
+
});
|
|
48
|
+
const paymentServiceRepo = new paymentService_1.PaymentServiceRepo(connection);
|
|
49
|
+
const credentials = yield getCreditCardPaymentServiceChannel({
|
|
50
|
+
project: { id: params.project.id },
|
|
51
|
+
paymentMethodType: DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD
|
|
52
|
+
})({ paymentService: paymentServiceRepo });
|
|
53
|
+
const creditCardRepo = new creditCard_1.CreditCardRepo({
|
|
54
|
+
siteId: credentials.siteId,
|
|
55
|
+
sitePass: credentials.sitePass,
|
|
56
|
+
cardService: new GMO.service.Card({
|
|
57
|
+
endpoint: credentials.endpoint,
|
|
58
|
+
useFetch: settings.gmo.useFetch
|
|
59
|
+
}, {
|
|
60
|
+
timeout: (params.data.executeBackground)
|
|
61
|
+
? settings.gmo.timeout
|
|
62
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
63
|
+
: 20000 // cronで実行の場合は長めに(2024-10-05~)
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
yield deleteById(params.data)({
|
|
67
|
+
account: new account_1.AccountRepo(connection),
|
|
68
|
+
action: new action_1.ActionRepo(connection),
|
|
69
|
+
creditCard: creditCardRepo,
|
|
70
|
+
ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
|
|
71
|
+
paymentService: paymentServiceRepo,
|
|
72
|
+
newPerson: newPersonRepo,
|
|
73
|
+
oldPerson: oldPersonRepo,
|
|
74
|
+
project: new project_1.ProjectRepo(connection),
|
|
75
|
+
task: new task_1.TaskRepo(connection),
|
|
76
|
+
cognitoIdentityServiceProvider
|
|
77
|
+
}, settings);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.call = call;
|
|
81
|
+
/**
|
|
82
|
+
* 会員削除処理
|
|
83
|
+
*/
|
|
84
|
+
function deleteById(params) {
|
|
85
|
+
// tslint:disable-next-line:max-func-body-length
|
|
86
|
+
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const deleteMemberAction = {
|
|
88
|
+
agent: params.agent,
|
|
89
|
+
object: Object.assign({ id: params.id, typeOf: factory.personType.Person, migrate: params.migrate, physically: params.physically }, (typeof params.migratePersonRecipientUrl === 'string')
|
|
90
|
+
? { migratePersonRecipientUrl: params.migratePersonRecipientUrl } : undefined),
|
|
91
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
92
|
+
typeOf: factory.actionType.DeleteAction
|
|
93
|
+
};
|
|
94
|
+
const action = yield repos.action.start(deleteMemberAction);
|
|
95
|
+
let existingPeople;
|
|
96
|
+
try {
|
|
97
|
+
const project = yield repos.project.findById({
|
|
98
|
+
id: params.project.id,
|
|
99
|
+
inclusion: ['settings'],
|
|
100
|
+
exclusion: []
|
|
101
|
+
});
|
|
102
|
+
// const useUsernameAsGMOMemberId = project.settings?.useUsernameAsGMOMemberId === true;
|
|
103
|
+
// 移行の場合、全所有権情報通知タスクを作成
|
|
104
|
+
if (params.migrate && typeof params.migratePersonRecipientUrl === 'string') {
|
|
105
|
+
yield createInformTask({
|
|
106
|
+
id: params.id,
|
|
107
|
+
project: { id: project.id },
|
|
108
|
+
now: action.startDate,
|
|
109
|
+
migratePersonRecipientUrl: params.migratePersonRecipientUrl
|
|
110
|
+
})(repos);
|
|
111
|
+
}
|
|
112
|
+
if (!params.migrate) {
|
|
113
|
+
// 移行でなければDeleteTransactionタスクを作成(2023-07-03~)
|
|
114
|
+
yield createDeleteTransactionTask({
|
|
115
|
+
id: params.id,
|
|
116
|
+
project: { id: project.id },
|
|
117
|
+
now: action.startDate
|
|
118
|
+
})({ task: repos.task });
|
|
119
|
+
}
|
|
120
|
+
existingPeople = yield repos.newPerson.search({ id: params.id });
|
|
121
|
+
// tslint:disable-next-line:no-console
|
|
122
|
+
console.log('admin:people:deleteById: existingPeople:', JSON.stringify(existingPeople));
|
|
123
|
+
if (existingPeople.length > 0) {
|
|
124
|
+
// クレジットカード削除
|
|
125
|
+
yield deleteCreditCardsById({
|
|
126
|
+
id: params.id,
|
|
127
|
+
useUsernameAsGMOMemberId: params.useUsernameAsGMOMemberId
|
|
128
|
+
})({
|
|
129
|
+
person: repos.newPerson,
|
|
130
|
+
creditCard: repos.creditCard,
|
|
131
|
+
cognitoIdentityServiceProvider: repos.cognitoIdentityServiceProvider
|
|
132
|
+
}, settings);
|
|
133
|
+
}
|
|
134
|
+
// 所有権削除
|
|
135
|
+
// tslint:disable-next-line:no-console
|
|
136
|
+
console.log('admin:people:deleteById: deleteOwnershipInfosById processing... personId:', params.id);
|
|
137
|
+
yield deleteOwnershipInfosById({
|
|
138
|
+
id: params.id,
|
|
139
|
+
project: { id: project.id }
|
|
140
|
+
})({ ownershipInfo: repos.ownershipInfo });
|
|
141
|
+
if (existingPeople.length > 0) {
|
|
142
|
+
// 会員削除
|
|
143
|
+
if (params.physically === true) {
|
|
144
|
+
// tslint:disable-next-line:no-console
|
|
145
|
+
console.log('admin:people:deleteById: deleteById processing...userId:', params.id);
|
|
146
|
+
yield repos.newPerson.deleteById({ userId: params.id });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Cognitoユーザを無効にする
|
|
150
|
+
yield repos.newPerson.globalSignOutAndDisable({ userId: params.id });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
try {
|
|
156
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
157
|
+
}
|
|
158
|
+
catch (__) {
|
|
159
|
+
// no op
|
|
160
|
+
}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
const actionResult = { existingPeople };
|
|
164
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function getCreditCardPaymentServiceChannel(params) {
|
|
168
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
const paymentServices = yield repos.paymentService.projectFields({
|
|
171
|
+
limit: 1,
|
|
172
|
+
project: { id: { $eq: params.project.id } },
|
|
173
|
+
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
174
|
+
serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
175
|
+
}, ['availableChannel'], []);
|
|
176
|
+
const paymentService = paymentServices.shift();
|
|
177
|
+
if (paymentService === undefined) {
|
|
178
|
+
throw new factory.errors.NotFound('PaymentService');
|
|
179
|
+
}
|
|
180
|
+
// const paymentService = <Pick<chevre.factory.service.paymentService.IService, 'availableChannel'>>
|
|
181
|
+
// await repos.product.findById({ id: String(paymentServiceSetting.id) }, ['availableChannel'], []);
|
|
182
|
+
const availableChannel = paymentService === null || paymentService === void 0 ? void 0 : paymentService.availableChannel;
|
|
183
|
+
if (typeof (availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.serviceUrl) !== 'string') {
|
|
184
|
+
throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
|
|
185
|
+
}
|
|
186
|
+
if (typeof ((_a = availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId) !== 'string') {
|
|
187
|
+
throw new factory.errors.NotFound('paymentService.availableChannel.credentials.siteId');
|
|
188
|
+
}
|
|
189
|
+
if (typeof ((_b = availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass) !== 'string') {
|
|
190
|
+
throw new factory.errors.NotFound('paymentService.availableChannel.credentials.sitePass');
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
endpoint: availableChannel.serviceUrl,
|
|
194
|
+
siteId: availableChannel.credentials.siteId,
|
|
195
|
+
sitePass: availableChannel.credentials.sitePass
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function createInformTask(params) {
|
|
200
|
+
// tslint:disable-next-line:max-func-body-length
|
|
201
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const person = yield repos.newPerson.findById({ userId: params.id });
|
|
204
|
+
let oldUser;
|
|
205
|
+
const userIdentitiesStr = (_b = (_a = person.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'identities')) === null || _b === void 0 ? void 0 : _b.value;
|
|
206
|
+
if (typeof userIdentitiesStr === 'string' && userIdentitiesStr.length > 0) {
|
|
207
|
+
try {
|
|
208
|
+
const identities = JSON.parse(userIdentitiesStr);
|
|
209
|
+
if (Array.isArray(identities) && identities.length > 0) {
|
|
210
|
+
const userIdByIdentities = identities[0].userId;
|
|
211
|
+
if (typeof userIdByIdentities === 'string' && userIdByIdentities.length > 0) {
|
|
212
|
+
// oldUserは必ず存在するはず
|
|
213
|
+
oldUser = yield repos.oldPerson.findById({ userId: userIdByIdentities });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
// tslint:disable-next-line:no-console
|
|
219
|
+
console.error('find oldUser throwed', error);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const reservations = yield repos.ownershipInfo.projectFields({
|
|
224
|
+
project: { id: { $eq: params.project.id } },
|
|
225
|
+
ownedBy: { id: params.id },
|
|
226
|
+
typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.EventService } } }
|
|
227
|
+
});
|
|
228
|
+
const memberships = yield repos.ownershipInfo.projectFields({
|
|
229
|
+
limit: 1,
|
|
230
|
+
page: 1,
|
|
231
|
+
project: { id: { $eq: params.project.id } },
|
|
232
|
+
ownedBy: { id: params.id },
|
|
233
|
+
typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.MembershipService } } },
|
|
234
|
+
ownedFrom: params.now,
|
|
235
|
+
ownedThrough: params.now
|
|
236
|
+
});
|
|
237
|
+
let paymentCards = yield repos.ownershipInfo.projectFields({
|
|
238
|
+
// 最も古い所有ペイメントカードをデフォルトペイメントカードとして扱う使用なので、ソート条件は以下の通り
|
|
239
|
+
sort: { ownedFrom: factory.sortType.Ascending },
|
|
240
|
+
limit: 1,
|
|
241
|
+
page: 1,
|
|
242
|
+
project: { id: { $eq: params.project.id } },
|
|
243
|
+
ownedBy: { id: params.id },
|
|
244
|
+
typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.PaymentCard } } },
|
|
245
|
+
ownedFrom: params.now,
|
|
246
|
+
ownedThrough: params.now
|
|
247
|
+
});
|
|
248
|
+
paymentCards = yield Promise.all(paymentCards.map((paymentCard) => __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
// 口座検索
|
|
250
|
+
const accountNumber = String(paymentCard.typeOfGood.identifier);
|
|
251
|
+
const account = yield repos.account.findByAccountNumber({ accountNumber });
|
|
252
|
+
return Object.assign(Object.assign({}, paymentCard), { typeOfGood: Object.assign(Object.assign({}, paymentCard.typeOfGood), { balance: account.balance }) });
|
|
253
|
+
})));
|
|
254
|
+
// create task
|
|
255
|
+
let informTask;
|
|
256
|
+
const informActionAttributes = {
|
|
257
|
+
// agent: { id: params.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
258
|
+
object: {
|
|
259
|
+
id: person.id,
|
|
260
|
+
memberOf: person.memberOf,
|
|
261
|
+
typeOf: person.typeOf,
|
|
262
|
+
cognitoUser: {
|
|
263
|
+
Attributes: oldUser === null || oldUser === void 0 ? void 0 : oldUser.Attributes,
|
|
264
|
+
Enabled: oldUser === null || oldUser === void 0 ? void 0 : oldUser.Enabled,
|
|
265
|
+
UserCreateDate: oldUser === null || oldUser === void 0 ? void 0 : oldUser.UserCreateDate,
|
|
266
|
+
UserLastModifiedDate: oldUser === null || oldUser === void 0 ? void 0 : oldUser.UserLastModifiedDate,
|
|
267
|
+
UserStatus: oldUser === null || oldUser === void 0 ? void 0 : oldUser.UserStatus,
|
|
268
|
+
Username: oldUser === null || oldUser === void 0 ? void 0 : oldUser.Username
|
|
269
|
+
},
|
|
270
|
+
reservations: reservations.map((ownershipInfo) => {
|
|
271
|
+
const { id, typeOf, typeOfGood, ownedFrom, ownedThrough } = ownershipInfo;
|
|
272
|
+
return { id, typeOf, typeOfGood, ownedFrom, ownedThrough };
|
|
273
|
+
}),
|
|
274
|
+
memberships: memberships.map((ownershipInfo) => {
|
|
275
|
+
const { id, typeOf, typeOfGood, ownedFrom, ownedThrough } = ownershipInfo;
|
|
276
|
+
const { identifier } = typeOfGood;
|
|
277
|
+
return {
|
|
278
|
+
id,
|
|
279
|
+
typeOf,
|
|
280
|
+
typeOfGood: { identifier },
|
|
281
|
+
ownedFrom,
|
|
282
|
+
ownedThrough
|
|
283
|
+
};
|
|
284
|
+
}),
|
|
285
|
+
paymentCards: paymentCards.map((ownershipInfo) => {
|
|
286
|
+
const { id, typeOf, typeOfGood } = ownershipInfo;
|
|
287
|
+
const { balance, identifier } = typeOfGood;
|
|
288
|
+
return {
|
|
289
|
+
id,
|
|
290
|
+
typeOf,
|
|
291
|
+
typeOfGood: { balance, identifier }
|
|
292
|
+
};
|
|
293
|
+
})
|
|
294
|
+
},
|
|
295
|
+
// project: { id: params.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
296
|
+
recipient: {
|
|
297
|
+
url: params.migratePersonRecipientUrl,
|
|
298
|
+
id: '',
|
|
299
|
+
name: 'NewUserPool',
|
|
300
|
+
typeOf: factory.creativeWorkType.WebApplication
|
|
301
|
+
}
|
|
302
|
+
// typeOf: chevre.factory.actionType.InformAction
|
|
303
|
+
};
|
|
304
|
+
informTask = {
|
|
305
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
306
|
+
name: factory.taskName.TriggerWebhook,
|
|
307
|
+
status: factory.taskStatus.Ready,
|
|
308
|
+
runsAt: params.now,
|
|
309
|
+
remainingNumberOfTries: 10,
|
|
310
|
+
numberOfTried: 0,
|
|
311
|
+
executionResults: [],
|
|
312
|
+
data: informActionAttributes
|
|
313
|
+
};
|
|
314
|
+
yield repos.task.createInformTaskIfNotExist(informTask, { emitImmediately: true });
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function createDeleteTransactionTask(params) {
|
|
318
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
319
|
+
const deleteTransactionTasks = [
|
|
320
|
+
factory.transactionType.MoneyTransfer,
|
|
321
|
+
factory.transactionType.PlaceOrder,
|
|
322
|
+
factory.transactionType.ReturnOrder
|
|
323
|
+
].map((transactionType) => {
|
|
324
|
+
return {
|
|
325
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
326
|
+
name: factory.taskName.DeleteTransaction,
|
|
327
|
+
status: factory.taskStatus.Ready,
|
|
328
|
+
runsAt: params.now,
|
|
329
|
+
remainingNumberOfTries: 3,
|
|
330
|
+
numberOfTried: 0,
|
|
331
|
+
executionResults: [],
|
|
332
|
+
data: {
|
|
333
|
+
object: {
|
|
334
|
+
specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.AgentId,
|
|
335
|
+
agent: { id: params.id },
|
|
336
|
+
project: { id: params.project.id },
|
|
337
|
+
typeOf: transactionType
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
});
|
|
342
|
+
yield repos.task.saveMany(deleteTransactionTasks, { emitImmediately: true });
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function deleteOwnershipInfosById(params) {
|
|
346
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
347
|
+
// まず所有権削除
|
|
348
|
+
yield repos.ownershipInfo.deleteByOwnedById({
|
|
349
|
+
project: { id: params.project.id },
|
|
350
|
+
ownedBy: { id: params.id }
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function sleep(waitTime) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
return new Promise((resolve) => {
|
|
357
|
+
setTimeout(() => {
|
|
358
|
+
resolve();
|
|
359
|
+
}, waitTime);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const DELETE_CREDIT_CARD_MAX_RETRY_COUNT = 2;
|
|
364
|
+
const DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS = 1000;
|
|
365
|
+
function deleteCreditCardsById(params) {
|
|
366
|
+
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
367
|
+
let retry = true;
|
|
368
|
+
let numberOfTry = 0;
|
|
369
|
+
while (numberOfTry >= 0) {
|
|
370
|
+
try {
|
|
371
|
+
numberOfTry += 1;
|
|
372
|
+
if (numberOfTry > DELETE_CREDIT_CARD_MAX_RETRY_COUNT) {
|
|
373
|
+
retry = false;
|
|
374
|
+
}
|
|
375
|
+
// retryInterval
|
|
376
|
+
if (numberOfTry > 1) {
|
|
377
|
+
yield sleep(DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS * (numberOfTry - 1));
|
|
378
|
+
}
|
|
379
|
+
// クレジットカード削除
|
|
380
|
+
if (params.useUsernameAsGMOMemberId) {
|
|
381
|
+
const person = yield repos.person.findById({ userId: params.id });
|
|
382
|
+
let oldUsername;
|
|
383
|
+
try {
|
|
384
|
+
oldUsername = yield (0, person2username_1.person2username)(person, repos.cognitoIdentityServiceProvider, settings);
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
let throwsPerson2usernameError = true;
|
|
388
|
+
// oldUserが存在しないケースをハンドル
|
|
389
|
+
if (error instanceof factory.errors.NotFound && error.entityName === 'User') {
|
|
390
|
+
// tslint:disable-next-line:no-console
|
|
391
|
+
console.log('admin:people:deleteById: deleteCreditCardsById oldUsername not found', 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
392
|
+
throwsPerson2usernameError = false;
|
|
393
|
+
}
|
|
394
|
+
if (throwsPerson2usernameError) {
|
|
395
|
+
throw error;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (typeof oldUsername === 'string') {
|
|
399
|
+
// tslint:disable-next-line:no-console
|
|
400
|
+
console.log('admin:people:deleteById: deleteCreditCardsById processing... oldUsername:', oldUsername, 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
401
|
+
yield repos.creditCard.deleteAll({ personId: oldUsername });
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
yield repos.creditCard.deleteAll({ personId: params.id });
|
|
406
|
+
}
|
|
407
|
+
// tslint:disable-next-line:no-console
|
|
408
|
+
console.log('admin:people:deleteById: deleteCreditCardsById processed. personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
if (retry) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
@@ -96,6 +96,7 @@ function execute(task) {
|
|
|
96
96
|
case factory.taskName.AcceptCOAOffer:
|
|
97
97
|
case factory.taskName.AuthorizePayment:
|
|
98
98
|
case factory.taskName.CheckMovieTicket:
|
|
99
|
+
case factory.taskName.DeletePerson:
|
|
99
100
|
case factory.taskName.Pay:
|
|
100
101
|
case factory.taskName.PublishPaymentUrl:
|
|
101
102
|
case factory.taskName.Refund:
|
package/package.json
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
12
|
+
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
|
+
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
+
"@chevre/factory": "4.386.0-alpha.7",
|
|
15
|
+
"@cinerino/sdk": "10.13.0-alpha.3",
|
|
14
16
|
"@motionpicture/coa-service": "9.5.0",
|
|
15
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
16
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -30,8 +32,6 @@
|
|
|
30
32
|
},
|
|
31
33
|
"description": "Chevre Domain Library for Node.js",
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
34
|
-
"@aws-sdk/credential-providers": "3.600.0",
|
|
35
35
|
"@types/debug": "0.0.30",
|
|
36
36
|
"@types/google-libphonenumber": "^7.4.19",
|
|
37
37
|
"@types/http-status": "^0.2.30",
|
|
@@ -65,8 +65,6 @@
|
|
|
65
65
|
"typescript": "5.0.3"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@aws-sdk/client-cognito-identity-provider": "^3.600.0",
|
|
69
|
-
"@aws-sdk/credential-providers": "^3.600.0",
|
|
70
68
|
"mongoose": "^7.4.0",
|
|
71
69
|
"redis": "^4.6.5"
|
|
72
70
|
},
|
|
@@ -110,5 +108,5 @@
|
|
|
110
108
|
"postversion": "git push origin --tags",
|
|
111
109
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
110
|
},
|
|
113
|
-
"version": "22.5.0-alpha.
|
|
111
|
+
"version": "22.5.0-alpha.14"
|
|
114
112
|
}
|