@chevre/domain 21.18.0 → 21.19.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/optimizeOffers.ts +16 -0
- package/example/src/chevre/searchOffers.ts +2 -2
- package/lib/chevre/repo/aggregateOffer.d.ts +4 -9
- package/lib/chevre/repo/aggregateOffer.js +18 -222
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +9 -8
- package/lib/chevre/repo/offer.d.ts +7 -2
- package/lib/chevre/repo/offer.js +57 -26
- package/lib/chevre/service/offer/event/factory.d.ts +1 -4
- package/lib/chevre/service/offer/event/factory.js +3 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
|
|
10
|
+
const result = await aggregateOfferRepo.optimizeOffers();
|
|
11
|
+
console.log('result:', result);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
main()
|
|
15
|
+
.then(console.log)
|
|
16
|
+
.catch(console.error);
|
|
@@ -59,20 +59,15 @@ export declare class MongoRepository {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
}): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* カタログに属するサブカタログを全て除外する
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* サブカタログに属するサブカタログを全て除外する
|
|
70
|
-
*/
|
|
71
62
|
deleteById(params: {
|
|
72
63
|
project: {
|
|
73
64
|
id: string;
|
|
74
65
|
};
|
|
75
66
|
id: string;
|
|
76
67
|
}): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* 単価オファー最適化作業における一時的な処理
|
|
70
|
+
*/
|
|
71
|
+
optimizeOffers(): Promise<import("mongodb").UpdateResult>;
|
|
77
72
|
}
|
|
78
73
|
export {};
|
|
@@ -36,7 +36,8 @@ class MongoRepository {
|
|
|
36
36
|
if (typeof idEq === 'string') {
|
|
37
37
|
matchStages.push({
|
|
38
38
|
$match: {
|
|
39
|
-
'offers.id': { $eq: idEq }
|
|
39
|
+
// 'offers.id': { $eq: idEq }
|
|
40
|
+
_id: { $eq: idEq } // _idに変更(2023-12-22~)
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -44,9 +45,8 @@ class MongoRepository {
|
|
|
44
45
|
if (Array.isArray(idIn)) {
|
|
45
46
|
matchStages.push({
|
|
46
47
|
$match: {
|
|
47
|
-
'offers.id': {
|
|
48
|
-
|
|
49
|
-
}
|
|
48
|
+
// 'offers.id': { $in: idIn }
|
|
49
|
+
_id: { $in: idIn } // _idに変更(2023-12-22~)
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -533,28 +533,6 @@ class MongoRepository {
|
|
|
533
533
|
})
|
|
534
534
|
.exec();
|
|
535
535
|
debug('result', result);
|
|
536
|
-
// offersにもpush(ひとまず廃止)
|
|
537
|
-
// result = await this.aggregateOfferModel.updateMany(
|
|
538
|
-
// {
|
|
539
|
-
// 'project.id': { $eq: params.project.id },
|
|
540
|
-
// _id: { $in: params.id.$in }
|
|
541
|
-
// },
|
|
542
|
-
// {
|
|
543
|
-
// $push: {
|
|
544
|
-
// 'offers.$[offer].includedInDataCatalog': {
|
|
545
|
-
// $each: newIncludedInDataCatalogs
|
|
546
|
-
// }
|
|
547
|
-
// }
|
|
548
|
-
// },
|
|
549
|
-
// {
|
|
550
|
-
// // includedInDataCatalogのユニークネスを保証する
|
|
551
|
-
// arrayFilters: [
|
|
552
|
-
// { 'offer.includedInDataCatalog.id': { $nin: pushIncludedInDataCatalogIds } }
|
|
553
|
-
// ]
|
|
554
|
-
// }
|
|
555
|
-
// )
|
|
556
|
-
// .exec();
|
|
557
|
-
// debug('result', result);
|
|
558
536
|
});
|
|
559
537
|
}
|
|
560
538
|
/**
|
|
@@ -575,202 +553,6 @@ class MongoRepository {
|
|
|
575
553
|
.exec();
|
|
576
554
|
});
|
|
577
555
|
}
|
|
578
|
-
// public async pushIncludedInOfferCatalogItem(params: {
|
|
579
|
-
// project: { id: string };
|
|
580
|
-
// id: { $in: string[] };
|
|
581
|
-
// $push: {
|
|
582
|
-
// includedInOfferCatalogItem: {
|
|
583
|
-
// /**
|
|
584
|
-
// * サブカタログID
|
|
585
|
-
// */
|
|
586
|
-
// id: { $eq: string };
|
|
587
|
-
// includedInDataCatalog: {
|
|
588
|
-
// /**
|
|
589
|
-
// * カタログID
|
|
590
|
-
// */
|
|
591
|
-
// id: { $eq: string };
|
|
592
|
-
// };
|
|
593
|
-
// };
|
|
594
|
-
// };
|
|
595
|
-
// }): Promise<void> {
|
|
596
|
-
// if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
|
|
597
|
-
// return;
|
|
598
|
-
// }
|
|
599
|
-
// const newIncludedInOfferCatalogItem: {
|
|
600
|
-
// /**
|
|
601
|
-
// * サブカタログID
|
|
602
|
-
// */
|
|
603
|
-
// id: string;
|
|
604
|
-
// typeOf: 'OfferCatalog';
|
|
605
|
-
// includedInDataCatalog: {
|
|
606
|
-
// /**
|
|
607
|
-
// * カタログID
|
|
608
|
-
// */
|
|
609
|
-
// id: string;
|
|
610
|
-
// typeOf: 'OfferCatalog';
|
|
611
|
-
// };
|
|
612
|
-
// } = {
|
|
613
|
-
// id: params.$push.includedInOfferCatalogItem.id.$eq,
|
|
614
|
-
// typeOf: 'OfferCatalog',
|
|
615
|
-
// includedInDataCatalog: { id: params.$push.includedInOfferCatalogItem.includedInDataCatalog.id.$eq, typeOf: 'OfferCatalog' }
|
|
616
|
-
// };
|
|
617
|
-
// const result = await this.aggregateOfferModel.updateMany(
|
|
618
|
-
// {
|
|
619
|
-
// 'project.id': { $eq: params.project.id },
|
|
620
|
-
// _id: { $in: params.id.$in }
|
|
621
|
-
// },
|
|
622
|
-
// {
|
|
623
|
-
// // newIncludedInOfferCatalogItemsのユニークネスを保証する
|
|
624
|
-
// $addToSet: { 'offers.$[].includedInOfferCatalogItem': newIncludedInOfferCatalogItem }
|
|
625
|
-
// }
|
|
626
|
-
// )
|
|
627
|
-
// .exec();
|
|
628
|
-
// debug('result', result);
|
|
629
|
-
// }
|
|
630
|
-
/**
|
|
631
|
-
* サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
|
|
632
|
-
*/
|
|
633
|
-
// public async pullIncludedInOfferCatalogItem(params: {
|
|
634
|
-
// project: { id: string };
|
|
635
|
-
// id?: { $nin?: string[] };
|
|
636
|
-
// $pull: {
|
|
637
|
-
// includedInOfferCatalogItem: {
|
|
638
|
-
// $elemMatch: {
|
|
639
|
-
// /**
|
|
640
|
-
// * サブカタログID
|
|
641
|
-
// */
|
|
642
|
-
// id: { $eq: string };
|
|
643
|
-
// includedInDataCatalog: {
|
|
644
|
-
// /**
|
|
645
|
-
// * カタログID
|
|
646
|
-
// */
|
|
647
|
-
// id: { $eq: string };
|
|
648
|
-
// };
|
|
649
|
-
// };
|
|
650
|
-
// };
|
|
651
|
-
// };
|
|
652
|
-
// }) {
|
|
653
|
-
// const idNin = params.id?.$nin;
|
|
654
|
-
// await this.aggregateOfferModel.updateMany(
|
|
655
|
-
// {
|
|
656
|
-
// 'project.id': { $eq: params.project.id },
|
|
657
|
-
// 'offers.includedInOfferCatalogItem': {
|
|
658
|
-
// $elemMatch: {
|
|
659
|
-
// id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
|
|
660
|
-
// 'includedInDataCatalog.id': {
|
|
661
|
-
// $exists: true,
|
|
662
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
663
|
-
// }
|
|
664
|
-
// }
|
|
665
|
-
// },
|
|
666
|
-
// ...(Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined
|
|
667
|
-
// },
|
|
668
|
-
// {
|
|
669
|
-
// $pull: {
|
|
670
|
-
// 'offers.$[].includedInOfferCatalogItem': {
|
|
671
|
-
// id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
|
|
672
|
-
// 'includedInDataCatalog.id': {
|
|
673
|
-
// $exists: true,
|
|
674
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
675
|
-
// }
|
|
676
|
-
// }
|
|
677
|
-
// }
|
|
678
|
-
// }
|
|
679
|
-
// )
|
|
680
|
-
// .exec();
|
|
681
|
-
// }
|
|
682
|
-
/**
|
|
683
|
-
* カタログに属するサブカタログを全て除外する
|
|
684
|
-
*/
|
|
685
|
-
// public async pullIncludedInOfferCatalogItemByCatalogId(params: {
|
|
686
|
-
// project: { id: string };
|
|
687
|
-
// $pull: {
|
|
688
|
-
// includedInOfferCatalogItem: {
|
|
689
|
-
// $elemMatch: {
|
|
690
|
-
// /**
|
|
691
|
-
// * サブカタログID除外リスト
|
|
692
|
-
// */
|
|
693
|
-
// id?: { $nin: string[] };
|
|
694
|
-
// includedInDataCatalog: {
|
|
695
|
-
// /**
|
|
696
|
-
// * カタログID
|
|
697
|
-
// */
|
|
698
|
-
// id: { $eq: string };
|
|
699
|
-
// };
|
|
700
|
-
// };
|
|
701
|
-
// };
|
|
702
|
-
// };
|
|
703
|
-
// }) {
|
|
704
|
-
// const offerCatalogItemIdNin = params.$pull.includedInOfferCatalogItem.$elemMatch.id?.$nin;
|
|
705
|
-
// await this.aggregateOfferModel.updateMany(
|
|
706
|
-
// {
|
|
707
|
-
// 'project.id': { $eq: params.project.id },
|
|
708
|
-
// 'offers.includedInOfferCatalogItem': {
|
|
709
|
-
// $elemMatch: {
|
|
710
|
-
// 'includedInDataCatalog.id': {
|
|
711
|
-
// $exists: true,
|
|
712
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
713
|
-
// }
|
|
714
|
-
// }
|
|
715
|
-
// }
|
|
716
|
-
// },
|
|
717
|
-
// {
|
|
718
|
-
// $pull: {
|
|
719
|
-
// 'offers.$[].includedInOfferCatalogItem': {
|
|
720
|
-
// 'includedInDataCatalog.id': {
|
|
721
|
-
// $exists: true,
|
|
722
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
723
|
-
// },
|
|
724
|
-
// ...(Array.isArray(offerCatalogItemIdNin))
|
|
725
|
-
// ? { id: { $nin: offerCatalogItemIdNin } } // // 指定サブカタログを除外する
|
|
726
|
-
// : undefined
|
|
727
|
-
// }
|
|
728
|
-
// }
|
|
729
|
-
// }
|
|
730
|
-
// )
|
|
731
|
-
// .exec();
|
|
732
|
-
// }
|
|
733
|
-
/**
|
|
734
|
-
* サブカタログに属するサブカタログを全て除外する
|
|
735
|
-
*/
|
|
736
|
-
// public async pullIncludedInOfferCatalogItemByCatalogItemId(params: {
|
|
737
|
-
// project: { id: string };
|
|
738
|
-
// $pull: {
|
|
739
|
-
// includedInOfferCatalogItem: {
|
|
740
|
-
// $elemMatch: {
|
|
741
|
-
// /**
|
|
742
|
-
// * サブカタログID
|
|
743
|
-
// */
|
|
744
|
-
// id: { $eq: string };
|
|
745
|
-
// };
|
|
746
|
-
// };
|
|
747
|
-
// };
|
|
748
|
-
// }) {
|
|
749
|
-
// await this.aggregateOfferModel.updateMany(
|
|
750
|
-
// {
|
|
751
|
-
// 'project.id': { $eq: params.project.id },
|
|
752
|
-
// 'offers.includedInOfferCatalogItem': {
|
|
753
|
-
// $elemMatch: {
|
|
754
|
-
// id: {
|
|
755
|
-
// $exists: true,
|
|
756
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
|
|
757
|
-
// }
|
|
758
|
-
// }
|
|
759
|
-
// }
|
|
760
|
-
// },
|
|
761
|
-
// {
|
|
762
|
-
// $pull: {
|
|
763
|
-
// 'offers.$[].includedInOfferCatalogItem': {
|
|
764
|
-
// id: {
|
|
765
|
-
// $exists: true,
|
|
766
|
-
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
|
|
767
|
-
// }
|
|
768
|
-
// }
|
|
769
|
-
// }
|
|
770
|
-
// }
|
|
771
|
-
// )
|
|
772
|
-
// .exec();
|
|
773
|
-
// }
|
|
774
556
|
deleteById(params) {
|
|
775
557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
776
558
|
yield this.aggregateOfferModel.findOneAndRemove({
|
|
@@ -780,5 +562,19 @@ class MongoRepository {
|
|
|
780
562
|
.exec();
|
|
781
563
|
});
|
|
782
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* 単価オファー最適化作業における一時的な処理
|
|
567
|
+
*/
|
|
568
|
+
optimizeOffers() {
|
|
569
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
570
|
+
return this.aggregateOfferModel.updateMany({
|
|
571
|
+
$or: [
|
|
572
|
+
{ 'offers.id': { $exists: true } },
|
|
573
|
+
{ 'offers.project': { $exists: true } }
|
|
574
|
+
]
|
|
575
|
+
}, { $set: {} })
|
|
576
|
+
.exec();
|
|
577
|
+
});
|
|
578
|
+
}
|
|
783
579
|
}
|
|
784
580
|
exports.MongoRepository = MongoRepository;
|
|
@@ -52,14 +52,15 @@ const indexes = [
|
|
|
52
52
|
{ 'offers.priceSpecification.price': 1 },
|
|
53
53
|
{ name: 'searchByOffersPriceSpecificationPrice' }
|
|
54
54
|
],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
// ↓サブオファー最適化につき廃止(2023-12-22~)
|
|
56
|
+
// [
|
|
57
|
+
// // オファーIDはグローバルユニーク
|
|
58
|
+
// { 'offers.id': 1 },
|
|
59
|
+
// {
|
|
60
|
+
// name: 'uniqueOfferId',
|
|
61
|
+
// unique: true
|
|
62
|
+
// }
|
|
63
|
+
// ],
|
|
63
64
|
[
|
|
64
65
|
// オファーコードはプロジェクト内ユニーク
|
|
65
66
|
{ 'offers.identifier': 1, 'project.id': 1 },
|
|
@@ -152,7 +152,9 @@ export declare class MongoRepository {
|
|
|
152
152
|
}[]>;
|
|
153
153
|
count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
154
154
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<IUnitPriceOfferFromAggregateOffer[]>;
|
|
155
|
-
save(params: factory.unitPriceOffer.IUnitPriceOffer & {}): Promise<
|
|
155
|
+
save(params: factory.unitPriceOffer.IUnitPriceOffer & {}): Promise<{
|
|
156
|
+
id: string;
|
|
157
|
+
}>;
|
|
156
158
|
/**
|
|
157
159
|
* コードをキーにして冪等置換(2023-12-13~)
|
|
158
160
|
*/
|
|
@@ -167,7 +169,10 @@ export declare class MongoRepository {
|
|
|
167
169
|
* sskts専用オファー保管
|
|
168
170
|
*/
|
|
169
171
|
saveManyByIdentifier(params: {
|
|
170
|
-
|
|
172
|
+
project: {
|
|
173
|
+
id: string;
|
|
174
|
+
};
|
|
175
|
+
attributes: factory.aggregateOffer.ISubOffer;
|
|
171
176
|
upsert?: boolean;
|
|
172
177
|
}[]): Promise<void>;
|
|
173
178
|
/**
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -74,13 +74,15 @@ class MongoRepository {
|
|
|
74
74
|
const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
75
75
|
if (typeof idEq === 'string') {
|
|
76
76
|
matchStages.push({
|
|
77
|
-
$match: { 'offers.id': { $eq: idEq } }
|
|
77
|
+
// $match: { 'offers.id': { $eq: idEq } }
|
|
78
|
+
$match: { _id: { $eq: idEq } } // _idに変更(2023-12-22~)
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
|
|
81
82
|
if (Array.isArray(idIn)) {
|
|
82
83
|
matchStages.push({
|
|
83
|
-
$match: { 'offers.id': { $in: idIn } }
|
|
84
|
+
// $match: { 'offers.id': { $in: idIn } }
|
|
85
|
+
$match: { _id: { $in: idIn } } // _idに変更(2023-12-22~)
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
@@ -468,7 +470,12 @@ class MongoRepository {
|
|
|
468
470
|
positiveProjectionFields.forEach((field) => {
|
|
469
471
|
// idは上書きしない(2023-12-14~)
|
|
470
472
|
if (field !== 'id') {
|
|
471
|
-
|
|
473
|
+
if (field === 'project') {
|
|
474
|
+
projectStage[field] = `$project`;
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
projectStage[field] = `$offers.${field}`;
|
|
478
|
+
}
|
|
472
479
|
}
|
|
473
480
|
});
|
|
474
481
|
}
|
|
@@ -517,7 +524,10 @@ class MongoRepository {
|
|
|
517
524
|
}
|
|
518
525
|
// 解釈を集計オファーIDに変更する必要がある(2023-09-11~)
|
|
519
526
|
// 単価オファーIDリスト→集計オファーIDに変換→カタログ条件にセット
|
|
520
|
-
const aggregateOfferIds = yield this.aggregateOfferModel.distinct('_id',
|
|
527
|
+
const aggregateOfferIds = yield this.aggregateOfferModel.distinct('_id',
|
|
528
|
+
// { 'offers.id': { $in: params.ids } }
|
|
529
|
+
{ _id: { $in: params.ids } } // _idに変更(2023-12-22~)
|
|
530
|
+
)
|
|
521
531
|
.exec();
|
|
522
532
|
if (aggregateOfferIds.length === 0) {
|
|
523
533
|
throw new factory.errors.NotFound(factory.offerType.AggregateOffer);
|
|
@@ -765,13 +775,17 @@ class MongoRepository {
|
|
|
765
775
|
save(params) {
|
|
766
776
|
return __awaiter(this, void 0, void 0, function* () {
|
|
767
777
|
let doc;
|
|
778
|
+
let aggregateOfferId;
|
|
768
779
|
// const { $unset, ...paramsWithoutUnset } = params;
|
|
769
780
|
const paramsWithoutUnset = __rest(params, []);
|
|
770
|
-
let savedUnitPriceOffer;
|
|
771
|
-
if (params.id
|
|
781
|
+
// let savedUnitPriceOffer: factory.unitPriceOffer.IUnitPriceOffer;
|
|
782
|
+
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
772
783
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
773
784
|
const id = uniqid();
|
|
774
|
-
|
|
785
|
+
aggregateOfferId = id;
|
|
786
|
+
// サブオファー最適化(2023-12-22~)
|
|
787
|
+
// savedUnitPriceOffer = { ...paramsWithoutUnset, id };
|
|
788
|
+
const { project } = paramsWithoutUnset, savedUnitPriceOffer = __rest(paramsWithoutUnset, ["project"]);
|
|
775
789
|
const aggregateOffer = {
|
|
776
790
|
typeOf: factory.offerType.AggregateOffer,
|
|
777
791
|
project: params.project,
|
|
@@ -780,6 +794,7 @@ class MongoRepository {
|
|
|
780
794
|
doc = yield this.aggregateOfferModel.create(Object.assign(Object.assign({}, aggregateOffer), { _id: id }));
|
|
781
795
|
}
|
|
782
796
|
else {
|
|
797
|
+
aggregateOfferId = params.id;
|
|
783
798
|
const unitPriceOffers = yield this.search({
|
|
784
799
|
limit: 1,
|
|
785
800
|
page: 1,
|
|
@@ -792,24 +807,34 @@ class MongoRepository {
|
|
|
792
807
|
}
|
|
793
808
|
// 上書き禁止属性を除外
|
|
794
809
|
const { id, identifier, project, typeOf } = paramsWithoutUnset, updateFields = __rest(paramsWithoutUnset, ["id", "identifier", "project", "typeOf"]);
|
|
795
|
-
|
|
796
|
-
|
|
810
|
+
// サブオファー最適化(2023-12-22~)
|
|
811
|
+
const subOffer = Object.assign(Object.assign({}, updateFields), {
|
|
812
|
+
// id: originalUnitPriceOffer.id,
|
|
813
|
+
identifier: originalUnitPriceOffer.identifier,
|
|
814
|
+
// project: originalUnitPriceOffer.project,
|
|
815
|
+
typeOf: originalUnitPriceOffer.typeOf });
|
|
816
|
+
doc = yield this.aggregateOfferModel.findOneAndUpdate(
|
|
817
|
+
// { 'offers.id': params.id },
|
|
818
|
+
{ _id: params.id }, // _idに変更(2023-12-22~)
|
|
819
|
+
{
|
|
797
820
|
$set: {
|
|
798
|
-
'offers.$[offer]': savedUnitPriceOffer
|
|
821
|
+
// 'offers.$[offer]': savedUnitPriceOffer
|
|
822
|
+
'offers.0': subOffer // _idに変更(2023-12-22~)
|
|
799
823
|
}
|
|
800
824
|
}, {
|
|
801
825
|
upsert: false,
|
|
802
|
-
new: true
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
826
|
+
new: true
|
|
827
|
+
// _idに変更(2023-12-22~)
|
|
828
|
+
// arrayFilters: [
|
|
829
|
+
// { 'offer.id': { $eq: params.id } }
|
|
830
|
+
// ]
|
|
806
831
|
})
|
|
807
832
|
.exec();
|
|
808
833
|
}
|
|
809
834
|
if (doc === null) {
|
|
810
835
|
throw new factory.errors.NotFound(this.aggregateOfferModel.modelName);
|
|
811
836
|
}
|
|
812
|
-
return
|
|
837
|
+
return { id: aggregateOfferId };
|
|
813
838
|
});
|
|
814
839
|
}
|
|
815
840
|
/**
|
|
@@ -837,11 +862,13 @@ class MongoRepository {
|
|
|
837
862
|
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
838
863
|
});
|
|
839
864
|
const newOfferId = uniqid(); // setOnInsert時のみに利用する新ID
|
|
840
|
-
|
|
865
|
+
// サブオファー最適化(2023-12-22~)
|
|
866
|
+
// const subOffer: factory.aggregateOffer.ISubOffer = { ...p, id: newOfferId };
|
|
867
|
+
const { project } = p, subOffer = __rest(p, ["project"]);
|
|
841
868
|
const aggregateOffer = {
|
|
842
869
|
project: p.project,
|
|
843
870
|
typeOf: factory.offerType.AggregateOffer,
|
|
844
|
-
offers: [
|
|
871
|
+
offers: [subOffer]
|
|
845
872
|
};
|
|
846
873
|
const setOnInsert = Object.assign(Object.assign({}, aggregateOffer), { _id: newOfferId });
|
|
847
874
|
const updateFilter = { $setOnInsert: setOnInsert };
|
|
@@ -870,9 +897,11 @@ class MongoRepository {
|
|
|
870
897
|
'project.id': { $eq: p.project.id },
|
|
871
898
|
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
872
899
|
};
|
|
873
|
-
|
|
900
|
+
// サブオファー最適化(2023-12-22~)
|
|
901
|
+
// const unitPriceOffer: factory.unitPriceOffer.IUnitPriceOffer = { ...p, id: originalAggregateOffer.id };
|
|
902
|
+
const { project } = p, subOffer = __rest(p, ["project"]);
|
|
874
903
|
const setOnUpdate = {
|
|
875
|
-
'offers.0':
|
|
904
|
+
'offers.0': subOffer
|
|
876
905
|
};
|
|
877
906
|
const updateOne = {
|
|
878
907
|
filter,
|
|
@@ -900,16 +929,18 @@ class MongoRepository {
|
|
|
900
929
|
if (Array.isArray(params)) {
|
|
901
930
|
params.forEach((p) => {
|
|
902
931
|
const newOfferId = uniqid();
|
|
903
|
-
|
|
932
|
+
// サブオファー最適化(2023-12-22~)
|
|
933
|
+
// const unitPriceOffer: factory.aggregateOffer.ISubOffer = { ...p.attributes, id: newOfferId };
|
|
934
|
+
const subOffer = Object.assign({}, p.attributes);
|
|
904
935
|
const aggregateOffer = {
|
|
905
|
-
project: p.
|
|
936
|
+
project: { id: p.project.id, typeOf: factory.organizationType.Project },
|
|
906
937
|
typeOf: factory.offerType.AggregateOffer,
|
|
907
|
-
offers: [
|
|
938
|
+
offers: [subOffer]
|
|
908
939
|
};
|
|
909
940
|
insertBulkWriteOps.push({
|
|
910
941
|
updateOne: {
|
|
911
942
|
filter: {
|
|
912
|
-
'project.id': { $eq: p.
|
|
943
|
+
'project.id': { $eq: p.project.id },
|
|
913
944
|
'offers.identifier': { $exists: true, $eq: p.attributes.identifier }
|
|
914
945
|
},
|
|
915
946
|
update: {
|
|
@@ -918,12 +949,12 @@ class MongoRepository {
|
|
|
918
949
|
upsert: true
|
|
919
950
|
}
|
|
920
951
|
});
|
|
921
|
-
const
|
|
952
|
+
const $set = __rest(subOffer, []);
|
|
922
953
|
updateBulkWriteOps.push({
|
|
923
954
|
updateOne: {
|
|
924
955
|
filter: {
|
|
925
|
-
'project.id': { $eq:
|
|
926
|
-
'offers.identifier': { $exists: true, $eq:
|
|
956
|
+
'project.id': { $eq: aggregateOffer.project.id },
|
|
957
|
+
'offers.identifier': { $exists: true, $eq: subOffer.identifier }
|
|
927
958
|
},
|
|
928
959
|
update: {
|
|
929
960
|
// 特定の属性のみ更新する(IDを上書きできないので)
|
|
@@ -37,12 +37,9 @@ export declare function responseBody2acceptedOffers4result(params: {
|
|
|
37
37
|
seller: factory.transaction.placeOrder.ISeller;
|
|
38
38
|
}): IResultAcceptedOffer[];
|
|
39
39
|
export declare function coaTicket2offer(params: {
|
|
40
|
-
project: {
|
|
41
|
-
id: string;
|
|
42
|
-
};
|
|
43
40
|
theaterCode: string;
|
|
44
41
|
ticketResult: COA.factory.master.ITicketResult;
|
|
45
42
|
defaultCurrencyType?: factory.categoryCode.ICategoryCode;
|
|
46
43
|
defaultMembershipType?: factory.categoryCode.ICategoryCode;
|
|
47
|
-
}):
|
|
44
|
+
}): factory.aggregateOffer.ISubOffer;
|
|
48
45
|
export {};
|
|
@@ -340,7 +340,9 @@ function coaTicket2offer(params) {
|
|
|
340
340
|
? params.ticketResult.ticketNameEng
|
|
341
341
|
: ''
|
|
342
342
|
};
|
|
343
|
-
return Object.assign(Object.assign(Object.assign({
|
|
343
|
+
return Object.assign(Object.assign(Object.assign({
|
|
344
|
+
// project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
345
|
+
typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY,
|
|
344
346
|
// id: '',
|
|
345
347
|
identifier: identifier, name: offerName, description: {
|
|
346
348
|
ja: '',
|
|
@@ -34,13 +34,13 @@ function importFromCOA(params) {
|
|
|
34
34
|
const ticketResults = yield repos.masterService.ticket({ theaterCode: params.theaterCode });
|
|
35
35
|
const saveParams = ticketResults.map((ticketResult) => {
|
|
36
36
|
const offer = (0, factory_1.coaTicket2offer)({
|
|
37
|
-
project: params.project,
|
|
37
|
+
// project: params.project,
|
|
38
38
|
theaterCode: params.theaterCode,
|
|
39
39
|
ticketResult: ticketResult,
|
|
40
40
|
defaultCurrencyType,
|
|
41
41
|
defaultMembershipType
|
|
42
42
|
});
|
|
43
|
-
return { attributes: offer, upsert: true };
|
|
43
|
+
return { attributes: offer, upsert: true, project: { id: params.project.id } };
|
|
44
44
|
});
|
|
45
45
|
yield repos.offer.saveManyByIdentifier(saveParams);
|
|
46
46
|
}
|
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.348.0-alpha.0",
|
|
14
14
|
"@cinerino/sdk": "5.5.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.2.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.
|
|
118
|
+
"version": "21.19.0-alpha.1"
|
|
119
119
|
}
|