@chevre/domain 21.25.0-alpha.0 → 21.25.0-alpha.10
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/deleteOwnershipInfosByWebApplication.ts +80 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +1 -1
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +6 -3
- package/lib/chevre/emailMessageBuilder.d.ts +0 -4
- package/lib/chevre/factory/event.js +7 -4
- package/lib/chevre/repo/orderInTransaction.d.ts +6 -5
- package/lib/chevre/repo/orderInTransaction.js +15 -24
- package/lib/chevre/service/delivery/factory.d.ts +1 -0
- package/lib/chevre/service/delivery/factory.js +7 -2
- package/lib/chevre/service/event/createEvent.js +2 -1
- package/lib/chevre/service/event.js +33 -24
- package/lib/chevre/service/offer/product/factory.d.ts +10 -0
- package/lib/chevre/service/offer/product/factory.js +2 -1
- package/lib/chevre/service/offer/product.js +2 -1
- package/lib/chevre/service/order/deleteOrder.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +1 -68
- package/lib/chevre/service/order/sendOrder.js +7 -2
- package/lib/chevre/service/payment/any/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +6 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +137 -29
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +3 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +4 -13
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +73 -95
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +5 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +19 -20
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +19 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +102 -77
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +7 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +88 -130
- package/package.json +4 -4
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = ownershipInfoRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
'ownedBy.typeOf': { $eq: chevre.factory.creativeWorkType.WebApplication }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
console.log('infos found');
|
|
22
|
+
|
|
23
|
+
let i = 0;
|
|
24
|
+
let updateCount = 0;
|
|
25
|
+
await cursor.eachAsync(async (doc) => {
|
|
26
|
+
i += 1;
|
|
27
|
+
const ownershipInfo: Pick<
|
|
28
|
+
chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IGood>,
|
|
29
|
+
'id' | 'project' | 'identifier' | 'ownedBy' | 'ownedFrom' | 'ownedThrough'
|
|
30
|
+
> = doc.toObject();
|
|
31
|
+
|
|
32
|
+
let noNeedToDelete = true;
|
|
33
|
+
let ownedById: string | undefined;
|
|
34
|
+
let ownedByTypeOf: string;
|
|
35
|
+
if (Array.isArray(ownershipInfo.ownedBy)) {
|
|
36
|
+
ownedByTypeOf = ownershipInfo.ownedBy[0].typeOf;
|
|
37
|
+
if (ownershipInfo.ownedBy.every(({ typeOf }) => typeOf === chevre.factory.creativeWorkType.WebApplication)) {
|
|
38
|
+
noNeedToDelete = false;
|
|
39
|
+
ownedById = ownershipInfo.ownedBy[0].id;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
ownedByTypeOf = ownershipInfo.ownedBy.typeOf;
|
|
43
|
+
if (ownershipInfo.ownedBy.typeOf === chevre.factory.creativeWorkType.WebApplication) {
|
|
44
|
+
noNeedToDelete = false;
|
|
45
|
+
ownedById = ownershipInfo.ownedBy.id;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (noNeedToDelete) {
|
|
50
|
+
console.log(
|
|
51
|
+
'noNeedToDelete.',
|
|
52
|
+
ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
|
|
53
|
+
i, updateCount);
|
|
54
|
+
} else {
|
|
55
|
+
console.log(
|
|
56
|
+
'deleting...',
|
|
57
|
+
ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
|
|
58
|
+
i, updateCount);
|
|
59
|
+
if (typeof ownedById === 'string') {
|
|
60
|
+
await ownershipInfoRepo.deleteByIdAndOwnedById({
|
|
61
|
+
project: { id: ownershipInfo.project.id },
|
|
62
|
+
id: ownershipInfo.id,
|
|
63
|
+
ownedBy: { id: ownedById }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
updateCount += 1;
|
|
67
|
+
console.log(
|
|
68
|
+
'deleted.',
|
|
69
|
+
ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
|
|
70
|
+
i, updateCount);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(i, 'infos checked');
|
|
75
|
+
console.log(updateCount, 'infos updated');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
main()
|
|
79
|
+
.then()
|
|
80
|
+
.catch(console.error);
|
|
@@ -6,14 +6,17 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
8
|
|
|
9
|
+
const limit = 1;
|
|
10
|
+
const page = 2;
|
|
9
11
|
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
10
12
|
|
|
11
13
|
const result = await acceptedOfferRepo.searchSlicedAcceptedOffersByOrderNumber(
|
|
12
14
|
{
|
|
13
|
-
orderNumber: { $eq: '
|
|
14
|
-
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
15
|
+
orderNumber: { $eq: 'TTT6-4203485-8379924' },
|
|
16
|
+
// project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
17
|
+
project: { id: { $eq: 'ttts-development' } },
|
|
15
18
|
// tslint:disable-next-line:no-magic-numbers
|
|
16
|
-
$slice: [
|
|
19
|
+
$slice: [limit * (page - 1), limit]
|
|
17
20
|
}
|
|
18
21
|
);
|
|
19
22
|
console.log(result);
|
|
@@ -3,10 +3,6 @@ import * as factory from './factory';
|
|
|
3
3
|
* 注文配送メッセージを作成する
|
|
4
4
|
*/
|
|
5
5
|
export declare function createSendOrderMessage(params: {
|
|
6
|
-
project: {
|
|
7
|
-
id: string;
|
|
8
|
-
typeOf: factory.organizationType.Project;
|
|
9
|
-
};
|
|
10
6
|
order: factory.order.IOrder;
|
|
11
7
|
email?: factory.creativeWork.message.email.ICustomization;
|
|
12
8
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
@@ -15,11 +15,14 @@ function minimizeSuperEvent(params) {
|
|
|
15
15
|
: undefined), (typeof params.superEventFromDB.workPerformed.contentRating === 'string')
|
|
16
16
|
? { contentRating: params.superEventFromDB.workPerformed.contentRating }
|
|
17
17
|
: undefined);
|
|
18
|
-
const location = Object.assign(
|
|
18
|
+
const location = Object.assign({ typeOf: factory.placeType.MovieTheater, id: params.superEventFromDB.location.id, branchCode: params.superEventFromDB.location.branchCode }, (params.superEventFromDB.location.name !== undefined)
|
|
19
19
|
? { name: params.superEventFromDB.location.name }
|
|
20
|
-
: undefined
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
: undefined
|
|
21
|
+
// 廃止(2024-03-05~)
|
|
22
|
+
// ...(typeof params.superEventFromDB.location.kanaName === 'string')
|
|
23
|
+
// ? { kanaName: params.superEventFromDB.location.kanaName }
|
|
24
|
+
// : undefined
|
|
25
|
+
);
|
|
23
26
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.eventType.ScreeningEventSeries,
|
|
24
27
|
// 不要なので廃止(2023-06-09~)
|
|
25
28
|
// project: { typeOf: chevre.factory.organizationType.Project, id: params.project.id },
|
|
@@ -10,17 +10,18 @@ type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'>
|
|
|
10
10
|
export declare class MongoRepository {
|
|
11
11
|
private readonly orderModel;
|
|
12
12
|
constructor(connection: Connection);
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 取引進行中の注文からacceptedOffersを検索する
|
|
15
|
+
*/
|
|
16
|
+
findAcceptedOffersByOrderNumber(params: {
|
|
14
17
|
orderNumber: {
|
|
15
18
|
$eq: string;
|
|
16
19
|
};
|
|
17
|
-
}): Promise<
|
|
20
|
+
}): Promise<factory.order.IAcceptedOffer<factory.order.IItemOffered>[]>;
|
|
18
21
|
/**
|
|
19
22
|
* 注文を受注する
|
|
20
23
|
*/
|
|
21
|
-
placeOrder(order: Omit<factory.order.IOrder, 'id'>
|
|
22
|
-
acceptedOffers?: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
23
|
-
}): Promise<void>;
|
|
24
|
+
placeOrder(order: Omit<factory.order.IOrder, 'id'>): Promise<void>;
|
|
24
25
|
acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongodb").UpdateResult | undefined>;
|
|
25
26
|
/**
|
|
26
27
|
* serialNumberからオファーを除外する
|
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.MongoRepository = void 0;
|
|
24
13
|
const createDebug = require("debug");
|
|
@@ -32,30 +21,32 @@ class MongoRepository {
|
|
|
32
21
|
constructor(connection) {
|
|
33
22
|
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
34
23
|
}
|
|
35
|
-
|
|
24
|
+
/**
|
|
25
|
+
* 取引進行中の注文からacceptedOffersを検索する
|
|
26
|
+
*/
|
|
27
|
+
findAcceptedOffersByOrderNumber(params) {
|
|
36
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
|
|
38
|
-
return this.orderModel.find({
|
|
29
|
+
const doc = yield this.orderModel.findOne({
|
|
39
30
|
orderNumber: { $eq: params.orderNumber.$eq },
|
|
40
31
|
typeOf: { $eq: factory.transactionType.PlaceOrder }
|
|
41
|
-
})
|
|
42
|
-
.
|
|
43
|
-
.
|
|
32
|
+
}, { acceptedOffers: 1 })
|
|
33
|
+
.lean()
|
|
34
|
+
.exec();
|
|
35
|
+
if (doc === null) {
|
|
36
|
+
throw new factory.errors.NotFound('orderInTransaction');
|
|
37
|
+
}
|
|
38
|
+
return doc.acceptedOffers;
|
|
44
39
|
});
|
|
45
40
|
}
|
|
46
41
|
/**
|
|
47
42
|
* 注文を受注する
|
|
48
43
|
*/
|
|
49
|
-
placeOrder(order
|
|
50
|
-
// options: {
|
|
51
|
-
// ignoreAccpetedOffersFromResult: boolean;
|
|
52
|
-
// }
|
|
53
|
-
) {
|
|
44
|
+
placeOrder(order) {
|
|
54
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
46
|
let setFields;
|
|
56
47
|
// acceptedOffersを上書きしない
|
|
57
|
-
const { acceptedOffers
|
|
58
|
-
setFields =
|
|
48
|
+
// const { acceptedOffers, ...orderWithoutAcceptedOffers } = order;
|
|
49
|
+
setFields = order;
|
|
59
50
|
debug('placing an order...', order.orderNumber, 'setFields:', setFields);
|
|
60
51
|
// typeOf:PlaceOrderのドキュメントが存在すれば、typeOf:Orderに変更する
|
|
61
52
|
yield this.orderModel.updateOne({
|
|
@@ -7,4 +7,5 @@ export declare function createOwnershipInfosFromOrder(params: {
|
|
|
7
7
|
order: Pick<factory.order.IOrder, 'orderDate' | 'project' | 'customer' | 'orderNumber' | 'seller'> & {
|
|
8
8
|
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
9
9
|
};
|
|
10
|
+
offerIndexBase: number;
|
|
10
11
|
}): IOwnershipInfo[];
|
|
@@ -19,7 +19,12 @@ function createOwnershipInfosFromOrder(params) {
|
|
|
19
19
|
let ownershipInfo;
|
|
20
20
|
const ownedFrom = moment(params.order.orderDate)
|
|
21
21
|
.toDate();
|
|
22
|
-
const identifier = createOwnershipInfoIdentifier({
|
|
22
|
+
const identifier = createOwnershipInfoIdentifier({
|
|
23
|
+
order: params.order,
|
|
24
|
+
itemOffered,
|
|
25
|
+
offerIndex,
|
|
26
|
+
offerIndexBase: params.offerIndexBase
|
|
27
|
+
});
|
|
23
28
|
const acquiredFrom = createAcquiredFrom(params);
|
|
24
29
|
const ownedBy = createOwnedby(params);
|
|
25
30
|
const itemOfferedType = itemOffered.typeOf;
|
|
@@ -60,7 +65,7 @@ function createOwnershipInfosFromOrder(params) {
|
|
|
60
65
|
}
|
|
61
66
|
exports.createOwnershipInfosFromOrder = createOwnershipInfosFromOrder;
|
|
62
67
|
function createOwnershipInfoIdentifier(params) {
|
|
63
|
-
return util.format('%s-%s-%s-%s', params.order.customer.id, params.itemOffered.typeOf, params.order.orderNumber, params.offerIndex);
|
|
68
|
+
return util.format('%s-%s-%s-%s', params.order.customer.id, params.itemOffered.typeOf, params.order.orderNumber, (params.offerIndexBase + params.offerIndex));
|
|
64
69
|
}
|
|
65
70
|
function createAcquiredFrom(params) {
|
|
66
71
|
// 最低限の情報に絞る
|
|
@@ -42,7 +42,8 @@ function createEvent(params) {
|
|
|
42
42
|
const location = {
|
|
43
43
|
branchCode: movieTheater.branchCode,
|
|
44
44
|
id: movieTheater.id,
|
|
45
|
-
|
|
45
|
+
// 廃止(2024-03-05~)
|
|
46
|
+
// kanaName: movieTheater.kanaName,
|
|
46
47
|
name: movieTheater.name,
|
|
47
48
|
typeOf: factory.placeType.MovieTheater
|
|
48
49
|
};
|
|
@@ -232,7 +232,7 @@ function saveScreeningEventSeries(params) {
|
|
|
232
232
|
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
233
233
|
project: { id: { $eq: params.project.id } },
|
|
234
234
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
235
|
-
}, [], []);
|
|
235
|
+
}, ['additionalProperty', 'codeValue'], []);
|
|
236
236
|
const screeningEventSerieses = filmsFromCOA.map((filmFromCOA) => {
|
|
237
237
|
return createScreeningEventSeriesFromCOA({
|
|
238
238
|
project: project,
|
|
@@ -570,19 +570,7 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
570
570
|
titleBranchNum: params.filmFromCOA.titleBranchNum
|
|
571
571
|
});
|
|
572
572
|
const { additionalProperty, coaInfo } = createScreeningEventSeriesAdditionalPropertyFromCOA(params);
|
|
573
|
-
|
|
574
|
-
// flgMvtkUseはムビチケ、MGチケットの両方に適用される
|
|
575
|
-
if (coaInfo.flgMvtkUse === '1') {
|
|
576
|
-
// no op
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
if (!Array.isArray(unacceptedPaymentMethod)) {
|
|
580
|
-
unacceptedPaymentMethod = [];
|
|
581
|
-
}
|
|
582
|
-
// flgMvtkUseで決済方法区分から動的に
|
|
583
|
-
const unavailablePaymentMethodTypes = params.availablePaymentMethodTypes.filter((categoryCode) => { var _a, _b; return ((_b = (_a = categoryCode.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === 'flgMvtkUse')) === null || _b === void 0 ? void 0 : _b.value) === '1'; });
|
|
584
|
-
unacceptedPaymentMethod.push(...unavailablePaymentMethodTypes.map((c) => c.codeValue));
|
|
585
|
-
}
|
|
573
|
+
const { unacceptedPaymentMethod } = createScreeningEventSeriesUnacceptedPaymentMethodFromCOA(params);
|
|
586
574
|
const workPerformed = Object.assign({ id: `${params.movieTheater.branchCode}-${params.filmFromCOA.titleCode}`, identifier: params.filmFromCOA.titleCode, name: {
|
|
587
575
|
ja: params.filmFromCOA.titleNameOrig
|
|
588
576
|
}, duration: moment.duration(params.filmFromCOA.showTime, 'm')
|
|
@@ -605,7 +593,8 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
605
593
|
id: (params.movieTheater.id !== undefined) ? params.movieTheater.id : '',
|
|
606
594
|
branchCode: params.movieTheater.branchCode,
|
|
607
595
|
name: params.movieTheater.name,
|
|
608
|
-
|
|
596
|
+
// 廃止(2024-03-05~)
|
|
597
|
+
// kanaName: params.movieTheater.kanaName,
|
|
609
598
|
typeOf: params.movieTheater.typeOf
|
|
610
599
|
},
|
|
611
600
|
// 必須化(2023-07-12~)
|
|
@@ -623,15 +612,7 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
623
612
|
};
|
|
624
613
|
}
|
|
625
614
|
function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
|
|
626
|
-
const coaInfo = {
|
|
627
|
-
titleBranchNum: params.filmFromCOA.titleBranchNum,
|
|
628
|
-
kbnEirin: params.eirinKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnEirin)[0],
|
|
629
|
-
kbnEizou: params.eizouKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnEizou)[0],
|
|
630
|
-
kbnJoueihousiki: params.joueihousikiKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnJoueihousiki)[0],
|
|
631
|
-
kbnJimakufukikae: params.jimakufukikaeKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnJimakufukikae)[0],
|
|
632
|
-
flgMvtkUse: params.filmFromCOA.flgMvtkUse,
|
|
633
|
-
dateMvtkBegin: params.filmFromCOA.dateMvtkBegin
|
|
634
|
-
};
|
|
615
|
+
const coaInfo = Object.assign(Object.assign({ titleBranchNum: params.filmFromCOA.titleBranchNum, kbnEirin: params.eirinKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnEirin)[0], kbnEizou: params.eizouKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnEizou)[0], kbnJoueihousiki: params.joueihousikiKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnJoueihousiki)[0], kbnJimakufukikae: params.jimakufukikaeKubuns.filter((k) => k.kubunCode === params.filmFromCOA.kbnJimakufukikae)[0], flgMvtkUse: params.filmFromCOA.flgMvtkUse, dateMvtkBegin: params.filmFromCOA.dateMvtkBegin }, (typeof params.filmFromCOA.flgMgtkUse === 'string') ? { flgMgtkUse: params.filmFromCOA.flgMgtkUse } : undefined), (typeof params.filmFromCOA.dateMgtkBegin === 'string') ? { dateMgtkBegin: params.filmFromCOA.dateMgtkBegin } : undefined);
|
|
635
616
|
return {
|
|
636
617
|
coaInfo,
|
|
637
618
|
additionalProperty: [
|
|
@@ -640,6 +621,34 @@ function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
|
|
|
640
621
|
]
|
|
641
622
|
};
|
|
642
623
|
}
|
|
624
|
+
function createScreeningEventSeriesUnacceptedPaymentMethodFromCOA(params) {
|
|
625
|
+
let unacceptedPaymentMethod;
|
|
626
|
+
// flgMvtkUseはムビチケ、MGチケットの両方に適用される(<-flgMgtkUseが追加されるまで)(~2024-03-05)
|
|
627
|
+
if (params.filmFromCOA.flgMvtkUse === '1') {
|
|
628
|
+
// no op
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
if (!Array.isArray(unacceptedPaymentMethod)) {
|
|
632
|
+
unacceptedPaymentMethod = [];
|
|
633
|
+
}
|
|
634
|
+
// flgMvtkUseで決済方法区分から動的に
|
|
635
|
+
unacceptedPaymentMethod.push(...params.availablePaymentMethodTypes.filter(({ additionalProperty }) => { var _a; return ((_a = additionalProperty === null || additionalProperty === void 0 ? void 0 : additionalProperty.find(({ name }) => name === 'flgMvtkUse')) === null || _a === void 0 ? void 0 : _a.value) === '1'; })
|
|
636
|
+
.map(({ codeValue }) => codeValue));
|
|
637
|
+
}
|
|
638
|
+
if (params.filmFromCOA.flgMgtkUse === '0') {
|
|
639
|
+
if (!Array.isArray(unacceptedPaymentMethod)) {
|
|
640
|
+
unacceptedPaymentMethod = [];
|
|
641
|
+
}
|
|
642
|
+
// flgMgtkUseで決済方法区分から動的に
|
|
643
|
+
unacceptedPaymentMethod.push(...params.availablePaymentMethodTypes.filter(({ additionalProperty }) => { var _a; return ((_a = additionalProperty === null || additionalProperty === void 0 ? void 0 : additionalProperty.find(({ name }) => name === 'flgMgtkUse')) === null || _a === void 0 ? void 0 : _a.value) === '1'; })
|
|
644
|
+
.map(({ codeValue }) => codeValue));
|
|
645
|
+
}
|
|
646
|
+
if (Array.isArray(unacceptedPaymentMethod)) {
|
|
647
|
+
// 重複排除
|
|
648
|
+
unacceptedPaymentMethod = [...new Set(unacceptedPaymentMethod)];
|
|
649
|
+
}
|
|
650
|
+
return { unacceptedPaymentMethod };
|
|
651
|
+
}
|
|
643
652
|
/**
|
|
644
653
|
* COA情報からイベントIDを作成する
|
|
645
654
|
*/
|
|
@@ -13,6 +13,15 @@ export declare function createActionAttributes(params: {
|
|
|
13
13
|
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
14
14
|
transactionNumber: string;
|
|
15
15
|
}): factory.action.authorize.offer.product.IAttributes;
|
|
16
|
+
type IResultAcceptedOffer = factory.action.authorize.offer.product.IResultAcceptedOffer;
|
|
17
|
+
export declare function responseBody2resultAcceptedOffer(params: {
|
|
18
|
+
project: {
|
|
19
|
+
id: string;
|
|
20
|
+
typeOf: factory.organizationType.Project;
|
|
21
|
+
};
|
|
22
|
+
responseBody: factory.assetTransaction.registerService.ITransaction;
|
|
23
|
+
acceptedOffer: factory.action.authorize.offer.product.IObject;
|
|
24
|
+
}): IResultAcceptedOffer;
|
|
16
25
|
export declare function createResult(params: {
|
|
17
26
|
project: {
|
|
18
27
|
id: string;
|
|
@@ -22,3 +31,4 @@ export declare function createResult(params: {
|
|
|
22
31
|
responseBody: factory.assetTransaction.registerService.ITransaction;
|
|
23
32
|
acceptedOffer: factory.action.authorize.offer.product.IObject;
|
|
24
33
|
}): factory.action.authorize.offer.product.IResult;
|
|
34
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createResult = exports.createActionAttributes = exports.createRegisterServiceStartParams = void 0;
|
|
3
|
+
exports.createResult = exports.responseBody2resultAcceptedOffer = exports.createActionAttributes = exports.createRegisterServiceStartParams = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("../../../factory");
|
|
6
6
|
function createRegisterServiceStartParams(params) {
|
|
@@ -150,6 +150,7 @@ function responseBody2resultAcceptedOffer(params) {
|
|
|
150
150
|
}
|
|
151
151
|
return acceptedOffers;
|
|
152
152
|
}
|
|
153
|
+
exports.responseBody2resultAcceptedOffer = responseBody2resultAcceptedOffer;
|
|
153
154
|
function createResult(params) {
|
|
154
155
|
const acceptedOffers4result = responseBody2resultAcceptedOffer(params);
|
|
155
156
|
// 金額計算
|
|
@@ -147,11 +147,12 @@ function authorize(params) {
|
|
|
147
147
|
});
|
|
148
148
|
requestBody = startParams;
|
|
149
149
|
responseBody = yield RegisterServiceTransaction.start(startParams)(repos);
|
|
150
|
+
const acceptedOffers4result = (0, factory_1.responseBody2resultAcceptedOffer)({ project: action.project, responseBody, acceptedOffer });
|
|
150
151
|
result = (0, factory_1.createResult)({ project: action.project, requestBody, responseBody, acceptedOffer });
|
|
151
152
|
yield (0, any_1.acceptOffer)({
|
|
152
153
|
project: transaction.project,
|
|
153
154
|
purpose: { id: transaction.id },
|
|
154
|
-
acceptedOffers:
|
|
155
|
+
acceptedOffers: acceptedOffers4result
|
|
155
156
|
})(repos);
|
|
156
157
|
}
|
|
157
158
|
catch (error) {
|
|
@@ -81,7 +81,8 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
81
81
|
order: Object.assign(Object.assign({}, order), { acceptedOffers: yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
82
82
|
orderNumber: { $eq: order.orderNumber },
|
|
83
83
|
project: { id: { $eq: order.project.id } }
|
|
84
|
-
}) })
|
|
84
|
+
}) }),
|
|
85
|
+
offerIndexBase: 0
|
|
85
86
|
});
|
|
86
87
|
const ownershipIdentifiers = ownershipInfos.map((o) => String(o.identifier));
|
|
87
88
|
if (ownershipIdentifiers.length > 0) {
|
|
@@ -18,75 +18,9 @@ const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusCha
|
|
|
18
18
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
19
19
|
const debug = createDebug('chevre-domain:service:order');
|
|
20
20
|
function createOrder(params) {
|
|
21
|
-
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
22
|
-
// const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
23
|
-
// ? params.acceptedOffers.map((o) => {
|
|
24
|
-
// if (o.itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
25
|
-
// let itemOffered = o.itemOffered;
|
|
26
|
-
// const reservationFor = itemOffered.reservationFor;
|
|
27
|
-
// itemOffered = {
|
|
28
|
-
// ...itemOffered,
|
|
29
|
-
// reservationFor: {
|
|
30
|
-
// ...reservationFor,
|
|
31
|
-
// ...(reservationFor.doorTime !== undefined && reservationFor.doorTime !== null)
|
|
32
|
-
// ? {
|
|
33
|
-
// doorTime: moment(reservationFor.doorTime)
|
|
34
|
-
// .toDate()
|
|
35
|
-
// }
|
|
36
|
-
// : undefined,
|
|
37
|
-
// ...(reservationFor.endDate !== undefined)
|
|
38
|
-
// ? {
|
|
39
|
-
// endDate: moment(reservationFor.endDate)
|
|
40
|
-
// .toDate()
|
|
41
|
-
// }
|
|
42
|
-
// : undefined,
|
|
43
|
-
// ...(reservationFor.startDate !== undefined)
|
|
44
|
-
// ? {
|
|
45
|
-
// startDate: moment(reservationFor.startDate)
|
|
46
|
-
// .toDate()
|
|
47
|
-
// }
|
|
48
|
-
// : undefined
|
|
49
|
-
// }
|
|
50
|
-
// };
|
|
51
|
-
// return {
|
|
52
|
-
// ...o,
|
|
53
|
-
// itemOffered
|
|
54
|
-
// };
|
|
55
|
-
// } else if (o.itemOffered.typeOf === factory.reservationType.BusReservation) {
|
|
56
|
-
// let itemOffered = o.itemOffered;
|
|
57
|
-
// const reservationFor = itemOffered.reservationFor;
|
|
58
|
-
// itemOffered = {
|
|
59
|
-
// ...itemOffered,
|
|
60
|
-
// reservationFor: {
|
|
61
|
-
// ...reservationFor,
|
|
62
|
-
// ...(reservationFor.arrivalTime !== undefined)
|
|
63
|
-
// ? {
|
|
64
|
-
// arrivalTime: moment(reservationFor.arrivalTime)
|
|
65
|
-
// .toDate()
|
|
66
|
-
// }
|
|
67
|
-
// : undefined,
|
|
68
|
-
// ...(reservationFor.departureTime !== undefined)
|
|
69
|
-
// ? {
|
|
70
|
-
// departureTime: moment(reservationFor.departureTime)
|
|
71
|
-
// .toDate()
|
|
72
|
-
// }
|
|
73
|
-
// : undefined
|
|
74
|
-
// }
|
|
75
|
-
// };
|
|
76
|
-
// return {
|
|
77
|
-
// ...o,
|
|
78
|
-
// itemOffered
|
|
79
|
-
// };
|
|
80
|
-
// } else {
|
|
81
|
-
// return o;
|
|
82
|
-
// }
|
|
83
|
-
// })
|
|
84
|
-
// : [];
|
|
85
21
|
const orderedItems = (Array.isArray(params.orderedItem)) ? params.orderedItem : [];
|
|
86
22
|
return Object.assign(Object.assign(Object.assign({}, params), { orderDate: moment(params.orderDate)
|
|
87
|
-
.toDate(),
|
|
88
|
-
// acceptedOffers,
|
|
89
|
-
orderedItem: orderedItems }), (params.dateReturned !== null && params.dateReturned !== undefined)
|
|
23
|
+
.toDate(), orderedItem: orderedItems }), (params.dateReturned !== null && params.dateReturned !== undefined)
|
|
90
24
|
? {
|
|
91
25
|
dateReturned: moment(params.dateReturned)
|
|
92
26
|
.toDate()
|
|
@@ -124,7 +58,6 @@ function createOrderFromBody(params) {
|
|
|
124
58
|
throw new factory.errors.NotFound('transaction.result.order');
|
|
125
59
|
}
|
|
126
60
|
order = createOrder(orderByTransaction);
|
|
127
|
-
// const { result, ...placeOrderTransaction } = placeOrderTransactionWithResult;
|
|
128
61
|
return { order, placeOrderTransaction: placeOrderTransactionWithResult };
|
|
129
62
|
});
|
|
130
63
|
}
|
|
@@ -103,15 +103,20 @@ function sendOrder(params) {
|
|
|
103
103
|
createOwnerships = true;
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
|
+
const offerIndexBase = (limit * (page - 1));
|
|
106
107
|
const searchSlicedAcceptedOffersResult = yield repos.acceptedOffer.searchSlicedAcceptedOffersByOrderNumber({
|
|
107
|
-
$slice: [
|
|
108
|
+
$slice: [offerIndexBase, limit],
|
|
108
109
|
orderNumber: { $eq: order.orderNumber },
|
|
109
110
|
project: { id: { $eq: order.project.id } }
|
|
110
111
|
});
|
|
111
112
|
acceptedOffers = searchSlicedAcceptedOffersResult.acceptedOffers;
|
|
113
|
+
debug('delivering...', order.orderNumber, acceptedOffers.map((offer) => `${offer.itemOffered.id}`), params.object.acceptedOffers, 'offerIndexBase:', offerIndexBase);
|
|
112
114
|
// 所有権作成
|
|
113
115
|
if (createOwnerships) {
|
|
114
|
-
ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({
|
|
116
|
+
ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({
|
|
117
|
+
order: Object.assign(Object.assign({}, order), { acceptedOffers }),
|
|
118
|
+
offerIndexBase
|
|
119
|
+
});
|
|
115
120
|
ownershipInfos = yield Promise.all(ownershipInfos.map((ownershipInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
116
121
|
return repos.ownershipInfo.createIfNotExistByIdentifier(ownershipInfo);
|
|
117
122
|
})));
|
|
@@ -21,7 +21,7 @@ export declare function creatPayTransactionStartParams(params: {
|
|
|
21
21
|
export declare function createAuthorizeResult(params: {
|
|
22
22
|
object: factory.action.authorize.paymentMethod.any.IObject;
|
|
23
23
|
payTransaction: factory.assetTransaction.pay.ITransaction;
|
|
24
|
-
}): factory.action.authorize.paymentMethod.any.
|
|
24
|
+
}): factory.action.authorize.paymentMethod.any.IResultAsInvoice[];
|
|
25
25
|
/**
|
|
26
26
|
* 通知対象としてのアクションを最適化
|
|
27
27
|
*/
|
|
@@ -2,6 +2,7 @@ import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
|
2
2
|
import type { MongoRepository as CodeRepo } from '../../../repo/code';
|
|
3
3
|
import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
4
4
|
import type { MongoRepository as EmailMessageRepo } from '../../../repo/emailMessage';
|
|
5
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
5
6
|
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
6
7
|
import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
7
8
|
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
@@ -13,6 +14,7 @@ interface IConfirmOperationRepos {
|
|
|
13
14
|
emailMessage?: EmailMessageRepo;
|
|
14
15
|
project: ProjectRepo;
|
|
15
16
|
transaction: TransactionRepo;
|
|
17
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
16
18
|
orderNumber: OrderNumberRepo;
|
|
17
19
|
confirmationNumber: ConfirmationNumberRepo;
|
|
18
20
|
}
|
|
@@ -27,6 +29,10 @@ type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
|
|
|
27
29
|
* 同期的にに注文コードを発行する場合に指定
|
|
28
30
|
*/
|
|
29
31
|
publishCodeExpiresInSeconds?: number;
|
|
32
|
+
/**
|
|
33
|
+
* 取引検証時にorderInTransactionからオファーを検索するかどうか
|
|
34
|
+
*/
|
|
35
|
+
useAcceptedOffersFromOrderInTransaction: boolean;
|
|
30
36
|
};
|
|
31
37
|
};
|
|
32
38
|
/**
|