@chevre/domain 21.25.0-alpha.2 → 21.25.0-alpha.4
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/lib/chevre/repo/orderInTransaction.d.ts +5 -2
- package/lib/chevre/repo/orderInTransaction.js +12 -6
- 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/payment/any/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +2 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +113 -26
- 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 +85 -75
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +8 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +79 -107
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -10,11 +10,14 @@ 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
|
*/
|
|
@@ -32,15 +32,21 @@ class MongoRepository {
|
|
|
32
32
|
constructor(connection) {
|
|
33
33
|
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 取引進行中の注文からacceptedOffersを検索する
|
|
37
|
+
*/
|
|
38
|
+
findAcceptedOffersByOrderNumber(params) {
|
|
36
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
|
|
38
|
-
return this.orderModel.find({
|
|
40
|
+
const doc = yield this.orderModel.findOne({
|
|
39
41
|
orderNumber: { $eq: params.orderNumber.$eq },
|
|
40
42
|
typeOf: { $eq: factory.transactionType.PlaceOrder }
|
|
41
|
-
})
|
|
42
|
-
.
|
|
43
|
-
.
|
|
43
|
+
}, { acceptedOffers: 1 })
|
|
44
|
+
.lean()
|
|
45
|
+
.exec();
|
|
46
|
+
if (doc === null) {
|
|
47
|
+
throw new factory.errors.NotFound('orderInTransaction');
|
|
48
|
+
}
|
|
49
|
+
return doc.acceptedOffers;
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
@@ -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) {
|
|
@@ -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
|
}
|
|
@@ -8,22 +8,12 @@ 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.confirm = void 0;
|
|
24
13
|
const moment = require("moment");
|
|
25
14
|
const errorHandler_1 = require("../../../errorHandler");
|
|
26
15
|
const factory = require("../../../factory");
|
|
16
|
+
const availableProductTypes_1 = require("../../../factory/availableProductTypes");
|
|
27
17
|
const potentialActions_1 = require("./potentialActions");
|
|
28
18
|
const publishCode_1 = require("./publishCode");
|
|
29
19
|
const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
|
|
@@ -78,7 +68,15 @@ function confirm(params) {
|
|
|
78
68
|
expiresInSeconds: publishCodeExpiresInSeconds
|
|
79
69
|
})(repos);
|
|
80
70
|
}
|
|
81
|
-
const
|
|
71
|
+
// const acceptedOffers = await repos.orderInTransaction.findAcceptedOffersByOrderNumber({ orderNumber: { $eq: orderNumber } });
|
|
72
|
+
const { acceptedOffers, authorizePaymentActions, authorizeEventServiceOfferActions, authorizeMoneyTansferActions, authorizeProductOfferActions } = dissolveAuthorizeActions(completedAuthorizeActions);
|
|
73
|
+
const { result, eventId, reservationIds } = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizePaymentActions,
|
|
74
|
+
authorizeEventServiceOfferActions,
|
|
75
|
+
authorizeMoneyTansferActions,
|
|
76
|
+
authorizeProductOfferActions,
|
|
77
|
+
// authorizeActions: completedAuthorizeActions,
|
|
78
|
+
code,
|
|
79
|
+
acceptedOffers }));
|
|
82
80
|
// デフォルトEメールメッセージを検索
|
|
83
81
|
let emailMessageOnOrderSent;
|
|
84
82
|
if (repos.emailMessage !== undefined) {
|
|
@@ -125,7 +123,64 @@ function confirm(params) {
|
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
exports.confirm = confirm;
|
|
128
|
-
|
|
126
|
+
/**
|
|
127
|
+
* 全承認アクションを分解する
|
|
128
|
+
*/
|
|
129
|
+
function dissolveAuthorizeActions(completedAuthorizeActions) {
|
|
130
|
+
const acceptedOffers = [];
|
|
131
|
+
const authorizePaymentActions = [];
|
|
132
|
+
const authorizeEventServiceOfferActions = [];
|
|
133
|
+
const authorizeMoneyTansferActions = [];
|
|
134
|
+
const authorizeProductOfferActions = [];
|
|
135
|
+
completedAuthorizeActions.forEach((a) => {
|
|
136
|
+
var _a;
|
|
137
|
+
if (Array.isArray(a.object)) {
|
|
138
|
+
if (a.object.length > 0
|
|
139
|
+
&& a.object.every(({ typeOf }) => typeOf === factory.offerType.Offer)
|
|
140
|
+
&& a.object.every(({ itemOffered }) => availableProductTypes_1.availableProductTypes.indexOf(itemOffered.typeOf) >= 0)) {
|
|
141
|
+
authorizeProductOfferActions.push(a);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation) {
|
|
146
|
+
authorizeEventServiceOfferActions.push(a);
|
|
147
|
+
}
|
|
148
|
+
else if (a.object.typeOf === factory.offerType.Offer
|
|
149
|
+
&& ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer) {
|
|
150
|
+
authorizeMoneyTansferActions.push(a);
|
|
151
|
+
}
|
|
152
|
+
else if (a.object.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment) {
|
|
153
|
+
authorizePaymentActions.push(a);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
authorizeEventServiceOfferActions.forEach(({ result }) => {
|
|
158
|
+
const acceptedOffersByAuthorizeAction = result === null || result === void 0 ? void 0 : result.acceptedOffers;
|
|
159
|
+
if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
160
|
+
acceptedOffers.push(...acceptedOffersByAuthorizeAction);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
authorizeProductOfferActions.forEach(({ result }) => {
|
|
164
|
+
const acceptedOffersByAuthorizeAction = result === null || result === void 0 ? void 0 : result.acceptedOffers;
|
|
165
|
+
if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
166
|
+
acceptedOffers.push(...acceptedOffersByAuthorizeAction);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
authorizeMoneyTansferActions.forEach(({ result }) => {
|
|
170
|
+
const acceptedOffersByAuthorizeAction = result === null || result === void 0 ? void 0 : result.acceptedOffers;
|
|
171
|
+
if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
172
|
+
acceptedOffers.push(...acceptedOffersByAuthorizeAction);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
acceptedOffers,
|
|
177
|
+
authorizePaymentActions,
|
|
178
|
+
authorizeEventServiceOfferActions,
|
|
179
|
+
authorizeProductOfferActions,
|
|
180
|
+
authorizeMoneyTansferActions
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function createReservationIdsResult(order, acceptedOffers) {
|
|
129
184
|
var _a;
|
|
130
185
|
let eventId = '';
|
|
131
186
|
const reservationIds = [];
|
|
@@ -137,8 +192,8 @@ function createReservationIdsResult(order) {
|
|
|
137
192
|
// イベントIDが1つのみに対応
|
|
138
193
|
if (eventIdsByOrder.length === 1) {
|
|
139
194
|
eventId = eventIdsByOrder[0];
|
|
140
|
-
if (Array.isArray(
|
|
141
|
-
|
|
195
|
+
if (Array.isArray(acceptedOffers)) {
|
|
196
|
+
acceptedOffers.forEach((o) => {
|
|
142
197
|
if (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
143
198
|
|| o.itemOffered.typeOf === factory.reservationType.BusReservation) {
|
|
144
199
|
reservationIds.push(o.itemOffered.id);
|
|
@@ -149,10 +204,31 @@ function createReservationIdsResult(order) {
|
|
|
149
204
|
}
|
|
150
205
|
return { eventId, reservationIds };
|
|
151
206
|
}
|
|
207
|
+
// tslint:disable-next-line:max-func-body-length
|
|
152
208
|
function createResult(params) {
|
|
153
209
|
const transaction = params.transaction;
|
|
210
|
+
const eventReservationAcceptedOffers = [];
|
|
211
|
+
const productAcceptedOffers = [];
|
|
212
|
+
const moneyTransferAcceptedOffers = [];
|
|
213
|
+
params.acceptedOffers.forEach((acceptedOffer) => {
|
|
214
|
+
const itemOfferedTypeOf = acceptedOffer.itemOffered.typeOf;
|
|
215
|
+
switch (itemOfferedTypeOf) {
|
|
216
|
+
case factory.reservationType.BusReservation:
|
|
217
|
+
case factory.reservationType.EventReservation:
|
|
218
|
+
eventReservationAcceptedOffers.push(acceptedOffer);
|
|
219
|
+
break;
|
|
220
|
+
case factory.permit.PermitType.Permit:
|
|
221
|
+
productAcceptedOffers.push(acceptedOffer);
|
|
222
|
+
break;
|
|
223
|
+
case factory.actionType.MoneyTransfer:
|
|
224
|
+
moneyTransferAcceptedOffers.push(acceptedOffer);
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
throw new factory.errors.NotImplemented(`${itemOfferedTypeOf} not implemented`);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
154
230
|
// 取引の確定条件が全て整っているかどうか確認
|
|
155
|
-
(0, validation_1.validateTransaction)(transaction, params.
|
|
231
|
+
(0, validation_1.validateTransaction)(transaction, params.authorizePaymentActions, params.authorizeEventServiceOfferActions, params.authorizeMoneyTansferActions, params.authorizeProductOfferActions, eventReservationAcceptedOffers);
|
|
156
232
|
// 注文作成
|
|
157
233
|
const order = (0, result_1.createOrder)({
|
|
158
234
|
orderNumber: params.orderNumber,
|
|
@@ -160,17 +236,21 @@ function createResult(params) {
|
|
|
160
236
|
orderDate: params.result.order.orderDate,
|
|
161
237
|
orderStatus: factory.orderStatus.OrderPaymentDue,
|
|
162
238
|
isGift: false,
|
|
163
|
-
|
|
239
|
+
authorizePaymentActions: params.authorizePaymentActions,
|
|
240
|
+
eventReservationAcceptedOffers,
|
|
241
|
+
productAcceptedOffers,
|
|
242
|
+
moneyTransferAcceptedOffers
|
|
164
243
|
});
|
|
165
244
|
(0, validation_1.validateEventOffers)({
|
|
166
|
-
transaction: transaction,
|
|
245
|
+
// transaction: transaction,
|
|
167
246
|
order: order,
|
|
168
|
-
|
|
247
|
+
authorizeEventServiceOfferActions: params.authorizeEventServiceOfferActions
|
|
169
248
|
});
|
|
170
249
|
// 注文オファー検証
|
|
171
250
|
(0, validation_1.validateNumItems)({
|
|
172
251
|
order: order,
|
|
173
|
-
result: params.result
|
|
252
|
+
result: params.result,
|
|
253
|
+
acceptedOffers: params.acceptedOffers
|
|
174
254
|
});
|
|
175
255
|
// 注文アイテム検証(2024-01-20~)
|
|
176
256
|
(0, validation_1.validateOrderedItem)({
|
|
@@ -187,20 +267,27 @@ function createResult(params) {
|
|
|
187
267
|
order.confirmationNumber = confirmationNumber;
|
|
188
268
|
order.identifier = identifier;
|
|
189
269
|
order.url = url;
|
|
190
|
-
const authorizeActions =
|
|
191
|
-
|
|
192
|
-
|
|
270
|
+
const authorizeActions = [
|
|
271
|
+
...params.authorizePaymentActions.map(({ id }) => ({ id })),
|
|
272
|
+
...params.authorizeEventServiceOfferActions.map(({ id }) => ({ id })),
|
|
273
|
+
...params.authorizeProductOfferActions.map(({ id }) => ({ id })),
|
|
274
|
+
...params.authorizeMoneyTansferActions.map(({ id }) => ({ id }))
|
|
275
|
+
];
|
|
276
|
+
// params.authorizeActions.map(({ id }) => ({ id }));
|
|
277
|
+
// const { acceptedOffers, ...orderWithoutAcceptedOffers } = order;
|
|
278
|
+
// const orderAsResult: factory.transaction.placeOrder.IOrderAsResult = order;
|
|
193
279
|
let eventId;
|
|
194
280
|
let reservationIds;
|
|
195
281
|
if (params.options.expectsReservationIds) {
|
|
196
282
|
// ttts対応として予約IDリストとイベントIDを返却
|
|
197
|
-
const reservationIdsResult = createReservationIdsResult(order);
|
|
283
|
+
const reservationIdsResult = createReservationIdsResult(order, params.acceptedOffers);
|
|
198
284
|
eventId = reservationIdsResult.eventId;
|
|
199
285
|
reservationIds = reservationIdsResult.reservationIds;
|
|
200
286
|
}
|
|
201
287
|
return {
|
|
202
|
-
orderWithAcceptedOffers: order,
|
|
203
|
-
result: Object.assign({ order
|
|
288
|
+
// orderWithAcceptedOffers: order,
|
|
289
|
+
result: Object.assign({ order,
|
|
290
|
+
authorizeActions, numAcceptedOffers: params.acceptedOffers.length, options: {
|
|
204
291
|
ignoreAccpetedOffersFromResult: true
|
|
205
292
|
} }, (typeof params.code === 'string') ? { code: params.code } : undefined),
|
|
206
293
|
eventId,
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
|
-
export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyTransfer.IAction;
|
|
3
|
-
export type IAuthorizeSeatReservationOffer = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
|
|
4
2
|
export declare function createReservationAcceptedOffers(params: {
|
|
5
|
-
|
|
6
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
3
|
+
eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[];
|
|
7
4
|
}): {
|
|
8
|
-
reservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[];
|
|
9
5
|
reservationOrderItems: factory.order.IOrderedItem[];
|
|
10
6
|
};
|
|
11
7
|
export declare function createProductItems(params: {
|
|
12
|
-
transaction: factory.transaction.placeOrder.ITransaction;
|
|
13
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
14
|
-
}): {
|
|
15
8
|
productAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IPermit>[];
|
|
9
|
+
}): {
|
|
16
10
|
productOrderItems: factory.order.IOrderedItem[];
|
|
17
11
|
};
|
|
18
|
-
export declare function createMoneyTransferAcceptedOffers(
|
|
19
|
-
transaction: factory.transaction.placeOrder.ITransaction;
|
|
20
|
-
seller: factory.order.ISeller;
|
|
21
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
22
|
-
}): {
|
|
12
|
+
export declare function createMoneyTransferAcceptedOffers(__: {
|
|
23
13
|
moneyTransferAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>[];
|
|
14
|
+
}): {
|
|
24
15
|
moneyTransferOrderItems: factory.order.IOrderedItem[];
|
|
25
16
|
};
|
|
@@ -2,35 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createMoneyTransferAcceptedOffers = exports.createProductItems = exports.createReservationAcceptedOffers = void 0;
|
|
4
4
|
const factory = require("../../../../factory");
|
|
5
|
-
|
|
5
|
+
// import { availableProductTypes } from '../../../../factory/availableProductTypes';
|
|
6
6
|
function createReservationAcceptedOffers(params) {
|
|
7
|
-
const acceptedOffers = [];
|
|
7
|
+
// const acceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[] = [];
|
|
8
8
|
const orderedItems = [];
|
|
9
9
|
// 座席予約に対する承認アクション取り出す
|
|
10
|
-
const seatReservationAuthorizeActions = params.authorizeActions
|
|
11
|
-
|
|
10
|
+
// const seatReservationAuthorizeActions = <IAuthorizeSeatReservationOffer[]>params.authorizeActions
|
|
11
|
+
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
12
12
|
const eventIds = [];
|
|
13
|
-
seatReservationAuthorizeActions.forEach((authorizeSeatReservationAction) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
13
|
+
// seatReservationAuthorizeActions.forEach((authorizeSeatReservationAction) => {
|
|
14
|
+
// const resultAcceptedOffers = authorizeSeatReservationAction.result?.acceptedOffers;
|
|
15
|
+
// });
|
|
16
|
+
if (Array.isArray(params.eventReservationAcceptedOffers) && params.eventReservationAcceptedOffers.length > 0) {
|
|
17
|
+
// acceptedOffers.push(...resultAcceptedOffers);
|
|
18
|
+
// プロダクトIDで最適化する
|
|
19
|
+
const reservationFor = params.eventReservationAcceptedOffers[0].itemOffered.reservationFor;
|
|
20
|
+
const issuedThrough = params.eventReservationAcceptedOffers[0].itemOffered.issuedThrough;
|
|
21
|
+
if (typeof (issuedThrough === null || issuedThrough === void 0 ? void 0 : issuedThrough.typeOf) === 'string') {
|
|
22
|
+
if (!eventIds.includes(String(reservationFor.id))) {
|
|
23
|
+
eventIds.push(String(reservationFor.id));
|
|
24
|
+
const orderedItem = reservationOffers2orderedItem({ reservationFor, issuedThrough });
|
|
25
|
+
orderedItems.push({
|
|
26
|
+
typeOf: 'OrderItem',
|
|
27
|
+
orderedItem
|
|
28
|
+
});
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
// reservationAcceptedOffers: acceptedOffers,
|
|
34
|
+
reservationOrderItems: orderedItems
|
|
35
|
+
};
|
|
34
36
|
}
|
|
35
37
|
exports.createReservationAcceptedOffers = createReservationAcceptedOffers;
|
|
36
38
|
function reservationOffers2orderedItem(params) {
|
|
@@ -82,85 +84,61 @@ function reservationOffers2orderedItem(params) {
|
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
function createProductItems(params) {
|
|
85
|
-
|
|
87
|
+
var _a;
|
|
88
|
+
// const acceptedOffers: factory.order.IAcceptedOffer<factory.order.IPermit>[] = [];
|
|
86
89
|
const orderedItems = [];
|
|
87
|
-
const authorizePaymentCardOfferActions = params.authorizeActions
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// const authorizePaymentCardOfferActions = (<factory.action.authorize.offer.product.IAction[]>params.authorizeActions)
|
|
91
|
+
// .filter((a) =>
|
|
92
|
+
// Array.isArray(a.object)
|
|
93
|
+
// && a.object.length > 0
|
|
94
|
+
// && a.object[0].typeOf === factory.offerType.Offer
|
|
95
|
+
// && availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0
|
|
96
|
+
// );
|
|
92
97
|
const productIds = [];
|
|
93
|
-
authorizePaymentCardOfferActions.forEach((a) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
98
|
+
// authorizePaymentCardOfferActions.forEach((a) => {
|
|
99
|
+
// const resultAcceptedOffers = a.result?.acceptedOffers;
|
|
100
|
+
// });
|
|
101
|
+
if (Array.isArray(params.productAcceptedOffers) && params.productAcceptedOffers.length > 0) {
|
|
102
|
+
// acceptedOffers.push(...resultAcceptedOffers);
|
|
103
|
+
// プロダクトIDで最適化する
|
|
104
|
+
const issuedThrough = params.productAcceptedOffers[0].itemOffered.issuedThrough;
|
|
105
|
+
if (typeof (issuedThrough === null || issuedThrough === void 0 ? void 0 : issuedThrough.id) === 'string') {
|
|
106
|
+
if (!productIds.includes(issuedThrough.id)) {
|
|
107
|
+
productIds.push(issuedThrough.id);
|
|
108
|
+
orderedItems.push({
|
|
109
|
+
typeOf: 'OrderItem',
|
|
110
|
+
orderedItem: Object.assign({ id: String(issuedThrough.id), typeOf: issuedThrough.typeOf }, (typeof ((_a = issuedThrough.serviceType) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
111
|
+
? { serviceType: issuedThrough.serviceType }
|
|
112
|
+
: undefined)
|
|
113
|
+
});
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
// productAcceptedOffers: acceptedOffers,
|
|
119
|
+
productOrderItems: orderedItems
|
|
120
|
+
};
|
|
114
121
|
}
|
|
115
122
|
exports.createProductItems = createProductItems;
|
|
116
|
-
function createMoneyTransferAcceptedOffers(
|
|
123
|
+
function createMoneyTransferAcceptedOffers(__) {
|
|
117
124
|
// 通貨転送承認アクション
|
|
118
|
-
const authorizeMoneyTansferActions = params.authorizeActions
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const acceptedOffers = [];
|
|
125
|
+
// const authorizeMoneyTansferActions = (<IAuthorizeMoneyTransferOffer[]>params.authorizeActions)
|
|
126
|
+
// .filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
127
|
+
// .filter((a) => a.object.itemOffered?.typeOf === factory.actionType.MoneyTransfer);
|
|
128
|
+
// const acceptedOffers: factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>[] = [];
|
|
122
129
|
const orderedItems = [];
|
|
123
|
-
authorizeMoneyTansferActions.forEach((authorizeMoneyTansferAction) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// const itemOffered: factory.order.IMoneyTransfer = {
|
|
137
|
-
// typeOf: factory.actionType.MoneyTransfer,
|
|
138
|
-
// amount: {
|
|
139
|
-
// typeOf: 'MonetaryAmount',
|
|
140
|
-
// value: amountValue,
|
|
141
|
-
// currency
|
|
142
|
-
// },
|
|
143
|
-
// toLocation: {
|
|
144
|
-
// typeOf: authorizeMoneyTansferAction.object.itemOffered.toLocation.typeOf,
|
|
145
|
-
// // いったんマスク
|
|
146
|
-
// identifier: 'xxx',
|
|
147
|
-
// issuedThrough: { id: authorizeMoneyTansferAction.object.itemOffered.toLocation.issuedThrough?.id }
|
|
148
|
-
// },
|
|
149
|
-
// object: {
|
|
150
|
-
// pendingTransaction: {
|
|
151
|
-
// typeOf: pendingTransaction.typeOf,
|
|
152
|
-
// // MonetaryAmountの識別子として、MoneyTransfer取引番号をセットする
|
|
153
|
-
// transactionNumber: String(pendingTransaction.transactionNumber)
|
|
154
|
-
// }
|
|
155
|
-
// },
|
|
156
|
-
// name: `${amountValue} ${currency}`
|
|
157
|
-
// };
|
|
158
|
-
// acceptedOffers.push({
|
|
159
|
-
// typeOf: factory.offerType.Offer,
|
|
160
|
-
// itemOffered
|
|
161
|
-
// });
|
|
162
|
-
// }
|
|
163
|
-
});
|
|
164
|
-
return { moneyTransferAcceptedOffers: acceptedOffers, moneyTransferOrderItems: orderedItems };
|
|
130
|
+
// authorizeMoneyTansferActions.forEach((authorizeMoneyTansferAction) => {
|
|
131
|
+
// if (authorizeMoneyTansferAction.result === undefined) {
|
|
132
|
+
// throw new factory.errors.Argument('Transaction', 'authorize money transfer offer result does not exist');
|
|
133
|
+
// }
|
|
134
|
+
// const resultAcceptedOffers = authorizeMoneyTansferAction.result?.acceptedOffers;
|
|
135
|
+
// if (Array.isArray(resultAcceptedOffers) && resultAcceptedOffers.length > 0) {
|
|
136
|
+
// acceptedOffers.push(...resultAcceptedOffers);
|
|
137
|
+
// }
|
|
138
|
+
// });
|
|
139
|
+
return {
|
|
140
|
+
// moneyTransferAcceptedOffers: acceptedOffers,
|
|
141
|
+
moneyTransferOrderItems: orderedItems
|
|
142
|
+
};
|
|
165
143
|
}
|
|
166
144
|
exports.createMoneyTransferAcceptedOffers = createMoneyTransferAcceptedOffers;
|