@chevre/domain 21.34.0 → 21.35.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/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 +23 -96
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +8 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +11 -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.transaction.placeOrder.IOrderAsResult, 'confirmationNumber' | 'identifier' | 'name' | '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,24 @@ 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;
|
|
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
|
+
return Object.assign(Object.assign({}, orderByTransaction), { customer, orderDate: moment(orderByTransaction.orderDate)
|
|
30
|
+
.toDate(), orderedItem: orderedItems });
|
|
28
31
|
}
|
|
29
32
|
function createOrderFromBody(params) {
|
|
30
33
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
34
|
const confirmationNumber = String(params.confirmationNumber);
|
|
33
35
|
const orderNumber = params.orderNumber;
|
|
34
36
|
let order;
|
|
@@ -44,18 +46,18 @@ function createOrderFromBody(params) {
|
|
|
44
46
|
orderNumbers: [orderNumber]
|
|
45
47
|
}
|
|
46
48
|
},
|
|
47
|
-
inclusion: ['project', 'typeOf', 'result'],
|
|
49
|
+
inclusion: ['project', 'typeOf', 'result', 'object'],
|
|
48
50
|
exclusion: []
|
|
49
51
|
});
|
|
50
52
|
const placeOrderTransactionWithResult = placeOrderTransactions.shift();
|
|
51
53
|
if (placeOrderTransactionWithResult === undefined) {
|
|
52
54
|
throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
|
|
53
55
|
}
|
|
54
|
-
const orderByTransaction =
|
|
55
|
-
if (orderByTransaction === undefined) {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
order =
|
|
56
|
+
// const orderByTransaction = placeOrderTransactionWithResult.result?.order;
|
|
57
|
+
// if (orderByTransaction === undefined) {
|
|
58
|
+
// throw new factory.errors.NotFound('transaction.result.order');
|
|
59
|
+
// }
|
|
60
|
+
order = createPlacingOrder({ transaction: placeOrderTransactionWithResult });
|
|
59
61
|
return { order, placeOrderTransaction: placeOrderTransactionWithResult };
|
|
60
62
|
});
|
|
61
63
|
}
|
|
@@ -66,8 +68,6 @@ function placeOrderWithoutTransaction(params) {
|
|
|
66
68
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
69
|
var _a;
|
|
68
70
|
const order = params.object;
|
|
69
|
-
// アクションを作成する(2022-04-11~)
|
|
70
|
-
// const maskedCustomer = createMaskedCustomer(order, { noProfile: true });
|
|
71
71
|
const simpleOrder = {
|
|
72
72
|
typeOf: order.typeOf,
|
|
73
73
|
// seller: {
|
|
@@ -116,20 +116,6 @@ function voidAcceptedOfferIfNecessary(params) {
|
|
|
116
116
|
if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
|
|
117
117
|
const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
|
|
118
118
|
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
119
|
const authorizeActionsWithInstrument = yield repos.action.search({
|
|
134
120
|
typeOf: factory.actionType.AuthorizeAction,
|
|
135
121
|
purpose: {
|
|
@@ -155,68 +141,9 @@ function voidAcceptedOfferIfNecessary(params) {
|
|
|
155
141
|
acceptedOffers: { serialNumber: { $nin: serialNumbersMustBeIn } }
|
|
156
142
|
});
|
|
157
143
|
debug('voidAcceptedOfferBySerialNumber processed.', params.object.orderNumber, 'voidAcceptedOfferBySerialNumberResult:', voidAcceptedOfferBySerialNumberResult);
|
|
158
|
-
// await voidAcceptedOffer({
|
|
159
|
-
// authorizeActions,
|
|
160
|
-
// authorizeActionsWithInstrument,
|
|
161
|
-
// orderNumber: params.object.orderNumber
|
|
162
|
-
// })(repos);
|
|
163
144
|
}
|
|
164
145
|
});
|
|
165
146
|
}
|
|
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
147
|
/**
|
|
221
148
|
* 注文を作成する
|
|
222
149
|
*/
|
|
@@ -255,10 +182,10 @@ function placeOrder(params) {
|
|
|
255
182
|
typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id
|
|
256
183
|
};
|
|
257
184
|
const orderActionAttributes = {
|
|
258
|
-
agent: (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.agent :
|
|
185
|
+
agent: (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.agent : placeOrderTransaction.project,
|
|
259
186
|
object: simpleOrder,
|
|
260
187
|
potentialActions: {},
|
|
261
|
-
project:
|
|
188
|
+
project: placeOrderTransaction.project,
|
|
262
189
|
purpose: orderActionPurpose,
|
|
263
190
|
typeOf: factory.actionType.OrderAction
|
|
264
191
|
};
|
|
@@ -317,10 +244,10 @@ function placeOrder(params) {
|
|
|
317
244
|
yield (0, onOrderStatusChanged_1.onOrderPaymentDue)({
|
|
318
245
|
order: {
|
|
319
246
|
paymentMethods: order.paymentMethods,
|
|
320
|
-
project:
|
|
247
|
+
project: placeOrderTransaction.project,
|
|
321
248
|
orderNumber: order.orderNumber,
|
|
322
249
|
confirmationNumber: order.confirmationNumber,
|
|
323
|
-
customer: order.customer,
|
|
250
|
+
// customer: order.customer,
|
|
324
251
|
orderDate: order.orderDate,
|
|
325
252
|
seller: order.seller,
|
|
326
253
|
typeOf: order.typeOf,
|
|
@@ -359,7 +286,7 @@ function placeOrder(params) {
|
|
|
359
286
|
if (order.paymentMethods.length === 0) {
|
|
360
287
|
// paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpaymentDue2Processingを実行する必要がある
|
|
361
288
|
yield (0, onAssetTransactionStatusChanged_1.paymentDue2Processing)({
|
|
362
|
-
project: { id:
|
|
289
|
+
project: { id: placeOrderTransaction.project.id },
|
|
363
290
|
confirmationNumber: order.confirmationNumber,
|
|
364
291
|
orderNumber: order.orderNumber,
|
|
365
292
|
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
@@ -43,7 +43,7 @@ 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
47
|
code?: string;
|
|
48
48
|
/**
|
|
49
49
|
* expectsReservationIdsの場合のみ
|
|
@@ -89,6 +89,7 @@ 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 });
|
|
92
93
|
// デフォルトEメールメッセージを検索
|
|
93
94
|
let emailMessageOnOrderSent;
|
|
94
95
|
if (repos.emailMessage !== undefined) {
|
|
@@ -101,12 +102,13 @@ function confirm(params) {
|
|
|
101
102
|
emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
102
103
|
}
|
|
103
104
|
// ポストアクションを作成
|
|
104
|
-
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order,
|
|
105
|
+
const { emailMessages, potentialActions } = yield (0, potentialActions_1.createPotentialActions)(Object.assign(Object.assign({ order: result.order, // createEmailMessageでのorder.acceptedOffersへの依存性を排除したのでこちらでよいはず(2024-02-21~)
|
|
106
|
+
customer,
|
|
105
107
|
// order: orderWithAcceptedOffers, // 現時点でcreateEmailMessageでorder.acceptedOffersを使用している(2024-02-06~)
|
|
106
108
|
// transaction: transaction,
|
|
107
109
|
useOptimizedSendEmailAction: params.options.useOptimizedSendEmailAction }, (params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined), (emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined));
|
|
108
110
|
// メッセージ保管(2024-04-28~)
|
|
109
|
-
yield saveMessagesIfNeeded({ options: params.options }, result.order, emailMessages)(repos);
|
|
111
|
+
yield saveMessagesIfNeeded({ options: params.options }, { id: transaction.project.id }, result.order, emailMessages)(repos);
|
|
110
112
|
// ステータス変更
|
|
111
113
|
try {
|
|
112
114
|
yield repos.transaction.confirm({
|
|
@@ -131,16 +133,16 @@ function confirm(params) {
|
|
|
131
133
|
});
|
|
132
134
|
}
|
|
133
135
|
exports.confirm = confirm;
|
|
134
|
-
function saveMessagesIfNeeded(params, order, emailMessages) {
|
|
136
|
+
function saveMessagesIfNeeded(params, project, order, emailMessages) {
|
|
135
137
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
136
138
|
if (params.options.useSaveMessages) {
|
|
137
139
|
if (emailMessages.length > 0) {
|
|
138
|
-
const { orderNumber, typeOf,
|
|
140
|
+
const { orderNumber, typeOf, seller } = order;
|
|
139
141
|
debug('saving', emailMessages.length, 'messages...', emailMessages);
|
|
140
142
|
const saveMessageResult = yield repos.message.upsertByIdentifier(emailMessages.map(({ identifier, name, about, text, toRecipient, sender }) => {
|
|
141
143
|
return {
|
|
142
144
|
identifier, name, about, text, toRecipient, sender,
|
|
143
|
-
project,
|
|
145
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
144
146
|
provider: { id: seller.id, typeOf: seller.typeOf },
|
|
145
147
|
mainEntity: { orderNumber, typeOf }
|
|
146
148
|
};
|
|
@@ -273,7 +275,7 @@ function createResult(params) {
|
|
|
273
275
|
// 注文作成
|
|
274
276
|
const order = (0, result_1.createOrder)({
|
|
275
277
|
orderNumber: params.orderNumber,
|
|
276
|
-
transaction
|
|
278
|
+
transaction,
|
|
277
279
|
orderDate: params.result.order.orderDate,
|
|
278
280
|
orderStatus: factory.orderStatus.OrderPaymentDue,
|
|
279
281
|
isGift: false,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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;
|
|
4
5
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
5
6
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
6
7
|
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 });
|
|
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,8 @@ 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;
|
|
7
8
|
potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
|
|
8
9
|
emailMessage?: factory.creativeWork.message.email.ICreativeWork;
|
|
9
10
|
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,7 @@ 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 createCustomer(params: {
|
|
17
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'object'>;
|
|
18
|
+
}): factory.order.ICustomer;
|
|
19
|
+
export { createOrder, createCustomer };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOrder = void 0;
|
|
3
|
+
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,15 @@ 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(Object.assign({
|
|
22
|
+
return Object.assign(Object.assign(Object.assign({ typeOf: factory.order.OrderType.Order, seller: seller, 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: [] }, (typeof name === 'string') ? { name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker } : undefined), (settings_1.USE_EXPERIMENTAL_FEATURE)
|
|
25
|
+
? {}
|
|
26
|
+
: {
|
|
27
|
+
customer,
|
|
28
|
+
project: params.transaction.project,
|
|
29
|
+
isGift: params.isGift // discontinue(2024-06-17~)
|
|
30
|
+
});
|
|
26
31
|
}
|
|
27
32
|
exports.createOrder = createOrder;
|
|
28
33
|
function createSeller(params) {
|
|
@@ -54,6 +59,7 @@ function createCustomer(params) {
|
|
|
54
59
|
}
|
|
55
60
|
return Object.assign(Object.assign({}, customerByTransaction), { identifier: (Array.isArray(customerByTransaction.identifier)) ? customerByTransaction.identifier : [], name: customerName });
|
|
56
61
|
}
|
|
62
|
+
exports.createCustomer = createCustomer;
|
|
57
63
|
function createPaymentMethods(params) {
|
|
58
64
|
const paymentMethods = [];
|
|
59
65
|
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.0",
|
|
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.0"
|
|
114
114
|
}
|