@chevre/domain 21.2.0-alpha.83 → 21.2.0-alpha.85
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/searchSellers.ts +2 -1
- package/lib/chevre/repo/assetTransaction.js +15 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +40 -33
- package/lib/chevre/service/order/onOrderUpdated.d.ts +15 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.js +32 -17
- package/lib/chevre/service/order/returnOrder.js +0 -3
- package/lib/chevre/service/order/sendOrder.js +0 -5
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -1
- package/lib/chevre/service/reserve/checkInReservation.js +54 -27
- package/lib/chevre/service/reserve/confirmReservation.js +2 -1
- package/lib/chevre/service/reserve.d.ts +2 -2
- package/lib/chevre/service/reserve.js +2 -2
- package/lib/chevre/service/task/onAuthorizationCreated.js +9 -2
- package/package.json +2 -2
|
@@ -19,7 +19,8 @@ async function main() {
|
|
|
19
19
|
limit: 1,
|
|
20
20
|
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
21
21
|
object: {
|
|
22
|
-
|
|
22
|
+
reservationNumber: { $eq: 'xxx' }
|
|
23
|
+
// reservationFor: { id: { $eq: 'xxx' } }
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
console.log('reserveTransactions:', reserveTransactions);
|
|
@@ -23,7 +23,7 @@ class MongoRepository {
|
|
|
23
23
|
}
|
|
24
24
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
25
25
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
27
27
|
const andConditions = [
|
|
28
28
|
{
|
|
29
29
|
typeOf: params.typeOf
|
|
@@ -184,7 +184,16 @@ class MongoRepository {
|
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
const
|
|
187
|
+
const objectReservationNumberIn = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationNumber) === null || _0 === void 0 ? void 0 : _0.$in;
|
|
188
|
+
if (Array.isArray(objectReservationNumberIn)) {
|
|
189
|
+
andConditions.push({
|
|
190
|
+
'object.reservationNumber': {
|
|
191
|
+
$exists: true,
|
|
192
|
+
$in: objectReservationNumberIn
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const objectReservationNumberEq = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.reservationNumber) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
188
197
|
if (typeof objectReservationNumberEq === 'string') {
|
|
189
198
|
andConditions.push({
|
|
190
199
|
'object.reservationNumber': {
|
|
@@ -193,7 +202,7 @@ class MongoRepository {
|
|
|
193
202
|
}
|
|
194
203
|
});
|
|
195
204
|
}
|
|
196
|
-
const objectSubReservationIdIn = (
|
|
205
|
+
const objectSubReservationIdIn = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservations) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$in;
|
|
197
206
|
if (Array.isArray(objectSubReservationIdIn)) {
|
|
198
207
|
andConditions.push({
|
|
199
208
|
'object.subReservation.id': {
|
|
@@ -228,7 +237,7 @@ class MongoRepository {
|
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
}
|
|
231
|
-
const objectUnderNameIdEq = (
|
|
240
|
+
const objectUnderNameIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.underName) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$eq;
|
|
232
241
|
if (typeof objectUnderNameIdEq === 'string') {
|
|
233
242
|
andConditions.push({
|
|
234
243
|
'object.underName.id': {
|
|
@@ -239,7 +248,7 @@ class MongoRepository {
|
|
|
239
248
|
}
|
|
240
249
|
break;
|
|
241
250
|
case factory.assetTransactionType.RegisterService:
|
|
242
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
251
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.itemOffered) === null || _10 === void 0 ? void 0 : _10.serviceOutput) === null || _11 === void 0 ? void 0 : _11.identifier) === null || _12 === void 0 ? void 0 : _12.$eq;
|
|
243
252
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
244
253
|
andConditions.push({
|
|
245
254
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -248,7 +257,7 @@ class MongoRepository {
|
|
|
248
257
|
}
|
|
249
258
|
});
|
|
250
259
|
}
|
|
251
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
260
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_16 = (_15 = (_14 = (_13 = params.object) === null || _13 === void 0 ? void 0 : _13.itemOffered) === null || _14 === void 0 ? void 0 : _14.serviceOutput) === null || _15 === void 0 ? void 0 : _15.identifier) === null || _16 === void 0 ? void 0 : _16.$in;
|
|
252
261
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
253
262
|
andConditions.push({
|
|
254
263
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -6,7 +6,10 @@ export declare function getOrderWithToken(params: {
|
|
|
6
6
|
order: factory.order.IOrder;
|
|
7
7
|
expiresIn: number;
|
|
8
8
|
}): Promise<factory.order.IOrder | IOrderWithToken>;
|
|
9
|
-
export
|
|
9
|
+
export type IUpdatedOrder4inform = Pick<factory.order.IOrder, 'typeOf' | 'orderNumber' | 'name' | 'additionalProperty' | 'project'> & {
|
|
10
|
+
orderStatus?: undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare function createInformTasks(order: factory.order.IOrder | IOrderWithToken | IUpdatedOrder4inform): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
10
13
|
export declare function createConfirmReservationActionObject4ChevreByOrder(params: {
|
|
11
14
|
order: factory.order.IOrder;
|
|
12
15
|
}): factory.action.interact.confirm.reservation.IObject<factory.service.webAPI.Identifier.Chevre>[];
|
|
@@ -63,10 +63,13 @@ function createInformTasks(order) {
|
|
|
63
63
|
let informTasks = [];
|
|
64
64
|
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
65
65
|
const order4inform = creteOrder4inform(order);
|
|
66
|
-
let recipientId =
|
|
67
|
-
if (order.orderStatus ===
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
let recipientId = '';
|
|
67
|
+
if (typeof order.orderStatus === 'string') {
|
|
68
|
+
recipientId = order.customer.id;
|
|
69
|
+
if (order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
70
|
+
if (typeof ((_a = order.returner) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
71
|
+
recipientId = order.returner.id;
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
informTasks = informOrder.map((informOrderParams) => {
|
|
@@ -75,7 +78,6 @@ function createInformTasks(order) {
|
|
|
75
78
|
agent: order.project,
|
|
76
79
|
object: order4inform,
|
|
77
80
|
project: order.project,
|
|
78
|
-
// purpose: params.transaction,
|
|
79
81
|
recipient: {
|
|
80
82
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
81
83
|
id: recipientId,
|
|
@@ -100,36 +102,41 @@ function createInformTasks(order) {
|
|
|
100
102
|
}
|
|
101
103
|
exports.createInformTasks = createInformTasks;
|
|
102
104
|
function creteOrder4inform(order) {
|
|
103
|
-
if (order.orderStatus ===
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
if (typeof order.orderStatus === 'string') {
|
|
106
|
+
if (order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
107
|
+
// 返品注文通知内容を最適化(2022-12-28~)
|
|
108
|
+
return Object.assign(Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: order.orderStatus }, (order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
109
|
+
}
|
|
110
|
+
else if (order.orderStatus === factory.orderStatus.OrderDelivered) {
|
|
111
|
+
// 配送済注文通知内容を最適化(2022-12-29~)
|
|
112
|
+
return Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: order.orderStatus }, (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// 冗長な個人情報をmask
|
|
116
|
+
return Object.assign(Object.assign({
|
|
117
|
+
// whitelistで作成する(2022-07-19~)
|
|
118
|
+
project: order.project, typeOf: order.typeOf, seller: order.seller, price: order.price, priceCurrency: order.priceCurrency, confirmationNumber: order.confirmationNumber, orderNumber: order.orderNumber, acceptedOffers: order.acceptedOffers, orderStatus: order.orderStatus, orderDate: order.orderDate,
|
|
119
|
+
// mask
|
|
120
|
+
customer: Object.assign(Object.assign({}, (0, order_1.createMaskedCustomer)(order)), { additionalProperty: (Array.isArray(order.customer.additionalProperty)) ? order.customer.additionalProperty : [],
|
|
121
|
+
// identifierは必要
|
|
122
|
+
// 予約後を隠蔽(2022-12-24~)
|
|
123
|
+
identifier: (Array.isArray(order.customer.identifier))
|
|
124
|
+
? order.customer.identifier.filter((p) => {
|
|
125
|
+
return !reservedAgentIdentifireNames_1.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
|
|
126
|
+
})
|
|
127
|
+
: [] }),
|
|
128
|
+
// paymentMethodsに関してもmask(2022-05-30~)
|
|
129
|
+
paymentMethods: order.paymentMethods.map((p) => {
|
|
130
|
+
return Object.assign(Object.assign({}, p), (typeof p.accountId === 'string' && p.accountId.length > 0)
|
|
131
|
+
? { accountId: ASTERISK_CHARACTER.repeat(p.accountId.length) }
|
|
132
|
+
: undefined);
|
|
133
|
+
}) }, (typeof order.token === 'string')
|
|
134
|
+
? { token: order.token }
|
|
135
|
+
: undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
136
|
+
}
|
|
110
137
|
}
|
|
111
138
|
else {
|
|
112
|
-
|
|
113
|
-
return Object.assign(Object.assign({
|
|
114
|
-
// whitelistで作成する(2022-07-19~)
|
|
115
|
-
project: order.project, typeOf: order.typeOf, seller: order.seller, price: order.price, priceCurrency: order.priceCurrency, confirmationNumber: order.confirmationNumber, orderNumber: order.orderNumber, acceptedOffers: order.acceptedOffers, orderStatus: order.orderStatus, orderDate: order.orderDate,
|
|
116
|
-
// mask
|
|
117
|
-
customer: Object.assign(Object.assign({}, (0, order_1.createMaskedCustomer)(order)), { additionalProperty: (Array.isArray(order.customer.additionalProperty)) ? order.customer.additionalProperty : [],
|
|
118
|
-
// identifierは必要
|
|
119
|
-
// 予約後を隠蔽(2022-12-24~)
|
|
120
|
-
identifier: (Array.isArray(order.customer.identifier))
|
|
121
|
-
? order.customer.identifier.filter((p) => {
|
|
122
|
-
return !reservedAgentIdentifireNames_1.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
|
|
123
|
-
})
|
|
124
|
-
: [] }),
|
|
125
|
-
// paymentMethodsに関してもmask(2022-05-30~)
|
|
126
|
-
paymentMethods: order.paymentMethods.map((p) => {
|
|
127
|
-
return Object.assign(Object.assign({}, p), (typeof p.accountId === 'string' && p.accountId.length > 0)
|
|
128
|
-
? { accountId: ASTERISK_CHARACTER.repeat(p.accountId.length) }
|
|
129
|
-
: undefined);
|
|
130
|
-
}) }, (typeof order.token === 'string')
|
|
131
|
-
? { token: order.token }
|
|
132
|
-
: undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
139
|
+
return order;
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
function createConfirmReservationActionObject4ChevreByOrder(params) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 注文変更時処理
|
|
3
|
+
*/
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
|
+
import * as factory from '../../factory';
|
|
6
|
+
export declare function onOrderUpdated(params: {
|
|
7
|
+
additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
|
|
8
|
+
name?: string;
|
|
9
|
+
orderNumber: string;
|
|
10
|
+
project: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
}): (repos: {
|
|
14
|
+
task: TaskRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.onOrderUpdated = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const factory_1 = require("./onOrderStatusChanged/factory");
|
|
15
|
+
function onOrderUpdated(params) {
|
|
16
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
let tasks = [];
|
|
18
|
+
tasks = (0, factory_1.createInformTasks)(Object.assign(Object.assign({ typeOf: factory.order.OrderType.Order, orderNumber: params.orderNumber, project: { id: params.project.id, typeOf: factory.organizationType.Project } }, (typeof params.name === 'string') ? { name: params.name } : undefined), (Array.isArray(params.additionalProperty)) ? { additionalProperty: params.additionalProperty } : undefined));
|
|
19
|
+
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.onOrderUpdated = onOrderUpdated;
|
|
@@ -168,44 +168,59 @@ function placeOrder(params) {
|
|
|
168
168
|
confirmationNumber: params.object.confirmationNumber,
|
|
169
169
|
orderNumber: params.object.orderNumber
|
|
170
170
|
})({ transaction: repos.transaction });
|
|
171
|
-
// アクションを作成する(2022-04-11~)
|
|
172
171
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
173
172
|
const simpleOrder = {
|
|
174
|
-
// project: order.project,
|
|
175
173
|
typeOf: order.typeOf,
|
|
176
174
|
seller: order.seller,
|
|
177
175
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
178
|
-
// IOrderへ移行(2022-11-17~)
|
|
179
|
-
// confirmationNumber: order.confirmationNumber,
|
|
180
176
|
orderNumber: order.orderNumber,
|
|
181
177
|
price: order.price,
|
|
182
178
|
priceCurrency: order.priceCurrency,
|
|
183
179
|
orderDate: order.orderDate
|
|
184
180
|
};
|
|
181
|
+
const orderActionPurpose = {
|
|
182
|
+
typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id
|
|
183
|
+
};
|
|
185
184
|
const orderActionAttributes = {
|
|
186
185
|
agent: (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? params.agent : order.project,
|
|
187
186
|
object: simpleOrder,
|
|
188
187
|
potentialActions: {},
|
|
189
188
|
project: order.project,
|
|
190
|
-
purpose:
|
|
189
|
+
purpose: orderActionPurpose,
|
|
191
190
|
typeOf: factory.actionType.OrderAction
|
|
192
191
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
// 冪等性を担保(2023-05-31~)
|
|
193
|
+
const completedActions = yield repos.action.search({
|
|
194
|
+
limit: 1,
|
|
195
|
+
page: 1,
|
|
196
|
+
actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
197
|
+
typeOf: { $eq: orderActionAttributes.typeOf },
|
|
198
|
+
object: {
|
|
199
|
+
orderNumber: { $in: [orderActionAttributes.object.orderNumber] }
|
|
200
|
+
},
|
|
201
|
+
purpose: {
|
|
202
|
+
id: { $in: [orderActionPurpose.id] },
|
|
203
|
+
typeOf: { $in: [orderActionPurpose.typeOf] }
|
|
204
|
+
}
|
|
205
|
+
}, ['_id'], []);
|
|
206
|
+
if (completedActions.length === 0) {
|
|
207
|
+
const action = yield repos.action.start(orderActionAttributes);
|
|
199
208
|
try {
|
|
200
|
-
|
|
201
|
-
yield repos.action.giveUp({ typeOf: orderActionAttributes.typeOf, id: action.id, error: actionError });
|
|
209
|
+
yield repos.order.createIfNotExist(order);
|
|
202
210
|
}
|
|
203
|
-
catch (
|
|
204
|
-
//
|
|
211
|
+
catch (error) {
|
|
212
|
+
// actionにエラー結果を追加
|
|
213
|
+
try {
|
|
214
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
215
|
+
yield repos.action.giveUp({ typeOf: orderActionAttributes.typeOf, id: action.id, error: actionError });
|
|
216
|
+
}
|
|
217
|
+
catch (__) {
|
|
218
|
+
// 失敗したら仕方ない
|
|
219
|
+
}
|
|
220
|
+
throw error;
|
|
205
221
|
}
|
|
206
|
-
|
|
222
|
+
yield repos.action.complete({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
|
|
207
223
|
}
|
|
208
|
-
yield repos.action.complete({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
|
|
209
224
|
if (params.useOnOrderStatusChanged || params.useOnOrderStatusChanged === undefined) {
|
|
210
225
|
// 経理レポートを保管
|
|
211
226
|
yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(order)({ accountingReport: repos.accountingReport });
|
|
@@ -42,12 +42,9 @@ function returnOrder(params) {
|
|
|
42
42
|
throw new factory.errors.NotFound(factory.transactionType.ReturnOrder);
|
|
43
43
|
}
|
|
44
44
|
const simpleOrder = {
|
|
45
|
-
// project: order.project,
|
|
46
45
|
typeOf: order.typeOf,
|
|
47
46
|
seller: order.seller,
|
|
48
47
|
customer: (0, order_1.createMaskedCustomer)(order),
|
|
49
|
-
// IOrderへ移行(2022-11-17~)
|
|
50
|
-
// confirmationNumber: order.confirmationNumber,
|
|
51
48
|
orderNumber: order.orderNumber,
|
|
52
49
|
price: order.price,
|
|
53
50
|
priceCurrency: order.priceCurrency,
|
|
@@ -40,16 +40,11 @@ function sendOrder(params) {
|
|
|
40
40
|
if (order.confirmationNumber !== confirmationNumber) {
|
|
41
41
|
throw new factory.errors.NotFound('Order');
|
|
42
42
|
}
|
|
43
|
-
// SendOrderアクションを作成する
|
|
44
|
-
// minimizeする(2022-04-18~)
|
|
45
43
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
46
44
|
const simpleOrder = {
|
|
47
|
-
// project: order.project,
|
|
48
45
|
typeOf: order.typeOf,
|
|
49
46
|
seller: order.seller,
|
|
50
47
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
51
|
-
// IOrderへ移行(2022-11-17~)
|
|
52
|
-
// confirmationNumber: order.confirmationNumber,
|
|
53
48
|
orderNumber: order.orderNumber,
|
|
54
49
|
price: order.price,
|
|
55
50
|
priceCurrency: order.priceCurrency,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { deleteOrder } from './order/deleteOrder';
|
|
5
5
|
import { onOrderStatusChanged } from './order/onOrderStatusChanged';
|
|
6
|
+
import { onOrderUpdated } from './order/onOrderUpdated';
|
|
6
7
|
import { placeOrder, placeOrderWithoutTransaction } from './order/placeOrder';
|
|
7
8
|
import { returnOrder } from './order/returnOrder';
|
|
8
9
|
import { sendOrder } from './order/sendOrder';
|
|
9
|
-
export { deleteOrder, onOrderStatusChanged, placeOrder, placeOrderWithoutTransaction, returnOrder, sendOrder };
|
|
10
|
+
export { deleteOrder, onOrderStatusChanged, onOrderUpdated, placeOrder, placeOrderWithoutTransaction, returnOrder, sendOrder };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendOrder = exports.returnOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.onOrderStatusChanged = exports.deleteOrder = void 0;
|
|
3
|
+
exports.sendOrder = exports.returnOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.onOrderUpdated = exports.onOrderStatusChanged = exports.deleteOrder = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文サービス
|
|
6
6
|
*/
|
|
@@ -8,6 +8,8 @@ const deleteOrder_1 = require("./order/deleteOrder");
|
|
|
8
8
|
Object.defineProperty(exports, "deleteOrder", { enumerable: true, get: function () { return deleteOrder_1.deleteOrder; } });
|
|
9
9
|
const onOrderStatusChanged_1 = require("./order/onOrderStatusChanged");
|
|
10
10
|
Object.defineProperty(exports, "onOrderStatusChanged", { enumerable: true, get: function () { return onOrderStatusChanged_1.onOrderStatusChanged; } });
|
|
11
|
+
const onOrderUpdated_1 = require("./order/onOrderUpdated");
|
|
12
|
+
Object.defineProperty(exports, "onOrderUpdated", { enumerable: true, get: function () { return onOrderUpdated_1.onOrderUpdated; } });
|
|
11
13
|
const placeOrder_1 = require("./order/placeOrder");
|
|
12
14
|
Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return placeOrder_1.placeOrder; } });
|
|
13
15
|
Object.defineProperty(exports, "placeOrderWithoutTransaction", { enumerable: true, get: function () { return placeOrder_1.placeOrderWithoutTransaction; } });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
|
+
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
1
3
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
2
4
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
3
|
-
|
|
5
|
+
interface ICheckInReservationParams {
|
|
4
6
|
project: {
|
|
5
7
|
id: string;
|
|
6
8
|
};
|
|
@@ -20,7 +22,13 @@ export declare function checkInRerservation(params: {
|
|
|
20
22
|
ids?: string[];
|
|
21
23
|
};
|
|
22
24
|
};
|
|
25
|
+
}
|
|
26
|
+
export declare function checkInReservation(params: ICheckInReservationParams & {
|
|
27
|
+
reserveIfNotYet: boolean;
|
|
23
28
|
}): (repos: {
|
|
29
|
+
action: ActionRepo;
|
|
30
|
+
assetTransaction: AssetTransactionRepo;
|
|
24
31
|
reservation: ReservationRepo;
|
|
25
32
|
task: TaskRepo;
|
|
26
33
|
}) => Promise<void>;
|
|
34
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import * as factory from '../../factory';
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,37 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
9
|
});
|
|
11
10
|
};
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
14
|
-
|
|
12
|
+
exports.checkInReservation = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const confirmReservation_1 = require("./confirmReservation");
|
|
15
15
|
const onReservationCheckedIn_1 = require("./potentialActions/onReservationCheckedIn");
|
|
16
|
-
function
|
|
16
|
+
function checkInReservation(params) {
|
|
17
17
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const now = new Date();
|
|
19
|
+
// confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
|
|
20
|
+
if (params.reserveIfNotYet === true) {
|
|
21
|
+
yield reserveIfNotYet(params)(repos);
|
|
22
|
+
}
|
|
19
23
|
// 発券処理(Array対応)
|
|
20
24
|
let checkedInReservationIds;
|
|
21
25
|
if (Array.isArray(params.object.ids) && params.object.ids.length > 0) {
|
|
22
|
-
// confirmReservationが間に合わない可能性を考慮する(2023-05-30~)
|
|
23
|
-
// const reserveTransactions = await repos.assetTransaction.search<factory.assetTransactionType.Reserve>({
|
|
24
|
-
// typeOf: factory.assetTransactionType.Reserve,
|
|
25
|
-
// object: {
|
|
26
|
-
// reservations: {
|
|
27
|
-
// id: { $in: params.object.ids }
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// });
|
|
31
|
-
// await Promise.all(reserveTransactions.map(async (reserveTransaction) => {
|
|
32
|
-
// await confirmReservation([{
|
|
33
|
-
// project: reserveTransaction.project,
|
|
34
|
-
// typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
|
|
35
|
-
// // result: {},
|
|
36
|
-
// object: reservationPackage,
|
|
37
|
-
// agent: reserveTransaction.project,
|
|
38
|
-
// potentialActions: {
|
|
39
|
-
// moneyTransfer: moneyTransferActions
|
|
40
|
-
// },
|
|
41
|
-
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
42
|
-
// }])(repos);
|
|
43
|
-
// }))
|
|
44
26
|
yield repos.reservation.checkInIfNot({ id: { $in: params.object.ids }, now });
|
|
45
27
|
checkedInReservationIds = params.object.ids;
|
|
46
28
|
}
|
|
@@ -61,4 +43,49 @@ function checkInRerservation(params) {
|
|
|
61
43
|
})({ task: repos.task });
|
|
62
44
|
});
|
|
63
45
|
}
|
|
64
|
-
exports.
|
|
46
|
+
exports.checkInReservation = checkInReservation;
|
|
47
|
+
function reserveIfNotYet(params) {
|
|
48
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
let reserveTransactions = [];
|
|
50
|
+
if (Array.isArray(params.object.ids) && params.object.ids.length > 0) {
|
|
51
|
+
reserveTransactions = yield repos.assetTransaction.search({
|
|
52
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
53
|
+
object: {
|
|
54
|
+
reservations: { id: { $in: params.object.ids } }
|
|
55
|
+
},
|
|
56
|
+
statuses: [factory.transactionStatusType.Confirmed]
|
|
57
|
+
}, ['_id', 'transactionNumber', 'object', 'project', 'typeOf']);
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(params.object.reservationNumbers) && params.object.reservationNumbers.length > 0) {
|
|
60
|
+
reserveTransactions = yield repos.assetTransaction.search({
|
|
61
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
62
|
+
object: {
|
|
63
|
+
reservationNumber: { $in: params.object.reservationNumbers }
|
|
64
|
+
},
|
|
65
|
+
statuses: [factory.transactionStatusType.Confirmed]
|
|
66
|
+
}, ['_id', 'transactionNumber', 'object', 'project', 'typeOf']);
|
|
67
|
+
}
|
|
68
|
+
yield Promise.all(reserveTransactions.map((reserveTransaction) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
if (typeof ((_a = reserveTransaction.object.reservationFor) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
71
|
+
yield (0, confirmReservation_1.confirmReservation)({
|
|
72
|
+
actionAttributesList: [{
|
|
73
|
+
project: reserveTransaction.project,
|
|
74
|
+
typeOf: factory.actionType.ReserveAction,
|
|
75
|
+
object: {
|
|
76
|
+
typeOf: reserveTransaction.object.typeOf,
|
|
77
|
+
reservationNumber: reserveTransaction.object.reservationNumber,
|
|
78
|
+
reservationStatus: (typeof reserveTransaction.object.reservationStatus === 'string')
|
|
79
|
+
? reserveTransaction.object.reservationStatus
|
|
80
|
+
: factory.reservationStatusType.ReservationPending,
|
|
81
|
+
reservationFor: reserveTransaction.object.reservationFor
|
|
82
|
+
},
|
|
83
|
+
agent: reserveTransaction.project,
|
|
84
|
+
purpose: { typeOf: reserveTransaction.typeOf, id: reserveTransaction.id }
|
|
85
|
+
}],
|
|
86
|
+
useOnReservationConfirmed: false // ここでは確定予約の存在を担保すればよいだけ
|
|
87
|
+
})(repos);
|
|
88
|
+
}
|
|
89
|
+
})));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -49,8 +49,8 @@ function confirmReservation(params) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
exports.confirmReservation = confirmReservation;
|
|
52
|
-
// tslint:disable-next-line:max-func-body-length
|
|
53
52
|
function reserveIfNotYet(params) {
|
|
53
|
+
// tslint:disable-next-line:max-func-body-length
|
|
54
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
var _a;
|
|
56
56
|
const reservationPackage = params.object;
|
|
@@ -58,6 +58,7 @@ function reserveIfNotYet(params) {
|
|
|
58
58
|
const completedActions = yield repos.action.search({
|
|
59
59
|
limit: 1,
|
|
60
60
|
page: 1,
|
|
61
|
+
actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
61
62
|
typeOf: { $eq: params.typeOf },
|
|
62
63
|
object: {
|
|
63
64
|
typeOf: { $eq: params.object.typeOf }
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { maskUnderName } from './reserve/factory';
|
|
5
5
|
import { cancelPendingReservation, cancelReservation } from './reserve/cancelReservation';
|
|
6
|
-
import {
|
|
6
|
+
import { checkInReservation } from './reserve/checkInReservation';
|
|
7
7
|
import { confirmReservation } from './reserve/confirmReservation';
|
|
8
8
|
import { useReservation } from './reserve/useReservation';
|
|
9
9
|
import { verifyToken4reservation } from './reserve/verifyToken4reservation';
|
|
10
|
-
export { maskUnderName, cancelPendingReservation, cancelReservation,
|
|
10
|
+
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInReservation, confirmReservation, useReservation, verifyToken4reservation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyToken4reservation = exports.useReservation = exports.confirmReservation = exports.
|
|
3
|
+
exports.verifyToken4reservation = exports.useReservation = exports.confirmReservation = exports.checkInReservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約サービス
|
|
6
6
|
*/
|
|
@@ -10,7 +10,7 @@ const cancelReservation_1 = require("./reserve/cancelReservation");
|
|
|
10
10
|
Object.defineProperty(exports, "cancelPendingReservation", { enumerable: true, get: function () { return cancelReservation_1.cancelPendingReservation; } });
|
|
11
11
|
Object.defineProperty(exports, "cancelReservation", { enumerable: true, get: function () { return cancelReservation_1.cancelReservation; } });
|
|
12
12
|
const checkInReservation_1 = require("./reserve/checkInReservation");
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "checkInReservation", { enumerable: true, get: function () { return checkInReservation_1.checkInReservation; } });
|
|
14
14
|
const confirmReservation_1 = require("./reserve/confirmReservation");
|
|
15
15
|
Object.defineProperty(exports, "confirmReservation", { enumerable: true, get: function () { return confirmReservation_1.confirmReservation; } });
|
|
16
16
|
const useReservation_1 = require("./reserve/useReservation");
|
|
@@ -11,6 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
const action_1 = require("../../repo/action");
|
|
15
|
+
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
14
16
|
const code_1 = require("../../repo/code");
|
|
15
17
|
const order_1 = require("../../repo/order");
|
|
16
18
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
@@ -23,6 +25,8 @@ const reserve_1 = require("../reserve");
|
|
|
23
25
|
function call(data) {
|
|
24
26
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
27
|
yield onAuthorizationCreated(data)({
|
|
28
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
29
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
26
30
|
code: new code_1.MongoRepository(settings.connection),
|
|
27
31
|
order: new order_1.MongoRepository(settings.connection),
|
|
28
32
|
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
@@ -86,14 +90,17 @@ function onAuthorizationCreated(params) {
|
|
|
86
90
|
default:
|
|
87
91
|
// no op
|
|
88
92
|
}
|
|
89
|
-
yield (0, reserve_1.
|
|
93
|
+
yield (0, reserve_1.checkInReservation)({
|
|
90
94
|
project: { id: params.project.id },
|
|
91
95
|
object: {
|
|
92
96
|
ids: reservationIds,
|
|
93
97
|
reservationNumbers: reservationNumbers,
|
|
94
98
|
reservationFor: { ids: reservationForIds }
|
|
95
|
-
}
|
|
99
|
+
},
|
|
100
|
+
reserveIfNotYet: false
|
|
96
101
|
})({
|
|
102
|
+
action: repos.action,
|
|
103
|
+
assetTransaction: repos.assetTransaction,
|
|
97
104
|
reservation: repos.reservation,
|
|
98
105
|
task: repos.task
|
|
99
106
|
});
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.21",
|
|
13
13
|
"@cinerino/sdk": "3.157.0-alpha.5",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.85"
|
|
121
121
|
}
|