@chevre/domain 21.34.0 → 21.35.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/migratePayTransactionRecipes.ts +25 -24
- package/lib/chevre/emailMessageBuilder.d.ts +4 -1
- package/lib/chevre/factory/transaction.d.ts +1 -1
- package/lib/chevre/repo/action.js +6 -6
- package/lib/chevre/repo/orderInTransaction.d.ts +2 -1
- package/lib/chevre/repo/orderInTransaction.js +3 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder.js +37 -98
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +19 -9
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +8 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +8 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -2
- package/package.json +2 -2
|
@@ -48,10 +48,7 @@ async function main() {
|
|
|
48
48
|
limit: 1,
|
|
49
49
|
page: 1,
|
|
50
50
|
project: { id: { $eq: payTransaction.project.id } },
|
|
51
|
-
|
|
52
|
-
id: { $in: [payTransaction.project.id] },
|
|
53
|
-
typeOf: { $in: [chevre.factory.organizationType.Project] }
|
|
54
|
-
},
|
|
51
|
+
sameAs: { id: { $eq: payTransaction.id } },
|
|
55
52
|
object: {
|
|
56
53
|
typeOf: { $eq: 'Invoice' },
|
|
57
54
|
paymentMethodId: { $eq: payTransaction.transactionNumber }
|
|
@@ -74,7 +71,8 @@ async function main() {
|
|
|
74
71
|
console.log(
|
|
75
72
|
'authorizeInvoiceAction already exists. step:',
|
|
76
73
|
authorizeInvoiceAction.object.paymentMethodId,
|
|
77
|
-
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
74
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
75
|
+
updateCount, saveRecipeCount, saveActionCount
|
|
78
76
|
);
|
|
79
77
|
|
|
80
78
|
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
|
|
@@ -85,32 +83,35 @@ async function main() {
|
|
|
85
83
|
if (actionRecipe !== null) {
|
|
86
84
|
console.log(
|
|
87
85
|
'actionRecipe already exists. step:',
|
|
88
|
-
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
86
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
87
|
+
updateCount, saveRecipeCount, saveActionCount
|
|
89
88
|
);
|
|
90
89
|
|
|
91
90
|
// optimize payTransaction.object
|
|
92
91
|
let unsetResult: any;
|
|
93
92
|
if (secureTran2Result !== undefined) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
94
|
+
filter: { _id: { $eq: payTransaction.id } },
|
|
95
|
+
$unset: {
|
|
96
|
+
'object.entryTranArgs': 1,
|
|
97
|
+
'object.entryTranResult': 1,
|
|
98
|
+
'object.execTranArgs': 1,
|
|
99
|
+
'object.execTranResult': 1,
|
|
100
|
+
'object.secureTran2Result': 1
|
|
101
|
+
}
|
|
102
|
+
});
|
|
100
103
|
updateCount += 1;
|
|
101
104
|
} else if (entryTranArgs !== undefined && execTranResult !== undefined) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
updateCount += 1;
|
|
113
|
-
}
|
|
105
|
+
unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
106
|
+
filter: { _id: { $eq: payTransaction.id } },
|
|
107
|
+
$unset: {
|
|
108
|
+
'object.entryTranArgs': 1,
|
|
109
|
+
'object.entryTranResult': 1,
|
|
110
|
+
'object.execTranArgs': 1,
|
|
111
|
+
'object.execTranResult': 1
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
updateCount += 1;
|
|
114
115
|
}
|
|
115
116
|
console.log(
|
|
116
117
|
'result unset. unsetResult:', unsetResult,
|
|
@@ -3,11 +3,14 @@ type ISendableEmailMessage = factory.action.transfer.send.message.email.IObjectA
|
|
|
3
3
|
identifier: string;
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
|
6
|
+
export type IOrderAsCreateEmailParams = Pick<factory.order.IOrder, 'confirmationNumber' | 'identifier' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf'> & {
|
|
7
|
+
customer: factory.order.ICustomer;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* 注文配送メッセージを作成する
|
|
8
11
|
*/
|
|
9
12
|
declare function createSendOrderMessage(params: {
|
|
10
|
-
order:
|
|
13
|
+
order: IOrderAsCreateEmailParams;
|
|
11
14
|
email?: factory.creativeWork.message.email.ICustomization;
|
|
12
15
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
13
16
|
index: number;
|
|
@@ -12,7 +12,7 @@ export declare namespace placeOrder {
|
|
|
12
12
|
passportValidator?: IPassportValidator;
|
|
13
13
|
broker?: factory.order.IBroker;
|
|
14
14
|
};
|
|
15
|
-
type IOrderURLGenerator = (order: factory.
|
|
15
|
+
type IOrderURLGenerator = (order: factory.transaction.placeOrder.IOrderAsResult) => string;
|
|
16
16
|
type IResultOrderParams = factory.transaction.placeOrder.IResultOrderParams & {
|
|
17
17
|
/**
|
|
18
18
|
* 注文日時
|
|
@@ -1128,16 +1128,16 @@ class MongoRepository {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
saveActionWithEndDate(savingAction) {
|
|
1130
1130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
-
const { typeOf, project, agent, object } = savingAction, updateFields = __rest(savingAction, ["typeOf", "project", "agent", "object"]);
|
|
1131
|
+
const { sameAs, typeOf, project, agent, object } = savingAction, updateFields = __rest(savingAction, ["sameAs", "typeOf", "project", "agent", "object"]);
|
|
1132
1132
|
const filter = {
|
|
1133
1133
|
'project.id': { $eq: project.id },
|
|
1134
|
-
'agent.id': { $exists: true, $eq: agent.id },
|
|
1135
|
-
'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
1134
|
+
// 'agent.id': { $exists: true, $eq: agent.id },
|
|
1135
|
+
// 'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
1136
1136
|
'object.paymentMethodId': { $exists: true, $eq: object.paymentMethodId },
|
|
1137
|
-
typeOf: { $eq: typeOf }
|
|
1138
|
-
|
|
1137
|
+
typeOf: { $eq: typeOf },
|
|
1138
|
+
'sameAs.id': { $exists: true, $eq: sameAs.id }
|
|
1139
1139
|
};
|
|
1140
|
-
const setOnInsert = { typeOf, project, agent, object };
|
|
1140
|
+
const setOnInsert = { typeOf, project, agent, object, sameAs };
|
|
1141
1141
|
const setKeys = updateFields;
|
|
1142
1142
|
const update = {
|
|
1143
1143
|
$setOnInsert: setOnInsert,
|
|
@@ -4,6 +4,7 @@ type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'>
|
|
|
4
4
|
typeOf: factory.transactionType.PlaceOrder;
|
|
5
5
|
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
6
6
|
};
|
|
7
|
+
export type IPlacingOrder = Pick<factory.order.IOrder, 'broker' | 'confirmationNumber' | 'customer' | 'identifier' | 'isGift' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf' | 'url'>;
|
|
7
8
|
/**
|
|
8
9
|
* 取引中注文リポジトリ
|
|
9
10
|
*/
|
|
@@ -21,7 +22,7 @@ export declare class MongoRepository {
|
|
|
21
22
|
/**
|
|
22
23
|
* 注文を受注する
|
|
23
24
|
*/
|
|
24
|
-
placeOrder(order:
|
|
25
|
+
placeOrder(order: IPlacingOrder): Promise<void>;
|
|
25
26
|
acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongodb").UpdateResult | undefined>;
|
|
26
27
|
/**
|
|
27
28
|
* serialNumberからオファーを除外する
|
|
@@ -11,7 +11,7 @@ import * as factory from '../../factory';
|
|
|
11
11
|
* 冪等性を確保すること
|
|
12
12
|
*/
|
|
13
13
|
declare function deleteOrder(params: {
|
|
14
|
-
object: Pick<factory.order.IOrder, '
|
|
14
|
+
object: Pick<factory.order.IOrder, 'typeOf' | 'confirmationNumber' | 'orderDate' | 'orderNumber'>;
|
|
15
15
|
}): (repos: {
|
|
16
16
|
acceptedOffer: AcceptedOfferRepo;
|
|
17
17
|
accountingReport: AccountingReportRepo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
3
|
declare function onOrderPaymentDue(params: {
|
|
4
|
-
order: Pick<factory.order.IOrder, 'paymentMethods' | 'project' | 'orderNumber' | 'confirmationNumber' | '
|
|
4
|
+
order: Pick<factory.order.IOrder, 'paymentMethods' | 'project' | 'orderNumber' | 'confirmationNumber' | 'orderDate' | 'seller' | 'typeOf' | 'price' | 'priceCurrency'> & {
|
|
5
5
|
orderStatus: factory.orderStatus.OrderPaymentDue;
|
|
6
6
|
};
|
|
7
7
|
}): (repos: {
|
|
@@ -13,22 +13,36 @@ exports.placeOrderWithoutTransaction = exports.placeOrder = void 0;
|
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment");
|
|
15
15
|
const factory = require("../../factory");
|
|
16
|
+
const result_1 = require("../transaction/placeOrderInProgress/result");
|
|
16
17
|
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
17
18
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
18
19
|
const debug = createDebug('chevre-domain:service:order');
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
function createPlacingOrder(params) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const { transaction } = params;
|
|
23
|
+
const orderByTransaction = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
|
|
24
|
+
if (orderByTransaction === undefined) {
|
|
25
|
+
throw new factory.errors.NotFound('transaction.result.order');
|
|
26
|
+
}
|
|
27
|
+
const orderedItems = (Array.isArray(orderByTransaction.orderedItem)) ? orderByTransaction.orderedItem : [];
|
|
28
|
+
const customer = (0, result_1.createCustomer)({ transaction });
|
|
29
|
+
const seller = (0, result_1.createSeller)({ transaction });
|
|
30
|
+
const name = (typeof transaction.object.name === 'string') ? transaction.object.name : undefined;
|
|
31
|
+
const broker = (typeof ((_b = transaction.object.broker) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? transaction.object.broker : undefined;
|
|
32
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, orderByTransaction), { customer,
|
|
33
|
+
seller, orderDate: moment(orderByTransaction.orderDate)
|
|
34
|
+
.toDate(), orderedItem: orderedItems }), (typeof name === 'string') ? { name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker } : undefined
|
|
35
|
+
// discontinue(2024-06-17~)
|
|
36
|
+
// ...(params.dateReturned !== null && params.dateReturned !== undefined)
|
|
37
|
+
// ? {
|
|
38
|
+
// dateReturned: moment(params.dateReturned)
|
|
39
|
+
// .toDate()
|
|
40
|
+
// }
|
|
41
|
+
// : undefined
|
|
42
|
+
);
|
|
28
43
|
}
|
|
29
|
-
function
|
|
44
|
+
function createPlacingOrderFromExistingTransaction(params) {
|
|
30
45
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
46
|
const confirmationNumber = String(params.confirmationNumber);
|
|
33
47
|
const orderNumber = params.orderNumber;
|
|
34
48
|
let order;
|
|
@@ -44,18 +58,18 @@ function createOrderFromBody(params) {
|
|
|
44
58
|
orderNumbers: [orderNumber]
|
|
45
59
|
}
|
|
46
60
|
},
|
|
47
|
-
inclusion: ['project', 'typeOf', 'result'],
|
|
61
|
+
inclusion: ['project', 'typeOf', 'result', 'object', 'seller'],
|
|
48
62
|
exclusion: []
|
|
49
63
|
});
|
|
50
64
|
const placeOrderTransactionWithResult = placeOrderTransactions.shift();
|
|
51
65
|
if (placeOrderTransactionWithResult === undefined) {
|
|
52
66
|
throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
|
|
53
67
|
}
|
|
54
|
-
const orderByTransaction =
|
|
55
|
-
if (orderByTransaction === undefined) {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
order =
|
|
68
|
+
// const orderByTransaction = placeOrderTransactionWithResult.result?.order;
|
|
69
|
+
// if (orderByTransaction === undefined) {
|
|
70
|
+
// throw new factory.errors.NotFound('transaction.result.order');
|
|
71
|
+
// }
|
|
72
|
+
order = createPlacingOrder({ transaction: placeOrderTransactionWithResult });
|
|
59
73
|
return { order, placeOrderTransaction: placeOrderTransactionWithResult };
|
|
60
74
|
});
|
|
61
75
|
}
|
|
@@ -66,8 +80,6 @@ function placeOrderWithoutTransaction(params) {
|
|
|
66
80
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
81
|
var _a;
|
|
68
82
|
const order = params.object;
|
|
69
|
-
// アクションを作成する(2022-04-11~)
|
|
70
|
-
// const maskedCustomer = createMaskedCustomer(order, { noProfile: true });
|
|
71
83
|
const simpleOrder = {
|
|
72
84
|
typeOf: order.typeOf,
|
|
73
85
|
// seller: {
|
|
@@ -116,20 +128,6 @@ function voidAcceptedOfferIfNecessary(params) {
|
|
|
116
128
|
if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
|
|
117
129
|
const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
|
|
118
130
|
debug(completedAuthorizeActionIds.length, 'completedAuthorizeActionIds found from transaction', params.purpose.id);
|
|
119
|
-
// const authorizeActions = <Pick<IAuthorizeEventServiceOfferAction, 'object'>[]>
|
|
120
|
-
// await repos.action.search(
|
|
121
|
-
// {
|
|
122
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
123
|
-
// purpose: {
|
|
124
|
-
// typeOf: { $in: [factory.transactionType.PlaceOrder] },
|
|
125
|
-
// id: { $in: [params.purpose.id] }
|
|
126
|
-
// },
|
|
127
|
-
// object: { typeOf: { $eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation } },
|
|
128
|
-
// id: { $nin: completedAuthorizeActionIds }
|
|
129
|
-
// },
|
|
130
|
-
// ['object'],
|
|
131
|
-
// []
|
|
132
|
-
// );
|
|
133
131
|
const authorizeActionsWithInstrument = yield repos.action.search({
|
|
134
132
|
typeOf: factory.actionType.AuthorizeAction,
|
|
135
133
|
purpose: {
|
|
@@ -155,68 +153,9 @@ function voidAcceptedOfferIfNecessary(params) {
|
|
|
155
153
|
acceptedOffers: { serialNumber: { $nin: serialNumbersMustBeIn } }
|
|
156
154
|
});
|
|
157
155
|
debug('voidAcceptedOfferBySerialNumber processed.', params.object.orderNumber, 'voidAcceptedOfferBySerialNumberResult:', voidAcceptedOfferBySerialNumberResult);
|
|
158
|
-
// await voidAcceptedOffer({
|
|
159
|
-
// authorizeActions,
|
|
160
|
-
// authorizeActionsWithInstrument,
|
|
161
|
-
// orderNumber: params.object.orderNumber
|
|
162
|
-
// })(repos);
|
|
163
156
|
}
|
|
164
157
|
});
|
|
165
158
|
}
|
|
166
|
-
// function verifyAcceptedOffers(params: {
|
|
167
|
-
// order: factory.order.IOrder & {
|
|
168
|
-
// acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
169
|
-
// };
|
|
170
|
-
// }) {
|
|
171
|
-
// return async (repos: {
|
|
172
|
-
// orderInTransaction: OrderInTransactionRepo;
|
|
173
|
-
// }) => {
|
|
174
|
-
// const { order } = params;
|
|
175
|
-
// const orderInTransaction = (await repos.orderInTransaction.searchByOrderNumber({
|
|
176
|
-
// orderNumber: { $eq: order.orderNumber }
|
|
177
|
-
// })).shift();
|
|
178
|
-
// if (orderInTransaction !== undefined) {
|
|
179
|
-
// debug('verifying acceptedOffers...', order.orderNumber);
|
|
180
|
-
// const acceptedOffersLengthMatched = orderInTransaction.acceptedOffers.length === order.acceptedOffers.length;
|
|
181
|
-
// debug('acceptedOffers.length matched?', acceptedOffersLengthMatched);
|
|
182
|
-
// if (!acceptedOffersLengthMatched) {
|
|
183
|
-
// throw new factory.errors.ServiceUnavailable('acceptedOffers.length not matched');
|
|
184
|
-
// }
|
|
185
|
-
// const reservationIdsByOrderInTransation = orderInTransaction.acceptedOffers.map((offer) => {
|
|
186
|
-
// return (offer.itemOffered.typeOf === factory.reservationType.EventReservation)
|
|
187
|
-
// ? offer.itemOffered.id
|
|
188
|
-
// : '';
|
|
189
|
-
// });
|
|
190
|
-
// const reservationIdsByOrder = order.acceptedOffers.map((offer) => {
|
|
191
|
-
// return (offer.itemOffered.typeOf === factory.reservationType.EventReservation)
|
|
192
|
-
// ? offer.itemOffered.id
|
|
193
|
-
// : '';
|
|
194
|
-
// });
|
|
195
|
-
// debug('reservationIdsByOrderInTransation:', reservationIdsByOrderInTransation);
|
|
196
|
-
// debug('reservationIdsByOrder:', reservationIdsByOrder);
|
|
197
|
-
// const offerIdsByOrderInTransation = [...new Set(orderInTransaction.acceptedOffers.map((offer) => {
|
|
198
|
-
// return String(offer.id);
|
|
199
|
-
// }))];
|
|
200
|
-
// const offerIdsByOrder = [...new Set(order.acceptedOffers.map((offer) => {
|
|
201
|
-
// return String(offer.id);
|
|
202
|
-
// }))];
|
|
203
|
-
// debug('offerIdsByOrderInTransation:', offerIdsByOrderInTransation);
|
|
204
|
-
// debug('offerIdsByOrder:', offerIdsByOrder);
|
|
205
|
-
// const reservationIdsMatched = reservationIdsByOrderInTransation.length === reservationIdsByOrder.length
|
|
206
|
-
// && reservationIdsByOrderInTransation.every((reservationId) => reservationIdsByOrder.includes(reservationId));
|
|
207
|
-
// debug('reservationIds matched?', reservationIdsMatched);
|
|
208
|
-
// const offerIdsMatched = offerIdsByOrderInTransation.length === offerIdsByOrder.length
|
|
209
|
-
// && offerIdsByOrderInTransation.every((offerId) => offerIdsByOrder.includes(offerId));
|
|
210
|
-
// debug('offerIds matched?', offerIdsMatched);
|
|
211
|
-
// if (!reservationIdsMatched) {
|
|
212
|
-
// throw new factory.errors.ServiceUnavailable('reservationIds not matched');
|
|
213
|
-
// }
|
|
214
|
-
// if (!offerIdsMatched) {
|
|
215
|
-
// throw new factory.errors.ServiceUnavailable('offerIds not matched');
|
|
216
|
-
// }
|
|
217
|
-
// }
|
|
218
|
-
// };
|
|
219
|
-
// }
|
|
220
159
|
/**
|
|
221
160
|
* 注文を作成する
|
|
222
161
|
*/
|
|
@@ -228,7 +167,7 @@ function placeOrder(params) {
|
|
|
228
167
|
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
229
168
|
}
|
|
230
169
|
// 注文番号から取引と注文をfixする
|
|
231
|
-
const { order, placeOrderTransaction } = yield
|
|
170
|
+
const { order, placeOrderTransaction } = yield createPlacingOrderFromExistingTransaction({
|
|
232
171
|
project: { id: params.project.id },
|
|
233
172
|
confirmationNumber: params.object.confirmationNumber,
|
|
234
173
|
orderNumber: params.object.orderNumber
|
|
@@ -255,10 +194,10 @@ function placeOrder(params) {
|
|
|
255
194
|
typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id
|
|
256
195
|
};
|
|
257
196
|
const orderActionAttributes = {
|
|
258
|
-
agent: (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.agent :
|
|
197
|
+
agent: (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.agent : placeOrderTransaction.project,
|
|
259
198
|
object: simpleOrder,
|
|
260
199
|
potentialActions: {},
|
|
261
|
-
project:
|
|
200
|
+
project: placeOrderTransaction.project,
|
|
262
201
|
purpose: orderActionPurpose,
|
|
263
202
|
typeOf: factory.actionType.OrderAction
|
|
264
203
|
};
|
|
@@ -317,10 +256,10 @@ function placeOrder(params) {
|
|
|
317
256
|
yield (0, onOrderStatusChanged_1.onOrderPaymentDue)({
|
|
318
257
|
order: {
|
|
319
258
|
paymentMethods: order.paymentMethods,
|
|
320
|
-
project:
|
|
259
|
+
project: placeOrderTransaction.project,
|
|
321
260
|
orderNumber: order.orderNumber,
|
|
322
261
|
confirmationNumber: order.confirmationNumber,
|
|
323
|
-
customer: order.customer,
|
|
262
|
+
// customer: order.customer,
|
|
324
263
|
orderDate: order.orderDate,
|
|
325
264
|
seller: order.seller,
|
|
326
265
|
typeOf: order.typeOf,
|
|
@@ -359,7 +298,7 @@ function placeOrder(params) {
|
|
|
359
298
|
if (order.paymentMethods.length === 0) {
|
|
360
299
|
// paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpaymentDue2Processingを実行する必要がある
|
|
361
300
|
yield (0, onAssetTransactionStatusChanged_1.paymentDue2Processing)({
|
|
362
|
-
project: { id:
|
|
301
|
+
project: { id: placeOrderTransaction.project.id },
|
|
363
302
|
confirmationNumber: order.confirmationNumber,
|
|
364
303
|
orderNumber: order.orderNumber,
|
|
365
304
|
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
@@ -43,7 +43,8 @@ type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
|
|
|
43
43
|
* 注文取引を確定する
|
|
44
44
|
*/
|
|
45
45
|
declare function confirm(params: IConfirmParams): IConfirmOperation<{
|
|
46
|
-
order: factory.
|
|
46
|
+
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
47
|
+
customer: factory.order.ICustomer;
|
|
47
48
|
code?: string;
|
|
48
49
|
/**
|
|
49
50
|
* expectsReservationIdsの場合のみ
|
|
@@ -41,7 +41,7 @@ function confirm(params) {
|
|
|
41
41
|
}, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
|
|
42
42
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
43
43
|
// すでに確定済の場合
|
|
44
|
-
return transaction.result;
|
|
44
|
+
return Object.assign(Object.assign({}, transaction.result), { customer: (0, result_1.createCustomer)({ transaction }) });
|
|
45
45
|
}
|
|
46
46
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
47
47
|
throw new factory.errors.Argument('transactionId', 'Transaction already expired');
|
|
@@ -89,6 +89,8 @@ function confirm(params) {
|
|
|
89
89
|
authorizeMoneyTansferActions,
|
|
90
90
|
authorizeProductOfferActions,
|
|
91
91
|
acceptedOffers }), (typeof code === 'string') ? { code } : undefined));
|
|
92
|
+
const customer = (0, result_1.createCustomer)({ transaction });
|
|
93
|
+
const seller = (0, result_1.createSeller)({ transaction });
|
|
92
94
|
// デフォルトEメールメッセージを検索
|
|
93
95
|
let emailMessageOnOrderSent;
|
|
94
96
|
if (repos.emailMessage !== undefined) {
|
|
@@ -101,12 +103,18 @@ function confirm(params) {
|
|
|
101
103
|
emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
102
104
|
}
|
|
103
105
|
// ポストアクションを作成
|
|
104
|
-
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order,
|
|
106
|
+
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order, // createEmailMessageでのorder.acceptedOffersへの依存性を排除したのでこちらでよいはず(2024-02-21~)
|
|
107
|
+
customer,
|
|
108
|
+
seller,
|
|
105
109
|
// order: orderWithAcceptedOffers, // 現時点でcreateEmailMessageでorder.acceptedOffersを使用している(2024-02-06~)
|
|
106
110
|
// transaction: transaction,
|
|
107
111
|
useOptimizedSendEmailAction: params.options.useOptimizedSendEmailAction }, (params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined), (emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined));
|
|
108
112
|
// メッセージ保管(2024-04-28~)
|
|
109
|
-
yield saveMessagesIfNeeded({
|
|
113
|
+
yield saveMessagesIfNeeded({
|
|
114
|
+
options: params.options,
|
|
115
|
+
project: { id: transaction.project.id },
|
|
116
|
+
order: result.order, seller, emailMessages
|
|
117
|
+
})(repos);
|
|
110
118
|
// ステータス変更
|
|
111
119
|
try {
|
|
112
120
|
yield repos.transaction.confirm({
|
|
@@ -127,20 +135,22 @@ function confirm(params) {
|
|
|
127
135
|
throw error;
|
|
128
136
|
}
|
|
129
137
|
const { order } = result;
|
|
130
|
-
return Object.assign(Object.assign(Object.assign({ order
|
|
138
|
+
return Object.assign(Object.assign(Object.assign({ order,
|
|
139
|
+
customer }, (typeof code === 'string') ? { code } : undefined), (typeof eventId === 'string') ? { eventId } : undefined), (Array.isArray(reservationIds)) ? { reservationIds } : undefined);
|
|
131
140
|
});
|
|
132
141
|
}
|
|
133
142
|
exports.confirm = confirm;
|
|
134
|
-
function saveMessagesIfNeeded(params
|
|
143
|
+
function saveMessagesIfNeeded(params) {
|
|
135
144
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
|
|
145
|
+
const { options, project, order, emailMessages, seller } = params;
|
|
146
|
+
if (options.useSaveMessages) {
|
|
137
147
|
if (emailMessages.length > 0) {
|
|
138
|
-
const { orderNumber, typeOf
|
|
148
|
+
const { orderNumber, typeOf } = order;
|
|
139
149
|
debug('saving', emailMessages.length, 'messages...', emailMessages);
|
|
140
150
|
const saveMessageResult = yield repos.message.upsertByIdentifier(emailMessages.map(({ identifier, name, about, text, toRecipient, sender }) => {
|
|
141
151
|
return {
|
|
142
152
|
identifier, name, about, text, toRecipient, sender,
|
|
143
|
-
project,
|
|
153
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
144
154
|
provider: { id: seller.id, typeOf: seller.typeOf },
|
|
145
155
|
mainEntity: { orderNumber, typeOf }
|
|
146
156
|
};
|
|
@@ -273,7 +283,7 @@ function createResult(params) {
|
|
|
273
283
|
// 注文作成
|
|
274
284
|
const order = (0, result_1.createOrder)({
|
|
275
285
|
orderNumber: params.orderNumber,
|
|
276
|
-
transaction
|
|
286
|
+
transaction,
|
|
277
287
|
orderDate: params.result.order.orderDate,
|
|
278
288
|
orderStatus: factory.orderStatus.OrderPaymentDue,
|
|
279
289
|
isGift: false,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
2
|
export declare function createSendEmailMessageActions(params: {
|
|
3
|
-
order: factory.
|
|
3
|
+
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
4
|
+
customer: factory.order.ICustomer;
|
|
5
|
+
seller: factory.order.ISeller;
|
|
4
6
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
5
7
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
6
8
|
useOptimizedSendEmailAction: boolean;
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js
CHANGED
|
@@ -28,8 +28,9 @@ function createSendEmailMessageActions(params) {
|
|
|
28
28
|
// };
|
|
29
29
|
const sendEmailMessageOnOrderSentParams = (_e = (_d = (_c = (_b = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.potentialActions) === null || _c === void 0 ? void 0 : _c.sendOrder) === null || _d === void 0 ? void 0 : _d.potentialActions) === null || _e === void 0 ? void 0 : _e.sendEmailMessage;
|
|
30
30
|
if (Array.isArray(sendEmailMessageOnOrderSentParams)) {
|
|
31
|
+
const orderAsCreateEmailParams = Object.assign(Object.assign({}, params.order), { customer: params.customer, seller: params.seller });
|
|
31
32
|
yield Promise.all(sendEmailMessageOnOrderSentParams.map((s, index) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const emailMessage = yield emailMessageBuilder.createSendOrderMessage(Object.assign(Object.assign({ order:
|
|
33
|
+
const emailMessage = yield emailMessageBuilder.createSendOrderMessage(Object.assign(Object.assign({ order: orderAsCreateEmailParams, index }, (s.object !== undefined) ? { email: s.object } : undefined), (params.emailMessage !== undefined) ? { emailMessage: params.emailMessage } : undefined));
|
|
33
34
|
emailMessages.push(emailMessage);
|
|
34
35
|
let sendEmailMessageActionObject = emailMessage;
|
|
35
36
|
// 送信アクション最適化に対応(2024-04-29~)
|
|
@@ -3,7 +3,9 @@ import * as factory from '../../../factory';
|
|
|
3
3
|
* 取引のポストアクションを作成する
|
|
4
4
|
*/
|
|
5
5
|
export declare function createPotentialActions(params: {
|
|
6
|
-
order: factory.
|
|
6
|
+
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
7
|
+
customer: factory.order.ICustomer;
|
|
8
|
+
seller: factory.order.ISeller;
|
|
7
9
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
8
10
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
9
11
|
useOptimizedSendEmailAction: boolean;
|
|
@@ -2,7 +2,7 @@ import * as factory from '../../../factory';
|
|
|
2
2
|
/**
|
|
3
3
|
* 注文を生成する
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare function createOrder(params: {
|
|
6
6
|
orderNumber: string;
|
|
7
7
|
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'object' | 'seller' | 'project'>;
|
|
8
8
|
orderDate: Date;
|
|
@@ -13,3 +13,10 @@ export declare function createOrder(params: {
|
|
|
13
13
|
productAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IPermit>[];
|
|
14
14
|
moneyTransferAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>[];
|
|
15
15
|
}): factory.transaction.placeOrder.IOrderAsResult;
|
|
16
|
+
declare function createSeller(params: {
|
|
17
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'seller'>;
|
|
18
|
+
}): factory.order.ISeller;
|
|
19
|
+
declare function createCustomer(params: {
|
|
20
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'object'>;
|
|
21
|
+
}): factory.order.ICustomer;
|
|
22
|
+
export { createOrder, createCustomer, createSeller };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOrder = void 0;
|
|
3
|
+
exports.createSeller = exports.createCustomer = exports.createOrder = void 0;
|
|
4
4
|
const factory = require("../../../factory");
|
|
5
|
+
const settings_1 = require("../../../settings");
|
|
5
6
|
const orderedItem_1 = require("./result/orderedItem");
|
|
6
7
|
/**
|
|
7
8
|
* 注文を生成する
|
|
@@ -18,11 +19,11 @@ function createOrder(params) {
|
|
|
18
19
|
// const discounts: factory.order.IDiscount[] = [];
|
|
19
20
|
const name = (typeof params.transaction.object.name === 'string') ? params.transaction.object.name : undefined;
|
|
20
21
|
const broker = (typeof ((_a = params.transaction.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.transaction.object.broker : undefined;
|
|
21
|
-
return Object.assign(
|
|
22
|
+
return Object.assign({ typeOf: factory.order.OrderType.Order, price: price, priceCurrency: factory.priceCurrency.JPY, paymentMethods: paymentMethods,
|
|
22
23
|
// discounts: discounts, // 廃止(2024-04-16~)
|
|
23
|
-
confirmationNumber: '', orderNumber: params.orderNumber, orderedItem: orderedItems,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
confirmationNumber: '', orderNumber: params.orderNumber, orderedItem: orderedItems, url: '', orderStatus: params.orderStatus, orderDate: params.orderDate, identifier: [] }, (settings_1.USE_EXPERIMENTAL_FEATURE)
|
|
25
|
+
? {}
|
|
26
|
+
: Object.assign(Object.assign({ customer, project: params.transaction.project, seller, isGift: params.isGift }, (typeof name === 'string') ? { name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker } : undefined));
|
|
26
27
|
}
|
|
27
28
|
exports.createOrder = createOrder;
|
|
28
29
|
function createSeller(params) {
|
|
@@ -36,6 +37,7 @@ function createSeller(params) {
|
|
|
36
37
|
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : []
|
|
37
38
|
};
|
|
38
39
|
}
|
|
40
|
+
exports.createSeller = createSeller;
|
|
39
41
|
function createCustomer(params) {
|
|
40
42
|
// transaction.object.customerはstart時点でapiが自動的に指定、あるいは、その後クライアントから変更されるか
|
|
41
43
|
const customerByTransaction = params.transaction.object.customer;
|
|
@@ -54,6 +56,7 @@ function createCustomer(params) {
|
|
|
54
56
|
}
|
|
55
57
|
return Object.assign(Object.assign({}, customerByTransaction), { identifier: (Array.isArray(customerByTransaction.identifier)) ? customerByTransaction.identifier : [], name: customerName });
|
|
56
58
|
}
|
|
59
|
+
exports.createCustomer = createCustomer;
|
|
57
60
|
function createPaymentMethods(params) {
|
|
58
61
|
const paymentMethods = [];
|
|
59
62
|
let price = 0;
|
|
@@ -25,12 +25,12 @@ export declare function validateOrderedItem(params: {
|
|
|
25
25
|
};
|
|
26
26
|
}): void;
|
|
27
27
|
export declare function validatePaymentMethods(params: {
|
|
28
|
-
order: factory.
|
|
28
|
+
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
29
29
|
}): void;
|
|
30
30
|
/**
|
|
31
31
|
* 興行オファー適用条件確認
|
|
32
32
|
*/
|
|
33
33
|
export declare function validateEventOffers(params: {
|
|
34
|
-
order: factory.
|
|
34
|
+
order: factory.transaction.placeOrder.IOrderAsResult;
|
|
35
35
|
authorizeEventServiceOfferActions: IAuthorizeEventServiceOffer[];
|
|
36
36
|
}): void;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.375.0-alpha.1",
|
|
14
14
|
"@cinerino/sdk": "7.2.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.
|
|
113
|
+
"version": "21.35.0-alpha.1"
|
|
114
114
|
}
|