@chevre/domain 21.17.0-alpha.9 → 21.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/adminSellerPaymentAccepted.ts +60 -0
- package/example/src/chevre/isPaymentAcceptedBySeller.ts +24 -0
- package/example/src/chevre/saveOfferCatalogItem.ts +40 -0
- package/example/src/chevre/searchAggregateOffers.ts +11 -8
- package/example/src/chevre/searchOffers.ts +15 -7
- package/example/src/chevre/searchOrderAcceptedOffers.ts +38 -0
- package/lib/chevre/repo/action.d.ts +4 -4
- package/lib/chevre/repo/action.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +39 -17
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +25 -11
- package/lib/chevre/repo/offer.d.ts +17 -1
- package/lib/chevre/repo/offer.js +46 -21
- package/lib/chevre/repo/offerCatalogItem.d.ts +8 -2
- package/lib/chevre/repo/offerCatalogItem.js +5 -5
- package/lib/chevre/repo/order.d.ts +7 -6
- package/lib/chevre/repo/order.js +52 -28
- package/lib/chevre/repo/seller.d.ts +4 -23
- package/lib/chevre/repo/seller.js +3 -38
- package/lib/chevre/repo/sellerPaymentAccepted.d.ts +54 -0
- package/lib/chevre/repo/sellerPaymentAccepted.js +132 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/lib/chevre/service/assetTransaction/pay/account/validation.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +20 -24
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -8
- package/lib/chevre/service/assetTransaction/pay.js +26 -14
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.js +10 -13
- package/lib/chevre/service/offer/event/defaultOffer.d.ts +1 -1
- package/lib/chevre/service/offer/event/defaultOffer.js +5 -17
- package/lib/chevre/service/offer/event/factory.d.ts +6 -6
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +2 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +2 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +10 -6
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -5
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -3
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +0 -1
- package/lib/chevre/service/payment/any.d.ts +5 -6
- package/lib/chevre/service/payment/any.js +3 -6
- package/lib/chevre/service/payment/creditCard.d.ts +6 -6
- package/lib/chevre/service/payment/creditCard.js +22 -14
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +0 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +4 -8
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +21 -13
- package/lib/chevre/service/payment/movieTicket.d.ts +4 -6
- package/lib/chevre/service/payment/movieTicket.js +37 -34
- package/lib/chevre/service/payment.d.ts +4 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -2
- package/lib/chevre/service/task/pay.js +3 -2
- package/lib/chevre/service/task/refund.js +3 -2
- package/lib/chevre/service/task/voidPayTransaction.js +3 -2
- package/lib/chevre/service/task/voidPayment.js +3 -2
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +1 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +1 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +34 -34
- package/lib/chevre/service/transaction/placeOrderInProgress.js +3 -3
- package/package.json +3 -3
- package/example/src/chevre/aggregateSellerPaymentAccepted.ts +0 -27
- package/example/src/handlePhoneNumber.ts +0 -13
- package/example/src/retryConnectMongo.ts +0 -82
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -40,7 +40,7 @@ class MongoRepository {
|
|
|
40
40
|
}
|
|
41
41
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
42
42
|
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
|
|
43
|
-
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;
|
|
43
|
+
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;
|
|
44
44
|
const matchStages = [];
|
|
45
45
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
46
46
|
if (typeof projectIdEq === 'string') {
|
|
@@ -202,7 +202,18 @@ class MongoRepository {
|
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const appliesToMovieTicketServiceOutputTypeOfAll = (_11 = (_10 = (_9 = (_8 = params.priceSpecification) === null || _8 === void 0 ? void 0 : _8.appliesToMovieTicket) === null || _9 === void 0 ? void 0 : _9.serviceOutput) === null || _10 === void 0 ? void 0 : _10.typeOf) === null || _11 === void 0 ? void 0 : _11.$all;
|
|
206
|
+
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfAll)) {
|
|
207
|
+
matchStages.push({
|
|
208
|
+
$match: {
|
|
209
|
+
'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
210
|
+
$exists: true,
|
|
211
|
+
$all: appliesToMovieTicketServiceOutputTypeOfAll
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const appliesToMovieTicketServiceOutputTypeOfNin = (_15 = (_14 = (_13 = (_12 = params.priceSpecification) === null || _12 === void 0 ? void 0 : _12.appliesToMovieTicket) === null || _13 === void 0 ? void 0 : _13.serviceOutput) === null || _14 === void 0 ? void 0 : _14.typeOf) === null || _15 === void 0 ? void 0 : _15.$nin;
|
|
206
217
|
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
|
|
207
218
|
matchStages.push({
|
|
208
219
|
$match: {
|
|
@@ -213,7 +224,7 @@ class MongoRepository {
|
|
|
213
224
|
});
|
|
214
225
|
}
|
|
215
226
|
if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
|
|
216
|
-
const priceSpecificationPriceGte = (
|
|
227
|
+
const priceSpecificationPriceGte = (_16 = params.priceSpecification.price) === null || _16 === void 0 ? void 0 : _16.$gte;
|
|
217
228
|
if (typeof priceSpecificationPriceGte === 'number') {
|
|
218
229
|
matchStages.push({
|
|
219
230
|
$match: {
|
|
@@ -224,7 +235,7 @@ class MongoRepository {
|
|
|
224
235
|
}
|
|
225
236
|
});
|
|
226
237
|
}
|
|
227
|
-
const priceSpecificationPriceLte = (
|
|
238
|
+
const priceSpecificationPriceLte = (_17 = params.priceSpecification.price) === null || _17 === void 0 ? void 0 : _17.$lte;
|
|
228
239
|
if (typeof priceSpecificationPriceLte === 'number') {
|
|
229
240
|
matchStages.push({
|
|
230
241
|
$match: {
|
|
@@ -235,7 +246,7 @@ class MongoRepository {
|
|
|
235
246
|
}
|
|
236
247
|
});
|
|
237
248
|
}
|
|
238
|
-
const accountsReceivableGte = (
|
|
249
|
+
const accountsReceivableGte = (_19 = (_18 = params.priceSpecification.accounting) === null || _18 === void 0 ? void 0 : _18.accountsReceivable) === null || _19 === void 0 ? void 0 : _19.$gte;
|
|
239
250
|
if (typeof accountsReceivableGte === 'number') {
|
|
240
251
|
matchStages.push({
|
|
241
252
|
$match: {
|
|
@@ -246,7 +257,7 @@ class MongoRepository {
|
|
|
246
257
|
}
|
|
247
258
|
});
|
|
248
259
|
}
|
|
249
|
-
const accountsReceivableLte = (
|
|
260
|
+
const accountsReceivableLte = (_21 = (_20 = params.priceSpecification.accounting) === null || _20 === void 0 ? void 0 : _20.accountsReceivable) === null || _21 === void 0 ? void 0 : _21.$lte;
|
|
250
261
|
if (typeof accountsReceivableLte === 'number') {
|
|
251
262
|
matchStages.push({
|
|
252
263
|
$match: {
|
|
@@ -257,7 +268,7 @@ class MongoRepository {
|
|
|
257
268
|
}
|
|
258
269
|
});
|
|
259
270
|
}
|
|
260
|
-
const accountingCodeValueEq = (
|
|
271
|
+
const accountingCodeValueEq = (_24 = (_23 = (_22 = params.priceSpecification.accounting) === null || _22 === void 0 ? void 0 : _22.operatingRevenue) === null || _23 === void 0 ? void 0 : _23.codeValue) === null || _24 === void 0 ? void 0 : _24.$eq;
|
|
261
272
|
if (typeof accountingCodeValueEq === 'string') {
|
|
262
273
|
matchStages.push({
|
|
263
274
|
$match: {
|
|
@@ -268,7 +279,7 @@ class MongoRepository {
|
|
|
268
279
|
}
|
|
269
280
|
});
|
|
270
281
|
}
|
|
271
|
-
const accountingCodeValueIn = (
|
|
282
|
+
const accountingCodeValueIn = (_27 = (_26 = (_25 = params.priceSpecification.accounting) === null || _25 === void 0 ? void 0 : _25.operatingRevenue) === null || _26 === void 0 ? void 0 : _26.codeValue) === null || _27 === void 0 ? void 0 : _27.$in;
|
|
272
283
|
if (Array.isArray(accountingCodeValueIn)) {
|
|
273
284
|
matchStages.push({
|
|
274
285
|
$match: {
|
|
@@ -279,7 +290,7 @@ class MongoRepository {
|
|
|
279
290
|
}
|
|
280
291
|
});
|
|
281
292
|
}
|
|
282
|
-
const referenceQuantityValueEq = (
|
|
293
|
+
const referenceQuantityValueEq = (_29 = (_28 = params.priceSpecification.referenceQuantity) === null || _28 === void 0 ? void 0 : _28.value) === null || _29 === void 0 ? void 0 : _29.$eq;
|
|
283
294
|
if (typeof referenceQuantityValueEq === 'number') {
|
|
284
295
|
matchStages.push({
|
|
285
296
|
$match: {
|
|
@@ -291,7 +302,7 @@ class MongoRepository {
|
|
|
291
302
|
});
|
|
292
303
|
}
|
|
293
304
|
}
|
|
294
|
-
const availabilityEq = (
|
|
305
|
+
const availabilityEq = (_30 = params.availability) === null || _30 === void 0 ? void 0 : _30.$eq;
|
|
295
306
|
if (typeof availabilityEq === 'string') {
|
|
296
307
|
matchStages.push({
|
|
297
308
|
$match: {
|
|
@@ -299,7 +310,7 @@ class MongoRepository {
|
|
|
299
310
|
}
|
|
300
311
|
});
|
|
301
312
|
}
|
|
302
|
-
const availableAtOrFromIdEq = (
|
|
313
|
+
const availableAtOrFromIdEq = (_32 = (_31 = params.availableAtOrFrom) === null || _31 === void 0 ? void 0 : _31.id) === null || _32 === void 0 ? void 0 : _32.$eq;
|
|
303
314
|
if (typeof availableAtOrFromIdEq === 'string') {
|
|
304
315
|
matchStages.push({
|
|
305
316
|
$match: {
|
|
@@ -310,7 +321,7 @@ class MongoRepository {
|
|
|
310
321
|
}
|
|
311
322
|
});
|
|
312
323
|
}
|
|
313
|
-
const availableAtOrFromIdIn = (
|
|
324
|
+
const availableAtOrFromIdIn = (_34 = (_33 = params.availableAtOrFrom) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$in;
|
|
314
325
|
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
315
326
|
matchStages.push({
|
|
316
327
|
$match: {
|
|
@@ -321,7 +332,7 @@ class MongoRepository {
|
|
|
321
332
|
}
|
|
322
333
|
});
|
|
323
334
|
}
|
|
324
|
-
const addOnItemOfferedIdEq = (
|
|
335
|
+
const addOnItemOfferedIdEq = (_37 = (_36 = (_35 = params.addOn) === null || _35 === void 0 ? void 0 : _35.itemOffered) === null || _36 === void 0 ? void 0 : _36.id) === null || _37 === void 0 ? void 0 : _37.$eq;
|
|
325
336
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
326
337
|
matchStages.push({
|
|
327
338
|
$match: {
|
|
@@ -329,7 +340,7 @@ class MongoRepository {
|
|
|
329
340
|
}
|
|
330
341
|
});
|
|
331
342
|
}
|
|
332
|
-
const addOnItemOfferedIdIn = (
|
|
343
|
+
const addOnItemOfferedIdIn = (_40 = (_39 = (_38 = params.addOn) === null || _38 === void 0 ? void 0 : _38.itemOffered) === null || _39 === void 0 ? void 0 : _39.id) === null || _40 === void 0 ? void 0 : _40.$in;
|
|
333
344
|
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
334
345
|
matchStages.push({
|
|
335
346
|
$match: {
|
|
@@ -337,7 +348,7 @@ class MongoRepository {
|
|
|
337
348
|
}
|
|
338
349
|
});
|
|
339
350
|
}
|
|
340
|
-
const hasMerchantReturnPolicyIdEq = (
|
|
351
|
+
const hasMerchantReturnPolicyIdEq = (_42 = (_41 = params.hasMerchantReturnPolicy) === null || _41 === void 0 ? void 0 : _41.id) === null || _42 === void 0 ? void 0 : _42.$eq;
|
|
341
352
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
342
353
|
matchStages.push({
|
|
343
354
|
$match: {
|
|
@@ -348,7 +359,18 @@ class MongoRepository {
|
|
|
348
359
|
}
|
|
349
360
|
});
|
|
350
361
|
}
|
|
351
|
-
const
|
|
362
|
+
const acceptedPaymentMethodIdentifierIn = (_44 = (_43 = params.acceptedPaymentMethod) === null || _43 === void 0 ? void 0 : _43.identifier) === null || _44 === void 0 ? void 0 : _44.$in;
|
|
363
|
+
if (Array.isArray(acceptedPaymentMethodIdentifierIn)) {
|
|
364
|
+
matchStages.push({
|
|
365
|
+
$match: {
|
|
366
|
+
'offers.acceptedPaymentMethod.identifier': {
|
|
367
|
+
$exists: true,
|
|
368
|
+
$in: acceptedPaymentMethodIdentifierIn
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const additionalPropertyAll = (_45 = params.additionalProperty) === null || _45 === void 0 ? void 0 : _45.$all;
|
|
352
374
|
if (Array.isArray(additionalPropertyAll)) {
|
|
353
375
|
matchStages.push({
|
|
354
376
|
$match: {
|
|
@@ -359,7 +381,7 @@ class MongoRepository {
|
|
|
359
381
|
}
|
|
360
382
|
});
|
|
361
383
|
}
|
|
362
|
-
const additionalPropertyElemMatch = (
|
|
384
|
+
const additionalPropertyElemMatch = (_46 = params.additionalProperty) === null || _46 === void 0 ? void 0 : _46.$elemMatch;
|
|
363
385
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
364
386
|
matchStages.push({
|
|
365
387
|
$match: {
|
|
@@ -527,7 +549,7 @@ class MongoRepository {
|
|
|
527
549
|
* カタログ内ソートインデックスはsortedOfferIdsで判断する
|
|
528
550
|
*/
|
|
529
551
|
searchByOfferCatalogIdWithSortIndex(params) {
|
|
530
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
552
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
531
553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
532
554
|
const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
|
|
533
555
|
id: params.offerCatalog.id,
|
|
@@ -536,17 +558,20 @@ class MongoRepository {
|
|
|
536
558
|
let offers = [];
|
|
537
559
|
if (sortedOfferIds.length > 0) {
|
|
538
560
|
const appliesToMovieTicketServiceOutputTypeOfEq = (_d = (_c = (_b = (_a = params.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket) === null || _b === void 0 ? void 0 : _b.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
539
|
-
const
|
|
561
|
+
const appliesToMovieTicketServiceOutputTypeOfAll = (_h = (_g = (_f = (_e = params.priceSpecification) === null || _e === void 0 ? void 0 : _e.appliesToMovieTicket) === null || _f === void 0 ? void 0 : _f.serviceOutput) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$all;
|
|
562
|
+
const appliesToMovieTicketServiceTypeExists = (_l = (_k = (_j = params.priceSpecification) === null || _j === void 0 ? void 0 : _j.appliesToMovieTicket) === null || _k === void 0 ? void 0 : _k.serviceType) === null || _l === void 0 ? void 0 : _l.$exists;
|
|
540
563
|
// 適用決済カード条件なしのみを検索するかどうか
|
|
541
564
|
const onlyNoAppliesToMovieTicket = params.excludeAppliesToMovieTicket || (appliesToMovieTicketServiceTypeExists === false);
|
|
542
565
|
const onlyAppliesToMovieTicket = !params.excludeAppliesToMovieTicket && (appliesToMovieTicketServiceTypeExists === true);
|
|
543
566
|
const priceSpecificationConditions = {
|
|
544
567
|
appliesToMovieTicket: Object.assign(Object.assign({ serviceOutput: {
|
|
545
|
-
typeOf: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
568
|
+
typeOf: Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
546
569
|
// 利用不可決済方法区分条件を追加(2023-02-21~)
|
|
547
570
|
? { $nin: params.unacceptedPaymentMethod }
|
|
548
571
|
: undefined), (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string')
|
|
549
572
|
? { $eq: appliesToMovieTicketServiceOutputTypeOfEq }
|
|
573
|
+
: undefined), (Array.isArray(appliesToMovieTicketServiceOutputTypeOfAll))
|
|
574
|
+
? { $all: appliesToMovieTicketServiceOutputTypeOfAll }
|
|
550
575
|
: undefined)
|
|
551
576
|
} }, (onlyNoAppliesToMovieTicket)
|
|
552
577
|
? { serviceType: { $exists: false } }
|
|
@@ -556,7 +581,7 @@ class MongoRepository {
|
|
|
556
581
|
};
|
|
557
582
|
const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ priceSpecification: priceSpecificationConditions, onlyValid: params.onlyValid === true }, (params.useIncludeInDataCatalog)
|
|
558
583
|
? { includedInDataCatalog: { id: { $in: [params.offerCatalog.id] } } }
|
|
559
|
-
: { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((
|
|
584
|
+
: { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_m = params.availableAtOrFrom) === null || _m === void 0 ? void 0 : _m.id) === 'string')
|
|
560
585
|
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
|
|
561
586
|
: undefined), (typeof params.limit === 'number' && typeof params.page === 'number')
|
|
562
587
|
// 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
|
|
@@ -15,11 +15,17 @@ export declare class MongoRepository {
|
|
|
15
15
|
private readonly offerCatalogItemModel;
|
|
16
16
|
constructor(connection: Connection);
|
|
17
17
|
static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
|
|
18
|
-
save(params: factory.offerCatalog.IOfferCatalog
|
|
18
|
+
save(params: factory.offerCatalog.IOfferCatalog & {
|
|
19
|
+
$unset?: any;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
19
23
|
/**
|
|
20
24
|
* プロジェクトとコードから冪等保管
|
|
21
25
|
*/
|
|
22
|
-
saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<
|
|
26
|
+
saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<{
|
|
27
|
+
id: string;
|
|
28
|
+
}>;
|
|
23
29
|
/**
|
|
24
30
|
* 同期日時を更新する
|
|
25
31
|
*/
|
|
@@ -107,18 +107,18 @@ class MongoRepository {
|
|
|
107
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
108
|
let doc;
|
|
109
109
|
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
110
|
-
const { id } = params, creatingDoc = __rest(params, ["id"]);
|
|
110
|
+
const { id, $unset } = params, creatingDoc = __rest(params, ["id", "$unset"]);
|
|
111
111
|
doc = yield this.offerCatalogItemModel.create(creatingDoc);
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
|
-
const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
|
|
115
|
-
doc = yield this.offerCatalogItemModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true })
|
|
114
|
+
const { id, identifier, project, typeOf, $unset } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf", "$unset"]);
|
|
115
|
+
doc = yield this.offerCatalogItemModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert: false, new: true, projection: { _id: 1 } })
|
|
116
116
|
.exec();
|
|
117
117
|
}
|
|
118
118
|
if (doc === null) {
|
|
119
119
|
throw new factory.errors.NotFound(this.offerCatalogItemModel.modelName);
|
|
120
120
|
}
|
|
121
|
-
return doc.
|
|
121
|
+
return { id: doc.id };
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
@@ -135,7 +135,7 @@ class MongoRepository {
|
|
|
135
135
|
$setOnInsert: { identifier, project, typeOf }
|
|
136
136
|
}, { upsert: true, new: true })
|
|
137
137
|
.exec();
|
|
138
|
-
return doc.
|
|
138
|
+
return { id: doc.id };
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
@@ -25,11 +25,10 @@
|
|
|
25
25
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
type IKeyOfProjection = keyof factory.order.IOrder | '_id';
|
|
28
|
-
type
|
|
28
|
+
type IProjection4searchWithUnwoundAcceptedOffers = {
|
|
29
29
|
[key in keyof Omit<factory.order.IOrder, 'acceptedOffers'>]?: 1;
|
|
30
30
|
} & {
|
|
31
31
|
_id?: 0 | 1;
|
|
32
|
-
acceptedOffers?: ['$acceptedOffers'];
|
|
33
32
|
};
|
|
34
33
|
/**
|
|
35
34
|
* 注文リポジトリ
|
|
@@ -37,7 +36,7 @@ type IProjection4searchWithUnwoundAcceptedOffer = {
|
|
|
37
36
|
export declare class MongoRepository {
|
|
38
37
|
private readonly orderModel;
|
|
39
38
|
constructor(connection: Connection);
|
|
40
|
-
static CREATE_MONGO_CONDITIONS(params: factory.order.ISearchConditions):
|
|
39
|
+
static CREATE_MONGO_CONDITIONS(params: factory.order.ISearchConditions): FilterQuery<factory.order.IOrder>[];
|
|
41
40
|
/**
|
|
42
41
|
* なければ作成する
|
|
43
42
|
*/
|
|
@@ -141,9 +140,11 @@ export declare class MongoRepository {
|
|
|
141
140
|
/**
|
|
142
141
|
* オファー展開の注文検索
|
|
143
142
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
|
|
144
|
+
/**
|
|
145
|
+
* オファーのみ展開して検索する
|
|
146
|
+
*/
|
|
147
|
+
searchAcceptedOffers(params: factory.order.ISearchConditions, inclusion?: (keyof factory.order.IAcceptedOffer<factory.order.IItemOffered>)[]): Promise<factory.order.IAcceptedOffer<factory.order.IItemOffered>[]>;
|
|
147
148
|
/**
|
|
148
149
|
* 注文に含まれる予約番号を検索する
|
|
149
150
|
*/
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -989,7 +989,7 @@ class MongoRepository {
|
|
|
989
989
|
/**
|
|
990
990
|
* オファー展開の注文検索
|
|
991
991
|
*/
|
|
992
|
-
|
|
992
|
+
searchWithUnwoundAcceptedOffers(params, projection) {
|
|
993
993
|
var _a;
|
|
994
994
|
return __awaiter(this, void 0, void 0, function* () {
|
|
995
995
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -1005,43 +1005,67 @@ class MongoRepository {
|
|
|
1005
1005
|
conditions.forEach((c) => {
|
|
1006
1006
|
aggregate.match(c);
|
|
1007
1007
|
});
|
|
1008
|
-
aggregate.project((projection
|
|
1009
|
-
|
|
1010
|
-
:
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1008
|
+
aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
|
|
1009
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1010
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1011
|
+
aggregate.limit(params.limit * page)
|
|
1012
|
+
.skip(params.limit * (page - 1));
|
|
1013
|
+
}
|
|
1014
|
+
return aggregate
|
|
1015
|
+
// .allowDiskUse(true) // false化(2023-11-30~)
|
|
1016
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1017
|
+
.exec();
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* オファーのみ展開して検索する
|
|
1022
|
+
*/
|
|
1023
|
+
searchAcceptedOffers(params, inclusion) {
|
|
1024
|
+
var _a;
|
|
1025
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1026
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
1027
|
+
const aggregate = this.orderModel.aggregate();
|
|
1028
|
+
// pipelineの順序に注意
|
|
1029
|
+
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
1030
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
1031
|
+
/* istanbul ignore else */
|
|
1032
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
|
|
1033
|
+
aggregate.sort({ orderDate: params.sort.orderDate });
|
|
1034
|
+
}
|
|
1035
|
+
aggregate.unwind('$acceptedOffers');
|
|
1036
|
+
conditions.forEach((c) => {
|
|
1037
|
+
aggregate.match(c);
|
|
1038
|
+
});
|
|
1039
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
1040
|
+
const specifiedProjection = {
|
|
1041
|
+
_id: 0
|
|
1042
|
+
};
|
|
1043
|
+
inclusion.forEach((key) => {
|
|
1044
|
+
specifiedProjection[key] = `$acceptedOffers.${key}`;
|
|
1015
1045
|
});
|
|
1046
|
+
aggregate.project(specifiedProjection);
|
|
1047
|
+
}
|
|
1048
|
+
else {
|
|
1049
|
+
aggregate.project({
|
|
1050
|
+
_id: 0,
|
|
1051
|
+
itemOffered: '$acceptedOffers.itemOffered',
|
|
1052
|
+
priceSpecification: '$acceptedOffers.priceSpecification',
|
|
1053
|
+
typeOf: '$acceptedOffers.typeOf',
|
|
1054
|
+
id: '$acceptedOffers.id',
|
|
1055
|
+
offeredThrough: '$acceptedOffers.offeredThrough',
|
|
1056
|
+
name: '$acceptedOffers.name'
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1016
1059
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1017
1060
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1018
1061
|
aggregate.limit(params.limit * page)
|
|
1019
1062
|
.skip(params.limit * (page - 1));
|
|
1020
1063
|
}
|
|
1021
|
-
return aggregate
|
|
1064
|
+
return aggregate
|
|
1022
1065
|
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1023
1066
|
.exec();
|
|
1024
1067
|
});
|
|
1025
1068
|
}
|
|
1026
|
-
// 廃止(2023-10-15~)
|
|
1027
|
-
// public async saveAwardAccountsIfNotExist(parmas: {
|
|
1028
|
-
// orderNumber: string;
|
|
1029
|
-
// awardAccounts: factory.transaction.placeOrder.IAwardAccount[];
|
|
1030
|
-
// }) {
|
|
1031
|
-
// if (Array.isArray(parmas.awardAccounts)) {
|
|
1032
|
-
// const newIdentifier: factory.propertyValue.IPropertyValue<string>
|
|
1033
|
-
// = { name: AWARD_ACCOUNTS_IDENTIFIER_NAME, value: JSON.stringify(parmas.awardAccounts) };
|
|
1034
|
-
// await this.orderModel.findOneAndUpdate(
|
|
1035
|
-
// {
|
|
1036
|
-
// orderNumber: { $eq: parmas.orderNumber },
|
|
1037
|
-
// 'identifier.name': { $ne: AWARD_ACCOUNTS_IDENTIFIER_NAME }
|
|
1038
|
-
// },
|
|
1039
|
-
// { $push: { identifier: newIdentifier } },
|
|
1040
|
-
// { new: true }
|
|
1041
|
-
// )
|
|
1042
|
-
// .exec();
|
|
1043
|
-
// }
|
|
1044
|
-
// }
|
|
1045
1069
|
/**
|
|
1046
1070
|
* 注文に含まれる予約番号を検索する
|
|
1047
1071
|
*/
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
-
export type ISeller = factory.seller.ISeller
|
|
27
|
+
export type ISeller = Omit<factory.seller.ISeller, 'paymentAccepted'>;
|
|
28
|
+
export type ISavingSeller = Omit<factory.seller.ISeller, 'paymentAccepted'>;
|
|
28
29
|
export type ISellerByAggregate = Pick<ISeller, 'additionalProperty' | 'branchCode' | 'hasMerchantReturnPolicy' | 'id' | 'name' | 'project' | 'telephone' | 'typeOf' | 'url'>;
|
|
29
30
|
export interface IMemberSearchConditions {
|
|
30
31
|
/**
|
|
@@ -54,8 +55,8 @@ export declare class MongoRepository {
|
|
|
54
55
|
*/
|
|
55
56
|
save(params: {
|
|
56
57
|
id?: string;
|
|
57
|
-
attributes:
|
|
58
|
-
}): Promise<
|
|
58
|
+
attributes: ISavingSeller;
|
|
59
|
+
}): Promise<ISavingSeller>;
|
|
59
60
|
/**
|
|
60
61
|
* 集計検索(publicな属性検索が目的)
|
|
61
62
|
*/
|
|
@@ -64,26 +65,6 @@ export declare class MongoRepository {
|
|
|
64
65
|
* 販売者検索
|
|
65
66
|
*/
|
|
66
67
|
search(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<ISeller[]>;
|
|
67
|
-
/**
|
|
68
|
-
* 対応決済方法を検索する
|
|
69
|
-
*/
|
|
70
|
-
searchPaymentAcceptedById(params: {
|
|
71
|
-
limit?: number;
|
|
72
|
-
page?: number;
|
|
73
|
-
/**
|
|
74
|
-
* 販売者ID
|
|
75
|
-
*/
|
|
76
|
-
id: {
|
|
77
|
-
$eq: string;
|
|
78
|
-
};
|
|
79
|
-
project: {
|
|
80
|
-
id: {
|
|
81
|
-
$eq: string;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}): Promise<{
|
|
85
|
-
codeValue: string;
|
|
86
|
-
}[]>;
|
|
87
68
|
/**
|
|
88
69
|
* 販売者を削除する
|
|
89
70
|
*/
|
|
@@ -241,10 +241,7 @@ class MongoRepository {
|
|
|
241
241
|
/**
|
|
242
242
|
* 販売者検索
|
|
243
243
|
*/
|
|
244
|
-
search(conditions,
|
|
245
|
-
// inclusion化(2023-07-07~)
|
|
246
|
-
// projection?: any
|
|
247
|
-
inclusion, exclusion) {
|
|
244
|
+
search(conditions, inclusion, exclusion) {
|
|
248
245
|
var _a;
|
|
249
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
247
|
const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
|
|
@@ -258,7 +255,8 @@ class MongoRepository {
|
|
|
258
255
|
projection = {
|
|
259
256
|
__v: 0,
|
|
260
257
|
createdAt: 0,
|
|
261
|
-
updatedAt: 0
|
|
258
|
+
updatedAt: 0,
|
|
259
|
+
paymentAccepted: 0 // 除外(2023-12-01~)
|
|
262
260
|
};
|
|
263
261
|
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
264
262
|
exclusion.forEach((field) => {
|
|
@@ -282,39 +280,6 @@ class MongoRepository {
|
|
|
282
280
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
283
281
|
});
|
|
284
282
|
}
|
|
285
|
-
/**
|
|
286
|
-
* 対応決済方法を検索する
|
|
287
|
-
*/
|
|
288
|
-
searchPaymentAcceptedById(params) {
|
|
289
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
-
const matchStages = [
|
|
291
|
-
{ $match: { 'project.id': { $eq: params.project.id.$eq } } },
|
|
292
|
-
{ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id.$eq) } } }
|
|
293
|
-
];
|
|
294
|
-
const aggregate = this.organizationModel.aggregate([
|
|
295
|
-
{
|
|
296
|
-
$unwind: {
|
|
297
|
-
path: '$paymentAccepted'
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
...matchStages,
|
|
301
|
-
{ $sort: { 'paymentAccepted.paymentMethodType': factory.sortType.Ascending } },
|
|
302
|
-
{
|
|
303
|
-
$project: {
|
|
304
|
-
_id: 0,
|
|
305
|
-
codeValue: '$paymentAccepted.paymentMethodType'
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
]);
|
|
309
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
310
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
311
|
-
aggregate.limit(params.limit * page)
|
|
312
|
-
.skip(params.limit * (page - 1));
|
|
313
|
-
}
|
|
314
|
-
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
315
|
-
.exec();
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
283
|
/**
|
|
319
284
|
* 販売者を削除する
|
|
320
285
|
*/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* 販売者対応決済方法リポジトリ
|
|
4
|
+
*/
|
|
5
|
+
export declare class MongoRepository {
|
|
6
|
+
private readonly sellerModel;
|
|
7
|
+
constructor(connection: Connection);
|
|
8
|
+
search(params: {
|
|
9
|
+
limit?: number;
|
|
10
|
+
page?: number;
|
|
11
|
+
seller?: {
|
|
12
|
+
id?: {
|
|
13
|
+
$eq?: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
project?: {
|
|
17
|
+
id?: {
|
|
18
|
+
$eq?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
codeValue?: {
|
|
22
|
+
$eq?: string;
|
|
23
|
+
};
|
|
24
|
+
}): Promise<{
|
|
25
|
+
codeValue: string;
|
|
26
|
+
seller: {
|
|
27
|
+
id: string;
|
|
28
|
+
};
|
|
29
|
+
}[]>;
|
|
30
|
+
create(params: {
|
|
31
|
+
codeValue: string;
|
|
32
|
+
project: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
seller: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
deleteOne(params: {
|
|
40
|
+
codeValue: string;
|
|
41
|
+
project: {
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
seller: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
isAcceptedBySeller(params: {
|
|
49
|
+
seller: {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
codeValue: string;
|
|
53
|
+
}): Promise<boolean>;
|
|
54
|
+
}
|