@chevre/domain 21.20.0-alpha.27 → 21.20.0-alpha.28
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/lib/chevre/factory/order.d.ts +1 -0
- package/lib/chevre/factory/order.js +2 -1
- package/lib/chevre/repo/action.d.ts +3 -0
- package/lib/chevre/repo/action.js +46 -42
- package/lib/chevre/service/offer/any.d.ts +3 -0
- package/lib/chevre/service/order/placeOrder.js +37 -13
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +194 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +16 -65
- package/lib/chevre/service/transaction/placeOrderInProgress.js +14 -245
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
|
+
export declare const POINT_AWARD_IDENTIFIER_NAME = "pointAwardIdentifiers";
|
|
2
3
|
export declare const AWARD_ACCOUNTS_IDENTIFIER_NAME = "awardAccounts";
|
|
3
4
|
export type IMaskedCustomer = factory.order.ICustomer | Pick<factory.order.ICustomer, 'id' | 'typeOf'>;
|
|
4
5
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMaskedCustomer = exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = void 0;
|
|
3
|
+
exports.createMaskedCustomer = exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = exports.POINT_AWARD_IDENTIFIER_NAME = void 0;
|
|
4
|
+
exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
4
5
|
exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = 'awardAccounts';
|
|
5
6
|
const MASKED_PROFILE = '****';
|
|
6
7
|
/**
|
|
@@ -22,9 +22,13 @@ class MongoRepository {
|
|
|
22
22
|
}
|
|
23
23
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
24
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
-
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, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65;
|
|
25
|
+
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, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66;
|
|
26
26
|
const andConditions = [];
|
|
27
|
-
const
|
|
27
|
+
const idNin = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$nin;
|
|
28
|
+
if (Array.isArray(idNin)) {
|
|
29
|
+
andConditions.push({ _id: { $nin: idNin } });
|
|
30
|
+
}
|
|
31
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
28
32
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
29
33
|
/* istanbul ignore else */
|
|
30
34
|
if (typeof projectIdEq === 'string') {
|
|
@@ -36,7 +40,7 @@ class MongoRepository {
|
|
|
36
40
|
}
|
|
37
41
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
38
42
|
/* istanbul ignore else */
|
|
39
|
-
const agentTypeOfIn = (
|
|
43
|
+
const agentTypeOfIn = (_e = (_d = params.agent) === null || _d === void 0 ? void 0 : _d.typeOf) === null || _e === void 0 ? void 0 : _e.$in;
|
|
40
44
|
if (Array.isArray(agentTypeOfIn)) {
|
|
41
45
|
andConditions.push({
|
|
42
46
|
'agent.typeOf': {
|
|
@@ -45,7 +49,7 @@ class MongoRepository {
|
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
|
-
const agentIdIn = (
|
|
52
|
+
const agentIdIn = (_g = (_f = params.agent) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
49
53
|
if (Array.isArray(agentIdIn)) {
|
|
50
54
|
andConditions.push({
|
|
51
55
|
'agent.id': {
|
|
@@ -54,7 +58,7 @@ class MongoRepository {
|
|
|
54
58
|
}
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
|
-
const locationIdEq = (
|
|
61
|
+
const locationIdEq = (_j = (_h = params.location) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
58
62
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
59
63
|
/* istanbul ignore else */
|
|
60
64
|
if (typeof locationIdEq === 'string') {
|
|
@@ -65,7 +69,7 @@ class MongoRepository {
|
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
|
-
const locationIdentifierEq = (
|
|
72
|
+
const locationIdentifierEq = (_l = (_k = params.location) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
69
73
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
70
74
|
/* istanbul ignore else */
|
|
71
75
|
if (typeof locationIdentifierEq === 'string') {
|
|
@@ -76,7 +80,7 @@ class MongoRepository {
|
|
|
76
80
|
}
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
|
-
const objectMovieTicketsIdentifierEq = (
|
|
83
|
+
const objectMovieTicketsIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.movieTickets) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
80
84
|
if (typeof objectMovieTicketsIdentifierEq === 'string') {
|
|
81
85
|
andConditions.push({
|
|
82
86
|
'object.movieTickets.identifier': {
|
|
@@ -85,7 +89,7 @@ class MongoRepository {
|
|
|
85
89
|
}
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
|
-
const objectMovieTicketsServiceOutputReservationForIdEq = (_t = (_s = (_r = (_q =
|
|
92
|
+
const objectMovieTicketsServiceOutputReservationForIdEq = (_u = (_t = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.movieTickets) === null || _r === void 0 ? void 0 : _r.serviceOutput) === null || _s === void 0 ? void 0 : _s.reservationFor) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
89
93
|
if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
|
|
90
94
|
andConditions.push({
|
|
91
95
|
'object.movieTickets.serviceOutput.reservationFor.id': {
|
|
@@ -96,7 +100,7 @@ class MongoRepository {
|
|
|
96
100
|
}
|
|
97
101
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
98
102
|
/* istanbul ignore else */
|
|
99
|
-
const objectPaymentMethodIdEq = (
|
|
103
|
+
const objectPaymentMethodIdEq = (_w = (_v = params.object) === null || _v === void 0 ? void 0 : _v.paymentMethodId) === null || _w === void 0 ? void 0 : _w.$eq;
|
|
100
104
|
if (typeof objectPaymentMethodIdEq === 'string') {
|
|
101
105
|
andConditions.push({
|
|
102
106
|
'object.paymentMethodId': {
|
|
@@ -105,7 +109,7 @@ class MongoRepository {
|
|
|
105
109
|
}
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
|
-
const objectObjectPaymentMethodIdEq = (
|
|
112
|
+
const objectObjectPaymentMethodIdEq = (_z = (_y = (_x = params.object) === null || _x === void 0 ? void 0 : _x.object) === null || _y === void 0 ? void 0 : _y.paymentMethodId) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
109
113
|
if (typeof objectObjectPaymentMethodIdEq === 'string') {
|
|
110
114
|
andConditions.push({
|
|
111
115
|
'object.object.paymentMethodId': {
|
|
@@ -114,7 +118,7 @@ class MongoRepository {
|
|
|
114
118
|
}
|
|
115
119
|
});
|
|
116
120
|
}
|
|
117
|
-
const objectReservationForIdEq = (
|
|
121
|
+
const objectReservationForIdEq = (_2 = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.reservationFor) === null || _1 === void 0 ? void 0 : _1.id) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
118
122
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
119
123
|
/* istanbul ignore else */
|
|
120
124
|
if (typeof objectReservationForIdEq === 'string') {
|
|
@@ -125,7 +129,7 @@ class MongoRepository {
|
|
|
125
129
|
}
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
|
-
const objectReservationNumberEq = (
|
|
132
|
+
const objectReservationNumberEq = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservationNumber) === null || _4 === void 0 ? void 0 : _4.$eq;
|
|
129
133
|
if (typeof objectReservationNumberEq === 'string') {
|
|
130
134
|
andConditions.push({
|
|
131
135
|
'object.reservationNumber': {
|
|
@@ -134,7 +138,7 @@ class MongoRepository {
|
|
|
134
138
|
}
|
|
135
139
|
});
|
|
136
140
|
}
|
|
137
|
-
const objectReservationNumberIn = (
|
|
141
|
+
const objectReservationNumberIn = (_6 = (_5 = params.object) === null || _5 === void 0 ? void 0 : _5.reservationNumber) === null || _6 === void 0 ? void 0 : _6.$in;
|
|
138
142
|
if (Array.isArray(objectReservationNumberIn)) {
|
|
139
143
|
andConditions.push({
|
|
140
144
|
'object.reservationNumber': {
|
|
@@ -143,7 +147,7 @@ class MongoRepository {
|
|
|
143
147
|
}
|
|
144
148
|
});
|
|
145
149
|
}
|
|
146
|
-
const objectPaymentMethodAccountIdEq = (
|
|
150
|
+
const objectPaymentMethodAccountIdEq = (_9 = (_8 = (_7 = params.object) === null || _7 === void 0 ? void 0 : _7.paymentMethod) === null || _8 === void 0 ? void 0 : _8.accountId) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
147
151
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
148
152
|
/* istanbul ignore else */
|
|
149
153
|
if (typeof objectPaymentMethodAccountIdEq === 'string') {
|
|
@@ -154,7 +158,7 @@ class MongoRepository {
|
|
|
154
158
|
}
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
|
-
const objectPaymentMethodPaymentMethodIdEq = (
|
|
161
|
+
const objectPaymentMethodPaymentMethodIdEq = (_12 = (_11 = (_10 = params.object) === null || _10 === void 0 ? void 0 : _10.paymentMethod) === null || _11 === void 0 ? void 0 : _11.paymentMethodId) === null || _12 === void 0 ? void 0 : _12.$eq;
|
|
158
162
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
159
163
|
/* istanbul ignore else */
|
|
160
164
|
if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
|
|
@@ -165,7 +169,7 @@ class MongoRepository {
|
|
|
165
169
|
}
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
|
-
const objectPaymentMethodPaymentMethodIdIn = (
|
|
172
|
+
const objectPaymentMethodPaymentMethodIdIn = (_15 = (_14 = (_13 = params.object) === null || _13 === void 0 ? void 0 : _13.paymentMethod) === null || _14 === void 0 ? void 0 : _14.paymentMethodId) === null || _15 === void 0 ? void 0 : _15.$in;
|
|
169
173
|
if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
|
|
170
174
|
andConditions.push({
|
|
171
175
|
'object.paymentMethod.paymentMethodId': {
|
|
@@ -174,7 +178,7 @@ class MongoRepository {
|
|
|
174
178
|
}
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
|
-
const objectPaymentMethodTypeOfEq = (
|
|
181
|
+
const objectPaymentMethodTypeOfEq = (_18 = (_17 = (_16 = params.object) === null || _16 === void 0 ? void 0 : _16.paymentMethod) === null || _17 === void 0 ? void 0 : _17.typeOf) === null || _18 === void 0 ? void 0 : _18.$eq;
|
|
178
182
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
179
183
|
/* istanbul ignore else */
|
|
180
184
|
if (typeof objectPaymentMethodTypeOfEq === 'string') {
|
|
@@ -185,7 +189,7 @@ class MongoRepository {
|
|
|
185
189
|
}
|
|
186
190
|
});
|
|
187
191
|
}
|
|
188
|
-
const objectTypeOfEq = (
|
|
192
|
+
const objectTypeOfEq = (_20 = (_19 = params.object) === null || _19 === void 0 ? void 0 : _19.typeOf) === null || _20 === void 0 ? void 0 : _20.$eq;
|
|
189
193
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
190
194
|
/* istanbul ignore else */
|
|
191
195
|
if (typeof objectTypeOfEq === 'string') {
|
|
@@ -196,7 +200,7 @@ class MongoRepository {
|
|
|
196
200
|
}
|
|
197
201
|
});
|
|
198
202
|
}
|
|
199
|
-
const objectTypeOfIn = (
|
|
203
|
+
const objectTypeOfIn = (_22 = (_21 = params.object) === null || _21 === void 0 ? void 0 : _21.typeOf) === null || _22 === void 0 ? void 0 : _22.$in;
|
|
200
204
|
if (Array.isArray(objectTypeOfIn)) {
|
|
201
205
|
andConditions.push({
|
|
202
206
|
'object.typeOf': {
|
|
@@ -205,7 +209,7 @@ class MongoRepository {
|
|
|
205
209
|
}
|
|
206
210
|
});
|
|
207
211
|
}
|
|
208
|
-
const objectIdEq = (
|
|
212
|
+
const objectIdEq = (_24 = (_23 = params.object) === null || _23 === void 0 ? void 0 : _23.id) === null || _24 === void 0 ? void 0 : _24.$eq;
|
|
209
213
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
210
214
|
/* istanbul ignore else */
|
|
211
215
|
if (typeof objectIdEq === 'string') {
|
|
@@ -216,7 +220,7 @@ class MongoRepository {
|
|
|
216
220
|
}
|
|
217
221
|
});
|
|
218
222
|
}
|
|
219
|
-
const objectIdIn = (
|
|
223
|
+
const objectIdIn = (_26 = (_25 = params.object) === null || _25 === void 0 ? void 0 : _25.id) === null || _26 === void 0 ? void 0 : _26.$in;
|
|
220
224
|
if (Array.isArray(objectIdIn)) {
|
|
221
225
|
andConditions.push({
|
|
222
226
|
'object.id': {
|
|
@@ -225,7 +229,7 @@ class MongoRepository {
|
|
|
225
229
|
}
|
|
226
230
|
});
|
|
227
231
|
}
|
|
228
|
-
const objectOrderNumberIn = (
|
|
232
|
+
const objectOrderNumberIn = (_28 = (_27 = params.object) === null || _27 === void 0 ? void 0 : _27.orderNumber) === null || _28 === void 0 ? void 0 : _28.$in;
|
|
229
233
|
if (Array.isArray(objectOrderNumberIn)) {
|
|
230
234
|
andConditions.push({
|
|
231
235
|
'object.orderNumber': {
|
|
@@ -234,7 +238,7 @@ class MongoRepository {
|
|
|
234
238
|
}
|
|
235
239
|
});
|
|
236
240
|
}
|
|
237
|
-
const objectEventIdIn = (
|
|
241
|
+
const objectEventIdIn = (_31 = (_30 = (_29 = params.object) === null || _29 === void 0 ? void 0 : _29.event) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$in;
|
|
238
242
|
if (Array.isArray(objectEventIdIn)) {
|
|
239
243
|
andConditions.push({
|
|
240
244
|
'object.event.id': {
|
|
@@ -243,7 +247,7 @@ class MongoRepository {
|
|
|
243
247
|
}
|
|
244
248
|
});
|
|
245
249
|
}
|
|
246
|
-
const objectAcceptedOfferSeatNumberIn = (_37 = (_36 = (_35 = (_34 = (_33 = (_32 =
|
|
250
|
+
const objectAcceptedOfferSeatNumberIn = (_38 = (_37 = (_36 = (_35 = (_34 = (_33 = (_32 = params.object) === null || _32 === void 0 ? void 0 : _32.acceptedOffer) === null || _33 === void 0 ? void 0 : _33.itemOffered) === null || _34 === void 0 ? void 0 : _34.serviceOutput) === null || _35 === void 0 ? void 0 : _35.reservedTicket) === null || _36 === void 0 ? void 0 : _36.ticketedSeat) === null || _37 === void 0 ? void 0 : _37.seatNumber) === null || _38 === void 0 ? void 0 : _38.$in;
|
|
247
251
|
if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
|
|
248
252
|
andConditions.push({
|
|
249
253
|
'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
|
|
@@ -260,7 +264,7 @@ class MongoRepository {
|
|
|
260
264
|
});
|
|
261
265
|
}
|
|
262
266
|
else {
|
|
263
|
-
const typeOfEq = (
|
|
267
|
+
const typeOfEq = (_39 = params.typeOf) === null || _39 === void 0 ? void 0 : _39.$eq;
|
|
264
268
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
265
269
|
/* istanbul ignore else */
|
|
266
270
|
if (typeof typeOfEq === 'string') {
|
|
@@ -269,7 +273,7 @@ class MongoRepository {
|
|
|
269
273
|
});
|
|
270
274
|
}
|
|
271
275
|
}
|
|
272
|
-
const actionStatusIn = (
|
|
276
|
+
const actionStatusIn = (_40 = params.actionStatus) === null || _40 === void 0 ? void 0 : _40.$in;
|
|
273
277
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
274
278
|
/* istanbul ignore else */
|
|
275
279
|
if (Array.isArray(actionStatusIn)) {
|
|
@@ -300,7 +304,7 @@ class MongoRepository {
|
|
|
300
304
|
startDate: { $lte: startDateLte }
|
|
301
305
|
});
|
|
302
306
|
}
|
|
303
|
-
const fromLocationTypeOfIn = (
|
|
307
|
+
const fromLocationTypeOfIn = (_42 = (_41 = params.fromLocation) === null || _41 === void 0 ? void 0 : _41.typeOf) === null || _42 === void 0 ? void 0 : _42.$in;
|
|
304
308
|
if (Array.isArray(fromLocationTypeOfIn)) {
|
|
305
309
|
andConditions.push({
|
|
306
310
|
'fromLocation.typeOf': {
|
|
@@ -309,7 +313,7 @@ class MongoRepository {
|
|
|
309
313
|
}
|
|
310
314
|
});
|
|
311
315
|
}
|
|
312
|
-
const fromLocationAccountNumberIn = (
|
|
316
|
+
const fromLocationAccountNumberIn = (_44 = (_43 = params.fromLocation) === null || _43 === void 0 ? void 0 : _43.accountNumber) === null || _44 === void 0 ? void 0 : _44.$in;
|
|
313
317
|
if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
314
318
|
andConditions.push({
|
|
315
319
|
'fromLocation.accountNumber': {
|
|
@@ -318,7 +322,7 @@ class MongoRepository {
|
|
|
318
322
|
}
|
|
319
323
|
});
|
|
320
324
|
}
|
|
321
|
-
const fromLocationAccountTypeIn = (
|
|
325
|
+
const fromLocationAccountTypeIn = (_46 = (_45 = params.fromLocation) === null || _45 === void 0 ? void 0 : _45.accountType) === null || _46 === void 0 ? void 0 : _46.$in;
|
|
322
326
|
if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
323
327
|
andConditions.push({
|
|
324
328
|
'fromLocation.accountType': {
|
|
@@ -327,7 +331,7 @@ class MongoRepository {
|
|
|
327
331
|
}
|
|
328
332
|
});
|
|
329
333
|
}
|
|
330
|
-
const toLocationTypeOfIn = (
|
|
334
|
+
const toLocationTypeOfIn = (_48 = (_47 = params.toLocation) === null || _47 === void 0 ? void 0 : _47.typeOf) === null || _48 === void 0 ? void 0 : _48.$in;
|
|
331
335
|
if (Array.isArray(toLocationTypeOfIn)) {
|
|
332
336
|
andConditions.push({
|
|
333
337
|
'toLocation.typeOf': {
|
|
@@ -336,7 +340,7 @@ class MongoRepository {
|
|
|
336
340
|
}
|
|
337
341
|
});
|
|
338
342
|
}
|
|
339
|
-
const toLocationAccountNumberIn = (
|
|
343
|
+
const toLocationAccountNumberIn = (_50 = (_49 = params.toLocation) === null || _49 === void 0 ? void 0 : _49.accountNumber) === null || _50 === void 0 ? void 0 : _50.$in;
|
|
340
344
|
if (Array.isArray(toLocationAccountNumberIn)) {
|
|
341
345
|
andConditions.push({
|
|
342
346
|
'toLocation.accountNumber': {
|
|
@@ -345,7 +349,7 @@ class MongoRepository {
|
|
|
345
349
|
}
|
|
346
350
|
});
|
|
347
351
|
}
|
|
348
|
-
const toLocationAccountTypeIn = (
|
|
352
|
+
const toLocationAccountTypeIn = (_52 = (_51 = params.toLocation) === null || _51 === void 0 ? void 0 : _51.accountType) === null || _52 === void 0 ? void 0 : _52.$in;
|
|
349
353
|
if (Array.isArray(toLocationAccountTypeIn)) {
|
|
350
354
|
andConditions.push({
|
|
351
355
|
'toLocation.accountType': {
|
|
@@ -354,7 +358,7 @@ class MongoRepository {
|
|
|
354
358
|
}
|
|
355
359
|
});
|
|
356
360
|
}
|
|
357
|
-
const purposeTypeOfIn = (
|
|
361
|
+
const purposeTypeOfIn = (_54 = (_53 = params.purpose) === null || _53 === void 0 ? void 0 : _53.typeOf) === null || _54 === void 0 ? void 0 : _54.$in;
|
|
358
362
|
if (Array.isArray(purposeTypeOfIn)) {
|
|
359
363
|
andConditions.push({
|
|
360
364
|
'purpose.typeOf': {
|
|
@@ -363,7 +367,7 @@ class MongoRepository {
|
|
|
363
367
|
}
|
|
364
368
|
});
|
|
365
369
|
}
|
|
366
|
-
const purposeIdIn = (
|
|
370
|
+
const purposeIdIn = (_56 = (_55 = params.purpose) === null || _55 === void 0 ? void 0 : _55.id) === null || _56 === void 0 ? void 0 : _56.$in;
|
|
367
371
|
if (Array.isArray(purposeIdIn)) {
|
|
368
372
|
andConditions.push({
|
|
369
373
|
'purpose.id': {
|
|
@@ -372,7 +376,7 @@ class MongoRepository {
|
|
|
372
376
|
}
|
|
373
377
|
});
|
|
374
378
|
}
|
|
375
|
-
const purposeOrderNumberIn = (
|
|
379
|
+
const purposeOrderNumberIn = (_58 = (_57 = params.purpose) === null || _57 === void 0 ? void 0 : _57.orderNumber) === null || _58 === void 0 ? void 0 : _58.$in;
|
|
376
380
|
if (Array.isArray(purposeOrderNumberIn)) {
|
|
377
381
|
andConditions.push({
|
|
378
382
|
'purpose.orderNumber': {
|
|
@@ -381,7 +385,7 @@ class MongoRepository {
|
|
|
381
385
|
}
|
|
382
386
|
});
|
|
383
387
|
}
|
|
384
|
-
const resultTypeOfIn = (
|
|
388
|
+
const resultTypeOfIn = (_60 = (_59 = params.result) === null || _59 === void 0 ? void 0 : _59.typeOf) === null || _60 === void 0 ? void 0 : _60.$in;
|
|
385
389
|
if (Array.isArray(resultTypeOfIn)) {
|
|
386
390
|
andConditions.push({
|
|
387
391
|
'result.typeOf': {
|
|
@@ -390,7 +394,7 @@ class MongoRepository {
|
|
|
390
394
|
}
|
|
391
395
|
});
|
|
392
396
|
}
|
|
393
|
-
const resultIdIn = (
|
|
397
|
+
const resultIdIn = (_62 = (_61 = params.result) === null || _61 === void 0 ? void 0 : _61.id) === null || _62 === void 0 ? void 0 : _62.$in;
|
|
394
398
|
if (Array.isArray(resultIdIn)) {
|
|
395
399
|
andConditions.push({
|
|
396
400
|
'result.id': {
|
|
@@ -399,7 +403,7 @@ class MongoRepository {
|
|
|
399
403
|
}
|
|
400
404
|
});
|
|
401
405
|
}
|
|
402
|
-
const resultOrderNumberIn = (
|
|
406
|
+
const resultOrderNumberIn = (_64 = (_63 = params.result) === null || _63 === void 0 ? void 0 : _63.orderNumber) === null || _64 === void 0 ? void 0 : _64.$in;
|
|
403
407
|
if (Array.isArray(resultOrderNumberIn)) {
|
|
404
408
|
andConditions.push({
|
|
405
409
|
'result.orderNumber': {
|
|
@@ -408,7 +412,7 @@ class MongoRepository {
|
|
|
408
412
|
}
|
|
409
413
|
});
|
|
410
414
|
}
|
|
411
|
-
const resultCodeIn = (
|
|
415
|
+
const resultCodeIn = (_66 = (_65 = params.result) === null || _65 === void 0 ? void 0 : _65.code) === null || _66 === void 0 ? void 0 : _66.$in;
|
|
412
416
|
if (Array.isArray(resultCodeIn)) {
|
|
413
417
|
andConditions.push({
|
|
414
418
|
'result.code': {
|
|
@@ -621,16 +625,16 @@ class MongoRepository {
|
|
|
621
625
|
* 取引に対するアクション検索時などに使用
|
|
622
626
|
*/
|
|
623
627
|
searchByPurpose(params) {
|
|
624
|
-
var _a, _b, _c, _d, _e, _f;
|
|
628
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
625
629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
626
|
-
return this.search(Object.assign(Object.assign(Object.assign({ purpose: {
|
|
630
|
+
return this.search(Object.assign(Object.assign(Object.assign(Object.assign({ purpose: {
|
|
627
631
|
id: { $in: [params.purpose.id] },
|
|
628
632
|
typeOf: { $in: [params.purpose.typeOf] }
|
|
629
633
|
}, object: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq) === 'string')
|
|
630
634
|
? { typeOf: { $eq: params.object.typeOf.$eq } }
|
|
631
635
|
: undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethodId) === null || _d === void 0 ? void 0 : _d.$eq) === 'string')
|
|
632
636
|
? { paymentMethodId: { $eq: params.object.paymentMethodId.$eq } }
|
|
633
|
-
: undefined) }, (typeof ((_e = params.actionStatus) === null || _e === void 0 ? void 0 : _e.$eq) === 'string') ? { actionStatus: { $in: [params.actionStatus.$eq] } } : undefined), (typeof params.typeOf === 'string') ? { typeOf: { $eq: params.typeOf } } : undefined), (
|
|
637
|
+
: undefined) }, (typeof ((_e = params.actionStatus) === null || _e === void 0 ? void 0 : _e.$eq) === 'string') ? { actionStatus: { $in: [params.actionStatus.$eq] } } : undefined), (typeof params.typeOf === 'string') ? { typeOf: { $eq: params.typeOf } } : undefined), (Array.isArray((_f = params.id) === null || _f === void 0 ? void 0 : _f.$nin)) ? { id: { $nin: (_g = params.id) === null || _g === void 0 ? void 0 : _g.$nin } } : undefined), (typeof ((_h = params.sort) === null || _h === void 0 ? void 0 : _h.startDate) === 'number') ? { sort: params.sort } : undefined), [], []);
|
|
634
638
|
});
|
|
635
639
|
}
|
|
636
640
|
/**
|
|
@@ -21,6 +21,9 @@ export declare function acceptOffer(params: {
|
|
|
21
21
|
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
22
22
|
}): IAcceptOfferOperation<void>;
|
|
23
23
|
export declare function voidAcceptedOffer(params: {
|
|
24
|
+
/**
|
|
25
|
+
* 取消対象の承認アクション
|
|
26
|
+
*/
|
|
24
27
|
authorizeActions: IAuthorizeOfferAction[];
|
|
25
28
|
orderNumber: string;
|
|
26
29
|
}): (repos: {
|
|
@@ -8,25 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.placeOrderWithoutTransaction = exports.placeOrder = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
24
14
|
const moment = require("moment");
|
|
25
15
|
const order_1 = require("../../factory/order");
|
|
16
|
+
// import { voidAcceptedOffer } from '../offer/any';
|
|
26
17
|
const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
|
|
27
18
|
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
28
19
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
29
20
|
const factory = require("../../factory");
|
|
21
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
30
22
|
function createOrder(params) {
|
|
31
23
|
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
32
24
|
const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
@@ -112,8 +104,8 @@ function createOrderFromBody(params) {
|
|
|
112
104
|
throw new factory.errors.NotFound('transaction.result.order');
|
|
113
105
|
}
|
|
114
106
|
order = createOrder(orderByTransaction);
|
|
115
|
-
const { result
|
|
116
|
-
return { order, placeOrderTransaction };
|
|
107
|
+
// const { result, ...placeOrderTransaction } = placeOrderTransactionWithResult;
|
|
108
|
+
return { order, placeOrderTransaction: placeOrderTransactionWithResult };
|
|
117
109
|
});
|
|
118
110
|
}
|
|
119
111
|
/**
|
|
@@ -165,6 +157,33 @@ function placeOrderWithoutTransaction(params) {
|
|
|
165
157
|
});
|
|
166
158
|
}
|
|
167
159
|
exports.placeOrderWithoutTransaction = placeOrderWithoutTransaction;
|
|
160
|
+
function voidAcceptedOfferIfNecessary(params) {
|
|
161
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
var _a;
|
|
163
|
+
// 取引に保管された承認アクション以外のアクションについて、オファーを除外する
|
|
164
|
+
const authorizeActionsAsResult = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.authorizeActions;
|
|
165
|
+
if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
|
|
166
|
+
const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
|
|
167
|
+
debug(completedAuthorizeActionIds.length, 'completedAuthorizeActionIds found from transaction', params.purpose.id);
|
|
168
|
+
const authorizeActions = yield repos.action.searchByPurpose({
|
|
169
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
170
|
+
purpose: {
|
|
171
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
172
|
+
id: params.purpose.id
|
|
173
|
+
},
|
|
174
|
+
object: { typeOf: { $eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation } },
|
|
175
|
+
id: { $nin: completedAuthorizeActionIds }
|
|
176
|
+
});
|
|
177
|
+
debug('processing voidAcceptedOffer', authorizeActions.length, 'authorizeActions...', authorizeActions);
|
|
178
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
179
|
+
// TODO implement
|
|
180
|
+
// await voidAcceptedOffer({
|
|
181
|
+
// authorizeActions,
|
|
182
|
+
// orderNumber: params.object.orderNumber
|
|
183
|
+
// })(repos);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
168
187
|
/**
|
|
169
188
|
* 注文を作成する
|
|
170
189
|
*/
|
|
@@ -227,6 +246,11 @@ function placeOrder(params) {
|
|
|
227
246
|
if (completedActions.length === 0) {
|
|
228
247
|
const action = yield repos.action.start(orderActionAttributes);
|
|
229
248
|
try {
|
|
249
|
+
// 冗長なオファーを除外する(念のため)
|
|
250
|
+
yield voidAcceptedOfferIfNecessary({
|
|
251
|
+
object: { orderNumber: order.orderNumber },
|
|
252
|
+
purpose: placeOrderTransaction
|
|
253
|
+
})(repos);
|
|
230
254
|
// orderInTransactionを考慮(2024-01-14~)
|
|
231
255
|
yield repos.orderInTransaction.placeOrder(order);
|
|
232
256
|
yield repos.order.createIfNotExist(order);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
3
|
+
import type { MongoRepository as EmailMessageRepo } from '../../../repo/emailMessage';
|
|
4
|
+
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
5
|
+
import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
6
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
7
|
+
import * as factory from '../../../factory';
|
|
8
|
+
import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
9
|
+
interface IConfirmOperationRepos {
|
|
10
|
+
action: ActionRepo;
|
|
11
|
+
emailMessage?: EmailMessageRepo;
|
|
12
|
+
project: ProjectRepo;
|
|
13
|
+
transaction: TransactionRepo;
|
|
14
|
+
orderNumber: OrderNumberRepo;
|
|
15
|
+
confirmationNumber: ConfirmationNumberRepo;
|
|
16
|
+
}
|
|
17
|
+
type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
|
|
18
|
+
type IConfirmParams = PlaceOrderFactory.IConfirmParams;
|
|
19
|
+
/**
|
|
20
|
+
* 注文取引を確定する
|
|
21
|
+
*/
|
|
22
|
+
declare function confirm(params: IConfirmParams): IConfirmOperation<factory.transaction.placeOrder.IResult>;
|
|
23
|
+
export { confirm };
|
|
@@ -0,0 +1,194 @@
|
|
|
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.confirm = void 0;
|
|
13
|
+
const moment = require("moment");
|
|
14
|
+
const errorHandler_1 = require("../../../errorHandler");
|
|
15
|
+
const factory = require("../../../factory");
|
|
16
|
+
const potentialActions_1 = require("./potentialActions");
|
|
17
|
+
const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
|
|
18
|
+
const publishOrderNumberIfNotExist_1 = require("./publishOrderNumberIfNotExist");
|
|
19
|
+
const result_1 = require("./result");
|
|
20
|
+
const validation_1 = require("./validation");
|
|
21
|
+
/**
|
|
22
|
+
* 注文取引を確定する
|
|
23
|
+
*/
|
|
24
|
+
function confirm(params) {
|
|
25
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
// 確認番号を事前発行
|
|
28
|
+
yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
29
|
+
id: params.id,
|
|
30
|
+
object: { orderDate: params.result.order.orderDate }
|
|
31
|
+
})(repos);
|
|
32
|
+
const transaction = yield repos.transaction.findById({
|
|
33
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
34
|
+
id: params.id
|
|
35
|
+
});
|
|
36
|
+
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
37
|
+
// すでに確定済の場合
|
|
38
|
+
return transaction.result;
|
|
39
|
+
}
|
|
40
|
+
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
41
|
+
throw new factory.errors.Argument('transactionId', 'Transaction already expired');
|
|
42
|
+
}
|
|
43
|
+
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
44
|
+
throw new factory.errors.Argument('transactionId', 'Transaction already canceled');
|
|
45
|
+
}
|
|
46
|
+
if (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.id) === 'string' && transaction.agent.id !== params.agent.id) {
|
|
47
|
+
throw new factory.errors.Forbidden('Transaction not yours');
|
|
48
|
+
}
|
|
49
|
+
// 取引に対する全ての承認アクションをマージ
|
|
50
|
+
const completedAuthorizeActions = yield searchAuthorizeActions(params)(repos);
|
|
51
|
+
// 注文番号を発行
|
|
52
|
+
const orderNumber = yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
|
|
53
|
+
project: { id: transaction.project.id },
|
|
54
|
+
id: transaction.id,
|
|
55
|
+
object: { orderDate: params.result.order.orderDate }
|
|
56
|
+
})(repos);
|
|
57
|
+
const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions }));
|
|
58
|
+
// デフォルトEメールメッセージを検索
|
|
59
|
+
let emailMessageOnOrderSent;
|
|
60
|
+
if (repos.emailMessage !== undefined) {
|
|
61
|
+
const searchEmailMessagesResult = yield repos.emailMessage.search({
|
|
62
|
+
limit: 1,
|
|
63
|
+
page: 1,
|
|
64
|
+
project: { id: { $eq: transaction.project.id } },
|
|
65
|
+
about: { identifier: { $eq: factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
|
|
66
|
+
});
|
|
67
|
+
emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
68
|
+
}
|
|
69
|
+
// ポストアクションを作成
|
|
70
|
+
const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
|
|
71
|
+
order: result.order,
|
|
72
|
+
potentialActions: params.potentialActions,
|
|
73
|
+
transaction: transaction,
|
|
74
|
+
emailMessage: emailMessageOnOrderSent,
|
|
75
|
+
authorizeActions: completedAuthorizeActions
|
|
76
|
+
});
|
|
77
|
+
// ステータス変更
|
|
78
|
+
try {
|
|
79
|
+
yield repos.transaction.confirm({
|
|
80
|
+
typeOf: transaction.typeOf,
|
|
81
|
+
id: transaction.id,
|
|
82
|
+
result: result,
|
|
83
|
+
potentialActions: potentialActions
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
88
|
+
// 万が一同一注文番号で確定しようとすると、MongoDBでE11000 duplicate key errorが発生する
|
|
89
|
+
// message: 'E11000 duplicate key error collection: prodttts.transactions index:result.order.orderNumber_1 dup key:...',
|
|
90
|
+
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
91
|
+
throw new factory.errors.AlreadyInUse('transaction', ['result.order.orderNumber']);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
97
|
+
// if (typeof transaction.result?.order.typeOf !== 'string') {
|
|
98
|
+
// throw new factory.errors.ServiceUnavailable('transaction.result not found');
|
|
99
|
+
// }
|
|
100
|
+
return result;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.confirm = confirm;
|
|
104
|
+
function createResult(params) {
|
|
105
|
+
const transaction = params.transaction;
|
|
106
|
+
// 取引の確定条件が全て整っているかどうか確認
|
|
107
|
+
(0, validation_1.validateTransaction)(transaction, params.authorizeActions);
|
|
108
|
+
// 注文作成
|
|
109
|
+
const order = (0, result_1.createOrder)({
|
|
110
|
+
orderNumber: params.orderNumber,
|
|
111
|
+
transaction: transaction,
|
|
112
|
+
orderDate: params.result.order.orderDate,
|
|
113
|
+
// OrderPaymentDueオプションを追加(2023-08-25~)
|
|
114
|
+
// 注文作成時のステータスとなる
|
|
115
|
+
// orderStatus: (USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
|
|
116
|
+
orderStatus: factory.orderStatus.OrderPaymentDue,
|
|
117
|
+
isGift: false,
|
|
118
|
+
authorizeActions: params.authorizeActions
|
|
119
|
+
});
|
|
120
|
+
(0, validation_1.validateEventOffers)({
|
|
121
|
+
transaction: transaction,
|
|
122
|
+
order: order,
|
|
123
|
+
authorizeActions: params.authorizeActions
|
|
124
|
+
});
|
|
125
|
+
// 注文アイテム数制限確認
|
|
126
|
+
(0, validation_1.validateNumItems)({
|
|
127
|
+
order: order,
|
|
128
|
+
result: params.result
|
|
129
|
+
});
|
|
130
|
+
(0, validation_1.validatePaymentMethods)({ order });
|
|
131
|
+
// 確認番号を発行
|
|
132
|
+
const { confirmationNumber, identifier, url } = createConfirmationNumber({
|
|
133
|
+
order: order,
|
|
134
|
+
transaction: transaction,
|
|
135
|
+
result: params.result
|
|
136
|
+
});
|
|
137
|
+
order.confirmationNumber = confirmationNumber;
|
|
138
|
+
order.identifier = identifier;
|
|
139
|
+
order.url = url;
|
|
140
|
+
const authorizeActions = params.authorizeActions.map(({ id }) => ({ id }));
|
|
141
|
+
return {
|
|
142
|
+
order,
|
|
143
|
+
authorizeActions,
|
|
144
|
+
numAcceptedOffers: order.acceptedOffers.length // 追加(2024-01-17~)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function searchAuthorizeActions(params) {
|
|
148
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
// 取引に対する全ての承認アクションをマージ
|
|
150
|
+
let authorizeActions = yield repos.action.searchByPurpose({
|
|
151
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
152
|
+
purpose: {
|
|
153
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
154
|
+
id: params.id
|
|
155
|
+
},
|
|
156
|
+
// Completedに絞る(2023-05-16~)
|
|
157
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
158
|
+
});
|
|
159
|
+
// 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
|
|
160
|
+
authorizeActions = authorizeActions.filter((a) => {
|
|
161
|
+
return (a.endDate instanceof Date) && moment(a.endDate)
|
|
162
|
+
.isBefore(moment(params.result.order.orderDate));
|
|
163
|
+
});
|
|
164
|
+
return authorizeActions;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function createConfirmationNumber(params) {
|
|
168
|
+
const confirmationNumber = params.transaction.object.confirmationNumber;
|
|
169
|
+
let url = '';
|
|
170
|
+
let identifier = [];
|
|
171
|
+
// 取引に確認番号が保管されていなければ、確認番号を発行
|
|
172
|
+
if (typeof confirmationNumber !== 'string') {
|
|
173
|
+
// 事前に発行済なはずなので、ありえないフロー
|
|
174
|
+
throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
|
|
175
|
+
}
|
|
176
|
+
// URLの指定があれば上書き
|
|
177
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
178
|
+
/* istanbul ignore if */
|
|
179
|
+
if (typeof params.result.order.url === 'string') {
|
|
180
|
+
url = params.result.order.url;
|
|
181
|
+
}
|
|
182
|
+
else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
|
|
183
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
184
|
+
/* istanbul ignore next */
|
|
185
|
+
url = params.result.order.url(params.order);
|
|
186
|
+
}
|
|
187
|
+
// 識別子の指定があれば上書き
|
|
188
|
+
identifier = [
|
|
189
|
+
...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
|
|
190
|
+
// 取引に指定があれば追加
|
|
191
|
+
...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
|
|
192
|
+
];
|
|
193
|
+
return { confirmationNumber, url, identifier };
|
|
194
|
+
}
|
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
2
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
3
|
+
/**
|
|
4
|
+
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
5
|
+
*/
|
|
6
|
+
declare function publishConfirmationNumberIfNotExist(params: {
|
|
7
|
+
/**
|
|
8
|
+
* 取引ID
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
object: {
|
|
12
|
+
orderDate: Date;
|
|
13
|
+
};
|
|
14
|
+
}): (repos: {
|
|
15
|
+
transaction: TransactionRepo;
|
|
16
|
+
confirmationNumber: ConfirmationNumberRepo;
|
|
17
|
+
}) => Promise<string>;
|
|
18
|
+
export { publishConfirmationNumberIfNotExist };
|
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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.publishConfirmationNumberIfNotExist = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
16
|
+
*/
|
|
17
|
+
function publishConfirmationNumberIfNotExist(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// 最適化(2023-02-03~)
|
|
20
|
+
let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
21
|
+
// すでに発行済であれば何もしない
|
|
22
|
+
if (typeof confirmationNumber === 'string') {
|
|
23
|
+
return confirmationNumber;
|
|
24
|
+
}
|
|
25
|
+
// 確認番号を発行
|
|
26
|
+
confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
|
|
27
|
+
// 取引に存在しなければ保管
|
|
28
|
+
yield repos.transaction.saveConfirmationNumberIfNotExist({
|
|
29
|
+
id: params.id,
|
|
30
|
+
confirmationNumber
|
|
31
|
+
});
|
|
32
|
+
// 確認番号を取引から再取得
|
|
33
|
+
// 最適化(2023-02-03~)
|
|
34
|
+
confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
35
|
+
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
36
|
+
if (typeof confirmationNumber !== 'string') {
|
|
37
|
+
throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
|
|
38
|
+
}
|
|
39
|
+
return confirmationNumber;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
2
|
+
import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
3
|
+
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
4
|
+
/**
|
|
5
|
+
* 未発行であれば、注文番号を発行して取引に保管する
|
|
6
|
+
*/
|
|
7
|
+
declare function publishOrderNumberIfNotExist(params: {
|
|
8
|
+
project: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 取引ID
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
object: {
|
|
16
|
+
orderDate: Date;
|
|
17
|
+
};
|
|
18
|
+
}): (repos: {
|
|
19
|
+
project: ProjectRepo;
|
|
20
|
+
transaction: TransactionRepo;
|
|
21
|
+
orderNumber: OrderNumberRepo;
|
|
22
|
+
}) => Promise<string>;
|
|
23
|
+
export { publishOrderNumberIfNotExist };
|
|
@@ -0,0 +1,46 @@
|
|
|
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.publishOrderNumberIfNotExist = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 未発行であれば、注文番号を発行して取引に保管する
|
|
16
|
+
*/
|
|
17
|
+
function publishOrderNumberIfNotExist(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// 最適化(2023-02-03~)
|
|
20
|
+
let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
21
|
+
// すでに発行済であれば何もしない
|
|
22
|
+
if (typeof orderNumber === 'string') {
|
|
23
|
+
return orderNumber;
|
|
24
|
+
}
|
|
25
|
+
// 注文番号を発行
|
|
26
|
+
const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
|
|
27
|
+
if (typeof alternateName !== 'string') {
|
|
28
|
+
throw new factory.errors.NotFound('project.alternateName');
|
|
29
|
+
}
|
|
30
|
+
orderNumber = yield repos.orderNumber.publishByTimestamp({
|
|
31
|
+
project: { alternateName },
|
|
32
|
+
orderDate: params.object.orderDate
|
|
33
|
+
});
|
|
34
|
+
// 取引に存在しなければ保管
|
|
35
|
+
yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
|
|
36
|
+
// 注文番号を取引から再取得
|
|
37
|
+
// 最適化(2023-02-03~)
|
|
38
|
+
orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
39
|
+
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
40
|
+
if (typeof orderNumber !== 'string') {
|
|
41
|
+
throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
|
|
42
|
+
}
|
|
43
|
+
return orderNumber;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
|
|
@@ -1,80 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { MongoRepository as EmailMessageRepo } from '../../repo/emailMessage';
|
|
5
|
-
import type { RedisRepository as OrderNumberRepo } from '../../repo/orderNumber';
|
|
6
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
1
|
+
/**
|
|
2
|
+
* 進行中注文取引サービス
|
|
3
|
+
*/
|
|
7
4
|
import type { MongoRepository as SellerRepo } from '../../repo/seller';
|
|
8
5
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import * as factory from '../../factory';
|
|
7
|
+
import { POINT_AWARD_IDENTIFIER_NAME } from '../../factory/order';
|
|
8
|
+
import { placeOrder as PlaceOrderFactory } from '../../factory/transaction';
|
|
9
|
+
import { confirm } from './placeOrderInProgress/confirm';
|
|
10
|
+
import { publishConfirmationNumberIfNotExist } from './placeOrderInProgress/publishConfirmationNumberIfNotExist';
|
|
11
|
+
import { publishOrderNumberIfNotExist } from './placeOrderInProgress/publishOrderNumberIfNotExist';
|
|
12
|
+
interface IStartOperationRepos {
|
|
12
13
|
seller: SellerRepo;
|
|
13
14
|
transaction: TransactionRepo;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
action: ActionRepo;
|
|
18
|
-
emailMessage?: EmailMessageRepo;
|
|
19
|
-
project: ProjectRepo;
|
|
20
|
-
transaction: TransactionRepo;
|
|
21
|
-
orderNumber: OrderNumberRepo;
|
|
22
|
-
confirmationNumber: ConfirmationNumberRepo;
|
|
23
|
-
}
|
|
24
|
-
export type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
|
|
25
|
-
export type IPassportValidator = IWaiterPassportValidator;
|
|
26
|
-
export type IStartParams = PlaceOrderFactory.IStartParams & {
|
|
16
|
+
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
17
|
+
type IStartParams = PlaceOrderFactory.IStartParams & {
|
|
27
18
|
validateEligibleCustomerType: boolean;
|
|
28
19
|
};
|
|
29
20
|
/**
|
|
30
21
|
* 取引開始
|
|
31
22
|
*/
|
|
32
|
-
|
|
33
|
-
export type IOrderURLGenerator = PlaceOrderFactory.IOrderURLGenerator;
|
|
34
|
-
export type IResultOrderParams = PlaceOrderFactory.IResultOrderParams;
|
|
35
|
-
export type IConfirmParams = PlaceOrderFactory.IConfirmParams;
|
|
36
|
-
/**
|
|
37
|
-
* 注文取引を確定する
|
|
38
|
-
*/
|
|
39
|
-
export declare function confirm(params: IConfirmParams): IConfirmOperation<factory.transaction.placeOrder.IResult>;
|
|
40
|
-
/**
|
|
41
|
-
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
42
|
-
*/
|
|
43
|
-
export declare function publishConfirmationNumberIfNotExist(params: {
|
|
44
|
-
/**
|
|
45
|
-
* 取引ID
|
|
46
|
-
*/
|
|
47
|
-
id: string;
|
|
48
|
-
object: {
|
|
49
|
-
orderDate: Date;
|
|
50
|
-
};
|
|
51
|
-
}): (repos: {
|
|
52
|
-
transaction: TransactionRepo;
|
|
53
|
-
confirmationNumber: ConfirmationNumberRepo;
|
|
54
|
-
}) => Promise<string>;
|
|
55
|
-
/**
|
|
56
|
-
* 未発行であれば、注文番号を発行して取引に保管する
|
|
57
|
-
*/
|
|
58
|
-
export declare function publishOrderNumberIfNotExist(params: {
|
|
59
|
-
project: {
|
|
60
|
-
id: string;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* 取引ID
|
|
64
|
-
*/
|
|
65
|
-
id: string;
|
|
66
|
-
object: {
|
|
67
|
-
orderDate: Date;
|
|
68
|
-
};
|
|
69
|
-
}): (repos: {
|
|
70
|
-
project: ProjectRepo;
|
|
71
|
-
transaction: TransactionRepo;
|
|
72
|
-
orderNumber: OrderNumberRepo;
|
|
73
|
-
}) => Promise<string>;
|
|
23
|
+
declare function start(params: IStartParams): IStartOperation<factory.transaction.placeOrder.ITransaction>;
|
|
74
24
|
/**
|
|
75
25
|
* インセンティブ承認
|
|
76
26
|
*/
|
|
77
|
-
|
|
27
|
+
declare function authorizeAward(params: {
|
|
78
28
|
transaction: {
|
|
79
29
|
id: string;
|
|
80
30
|
};
|
|
@@ -92,7 +42,7 @@ export declare function authorizeAward(params: {
|
|
|
92
42
|
/**
|
|
93
43
|
* インセンティブ承認を取り消す
|
|
94
44
|
*/
|
|
95
|
-
|
|
45
|
+
declare function voidAward(params: {
|
|
96
46
|
/**
|
|
97
47
|
* 取引進行者
|
|
98
48
|
*/
|
|
@@ -108,3 +58,4 @@ export declare function voidAward(params: {
|
|
|
108
58
|
}): (repos: {
|
|
109
59
|
transaction: TransactionRepo;
|
|
110
60
|
}) => Promise<void>;
|
|
61
|
+
export { authorizeAward, confirm, POINT_AWARD_IDENTIFIER_NAME, publishConfirmationNumberIfNotExist, publishOrderNumberIfNotExist, start, voidAward };
|
|
@@ -9,27 +9,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.voidAward = exports.
|
|
13
|
-
|
|
14
|
-
* 進行中注文取引サービス
|
|
15
|
-
*/
|
|
16
|
-
const moment = require("moment");
|
|
12
|
+
exports.voidAward = exports.start = exports.publishOrderNumberIfNotExist = exports.publishConfirmationNumberIfNotExist = exports.POINT_AWARD_IDENTIFIER_NAME = exports.confirm = exports.authorizeAward = void 0;
|
|
13
|
+
const errorHandler_1 = require("../../errorHandler");
|
|
17
14
|
const factory = require("../../factory");
|
|
15
|
+
const order_1 = require("../../factory/order");
|
|
16
|
+
Object.defineProperty(exports, "POINT_AWARD_IDENTIFIER_NAME", { enumerable: true, get: function () { return order_1.POINT_AWARD_IDENTIFIER_NAME; } });
|
|
17
|
+
const confirm_1 = require("./placeOrderInProgress/confirm");
|
|
18
|
+
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return confirm_1.confirm; } });
|
|
18
19
|
const factory_1 = require("./placeOrderInProgress/factory");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
20
|
+
const publishConfirmationNumberIfNotExist_1 = require("./placeOrderInProgress/publishConfirmationNumberIfNotExist");
|
|
21
|
+
Object.defineProperty(exports, "publishConfirmationNumberIfNotExist", { enumerable: true, get: function () { return publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist; } });
|
|
22
|
+
const publishOrderNumberIfNotExist_1 = require("./placeOrderInProgress/publishOrderNumberIfNotExist");
|
|
23
|
+
Object.defineProperty(exports, "publishOrderNumberIfNotExist", { enumerable: true, get: function () { return publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist; } });
|
|
22
24
|
const validateSeller_1 = require("./placeOrderInProgress/validation/validateSeller");
|
|
23
|
-
const
|
|
24
|
-
const errorHandler_1 = require("../../errorHandler");
|
|
25
|
-
exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
25
|
+
const validation_1 = require("./validation");
|
|
26
26
|
/**
|
|
27
27
|
* 取引開始
|
|
28
28
|
*/
|
|
29
29
|
function start(params) {
|
|
30
30
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
var _a;
|
|
32
|
-
const { passport, customerType } = yield (0,
|
|
32
|
+
const { passport, customerType } = yield (0, validation_1.validateWaiterPassport)(params);
|
|
33
33
|
const sellers = yield repos.seller.search({
|
|
34
34
|
limit: 1,
|
|
35
35
|
page: 1,
|
|
@@ -63,237 +63,6 @@ function start(params) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
exports.start = start;
|
|
66
|
-
/**
|
|
67
|
-
* 注文取引を確定する
|
|
68
|
-
*/
|
|
69
|
-
function confirm(params) {
|
|
70
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
var _a;
|
|
72
|
-
// 確認番号を事前発行
|
|
73
|
-
yield publishConfirmationNumberIfNotExist({
|
|
74
|
-
id: params.id,
|
|
75
|
-
object: { orderDate: params.result.order.orderDate }
|
|
76
|
-
})(repos);
|
|
77
|
-
const transaction = yield repos.transaction.findById({
|
|
78
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
79
|
-
id: params.id
|
|
80
|
-
});
|
|
81
|
-
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
82
|
-
// すでに確定済の場合
|
|
83
|
-
return transaction.result;
|
|
84
|
-
}
|
|
85
|
-
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
86
|
-
throw new factory.errors.Argument('transactionId', 'Transaction already expired');
|
|
87
|
-
}
|
|
88
|
-
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
89
|
-
throw new factory.errors.Argument('transactionId', 'Transaction already canceled');
|
|
90
|
-
}
|
|
91
|
-
if (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.id) === 'string' && transaction.agent.id !== params.agent.id) {
|
|
92
|
-
throw new factory.errors.Forbidden('Transaction not yours');
|
|
93
|
-
}
|
|
94
|
-
// 取引に対する全ての承認アクションをマージ
|
|
95
|
-
const completedAuthorizeActions = yield searchAuthorizeActions(params)(repos);
|
|
96
|
-
// 注文番号を発行
|
|
97
|
-
const orderNumber = yield publishOrderNumberIfNotExist({
|
|
98
|
-
project: { id: transaction.project.id },
|
|
99
|
-
id: transaction.id,
|
|
100
|
-
object: { orderDate: params.result.order.orderDate }
|
|
101
|
-
})(repos);
|
|
102
|
-
const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions }));
|
|
103
|
-
// デフォルトEメールメッセージを検索
|
|
104
|
-
let emailMessageOnOrderSent;
|
|
105
|
-
if (repos.emailMessage !== undefined) {
|
|
106
|
-
const searchEmailMessagesResult = yield repos.emailMessage.search({
|
|
107
|
-
limit: 1,
|
|
108
|
-
page: 1,
|
|
109
|
-
project: { id: { $eq: transaction.project.id } },
|
|
110
|
-
about: { identifier: { $eq: factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
|
|
111
|
-
});
|
|
112
|
-
emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
113
|
-
}
|
|
114
|
-
// ポストアクションを作成
|
|
115
|
-
const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
|
|
116
|
-
order: result.order,
|
|
117
|
-
potentialActions: params.potentialActions,
|
|
118
|
-
transaction: transaction,
|
|
119
|
-
emailMessage: emailMessageOnOrderSent,
|
|
120
|
-
authorizeActions: completedAuthorizeActions
|
|
121
|
-
});
|
|
122
|
-
// ステータス変更
|
|
123
|
-
try {
|
|
124
|
-
yield repos.transaction.confirm({
|
|
125
|
-
typeOf: transaction.typeOf,
|
|
126
|
-
id: transaction.id,
|
|
127
|
-
result: result,
|
|
128
|
-
potentialActions: potentialActions
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
133
|
-
// 万が一同一注文番号で確定しようとすると、MongoDBでE11000 duplicate key errorが発生する
|
|
134
|
-
// message: 'E11000 duplicate key error collection: prodttts.transactions index:result.order.orderNumber_1 dup key:...',
|
|
135
|
-
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
136
|
-
throw new factory.errors.AlreadyInUse('transaction', ['result.order.orderNumber']);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
142
|
-
// if (typeof transaction.result?.order.typeOf !== 'string') {
|
|
143
|
-
// throw new factory.errors.ServiceUnavailable('transaction.result not found');
|
|
144
|
-
// }
|
|
145
|
-
return result;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
exports.confirm = confirm;
|
|
149
|
-
/**
|
|
150
|
-
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
151
|
-
*/
|
|
152
|
-
function publishConfirmationNumberIfNotExist(params) {
|
|
153
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
// 最適化(2023-02-03~)
|
|
155
|
-
let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
156
|
-
// すでに発行済であれば何もしない
|
|
157
|
-
if (typeof confirmationNumber === 'string') {
|
|
158
|
-
return confirmationNumber;
|
|
159
|
-
}
|
|
160
|
-
// 確認番号を発行
|
|
161
|
-
confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
|
|
162
|
-
// 取引に存在しなければ保管
|
|
163
|
-
yield repos.transaction.saveConfirmationNumberIfNotExist({
|
|
164
|
-
id: params.id,
|
|
165
|
-
confirmationNumber
|
|
166
|
-
});
|
|
167
|
-
// 確認番号を取引から再取得
|
|
168
|
-
// 最適化(2023-02-03~)
|
|
169
|
-
confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
170
|
-
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
171
|
-
if (typeof confirmationNumber !== 'string') {
|
|
172
|
-
throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
|
|
173
|
-
}
|
|
174
|
-
return confirmationNumber;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
|
|
178
|
-
/**
|
|
179
|
-
* 未発行であれば、注文番号を発行して取引に保管する
|
|
180
|
-
*/
|
|
181
|
-
function publishOrderNumberIfNotExist(params) {
|
|
182
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
// 最適化(2023-02-03~)
|
|
184
|
-
let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
185
|
-
// すでに発行済であれば何もしない
|
|
186
|
-
if (typeof orderNumber === 'string') {
|
|
187
|
-
return orderNumber;
|
|
188
|
-
}
|
|
189
|
-
// 注文番号を発行
|
|
190
|
-
const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
|
|
191
|
-
if (typeof alternateName !== 'string') {
|
|
192
|
-
throw new factory.errors.NotFound('project.alternateName');
|
|
193
|
-
}
|
|
194
|
-
orderNumber = yield repos.orderNumber.publishByTimestamp({
|
|
195
|
-
project: { alternateName },
|
|
196
|
-
orderDate: params.object.orderDate
|
|
197
|
-
});
|
|
198
|
-
// 取引に存在しなければ保管
|
|
199
|
-
yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
|
|
200
|
-
// 注文番号を取引から再取得
|
|
201
|
-
// 最適化(2023-02-03~)
|
|
202
|
-
orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
203
|
-
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
204
|
-
if (typeof orderNumber !== 'string') {
|
|
205
|
-
throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
|
|
206
|
-
}
|
|
207
|
-
return orderNumber;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
|
|
211
|
-
function createResult(params) {
|
|
212
|
-
const transaction = params.transaction;
|
|
213
|
-
// 取引の確定条件が全て整っているかどうか確認
|
|
214
|
-
(0, validation_1.validateTransaction)(transaction, params.authorizeActions);
|
|
215
|
-
// 注文作成
|
|
216
|
-
const order = (0, result_1.createOrder)({
|
|
217
|
-
orderNumber: params.orderNumber,
|
|
218
|
-
transaction: transaction,
|
|
219
|
-
orderDate: params.result.order.orderDate,
|
|
220
|
-
// OrderPaymentDueオプションを追加(2023-08-25~)
|
|
221
|
-
// 注文作成時のステータスとなる
|
|
222
|
-
// orderStatus: (USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
|
|
223
|
-
orderStatus: factory.orderStatus.OrderPaymentDue,
|
|
224
|
-
isGift: false,
|
|
225
|
-
authorizeActions: params.authorizeActions
|
|
226
|
-
});
|
|
227
|
-
(0, validation_1.validateEventOffers)({
|
|
228
|
-
transaction: transaction,
|
|
229
|
-
order: order,
|
|
230
|
-
authorizeActions: params.authorizeActions
|
|
231
|
-
});
|
|
232
|
-
// 注文アイテム数制限確認
|
|
233
|
-
(0, validation_1.validateNumItems)({
|
|
234
|
-
order: order,
|
|
235
|
-
result: params.result
|
|
236
|
-
});
|
|
237
|
-
(0, validation_1.validatePaymentMethods)({ order });
|
|
238
|
-
// 確認番号を発行
|
|
239
|
-
const { confirmationNumber, identifier, url } = createConfirmationNumber({
|
|
240
|
-
order: order,
|
|
241
|
-
transaction: transaction,
|
|
242
|
-
result: params.result
|
|
243
|
-
});
|
|
244
|
-
order.confirmationNumber = confirmationNumber;
|
|
245
|
-
order.identifier = identifier;
|
|
246
|
-
order.url = url;
|
|
247
|
-
return { order };
|
|
248
|
-
}
|
|
249
|
-
function searchAuthorizeActions(params) {
|
|
250
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
// 取引に対する全ての承認アクションをマージ
|
|
252
|
-
let authorizeActions = yield repos.action.searchByPurpose({
|
|
253
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
254
|
-
purpose: {
|
|
255
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
256
|
-
id: params.id
|
|
257
|
-
},
|
|
258
|
-
// Completedに絞る(2023-05-16~)
|
|
259
|
-
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
260
|
-
});
|
|
261
|
-
// 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
|
|
262
|
-
authorizeActions = authorizeActions.filter((a) => {
|
|
263
|
-
return (a.endDate instanceof Date) && moment(a.endDate)
|
|
264
|
-
.isBefore(moment(params.result.order.orderDate));
|
|
265
|
-
});
|
|
266
|
-
return authorizeActions;
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
function createConfirmationNumber(params) {
|
|
270
|
-
const confirmationNumber = params.transaction.object.confirmationNumber;
|
|
271
|
-
let url = '';
|
|
272
|
-
let identifier = [];
|
|
273
|
-
// 取引に確認番号が保管されていなければ、確認番号を発行
|
|
274
|
-
if (typeof confirmationNumber !== 'string') {
|
|
275
|
-
// 事前に発行済なはずなので、ありえないフロー
|
|
276
|
-
throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
|
|
277
|
-
}
|
|
278
|
-
// URLの指定があれば上書き
|
|
279
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
280
|
-
/* istanbul ignore if */
|
|
281
|
-
if (typeof params.result.order.url === 'string') {
|
|
282
|
-
url = params.result.order.url;
|
|
283
|
-
}
|
|
284
|
-
else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
|
|
285
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
286
|
-
/* istanbul ignore next */
|
|
287
|
-
url = params.result.order.url(params.order);
|
|
288
|
-
}
|
|
289
|
-
// 識別子の指定があれば上書き
|
|
290
|
-
identifier = [
|
|
291
|
-
...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
|
|
292
|
-
// 取引に指定があれば追加
|
|
293
|
-
...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
|
|
294
|
-
];
|
|
295
|
-
return { confirmationNumber, url, identifier };
|
|
296
|
-
}
|
|
297
66
|
/**
|
|
298
67
|
* インセンティブ承認
|
|
299
68
|
*/
|
|
@@ -325,7 +94,7 @@ function authorizeAward(params) {
|
|
|
325
94
|
'object.potentialActions.givePointAward': givePointAwardParams
|
|
326
95
|
},
|
|
327
96
|
// order.identifierに入金識別子を保管する
|
|
328
|
-
$push: { 'object.identifier': { name:
|
|
97
|
+
$push: { 'object.identifier': { name: order_1.POINT_AWARD_IDENTIFIER_NAME, value: JSON.stringify(pointAwardIdentifiers) } }
|
|
329
98
|
}
|
|
330
99
|
});
|
|
331
100
|
}
|
|
@@ -352,7 +121,7 @@ function voidAward(params) {
|
|
|
352
121
|
$unset: {
|
|
353
122
|
'object.potentialActions.givePointAward': 1
|
|
354
123
|
},
|
|
355
|
-
$pull: { 'object.identifier': { name:
|
|
124
|
+
$pull: { 'object.identifier': { name: order_1.POINT_AWARD_IDENTIFIER_NAME } }
|
|
356
125
|
}
|
|
357
126
|
});
|
|
358
127
|
});
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.createReturnPointAwardActions = void 0;
|
|
13
13
|
const factory = require("../../../../factory");
|
|
14
14
|
const order_1 = require("../../../../factory/order");
|
|
15
|
-
const placeOrderInProgress_1 = require("../../placeOrderInProgress");
|
|
16
15
|
/**
|
|
17
16
|
* ポイント特典返却アクションを作成する
|
|
18
17
|
*/
|
|
@@ -22,7 +21,7 @@ function createReturnPointAwardActions(params) {
|
|
|
22
21
|
const returnPointAwardActions = [];
|
|
23
22
|
// 入金識別子はorder.identifierに保管されている
|
|
24
23
|
let pointAwardIdentifiers = [];
|
|
25
|
-
const pointAwardIdentifierStr = (_b = (_a = params.order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name ===
|
|
24
|
+
const pointAwardIdentifierStr = (_b = (_a = params.order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === order_1.POINT_AWARD_IDENTIFIER_NAME)) === null || _b === void 0 ? void 0 : _b.value;
|
|
26
25
|
if (typeof pointAwardIdentifierStr === 'string') {
|
|
27
26
|
try {
|
|
28
27
|
pointAwardIdentifiers = JSON.parse(pointAwardIdentifierStr);
|
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.352.0-alpha.0",
|
|
14
14
|
"@cinerino/sdk": "5.9.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "21.20.0-alpha.
|
|
118
|
+
"version": "21.20.0-alpha.28"
|
|
119
119
|
}
|